[jboss-cvs] JBossAS SVN: r73655 - in projects/ejb3/trunk: proxy/src/test/java/org/jboss/ejb3/test/proxy/common and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat May 24 16:31:29 EDT 2008
Author: ALRubinger
Date: 2008-05-24 16:31:29 -0400 (Sat, 24 May 2008)
New Revision: 73655
Added:
projects/ejb3/trunk/test/src/main/java/org/
projects/ejb3/trunk/test/src/main/java/org/jboss/
projects/ejb3/trunk/test/src/main/java/org/jboss/test/
projects/ejb3/trunk/test/src/main/java/org/jboss/test/mc/
projects/ejb3/trunk/test/src/main/java/org/jboss/test/mc/bootstrap/
projects/ejb3/trunk/test/src/main/java/org/jboss/test/mc/bootstrap/EmbeddedTestMcBootstrap.java
Removed:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/EmbeddedTestMcBootstrap.java
Modified:
projects/ejb3/trunk/proxy/pom.xml
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/registry/ProxyFactoryRegistryUnitTestCaseBase.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/ProxyEqualityTestCaseBase.java
Log:
[EJBTHREE-1380] Moved EmbeddedTestMcBootstrap to EJB3 Test
Modified: projects/ejb3/trunk/proxy/pom.xml
===================================================================
--- projects/ejb3/trunk/proxy/pom.xml 2008-05-24 20:24:16 UTC (rev 73654)
+++ projects/ejb3/trunk/proxy/pom.xml 2008-05-24 20:31:29 UTC (rev 73655)
@@ -127,7 +127,7 @@
<dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-common</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>0.1.1-SNAPSHOT</version>
</dependency>
<dependency>
@@ -136,6 +136,13 @@
<version>0.13.0</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-test</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/EmbeddedTestMcBootstrap.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/EmbeddedTestMcBootstrap.java 2008-05-24 20:24:16 UTC (rev 73654)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/EmbeddedTestMcBootstrap.java 2008-05-24 20:31:29 UTC (rev 73655)
@@ -1,350 +0,0 @@
-/*
- * 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.ejb3.test.proxy.common;
-
-import java.net.URL;
-
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
-import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.logging.Logger;
-
-/**
- * EmbeddedTestMcBootstrap
- *
- * A MicroContainer Bootstrap for general use in testing
- * runtimes
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class EmbeddedTestMcBootstrap extends BasicBootstrap
-{
- // --------------------------------------------------------------------------------||
- // Class Members ------------------------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(EmbeddedTestMcBootstrap.class);
-
- private static final String DEFAULT_SUFFIX_DEPLOYABLE_XML = "-beans.xml";
-
- // --------------------------------------------------------------------------------||
- // Instance Members ---------------------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- private BasicXMLDeployer deployer;
-
- private Thread shutdownHook;
-
- // --------------------------------------------------------------------------------||
- // Constructors -------------------------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- public EmbeddedTestMcBootstrap()
- {
- super();
- }
-
- // --------------------------------------------------------------------------------||
- // Static Methods -----------------------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- /**
- * Creates, runs, and returns a new Embedded MC Bootstrap
- */
- public static EmbeddedTestMcBootstrap createEmbeddedMcBootstrap()
- {
- EmbeddedTestMcBootstrap bootstrap = new EmbeddedTestMcBootstrap();
- log.debug("Starting " + bootstrap + "...");
- bootstrap.run();
- log.info("Started: " + bootstrap);
- return bootstrap;
- }
-
- // --------------------------------------------------------------------------------||
- // Overridden Implementations -----------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- @Override
- protected void bootstrap() throws Throwable
- {
- // Call super implementation
- super.bootstrap();
-
- // Create and set an XML Deployer
- this.setDeployer(new BasicXMLDeployer(this.getKernel()));
-
- // Add a shutdown hook
- shutdownHook = new ShutdownDeployerThread();
- Runtime.getRuntime().addShutdownHook(shutdownHook);
- }
-
- // --------------------------------------------------------------------------------||
- // Functional Methods -------------------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- /**
- * Deploys the specified URL
- *
- * @param url
- */
- public void deploy(URL url)
- {
- try
- {
- log.debug("Deploying " + url.toString() + "...");
- this.getDeployer().deploy(url);
- log.info("Deployed: " + url.toString());
- }
- catch (Throwable e)
- {
- throw new RuntimeException("Could not deploy " + url.toString(), e);
- }
- }
-
- /**
- * Deploys the specified URL expressed as a String
- *
- * @param url
- */
- public void deploy(ClassLoader cl, String url)
- {
- URL deployable = this.getResource(cl, url);
- this.deploy(deployable);
- }
-
- /**
- * Deploy a URL in the form "fullyQualifiedClassName-beans.xml" constructed
- * from the specified testClass
- *
- * @param testClass
- */
- public void deploy(Class<?> testClass)
- {
- this.deploy(testClass, null);
- }
-
- /**
- * Deploy a URL in the form "packageName.filename-beans.xml" constructed
- * from the specified testClass and filename
- *
- * @param testClass
- * @param filename
- */
- public void deploy(Class<?> testClass, String filename)
- {
- this.deploy(testClass.getClassLoader(), this.getDeployableXmlUrl(testClass, filename));
- }
-
- /**
- * @param name
- */
- public <T> T lookup(String name, Class<T> expectedType) throws Throwable
- {
- KernelController controller = getKernel().getController();
- ControllerContext context = controller.getContext(name, null);
- controller.change(context, ControllerState.INSTALLED);
- if (context.getError() != null)
- throw context.getError();
-
- if (context.getState() != ControllerState.INSTALLED)
- {
- log.error(context.getDependencyInfo().getUnresolvedDependencies(null));
- }
- // TODO: it can be stalled because of dependencies
- assert context.getState() == ControllerState.INSTALLED;
-
- return expectedType.cast(context.getTarget());
- }
-
- /**
- * Undeploys the specified URL
- *
- * @param url
- */
- public void undeploy(URL url)
- {
- try
- {
- log.debug("Undeploying " + url.toString() + "...");
- this.getDeployer().undeploy(url);
- log.info("Undeployed: " + url.toString());
- }
- catch (Throwable e)
- {
- throw new RuntimeException("Could not undeploy " + url.toString(), e);
- }
- }
-
- /**
- * Undeploys the specified URL expressed as a String
- *
- * @param url
- */
- public void undeploy(ClassLoader cl, String url)
- {
- URL deployable = this.getResource(cl, url);
- this.undeploy(deployable);
- }
-
- /**
- * Undeploy a URL in the form "fullyQualifiedClassName-beans.xml" constructed
- * from the specified testClass
- *
- * @param testClass
- */
- public void undeploy(Class<?> testClass)
- {
- this.undeploy(testClass, null);
- }
-
- /**
- * Undeploy a URL in the form "packageName.filename-beans.xml" constructed
- * from the specified testClass and filename
- *
- * @param testClass
- * @param filename
- */
- public void undeploy(Class<?> testClass, String filename)
- {
- this.undeploy(testClass.getClassLoader(), this.getDeployableXmlUrl(testClass, filename));
- }
-
- // --------------------------------------------------------------------------------||
- // Accessors / Mutators -----------------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- protected BasicXMLDeployer getDeployer()
- {
- return deployer;
- }
-
- protected void setDeployer(BasicXMLDeployer deployer)
- {
- this.deployer = deployer;
- }
-
- // --------------------------------------------------------------------------------||
- // Inner Classes ------------------------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- /**
- * ShutdownDeployerThread
- *
- * A Simple Thread that, when run, will shut down its deployer
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
- protected final class ShutdownDeployerThread extends Thread
- {
- @Override
- public void run()
- {
- super.run();
-
- shutdownHook();
- }
-
- }
-
- // --------------------------------------------------------------------------------||
- // Helper Methods -----------------------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- private String getDeployableXmlUrl(Class<?> clazz, String filename)
- {
- // Initialize
- StringBuffer url = new StringBuffer();
-
- // If the filename is specified
- if (filename != null)
- {
- // Assemble filename in form "packagename.filename"
- url.append(clazz.getClass().getPackage().toString());
- url.append('.');
- url.append(filename);
- }
- // Use default filename for the test class
- else
- {
- // Assemble filename in form "fullyQualifiedClassName"
- url.append(clazz.getName());
- }
-
- // Make a String
- String flatten = url.toString();
-
- // Adjust for filename structure instead of package structure
- flatten = flatten.replace('.', '/');
-
- // Append Suffix
- flatten = flatten + EmbeddedTestMcBootstrap.DEFAULT_SUFFIX_DEPLOYABLE_XML;
-
- // Return
- return flatten;
- }
-
- private URL getResource(ClassLoader cl, String resource)
- {
- // Ensure specified
- assert cl != null : "Specified " + ClassLoader.class.getSimpleName() + " is null";
- assert resource != null && !resource.equals("") : "Resource must be specified";
-
- // Obtain URL
- URL url = cl.getResource(resource);
- if (url == null)
- {
- throw new RuntimeException("Resource \"" + resource + "\" could not be obtained from current classloader");
- }
- return url;
- }
-
- public void installInstance(String name, Object instance) throws Throwable
- {
- BeanMetaDataBuilder bmdb = BeanMetaDataBuilder.createBuilder(name, instance.getClass().getName());
- this.getKernel().getController().install(bmdb.getBeanMetaData(),instance);
- log.info("Installed in MC at \"" + name + "\": " + instance);
- }
-
- /**
- * Perform a clean shutdown.
- */
- public void shutdown()
- {
- // remove the hook
- Runtime.getRuntime().removeShutdownHook(shutdownHook);
-
- // and call it.
- shutdownHook();
- }
-
- private void shutdownHook()
- {
- log.debug("Shutting down " + this.deployer + "...");
- getDeployer().shutdown();
- log.info("Shut down: " + getDeployer());
- }
-}
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/registry/ProxyFactoryRegistryUnitTestCaseBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/registry/ProxyFactoryRegistryUnitTestCaseBase.java 2008-05-24 20:24:16 UTC (rev 73654)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/registry/ProxyFactoryRegistryUnitTestCaseBase.java 2008-05-24 20:31:29 UTC (rev 73655)
@@ -30,8 +30,8 @@
import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryAlreadyRegisteredException;
import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryNotRegisteredException;
import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryRegistry;
-import org.jboss.ejb3.test.proxy.common.EmbeddedTestMcBootstrap;
import org.jboss.logging.Logger;
+import org.jboss.test.mc.bootstrap.EmbeddedTestMcBootstrap;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java 2008-05-24 20:24:16 UTC (rev 73654)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java 2008-05-24 20:31:29 UTC (rev 73655)
@@ -24,15 +24,9 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.lang.reflect.AnnotatedElement;
-import java.util.Collection;
-import java.util.HashSet;
-
import javax.naming.InitialContext;
import org.jboss.ejb3.proxy.hack.Hack;
-import org.jboss.ejb3.proxy.mc.MicrocontainerBindings;
-import org.jboss.ejb3.test.proxy.common.EmbeddedTestMcBootstrap;
import org.jboss.ejb3.test.proxy.common.Utils;
import org.jboss.ejb3.test.proxy.common.container.StatelessContainer;
import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessBean;
@@ -41,14 +35,7 @@
import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessRemote;
import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessRemoteHome;
import org.jboss.logging.Logger;
-import org.jboss.metadata.annotation.creator.ejb.EjbJar30Creator;
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionPolicyDecorator;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
-import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+import org.jboss.test.mc.bootstrap.EmbeddedTestMcBootstrap;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/ProxyEqualityTestCaseBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/ProxyEqualityTestCaseBase.java 2008-05-24 20:24:16 UTC (rev 73654)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/ProxyEqualityTestCaseBase.java 2008-05-24 20:31:29 UTC (rev 73655)
@@ -28,9 +28,9 @@
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.hack.Hack;
import org.jboss.ejb3.proxy.handler.ProxyInvocationHandler;
-import org.jboss.ejb3.test.proxy.common.EmbeddedTestMcBootstrap;
import org.jboss.ejb3.test.proxy.common.container.SessionContainer;
import org.jboss.logging.Logger;
+import org.jboss.test.mc.bootstrap.EmbeddedTestMcBootstrap;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Copied: projects/ejb3/trunk/test/src/main/java/org/jboss/test/mc/bootstrap/EmbeddedTestMcBootstrap.java (from rev 73651, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/EmbeddedTestMcBootstrap.java)
===================================================================
--- projects/ejb3/trunk/test/src/main/java/org/jboss/test/mc/bootstrap/EmbeddedTestMcBootstrap.java (rev 0)
+++ projects/ejb3/trunk/test/src/main/java/org/jboss/test/mc/bootstrap/EmbeddedTestMcBootstrap.java 2008-05-24 20:31:29 UTC (rev 73655)
@@ -0,0 +1,350 @@
+/*
+ * 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.test.mc.bootstrap;
+
+import java.net.URL;
+
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.logging.Logger;
+
+/**
+ * EmbeddedTestMcBootstrap
+ *
+ * A MicroContainer Bootstrap for general use in testing
+ * runtimes
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class EmbeddedTestMcBootstrap extends BasicBootstrap
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(EmbeddedTestMcBootstrap.class);
+
+ private static final String DEFAULT_SUFFIX_DEPLOYABLE_XML = "-beans.xml";
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private BasicXMLDeployer deployer;
+
+ private Thread shutdownHook;
+
+ // --------------------------------------------------------------------------------||
+ // Constructors -------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public EmbeddedTestMcBootstrap()
+ {
+ super();
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Static Methods -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Creates, runs, and returns a new Embedded MC Bootstrap
+ */
+ public static EmbeddedTestMcBootstrap createEmbeddedMcBootstrap()
+ {
+ EmbeddedTestMcBootstrap bootstrap = new EmbeddedTestMcBootstrap();
+ log.debug("Starting " + bootstrap + "...");
+ bootstrap.run();
+ log.info("Started: " + bootstrap);
+ return bootstrap;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Overridden Implementations -----------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ @Override
+ protected void bootstrap() throws Throwable
+ {
+ // Call super implementation
+ super.bootstrap();
+
+ // Create and set an XML Deployer
+ this.setDeployer(new BasicXMLDeployer(this.getKernel()));
+
+ // Add a shutdown hook
+ shutdownHook = new ShutdownDeployerThread();
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Functional Methods -------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Deploys the specified URL
+ *
+ * @param url
+ */
+ public void deploy(URL url)
+ {
+ try
+ {
+ log.debug("Deploying " + url.toString() + "...");
+ this.getDeployer().deploy(url);
+ log.info("Deployed: " + url.toString());
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("Could not deploy " + url.toString(), e);
+ }
+ }
+
+ /**
+ * Deploys the specified URL expressed as a String
+ *
+ * @param url
+ */
+ public void deploy(ClassLoader cl, String url)
+ {
+ URL deployable = this.getResource(cl, url);
+ this.deploy(deployable);
+ }
+
+ /**
+ * Deploy a URL in the form "fullyQualifiedClassName-beans.xml" constructed
+ * from the specified testClass
+ *
+ * @param testClass
+ */
+ public void deploy(Class<?> testClass)
+ {
+ this.deploy(testClass, null);
+ }
+
+ /**
+ * Deploy a URL in the form "packageName.filename-beans.xml" constructed
+ * from the specified testClass and filename
+ *
+ * @param testClass
+ * @param filename
+ */
+ public void deploy(Class<?> testClass, String filename)
+ {
+ this.deploy(testClass.getClassLoader(), this.getDeployableXmlUrl(testClass, filename));
+ }
+
+ /**
+ * @param name
+ */
+ public <T> T lookup(String name, Class<T> expectedType) throws Throwable
+ {
+ KernelController controller = getKernel().getController();
+ ControllerContext context = controller.getContext(name, null);
+ controller.change(context, ControllerState.INSTALLED);
+ if (context.getError() != null)
+ throw context.getError();
+
+ if (context.getState() != ControllerState.INSTALLED)
+ {
+ log.error(context.getDependencyInfo().getUnresolvedDependencies(null));
+ }
+ // TODO: it can be stalled because of dependencies
+ assert context.getState() == ControllerState.INSTALLED;
+
+ return expectedType.cast(context.getTarget());
+ }
+
+ /**
+ * Undeploys the specified URL
+ *
+ * @param url
+ */
+ public void undeploy(URL url)
+ {
+ try
+ {
+ log.debug("Undeploying " + url.toString() + "...");
+ this.getDeployer().undeploy(url);
+ log.info("Undeployed: " + url.toString());
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("Could not undeploy " + url.toString(), e);
+ }
+ }
+
+ /**
+ * Undeploys the specified URL expressed as a String
+ *
+ * @param url
+ */
+ public void undeploy(ClassLoader cl, String url)
+ {
+ URL deployable = this.getResource(cl, url);
+ this.undeploy(deployable);
+ }
+
+ /**
+ * Undeploy a URL in the form "fullyQualifiedClassName-beans.xml" constructed
+ * from the specified testClass
+ *
+ * @param testClass
+ */
+ public void undeploy(Class<?> testClass)
+ {
+ this.undeploy(testClass, null);
+ }
+
+ /**
+ * Undeploy a URL in the form "packageName.filename-beans.xml" constructed
+ * from the specified testClass and filename
+ *
+ * @param testClass
+ * @param filename
+ */
+ public void undeploy(Class<?> testClass, String filename)
+ {
+ this.undeploy(testClass.getClassLoader(), this.getDeployableXmlUrl(testClass, filename));
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Accessors / Mutators -----------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ protected BasicXMLDeployer getDeployer()
+ {
+ return deployer;
+ }
+
+ protected void setDeployer(BasicXMLDeployer deployer)
+ {
+ this.deployer = deployer;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Inner Classes ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * ShutdownDeployerThread
+ *
+ * A Simple Thread that, when run, will shut down its deployer
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ protected final class ShutdownDeployerThread extends Thread
+ {
+ @Override
+ public void run()
+ {
+ super.run();
+
+ shutdownHook();
+ }
+
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Helper Methods -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private String getDeployableXmlUrl(Class<?> clazz, String filename)
+ {
+ // Initialize
+ StringBuffer url = new StringBuffer();
+
+ // If the filename is specified
+ if (filename != null)
+ {
+ // Assemble filename in form "packagename.filename"
+ url.append(clazz.getClass().getPackage().toString());
+ url.append('.');
+ url.append(filename);
+ }
+ // Use default filename for the test class
+ else
+ {
+ // Assemble filename in form "fullyQualifiedClassName"
+ url.append(clazz.getName());
+ }
+
+ // Make a String
+ String flatten = url.toString();
+
+ // Adjust for filename structure instead of package structure
+ flatten = flatten.replace('.', '/');
+
+ // Append Suffix
+ flatten = flatten + EmbeddedTestMcBootstrap.DEFAULT_SUFFIX_DEPLOYABLE_XML;
+
+ // Return
+ return flatten;
+ }
+
+ private URL getResource(ClassLoader cl, String resource)
+ {
+ // Ensure specified
+ assert cl != null : "Specified " + ClassLoader.class.getSimpleName() + " is null";
+ assert resource != null && !resource.equals("") : "Resource must be specified";
+
+ // Obtain URL
+ URL url = cl.getResource(resource);
+ if (url == null)
+ {
+ throw new RuntimeException("Resource \"" + resource + "\" could not be obtained from current classloader");
+ }
+ return url;
+ }
+
+ public void installInstance(String name, Object instance) throws Throwable
+ {
+ BeanMetaDataBuilder bmdb = BeanMetaDataBuilder.createBuilder(name, instance.getClass().getName());
+ this.getKernel().getController().install(bmdb.getBeanMetaData(),instance);
+ log.info("Installed in MC at \"" + name + "\": " + instance);
+ }
+
+ /**
+ * Perform a clean shutdown.
+ */
+ public void shutdown()
+ {
+ // remove the hook
+ Runtime.getRuntime().removeShutdownHook(shutdownHook);
+
+ // and call it.
+ shutdownHook();
+ }
+
+ private void shutdownHook()
+ {
+ log.debug("Shutting down " + this.deployer + "...");
+ getDeployer().shutdown();
+ log.info("Shut down: " + getDeployer());
+ }
+}
More information about the jboss-cvs-commits
mailing list