Thread: [Ejtools-cvs] CVS: applications/management/src/main/net/sourceforge/ejtools/management/model Resourc
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-04-22 18:00:20
|
Update of /cvsroot/ejtools/applications/management/src/main/net/sourceforge/ejtools/management/model In directory usw-pr-cvs1:/tmp/cvs-serv30166/management/src/main/net/sourceforge/ejtools/management/model Added Files: Resource.java Log Message: Initial Import --- NEW FILE: Resource.java --- package net.sourceforge.ejtools.management.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 net.sourceforge.ejtools.awt.*; import net.sourceforge.ejtools.jmx.MBeanAccessor; /** * Description of the Class * * @author letiembl * @created 13 décembre 2001 */ public class Resource extends Node implements MBeanAccessor { /** Description of the Field */ protected String canonicalName; /** Description of the Field */ protected transient MBeanInfo info; /** Description of the Field */ protected String j2eeType; /** Description of the Field */ protected transient ObjectName objectName; /** Constructor for the Resource object */ public Resource() { } /** * Gets the attribute attribute of the Resource object * * @param name Description of the Parameter * @param attribute Description of the Parameter * @return The attribute 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.canonicalName; } /** * Gets the component attribute of the Resource object * * @return The component value */ public Component getComponent() { if (c == null) { BeanContextServices context = (BeanContextServices) getBeanContext(); if (context.hasService(ConnectionService.class)) { try { ConnectionService service = (ConnectionService) context.getService(this, this, ConnectionService.class, this, this); 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 { c = new GenericMBeanCustomizer(true, this); } catch (Exception e) { e.printStackTrace(); } } return (Component) c; } /** * Gets the j2eeType attribute of the Resource object * * @return The j2eeType value */ public String getJ2EEType() { return j2eeType; } /** * Gets the mBeanInfo attribute of the Resource object * * @return The mBeanInfo value */ public MBeanInfo getMBeanInfo() { return this.info; } /** * 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 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 */ 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; } /** * Sets the attribute attribute of the Resource object * * @param name The new attribute value * @param attribute The new attribute value */ 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 objectName The new reference value * @exception Exception Description of Exception */ public void setReference(ObjectName objectName) throws Exception { this.objectName = objectName; this.canonicalName = objectName.getCanonicalName(); this.name = objectName.getKeyProperty("name"); this.j2eeType = objectName.getKeyProperty("j2eeType"); } /** * Description of the Method * * @return Description of the Return Value */ public String toString() { return (this.canonicalName == null ? "undefined" : this.canonicalName); } } |