[jboss-cvs] JBossAS SVN: r90438 - in branches/JBPAPP_5_0: system/src/main/org/jboss/system/server/profile/basic and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jun 18 12:47:01 EDT 2009
Author: emuckenhuber
Date: 2009-06-18 12:47:00 -0400 (Thu, 18 Jun 2009)
New Revision: 90438
Added:
branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/LifecycleInfo.java
Modified:
branches/JBPAPP_5_0/component-matrix/pom.xml
branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java
branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/ServiceProxy.java
branches/JBPAPP_5_0/system/src/main/org/jboss/system/server/profile/basic/XmlIncludeVirtualFileFilter.java
Log:
merge with branch 5_x: Update MC libs (MDR 2.0.2.GA, Kernel 2.0.7.GA, Deployers 2.0.8.GA); add lifecycle support to SCC; fix SP invoke
Modified: branches/JBPAPP_5_0/component-matrix/pom.xml
===================================================================
--- branches/JBPAPP_5_0/component-matrix/pom.xml 2009-06-18 16:29:34 UTC (rev 90437)
+++ branches/JBPAPP_5_0/component-matrix/pom.xml 2009-06-18 16:47:00 UTC (rev 90438)
@@ -64,7 +64,7 @@
<version.org.jboss.cluster.client>1.1.1.GA</version.org.jboss.cluster.client>
<version.org.jboss.cluster.server.api>1.1.1.GA</version.org.jboss.cluster.server.api>
<version.org.jboss.common.core>2.2.14.GA</version.org.jboss.common.core>
- <version.org.jboss.deployers>2.0.7.GA</version.org.jboss.deployers>
+ <version.org.jboss.deployers>2.0.8.GA</version.org.jboss.deployers>
<version.org.jboss.ejb3.common.client>1.0.0</version.org.jboss.ejb3.common.client>
<version.org.jboss.ejb3.core.client>1.1.5</version.org.jboss.ejb3.core.client>
<version.org.jboss.ejb3.proxy.impl.client>1.0.2</version.org.jboss.ejb3.proxy.impl.client>
@@ -81,9 +81,9 @@
<version.org.jboss.logbridge>1.0.0.GA</version.org.jboss.logbridge>
<version.org.jboss.logmanager>1.0.0.GA</version.org.jboss.logmanager>
<version.org.jboss.man>2.1.1.CR1</version.org.jboss.man>
- <version.org.jboss.mdr>2.0.1.GA</version.org.jboss.mdr>
+ <version.org.jboss.mdr>2.0.2.GA</version.org.jboss.mdr>
<version.org.jboss.metadata>1.0.1.GA</version.org.jboss.metadata>
- <version.org.jboss.microcontainer>2.0.6.GA</version.org.jboss.microcontainer>
+ <version.org.jboss.microcontainer>2.0.7.GA</version.org.jboss.microcontainer>
<version.org.jboss.naming>5.0.3.GA</version.org.jboss.naming>
<version.org.jboss.reflect>2.0.2.GA</version.org.jboss.reflect>
<version.org.jboss.remoting>2.5.1</version.org.jboss.remoting>
Modified: branches/JBPAPP_5_0/system/src/main/org/jboss/system/server/profile/basic/XmlIncludeVirtualFileFilter.java
===================================================================
--- branches/JBPAPP_5_0/system/src/main/org/jboss/system/server/profile/basic/XmlIncludeVirtualFileFilter.java 2009-06-18 16:29:34 UTC (rev 90437)
+++ branches/JBPAPP_5_0/system/src/main/org/jboss/system/server/profile/basic/XmlIncludeVirtualFileFilter.java 2009-06-18 16:47:00 UTC (rev 90438)
@@ -21,18 +21,17 @@
*/
package org.jboss.system.server.profile.basic;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.deployers.vfs.spi.structure.modified.AbstractPathNameFilter;
/**
* Include only .xml files.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class XmlIncludeVirtualFileFilter implements VirtualFileFilter
+public class XmlIncludeVirtualFileFilter extends AbstractPathNameFilter
{
- public boolean accepts(VirtualFile file)
+ public boolean accepts(String path)
{
- return file.getName().endsWith(".xml");
+ return path.endsWith(".xml");
}
}
\ No newline at end of file
Copied: branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/LifecycleInfo.java (from rev 90432, branches/Branch_5_x/system-jmx/src/main/org/jboss/system/microcontainer/LifecycleInfo.java)
===================================================================
--- branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/LifecycleInfo.java (rev 0)
+++ branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/LifecycleInfo.java 2009-06-18 16:47:00 UTC (rev 90438)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.system.microcontainer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServer;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.ControllerStateModel;
+import org.jboss.system.ServiceController;
+
+/**
+ * Holds the needed kernel bus lifecycle invocation info.
+ * Used by {@link ServiceControllerContext#lifecycleInvocation(String, Object[], String[])}
+ * to make invocations on the MBean lifecycle methods.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class LifecycleInfo
+{
+ private ServiceControllerContext context;
+ private Map<String, StateInfo> lifecycleOps;
+
+ /**
+ * @param context the ServiceControllerContext
+ * @throws Throwable for any error
+ */
+ public LifecycleInfo(ServiceControllerContext context) throws Throwable
+ {
+ if (context == null)
+ throw new IllegalArgumentException("Null context");
+
+ this.context = context;
+ // build possible lifecycle ops
+ lifecycleOps = new HashMap<String, StateInfo>();
+ lifecycleOps.put("create", new StateInfo(false, true, ControllerState.CREATE));
+ lifecycleOps.put("start", new StateInfo(false, true, ControllerState.INSTALLED));
+ lifecycleOps.put("stop", new StateInfo(false, false, ControllerState.CREATE));
+ lifecycleOps.put("destroy", new StateInfo(false, false, ControllerState.CONFIGURED));
+
+ ServiceController controller = context.getServiceController();
+ MBeanServer server = controller.getMBeanServer();
+ if (server != null)
+ {
+ MBeanInfo info = server.getMBeanInfo(context.getObjectName());
+ MBeanOperationInfo[] ops = info.getOperations();
+ if (ops != null)
+ {
+ for (MBeanOperationInfo op : ops)
+ {
+ String name = op.getName();
+
+ StateInfo flag = lifecycleOps.get(name);
+ if (flag == null)
+ {
+ continue;
+ }
+
+ // Validate that is a no-arg void return type method
+ if (op.getReturnType().equals("void") == false)
+ {
+ continue;
+ }
+ if (op.getSignature().length != 0)
+ {
+ continue;
+ }
+
+ flag.opExists = true;
+ }
+ }
+ }
+ }
+
+ /**
+ * Is this invocation a lifecycle invocation.
+ *
+ * Return state value to which this context should be moved
+ * or return current state if we're already past the lifecycle state
+ * or null if the invocation is actually not a lifecycle invocation.
+ *
+ * @param opName operation name
+ * @param signature method's parameter types / signatures
+ * @return state to which we should move this context, or null if this is not lifecycle invocation
+ * @throws Throwable for any error
+ */
+ public ControllerState lifecycleInvocation(String opName, String[] signature) throws Throwable
+ {
+ if (signature != null && signature.length > 0)
+ return null;
+
+ StateInfo flag = lifecycleOps.get(opName);
+ if (flag == null || flag.opExists == false)
+ return null;
+
+ Controller controller = context.getController();
+ ControllerStateModel model = controller.getStates();
+ ControllerState state = context.getState();
+ if (flag.installPhase)
+ {
+ if (model.isAfterState(flag.state, state))
+ return flag.state;
+ else
+ return state;
+ }
+ else
+ {
+ if (model.isBeforeState(flag.state, state))
+ return flag.state;
+ else
+ return state;
+ }
+ }
+
+ /**
+ * State info holder.
+ */
+ private class StateInfo
+ {
+ boolean opExists;
+ boolean installPhase;
+ ControllerState state;
+
+ private StateInfo(boolean opExists, boolean installPhase, ControllerState state)
+ {
+ this.opExists = opExists;
+ this.installPhase = installPhase;
+ this.state = state;
+ }
+ }
+}
Modified: branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java
===================================================================
--- branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java 2009-06-18 16:29:34 UTC (rev 90437)
+++ branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java 2009-06-18 16:47:00 UTC (rev 90438)
@@ -33,7 +33,7 @@
import org.jboss.dependency.spi.ControllerMode;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+import org.jboss.dependency.spi.dispatch.LifecycleDispatchContext;
import org.jboss.system.Service;
import org.jboss.system.ServiceContext;
import org.jboss.system.ServiceController;
@@ -48,7 +48,7 @@
* @author <a href="ales.justin at jboss.com">Ales Justin</a>
* @version $Revision$
*/
-public class ServiceControllerContext extends AbstractControllerContext implements InvokeDispatchContext
+public class ServiceControllerContext extends AbstractControllerContext implements LifecycleDispatchContext
{
/** The ObjectName */
private ObjectName objectName;
@@ -65,6 +65,9 @@
// Whether to include the lifecycle
private boolean includeLifecycle = true;
+ /** The lifecycle info */
+ private volatile LifecycleInfo lifecycleInfo;
+
/**
* Create a new ServiceControllerContext.
*
@@ -199,6 +202,14 @@
}
}
+ public ControllerState lifecycleInvocation(String name, Object[] parameters, String[] signature) throws Throwable
+ {
+ if (lifecycleInfo == null)
+ lifecycleInfo = new LifecycleInfo(this);
+
+ return lifecycleInfo.lifecycleInvocation(name, signature);
+ }
+
/**
* Get the ObjectName.
*
Modified: branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/ServiceProxy.java
===================================================================
--- branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/ServiceProxy.java 2009-06-18 16:29:34 UTC (rev 90437)
+++ branches/JBPAPP_5_0/system-jmx/src/main/org/jboss/system/microcontainer/ServiceProxy.java 2009-06-18 16:47:00 UTC (rev 90438)
@@ -25,7 +25,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
-
+import java.util.Map;
import javax.management.MBeanInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanServer;
@@ -51,6 +51,7 @@
* @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
* @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
* @version $Revision$
*/
public class ServiceProxy implements InvocationHandler
@@ -59,7 +60,7 @@
* A mapping from the Service interface method names to the corresponding
* index into the ServiceProxy.hasOp array.
*/
- private static HashMap<String, Integer> serviceOpMap = new HashMap<String, Integer>();
+ private static Map<String, Integer> serviceOpMap = new HashMap<String, Integer>();
// A singleton proxy with no callouts
private static Service NO_LIFECYCLE_CALLOUT;
@@ -69,10 +70,10 @@
*/
static
{
- serviceOpMap.put("create", new Integer(0));
- serviceOpMap.put("start", new Integer(1));
- serviceOpMap.put("destroy", new Integer(2));
- serviceOpMap.put("stop", new Integer(3));
+ serviceOpMap.put("create", 0);
+ serviceOpMap.put("start", 1);
+ serviceOpMap.put("destroy", 2);
+ serviceOpMap.put("stop", 3);
Class<?>[] interfaces = { Service.class };
NO_LIFECYCLE_CALLOUT = (Service) Proxy.newProxyInstance(Service.class.getClassLoader(), interfaces, NoLifecycleCallout.INSTANCE);
}
@@ -108,17 +109,18 @@
*/
public static Service getServiceProxy(ObjectName objectName, MBeanServer server, boolean includeLifecycle) throws Exception
{
- Service service = null;
- MBeanInfo info = server.getMBeanInfo(objectName);
- MBeanOperationInfo[] opInfo = info.getOperations();
- Class<?>[] interfaces = { Service.class };
- InvocationHandler handler = new ServiceProxy(objectName, server, opInfo);
- if (includeLifecycle == false)
- service = NO_LIFECYCLE_CALLOUT;
+ if (includeLifecycle)
+ {
+ MBeanInfo info = server.getMBeanInfo(objectName);
+ MBeanOperationInfo[] opInfo = info.getOperations();
+ Class<?>[] interfaces = { Service.class };
+ InvocationHandler handler = new ServiceProxy(objectName, server, opInfo);
+ return (Service) Proxy.newProxyInstance(Service.class.getClassLoader(), interfaces, handler);
+ }
else
- service = (Service) Proxy.newProxyInstance(Service.class.getClassLoader(), interfaces, handler);
-
- return service;
+ {
+ return NO_LIFECYCLE_CALLOUT;
+ }
}
/**
@@ -135,9 +137,8 @@
this.server = server;
this.objectName = objectName;
- for (int op = 0; op < opInfo.length; op++)
+ for (MBeanOperationInfo info : opInfo)
{
- MBeanOperationInfo info = opInfo[op];
String name = info.getName();
if (name.equals(ServiceController.JBOSS_INTERNAL_LIFECYCLE))
@@ -162,7 +163,7 @@
continue;
}
- hasOp[opID.intValue()] = true;
+ hasOp[opID] = true;
}
}
@@ -171,14 +172,13 @@
* corresponding hasOp array element is true, dispatch the method to the
* mbean we are proxying.
*
- * @param proxy
- * @param method
- * @param args
- * @return Always null.
- * @throws Throwable
+ * @param proxy the proxy
+ * @param method the method
+ * @param args the args
+ * @return always null.
+ * @throws Throwable for any error
*/
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
String name = method.getName();
@@ -197,7 +197,7 @@
Integer opID = serviceOpMap.get(name);
- if (opID != null && hasOp[opID.intValue()] == true)
+ if (opID != null && hasOp[opID])
{
// deal with those pesky JMX exceptions
try
More information about the jboss-cvs-commits
mailing list