[jboss-svn-commits] JBoss Common SVN: r4367 - in arquillian/trunk/containers: jbossas-embedded-60/src/main/resources/META-INF/services and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 7 20:15:39 EDT 2010
Author: aslak
Date: 2010-05-07 20:15:38 -0400 (Fri, 07 May 2010)
New Revision: 4367
Added:
arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java
arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JBossEmbeddedContainer.java
arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java
arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JBossRemoteContainer.java
arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java
arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JBossRemoteContainer.java
Removed:
arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java
arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JbossEmbeddedContainer.java
arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java
arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JbossRemoteContainer.java
arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java
arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JbossRemoteContainer.java
Modified:
arquillian/trunk/containers/jbossas-embedded-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
arquillian/trunk/containers/jbossas-embedded-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
arquillian/trunk/containers/jbossas-remote-51/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
arquillian/trunk/containers/jbossas-remote-51/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
arquillian/trunk/containers/jbossas-remote-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
arquillian/trunk/containers/jbossas-remote-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
Log:
ARQ-99 Renamed Jboss classes to JBoss, capital B
Copied: arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java (from rev 4348, arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java)
===================================================================
--- arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java (rev 0)
+++ arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.jboss;
+
+import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
+import org.jboss.arquillian.spi.TestEnricher;
+import org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher;
+import org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher;
+import org.jboss.arquillian.testenricher.resource.ResourceInjectionEnricher;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+/**
+ * EmbeddedDeploymentAppender
+ *
+ * Package the required dependencies needed by the Jboss Embedded Container plugin
+ * to run in container.
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class JBossDeploymentAppender implements AuxiliaryArchiveAppender
+{
+
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.DeploymentAppender#createArchive()
+ */
+ public Archive<?> createAuxiliaryArchive()
+ {
+ JavaArchive archive = ShrinkWrap.create("arquillian-jboss-testenrichers.jar", JavaArchive.class)
+ .addPackages(
+ true,
+ EJBInjectionEnricher.class.getPackage(),
+ ResourceInjectionEnricher.class.getPackage(),
+ CDIInjectionEnricher.class.getPackage())
+ .addServiceProvider(
+ TestEnricher.class,
+ EJBInjectionEnricher.class,
+ ResourceInjectionEnricher.class,
+ CDIInjectionEnricher.class);
+ return archive;
+ }
+
+}
Copied: arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JBossEmbeddedContainer.java (from rev 4348, arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JbossEmbeddedContainer.java)
===================================================================
--- arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JBossEmbeddedContainer.java (rev 0)
+++ arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JBossEmbeddedContainer.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.jboss;
+
+import java.net.URL;
+
+import org.jboss.arquillian.protocol.servlet.ServletMethodExecutor;
+import org.jboss.arquillian.spi.Configuration;
+import org.jboss.arquillian.spi.ContainerMethodExecutor;
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.DeployableContainer;
+import org.jboss.arquillian.spi.DeploymentException;
+import org.jboss.arquillian.spi.LifecycleException;
+import org.jboss.embedded.api.server.JBossASEmbeddedServer;
+import org.jboss.embedded.core.server.JBossASEmbeddedServerImpl;
+import org.jboss.shrinkwrap.api.Archive;
+
+/**
+ * JbossEmbeddedContainer
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class JBossEmbeddedContainer implements DeployableContainer
+{
+ private JBossASEmbeddedServer server;
+
+ public JBossEmbeddedContainer()
+ {
+ server = new JBossASEmbeddedServerImpl();
+ server.getConfiguration().bindAddress("localhost");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.DeployableContainer#setup(org.jboss.arquillian.spi.Context, org.jboss.arquillian.spi.Configuration)
+ */
+ public void setup(Context context, Configuration configuration)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.DeployableContainer#start(org.jboss.arquillian.spi.Context)
+ */
+ public void start(Context context) throws LifecycleException
+ {
+ try
+ {
+ server.start();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not start container", e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.DeployableContainer#stop(org.jboss.arquillian.spi.Context)
+ */
+ public void stop(Context context) throws LifecycleException
+ {
+ try
+ {
+ server.stop();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not stop container", e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.DeployableContainer#deploy(org.jboss.arquillian.spi.Context, org.jboss.shrinkwrap.api.Archive)
+ */
+ public ContainerMethodExecutor deploy(Context context, Archive<?> archive) throws DeploymentException
+ {
+ try
+ {
+ server.deploy(archive);
+
+ return new ServletMethodExecutor(
+ new URL(
+ "http",
+ server.getConfiguration().getBindAddress(),
+ 8080,
+ "/")
+ );
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Could not deploy to container", e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.arquillian.spi.DeployableContainer#undeploy(org.jboss.arquillian.spi.Context, org.jboss.shrinkwrap.api.Archive)
+ */
+ public void undeploy(Context context, Archive<?> archive) throws DeploymentException
+ {
+ try
+ {
+ server.undeploy(archive);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Could not undeploy from container", e);
+ }
+ }
+}
Deleted: arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java
===================================================================
--- arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.jboss;
-
-import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
-import org.jboss.arquillian.spi.TestEnricher;
-import org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher;
-import org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher;
-import org.jboss.arquillian.testenricher.resource.ResourceInjectionEnricher;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.Archives;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-
-/**
- * EmbeddedDeploymentAppender
- *
- * Package the required dependencies needed by the Jboss Embedded Container plugin
- * to run in container.
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public class JbossDeploymentAppender implements AuxiliaryArchiveAppender
-{
-
- /* (non-Javadoc)
- * @see org.jboss.arquillian.spi.DeploymentAppender#createArchive()
- */
- @Override
- public Archive<?> createAuxiliaryArchive()
- {
- JavaArchive archive = Archives.create("arquillian-jboss-testenrichers.jar", JavaArchive.class)
- .addPackages(
- true,
- EJBInjectionEnricher.class.getPackage(),
- ResourceInjectionEnricher.class.getPackage(),
- CDIInjectionEnricher.class.getPackage())
- .addServiceProvider(
- TestEnricher.class,
- EJBInjectionEnricher.class,
- ResourceInjectionEnricher.class,
- CDIInjectionEnricher.class);
- return archive;
- }
-
-}
Deleted: arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JbossEmbeddedContainer.java
===================================================================
--- arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JbossEmbeddedContainer.java 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-embedded-60/src/main/java/org/jboss/arquillian/jboss/JbossEmbeddedContainer.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1,105 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.jboss;
-
-import java.net.URL;
-
-import org.jboss.arquillian.protocol.servlet.ServletMethodExecutor;
-import org.jboss.arquillian.spi.ContainerMethodExecutor;
-import org.jboss.arquillian.spi.DeployableContainer;
-import org.jboss.arquillian.spi.DeploymentException;
-import org.jboss.arquillian.spi.LifecycleException;
-import org.jboss.embedded.api.server.JBossASEmbeddedServer;
-import org.jboss.embedded.core.server.JBossASEmbeddedServerImpl;
-import org.jboss.shrinkwrap.api.Archive;
-
-/**
- * JbossEmbeddedContainer
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public class JbossEmbeddedContainer implements DeployableContainer
-{
- private JBossASEmbeddedServer server;
-
- public JbossEmbeddedContainer()
- {
- server = new JBossASEmbeddedServerImpl();
- server.getConfiguration().bindAddress("localhost");
- }
-
- @Override
- public void start() throws LifecycleException
- {
- try
- {
- server.start();
- }
- catch (Exception e)
- {
- throw new LifecycleException("Could not start container", e);
- }
- }
-
- @Override
- public void stop() throws LifecycleException
- {
- try
- {
- server.stop();
- }
- catch (Exception e)
- {
- throw new LifecycleException("Could not stop container", e);
- }
- }
-
- @Override
- public ContainerMethodExecutor deploy(Archive<?> archive) throws DeploymentException
- {
- try
- {
- server.deploy(archive);
-
- return new ServletMethodExecutor(
- new URL(
- "http",
- server.getConfiguration().getBindAddress(),
- 8080,
- "/")
- );
- }
- catch (Exception e)
- {
- throw new DeploymentException("Could not deploy to container", e);
- }
- }
-
- @Override
- public void undeploy(Archive<?> archive) throws DeploymentException
- {
- try
- {
- server.undeploy(archive);
- }
- catch (Exception e)
- {
- throw new DeploymentException("Could not undeploy from container", e);
- }
- }
-}
Modified: arquillian/trunk/containers/jbossas-embedded-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
===================================================================
--- arquillian/trunk/containers/jbossas-embedded-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-embedded-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1 +1 @@
-org.jboss.arquillian.jboss.JbossDeploymentAppender
\ No newline at end of file
+org.jboss.arquillian.jboss.JBossDeploymentAppender
\ No newline at end of file
Modified: arquillian/trunk/containers/jbossas-embedded-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
===================================================================
--- arquillian/trunk/containers/jbossas-embedded-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-embedded-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1 +1 @@
-org.jboss.arquillian.jboss.JbossEmbeddedContainer
\ No newline at end of file
+org.jboss.arquillian.jboss.JBossEmbeddedContainer
\ No newline at end of file
Copied: arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java (from rev 4348, arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java)
===================================================================
--- arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java (rev 0)
+++ arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.jboss;
+
+import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
+import org.jboss.arquillian.spi.TestEnricher;
+import org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher;
+import org.jboss.arquillian.testenricher.resource.ResourceInjectionEnricher;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+/**
+ * EmbeddedDeploymentAppender
+ *
+ * Package the required dependencies needed by the Jboss Embedded Container plugin
+ * to run in container.
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class JBossDeploymentAppender implements AuxiliaryArchiveAppender
+{
+
+ public Archive<?> createAuxiliaryArchive()
+ {
+ JavaArchive archive = ShrinkWrap.create("arquillian-jboss-testenrichers.jar", JavaArchive.class)
+ .addPackages(
+ true,
+ EJBInjectionEnricher.class.getPackage(),
+ ResourceInjectionEnricher.class.getPackage())
+ .addServiceProvider(
+ TestEnricher.class,
+ EJBInjectionEnricher.class,
+ ResourceInjectionEnricher.class);
+ return archive;
+ }
+
+}
Copied: arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JBossRemoteContainer.java (from rev 4348, arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JbossRemoteContainer.java)
===================================================================
--- arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JBossRemoteContainer.java (rev 0)
+++ arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JBossRemoteContainer.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -0,0 +1,302 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.jboss;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.InitialContext;
+
+import org.jboss.arquillian.protocol.servlet.ServletMethodExecutor;
+import org.jboss.arquillian.spi.Configuration;
+import org.jboss.arquillian.spi.ContainerMethodExecutor;
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.DeployableContainer;
+import org.jboss.arquillian.spi.DeploymentException;
+import org.jboss.arquillian.spi.LifecycleException;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.virtual.VFS;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+
+/**
+ * JbossRemoteContainer
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class JBossRemoteContainer implements DeployableContainer
+{
+ // TODO: replace by configuration
+ private static final String HOST_ADDRESS = "localhost";
+
+ //private static final Logger log = Logger.getLogger(JbossRemoteContainer.class.getName());
+
+ private final List<String> failedUndeployments = new ArrayList<String>();
+ private DeploymentManager deploymentManager;
+
+ private HttpServer httpFileServer;
+
+ private JBossConfiguration configuration;
+
+ public void setup(Context context, Configuration configuration)
+ {
+ this.configuration = configuration.getContainerConfig(JBossConfiguration.class);
+ }
+
+ public void start(Context context) throws LifecycleException
+ {
+ try
+ {
+ // TODO: configure http bind address
+ httpFileServer = HttpServer.create();
+ httpFileServer.bind(new InetSocketAddress(InetAddress.getByName(HOST_ADDRESS), 9000), -1);
+ httpFileServer.start();
+ initDeploymentManager();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not connect to container", e);
+ }
+ }
+
+ public void stop(Context context) throws LifecycleException
+ {
+ try
+ {
+ httpFileServer.stop(0);
+ removeFailedUnDeployments();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not clean up", e);
+ }
+ }
+
+ public ContainerMethodExecutor deploy(Context context, final Archive<?> archive) throws DeploymentException
+ {
+ if(archive == null)
+ {
+ throw new IllegalArgumentException("Archive must be specified");
+ }
+ if (deploymentManager == null)
+ {
+ throw new IllegalStateException("start has not been called!");
+ }
+ String deploymentName = archive.getName();
+
+ Exception failure = null;
+ try
+ {
+ httpFileServer.createContext("/" + deploymentName, new HttpHandler()
+ {
+ public void handle(HttpExchange exchange) throws IOException
+ {
+ InputStream zip = archive.as(ZipExporter.class).exportZip();
+ ByteArrayOutputStream zipStream = new ByteArrayOutputStream();
+ JBossRemoteContainer.copy(zip, zipStream);
+ zip.close();
+
+ byte[] zipArray = zipStream.toByteArray();
+ exchange.sendResponseHeaders(200, zipArray.length);
+
+ OutputStream out = exchange.getResponseBody();
+ out.write(zipArray);
+ out.close();
+
+ }
+ });
+ URL fileServerUrl = createFileServerURL(deploymentName);
+
+ DeploymentProgress distribute = deploymentManager.distribute(deploymentName, fileServerUrl, true);
+ distribute.run();
+ DeploymentStatus uploadStatus = distribute.getDeploymentStatus();
+ if(uploadStatus.isFailed())
+ {
+ failure = uploadStatus.getFailure();
+ undeploy(deploymentName);
+ }
+ else
+ {
+ DeploymentProgress progress = deploymentManager.start(deploymentName);
+ progress.run();
+ DeploymentStatus status = progress.getDeploymentStatus();
+ if (status.isFailed())
+ {
+ failure = status.getFailure();
+ undeploy(deploymentName);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Could not deploy " + deploymentName, e);
+ }
+ if (failure != null)
+ {
+ throw new DeploymentException("Failed to deply " + deploymentName, failure);
+ }
+ try
+ {
+ return new ServletMethodExecutor(
+ new URL(
+ "http",
+ findRemoteServerHostAddress(),
+ 8080,
+ "/")
+ );
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not create ContianerMethodExecutor", e);
+ }
+ }
+
+ public void undeploy(Context context, Archive<?> archive) throws DeploymentException
+ {
+ if(archive == null)
+ {
+ throw new IllegalArgumentException("Archive must be specified");
+ }
+ undeploy(archive.getName());
+ }
+
+ private void undeploy(String name) throws DeploymentException
+ {
+ try
+ {
+ DeploymentProgress stopProgress = deploymentManager.stop(name);
+ stopProgress.run();
+
+ DeploymentProgress undeployProgress = deploymentManager.remove(name);
+ undeployProgress.run();
+ if (undeployProgress.getDeploymentStatus().isFailed())
+ {
+ failedUndeployments.add(name);
+ }
+ httpFileServer.removeContext("/" + name);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Could not undeploy " + name, e);
+ }
+ }
+
+ private void initDeploymentManager() throws Exception
+ {
+ String profileName = "default";
+ InitialContext ctx = new InitialContext();
+ ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+ deploymentManager = ps.getDeploymentManager();
+ ProfileKey defaultKey = new ProfileKey(profileName);
+ deploymentManager.loadProfile(defaultKey);
+ VFS.init();
+ }
+
+ private URL createFileServerURL(String archiveName)
+ {
+ try
+ {
+ InetSocketAddress address = httpFileServer.getAddress();
+ return new URL(
+ "http",
+ address.getHostName(),
+ address.getPort(),
+ "/" + archiveName);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Could not create fileserver url", e);
+ }
+ }
+
+ private void removeFailedUnDeployments() throws IOException
+ {
+ List<String> remainingDeployments = new ArrayList<String>();
+ for (String name : failedUndeployments)
+ {
+ try
+ {
+ DeploymentProgress undeployProgress = deploymentManager.remove(name);
+ undeployProgress.run();
+ if (undeployProgress.getDeploymentStatus().isFailed())
+ {
+ remainingDeployments.add(name);
+ }
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+ if (remainingDeployments.size() > 0)
+ {
+ //log.error("Failed to undeploy these artifacts: " + remainingDeployments);
+ }
+ failedUndeployments.clear();
+ }
+
+ private String findRemoteServerHostAddress() {
+ try
+ {
+ String providerURL = (String)new InitialContext().getEnvironment().get(
+ InitialContext.PROVIDER_URL);
+
+ return providerURL.substring(0, providerURL.indexOf(":"));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not determine host address", e);
+ }
+ }
+
+ private static void copy(InputStream source, OutputStream destination) throws IOException
+ {
+ if (source == null)
+ {
+ throw new IllegalArgumentException("source cannot be null");
+ }
+ if (destination == null)
+ {
+ throw new IllegalArgumentException("destination cannot be null");
+ }
+ byte[] readBuffer = new byte[2156];
+ int bytesIn = 0;
+ while((bytesIn = source.read(readBuffer)) != -1)
+ {
+ destination.write(readBuffer, 0, bytesIn);
+ }
+ }
+}
Deleted: arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java
===================================================================
--- arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.jboss;
-
-import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
-import org.jboss.arquillian.spi.TestEnricher;
-import org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher;
-import org.jboss.arquillian.testenricher.resource.ResourceInjectionEnricher;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-
-/**
- * EmbeddedDeploymentAppender
- *
- * Package the required dependencies needed by the Jboss Embedded Container plugin
- * to run in container.
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public class JbossDeploymentAppender implements AuxiliaryArchiveAppender
-{
-
- public Archive<?> createAuxiliaryArchive()
- {
- JavaArchive archive = ShrinkWrap.create("arquillian-jboss-testenrichers.jar", JavaArchive.class)
- .addPackages(
- true,
- EJBInjectionEnricher.class.getPackage(),
- ResourceInjectionEnricher.class.getPackage())
- .addServiceProvider(
- TestEnricher.class,
- EJBInjectionEnricher.class,
- ResourceInjectionEnricher.class);
- return archive;
- }
-
-}
Deleted: arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JbossRemoteContainer.java
===================================================================
--- arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JbossRemoteContainer.java 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-remote-51/src/main/java/org/jboss/arquillian/jboss/JbossRemoteContainer.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1,302 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.jboss;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.naming.InitialContext;
-
-import org.jboss.arquillian.protocol.servlet.ServletMethodExecutor;
-import org.jboss.arquillian.spi.Configuration;
-import org.jboss.arquillian.spi.ContainerMethodExecutor;
-import org.jboss.arquillian.spi.Context;
-import org.jboss.arquillian.spi.DeployableContainer;
-import org.jboss.arquillian.spi.DeploymentException;
-import org.jboss.arquillian.spi.LifecycleException;
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
-import org.jboss.virtual.VFS;
-
-import com.sun.net.httpserver.HttpExchange;
-import com.sun.net.httpserver.HttpHandler;
-import com.sun.net.httpserver.HttpServer;
-
-/**
- * JbossRemoteContainer
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public class JbossRemoteContainer implements DeployableContainer
-{
- // TODO: replace by configuration
- private static final String HOST_ADDRESS = "localhost";
-
- //private static final Logger log = Logger.getLogger(JbossRemoteContainer.class.getName());
-
- private final List<String> failedUndeployments = new ArrayList<String>();
- private DeploymentManager deploymentManager;
-
- private HttpServer httpFileServer;
-
- private JBossConfiguration configuration;
-
- public void setup(Context context, Configuration configuration)
- {
- this.configuration = configuration.getContainerConfig(JBossConfiguration.class);
- }
-
- public void start(Context context) throws LifecycleException
- {
- try
- {
- // TODO: configure http bind address
- httpFileServer = HttpServer.create();
- httpFileServer.bind(new InetSocketAddress(InetAddress.getByName(HOST_ADDRESS), 9000), -1);
- httpFileServer.start();
- initDeploymentManager();
- }
- catch (Exception e)
- {
- throw new LifecycleException("Could not connect to container", e);
- }
- }
-
- public void stop(Context context) throws LifecycleException
- {
- try
- {
- httpFileServer.stop(0);
- removeFailedUnDeployments();
- }
- catch (Exception e)
- {
- throw new LifecycleException("Could not clean up", e);
- }
- }
-
- public ContainerMethodExecutor deploy(Context context, final Archive<?> archive) throws DeploymentException
- {
- if(archive == null)
- {
- throw new IllegalArgumentException("Archive must be specified");
- }
- if (deploymentManager == null)
- {
- throw new IllegalStateException("start has not been called!");
- }
- String deploymentName = archive.getName();
-
- Exception failure = null;
- try
- {
- httpFileServer.createContext("/" + deploymentName, new HttpHandler()
- {
- public void handle(HttpExchange exchange) throws IOException
- {
- InputStream zip = archive.as(ZipExporter.class).exportZip();
- ByteArrayOutputStream zipStream = new ByteArrayOutputStream();
- JbossRemoteContainer.copy(zip, zipStream);
- zip.close();
-
- byte[] zipArray = zipStream.toByteArray();
- exchange.sendResponseHeaders(200, zipArray.length);
-
- OutputStream out = exchange.getResponseBody();
- out.write(zipArray);
- out.close();
-
- }
- });
- URL fileServerUrl = createFileServerURL(deploymentName);
-
- DeploymentProgress distribute = deploymentManager.distribute(deploymentName, fileServerUrl, true);
- distribute.run();
- DeploymentStatus uploadStatus = distribute.getDeploymentStatus();
- if(uploadStatus.isFailed())
- {
- failure = uploadStatus.getFailure();
- undeploy(deploymentName);
- }
- else
- {
- DeploymentProgress progress = deploymentManager.start(deploymentName);
- progress.run();
- DeploymentStatus status = progress.getDeploymentStatus();
- if (status.isFailed())
- {
- failure = status.getFailure();
- undeploy(deploymentName);
- }
- }
- }
- catch (Exception e)
- {
- throw new DeploymentException("Could not deploy " + deploymentName, e);
- }
- if (failure != null)
- {
- throw new DeploymentException("Failed to deply " + deploymentName, failure);
- }
- try
- {
- return new ServletMethodExecutor(
- new URL(
- "http",
- findRemoteServerHostAddress(),
- 8080,
- "/")
- );
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not create ContianerMethodExecutor", e);
- }
- }
-
- public void undeploy(Context context, Archive<?> archive) throws DeploymentException
- {
- if(archive == null)
- {
- throw new IllegalArgumentException("Archive must be specified");
- }
- undeploy(archive.getName());
- }
-
- private void undeploy(String name) throws DeploymentException
- {
- try
- {
- DeploymentProgress stopProgress = deploymentManager.stop(name);
- stopProgress.run();
-
- DeploymentProgress undeployProgress = deploymentManager.remove(name);
- undeployProgress.run();
- if (undeployProgress.getDeploymentStatus().isFailed())
- {
- failedUndeployments.add(name);
- }
- httpFileServer.removeContext("/" + name);
- }
- catch (Exception e)
- {
- throw new DeploymentException("Could not undeploy " + name, e);
- }
- }
-
- private void initDeploymentManager() throws Exception
- {
- String profileName = "default";
- InitialContext ctx = new InitialContext();
- ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
- deploymentManager = ps.getDeploymentManager();
- ProfileKey defaultKey = new ProfileKey(profileName);
- deploymentManager.loadProfile(defaultKey);
- VFS.init();
- }
-
- private URL createFileServerURL(String archiveName)
- {
- try
- {
- InetSocketAddress address = httpFileServer.getAddress();
- return new URL(
- "http",
- address.getHostName(),
- address.getPort(),
- "/" + archiveName);
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException("Could not create fileserver url", e);
- }
- }
-
- private void removeFailedUnDeployments() throws IOException
- {
- List<String> remainingDeployments = new ArrayList<String>();
- for (String name : failedUndeployments)
- {
- try
- {
- DeploymentProgress undeployProgress = deploymentManager.remove(name);
- undeployProgress.run();
- if (undeployProgress.getDeploymentStatus().isFailed())
- {
- remainingDeployments.add(name);
- }
- }
- catch (Exception e)
- {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- }
- if (remainingDeployments.size() > 0)
- {
- //log.error("Failed to undeploy these artifacts: " + remainingDeployments);
- }
- failedUndeployments.clear();
- }
-
- private String findRemoteServerHostAddress() {
- try
- {
- String providerURL = (String)new InitialContext().getEnvironment().get(
- InitialContext.PROVIDER_URL);
-
- return providerURL.substring(0, providerURL.indexOf(":"));
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not determine host address", e);
- }
- }
-
- private static void copy(InputStream source, OutputStream destination) throws IOException
- {
- if (source == null)
- {
- throw new IllegalArgumentException("source cannot be null");
- }
- if (destination == null)
- {
- throw new IllegalArgumentException("destination cannot be null");
- }
- byte[] readBuffer = new byte[2156];
- int bytesIn = 0;
- while((bytesIn = source.read(readBuffer)) != -1)
- {
- destination.write(readBuffer, 0, bytesIn);
- }
- }
-}
Modified: arquillian/trunk/containers/jbossas-remote-51/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
===================================================================
--- arquillian/trunk/containers/jbossas-remote-51/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-remote-51/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1 +1 @@
-org.jboss.arquillian.jboss.JbossDeploymentAppender
\ No newline at end of file
+org.jboss.arquillian.jboss.JBossDeploymentAppender
\ No newline at end of file
Modified: arquillian/trunk/containers/jbossas-remote-51/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
===================================================================
--- arquillian/trunk/containers/jbossas-remote-51/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-remote-51/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1 +1 @@
-org.jboss.arquillian.jboss.JbossRemoteContainer
\ No newline at end of file
+org.jboss.arquillian.jboss.JBossRemoteContainer
\ No newline at end of file
Copied: arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java (from rev 4348, arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java)
===================================================================
--- arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java (rev 0)
+++ arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JBossDeploymentAppender.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.jboss;
+
+import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
+import org.jboss.arquillian.spi.TestEnricher;
+import org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher;
+import org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher;
+import org.jboss.arquillian.testenricher.resource.ResourceInjectionEnricher;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+/**
+ * EmbeddedDeploymentAppender
+ *
+ * Package the required dependencies needed by the Jboss Embedded Container plugin
+ * to run in container.
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class JBossDeploymentAppender implements AuxiliaryArchiveAppender
+{
+
+ public Archive<?> createAuxiliaryArchive()
+ {
+ JavaArchive archive = ShrinkWrap.create("arquillian-jboss-testenrichers.jar", JavaArchive.class)
+ .addPackages(
+ true,
+ EJBInjectionEnricher.class.getPackage(),
+ ResourceInjectionEnricher.class.getPackage(),
+ CDIInjectionEnricher.class.getPackage())
+ .addServiceProvider(
+ TestEnricher.class,
+ EJBInjectionEnricher.class,
+ ResourceInjectionEnricher.class,
+ CDIInjectionEnricher.class);
+ return archive;
+ }
+
+}
Copied: arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JBossRemoteContainer.java (from rev 4353, arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JbossRemoteContainer.java)
===================================================================
--- arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JBossRemoteContainer.java (rev 0)
+++ arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JBossRemoteContainer.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -0,0 +1,304 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.arquillian.jboss;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.InitialContext;
+
+import org.jboss.arquillian.protocol.servlet.ServletMethodExecutor;
+import org.jboss.arquillian.spi.Configuration;
+import org.jboss.arquillian.spi.ContainerMethodExecutor;
+import org.jboss.arquillian.spi.Context;
+import org.jboss.arquillian.spi.DeployableContainer;
+import org.jboss.arquillian.spi.DeploymentException;
+import org.jboss.arquillian.spi.LifecycleException;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+
+/**
+ * JbossRemoteContainer
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class JBossRemoteContainer implements DeployableContainer
+{
+ // TODO: replace by configuration
+ private static final String HOST_ADDRESS = "localhost";
+
+ //private static final Logger log = Logger.getLogger(JbossRemoteContainer.class.getName());
+
+ private final List<String> failedUndeployments = new ArrayList<String>();
+ private DeploymentManager deploymentManager;
+
+ private HttpServer httpFileServer;
+
+ private JBossConfiguration configuration;
+
+ public JBossRemoteContainer()
+ {
+ }
+
+ public void setup(Context context, Configuration configuration)
+ {
+ this.configuration = configuration.getContainerConfig(JBossConfiguration.class);
+ }
+
+ public void start(Context context) throws LifecycleException
+ {
+ try
+ {
+ // TODO: configure http bind address
+ httpFileServer = HttpServer.create();
+ httpFileServer.bind(new InetSocketAddress(InetAddress.getByName(HOST_ADDRESS), 9000), -1);
+ httpFileServer.start();
+ initDeploymentManager();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not connect to container", e);
+ }
+ }
+
+ public void stop(Context context) throws LifecycleException
+ {
+ try
+ {
+ httpFileServer.stop(0);
+ removeFailedUnDeployments();
+ }
+ catch (Exception e)
+ {
+ throw new LifecycleException("Could not clean up", e);
+ }
+ }
+
+ public ContainerMethodExecutor deploy(Context context, final Archive<?> archive) throws DeploymentException
+ {
+ if(archive == null)
+ {
+ throw new IllegalArgumentException("Archive must be specified");
+ }
+ if (deploymentManager == null)
+ {
+ throw new IllegalStateException("start has not been called!");
+ }
+ String deploymentName = archive.getName();
+
+ Exception failure = null;
+ try
+ {
+ httpFileServer.createContext("/" + deploymentName, new HttpHandler()
+ {
+ public void handle(HttpExchange exchange) throws IOException
+ {
+ InputStream zip = archive.as(ZipExporter.class).exportZip();
+ ByteArrayOutputStream zipStream = new ByteArrayOutputStream();
+ JBossRemoteContainer.copy(zip, zipStream);
+ zip.close();
+
+ byte[] zipArray = zipStream.toByteArray();
+ exchange.sendResponseHeaders(200, zipArray.length);
+
+ OutputStream out = exchange.getResponseBody();
+ out.write(zipArray);
+ out.close();
+
+ }
+ });
+ URL fileServerUrl = createFileServerURL(deploymentName);
+
+ DeploymentProgress distribute = deploymentManager.distribute(deploymentName, fileServerUrl, true);
+ distribute.run();
+ DeploymentStatus uploadStatus = distribute.getDeploymentStatus();
+ if(uploadStatus.isFailed())
+ {
+ failure = uploadStatus.getFailure();
+ undeploy(deploymentName);
+ }
+ else
+ {
+ DeploymentProgress progress = deploymentManager.start(deploymentName);
+ progress.run();
+ DeploymentStatus status = progress.getDeploymentStatus();
+ if (status.isFailed())
+ {
+ failure = status.getFailure();
+ undeploy(deploymentName);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Could not deploy " + deploymentName, e);
+ }
+ if (failure != null)
+ {
+ throw new DeploymentException("Failed to deply " + deploymentName, failure);
+ }
+ try
+ {
+ return new ServletMethodExecutor(
+ new URL(
+ "http",
+ findRemoteServerHostAddress(),
+ 8080,
+ "/")
+ );
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not create ContianerMethodExecutor", e);
+ }
+ }
+
+ public void undeploy(Context context, Archive<?> archive) throws DeploymentException
+ {
+ if(archive == null)
+ {
+ throw new IllegalArgumentException("Archive must be specified");
+ }
+ undeploy(archive.getName());
+ }
+
+ private void undeploy(String name) throws DeploymentException
+ {
+ try
+ {
+ DeploymentProgress stopProgress = deploymentManager.stop(name);
+ stopProgress.run();
+
+ DeploymentProgress undeployProgress = deploymentManager.remove(name);
+ undeployProgress.run();
+ if (undeployProgress.getDeploymentStatus().isFailed())
+ {
+ failedUndeployments.add(name);
+ }
+ httpFileServer.removeContext("/" + name);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException("Could not undeploy " + name, e);
+ }
+ }
+
+ private void initDeploymentManager() throws Exception
+ {
+ String profileName = "default";
+ InitialContext ctx = new InitialContext();
+ ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+ deploymentManager = ps.getDeploymentManager();
+ ProfileKey defaultKey = new ProfileKey(profileName);
+ deploymentManager.loadProfile(defaultKey);
+ }
+
+ private URL createFileServerURL(String archiveName)
+ {
+ try
+ {
+ InetSocketAddress address = httpFileServer.getAddress();
+ return new URL(
+ "http",
+ address.getHostName(),
+ address.getPort(),
+ "/" + archiveName);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException("Could not create fileserver url", e);
+ }
+ }
+
+ private void removeFailedUnDeployments() throws IOException
+ {
+ List<String> remainingDeployments = new ArrayList<String>();
+ for (String name : failedUndeployments)
+ {
+ try
+ {
+ DeploymentProgress undeployProgress = deploymentManager.remove(name);
+ undeployProgress.run();
+ if (undeployProgress.getDeploymentStatus().isFailed())
+ {
+ remainingDeployments.add(name);
+ }
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+ if (remainingDeployments.size() > 0)
+ {
+ //log.error("Failed to undeploy these artifacts: " + remainingDeployments);
+ }
+ failedUndeployments.clear();
+ }
+
+ private String findRemoteServerHostAddress() {
+ try
+ {
+ String providerURL = (String)new InitialContext().getEnvironment().get(
+ InitialContext.PROVIDER_URL);
+
+ return providerURL.substring(0, providerURL.indexOf(":"));
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Could not determine host address", e);
+ }
+ }
+
+ private static void copy(InputStream source, OutputStream destination) throws IOException
+ {
+ if (source == null)
+ {
+ throw new IllegalArgumentException("source cannot be null");
+ }
+ if (destination == null)
+ {
+ throw new IllegalArgumentException("destination cannot be null");
+ }
+ byte[] readBuffer = new byte[2156];
+ int bytesIn = 0;
+ while((bytesIn = source.read(readBuffer)) != -1)
+ {
+ destination.write(readBuffer, 0, bytesIn);
+ }
+ }
+}
Deleted: arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java
===================================================================
--- arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JbossDeploymentAppender.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.jboss;
-
-import org.jboss.arquillian.spi.AuxiliaryArchiveAppender;
-import org.jboss.arquillian.spi.TestEnricher;
-import org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher;
-import org.jboss.arquillian.testenricher.ejb.EJBInjectionEnricher;
-import org.jboss.arquillian.testenricher.resource.ResourceInjectionEnricher;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-
-/**
- * EmbeddedDeploymentAppender
- *
- * Package the required dependencies needed by the Jboss Embedded Container plugin
- * to run in container.
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public class JbossDeploymentAppender implements AuxiliaryArchiveAppender
-{
-
- public Archive<?> createAuxiliaryArchive()
- {
- JavaArchive archive = ShrinkWrap.create("arquillian-jboss-testenrichers.jar", JavaArchive.class)
- .addPackages(
- true,
- EJBInjectionEnricher.class.getPackage(),
- ResourceInjectionEnricher.class.getPackage(),
- CDIInjectionEnricher.class.getPackage())
- .addServiceProvider(
- TestEnricher.class,
- EJBInjectionEnricher.class,
- ResourceInjectionEnricher.class,
- CDIInjectionEnricher.class);
- return archive;
- }
-
-}
Deleted: arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JbossRemoteContainer.java
===================================================================
--- arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JbossRemoteContainer.java 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-remote-60/src/main/java/org/jboss/arquillian/jboss/JbossRemoteContainer.java 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1,304 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.arquillian.jboss;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.naming.InitialContext;
-
-import org.jboss.arquillian.protocol.servlet.ServletMethodExecutor;
-import org.jboss.arquillian.spi.Configuration;
-import org.jboss.arquillian.spi.ContainerMethodExecutor;
-import org.jboss.arquillian.spi.Context;
-import org.jboss.arquillian.spi.DeployableContainer;
-import org.jboss.arquillian.spi.DeploymentException;
-import org.jboss.arquillian.spi.LifecycleException;
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
-
-import com.sun.net.httpserver.HttpExchange;
-import com.sun.net.httpserver.HttpHandler;
-import com.sun.net.httpserver.HttpServer;
-
-/**
- * JbossRemoteContainer
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- */
-public class JbossRemoteContainer implements DeployableContainer
-{
- // TODO: replace by configuration
- private static final String HOST_ADDRESS = "localhost";
-
- //private static final Logger log = Logger.getLogger(JbossRemoteContainer.class.getName());
-
- private final List<String> failedUndeployments = new ArrayList<String>();
- private DeploymentManager deploymentManager;
-
- private HttpServer httpFileServer;
-
- private JBossConfiguration configuration;
-
- public JbossRemoteContainer()
- {
- }
-
- public void setup(Context context, Configuration configuration)
- {
- this.configuration = configuration.getContainerConfig(JBossConfiguration.class);
- }
-
- public void start(Context context) throws LifecycleException
- {
- try
- {
- // TODO: configure http bind address
- httpFileServer = HttpServer.create();
- httpFileServer.bind(new InetSocketAddress(InetAddress.getByName(HOST_ADDRESS), 9000), -1);
- httpFileServer.start();
- initDeploymentManager();
- }
- catch (Exception e)
- {
- throw new LifecycleException("Could not connect to container", e);
- }
- }
-
- public void stop(Context context) throws LifecycleException
- {
- try
- {
- httpFileServer.stop(0);
- removeFailedUnDeployments();
- }
- catch (Exception e)
- {
- throw new LifecycleException("Could not clean up", e);
- }
- }
-
- public ContainerMethodExecutor deploy(Context context, final Archive<?> archive) throws DeploymentException
- {
- if(archive == null)
- {
- throw new IllegalArgumentException("Archive must be specified");
- }
- if (deploymentManager == null)
- {
- throw new IllegalStateException("start has not been called!");
- }
- String deploymentName = archive.getName();
-
- Exception failure = null;
- try
- {
- httpFileServer.createContext("/" + deploymentName, new HttpHandler()
- {
- public void handle(HttpExchange exchange) throws IOException
- {
- InputStream zip = archive.as(ZipExporter.class).exportZip();
- ByteArrayOutputStream zipStream = new ByteArrayOutputStream();
- JbossRemoteContainer.copy(zip, zipStream);
- zip.close();
-
- byte[] zipArray = zipStream.toByteArray();
- exchange.sendResponseHeaders(200, zipArray.length);
-
- OutputStream out = exchange.getResponseBody();
- out.write(zipArray);
- out.close();
-
- }
- });
- URL fileServerUrl = createFileServerURL(deploymentName);
-
- DeploymentProgress distribute = deploymentManager.distribute(deploymentName, fileServerUrl, true);
- distribute.run();
- DeploymentStatus uploadStatus = distribute.getDeploymentStatus();
- if(uploadStatus.isFailed())
- {
- failure = uploadStatus.getFailure();
- undeploy(deploymentName);
- }
- else
- {
- DeploymentProgress progress = deploymentManager.start(deploymentName);
- progress.run();
- DeploymentStatus status = progress.getDeploymentStatus();
- if (status.isFailed())
- {
- failure = status.getFailure();
- undeploy(deploymentName);
- }
- }
- }
- catch (Exception e)
- {
- throw new DeploymentException("Could not deploy " + deploymentName, e);
- }
- if (failure != null)
- {
- throw new DeploymentException("Failed to deply " + deploymentName, failure);
- }
- try
- {
- return new ServletMethodExecutor(
- new URL(
- "http",
- findRemoteServerHostAddress(),
- 8080,
- "/")
- );
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not create ContianerMethodExecutor", e);
- }
- }
-
- public void undeploy(Context context, Archive<?> archive) throws DeploymentException
- {
- if(archive == null)
- {
- throw new IllegalArgumentException("Archive must be specified");
- }
- undeploy(archive.getName());
- }
-
- private void undeploy(String name) throws DeploymentException
- {
- try
- {
- DeploymentProgress stopProgress = deploymentManager.stop(name);
- stopProgress.run();
-
- DeploymentProgress undeployProgress = deploymentManager.remove(name);
- undeployProgress.run();
- if (undeployProgress.getDeploymentStatus().isFailed())
- {
- failedUndeployments.add(name);
- }
- httpFileServer.removeContext("/" + name);
- }
- catch (Exception e)
- {
- throw new DeploymentException("Could not undeploy " + name, e);
- }
- }
-
- private void initDeploymentManager() throws Exception
- {
- String profileName = "default";
- InitialContext ctx = new InitialContext();
- ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
- deploymentManager = ps.getDeploymentManager();
- ProfileKey defaultKey = new ProfileKey(profileName);
- deploymentManager.loadProfile(defaultKey);
- }
-
- private URL createFileServerURL(String archiveName)
- {
- try
- {
- InetSocketAddress address = httpFileServer.getAddress();
- return new URL(
- "http",
- address.getHostName(),
- address.getPort(),
- "/" + archiveName);
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException("Could not create fileserver url", e);
- }
- }
-
- private void removeFailedUnDeployments() throws IOException
- {
- List<String> remainingDeployments = new ArrayList<String>();
- for (String name : failedUndeployments)
- {
- try
- {
- DeploymentProgress undeployProgress = deploymentManager.remove(name);
- undeployProgress.run();
- if (undeployProgress.getDeploymentStatus().isFailed())
- {
- remainingDeployments.add(name);
- }
- }
- catch (Exception e)
- {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- }
- if (remainingDeployments.size() > 0)
- {
- //log.error("Failed to undeploy these artifacts: " + remainingDeployments);
- }
- failedUndeployments.clear();
- }
-
- private String findRemoteServerHostAddress() {
- try
- {
- String providerURL = (String)new InitialContext().getEnvironment().get(
- InitialContext.PROVIDER_URL);
-
- return providerURL.substring(0, providerURL.indexOf(":"));
- }
- catch (Exception e)
- {
- throw new RuntimeException("Could not determine host address", e);
- }
- }
-
- private static void copy(InputStream source, OutputStream destination) throws IOException
- {
- if (source == null)
- {
- throw new IllegalArgumentException("source cannot be null");
- }
- if (destination == null)
- {
- throw new IllegalArgumentException("destination cannot be null");
- }
- byte[] readBuffer = new byte[2156];
- int bytesIn = 0;
- while((bytesIn = source.read(readBuffer)) != -1)
- {
- destination.write(readBuffer, 0, bytesIn);
- }
- }
-}
Modified: arquillian/trunk/containers/jbossas-remote-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender
===================================================================
--- arquillian/trunk/containers/jbossas-remote-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-remote-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.AuxiliaryArchiveAppender 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1 +1 @@
-org.jboss.arquillian.jboss.JbossDeploymentAppender
\ No newline at end of file
+org.jboss.arquillian.jboss.JBossDeploymentAppender
\ No newline at end of file
Modified: arquillian/trunk/containers/jbossas-remote-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer
===================================================================
--- arquillian/trunk/containers/jbossas-remote-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-05-07 20:33:42 UTC (rev 4366)
+++ arquillian/trunk/containers/jbossas-remote-60/src/main/resources/META-INF/services/org.jboss.arquillian.spi.DeployableContainer 2010-05-08 00:15:38 UTC (rev 4367)
@@ -1 +1 @@
-org.jboss.arquillian.jboss.JbossRemoteContainer
\ No newline at end of file
+org.jboss.arquillian.jboss.JBossRemoteContainer
\ No newline at end of file
More information about the jboss-svn-commits
mailing list