[Jboss-cvs] JBossAS SVN: r56013 - in trunk/ejb3/src: main/org/jboss/ejb3 test/org/jboss/ejb3/test/jca/inflowmdb/unit
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 16 21:18:37 EDT 2006
Author: bdecoste
Date: 2006-08-16 21:18:34 -0400 (Wed, 16 Aug 2006)
New Revision: 56013
Added:
trunk/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java
trunk/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java
trunk/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java
trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstractionFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java
trunk/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/unit/InflowUnitTestCase.java
Log:
added ClientKernelAbstraction for client invocations
Added: trunk/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java 2006-08-17 01:09:56 UTC (rev 56012)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java 2006-08-17 01:18:34 UTC (rev 56013)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.ejb3;
+
+import javax.management.ObjectName;
+
+import javax.management.MBeanServer;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface ClientKernelAbstraction
+{
+ Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws Exception;
+}
Added: trunk/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java 2006-08-17 01:09:56 UTC (rev 56012)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java 2006-08-17 01:18:34 UTC (rev 56013)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.ejb3;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class JmxClientKernelAbstraction implements ClientKernelAbstraction
+{
+ private static final Logger log = Logger.getLogger(JmxKernelAbstraction.class);
+
+ private MBeanServerConnection server;
+
+ public JmxClientKernelAbstraction(MBeanServerConnection server)
+ {
+ this.server = server;
+ }
+
+ public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws Exception
+ {
+ return server.invoke(name, operationName, params, signature);
+ }
+}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java 2006-08-17 01:09:56 UTC (rev 56012)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java 2006-08-17 01:18:34 UTC (rev 56013)
@@ -36,7 +36,9 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public class JmxKernelAbstraction implements KernelAbstraction
+public class JmxKernelAbstraction
+ extends JmxClientKernelAbstraction
+ implements KernelAbstraction
{
private static final Logger log = Logger.getLogger(JmxKernelAbstraction.class);
@@ -46,15 +48,16 @@
public JmxKernelAbstraction(DeploymentInfo di)
{
+ super(di.getServer());
this.server = di.getServer();
serviceController = (ServiceControllerMBean) MBeanProxyExt.create(ServiceControllerMBean.class, ServiceControllerMBean.OBJECT_NAME,
- server);
+ di.getServer());
this.di = di;
}
public JmxKernelAbstraction(MBeanServer server)
{
- this.server = server;
+ super(server);
serviceController = (ServiceControllerMBean) MBeanProxyExt.create(ServiceControllerMBean.class, ServiceControllerMBean.OBJECT_NAME,
server);
}
@@ -171,9 +174,4 @@
uninstallMBean(on);
}
-
- public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws Exception
- {
- return server.invoke(name, operationName, params, signature);
- }
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstractionFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstractionFactory.java 2006-08-17 01:09:56 UTC (rev 56012)
+++ trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstractionFactory.java 2006-08-17 01:18:34 UTC (rev 56013)
@@ -35,26 +35,15 @@
{
private static final Logger log = Logger.getLogger(KernelAbstractionFactory.class);
+ private static ClientKernelAbstraction clientKernelAbstraction = null;
private static KernelAbstraction kernelAbstraction = null;
private static Kernel kernel = null;
public static KernelAbstraction getInstance() throws Exception
- {
-
- MBeanServer mbeanServer;
-
- try
- {
- mbeanServer = org.jboss.mx.util.MBeanServerLocator.locateJBoss();
- }
- catch (IllegalStateException e)
- {
- String adaptorName = System.getProperty("jbosstest.server.name", "jmx/invoker/RMIAdaptor");
- mbeanServer = (MBeanServer)InitialContextFactory.getInitialContext().lookup(adaptorName);
- }
-
+ {
if (kernelAbstraction == null)
{
+ MBeanServer mbeanServer = (MBeanServer)getMBeanServer();
if (kernel != null)
kernelAbstraction = new MCKernelAbstraction(kernel, mbeanServer);
else
@@ -64,12 +53,46 @@
}
return kernelAbstraction;
- }
+ }
+
+ public static ClientKernelAbstraction getClientInstance() throws Exception
+ {
+ if (clientKernelAbstraction == null)
+ {
+ if (kernel != null)
+ {
+ clientKernelAbstraction = new MCClientKernelAbstraction(kernel);
+ }
+ else
+ {
+ MBeanServerConnection mbeanServer = (MBeanServerConnection)getMBeanServer();
+ clientKernelAbstraction = new JmxClientKernelAbstraction(mbeanServer);
+ }
+ }
+
+ return clientKernelAbstraction;
+ }
- public static void setKernel(Kernel k)
- {
- kernel = k;
- }
+ public static void setKernel(Kernel k)
+ {
+ kernel = k;
+ }
+ protected static MBeanServerConnection getMBeanServer() throws Exception
+ {
+ MBeanServerConnection mbeanServer;
+
+ try
+ {
+ mbeanServer = org.jboss.mx.util.MBeanServerLocator.locateJBoss();
+ }
+ catch (IllegalStateException e)
+ {
+ String adaptorName = System.getProperty("jbosstest.server.name", "jmx/invoker/RMIAdaptor");
+ mbeanServer = (MBeanServerConnection)InitialContextFactory.getInitialContext().lookup(adaptorName);
+ }
+
+ return mbeanServer;
+ }
}
Added: trunk/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java 2006-08-17 01:09:56 UTC (rev 56012)
+++ trunk/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java 2006-08-17 01:18:34 UTC (rev 56013)
@@ -0,0 +1,74 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.ejb3;
+
+import java.lang.reflect.Method;
+
+import javax.management.ObjectName;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+
+import org.jboss.ejb3.embedded.resource.RARDeployment;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MCClientKernelAbstraction implements ClientKernelAbstraction
+{
+ private static final Logger log = Logger.getLogger(MCClientKernelAbstraction.class);
+
+ protected Kernel kernel;
+
+ public MCClientKernelAbstraction(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+ public Object invoke(ObjectName objectName, String operationName, Object[] params, String[] signature) throws Exception
+ {
+ String name = objectName.getCanonicalName();
+ KernelRegistryEntry entry = kernel.getRegistry().getEntry(name);
+ if (entry != null)
+ {
+ Object target = entry.getTarget();
+ if (target instanceof RARDeployment)
+ {
+ RARDeployment deployment = (RARDeployment)target;
+ return deployment.invoke(operationName, params, signature);
+ }
+ else
+ {
+ Class[] types = new Class[signature.length];
+ for (int i = 0; i < signature.length; ++i)
+ {
+ types[i] = Thread.currentThread().getContextClassLoader().loadClass(signature[i]);
+ }
+ Method method = target.getClass().getMethod(operationName, types);
+ return method.invoke(target, params);
+ }
+ }
+ return null;
+ }
+}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java 2006-08-17 01:09:56 UTC (rev 56012)
+++ trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java 2006-08-17 01:18:34 UTC (rev 56013)
@@ -47,7 +47,9 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public class MCKernelAbstraction implements KernelAbstraction
+public class MCKernelAbstraction
+ extends MCClientKernelAbstraction
+ implements KernelAbstraction
{
private static final Logger log = Logger.getLogger(MCKernelAbstraction.class);
@@ -72,13 +74,12 @@
this.setFactoryMethod("create");
}
}
-
- private Kernel kernel;
+
private MBeanServer server;
public MCKernelAbstraction(Kernel kernel, MBeanServer server)
{
- this.kernel = kernel;
+ super(kernel);
this.server = server;
}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/unit/InflowUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/unit/InflowUnitTestCase.java 2006-08-17 01:09:56 UTC (rev 56012)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/unit/InflowUnitTestCase.java 2006-08-17 01:18:34 UTC (rev 56013)
@@ -24,7 +24,7 @@
import javax.management.ObjectName;
import org.jboss.ejb3.InitialContextFactory;
-import org.jboss.ejb3.KernelAbstraction;
+import org.jboss.ejb3.ClientKernelAbstraction;
import org.jboss.ejb3.KernelAbstractionFactory;
import org.jboss.ejb3.test.jca.inflow.TestResourceAdapter;
@@ -50,7 +50,7 @@
public void testInflow() throws Throwable
{
- KernelAbstraction kernel = KernelAbstractionFactory.getInstance();
+ ClientKernelAbstraction kernel = KernelAbstractionFactory.getClientInstance();
TestResourceAdapterInflowResults results = (TestResourceAdapterInflowResults)kernel.invoke
(
TestResourceAdapter.mbean,
More information about the jboss-cvs-commits
mailing list