User: user57
Date: 01/09/10 22:23:40
Modified: src/main/org/jboss/system ServiceController.java
Log:
o cleaned up some of the formatting-mess that preatty does
o only casing a Throwable to an Exception if it is an exception (also
handles Errors, else throws an Error)
Revision Changes Path
1.5 +73 -62 jboss/src/main/org/jboss/system/ServiceController.java
Index: ServiceController.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServiceController.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServiceController.java 2001/09/08 17:08:32 1.4
+++ ServiceController.java 2001/09/11 05:23:40 1.5
@@ -42,28 +42,25 @@
* @see org.jboss.system.Service
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="[EMAIL PROTECTED]">David Jencks</a>
- * @version $Revision: 1.4 $ <p>
+ * @version $Revision: 1.5 $ <p>
*
- * <b>Revisions:</b> <p>
+ * <b>Revisions:</b> <p>
*
- * <b>20010830 marcf</b>
- * <ol>
- * <li> Initial version checked in
- * </ol>
- * <b>20010908 david jencks</b>
- * <ol>
- * <li> fixed tabs to spaces and log4j logging. Made it report the number
- * of successes on init etc. Modified to support undeploy and work with
- * .sar dependency management and recursive sar deployment.
- * </ol>
- *
+ * <b>20010830 marcf</b>
+ * <ol>
+ * <li>Initial version checked in
+ * </ol>
+ * <b>20010908 david jencks</b>
+ * <ol>
+ * <li>fixed tabs to spaces and log4j logging. Made it report the number
+ * of successes on init etc. Modified to support undeploy and work with
+ * .sar dependency management and recursive sar deployment.
+ * </ol>
*/
-
public class ServiceController
extends ServiceMBeanSupport
implements ServiceControllerMBean, MBeanRegistration
{
-
/**
* A mapping from the Service interface method names to the corresponding
* index into the ServiceProxy.hasOp array.
@@ -81,15 +78,17 @@
// Attributes ----------------------------------------------------
- // A callback to the JMX MBeanServer
+ /** A callback to the JMX MBeanServer */
MBeanServer server;
- // The array list keeps the order of deployment
+ /** The array list keeps the order of deployment. */
List services = new ArrayList();
- // The map keeps the list of objectNames to services
+
+ /** The map keeps the list of objectNames to services. */
Map nameToServiceMap = new HashMap();
- JBossCategory category =
(JBossCategory)JBossCategory.getInstance(getClass().getName());
+ JBossCategory category = (JBossCategory)
+ JBossCategory.getInstance(getClass().getName());
// Static --------------------------------------------------------
@@ -115,7 +114,6 @@
*/
public ObjectName[] getDeployed()
{
-
ObjectName[] deployed = new ObjectName[services.size()];
services.toArray(deployed);
@@ -170,31 +168,30 @@
ree.getTargetError().printStackTrace();
throw ree.getTargetError();
}
- /*
- * catch (MalformedObjectNameException mone) {}
- * catch (ReflectionException re) {}
- * catch (InstanceNotFoundException re) {}
- */
- catch (Throwable ex)
- {
- category.error("Could not create MBean " + objectName);
- category.debug("Error creating MBean " + objectName, ex);
- //pffff...
- throw (Exception)ex;
+ //
+ // catch (MalformedObjectNameException mone) {}
+ // catch (ReflectionException re) {}
+ // catch (InstanceNotFoundException re) {}
+ //
+ catch (Throwable e)
+ {
+ category.error("Could not create MBean: " + objectName, e);
+ if (e instanceof Exception)
+ throw (Exception)e;
+ if (e instanceof Error)
+ throw (Error)e;
+ throw new Error("unexpected throwable: " + e);
}
-
+
// Configure the MBean
try
{
configurator.configure(mbeanElement);
}
-
- catch (ConfigurationException ce)
+ catch (ConfigurationException e)
{
-
- category.error("Could not configure MBean " + objectName);
- category.debug("Error configuring MBean " + objectName, ce);
- throw ce;
+ category.error("Could not configure MBean: " + objectName, e);
+ throw e;
}
String serviceFactory = mbeanElement.getAttribute("serviceFactory");
@@ -237,11 +234,17 @@
*/
public void undeploy(ObjectName objectName) throws Exception
{
- category.debug("undeploying " + objectName + "from server");
+ if (category.isDebugEnabled()) {
+ category.debug("undeploying " + objectName + "from server");
+ }
+
// Do we have a deployed MBean?
if (server.isRegistered(objectName))
{
- category.debug("undeploying " + objectName + "from server");
+ if (category.isDebugEnabled()) {
+ category.debug("undeploying " + objectName + "from server");
+ }
+
//Remove from local maps
services.remove(objectName);
Service service = (Service)nameToServiceMap.remove(objectName);
@@ -250,9 +253,9 @@
server.unregisterMBean(objectName);
// Remove the MBeanClassLoader used by the MBean
- ObjectName loader = new ObjectName("ZClassLoaders:id=" +
objectName.hashCode());
+ ObjectName loader =
+ new ObjectName("ZClassLoaders:id=" + objectName.hashCode());
server.unregisterMBean(loader);
-
}
}
@@ -264,12 +267,11 @@
* @param server Description of Parameter
* @param name Description of Parameter
* @return Description of the Returned Value
- * @exception java.lang.Exception Description of Exception
+ * @exception Exception Description of Exception
*/
public ObjectName preRegister(MBeanServer server, ObjectName name)
- throws java.lang.Exception
+ throws Exception
{
-
this.server = server;
creator = new ServiceCreator(server);
@@ -280,6 +282,7 @@
}
// Service implementation ----------------------------------------
+
/**
* #Description of the Method
*
@@ -309,6 +312,7 @@
category.error("Could not initialize " + name, e);
}
}
+
category.info("Initialized " + serviceCounter + " services");
}
@@ -409,6 +413,7 @@
category.error("Could not destroy" + name, e);
}
}
+
category.info("Destroyed " + serviceCounter + " services");
}
@@ -427,7 +432,8 @@
}
else
{
- throw new InstanceNotFoundException("Could not find " +
serviceName.toString());
+ throw new InstanceNotFoundException
+ ("Could not find " + serviceName.toString());
}
}
@@ -446,7 +452,8 @@
}
else
{
- throw new InstanceNotFoundException("Could not find " +
serviceName.toString());
+ throw new InstanceNotFoundException
+ ("Could not find " + serviceName.toString());
}
}
@@ -465,7 +472,8 @@
}
else
{
- throw new InstanceNotFoundException("Could not find " +
serviceName.toString());
+ throw new InstanceNotFoundException
+ ("Could not find " + serviceName.toString());
}
}
@@ -484,25 +492,27 @@
}
else
{
- throw new InstanceNotFoundException("Could not find " +
serviceName.toString());
+ throw new InstanceNotFoundException
+ ("Could not find " + serviceName.toString());
}
}
/**
- * Get the Service interface through which the mbean given by objectName will
- * be managed.
+ * Get the Service interface through which the mbean given by objectName
+ * will be managed.
*
* @param objectName
* @param info
* @param serviceFactory
* @return The ServiceInstance value
+ *
* @throws ClassNotFoundException
* @throws InstantiationException
* @throws IllegalAccessException
*/
private Service getServiceInstance(ObjectName objectName,
- MBeanInfo info,
- String serviceFactory)
+ MBeanInfo info,
+ String serviceFactory)
throws ClassNotFoundException, InstantiationException,
IllegalAccessException
{
Service service = null;
@@ -529,10 +539,11 @@
/**
* Parse an object name from the given element attribute 'name'.
*
- * @param element Element to parse name from.
- * @return Object name.
- * @throws ConfigurationException Missing attribute 'name' (thrown if 'name'
- * is null or "").
+ * @param element Element to parse name from.
+ * @return Object name.
+ *
+ * @throws ConfigurationException Missing attribute 'name' (thrown if
+ * 'name' is null or "").
* @throws MalformedObjectNameException
*/
private ObjectName parseObjectName(final Element element)
@@ -589,9 +600,10 @@
* matching operation is forwarded to the mbean by invoking the method
* through the MBeanServer object.
*/
- private class ServiceProxy implements InvocationHandler
+ private class ServiceProxy
+ implements InvocationHandler
{
- private boolean[] hasOp = {false, false, false, false};
+ private boolean[] hasOp = { false, false, false, false };
private ObjectName objectName;
/**
@@ -603,7 +615,7 @@
* @param opInfo
*/
public ServiceProxy(ObjectName objectName,
- MBeanOperationInfo[] opInfo)
+ MBeanOperationInfo[] opInfo)
{
this.objectName = objectName;
int opCount = 0;
@@ -649,10 +661,9 @@
* @param proxy
* @param method
* @param args
- * @return Always null.
+ * @return Always null.
* @throws Throwable
*/
-
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
{
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development