Solved

How to create a CompositeType and CompositeData for Mbean operation?

Posted on 2014-04-02
2
818 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

Industry Leaders: 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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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 …

740 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