Thread: [Ejtools-cvs] CVS: applications/management/src/main/net/sourceforge/ejtools/management/model Server.
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-04-22 17:59:45
|
Update of /cvsroot/ejtools/applications/management/src/main/net/sourceforge/ejtools/management/model In directory usw-pr-cvs1:/tmp/cvs-serv30601/management/src/main/net/sourceforge/ejtools/management/model Added Files: Server.java Log Message: Initial Import --- NEW FILE: Server.java --- package net.sourceforge.ejtools.management.model; import java.awt.*; import java.beans.*; import java.beans.beancontext.*; import java.io.*; import java.util.*; import java.util.Iterator; import java.util.Set; 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; /** * Description of the Class * * @author letiembl * @created 13 décembre 2001 */ public class Server extends Node { /** Description of the Field */ protected int count = 0; /** Description of the Field */ protected String defaultDomain = ""; /** Description of the Field */ protected String ejbName = "ejb/mgmt/MEJB"; /** 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"; /** Constructor for the Server object */ public Server() { this.setName("JSR77 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); } } /** Description of the Method */ public void connect() { Iterator iterator = iterator(); while (iterator.hasNext()) { remove(iterator.next()); } 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()); ObjectName query = new ObjectName(this.defaultDomain + ":*"); Set mbeans = service.queryNames(query, null); Vector resources = new Vector(); Iterator it = mbeans.iterator(); while (it.hasNext()) { ObjectName on = (ObjectName) it.next(); System.out.println("New Resource: " + on); Resource resource = new Resource(); resource.setReference(on); resources.add(resource); } context.releaseService(this, this, ConnectionService.class); createHierarchy(resources); it = resources.iterator(); while (it.hasNext()) { add(it.next()); } } 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); } } |