[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceCreator.java

2002-01-20 Thread marc fleury

  User: mnf999  
  Date: 02/01/20 07:19:38

  Modified:src/main/org/jboss/system ServiceCreator.java
  Log:
  
  
  Revision  ChangesPath
  1.11  +5 -3  jboss/src/main/org/jboss/system/ServiceCreator.java
  
  Index: ServiceCreator.java
  ===
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServiceCreator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ServiceCreator.java   2002/01/05 12:08:54 1.10
  +++ ServiceCreator.java   2002/01/20 15:19:38 1.11
  @@ -25,7 +25,7 @@
* @see Service
* 
* @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
* 
* pbRevisions:/b
* pb2001/08/03 marcf /b
  @@ -83,12 +83,14 @@
 ConstructorInfo constructor =
   
 ConstructorInfo.create(mbeanElement);
  -  if (debug)
  - log.debug(About to create bean: +name);
  +  
  +  if (debug) log.debug(About to create bean: +name);
  +

 // Create the MBean instance
 try 
 {
  + log.info(code +code);
ObjectInstance instance = server.createMBean(code,
 name,
 loader,
  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceCreator.java

2001-12-18 Thread marc fleury

  User: mnf999  
  Date: 01/12/18 22:34:08

  Modified:src/main/org/jboss/system ServiceCreator.java
  Log:
  
  
  Revision  ChangesPath
  1.8   +132 -116  jboss/src/main/org/jboss/system/ServiceCreator.java
  
  Index: ServiceCreator.java
  ===
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServiceCreator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ServiceCreator.java   2001/12/09 03:36:01 1.7
  +++ ServiceCreator.java   2001/12/19 06:34:08 1.8
  @@ -1,9 +1,9 @@
   /*
  - * JBoss, the OpenSource J2EE webOS
  - *
  - * Distributable under LGPL license.
  - * See terms of license at gnu.org.
  - */
  +* JBoss, the OpenSource J2EE webOS
  +*
  +* Distributable under LGPL license.
  +* See terms of license at gnu.org.
  +*/
   package org.jboss.system;
   
   import java.lang.reflect.Constructor;
  @@ -24,7 +24,7 @@
* @see Service
* 
* @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
* 
* pbRevisions:/b
* pb2001/08/03 marcf /b
  @@ -38,46 +38,47 @@
   
  /** Instance logger. */
  private final Logger log = Logger.getLogger(getClass());
  - 
  +   
  private MBeanServer server;
  - 
  +   
  public ServiceCreator(final MBeanServer server) {
 this.server = server;
  }
  - 
  +   
  /**
  -* Parses the given configuration document and creates MBean
  -* instances in the current MBean server.
  -*
  -* @param configuration The configuration document.
  -*
  -* @throws ConfigurationException   The configuration document contains
  -*  invalid or missing syntax.
  -* @throws ExceptionFailed for some other reason.
  -*/
  -   public ObjectInstance create(Element mbeanElement) throws Exception
  +   * Parses the given configuration document and creates MBean
  +   * instances in the current MBean server.
  +   *
  +   * @param configuration The configuration document.
  +   *
  +   * @throws ConfigurationException   The configuration document contains
  +   *  invalid or missing syntax.
  +   * @throws ExceptionFailed for some other reason.
  +   */
  +   public ObjectInstance install(Element mbeanElement) throws Exception
  {
 ObjectName name = parseObjectName(mbeanElement);
  - 
  +  
 // marcf fixme add and remove the classlaoder from the controller
  - 
  +  
 ObjectName loader = new ObjectName(ZClassLoaders:id=+name.hashCode());
  - 
  +  
 MBeanClassLoader cl = new MBeanClassLoader(name);
  - 
  +  
 if (!server.isRegistered(loader))
server.registerMBean(cl, loader);
  - 
  +  
 // If class is given, instantiate it
 String code = mbeanElement.getAttribute(code);
 if (code == null)
 {
throw new ConfigurationException(missing 'code' attribute);
 }
  - 
  +  
 // get the constructor params/sig to use
 ConstructorInfo constructor =
  - ConstructorInfo.create(mbeanElement);
  +
  +   ConstructorInfo.create(mbeanElement);
 log.debug(About to create bean: +name);

 // Create the MBean instance
  @@ -91,7 +92,7 @@
log.debug(Created bean: +name);

return instance;
  - 
  +  
 } 
 catch (Exception e) 
 {
  @@ -104,66 +105,81 @@

throw e;
 } // end of try-catch
  +   
  +   } 
  +   
  +   
  +   public void remove(ObjectName name) throws Exception
  +   {
  +  
  +  // Remove the MBean from the MBeanServer
  +  server.unregisterMBean(name);
 
  +  // Remove the MBeanClassLoader used by the MBean
  +  ObjectName loader = new ObjectName(ZClassLoaders:id= + name.hashCode());
  +  if (server.isRegistered(loader)) 
  +  {
  + server.unregisterMBean(loader);
  +  } // end of if ()
  } 
  - 
  +   
  /**
  -* Provides a wrapper around the information about which constructor
  -* that MBeanServer should use to construct a MBean.
  -* Please note that only basic datatypes (type is then the same as
  -* you use to declare it short, int, float etc.) and any class
  -* having a constructor taking a single String as only parameter.
  -*
  -* pXML syntax for contructor:
  -*   pre
  -*  constructor
  -* arg type=xxx value=yyy/
  -* ...
  -* arg type=xxx value=yyy/
  -*  /constructor
  -*   /pre
  -*/
  +   * Provides a wrapper around the information about which constructor
  +   * that MBeanServer should 

[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceCreator.java

2001-12-08 Thread Jason Dillon

  User: user57  
  Date: 01/12/08 18:37:54

  Modified:src/main/org/jboss/system ServiceCreator.java
  Log:
   o minor cosmetic change to about/create bean log messages
  
  Revision  ChangesPath
  1.6   +12 -12jboss/src/main/org/jboss/system/ServiceCreator.java
  
  Index: ServiceCreator.java
  ===
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServiceCreator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ServiceCreator.java   2001/12/05 21:23:59 1.5
  +++ ServiceCreator.java   2001/12/09 02:37:54 1.6
  @@ -24,7 +24,7 @@
* @see Service
* 
* @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
* 
* pbRevisions:/b
* pb2001/08/03 marcf /b
  @@ -35,7 +35,8 @@
   public class ServiceCreator 
   {
  // Attributes 
  -   
  +
  +   /** Instance logger. */
  private final Logger log = Logger.getLogger(getClass());

  private MBeanServer server;
  @@ -72,31 +73,30 @@
 String code = mbeanElement.getAttribute(code);
 if (code == null)
 {
  - throw new ConfigurationException
  -(missing 'code' attribute);
  + throw new ConfigurationException(missing 'code' attribute);
 }

 // get the constructor params/sig to use
 ConstructorInfo constructor =
ConstructorInfo.create(mbeanElement);
  -  log.info(About to create the bean+name);
  +  log.info(About to create bean: +name);

 // Create the MBean instance
 try 
 {
  - ObjectInstance instance =  server.createMBean(code,
  -   name,
  -   loader,
  -   constructor.params,
  -   constructor.signature);
  - log.info(Created the bean+name);
  + ObjectInstance instance = server.createMBean(code,
  +  name,
  +  loader,
  +  constructor.params,
  +  constructor.signature);
  + log.info(Created bean: +name);

return instance;

 } 
 catch (Exception e) 
 {
  - //didn't work, unregister in case the jmx agent is screwed.
  + // didn't work, unregister in case the jmx agent is screwed.
try 
{
   server.unregisterMBean(name);
  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceCreator.java

2001-12-08 Thread Jason Dillon

  User: user57  
  Date: 01/12/08 19:36:01

  Modified:src/main/org/jboss/system ServiceCreator.java
  Log:
   o info messages to debug
  
  Revision  ChangesPath
  1.7   +4 -5  jboss/src/main/org/jboss/system/ServiceCreator.java
  
  Index: ServiceCreator.java
  ===
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServiceCreator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ServiceCreator.java   2001/12/09 02:37:54 1.6
  +++ ServiceCreator.java   2001/12/09 03:36:01 1.7
  @@ -24,7 +24,7 @@
* @see Service
* 
* @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
* 
* pbRevisions:/b
* pb2001/08/03 marcf /b
  @@ -57,7 +57,6 @@
   */
  public ObjectInstance create(Element mbeanElement) throws Exception
  {
  - 
 ObjectName name = parseObjectName(mbeanElement);

 // marcf fixme add and remove the classlaoder from the controller
  @@ -79,7 +78,7 @@
 // get the constructor params/sig to use
 ConstructorInfo constructor =
ConstructorInfo.create(mbeanElement);
  -  log.info(About to create bean: +name);
  +  log.debug(About to create bean: +name);

 // Create the MBean instance
 try 
  @@ -89,7 +88,7 @@
 loader,
 constructor.params,
 constructor.signature);
  - log.info(Created bean: +name);
  + log.debug(Created bean: +name);

return instance;

  @@ -100,7 +99,7 @@
try 
{
   server.unregisterMBean(name);
  - } catch (Exception othere) 
  + } catch (Exception ignore)
{ } // end of try-catch

throw e;
  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceCreator.java

2001-12-05 Thread David Jencks

  User: d_jencks
  Date: 01/12/05 13:24:00

  Modified:src/main/org/jboss/system ServiceCreator.java
  Log:
  Fix to problem of bad DynamicMBean that returns null MBeanInfo being registered 
after MBeanServer creates it.
  
  Revision  ChangesPath
  1.5   +23 -10jboss/src/main/org/jboss/system/ServiceCreator.java
  
  Index: ServiceCreator.java
  ===
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServiceCreator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ServiceCreator.java   2001/11/26 03:19:46 1.4
  +++ ServiceCreator.java   2001/12/05 21:23:59 1.5
  @@ -24,7 +24,7 @@
* @see Service
* 
* @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
* 
* pbRevisions:/b
* pb2001/08/03 marcf /b
  @@ -82,17 +82,30 @@
 log.info(About to create the bean+name);

 // Create the MBean instance
  -  ObjectInstance instance = 
  - server.createMBean(code,
  -name,
  -loader,
  -constructor.params,
  -constructor.signature);
  - 
  -  log.info(Created the bean+name);
  +  try 
  +  {
  + ObjectInstance instance =  server.createMBean(code,
  +   name,
  +   loader,
  +   constructor.params,
  +   constructor.signature);
  + log.info(Created the bean+name);

  -  return instance;
  + return instance;

  +  } 
  +  catch (Exception e) 
  +  {
  + //didn't work, unregister in case the jmx agent is screwed.
  + try 
  + {
  +server.unregisterMBean(name);
  + } catch (Exception othere) 
  + { } // end of try-catch
  + 
  + throw e;
  +  } // end of try-catch
  +  
  } 

  /**
  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] CVS update: jboss/src/main/org/jboss/system ServiceCreator.java

2001-08-29 Thread marc fleury

  User: mnf999  
  Date: 01/08/29 16:22:01

  Added:   src/main/org/jboss/system ServiceCreator.java
  Log:
  A helper class to create an MBean from an XML snippet
  
  Revision  ChangesPath
  1.1  jboss/src/main/org/jboss/system/ServiceCreator.java
  
  Index: ServiceCreator.java
  ===
  /*
  * JBoss, the OpenSource J2EE server
  *
  * Distributable under LGPL license.
  * See terms of license at gnu.org.
  */
  package org.jboss.system;
  
  
  import java.lang.reflect.Constructor;
  
  import javax.management.ObjectName;
  import javax.management.MBeanServer;
  import javax.management.ObjectInstance;
  import javax.management.MalformedObjectNameException;
  
  import org.w3c.dom.Element;
  import org.w3c.dom.NodeList;
  
  /** 
  *
  * A helper class for the controller
  *   
  * @author a href=mailto:[EMAIL PROTECTED];Marc Fleury/a
  * @see org.jboss.system.Service
  * @version $Revision: 1.1 $
  
  * pbRevisions:/b
  * pb2001/08/03 marcf /b
  * ol
  * liInitial version checked in
  * /ol
  *
  */
  public class ServiceCreator 
  {

// Attributes 

private MBeanServer server;

public ServiceCreator(MBeanServer server) {this.server = server;}

/**
* Parses the given configuration document and creates MBean
* instances in the current MBean server.
*
* @param configuration The configuration document.
*
* @throws ConfigurationException   The configuration document contains
*  invalid or missing syntax.
* @throws ExceptionFailed for some other reason.
*/
public ObjectInstance create(Element mbeanElement) throws Exception
{

ObjectName name = parseObjectName(mbeanElement);

//marcf fixme add and remove the classlaoder from the controller


ObjectName loader = new 
ObjectName(ZClassLoaders:id=+name.hashCode());

MBeanClassLoader cl = new MBeanClassLoader(name);

if (!server.isRegistered(loader))
server.registerMBean(cl, loader);

// If class is given, instantiate it
String code = mbeanElement.getAttribute(code);
if (code == null)
{
throw new ConfigurationException
(missing 'code' attribute);
}

// get the constructor params/sig to use
ConstructorInfo constructor =
ConstructorInfo.create(mbeanElement);
System.out.println(About to create the bean+name);

// Create the MBean instance
ObjectInstance instance = 
server.createMBean(code,
name,
loader,
constructor.params,
constructor.signature);

System.out.println(Created the bean+name);

return instance;

}   

/**
* Provides a wrapper around the information about which constructor
* that MBeanServer should use to construct a MBean.
* Please note that only basic datatypes (type is then the same as
* you use to declare it short, int, float etc.) and any class
* having a constructor taking a single String as only parameter.
*
* pXML syntax for contructor:
*   pre
*  constructor
* arg type=xxx value=yyy/
* ...
* arg type=xxx value=yyy/
*  /constructor
*   /pre
*/
private static class ConstructorInfo
{
/** An empty parameters list. */
public static final Object EMPTY_PARAMS[] = {};

/** An signature list. */
public static final String EMPTY_SIGNATURE[] = {};

/** The constructor signature. */
public String[] signature = EMPTY_SIGNATURE;

/** The constructor parameters. */
public Object[] params = EMPTY_PARAMS;

/**
* Create a ConstructorInfo object for the given configuration.
*
* @param element   The element to build info for.
* @return  A constructor information object.
*
* @throws ConfigurationException   Failed to create info object.
*/
public static