Thread: [Ejtools-cvs] CVS: applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model Resour
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-04-22 18:00:15
|
Update of /cvsroot/ejtools/applications/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model In directory usw-pr-cvs1:/tmp/cvs-serv30166/jmx.browser/src/main/net/sourceforge/ejtools/jmxbrowser/model Added Files: Resource.java Log Message: Initial Import --- NEW FILE: Resource.java --- package net.sourceforge.ejtools.jmxbrowser.model; import java.awt.*; import java.beans.*; import java.beans.beancontext.*; import java.lang.reflect.*; import java.util.*; import javax.management.*; import javax.naming.*; import javax.swing.*; import org.w3c.dom.*; import com.dreambean.awt.*; import net.sourceforge.ejtools.awt.*; import net.sourceforge.ejtools.jmx.MBeanAccessor; 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 Resource extends Node implements MBeanAccessor { /** Description of the Field */ protected String description; /** Description of the Field */ protected String domain; /** Description of the Field */ protected transient MBeanInfo info; /** Description of the Field */ protected transient ObjectInstance objectInstance; /** Description of the Field */ protected transient ObjectName objectName; /** Description of the Field */ protected transient ResourceUpdater updater; /** Constructor for the Resource object */ public Resource() { } public String getSmallIcon(){ return "EJBModule16.gif"; } /** * Getter for the attribute attribute * * @param name Description of Parameter * @param attribute Description of Parameter * @return The value */ public Object getAttribute(ObjectName name, String attribute) { BeanContextServices context = (BeanContextServices) getBeanContext(); Object result = null; if (context.hasService(ConnectionService.class)) { try { ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this); result = service.getAttribute(name, attribute); context.releaseService(this, this, ConnectionService.class); } catch (Exception e) { e.printStackTrace(); } } return result; } /** * Gets the canonicalName attribute of the Resource object * * @return The canonicalName value */ public String getCanonicalName() { return this.name; } /** * Gets the component attribute of the Resource object * * @return The component value * @author laurent * @created 23 mars 2002 */ public Component getComponent() { /* * updater = new ResourceUpdater(); * MBeanAttributeInfo[] attributes = this.info.getAttributes(); * if (attributes != null) * { * for (int i = 0; i < attributes.length; i++) * { * MBeanAttributeInfo ainfo = attributes[i]; * updater.enableAttribute(ainfo.getName()); * } * } */ if (c == null) { BeanContextServices context = (BeanContextServices) getBeanContext(); if (context.hasService(ConnectionService.class)) { try { ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this); // Adaptor connector = service.createEJB(); this.info = service.getMBeanInfo(this.objectName); context.releaseService(this, this, ConnectionService.class); } catch (Exception e) { System.out.println("Error during utilisation of service ConnectionService (" + e.getMessage() + ")"); e.printStackTrace(); } } try { // this.connector.addNotificationListener(this.objectName, updater, updater, null); c = new GenericMBeanCustomizer(true, this); } catch (Exception e) { e.printStackTrace(); } } return (Component) c; } /** * Gets the description attribute of the Resource object * * @return The description value */ public String getDescription() { return this.description; } /** * Gets the domain attribute of the Resource object * * @return The domain value */ public String getDomain() { return this.domain; } /** * Gets the mBeanInfo attribute of the Resource object * * @return The mBeanInfo value */ public MBeanInfo getMBeanInfo() { return this.info; } /** * Gets the instance attribute of the Resource object * * @return The instance value */ public ObjectInstance getObjectInstance() { return this.objectInstance; } /** * Gets the objectName attribute of the Resource object * * @return The objectName value */ public ObjectName getObjectName() { return this.objectName; } /** * Description of the Method * * @param name Description of Parameter * @param action Description of Parameter * @param params Description of Parameter * @param signatures Description of Parameter * @return Description of the Returned Value */ public Object invoke(ObjectName name, String action, Object[] params, String[] signatures) { BeanContextServices context = (BeanContextServices) getBeanContext(); Object result = null; if (context.hasService(ConnectionService.class)) { try { ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this); result = service.invoke(name, action, params, signatures); context.releaseService(this, this, ConnectionService.class); } catch (Exception e) { e.printStackTrace(); } } return result; } /** * Getter for the attribute attribute * * @param name Description of Parameter * @param attribute Description of Parameter */ public void setAttribute(ObjectName name, Attribute attribute) { BeanContextServices context = (BeanContextServices) getBeanContext(); if (context.hasService(ConnectionService.class)) { try { ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this); service.setAttribute(name, attribute); context.releaseService(this, this, ConnectionService.class); } catch (Exception e) { e.printStackTrace(); } } } /** * Sets the reference attribute of the Resource object * * @param instance The new reference value * @exception Exception Description of Exception */ public void setReference(ObjectInstance instance) throws Exception { this.objectInstance = instance; this.objectName = this.objectInstance.getObjectName(); this.name = this.objectName.getCanonicalName(); this.className = this.objectInstance.getClassName(); this.domain = this.objectName.getDomain(); } /** * Description of the Class * * @author letiembl * @created 11 janvier 2002 */ class ResourceUpdater extends AttributeChangeNotificationFilter implements NotificationListener { /** * Description of the Method * * @param notification Description of Parameter * @param handback Description of Parameter */ public void handleNotification(Notification notification, Object handback) { AttributeChangeNotification acn = (AttributeChangeNotification) notification; System.out.println("### Attribute has been changed " + acn.getAttributeName()); firePropertyChange(acn.getAttributeName(), acn.getOldValue(), acn.getNewValue()); } } } |