Thread: [Ejtools-cvs] CVS: applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model Connec
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-04-28 19:38:14
|
Update of /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model In directory usw-pr-cvs1:/tmp/cvs-serv16586/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model Modified Files: ConnectionService.java EJBConnectionService.java LocalConnectionService.java RMIConnectionService.java Resource.java Server.java Log Message: Add access to createMBean and to unregisterMBean Index: ConnectionService.java =================================================================== RCS file: /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model/ConnectionService.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConnectionService.java 22 Apr 2002 17:38:42 -0000 1.1 --- ConnectionService.java 28 Apr 2002 13:05:44 -0000 1.2 *************** *** 1,8 **** package net.sourceforge.ejtools.jmxbrowser.model; - import java.util.Set; import java.io.Serializable; import javax.management.Attribute; import javax.management.MBeanInfo; import javax.management.ObjectName; import javax.management.QueryExp; --- 1,9 ---- package net.sourceforge.ejtools.jmxbrowser.model; import java.io.Serializable; + import java.util.Set; import javax.management.Attribute; import javax.management.MBeanInfo; + import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.QueryExp; *************** *** 18,41 **** --- 19,147 ---- public interface ConnectionService extends Serializable { + /** + * Gets the attribute attribute of the ConnectionService object + * + * @param name Description of the Parameter + * @param attribute Description of the Parameter + * @return The attribute value + * @exception Exception Description of the Exception + */ public Object getAttribute(ObjectName name, String attribute) throws Exception; + + /** + * Gets the defaultDomain attribute of the ConnectionService object + * + * @return The defaultDomain value + * @exception Exception Description of the Exception + */ public String getDefaultDomain() throws Exception; + + /** + * Gets the mBeanCount attribute of the ConnectionService object + * + * @return The mBeanCount value + * @exception Exception Description of the Exception + */ public Integer getMBeanCount() throws Exception; + + /** + * Gets the mBeanInfo attribute of the ConnectionService object + * + * @param name Description of the Parameter + * @return The mBeanInfo value + * @exception Exception Description of the Exception + */ public MBeanInfo getMBeanInfo(ObjectName name) throws Exception; + + /** + * Description of the Method + * + * @param name Description of the Parameter + * @param action Description of the Parameter + * @param params Description of the Parameter + * @param signatures Description of the Parameter + * @return Description of the Return Value + * @exception Exception Description of the Exception + */ public Object invoke(ObjectName name, String action, Object[] params, String[] signatures) throws Exception; + + /** + * Description of the Method + * + * @param name Description of the Parameter + * @param exp Description of the Parameter + * @return Description of the Return Value + * @exception Exception Description of the Exception + */ public Set queryMBeans(ObjectName name, QueryExp exp) throws Exception; + + /** + * Sets the attribute attribute of the ConnectionService object + * + * @param name The new attribute value + * @param attribute The new attribute value + * @exception Exception Description of the Exception + */ public void setAttribute(ObjectName name, Attribute attribute) throws Exception; + + /** + * Description of the Method + * + * @param className Description of the Parameter + * @param name Description of the Parameter + * @param loaderName Description of the Parameter + * @param params Description of the Parameter + * @param signature Description of the Parameter + * @return Description of the Return Value + * @exception Exception Description of the Exception + */ + public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws Exception; + + + /** + * Description of the Method + * + * @param name Description of the Parameter + * @exception Exception Description of the Exception + */ + public void unregisterMBean(ObjectName name) throws Exception; + + + /** + * Sets the eJBName attribute of the ConnectionService object + * + * @param ejbName The new eJBName value + */ public void setEJBName(String ejbName); + + /** + * Sets the factory attribute of the ConnectionService object + * + * @param factory The new factory value + */ public void setFactory(String factory); + + /** + * Sets the packages attribute of the ConnectionService object + * + * @param pkgs The new packages value + */ public void setPackages(String pkgs); + + /** + * Sets the uRL attribute of the ConnectionService object + * + * @param url The new uRL value + */ public void setURL(String url); } Index: EJBConnectionService.java =================================================================== RCS file: /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model/EJBConnectionService.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EJBConnectionService.java 22 Apr 2002 17:38:59 -0000 1.1 --- EJBConnectionService.java 28 Apr 2002 13:05:44 -0000 1.2 *************** *** 4,7 **** --- 4,8 ---- import javax.management.Attribute; import javax.management.MBeanInfo; + import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.QueryExp; *************** *** 37,40 **** --- 38,58 ---- /** + * Description of the Method + * + * @param className Description of the Parameter + * @param name Description of the Parameter + * @param loaderName Description of the Parameter + * @param params Description of the Parameter + * @param signature Description of the Parameter + * @return Description of the Return Value + * @exception Exception Description of the Exception + */ + public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws Exception + { + return getConnector().createMBean(className, name, loaderName, params, signature); + } + + + /** * Getter for the attribute attribute * *************** *** 181,184 **** --- 199,214 ---- * Description of the Method * + * @param name Description of the Parameter + * @exception Exception Description of the Exception + */ + public void unregisterMBean(ObjectName name) throws Exception + { + getConnector().unregisterMBean(name); + } + + + /** + * Description of the Method + * * @return Description of the Returned Value * @exception Exception Description of Exception *************** *** 188,194 **** if (connector == null) { ! InitialContext context = new InitialContext(); ! Object ref = context.lookup(this.ejbName); ! AdaptorHome home = (AdaptorHome) PortableRemoteObject.narrow(ref, AdaptorHome.class); connector = home.create(); --- 218,224 ---- if (connector == null) { ! InitialContext context = new InitialContext(); ! Object ref = context.lookup(this.ejbName); ! AdaptorHome home = (AdaptorHome) PortableRemoteObject.narrow(ref, AdaptorHome.class); connector = home.create(); *************** *** 197,198 **** --- 227,229 ---- } } + Index: LocalConnectionService.java =================================================================== RCS file: /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model/LocalConnectionService.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LocalConnectionService.java 22 Apr 2002 17:39:59 -0000 1.1 --- LocalConnectionService.java 28 Apr 2002 13:05:44 -0000 1.2 *************** *** 3,10 **** import java.util.ArrayList; import java.util.Set; - import javax.management.MBeanServer; - import javax.management.MBeanServerFactory; import javax.management.Attribute; import javax.management.MBeanInfo; import javax.management.ObjectName; import javax.management.QueryExp; --- 3,11 ---- import java.util.ArrayList; import java.util.Set; import javax.management.Attribute; import javax.management.MBeanInfo; + import javax.management.MBeanServer; + import javax.management.MBeanServerFactory; + import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.QueryExp; *************** *** 39,42 **** --- 40,60 ---- /** + * Description of the Method + * + * @param className Description of the Parameter + * @param name Description of the Parameter + * @param loaderName Description of the Parameter + * @param params Description of the Parameter + * @param signature Description of the Parameter + * @return Description of the Return Value + * @exception Exception Description of the Exception + */ + public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws Exception + { + return getConnector().createMBean(className, name, loaderName, params, signature); + } + + + /** * Getter for the attribute attribute * *************** *** 183,186 **** --- 201,216 ---- * Description of the Method * + * @param name Description of the Parameter + * @exception Exception Description of the Exception + */ + public void unregisterMBean(ObjectName name) throws Exception + { + getConnector().unregisterMBean(name); + } + + + /** + * Description of the Method + * * @return Description of the Returned Value * @exception Exception Description of Exception *************** *** 190,197 **** if (connector == null) { ! ArrayList servers = MBeanServerFactory.findMBeanServer(null); ! if (servers == null) ! throw new Exception("No MBeanServer found."); ! connector = (MBeanServer)servers.get(0); } --- 220,229 ---- if (connector == null) { ! ArrayList servers = MBeanServerFactory.findMBeanServer(null); ! if (servers == null) ! { ! throw new Exception("No MBeanServer found."); ! } ! connector = (MBeanServer) servers.get(0); } Index: RMIConnectionService.java =================================================================== RCS file: /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model/RMIConnectionService.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RMIConnectionService.java 22 Apr 2002 17:41:20 -0000 1.1 --- RMIConnectionService.java 28 Apr 2002 13:05:44 -0000 1.2 *************** *** 4,7 **** --- 4,8 ---- import javax.management.Attribute; import javax.management.MBeanInfo; + import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.QueryExp; *************** *** 36,39 **** --- 37,57 ---- /** + * Description of the Method + * + * @param className Description of the Parameter + * @param name Description of the Parameter + * @param loaderName Description of the Parameter + * @param params Description of the Parameter + * @param signature Description of the Parameter + * @return Description of the Return Value + * @exception Exception Description of the Exception + */ + public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws Exception + { + return getConnector().createMBean(className, name, loaderName, params, signature); + } + + + /** * Getter for the attribute attribute * *************** *** 180,183 **** --- 198,213 ---- * Description of the Method * + * @param name Description of the Parameter + * @exception Exception Description of the Exception + */ + public void unregisterMBean(ObjectName name) throws Exception + { + getConnector().unregisterMBean(name); + } + + + /** + * Description of the Method + * * @return Description of the Returned Value * @exception Exception Description of Exception *************** *** 187,193 **** if (connector == null) { ! InitialContext context = new InitialContext(); ! Object ref = context.lookup(this.ejbName); ! connector = (RMIAdaptor) PortableRemoteObject.narrow(ref, RMIAdaptor.class); } return connector; --- 217,223 ---- if (connector == null) { ! InitialContext context = new InitialContext(); ! Object ref = context.lookup(this.ejbName); ! connector = (RMIAdaptor) PortableRemoteObject.narrow(ref, RMIAdaptor.class); } return connector; Index: Resource.java =================================================================== RCS file: /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model/Resource.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Resource.java 24 Apr 2002 20:08:22 -0000 1.2 --- Resource.java 28 Apr 2002 13:05:44 -0000 1.3 *************** *** 42,45 **** --- 42,80 ---- public Resource() { } + + /** + * Description of the Method + * + * @param className Description of the Parameter + * @param name Description of the Parameter + * @param loaderName Description of the Parameter + * @param params Description of the Parameter + * @param signature Description of the Parameter + * @return Description of the Return Value + */ + public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) + { + BeanContextServices context = (BeanContextServices) getBeanContext(); + ObjectInstance result = null; + + if (context.hasService(ConnectionService.class)) + { + try + { + ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this); + + result = service.createMBean(className, name, loaderName, params, signature); + + context.releaseService(this, this, ConnectionService.class); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + return result; + } + + /** * Getter for the attribute attribute *************** *** 129,133 **** { // this.connector.addNotificationListener(this.objectName, updater, updater, null); ! c = new GenericMBeanCustomizer(true, this); } catch (Exception e) --- 164,168 ---- { // this.connector.addNotificationListener(this.objectName, updater, updater, null); ! c = new GenericMBeanCustomizer(this); } catch (Exception e) *************** *** 289,292 **** --- 324,354 ---- this.className = this.objectInstance.getClassName(); this.domain = this.objectName.getDomain(); + } + + + /** + * Description of the Method + * + * @param name Description of the Parameter + */ + public void unregisterMBean(ObjectName name) + { + BeanContextServices context = (BeanContextServices) getBeanContext(); + + if (context.hasService(ConnectionService.class)) + { + try + { + ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this); + + service.unregisterMBean(name); + + context.releaseService(this, this, ConnectionService.class); + } + catch (Exception e) + { + e.printStackTrace(); + } + } } Index: Server.java =================================================================== RCS file: /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model/Server.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Server.java 24 Apr 2002 20:08:22 -0000 1.2 --- Server.java 28 Apr 2002 13:05:44 -0000 1.3 *************** *** 34,48 **** protected Hashtable domains = new Hashtable(); /** Description of the Field */ - protected Hashtable mbeans = new Hashtable(); - /** Description of the Field */ protected String ejbName = "ejb/jmx/ejb/Adaptor"; /** Description of the Field */ protected String factory = "org.jnp.interfaces.NamingContextFactory"; /** Description of the Field */ protected String pkgs = "org.jboss.naming:org.jnp.interfaces"; /** Description of the Field */ protected String url = "localhost:1099"; - /** Description of the Field */ - protected String filter = "*:*"; --- 34,48 ---- protected Hashtable domains = new Hashtable(); /** Description of the Field */ protected String ejbName = "ejb/jmx/ejb/Adaptor"; /** Description of the Field */ protected String factory = "org.jnp.interfaces.NamingContextFactory"; /** Description of the Field */ + protected String filter = "*:*"; + /** Description of the Field */ + protected Hashtable mbeans = new Hashtable(); + /** Description of the Field */ protected String pkgs = "org.jboss.naming:org.jnp.interfaces"; /** Description of the Field */ protected String url = "localhost:1099"; *************** *** 68,79 **** } /** Description of the Method */ public void connect() { System.out.println("In connect"); ! this.clear(); ! this.domains.clear(); ! this.mbeans.clear(); BeanContextServices context = (BeanContextServices) getBeanContext(); --- 68,80 ---- } + /** Description of the Method */ public void connect() { System.out.println("In connect"); ! this.clear(); ! this.domains.clear(); ! this.mbeans.clear(); BeanContextServices context = (BeanContextServices) getBeanContext(); *************** *** 95,99 **** Collection result = service.queryMBeans(new ObjectName(filter), null); ! int counter = result.size(); Vector resources = new Vector(); --- 96,100 ---- Collection result = service.queryMBeans(new ObjectName(filter), null); ! int counter = result.size(); Vector resources = new Vector(); *************** *** 115,122 **** d.add(resource); resource.setReference(oi); ! this.mbeans.put(resource.getCanonicalName(), resource); } ! setCount(counter); it = resources.iterator(); --- 116,123 ---- d.add(resource); resource.setReference(oi); ! this.mbeans.put(resource.getCanonicalName(), resource); } ! setCount(counter); it = resources.iterator(); *************** *** 141,151 **** - public Object searchObjectName(String objectName) { - if (objectName!=null){ - return mbeans.get(objectName); - } - return null; - } - /** * Getter for the count attribute --- 142,145 ---- *************** *** 169,177 **** } - public String getFilter() - { - return filter; - } - /** --- 163,166 ---- *************** *** 198,201 **** --- 187,201 ---- /** + * Gets the filter attribute of the Server object + * + * @return The filter value + */ + public String getFilter() + { + return filter; + } + + + /** * Gets the packages attribute of the Server object * *************** *** 220,223 **** --- 220,239 ---- /** + * Description of the Method + * + * @param objectName Description of the Parameter + * @return Description of the Return Value + */ + public Object searchObjectName(String objectName) + { + if (objectName != null) + { + return mbeans.get(objectName); + } + return null; + } + + + /** * Setter for the ejbName attribute * *************** *** 229,237 **** } - public void setFilter(String filter) - { - this.filter = filter; - } - /** --- 245,248 ---- *************** *** 247,250 **** --- 258,272 ---- /** + * Sets the filter attribute of the Server object + * + * @param filter The new filter value + */ + public void setFilter(String filter) + { + this.filter = filter; + } + + + /** * Sets the packages attribute of the Server object * *************** *** 265,268 **** --- 287,300 ---- { this.url = url; + } + + + /** + * Description of the Method + * + * @param name Description of the Parameter + */ + public void unregisterMBean(ObjectName name) + { } |