Thread: [Ejtools-cvs] CVS: applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model Server
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-04-22 17:59:51
|
Update of /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model In directory usw-pr-cvs1:/tmp/cvs-serv30470/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model Added Files: Server.java Log Message: Initial Import --- NEW FILE: Server.java --- package net.sourceforge.ejtools.jmxbrowser.model; import java.awt.*; import java.beans.*; import java.beans.beancontext.*; import java.io.*; import java.util.*; import javax.management.*; import javax.naming.*; import javax.swing.*; import org.w3c.dom.*; import com.dreambean.awt.*; import com.dreambean.awt.editors.*; import net.sourceforge.ejtools.util.JNDI; import net.sourceforge.ejtools.xml.*; import net.sourceforge.ejtools.xml.beans.*; import org.jboss.jmx.adaptor.interfaces.Adaptor; import org.jboss.jmx.adaptor.interfaces.AdaptorHome; /** * Description of the Class * * @author letiembl * @created 13 décembre 2001 */ public class Server extends Node implements BeanContextXmlProxy { /** Description of the Field */ protected int count = 0; /** Description of the Field */ protected String defaultDomain = ""; /** Description of the Field */ 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 pkgs = "org.jboss.naming:org.jnp.interfaces"; /** Description of the Field */ protected String url = "localhost:1099"; /** Description of the Field */ protected transient XmlComponent xc = null; /** Constructor for the Server object */ public Server() { this.setName("JMX Server"); JNDI.setJNDIProperties(); if (System.getProperty(Context.INITIAL_CONTEXT_FACTORY) != null) { this.factory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY); } if (System.getProperty(Context.URL_PKG_PREFIXES) != null) { this.pkgs = System.getProperty(Context.URL_PKG_PREFIXES); } if (System.getProperty(Context.PROVIDER_URL) != null) { this.url = System.getProperty(Context.PROVIDER_URL); } } public String getSmallIcon(){ return "Server16.gif"; } public XmlComponent getXmlProxy() { if (xc == null) { xc = new GenericXmlCustomizer(this); } return xc; } /** Description of the Method */ public void connect() { BeanContextServices context = (BeanContextServices) getBeanContext(); if (context.hasService(ConnectionService.class)) { try { ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this); service.setFactory(this.factory); service.setPackages(this.pkgs); service.setURL(this.url); service.setEJBName(this.ejbName); this.setDefaultDomain(service.getDefaultDomain()); this.setCount(service.getMBeanCount().intValue()); Collection mbeans = service.queryMBeans(null, null); Vector resources = new Vector(); Iterator it = mbeans.iterator(); while (it.hasNext()) { ObjectInstance oi = (ObjectInstance) it.next(); String name = oi.getObjectName().getDomain(); Domain d = (Domain) this.domains.get(name); if (d == null) { d = new Domain(); d.setName(oi.getObjectName().getDomain()); resources.add(d); this.domains.put(name, d); } Resource resource = new Resource(); d.add(resource); resource.setReference(oi); } it = resources.iterator(); while (it.hasNext()) { add(it.next()); } context.releaseService(this, this, ConnectionService.class); } catch (Exception e) { System.out.println("Error during utilisation of service ConnectionService (" + e.getMessage() + ")"); e.printStackTrace(); } } } /** Description of the Method */ public void disconnect() { } /** * Getter for the count attribute * * @return The value */ public int getCount() { return count; } /** * Getter for the defaultDomain attribute * * @return The value */ public String getDefaultDomain() { return defaultDomain; } /** * Getter for the ejbName attribute * * @return The value */ public String getEJBName() { return ejbName; } /** * Gets the factory attribute of the Server object * * @return The factory value */ public String getFactory() { return this.factory; } /** * Gets the packages attribute of the Server object * * @return The packages value */ public String getPackages() { return this.pkgs; } /** * Gets the url attribute of the Server object * * @return The url value */ public String getURL() { return this.url; } /** * Setter for the ejbName attribute * * @param ejbName The new value */ public void setEJBName(String ejbName) { this.ejbName = ejbName; } /** * Sets the factory attribute of the Server object * * @param factory The new factory value */ public void setFactory(String factory) { this.factory = factory; } /** * Sets the packages attribute of the Server object * * @param pkgs The new packages value */ public void setPackages(String pkgs) { this.pkgs = pkgs; } /** * Sets the url attribute of the Server object * * @param url The new url value */ public void setURL(String url) { this.url = url; } /** * Setter for the mBeanCount attribute * * @param count The new value */ protected void setCount(int count) { int oldCount = this.count; this.count = count; firePropertyChange("count", new Integer(oldCount), new Integer(count)); } /** * Setter for the defaultDomain attribute * * @param defaultDomain The new value */ protected void setDefaultDomain(String defaultDomain) { String oldDomain = this.defaultDomain; this.defaultDomain = defaultDomain; firePropertyChange("defaultDomain", oldDomain, defaultDomain); } } |