Solved

How to create a CompositeType and CompositeData for Mbean operation?

Posted on 2014-04-02
2
845 Views
Last Modified: 2014-05-06
I googled but can't find any good example for creating the CompositeData object to pass it as a parameter to the MBean operation.

Can you help?

Say, I have a Person class

Person class {String name;int age; boolean married;}

interface PersonDao {
public int addPerson(Person p);
}

PersonDaoImpl class implements PersonDao {
public int addPerson(Person p);
}


MBean
public int addPerson(Person person) {
String[] sig = { String.class.getName(),
Integer.class.getName(), Boolean.class.getName(),
};
Object[] arg = { person.getName(),new Integer(person.getAge()),
Boolean.valueOf(Person.IsMarried};

int rowNo = (int) server.invoke(name, "addPerson", arg, sig);

}

Here I cannot pass person as object.
So I have to pass it as primitive data type.


How can I create a CompositeType as Person class and CompositeData?

  private static String[] itemNames = {"name", "age", "married"};
private static String[] itemDescriptions = {"Full Name", "Age", "Married or not"};
  private static OpenType[] itemTypes = {SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN};
    private static CompositeType personType = null;

 personType = new CompositeType("person",
                                    "a Person",
                                itemNames,
                                   itemDescriptions,
                                  itemTypes);


How do I use the CompositeDat in my invoke method?

MBean
public int addPerson(Person person) {
String[] sig = { String.class.getName(),
Integer.class.getName(), Boolean.class.getName(),
};
Object[] arg = { person.getName(),new Integer(person.getAge()),
Boolean.valueOf(Person.IsMarried};

int rowNo = (int) server.invoke(name, "addPerson", arg, sig);

}
0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
sanjooz earned 500 total points
ID: 39989614
Here is an example. Scroll down to Example 2-11

http://docs.oracle.com/cd/E19159-01/819-7758/gcitp/index.html
0
 

Author Comment

by:dkim18
ID: 39990229
Already saw that.

That doesnot show much other than invoke method returning a result set and casting using compositedata.

I am looking for an example or something explaining 1) how CustomInfo was inserted into compositetype object back in the mbean method ans 2) how to pass CustomInfo object as compositedata type to mbean method.

I looked and looked but can't find any example.

Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
spring maven example issues 3 104
Java Inheritance super keyword use 8 72
Session in java desktop 5 37
JVM error from eclipse 1 26
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question