Solved

How to create a CompositeType and CompositeData for Mbean operation?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now