Using MBean APIs to Manage an XML MetaData Cache
You can use the Configuration MBean APIs to create your own cache, and to add, get, and delete data from the cache. For more information on MBeans, see Programming Management Applications, at http://e-docs.bea.com/wli/docs70/devmgmt/manage.htm.
Retrieving the Singleton XMLCacheMBean
Use the following code to retrieve the singleton XMLCacheMBean:
Context ctx = new InitialContext();
MBeanHome home = (MBeanHome) ctx.lookup(MBeanHome.LOCAL_JNDI_NAME); (XMLCacheMBean) xmlCacheMBean = home.getMBean(XMLCacheMBean.SINGLETON_MBEAN_NAME, XMLCacheMBean.MBEAN_TYPE);
String key = "key1";
Using the Configuration MBean API
The Configuration MBean API provides the following methods to add an entry to, or to get or delete an entry from the XML MetaData Cache:
public XmlObject xmlObj = XmlObject.Factory.parse(new File(YourXmlFile)) //create an xmlObject
Use this method to create an XMLobject.
public xmlCacheMBean.add(key, xmlObj);
Use this method to add a key to the XML MetaData Cache.
public XmlObject xmlObject_get = xmlCacheMBean.get(key);
Use this method to get a key from the XML MetaData Cache.
public XmlObject newxmlObj = ..... //create another xmlObject
Use this method to create a new XMLObject.
public xmlCacheMBean.update(key,newxmlObj);
Use this method to update an XML MetaData Cache.
public xmlCacheMBean.delete(key);
Use this method to delete a key from the XML MetaData Cache.
public boolean keyExists = xmlCacheMBean.keyExists(key);
Use this method to find out if a particular key exists within the XML MetaData Cache.
public String[] allKeys = xmlCacheMBean.getAllKeys();
Use this method to get a list of all keys within the XML MetaData Cache.