Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
2.  Creating JavaBeans Using the MOF Compiler Generating JavaBeans Example  Previous   Contents   Next 
   
 

Following is the content of Simple_ClassBean.java:

package foo.com;

import javax.wbem.client.*;
import javax.wbem.cim.*;
import java.util.*;
import java.lang.Exception;

/**
 * This Interface contains accessor and mutator methods for all 
 * properties defined in CIM class Simple_Class as well as methods 
 * comparable to the invokeMethods defined for this class. This Interface 
 * is implemented by Simple_ClassBeanImpl. The CIM class Simple_Class is 
 * described as follows: 
 */
public interface Simple_ClassBean extends CIMBean {

    /**
     * This method returns the Simple_Class.Name property value. This 
     * property is described as follows: 
     * 
     * Name of the class.
     * 
     * @return	String	current Name property value
     * @exception	Exception	
     */
    public String getName() throws Exception;

    /**
     * This method sets the Simple_Class.Name property value. This 
     * property is described as follows: 
     * 
     * Name of the class.
     * 
     * @param	String	new Name property value
     * @exception	Exception	
     */
    public void setName(String name) throws Exception;


    /**
     * This method invokes the Simple_Class.printClass() method. This 
     * method is described as follows: 
     * 
     * Method to print the contents of the class.
     * 
     * @return	String	return value of printClass() invokation
     * @exception	Exception	
     */
    public String printClass() throws Exception, CIMException;

} // Interface Simple_ClassBean

Following is the content of Simple_ClassBeanImpl.java:

package foo.com;

import javax.wbem.client.*;
import javax.wbem.cim.*;
import java.util.*;
import java.lang.Exception;

/**
 * This Class contains accessor and mutator methods for all properties 
 * defined in the CIM class Simple_Class as well as methods comparable 
 * to the invokeMethods defined for this class. This Class implements 
 * the Simple_ClassBean Interface. The CIM class Simple_Class is 
 * described as follows: 
 */
public class Simple_ClassBeanImpl extends CIMBeanImpl implements 
    Simple_ClassBean {

     private CIMOMHandle cimomHandle = null;
    private CIMInstance cimInstance = null;
    private final static String[] keysArr = {"Name"};

    /**
     * This constructor creates a Simple_ClassBeanImpl Class which 
     * implements the Simple_ClassBean Interface, and encapsulates the 
     * CIM class Simple_Class in a Java Bean. The CIM class Simple_Class 
     * is described as follows: 
     * 
     * @param	CIMOMHandle	handle to the CIMOM
     * @param	CIMInstance	handle to the CIMInstance being managed
     */
    public Simple_ClassBeanImpl(CIMOMHandle handle, CIMInstance instance) 
	{

 	super(handle, instance);

	this.cimomHandle = handle;
	this.cimInstance = instance;

    } // constructor

    /**
     * This method returns an array of Strings with the names of the key 
     * qualified properties defined for the CIM class. This method is 
     * used to build the CIMObjectPath of the CIMInstance managed by 
     * the Bean in the case that the key qualifiers are not included 
     * in the CIMInstance. 
     * 
     * @return	String[]	array of the key qualified property names
     */
    public String[] getBeanKeys() {

	return keysArr;

    } // getBeanKeys

    /**
     * This method returns the Simple_Class.Name property value. This 
     * property is described as follows: 
     * 
     * Name of the class.
     * 
     * @return	String	current Name property value
     * @exception	Exception	
     */
    public String getName() throws Exception {

	return (String)getProperty("Name");

    } // getName

    /**
     * This method sets the Simple_Class.Name property value. This 
     * property is described as follows: 
     * 
     * Name of the class.
     * 
     * @param	String	new Name property value
     * @exception	Exception	
     */
    public void setName(String name) throws Exception {

	setProperty("Name", name);

    } // setName


    /**
     * This method invokes the Simple_Class.printClass() method. This 
     * method is described as follows: 
     * 
     * Method to print the contents of the class.
     * 
     * @return	String	return value of printClass() invokation
     * @exception	Exception	
     */
    public String printClass() throws Exception, CIMException {

	Vector vInParams = new Vector();
	Vector vOutParams = new Vector();

	CIMValue cv = cimomHandle.invokeMethod(cimInstance.getObjectPath(), 
 "printClass", vInParams, vOutParams);
	return (String)cv.getValue();

    } // printClass
} // Class Simple_ClassBeanImpl

 
 
 
  Previous   Contents   Next