[jboss-cvs] JBossAS SVN: r97298 - projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 2 10:46:00 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-12-02 10:45:59 -0500 (Wed, 02 Dec 2009)
New Revision: 97298
Added:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/DeployerServiceClient.java
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
Log:
Delegate to the Deployer service registered in JMX
Added: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/DeployerServiceClient.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/DeployerServiceClient.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/DeployerServiceClient.java 2009-12-02 15:45:59 UTC (rev 97298)
@@ -0,0 +1,99 @@
+/*
+ * 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.osgi.testing.internal;
+
+// $Id$
+
+import java.net.URL;
+import java.util.Arrays;
+
+import javax.management.MBeanException;
+import javax.management.ObjectName;
+
+import org.jboss.osgi.deployment.deployer.AbstractDeployerService;
+import org.jboss.osgi.deployment.deployer.Deployment;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.osgi.framework.BundleException;
+
+/**
+ * An abstract implementation of the {@link OSGiRuntime}
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+class DeployerServiceClient extends AbstractDeployerService
+{
+ private final OSGiRuntime runtime;
+ private ObjectName oname;
+
+ DeployerServiceClient(OSGiRuntime runtime, ObjectName oname)
+ {
+ this.runtime = runtime;
+ this.oname = oname;
+ }
+
+ public void deploy(Deployment[] deps) throws BundleException
+ {
+ invokeDeployerMBean(oname, "deploy", deps, Deployment[].class.getName());
+ }
+
+ public void deploy(URL url) throws BundleException
+ {
+ invokeDeployerMBean(oname, "deploy", url, URL.class.getName());
+ }
+
+ public void undeploy(Deployment[] deps) throws BundleException
+ {
+ invokeDeployerMBean(oname, "undeploy", deps, Deployment[].class.getName());
+ }
+
+ public void undeploy(URL url) throws BundleException
+ {
+ invokeDeployerMBean(oname, "undeploy", url, URL.class.getName());
+ }
+
+ private void invokeDeployerMBean(ObjectName oname, String method, Object arg, String type) throws BundleException
+ {
+ try
+ {
+ this.runtime.getMBeanServer().invoke(oname, method, new Object[] { arg }, new String[] { type });
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ if (ex instanceof MBeanException)
+ {
+ ex = ((MBeanException)ex).getTargetException();
+ if (ex instanceof BundleException)
+ throw (BundleException)ex;
+ }
+
+ if (arg instanceof Deployment[])
+ arg = Arrays.asList((Deployment[])arg);
+
+ throw new BundleException("Cannot " + method + ": " + arg, ex);
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/DeployerServiceClient.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2009-12-02 15:38:01 UTC (rev 97297)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2009-12-02 15:45:59 UTC (rev 97298)
@@ -34,6 +34,7 @@
import javax.management.MBeanServerFactory;
import org.jboss.osgi.deployment.deployer.DeployerService;
+import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.spi.capability.Capability;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.util.BundleInfo;
@@ -77,8 +78,19 @@
ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
if (sref != null)
{
- DeployerService service = (DeployerService)context.getService(sref);
- service.deploy(rootURL);
+ Object obj = context.getService(sref);
+ if (obj instanceof DeployerService)
+ {
+ DeployerService service = (DeployerService)obj;
+ service.deploy(rootURL);
+ }
+ else
+ {
+ DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
+ Deployment dep = deployer.createDeployment(info);
+ dep.setAutoStart(false);
+ deployer.deploy(new Deployment[] { dep });
+ }
bundle = getBundle(symbolicName, version, true);
}
else
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2009-12-02 15:38:01 UTC (rev 97297)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2009-12-02 15:45:59 UTC (rev 97298)
@@ -36,14 +36,10 @@
import java.util.jar.JarFile;
import java.util.jar.Manifest;
-import javax.management.MBeanException;
-import javax.management.ObjectName;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.jboss.osgi.deployment.deployer.AbstractDeployerService;
import org.jboss.osgi.deployment.deployer.DeployerService;
-import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.spi.capability.Capability;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.osgi.testing.OSGiBundle;
@@ -170,13 +166,13 @@
protected void deploy(URL archiveURL) throws Exception
{
- DeployerServiceClient deployer = new DeployerServiceClient(DeployerService.MBEAN_DEPLOYER_SERVICE);
+ DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
deployer.deploy(archiveURL);
}
protected void undeploy(URL archiveURL) throws Exception
{
- DeployerServiceClient deployer = new DeployerServiceClient(DeployerService.MBEAN_DEPLOYER_SERVICE);
+ DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
deployer.undeploy(archiveURL);
}
@@ -308,60 +304,4 @@
}
}
}
-
- class DeployerServiceClient extends AbstractDeployerService
- {
- private ObjectName oname;
-
- DeployerServiceClient(ObjectName oname)
- {
- this.oname = oname;
- }
-
- public void deploy(Deployment[] deps) throws BundleException
- {
- invokeDeployerMBean(oname, "deploy", deps, Deployment[].class.getName());
- }
-
- public void deploy(URL url) throws BundleException
- {
- invokeDeployerMBean(oname, "deploy", url, URL.class.getName());
- }
-
- public void undeploy(Deployment[] deps) throws BundleException
- {
- invokeDeployerMBean(oname, "undeploy", deps, Deployment[].class.getName());
- }
-
- public void undeploy(URL url) throws BundleException
- {
- invokeDeployerMBean(oname, "undeploy", url, URL.class.getName());
- }
-
- private void invokeDeployerMBean(ObjectName oname, String method, Object arg, String type) throws BundleException
- {
- try
- {
- getMBeanServer().invoke(oname, method, new Object[] { arg }, new String[] { type });
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- if (ex instanceof MBeanException)
- {
- ex = ((MBeanException)ex).getTargetException();
- if (ex instanceof BundleException)
- throw (BundleException)ex;
- }
-
- if (arg instanceof Deployment[])
- arg = Arrays.asList((Deployment[])arg);
-
- throw new BundleException("Cannot " + method + ": " + arg, ex);
- }
- }
- }
}
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2009-12-02 15:38:01 UTC (rev 97297)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2009-12-02 15:45:59 UTC (rev 97298)
@@ -72,7 +72,7 @@
BundleInfo info = BundleInfo.createBundleInfo(location);
// Create the deployment from the info
- DeployerServiceClient deployer = new DeployerServiceClient(DeployerService.MBEAN_DEPLOYER_SERVICE);
+ DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
Deployment dep = deployer.createDeployment(info);
dep.setAutoStart(false);
@@ -115,7 +115,7 @@
{
URL archiveURL = getTestHelper().getTestArchiveURL(location);
ObjectName oname = getDeployerServiceName(archiveURL);
- DeployerServiceClient deployer = new DeployerServiceClient(oname);
+ DeployerServiceClient deployer = new DeployerServiceClient(this, oname);
deployer.deploy(archiveURL);
}
@@ -123,7 +123,7 @@
{
URL archiveURL = getTestHelper().getTestArchiveURL(location);
ObjectName oname = getDeployerServiceName(archiveURL);
- DeployerServiceClient deployer = new DeployerServiceClient(oname);
+ DeployerServiceClient deployer = new DeployerServiceClient(this, oname);
deployer.undeploy(archiveURL);
}
More information about the jboss-cvs-commits
mailing list