Author: adriana
Date: 2008-08-21 09:02:14 -0500 (Thu, 21 Aug 2008)
New Revision: 1686
Added:
core/trunk/containers/jonas/
core/trunk/containers/jonas/pom.xml
core/trunk/containers/jonas/src/
core/trunk/containers/jonas/src/main/
core/trunk/containers/jonas/src/main/java/
core/trunk/containers/jonas/src/main/java/org/
core/trunk/containers/jonas/src/main/java/org/codehaus/
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xAdmin.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xExistingLocalConfiguration.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalContainer.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalDeployer.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xJsr160RemoteDeployer.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xMEJBRemoteDeployer.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xRemoteContainer.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xStandaloneLocalConfiguration.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasPropertySet.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasRuntimeConfiguration.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/AbstractJonas4xRemoteDeployer.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/AbstractJonasInstalledLocalContainer.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/AbstractJonasRemoteDeployer.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JSR160MBeanServerConnectionFactory.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/Jonas4xStandaloneLocalConfigurationCapability.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasAdmin.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasContainerCapability.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasExistingLocalConfigurationCapability.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasRuntimeConfigurationCapability.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/MBeanServerConnectionFactory.java
core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/MEJBMBeanServerConnectionFactory.java
core/trunk/containers/jonas/src/main/resources/
core/trunk/containers/jonas/src/main/resources/org/
core/trunk/containers/jonas/src/main/resources/org/codehaus/
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/carol.properties
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/domain.xml
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jaas.config
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jacorb.properties
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jetty5.xml
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jonas-realm.xml
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jonas.properties
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/server.xml
core/trunk/containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/trace.properties
core/trunk/containers/jonas/src/test/
core/trunk/containers/jonas/src/test/java/
core/trunk/containers/jonas/src/test/java/org/
core/trunk/containers/jonas/src/test/java/org/codehaus/
core/trunk/containers/jonas/src/test/java/org/codehaus/cargo/
core/trunk/containers/jonas/src/test/java/org/codehaus/cargo/container/
core/trunk/containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/
core/trunk/containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/Jonas4xExistingLocalConfigurationTest.java
core/trunk/containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalContainerTest.java
core/trunk/containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalDeployerTest.java
core/trunk/containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/Jonas4xStandaloneLocalConfigurationTest.java
core/trunk/containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/internal/
core/trunk/containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/internal/JonasContainerCapabilityTest.java
core/trunk/containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/internal/JonasRemoteDeployerTest.java
core/trunk/containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/internal/MEJBProxyTest.java
Log:
Add jonas container.
Added: core/trunk/containers/jonas/pom.xml
===================================================================
--- core/trunk/containers/jonas/pom.xml (rev 0)
+++ core/trunk/containers/jonas/pom.xml 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2005-2007 Vincent Massol.
+ ~
+ ~ 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.
+ -->
+
+<project xmlns="
http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-core-containers</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>cargo-core-container-jonas</artifactId>
+ <name>Cargo Core Jonas Container</name>
+ <packaging>jar</packaging>
+ <description>Core API implementation for Jonas containers</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-core-api-generic</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-management_1.0_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ejb_2.1_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <activation>
+ <jdk>1.4</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>mx4j</groupId>
+ <artifactId>mx4j</artifactId>
+ <version>3.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>mx4j</groupId>
+ <artifactId>mx4j-remote</artifactId>
+ <version>3.0.2</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+</project>
Added: core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xAdmin.java
===================================================================
--- core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xAdmin.java (rev 0)
+++ core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xAdmin.java 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,115 @@
+/*
+ * ========================================================================
+ *
+ * Copyright 2007-2008 OW2.
+ *
+ * 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.codehaus.cargo.container.jonas;
+
+import org.apache.tools.ant.taskdefs.Java;
+import org.codehaus.cargo.container.jonas.internal.JonasAdmin;
+import org.codehaus.cargo.util.AntUtils;
+
+/**
+ * JOnAS admin command line utils class.
+ *
+ * @version $Id: Jonas4xAdmin.java 14641 2008-07-25 11:46:29Z alitokmen $
+ */
+public class Jonas4xAdmin implements JonasAdmin
+{
+ /**
+ * Target JOnAS container, used for admin command line invocation setup.
+ */
+ private Jonas4xInstalledLocalContainer targetContainer;
+
+ /**
+ *
+ * @param targetContainer the JOnAS target container
+ */
+ public Jonas4xAdmin(Jonas4xInstalledLocalContainer targetContainer)
+ {
+ this.targetContainer = targetContainer;
+ }
+
+ /**
+ * Look if a local server instance is running.
+ *
+ * @return true if a local server instance is running
+ */
+ public final boolean isServerRunning()
+ {
+ Java java = (Java) new AntUtils().createAntTask("java");
+ java.setFork(true);
+
+ targetContainer.doAction(java);
+ java.createArg().setValue("org.objectweb.jonas.adm.JonasAdmin");
+ targetContainer.doServerNameParam(java);
+ java.createArg().setValue("-l");
+
+ int returnCode = java.executeJava();
+ return returnCode == 0;
+ }
+
+ /**
+ * Undeploys the given bean name.
+ *
+ * @param beanFileName the bean file name
+ * @return true if the bean has been correctly undeployed
+ */
+ public final boolean unDeploy(String beanFileName)
+ {
+ boolean undeployed = genericDeployment(beanFileName, "-r");
+ if (!undeployed)
+ {
+ // file deployed trough autoload directory are not undeployed it the autoload
+ // directory is not specified in the path
+ undeployed = genericDeployment("autoload/" + beanFileName, "-r");
+ }
+ return undeployed;
+ }
+
+ /**
+ * deploys the given bean name.
+ *
+ * @param beanFileName the bean file name
+ * @return true if the bean has been correctly deployed
+ */
+ public final boolean deploy(String beanFileName)
+ {
+ return genericDeployment(beanFileName, "-a");
+ }
+
+ /**
+ *
+ * @param beanFileName bean File Name
+ * @param deploymentParam deployment parameter
+ * @return true if the deployment command(deploy or undeploy...)bean has been correctly executed
+ */
+ private boolean genericDeployment(String beanFileName, String deploymentParam)
+ {
+ Java java = (Java) new AntUtils().createAntTask("java");
+ java.setFork(true);
+
+ targetContainer.doAction(java);
+ java.createArg().setValue("org.objectweb.jonas.adm.JonasAdmin");
+ targetContainer.doServerNameParam(java);
+ java.createArg().setValue(deploymentParam);
+ java.createArg().setValue(beanFileName);
+
+ int returnCode = java.executeJava();
+ return returnCode == 0;
+ }
+}
Added: core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xExistingLocalConfiguration.java
===================================================================
--- core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xExistingLocalConfiguration.java (rev 0)
+++ core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xExistingLocalConfiguration.java 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,123 @@
+/*
+ * ========================================================================
+ *
+ * Copyright 2007-2008 OW2.
+ *
+ * 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.codehaus.cargo.container.jonas;
+
+import org.codehaus.cargo.container.ContainerException;
+import org.codehaus.cargo.container.InstalledLocalContainer;
+import org.codehaus.cargo.container.LocalContainer;
+import org.codehaus.cargo.container.configuration.ConfigurationCapability;
+import org.codehaus.cargo.container.jonas.internal.JonasExistingLocalConfigurationCapability;
+import org.codehaus.cargo.container.property.GeneralPropertySet;
+import org.codehaus.cargo.container.property.ServletPropertySet;
+import org.codehaus.cargo.container.spi.configuration.AbstractExistingLocalConfiguration;
+
+/**
+ * JOnAS existing {@link org.codehaus.cargo.container.configuration.Configuration} implementation.
+ *
+ * @version $Id: Jonas4xExistingLocalConfiguration.java 14641 2008-07-25 11:46:29Z alitokmen $
+ */
+public class Jonas4xExistingLocalConfiguration extends AbstractExistingLocalConfiguration
+{
+
+ /**
+ * Capability of the JOnAS existing configuration.
+ */
+ private static ConfigurationCapability capability =
+ new JonasExistingLocalConfigurationCapability();
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractExistingLocalConfiguration#AbstractExistingLocalConfiguration(String)
+ */
+ public Jonas4xExistingLocalConfiguration(String dir)
+ {
+ super(dir);
+ setProperty(GeneralPropertySet.PROTOCOL, "http");
+ setProperty(GeneralPropertySet.HOSTNAME, "localhost");
+ setProperty(ServletPropertySet.PORT, "9000");
+ setProperty(GeneralPropertySet.JVMARGS, "-Xms128m -Xmx512m");
+ setProperty(JonasPropertySet.JONAS_SERVER_NAME, "jonas");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.spi.configuration.AbstractLocalConfiguration#doConfigure(org.codehaus.cargo.container.LocalContainer)
+ */
+ protected void doConfigure(LocalContainer container) throws Exception
+ {
+
+ InstalledLocalContainer jonasContainer = (InstalledLocalContainer) container;
+
+ checkDirExists("conf");
+ checkDirExists("apps");
+ checkDirExists("apps/autoload");
+ checkDirExists("webapps");
+ checkDirExists("webapps/autoload");
+ checkDirExists("ejbjars");
+ checkDirExists("ejbjars/autoload");
+
+ Jonas4xInstalledLocalDeployer deployer = new Jonas4xInstalledLocalDeployer(jonasContainer);
+ deployer.deploy(getDeployables());
+
+ // Deploy the CPC (Cargo Ping Component) to the webapps directory.
+ getResourceUtils().copyResource(RESOURCE_PATH + "cargocpc.war",
+ getFileHandler().append(getHome(), "/webapps/autoload/cargocpc.war"), getFileHandler());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.configuration.Configuration#getCapability()
+ */
+ public ConfigurationCapability getCapability()
+ {
+ return capability;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ return "JOnAS Existing Local Configuration";
+ }
+
+ /**
+ * Check if the directory exists.
+ *
+ * @param dir the directory name
+ */
+ private void checkDirExists(String dir)
+ {
+ String path = getFileHandler().append(getHome(), dir);
+ boolean exists = getFileHandler().exists(path);
+
+ if (!exists)
+ {
+ throw new ContainerException("Invalid existing configuration: The [" + path
+ + "] directory does not exist");
+ }
+ }
+
+}
Added: core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalContainer.java
===================================================================
--- core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalContainer.java (rev 0)
+++ core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalContainer.java 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,125 @@
+/*
+ * ========================================================================
+ *
+ * Copyright 2007-2008 OW2.
+ *
+ * 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.codehaus.cargo.container.jonas;
+
+import java.util.Map;
+
+import org.apache.tools.ant.taskdefs.Java;
+import org.codehaus.cargo.container.configuration.LocalConfiguration;
+import org.codehaus.cargo.container.internal.AntContainerExecutorThread;
+import org.codehaus.cargo.container.jonas.internal.AbstractJonasInstalledLocalContainer;
+
+/**
+ * Support for the JOnAS JEE container.
+ *
+ * @version $Id: Jonas4xInstalledLocalContainer.java 14689 2008-07-29 14:17:35Z alitokmen $
+ */
+public class Jonas4xInstalledLocalContainer extends AbstractJonasInstalledLocalContainer
+{
+ /**
+ * Unique container id.
+ */
+ public static final String ID = "jonas4x";
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractJonasInstalledLocalContainer#AbstractJonasInstalledLocalContainer(org.codehaus.cargo.container.configuration.LocalConfiguration)
+ */
+ public Jonas4xInstalledLocalContainer(LocalConfiguration configuration)
+ {
+ super(configuration);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractJonasInstalledLocalContainer#doStart(Java)
+ */
+ public void doStart(Java java)
+ {
+ doAction(java);
+ java.createArg().setValue("org.objectweb.jonas.server.Server");
+ java.createArg().setValue("-fg");
+
+ AntContainerExecutorThread jonasRunner = new AntContainerExecutorThread(java);
+ jonasRunner.start();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractJonasInstalledLocalContainer#doStop(Java)
+ */
+ public void doStop(Java java)
+ {
+ doAction(java);
+ java.createArg().setValue("org.objectweb.jonas.adm.JonasAdmin");
+ doServerNameParam(java);
+ java.createArg().setValue("-s");
+
+ AntContainerExecutorThread jonasRunner = new AntContainerExecutorThread(java);
+ jonasRunner.start();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractJonasInstalledLocalContainer#setupExtraSysProps(Java, Map)
+ */
+ protected void setupExtraSysProps(Java java, Map configuredSysProps)
+ {
+ addSysProp(java, configuredSysProps, "jonas.default.classloader", "true");
+ addSysProp(java, configuredSysProps, "org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
+ addSysProp(java, configuredSysProps, "org.omg.CORBA.ORBSingletonClass",
+ "org.jacorb.orb.ORBSingleton");
+ addSysProp(java, configuredSysProps,
+ "org.omg.PortableInterceptor.ORBInitializerClass.standard_init",
+ "org.jacorb.orb.standardInterceptors.IORInterceptorInitializer");
+ addSysProp(java, configuredSysProps, "javax.rmi.CORBA.PortableRemoteObjectClass",
+ "org.objectweb.carol.rmi.multi.MultiPRODelegate");
+ addSysProp(java, configuredSysProps, "java.naming.factory.initial",
+ "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory");
+ addSysProp(java, configuredSysProps, "javax.rmi.CORBA.UtilClass",
+ "org.objectweb.carol.util.delegate.UtilDelegateImpl");
+ addSysProp(java, configuredSysProps, "java.rmi.server.RMIClassLoaderSpi",
+ "org.objectweb.jonas.server.RemoteClassLoaderSpi");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.Container#getId()
+ */
+ public String getId()
+ {
+ return ID;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.Container#getName()
+ */
+ public String getName()
+ {
+ return "JOnAS " + getVersion("4.x");
+ }
+}
Added: core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalDeployer.java
===================================================================
--- core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalDeployer.java (rev 0)
+++ core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalDeployer.java 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,276 @@
+/*
+ * ========================================================================
+ *
+ * Copyright 2007-2008 OW2.
+ *
+ * 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.codehaus.cargo.container.jonas;
+
+import org.codehaus.cargo.container.InstalledLocalContainer;
+import org.codehaus.cargo.container.deployable.Deployable;
+import org.codehaus.cargo.container.deployable.EAR;
+import org.codehaus.cargo.container.deployable.EJB;
+import org.codehaus.cargo.container.deployable.RAR;
+import org.codehaus.cargo.container.deployable.WAR;
+import org.codehaus.cargo.container.jonas.internal.JonasAdmin;
+import org.codehaus.cargo.container.spi.deployer.AbstractCopyingInstalledLocalDeployer;
+import org.codehaus.cargo.util.CargoException;
+import org.codehaus.cargo.util.FileHandler;
+
+/**
+ * Static deployer that deploys WAR, EAR, EJB and RAR to JOnAS.
+ *
+ * @version $Id: Jonas4xInstalledLocalDeployer.java 14641 2008-07-25 11:46:29Z alitokmen $
+ */
+public class Jonas4xInstalledLocalDeployer extends AbstractCopyingInstalledLocalDeployer
+{
+
+ /**
+ * JOnAS admin used for hot deployment.
+ */
+ private JonasAdmin admin;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractCopyingInstalledLocalDeployer#AbstractCopyingInstalledLocalDeployer(InstalledLocalContainer)
+ */
+ public Jonas4xInstalledLocalDeployer(InstalledLocalContainer container)
+ {
+ this(container, new Jonas4xAdmin((Jonas4xInstalledLocalContainer) container), null);
+ }
+
+ /**
+ * Creation of a local depoyer with a given Jonas4xAdmin object and file handler.
+ *
+ * @param container the container to be used
+ * @param admin the JOnAS admin to use for deployment
+ * @param fileHandler the file handler to use, can be null to use the defaut file handler imple
+ */
+ public Jonas4xInstalledLocalDeployer(InstalledLocalContainer container, JonasAdmin admin,
+ FileHandler fileHandler)
+ {
+ super(container);
+ this.admin = admin;
+ if (fileHandler != null)
+ {
+ super.setFileHandler(fileHandler);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractCopyingInstalledLocalDeployer#deployEar(String,
+ * org.codehaus.cargo.container.deployable.EAR)
+ */
+ protected void deployEar(String deployableDir, EAR ear) throws CargoException
+ {
+ deploy(deployableDir + "/apps", ear, getFileHandler().getName(ear.getFile()),
+ new GenericCopyingDeployable());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractCopyingInstalledLocalDeployer#deployEjb(String,
+ * org.codehaus.cargo.container.deployable.EJB)
+ */
+ protected void deployEjb(String deployableDir, EJB ejb) throws CargoException
+ {
+ deploy(deployableDir + "/ejbjars", ejb, getFileHandler().getName(ejb.getFile()),
+ new GenericCopyingDeployable());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractCopyingInstalledLocalDeployer#deployRar(String,
+ * org.codehaus.cargo.container.deployable.RAR)
+ */
+ protected void deployRar(String deployableDir, RAR rar) throws CargoException
+ {
+ deploy(deployableDir + "/rars", rar, getFileHandler().getName(rar.getFile()),
+ new GenericCopyingDeployable());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractCopyingInstalledLocalDeployer#deployExpandedWar(String,
+ * org.codehaus.cargo.container.deployable.WAR)
+ */
+ protected void deployExpandedWar(String deployableDir, WAR war) throws CargoException
+ {
+ if (admin.isServerRunning())
+ {
+ getLogger()
+ .warn("Hot deployment of expanded war impossible", this.getClass().getName());
+ return;
+ }
+ super.deployExpandedWar(deployableDir + "/webapps/autoload", war);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractCopyingInstalledLocalDeployer#deployWar(String,
+ * org.codehaus.cargo.container.deployable.WAR)
+ */
+ protected void deployWar(String deployableDir, WAR war) throws CargoException
+ {
+ deploy(deployableDir + "/webapps", war, war.getContext() + ".war", new CopyingDeployable()
+ {
+
+ public void copyDeployable(String deployableDir, Deployable deployable)
+ {
+ getFileHandler().copyFile(
+ deployable.getFile(),
+ getFileHandler()
+ .append(deployableDir, ((WAR) deployable).getContext() + ".war"));
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.deployer.Deployer#redeploy(Deployable)
+ */
+ public void redeploy(Deployable deployable) throws CargoException
+ {
+ undeploy(deployable);
+ deploy(deployable);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.deployer.Deployer#undeploy(Deployable)
+ */
+ public void undeploy(Deployable deployable) throws CargoException
+ {
+ String fileName = getFileHandler().getName(deployable.getFile());
+ if (deployable instanceof WAR)
+ {
+ fileName = ((WAR) deployable).getContext() + ".war";
+ }
+ boolean isRunning = false;
+
+ isRunning = admin.isServerRunning();
+ if (isRunning)
+ {
+ boolean undeployed = admin.unDeploy(fileName);
+ if (!undeployed)
+ {
+ throw new CargoException("Unable to undeploy file " + fileName
+ + " trough JOnAS admin");
+ }
+ }
+ }
+
+ /**
+ * Deploy a {@link Deployable} to the running container.
+ *
+ * @param targetDir the target Directory directory where the container is expecting deployables
+ * to be dropped for deployments
+ * @param deployable the deployable object(the deployable file archive )
+ * @param fileName the archive file name to deploy
+ * @param copying Copying Deployable
+ * @throws CargoException if the deplyable can not be deployted
+ */
+ private void deploy(String targetDir, Deployable deployable, String fileName,
+ CopyingDeployable copying) throws CargoException
+ {
+ boolean isRunning = false;
+ String targetDiroctory = targetDir;
+
+ isRunning = admin.isServerRunning();
+ if (!isRunning)
+ {
+ targetDiroctory += "/autoload";
+ }
+ copying.copyDeployable(targetDiroctory, deployable);
+ if (isRunning)
+ {
+ // hot deployment trough JOnAS admin
+ boolean deployed = admin.deploy(fileName);
+ if (!deployed)
+ {
+ throw new CargoException("Unable to deploy file " + fileName
+ + " trough JOnAS admin");
+ }
+ }
+
+ }
+
+ /**
+ * Specifies the directory {@link org.codehaus.cargo.container.deployable.Deployable}s should
+ * be copied to. For Tomcat this is the <code>webapps</code> directory.
+ *
+ * @return Deployable the directory to deploy to
+ */
+ public String getDeployableDir()
+ {
+ // not the real exact deployment dir since under JOnAS they depends on the
+ // deployable type and this information is not provided as method input parameter,
+ // returned string is used as a base for overriden deployXXX methods
+ return getContainer().getConfiguration().getHome();
+ }
+
+ /**
+ *
+ * this Interface allows copying the deployble archive file to the JOnAS directory. where will
+ * be deployed
+ *
+ */
+ private interface CopyingDeployable
+ {
+ /**
+ * copy the Deployable archive file to the deployable directory.
+ *
+ * @param deployableDir the deployable directory
+ * @param deployable deployable to deploy
+ */
+ void copyDeployable(String deployableDir, Deployable deployable);
+ }
+
+ /**
+ *
+ * Generic class to allow copying the deployble archive file. to the JOnAS directory where will
+ * be deployed
+ *
+ */
+ private class GenericCopyingDeployable implements CopyingDeployable
+ {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.jonas.Deployer.GenericCopyingDeployable#copyDeployable(String,
+ * Deployable)
+ */
+ public void copyDeployable(String deployableDir, Deployable deployable)
+ {
+ getFileHandler().copyFile(
+ deployable.getFile(),
+ getFileHandler().append(deployableDir,
+ getFileHandler().getName(deployable.getFile())));
+ }
+
+ }
+
+}
Added: core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xJsr160RemoteDeployer.java
===================================================================
--- core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xJsr160RemoteDeployer.java (rev 0)
+++ core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xJsr160RemoteDeployer.java 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,51 @@
+/*
+ * ========================================================================
+ *
+ * Copyright 2007-2008 OW2.
+ *
+ * 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.codehaus.cargo.container.jonas;
+
+import org.codehaus.cargo.container.RemoteContainer;
+import org.codehaus.cargo.container.jonas.internal.AbstractJonas4xRemoteDeployer;
+import org.codehaus.cargo.container.jonas.internal.JSR160MBeanServerConnectionFactory;
+import org.codehaus.cargo.container.jonas.internal.MBeanServerConnectionFactory;
+
+/**
+ * Remote deployer that uses JMX Remoting (JSR 160) to deploy to JOnAS.
+ *
+ * @version $Id: Jonas4xJsr160RemoteDeployer.java 14641 2008-07-25 11:46:29Z alitokmen $
+ */
+public class Jonas4xJsr160RemoteDeployer extends AbstractJonas4xRemoteDeployer
+{
+ /**
+ * Jonas4xJsr160RemoteDeployer Constructor.
+ *
+ * @param container the remote container
+ */
+ public Jonas4xJsr160RemoteDeployer(RemoteContainer container)
+ {
+ super(container);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public MBeanServerConnectionFactory getMBeanServerConnectionFactory()
+ {
+ return new JSR160MBeanServerConnectionFactory();
+ }
+}
Added: core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xMEJBRemoteDeployer.java
===================================================================
--- core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xMEJBRemoteDeployer.java (rev 0)
+++ core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xMEJBRemoteDeployer.java 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,53 @@
+/*
+ * ========================================================================
+ *
+ * Copyright 2007-2008 OW2.
+ *
+ * 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.codehaus.cargo.container.jonas;
+
+import org.codehaus.cargo.container.RemoteContainer;
+import org.codehaus.cargo.container.jonas.internal.AbstractJonas4xRemoteDeployer;
+import org.codehaus.cargo.container.jonas.internal.MBeanServerConnectionFactory;
+import org.codehaus.cargo.container.jonas.internal.MEJBMBeanServerConnectionFactory;
+
+/**
+ * Remote deployer that uses Managment EJB (MEJB) to deploy to JOnAS.
+ *
+ * @version $Id: Jonas4xMEJBRemoteDeployer.java 14641 2008-07-25 11:46:29Z alitokmen $
+ */
+public class Jonas4xMEJBRemoteDeployer extends AbstractJonas4xRemoteDeployer
+{
+ /**
+ * Jonas4xMEJBRemoteDeployer Constructor.
+ *
+ * @param container the remote container
+ */
+ public Jonas4xMEJBRemoteDeployer(RemoteContainer container)
+ {
+ super(container);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.jonas.internal#getMBeanServerConnectionFactory()
+ */
+ public MBeanServerConnectionFactory getMBeanServerConnectionFactory()
+ {
+ return new MEJBMBeanServerConnectionFactory();
+ }
+}
Added: core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xRemoteContainer.java
===================================================================
--- core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xRemoteContainer.java (rev 0)
+++ core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xRemoteContainer.java 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,84 @@
+/*
+ * ========================================================================
+ *
+ * Copyright 2007-2008 OW2.
+ *
+ * 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.codehaus.cargo.container.jonas;
+
+import org.codehaus.cargo.container.ContainerCapability;
+import org.codehaus.cargo.container.configuration.RuntimeConfiguration;
+import org.codehaus.cargo.container.jonas.internal.JonasContainerCapability;
+import org.codehaus.cargo.container.spi.AbstractRemoteContainer;
+
+/**
+ * JOnAS remote container.
+ *
+ * @version $Id: Jonas4xRemoteContainer.java 14641 2008-07-25 11:46:29Z alitokmen $
+ */
+public class Jonas4xRemoteContainer extends AbstractRemoteContainer
+{
+ /**
+ * Unique container id.
+ */
+ public static final String ID = "jonas4x";
+
+ /**
+ * the Capability of the JOnAS container.
+ */
+ private ContainerCapability capability = new JonasContainerCapability();
+
+ /**
+ * {@link Jonas4xRemoteContainer} Default constructor.
+ *
+ * @param configuration the configuration to associate to this container.
+ */
+ public Jonas4xRemoteContainer(RuntimeConfiguration configuration)
+ {
+ super(configuration);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.Container#getCapability()
+ */
+ public ContainerCapability getCapability()
+ {
+ return capability;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.Container#getId()
+ */
+ public String getId()
+ {
+ return ID;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.Container#getName()
+ */
+ public String getName()
+ {
+ return "JOnAS 4.x Remote";
+ }
+
+}
Added: core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xStandaloneLocalConfiguration.java
===================================================================
--- core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xStandaloneLocalConfiguration.java (rev 0)
+++ core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xStandaloneLocalConfiguration.java 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,409 @@
+/*
+ * ========================================================================
+ *
+ * Copyright 2007-2008 OW2.
+ *
+ * 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.codehaus.cargo.container.jonas;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.tools.ant.types.FilterChain;
+import org.codehaus.cargo.container.InstalledLocalContainer;
+import org.codehaus.cargo.container.LocalContainer;
+import org.codehaus.cargo.container.configuration.ConfigurationCapability;
+import org.codehaus.cargo.container.jonas.internal.Jonas4xStandaloneLocalConfigurationCapability;
+import org.codehaus.cargo.container.property.GeneralPropertySet;
+import org.codehaus.cargo.container.property.ServletPropertySet;
+import org.codehaus.cargo.container.property.User;
+import org.codehaus.cargo.container.spi.configuration.AbstractStandaloneLocalConfiguration;
+import org.codehaus.cargo.util.CargoException;
+
+/**
+ * Implementation of a standalone {@link org.codehaus.cargo.container.configuration.Configuration}
+ * for JOnAS.
+ *
+ * @version $Id: Jonas4xStandaloneLocalConfiguration.java 14641 2008-07-25 11:46:29Z alitokmen $
+ */
+public class Jonas4xStandaloneLocalConfiguration extends AbstractStandaloneLocalConfiguration
+{
+ /**
+ * Jetty web container class name.
+ */
+ public static final String JETTY_WEB_CONTAINER_CLASS_NAME =
+ "org.objectweb.jonas.web.jetty50.JettyJWebContainerServiceImpl";
+
+ /**
+ * Tomcat web container class name.
+ */
+ public static final String CATALINA_WEB_CONTAINER_CLASS_NAME =
+ "org.objectweb.jonas.web.wrapper.catalina55.CatalinaJWebContainerServiceWrapper";
+
+ /**
+ * Token filter key for users' role.
+ */
+ protected static final String TOKEN_FILTER_KEY_USERS_ROLE = "cargo.servlet.users.role";
+
+ /**
+ * Token filter key for users' user name.
+ */
+ protected static final String TOKEN_FILTER_KEY_USERS_USER = "cargo.servlet.users.user";
+
+ /**
+ * JOnAS container capability.
+ */
+ private static ConfigurationCapability capability =
+ new Jonas4xStandaloneLocalConfigurationCapability();
+
+ /**
+ * JOnAS installed container.
+ */
+ private InstalledLocalContainer installedContainer;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractStandaloneLocalConfiguration#AbstractStandaloneLocalConfiguration(String)
+ */
+ public Jonas4xStandaloneLocalConfiguration(String dir)
+ {
+ super(dir);
+
+ setProperty(GeneralPropertySet.RMI_PORT, "1099");
+ setProperty(GeneralPropertySet.PROTOCOL, "http");
+ setProperty(GeneralPropertySet.HOSTNAME, "localhost");
+ setProperty(ServletPropertySet.PORT, "9000");
+ setProperty(GeneralPropertySet.JVMARGS, "-Xms128m -Xmx512m");
+ setProperty(JonasPropertySet.JONAS_REALM_NAME, "memrlm_1");
+ setProperty(JonasPropertySet.JONAS_AVAILABLES_DATASOURCES, "HSQL1");
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.configuration.Configuration#getCapability()
+ */
+ public ConfigurationCapability getCapability()
+ {
+ return capability;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.spi.configuration.AbstractLocalConfiguration#configure(LocalContainer)
+ */
+ protected void doConfigure(LocalContainer container) throws Exception
+ {
+ this.installedContainer = (InstalledLocalContainer) container;
+ setupConfigurationDir();
+
+ FilterChain filterChain = createJonasFilterChain(this.installedContainer);
+
+ // setting the JONAS_BASE environment
+ getFileHandler().createDirectory(getHome(), "/webapps");
+ getFileHandler().createDirectory(getHome(), "/webapps/autoload");
+ getFileHandler().createDirectory(getHome(), "/ejbjars");
+ getFileHandler().createDirectory(getHome(), "/ejbjars/autoload");
+ getFileHandler().createDirectory(getHome(), "/apps");
+ getFileHandler().createDirectory(getHome(), "/apps/autoload");
+ getFileHandler().createDirectory(getHome(), "/rars");
+ getFileHandler().createDirectory(getHome(), "/rars/autoload");
+
+ getFileHandler().createDirectory(getHome(), "/logs");
+
+ String confDir = getFileHandler().createDirectory(getHome(), "/conf");
+
+ // Copy configuration files from cargo resources directory with token replacement
+ String[] cargoFiles = new String[]
+ {
+ "carol.properties", "jetty5.xml", "server.xml", "jonas-realm.xml", "jonas.properties",
+ "trace.properties", "jaas.config"
+ };
+ for (int i = 0; i < cargoFiles.length; i++)
+ {
+ getResourceUtils().copyResource(
+ RESOURCE_PATH + container.getId() + "/" + cargoFiles[i],
+ getFileHandler().append(confDir, cargoFiles[i]), getFileHandler(), filterChain);
+ }
+
+ // Copy resources from JOnAS installation folder and exclude files
+ // that already copied from cargo resources folder
+ copyExternalResources(new File(installedContainer.getHome(), "conf"), new File(confDir),
+ cargoFiles);
+
+ // Deploy with user defined deployables with the appropriate deployer
+ Jonas4xInstalledLocalDeployer deployer = new Jonas4xInstalledLocalDeployer(
+ installedContainer);
+ deployer.deploy(getDeployables());
+
+ // Deploy the CPC (Cargo Ping Component) to the webapps directory
+ getResourceUtils().copyResource(RESOURCE_PATH + "cargocpc.war",
+ getFileHandler().append(getHome(), "/webapps/autoload/cargocpc.war"), getFileHandler());
+ }
+
+ /**
+ * Copy external resources to cargo configuration directory. This method will copy entire
+ * resources in the sourceDir (recursive), if it's a directory.
+ *
+ * @param sourceDir resource file / directory to be copied
+ * @param destDir cargo configuration directory
+ * @param cargoFiles list of cargo resources file that will excluded
+ * @throws IOException If an error occurs during the copy.
+ */
+ private void copyExternalResources(File sourceDir, File destDir, String[] cargoFiles)
+ throws IOException
+ {
+ File[] sourceFiles = sourceDir.listFiles();
+ if (sourceFiles != null)
+ {
+ for (int i = 0; i < sourceFiles.length; i++)
+ {
+ if (!isExcluded(cargoFiles, sourceFiles[i].getName()))
+ {
+ if (sourceFiles[i].isDirectory())
+ {
+ getFileHandler().createDirectory(destDir.getPath(),
+ sourceFiles[i].getName());
+ copyExternalResources(sourceFiles[i], new File(destDir, sourceFiles[i]
+ .getName()), cargoFiles);
+ }
+ else
+ {
+ getFileHandler().copy(new FileInputStream(sourceFiles[i]),
+ new FileOutputStream(new File(destDir, sourceFiles[i].getName())));
+ }
+
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if file with name <code>filename</code> is one of cargo resources file.
+ *
+ * @param cargoFiles list of cargo resources files
+ * @param filename filename of the file
+ * @return true if <code>filename</code> is one of cargo resources file
+ */
+ private boolean isExcluded(String[] cargoFiles, String filename)
+ {
+ for (int i = 0; i < cargoFiles.length; i++)
+ {
+ if (cargoFiles[i].equals(filename))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.spi.configuration.AbstractStandaloneLocalConfiguration#createFilterChain()
+ */
+ protected FilterChain createJonasFilterChain(InstalledLocalContainer installedContainer)
+ {
+ // protocol, port, hostname are handled by the abstract impl
+ FilterChain filterChain = super.createFilterChain();
+
+ getAntUtils().addTokenToFilterChain(filterChain, GeneralPropertySet.RMI_PORT,
+ getPropertyValue(GeneralPropertySet.RMI_PORT));
+
+ getAntUtils().addTokenToFilterChain(filterChain, GeneralPropertySet.LOGGING,
+ getJonasLogLevel(getPropertyValue(GeneralPropertySet.LOGGING)));
+
+ getAntUtils().addTokenToFilterChain(filterChain, JonasPropertySet.JONAS_REALM_NAME,
+ getPropertyValue(JonasPropertySet.JONAS_REALM_NAME));
+
+ getAntUtils().addTokenToFilterChain(filterChain,
+ JonasPropertySet.JONAS_AVAILABLES_DATASOURCES,
+ getPropertyValue(JonasPropertySet.JONAS_AVAILABLES_DATASOURCES));
+
+ getAntUtils().addTokenToFilterChain(filterChain,
+ JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME,
+ getWebContainerClassName(installedContainer));
+
+ createUserFilterChain(filterChain);
+
+ return filterChain;
+
+ }
+
+ /**
+ * Get the Web Container Class Name.
+ *
+ * @param installedContainer theinstalled container
+ * @return he Web Container Class Name.
+ * @throws CargoException if Unable to detect JOnAS web container
+ */
+ protected String getWebContainerClassName(InstalledLocalContainer installedContainer)
+ throws CargoException
+ {
+ String providedSetting = getPropertyValue(JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME);
+ if (providedSetting == null || providedSetting.trim().length() < 1)
+ {
+ if (isWebContainerInstalled("lib/jetty/lib", installedContainer))
+ {
+ providedSetting = JETTY_WEB_CONTAINER_CLASS_NAME;
+ }
+ else if (isWebContainerInstalled("lib/catalina/server/lib", installedContainer))
+ {
+ providedSetting = CATALINA_WEB_CONTAINER_CLASS_NAME;
+ }
+ }
+
+ if (providedSetting == null || providedSetting.trim().length() < 1)
+ {
+ throw new CargoException("Unable to detect JOnAS web container "
+ + "implementation please provide a "
+ + JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME
+ + " setting containg the web runtime class name");
+ }
+ else
+ {
+ return providedSetting;
+ }
+ }
+
+ /**
+ * Checks whether a given web container is installed.
+ *
+ * @param webContainerLibDir Web container library directory.
+ * @param installedContainer Container to look for.
+ *
+ * @return true if installed, false otherwise.
+ */
+ private boolean isWebContainerInstalled(String webContainerLibDir,
+ InstalledLocalContainer installedContainer)
+ {
+
+ String libsDirName = getFileHandler().append(installedContainer.getHome(),
+ webContainerLibDir);
+ boolean exists = getFileHandler().exists(libsDirName);
+
+ if (exists)
+ {
+ String[] files = getFileHandler().getChildren(libsDirName);
+ // more than 1 jar is present in webContainerLibDir if the container is installed
+ int jarCount = 0;
+ for (int i = 0; i < files.length; i++)
+ {
+ if (files[i].toLowerCase().endsWith(".jar"))
+ {
+ jarCount++;
+ }
+ }
+
+ if (jarCount > 1)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Creates the user filter chain that should be applied while copying container configuration
+ * files to the working directory from which the container is started.
+ *
+ * @param filterChain The user filter chain
+ */
+ protected void createUserFilterChain(FilterChain filterChain)
+ {
+ StringBuffer rolesBuffer = new StringBuffer("<!-- no cargo roles defined -->");
+ StringBuffer usersBuffer = new StringBuffer("<!-- no cargo users defined -->");
+ if (getPropertyValue(ServletPropertySet.USERS) != null)
+ {
+
+ rolesBuffer.setLength(0);
+ usersBuffer.setLength(0);
+ Set processedRoles = new HashSet();
+ Iterator users = User.parseUsers(getPropertyValue(ServletPropertySet.USERS)).iterator();
+ while (users.hasNext())
+ {
+ User user = (User) users.next();
+ usersBuffer.append("<user name=\"").append(user.getName().trim()).append(
+ "\" password=\"").append(user.getPassword()).append("\" roles=\"");
+ Iterator roles = user.getRoles().iterator();
+ while (roles.hasNext())
+ {
+ String role = (String) roles.next();
+ if (!processedRoles.contains(role))
+ {
+ rolesBuffer.append("<role name=\"").append(role).append(
+ "\" description=\"Cargo standalone configuration "
+ + "auto generated role\" />\n");
+ processedRoles.add(role);
+ }
+ usersBuffer.append(role);
+ if (roles.hasNext())
+ {
+ usersBuffer.append(",");
+ }
+ }
+ usersBuffer.append("\" />\n");
+ }
+ }
+ getAntUtils().addTokenToFilterChain(filterChain, TOKEN_FILTER_KEY_USERS_ROLE,
+ rolesBuffer.toString().trim());
+ getAntUtils().addTokenToFilterChain(filterChain, "cargo.servlet.users.user",
+ usersBuffer.toString().trim());
+ }
+
+ /**
+ * Translate Cargo logging levels into JOnAS logging levels.
+ *
+ * @param cargoLogLevel Cargo logging level
+ * @return the corresponding JOnAS logging level
+ */
+ private String getJonasLogLevel(String cargoLogLevel)
+ {
+ String level;
+
+ if (cargoLogLevel.equalsIgnoreCase("low"))
+ {
+ level = "ERROR";
+ }
+ else if (cargoLogLevel.equalsIgnoreCase("medium"))
+ {
+ level = "WARN";
+ }
+ else
+ {
+ level = "INFO";
+ }
+
+ return level;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ return "JOnAS Standalone Configuration";
+ }
+}
Added: core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasPropertySet.java
===================================================================
--- core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasPropertySet.java (rev 0)
+++ core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasPropertySet.java 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,105 @@
+/*
+ * ========================================================================
+ *
+ * Copyright 2007-2008 OW2.
+ *
+ * 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.codehaus.cargo.container.jonas;
+
+/**
+ * JOnAS specific properties.
+ *
+ * @version $Id: JonasPropertySet.java 14699 2008-07-30 13:01:19Z alitokmen $
+ */
+public class JonasPropertySet
+{
+ /**
+ * Defines a deployable identifier for remote deployment, this identifier will be used within
+ * JOnAS to identify a deployed application When not specified, the file name of the deployable
+ * is used as the identifier.
+ */
+ public static final String JONAS_DEPLOYABLE_IDENTIFIER = "cargo.jonas.deployable.identifier";
+
+ /**
+ * The JOnAS target server name to be used for remote deployment, defaults to "jonas".
+ */
+ public static final String JONAS_SERVER_NAME = "cargo.jonas.server.name";
+
+ /**
+ * The JOnAS target domain name to be used for remote deployment, defaults to "jonas".
+ */
+ public static final String JONAS_DOMAIN_NAME = "cargo.jonas.domain.name";
+
+ /**
+ * The JOnAS target cluster name to be used for remote cluster deployment, defaults to null.
+ * If null, we consider deployment is done on the target server only (not a cluster).
+ * If not null, the target server must be set to the Domain Master's.
+ */
+ public static final String JONAS_CLUSTER_NAME = "cargo.jonas.cluster.name";
+
+ /**
+ * The JOnAS realm name for a standalone configuration, defaults to "memrlm_1", useful setting
+ * for webapps using a custom authentication realm name.
+ */
+ public static final String JONAS_REALM_NAME = "cargo.jonas.realm.name";
+
+ /**
+ * The JOnAS web container class name implementation to be used for standalone configuration,
+ * will be autodetected when no setting provided.
+ */
+ public static final String JONAS_WEBCONTAINER_CLASS_NAME =
+ "cargo.jonas.webcontainer.class.name";
+
+ /**
+ * The JOnAS available datasources configs names(comma delimited) for standalone configuration,
+ * defaults to "HSQL1". You will still have to configure manually in your JOnAS install home the
+ * datasource.properties files. HSLQ1 should always be provided.
+ */
+ public static final String JONAS_AVAILABLES_DATASOURCES = "cargo.jonas.datasources.name";
+
+ /**
+ * For MEJB remote deployment only, defines the path in the JNDI tree of the MEJB remote object,
+ * defaults to "ejb/mgmt/MEJB".
+ */
+ public static final String JONAS_MEJB_JNDI_PATH = "cargo.jonas.jndi.mejb.path";
+
+ /**
+ * For MEJB remote deployment only, defines the path where the JAAS configuration file is.
+ * Defaults to "jaas.config", ignored if {@link JonasPropertySet#JONAS_MEJB_JAAS_ROLE} is not
+ * set.
+ */
+ public static final String JONAS_MEJB_JAAS_FILE = "cargo.jonas.jndi.jaas.file";
+
+ /**
+ * For MEJB remote deployment only, defines the role to use when connecting. Defaults to null,
+ * in which case no authentication is used.
+ */
+ public static final String JONAS_MEJB_JAAS_ROLE = "cargo.jonas.jndi.jaas.role";
+
+ /**
+ * For MEJB remote deployment only, the jndi initial context factory, defaults to
+ * "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory".
+ */
+ public static final String JONAS_MEJB_JNDI_INIT_CTX_FACT =
+ "cargo.jonas.jndi.initial.context.factory";
+
+ /**
+ * Utility classes don't have a public constructor.
+ */
+ protected JonasPropertySet()
+ {
+ }
+}
Added: core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasRuntimeConfiguration.java
===================================================================
--- core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasRuntimeConfiguration.java (rev 0)
+++ core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasRuntimeConfiguration.java 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,57 @@
+/*
+ * ========================================================================
+ *
+ * Copyright 2007-2008 OW2.
+ *
+ * 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.codehaus.cargo.container.jonas;
+
+import org.codehaus.cargo.container.configuration.ConfigurationCapability;
+import org.codehaus.cargo.container.jonas.internal.JonasRuntimeConfigurationCapability;
+import org.codehaus.cargo.container.spi.configuration.AbstractRuntimeConfiguration;
+
+/**
+ * Configuration to use when using a JOnAS remote container.
+ *
+ * @version $Id: JonasRuntimeConfiguration.java 14641 2008-07-25 11:46:29Z alitokmen $
+ */
+public class JonasRuntimeConfiguration extends AbstractRuntimeConfiguration
+{
+ /**
+ * Capability of the JOnAS runtime configuration.
+ */
+ private static ConfigurationCapability capability = new JonasRuntimeConfigurationCapability();
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.cargo.container.configuration.Configuration#getCapability()
+ */
+ public ConfigurationCapability getCapability()
+ {
+ return capability;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ return "JOnAS Runtime Configuration";
+ }
+}
Added: core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/AbstractJonas4xRemoteDeployer.java
===================================================================
--- core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/AbstractJonas4xRemoteDeployer.java (rev 0)
+++ core/trunk/containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/AbstractJonas4xRemoteDeployer.java 2008-08-21 14:02:14 UTC (rev 1686)
@@ -0,0 +1,153 @@
+/*
+ * ========================================================================
+ *
+ * Copyright 2007-2008 OW2.
+ *
+ * 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.codehaus.cargo.container.jonas.internal;
+
+import java.io.File;
+
+import org.codehaus.cargo.container.RemoteContainer;
+import org.codehaus.cargo.container.deployable.Deployable;
+import org.codehaus.cargo.container.deployable.DeployableType;
+import org.codehaus.cargo.container.deployable.WAR;
+
+/**
+ * Remote deployer for JOnAS 4.x.
+ *
+ * @version $Id: AbstractJonas4xRemoteDeployer.java 14871 2008-08-20 14:19:25Z alitokmen $
+ */
+public abstract class AbstractJonas4xRemoteDeployer extends AbstractJonasRemoteDeployer
+{
+ /**
+ * Jonas4xJsr160RemoteDeployer Constructor.
+ *
+ * @param container the remote container
+ */
+ public AbstractJonas4xRemoteDeployer(RemoteContainer container)
+ {
+ super(container);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractJonasRemoteDeployer#getOperationName(ActionType, DeployableType)
+ */
+ protected String getOperationName(ActionType actionType, DeployableType deployableType)
+ {
+ String operationPrefix;
+ if (actionType == ActionType.DEPLOY)
+ {
+ operationPrefix = "deploy";
+ }
+ else if (actionType == ActionType.UPLOAD_DEPLOY)
+ {
+ operationPrefix = "uploadDeploy";
+ }
+ else if (actionType == ActionType.UNDEPLOY)
+ {
+ operationPrefix = "unDeploy";
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unsupported Action type: " + actionType);
+ }
+
+ String operationSuffix;
+ if (deployableType == DeployableType.WAR)
+ {
+ operationSuffix = "War";
+ }
+ else if (deployableType == DeployableType.EAR)
+ {
+ operationSuffix = "Ear";
+ }
+ else if (deployableType == DeployableType.EJB)
+ {
+ operationSuffix = "Jar";
+ }
+ else if (deployableType == DeployableType.RAR)
+ {
+ operationSuffix = "Rar";
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unsupported Deployable type: " + deployableType);
+ }
+
+ return operationPrefix + operationSuffix;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractJonasRemoteDeployer#getRemoteFileName(Deployable, String)
+ */
+ protected String getRemoteFileName(Deployable deployable, String deployableIdentifier)
+ {
+ String deployableId = deployableIdentifier;
+
+ if (deployableId != null && deployableId.trim().length() > 0)
+ {
+ int identifierExtIndex = deployableId.lastIndexOf(".");
+ if (identifierExtIndex != -1)
+ {
+ deployableId = deployableId.substring(0, identifierExtIndex);
+ }
+
+ if (deployable.getType() == DeployableType.WAR)
+ {
+ deployableId += ".war";
+ }
+ else if (deployable.getType() == DeployableType.EAR)
+ {
+ deployableId += ".ear";
+ }
+ else if (deployable.getType() == DeployableType.EJB)
+ {
+ deployableId += ".jar";
+ }
+ else if (deployable.getType() == DeployableType.RAR)
+ {
+ deployableId += ".rar";
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unsupported Deployable type: "
+ + deployable.getType());
+ }
+ return deployableId;
+ }
+
+ File localFile = new File(deployable.getFile());
+ String remoteFilePath = localFile.getName();
+ if (deployable.getType() == DeployableType.WAR)
+ {
+ WAR war = (WAR) deployable;
+ if (war.getContext().length() == 0)
+ {
+ remoteFilePath = "rootContext.war";
+