Index: samples/java/src/test/java/org/codehaus/cargo/sample/java/AbstractCargoTestCase.java =================================================================== --- samples/java/src/test/java/org/codehaus/cargo/sample/java/AbstractCargoTestCase.java (revision 1492) +++ samples/java/src/test/java/org/codehaus/cargo/sample/java/AbstractCargoTestCase.java (working copy) @@ -46,6 +46,7 @@ import org.codehaus.cargo.util.log.LogLevel; import java.io.File; +import java.util.Enumeration; public class AbstractCargoTestCase extends TestCase { @@ -137,6 +138,12 @@ configuration.setProperty(ServletPropertySet.PORT, "" + getTestData().port); configuration.setProperty(GeneralPropertySet.LOGGING, "high"); + + for (Enumeration e = getTestData().configuration.keys(); e.hasMoreElements();) + { + String propertyName = (String)e.nextElement(); + configuration.setProperty(propertyName,getTestData().configuration.getProperty(propertyName)); + } configuration.setLogger(getLogger()); Index: samples/java/src/test/java/org/codehaus/cargo/sample/java/RemoteDeploymentTest.java =================================================================== --- samples/java/src/test/java/org/codehaus/cargo/sample/java/RemoteDeploymentTest.java (revision 1492) +++ samples/java/src/test/java/org/codehaus/cargo/sample/java/RemoteDeploymentTest.java (working copy) @@ -52,31 +52,30 @@ private FileHandler fileHandler = new DefaultFileHandler(); private InstalledLocalContainer localContainer; + private Deployable war; + private Deployer deployer; + private URL warPingURL; - public RemoteDeploymentTest(String testName, EnvironmentTestData testData) - throws Exception + public RemoteDeploymentTest(String testName, EnvironmentTestData testData) throws Exception { super(testName, testData); } public static Test suite() throws Exception { - CargoTestSuite suite = new CargoTestSuite( - "Tests that perform remote deployments on remote containers"); + CargoTestSuite suite = + new CargoTestSuite("Tests that perform remote deployments on remote containers"); suite.addTestSuite(RemoteDeploymentTest.class, new Validator[] { - new IsRemoteContainerValidator(), - new HasRuntimeConfigurationValidator(), - new HasRemoteDeployerValidator(), - new HasWarSupportValidator(), + new IsRemoteContainerValidator(), new HasRuntimeConfigurationValidator(), + new HasRemoteDeployerValidator(), new HasWarSupportValidator(), - // Ensure the container can be installed locally so that we can start it and consider - // it as our remote container for the tests. - new HasInstalledLocalContainerValidator(), - new HasStandaloneConfigurationValidator()}); + // Ensure the container can be installed locally so that we can start it and consider + // it as our remote container for the tests. + new HasInstalledLocalContainerValidator(), new HasStandaloneConfigurationValidator()}); return suite; } @@ -87,13 +86,17 @@ // First install a local container and start it. This is the container into which we'll // deploy into. It'll act as a remote container, already running. - this.localContainer = (InstalledLocalContainer) createContainer( - ContainerType.INSTALLED, createConfiguration(ConfigurationType.STANDALONE)); + this.localContainer = + (InstalledLocalContainer) createContainer(ContainerType.INSTALLED, + createConfiguration(ConfigurationType.STANDALONE)); // Set up credentials for securing the manager app in the host container. This is for // Tomcat. - this.localContainer.getConfiguration().setProperty(ServletPropertySet.USERS, - "cargo:password:manager"); + if (this.localContainer.getConfiguration().getPropertyValue(ServletPropertySet.USERS) == null) + { + this.localContainer.getConfiguration().setProperty(ServletPropertySet.USERS, + "cargo:password:manager"); + } this.localContainer.start(); @@ -101,17 +104,24 @@ setContainer(createContainer(createConfiguration(ConfigurationType.RUNTIME))); // Set up deployment credentials - getRemoteContainer().getConfiguration().setProperty(RemotePropertySet.USERNAME, - "cargo"); - getRemoteContainer().getConfiguration().setProperty(RemotePropertySet.PASSWORD, - "password"); + if (getRemoteContainer().getConfiguration().getPropertyValue(RemotePropertySet.USERNAME) == null) + { + getRemoteContainer().getConfiguration().setProperty(RemotePropertySet.USERNAME, + "cargo"); + } + if (getRemoteContainer().getConfiguration().getPropertyValue(RemotePropertySet.PASSWORD) == null) + { + getRemoteContainer().getConfiguration().setProperty(RemotePropertySet.PASSWORD, + "password"); + } + this.war = + new DefaultDeployableFactory().createDeployable(getContainer().getId(), getTestData() + .getTestDataFileFor("simple-war"), DeployableType.WAR); - this.war = new DefaultDeployableFactory().createDeployable(getContainer().getId(), - getTestData().getTestDataFileFor("simple-war"), DeployableType.WAR); + this.warPingURL = + new URL("http://localhost:" + getTestData().port + "/simple-war-" + + getTestData().version + "/index.jsp"); - this.warPingURL = new URL("http://localhost:" + getTestData().port - + "/simple-war-" + getTestData().version + "/index.jsp"); - this.deployer = createDeployer(DeployerType.REMOTE, getRemoteContainer()); } @@ -126,7 +136,8 @@ public void testDeployUndeployRedeployWarRemotely() throws Exception { deployer.deploy(this.war); - PingUtils.assertPingTrue("simple war not correctly deployed", this.warPingURL, getLogger()); + PingUtils.assertPingTrue("simple war not correctly deployed", this.warPingURL, + getLogger()); deployer.undeploy(war); PingUtils.assertPingFalse("simple war not correctly undeployed", this.warPingURL, @@ -134,18 +145,21 @@ // Redeploy a second time to ensure that the undeploy worked. deployer.deploy(war); - PingUtils.assertPingTrue("simple war not correctly deployed", this.warPingURL, getLogger()); + PingUtils.assertPingTrue("simple war not correctly deployed", this.warPingURL, + getLogger()); // Redeploy the WAR after modifying its content deployer.redeploy(modifyWar(this.war)); - URL newWarPingURL = new URL("http://localhost:" + getTestData().port - + "/simple-war-" + getTestData().version + "/some.html"); - PingUtils.assertPingTrue("simple war not correctly redeployed", newWarPingURL, getLogger()); + URL newWarPingURL = + new URL("http://localhost:" + getTestData().port + "/simple-war-" + + getTestData().version + "/some.html"); + PingUtils.assertPingTrue("simple war not correctly redeployed", newWarPingURL, + getLogger()); } /** - * Modify the original simple WAR file to add a new HTML file which we will later ping to - * verify the new WAR has been deployed. + * Modify the original simple WAR file to add a new HTML file which we will later ping to verify + * the new WAR has been deployed. */ private Deployable modifyWar(Deployable originalDeployable) throws Exception { @@ -168,7 +182,7 @@ warTask.addFileset(fileSet); warTask.execute(); - return new DefaultDeployableFactory().createDeployable(getContainer().getId(), - updatedWar.getPath(), DeployableType.WAR); + return new DefaultDeployableFactory().createDeployable(getContainer().getId(), updatedWar + .getPath(), DeployableType.WAR); } } Index: samples/java/src/main/java/org/codehaus/cargo/sample/java/EnvironmentTestData.java =================================================================== --- samples/java/src/main/java/org/codehaus/cargo/sample/java/EnvironmentTestData.java (revision 1492) +++ samples/java/src/main/java/org/codehaus/cargo/sample/java/EnvironmentTestData.java (working copy) @@ -22,6 +22,8 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; +import java.util.Enumeration; +import java.util.Properties; import org.codehaus.cargo.container.ContainerException; import org.codehaus.cargo.container.ContainerType; @@ -88,6 +90,12 @@ * Proxy properties if defined (can be null). */ public Proxy proxy; + + + /** + * Custom configuration properties + */ + public Properties configuration; /** * @param containerId the container's name (eg "resin3x") @@ -109,9 +117,32 @@ this.home = getSystemProperty("cargo." + containerId + ".home"); this.version = System.getProperty("cargo.version"); this.containerTimeout = Long.parseLong(getSystemProperty("cargo.containers.timeout")); + this.configuration = createContainerConfiguration(containerId); } /** + * Parse the list of system properties starting with cargo." + containerId + ".configuration. + * and populates a Properties object with properties names minus cargo." + containerId + ".configuration. + * @param containerId the container id to search configuration properties for + * @return a properties object containing container specific configuration entries + */ + private Properties createContainerConfiguration(String containerId) + { + Properties config = new Properties(); + String configurationPrefix = "cargo." + containerId + ".configuration."; + configuration = new Properties(); + for (Enumeration e = System.getProperties().keys(); e.hasMoreElements();) + { + String propertyName = (String)e.nextElement(); + if (propertyName.startsWith(configurationPrefix)) + { + config.put(propertyName.substring(configurationPrefix.length()), System.getProperty(propertyName)); + } + } + return config; + } + + /** * @param containerName the container's name * @return the port to use for the specified container */ Index: samples/pom.xml =================================================================== --- samples/pom.xml (revision 1492) +++ samples/pom.xml (working copy) @@ -43,6 +43,11 @@ org.codehaus.cargo + cargo-core-container-jonas + ${version} + + + org.codehaus.cargo cargo-core-container-orion ${version} @@ -224,6 +229,15 @@ cargo.jetty6x.url http://dist.codehaus.org/jetty/jetty-6.1.1.zip + + + cargo.geronimo1x.port + 8280 + + + cargo.geronimo1x.url + http://www.apache.org/dist/geronimo/1.1.1/geronimo-tomcat-j2ee-1.1.1.zip + + + + cargo.jonas4x.port + 8280 + + + + cargo.jonas4x.configuration.cargo.jonas.realm.name + Cargo_Test_Realm + + + cargo.jonas4x.configuration.cargo.jonas.remote.deployer.skip.module.removal + true + + + cargo.jonas4x.configuration.cargo.remote.username + jonas + + + cargo.jonas4x.configuration.cargo.remote.password + jonas + + + cargo.version - 0.9.1 + ${version} @@ -406,6 +459,12 @@ + geronimo1x + + geronimo1x + + + orion1x orion1x @@ -483,5 +542,11 @@ jo1x + + jonas4x + + jonas4x + + \ No newline at end of file Index: containers/jetty/src/main/java/org/codehaus/cargo/container/jetty/Jetty6xEmbeddedLocalContainer.java =================================================================== --- containers/jetty/src/main/java/org/codehaus/cargo/container/jetty/Jetty6xEmbeddedLocalContainer.java (revision 1492) +++ containers/jetty/src/main/java/org/codehaus/cargo/container/jetty/Jetty6xEmbeddedLocalContainer.java (working copy) @@ -332,7 +332,7 @@ getClassLoader().loadClass("org.mortbay.jetty.security.HashUserRealm"); this.defaultRealm = realmClass.getConstructor(new Class[] {String.class}).newInstance( - new Object[] {"Cargo Test Realm"}); + new Object[] {"Cargo_Test_Realm"}); Iterator users = User.parseUsers(getConfiguration().getPropertyValue(ServletPropertySet.USERS)) Index: containers/jetty/src/main/java/org/codehaus/cargo/container/jetty/internal/AbstractJetty4x5xEmbeddedLocalContainer.java =================================================================== --- containers/jetty/src/main/java/org/codehaus/cargo/container/jetty/internal/AbstractJetty4x5xEmbeddedLocalContainer.java (revision 1492) +++ containers/jetty/src/main/java/org/codehaus/cargo/container/jetty/internal/AbstractJetty4x5xEmbeddedLocalContainer.java (working copy) @@ -130,7 +130,7 @@ { Class realmClass = getClassLoader().loadClass("org.mortbay.http.HashUserRealm"); Object defaultRealm = realmClass.getConstructor( - new Class[] {String.class}).newInstance(new Object[] {"Cargo Test Realm"}); + new Class[] {String.class}).newInstance(new Object[] {"Cargo_Test_Realm"}); Iterator users = User.parseUsers( getConfiguration().getPropertyValue(ServletPropertySet.USERS)).iterator(); Index: containers/pom.xml =================================================================== --- containers/pom.xml (revision 1492) +++ containers/pom.xml (working copy) @@ -66,5 +66,6 @@ resin tomcat weblogic + jonas Index: containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalContainerTest.java =================================================================== --- containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalContainerTest.java (revision 0) +++ containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalContainerTest.java (revision 0) @@ -0,0 +1,131 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas; + +import org.apache.commons.vfs.impl.StandardFileSystemManager; +import org.apache.tools.ant.taskdefs.Java; +import org.codehaus.cargo.container.configuration.LocalConfiguration; +import org.codehaus.cargo.util.FileHandler; +import org.codehaus.cargo.util.VFSFileHandler; +import org.jmock.Mock; +import org.jmock.cglib.MockObjectTestCase; +import org.jmock.core.Constraint; + +/** + * Unit tests for {@link Jonas4xInstalledLocalContainer}. + */ +public class Jonas4xInstalledLocalContainerTest extends MockObjectTestCase +{ + + private static final String JONAS_ROOT = "ram:///jonasroot"; + + private static final String JONAS_BASE = "ram:///jonasbase"; + + private Jonas4xInstalledLocalContainer container; + + private StandardFileSystemManager fsManager; + + private FileHandler fileHandler; + + /** + * {@inheritDoc} + * + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + + this.fsManager = new StandardFileSystemManager(); + this.fsManager.init(); + this.fileHandler = new VFSFileHandler(this.fsManager); + + this.fileHandler.createDirectory(null, JONAS_ROOT); + this.fileHandler.createDirectory(null, JONAS_BASE); + + LocalConfiguration configuration = new JonasStandaloneLocalConfiguration(JONAS_BASE); + + this.container = new Jonas4xInstalledLocalContainer(configuration); + this.container.setFileHandler(this.fileHandler); + this.container.setHome(JONAS_ROOT); + + } + + public void testSetupSysProps() + { + Mock mockJava = mock(Java.class); + + DoActionConstraint constaint = new DoActionConstraint(); + mockJava.expects(exactly(15)).method("addSysproperty").with(constaint); + + container.setupSysProps((Java) mockJava.proxy()); + + mockJava.verify(); + assertEquals(0, constaint.remaingChecks); + } + + private class DoActionConstraint implements Constraint + { + + int remaingChecks = 5; + + String settingPair = null; + + public boolean eval(Object arg) + { + org.apache.tools.ant.types.Environment.Variable var = + (org.apache.tools.ant.types.Environment.Variable) arg; + settingPair = var.getKey() + "=" + var.getValue(); + if (var.getKey().equals("install.root")) + { + remaingChecks--; + return var.getValue().endsWith("ram:/jonasroot"); + } + else if (var.getKey().equals("jonas.base")) + { + remaingChecks--; + return var.getValue().endsWith("ram:/jonasbase"); + } + else if (var.getKey().equals("java.endorsed.dirs")) + { + remaingChecks--; + return var.getValue().endsWith(fileHandler.append("ram:/jonasroot", "lib/endorsed")); + } + else if (var.getKey().equals("java.security.policy")) + { + remaingChecks--; + return var.getValue().endsWith(fileHandler.append("ram:/jonasbase", "conf/java.policy")); + } + else if (var.getKey().equals("java.security.auth.login.config")) + { + remaingChecks--; + return var.getValue().endsWith(fileHandler.append("ram:/jonasbase", "conf/jaas.config")); + } + return true; + } + + public StringBuffer describeTo(StringBuffer buffer) + { + buffer.append("unexpected settings " + settingPair); + return buffer; + } + + } +} Index: containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalDeployerTest.java =================================================================== --- containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalDeployerTest.java (revision 0) +++ containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalDeployerTest.java (revision 0) @@ -0,0 +1,226 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas; + +import org.apache.commons.vfs.impl.StandardFileSystemManager; +import org.codehaus.cargo.container.configuration.LocalConfiguration; +import org.codehaus.cargo.container.deployable.DeployableType; +import org.codehaus.cargo.container.deployable.EAR; +import org.codehaus.cargo.container.deployable.EJB; +import org.codehaus.cargo.container.deployable.WAR; +import org.codehaus.cargo.container.jonas.internal.JonasAdmin; +import org.codehaus.cargo.generic.deployable.DefaultDeployableFactory; +import org.codehaus.cargo.generic.deployable.DeployableFactory; +import org.codehaus.cargo.util.CargoException; +import org.codehaus.cargo.util.FileHandler; +import org.codehaus.cargo.util.VFSFileHandler; +import org.jmock.Mock; +import org.jmock.cglib.MockObjectTestCase; + +/** + * Unit tests for {@link Jonas4xInstalledLocalDeployer}. + */ +public class Jonas4xInstalledLocalDeployerTest extends MockObjectTestCase +{ + + private static final String JONAS_ROOT = "ram:///jonasroot"; + + private static final String JONAS_BASE = "ram:///jonasbase"; + + private Jonas4xInstalledLocalDeployer deployer; + + private StandardFileSystemManager fsManager; + + private FileHandler fileHandler; + + private Mock admin; + + private DeployableFactory factory; + + /** + * {@inheritDoc} + * + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + + this.fsManager = new StandardFileSystemManager(); + this.fsManager.init(); + this.fileHandler = new VFSFileHandler(this.fsManager); + + this.fileHandler.createDirectory(null, JONAS_ROOT); + this.fileHandler.createDirectory(null, JONAS_BASE); + + LocalConfiguration configuration = new JonasExistingLocalConfiguration(JONAS_BASE); + + Jonas4xInstalledLocalContainer container = + new Jonas4xInstalledLocalContainer(configuration); + container.setFileHandler(this.fileHandler); + container.setHome(JONAS_ROOT); + + admin = mock(JonasAdmin.class); + + deployer = + new Jonas4xInstalledLocalDeployer(container, + (JonasAdmin) admin.proxy(), + this.fileHandler); + + factory = new DefaultDeployableFactory(); + + } + + private void setupAdminHotDeployment() + { + admin.reset(); + admin.stubs().method("isServerRunning").will(returnValue(true)); + admin.stubs().method("deploy").withAnyArguments().will(returnValue(true)); + } + + private void setupAdminHotDeploymentFailure() + { + admin.reset(); + admin.stubs().method("isServerRunning").will(returnValue(true)); + admin.stubs().method("deploy").withAnyArguments().will(returnValue(false)); + } + + private void setupAdminColdDeployment() + { + admin.reset(); + admin.stubs().method("isServerRunning").will(returnValue(false)); + } + + public void testDeployJar() + { + + this.fileHandler.createFile("ram:///test.jar"); + EJB ejb = + (EJB) factory.createDeployable(Jonas4xInstalledLocalContainer.ID, "ram:///test.jar", + DeployableType.EJB); + + setupAdminColdDeployment(); + deployer.deployEjb(deployer.getDeployableDir(), ejb); + assertTrue(fileHandler.exists(deployer.getDeployableDir() + "/ejbjars/autoload/test.jar")); + + setupAdminHotDeployment(); + deployer.deployEjb(deployer.getDeployableDir(), ejb); + assertTrue(fileHandler.exists(deployer.getDeployableDir() + "/ejbjars/test.jar")); + + setupAdminHotDeploymentFailure(); + try + { + deployer.deployEjb(deployer.getDeployableDir(), ejb); + fail("No CargoException raised"); + } + catch (CargoException ex) + { + } + + } + + public void testDeployEjb() + { + + this.fileHandler.createFile("ram:///test.ear"); + EAR ear = + (EAR) factory.createDeployable(Jonas4xInstalledLocalContainer.ID, "ram:///test.ear", + DeployableType.EAR); + + setupAdminColdDeployment(); + deployer.deployEar(deployer.getDeployableDir(), ear); + assertTrue(fileHandler.exists(deployer.getDeployableDir() + "/apps/autoload/test.ear")); + + setupAdminHotDeployment(); + deployer.deployEar(deployer.getDeployableDir(), ear); + assertTrue(fileHandler.exists(deployer.getDeployableDir() + "/apps/test.ear")); + + setupAdminHotDeploymentFailure(); + try + { + deployer.deployEar(deployer.getDeployableDir(), ear); + fail("No CargoException raised"); + } + catch (CargoException ex) + { + } + + } + + public void testDeployWar() + { + this.fileHandler.createFile("ram:///test.war"); + WAR war = + (WAR) factory.createDeployable(Jonas4xInstalledLocalContainer.ID, "ram:///test.war", + DeployableType.WAR); + war.setContext("testContext"); + + setupAdminColdDeployment(); + deployer.deployWar(deployer.getDeployableDir(), war); + assertFalse(fileHandler + .exists(deployer.getDeployableDir() + "/webapps/autoload/test.war")); + assertTrue(fileHandler.exists(deployer.getDeployableDir() + + "/webapps/autoload/testContext.war")); + + setupAdminHotDeployment(); + deployer.deployWar(deployer.getDeployableDir(), war); + assertFalse(fileHandler.exists(deployer.getDeployableDir() + "/webapps/test.war")); + assertTrue(fileHandler.exists(deployer.getDeployableDir() + "/webapps/testContext.war")); + + setupAdminHotDeploymentFailure(); + try + { + deployer.deployWar(deployer.getDeployableDir(), war); + fail("No CargoException raised"); + } + catch (CargoException ex) + { + } + } + + public void testDeployExpandedWar() + { + this.fileHandler.createFile("ram:///testExpandedWar"); + WAR war = + (WAR) factory.createDeployable(Jonas4xInstalledLocalContainer.ID, + "ram:///testExpandedWar", DeployableType.WAR); + war.setContext("testExpandedWarContext"); + + setupAdminColdDeployment(); + deployer.deployExpandedWar(deployer.getDeployableDir(), war); + assertFalse(fileHandler.exists(deployer.getDeployableDir() + + "/webapps/autoload/testExpandedWar")); + assertTrue(fileHandler.exists(deployer.getDeployableDir() + + "/webapps/autoload/testExpandedWarContext")); + + setupAdminHotDeployment(); + deployer.deployExpandedWar(deployer.getDeployableDir(), war); + assertFalse(fileHandler.exists(deployer.getDeployableDir() + "/webapps/testExpandedWar")); + assertFalse(fileHandler.exists(deployer.getDeployableDir() + + "/webapps/testExpandedWarContext")); + + } + + public void testGetDeployableDir() + { + assertEquals(JONAS_BASE, deployer.getDeployableDir()); + } + +} Index: containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/JonasStandaloneLocalConfigurationTest.java =================================================================== --- containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/JonasStandaloneLocalConfigurationTest.java (revision 0) +++ containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/JonasStandaloneLocalConfigurationTest.java (revision 0) @@ -0,0 +1,276 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas; + +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; + +import junit.framework.TestCase; + +import org.apache.commons.vfs.impl.StandardFileSystemManager; +import org.apache.tools.ant.filters.ReplaceTokens; +import org.apache.tools.ant.types.FilterChain; +import org.codehaus.cargo.container.property.GeneralPropertySet; +import org.codehaus.cargo.container.property.ServletPropertySet; +import org.codehaus.cargo.util.CargoException; +import org.codehaus.cargo.util.FileHandler; +import org.codehaus.cargo.util.VFSFileHandler; + +/** + * Unit tests for {@link JonasStandaloneLocalConfiguration}. + */ +public class JonasStandaloneLocalConfigurationTest extends TestCase +{ + private static final String JONAS_ROOT = "ram:///jonasroot"; + + private static final String JONAS_BASE = "ram:///jonasbase"; + + private Jonas4xInstalledLocalContainer container; + + private StandardFileSystemManager fsManager; + + private FileHandler fileHandler; + + private JonasStandaloneLocalConfiguration configuration; + + /** + * {@inheritDoc} + * + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + + this.fsManager = new StandardFileSystemManager(); + this.fsManager.init(); + this.fileHandler = new VFSFileHandler(this.fsManager); + + fileHandler.createDirectory(null, JONAS_ROOT); + fileHandler.createDirectory(null, JONAS_BASE); + + configuration = new JonasStandaloneLocalConfiguration(JONAS_BASE); + configuration.setFileHandler(fileHandler); + + this.container = new Jonas4xInstalledLocalContainer(configuration); + this.container.setFileHandler(this.fileHandler); + this.container.setHome(JONAS_ROOT); + + } + + public void testDoConfigure() throws Exception + { + + configuration.setProperty(JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME, + "com.foo.bar.WebContainerImpl"); + + configuration.doConfigure(container); + + assertTrue(fileHandler.exists(JONAS_BASE + "/webapps")); + assertTrue(fileHandler.exists(JONAS_BASE + "/webapps/autoload")); + assertTrue(fileHandler.exists(JONAS_BASE + "/ejbjars")); + assertTrue(fileHandler.exists(JONAS_BASE + "/ejbjars/autoload")); + assertTrue(fileHandler.exists(JONAS_BASE + "/apps")); + assertTrue(fileHandler.exists(JONAS_BASE + "/apps/autoload")); + assertTrue(fileHandler.exists(JONAS_BASE + "/rars")); + assertTrue(fileHandler.exists(JONAS_BASE + "/rars/autoload")); + + assertTrue(fileHandler.exists(JONAS_BASE + "/conf")); + assertTrue(fileHandler.exists(JONAS_BASE + "/logs")); + + } + + public void testCreateJonasFilterChain() throws Exception + { + + configuration.setProperty(GeneralPropertySet.PROTOCOL, "https"); + configuration.setProperty(ServletPropertySet.PORT, "8080"); + configuration.setProperty(GeneralPropertySet.HOSTNAME, "testhost"); + configuration.setProperty(GeneralPropertySet.RMI_PORT, "1098"); + configuration.setProperty(GeneralPropertySet.LOGGING, "low"); // cargo compliant level + configuration.setProperty(JonasPropertySet.JONAS_REALM_NAME, "test_realm_name"); + configuration.setProperty(JonasPropertySet.JONAS_AVAILABLES_DATASOURCES, + "testds1,testds2"); + configuration.setProperty(JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME, + "test.impl.Class"); + + Map replacements = new HashMap(); + replacements.put(GeneralPropertySet.PROTOCOL, "test @" + GeneralPropertySet.PROTOCOL + + "@ test"); + replacements.put(ServletPropertySet.PORT, "test @" + ServletPropertySet.PORT + "@ test"); + replacements.put(GeneralPropertySet.HOSTNAME, "test @" + GeneralPropertySet.HOSTNAME + + "@ test"); + replacements.put(GeneralPropertySet.RMI_PORT, "test @" + GeneralPropertySet.RMI_PORT + + "@ test"); + replacements.put(GeneralPropertySet.LOGGING, "test @" + GeneralPropertySet.LOGGING + + "@ test"); + replacements.put(JonasPropertySet.JONAS_REALM_NAME, "test @" + + JonasPropertySet.JONAS_REALM_NAME + "@ test"); + replacements.put(JonasPropertySet.JONAS_AVAILABLES_DATASOURCES, "test @" + + JonasPropertySet.JONAS_AVAILABLES_DATASOURCES + "@ test"); + replacements.put(JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME, "test @" + + JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME + "@ test"); + Map replacementsResults = new HashMap(); + + FilterChain jonasFilterChain = configuration.createJonasFilterChain(this.container); + + processTestChainReplacements(replacements, replacementsResults, jonasFilterChain); + + assertEquals("test testhost test", (String) replacementsResults + .get(GeneralPropertySet.HOSTNAME)); + assertEquals("test https test", (String) replacementsResults + .get(GeneralPropertySet.PROTOCOL)); + assertEquals("test 8080 test", (String) replacementsResults.get(ServletPropertySet.PORT)); + assertEquals("test 1098 test", (String) replacementsResults + .get(GeneralPropertySet.RMI_PORT)); + assertEquals("test ERROR test", (String) replacementsResults + .get(GeneralPropertySet.LOGGING)); // transformed to log4j compliant level by + // createJonasFilterChain + assertEquals("test test_realm_name test", (String) replacementsResults + .get(JonasPropertySet.JONAS_REALM_NAME)); + assertEquals("test testds1,testds2 test", (String) replacementsResults + .get(JonasPropertySet.JONAS_AVAILABLES_DATASOURCES)); + assertEquals("test test.impl.Class test", (String) replacementsResults + .get(JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME)); + + } + + public void testCreateUserFilterChain() throws Exception + { + + Map replacementsResults = new HashMap(); + Map replacements = new HashMap(); + replacements.put(JonasStandaloneLocalConfiguration.TOKEN_FILTER_KEY_USERS_ROLE, "test @" + + JonasStandaloneLocalConfiguration.TOKEN_FILTER_KEY_USERS_ROLE + "@ test"); + replacements.put(JonasStandaloneLocalConfiguration.TOKEN_FILTER_KEY_USERS_USER, "test @" + + JonasStandaloneLocalConfiguration.TOKEN_FILTER_KEY_USERS_USER + "@ test"); + + FilterChain usersFilterChain = new FilterChain(); + configuration.createUserFilterChain(usersFilterChain); + processTestChainReplacements(replacements, replacementsResults, usersFilterChain); + assertEquals("test test", (String) replacementsResults + .get(JonasStandaloneLocalConfiguration.TOKEN_FILTER_KEY_USERS_ROLE)); + assertEquals("test test", (String) replacementsResults + .get(JonasStandaloneLocalConfiguration.TOKEN_FILTER_KEY_USERS_USER)); + + replacementsResults.clear(); + usersFilterChain = new FilterChain(); + configuration.setProperty(ServletPropertySet.USERS, "test:pwd:testrole1,testrole2"); + configuration.createUserFilterChain(usersFilterChain); + processTestChainReplacements(replacements, replacementsResults, usersFilterChain); + assertEquals( + "test \n test", + (String) replacementsResults + .get(JonasStandaloneLocalConfiguration.TOKEN_FILTER_KEY_USERS_ROLE)); + assertEquals( + "test test", + (String) replacementsResults + .get(JonasStandaloneLocalConfiguration.TOKEN_FILTER_KEY_USERS_USER)); + + replacementsResults.clear(); + usersFilterChain = new FilterChain(); + configuration.setProperty(ServletPropertySet.USERS, + "test1:pwd:testrole1,testrole2|test2:pwd:testrole1"); + configuration.createUserFilterChain(usersFilterChain); + processTestChainReplacements(replacements, replacementsResults, usersFilterChain); + assertEquals( + "test \n test", + (String) replacementsResults + .get(JonasStandaloneLocalConfiguration.TOKEN_FILTER_KEY_USERS_ROLE)); + assertEquals( + "test \n test", + (String) replacementsResults + .get(JonasStandaloneLocalConfiguration.TOKEN_FILTER_KEY_USERS_USER)); + + } + + public void testGetWebContainerClassName() + { + // implementation only looks if more than 1 jar is present in the jetty or catalina libs dir + // if more than 1 jar, then it means that the we have found the jonas provided web container + // nothing setting provided and no dirs present, the conf should raise a CargoException + try + { + configuration.getWebContainerClassName(this.container); + fail("CargoException not raised"); + } + catch (CargoException ex) + { + + } + + // setup a fake jetty and catalina installation + fileHandler.createDirectory(container.getHome(), "lib/jetty/lib"); + fileHandler.createFile(fileHandler.append(container.getHome(), + "lib/jetty/lib/testjar1.jar")); + fileHandler.createDirectory(container.getHome(), "lib/catalina/server/lib"); + fileHandler.createFile(fileHandler.append(container.getHome(), + "lib/catalina/server/lib/testjar1.jar")); + configuration.setProperty(JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME, "foo.bar.baz"); + assertEquals("foo.bar.baz", configuration.getWebContainerClassName(this.container)); + + configuration.setProperty(JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME, null); + // adding an additional jar to enable jetty detection + fileHandler.createFile(fileHandler.append(container.getHome(), + "lib/jetty/lib/testjar2.jar")); + assertEquals(JonasStandaloneLocalConfiguration.JETTY_WEB_CONTAINER_CLASS_NAME, + configuration.getWebContainerClassName(this.container)); + + // adding an additional jar to enable catalina detection + fileHandler.createFile(fileHandler.append(container.getHome(), + "lib/catalina/server/lib/testjar2.jar")); + // removing fake jetty jar to stop jetty detection + fileHandler.delete(fileHandler.append(container.getHome(), "lib/jetty/lib/testjar2.jar")); + assertEquals(JonasStandaloneLocalConfiguration.CATALINA_WEB_CONTAINER_CLASS_NAME, + configuration.getWebContainerClassName(this.container)); + } + + private void processTestChainReplacements(Map replacements, Map replacementsResults, + FilterChain filterChain) throws IOException + { + for (Iterator i = replacements.keySet().iterator(); i.hasNext();) + { + String keyName = (String) i.next(); + Vector readers = filterChain.getFilterReaders(); + for (Enumeration e = readers.elements(); e.hasMoreElements();) + { + ReplaceTokens replaceToken = (ReplaceTokens) e.nextElement(); + Reader replacedReader = + replaceToken.chain(new StringReader((String) replacements.get(keyName))); + int readen = 0; + StringBuffer replaced = new StringBuffer(); + while ((readen = replacedReader.read()) != -1) + { + replaced.append((char) readen); + } + if (replaced.indexOf("@") == -1) + { + replacementsResults.put(keyName, replaced.toString()); + } + } + } + } +} Index: containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/JonasExistingLocalConfigurationTest.java =================================================================== --- containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/JonasExistingLocalConfigurationTest.java (revision 0) +++ containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/JonasExistingLocalConfigurationTest.java (revision 0) @@ -0,0 +1,97 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas; + +import junit.framework.TestCase; + +import org.apache.commons.vfs.impl.StandardFileSystemManager; +import org.codehaus.cargo.container.ContainerException; +import org.codehaus.cargo.util.FileHandler; +import org.codehaus.cargo.util.VFSFileHandler; + +/** + * Unit tests for {@link JonasExistingLocalConfiguration}. + */ +public class JonasExistingLocalConfigurationTest extends TestCase +{ + private static final String JONAS_ROOT = "ram:///jonasroot"; + + private Jonas4xInstalledLocalContainer container; + + private StandardFileSystemManager fsManager; + + private FileHandler fileHandler; + + private JonasExistingLocalConfiguration configuration; + + /** + * {@inheritDoc} + * + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + + this.fsManager = new StandardFileSystemManager(); + this.fsManager.init(); + this.fileHandler = new VFSFileHandler(this.fsManager); + + fileHandler.createDirectory(null, JONAS_ROOT); + + configuration = new JonasExistingLocalConfiguration(JONAS_ROOT); + configuration.setFileHandler(fileHandler); + + this.container = new Jonas4xInstalledLocalContainer(configuration); + this.container.setFileHandler(this.fileHandler); + this.container.setHome(JONAS_ROOT); + + } + + public void testDoConfigure() throws Exception + { + try + { + configuration.doConfigure(container); + fail("No ContainerException raised"); + } + catch (ContainerException ex) + { + } + + fileHandler.createDirectory(JONAS_ROOT, "conf"); + fileHandler.createDirectory(JONAS_ROOT, "apps"); + fileHandler.createDirectory(JONAS_ROOT, "apps/autoload"); + fileHandler.createDirectory(JONAS_ROOT, "webapps"); + fileHandler.createDirectory(JONAS_ROOT, "webapps/autoload"); + fileHandler.createDirectory(JONAS_ROOT, "ejbjars"); + fileHandler.createDirectory(JONAS_ROOT, "ejbjars/autoload"); + + try + { + configuration.doConfigure(container); + } + catch (ContainerException ex) + { + ex.printStackTrace(); + fail("ContainerException raised"); + } + } +} Index: containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/internal/AbstractJonasJMXRemoteDeployerTest.java =================================================================== --- containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/internal/AbstractJonasJMXRemoteDeployerTest.java (revision 0) +++ containers/jonas/src/test/java/org/codehaus/cargo/container/jonas/internal/AbstractJonasJMXRemoteDeployerTest.java (revision 0) @@ -0,0 +1,119 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas.internal; + +import javax.management.MalformedObjectNameException; + +import org.codehaus.cargo.container.RemoteContainer; +import org.codehaus.cargo.container.configuration.RuntimeConfiguration; +import org.codehaus.cargo.container.deployable.Deployable; +import org.codehaus.cargo.container.deployable.DeployableType; +import org.codehaus.cargo.container.deployable.WAR; +import org.codehaus.cargo.container.jonas.Jonas4xRemoteContainer; +import org.codehaus.cargo.container.jonas.JonasRuntimeConfiguration; +import org.codehaus.cargo.generic.deployable.DefaultDeployableFactory; +import org.codehaus.cargo.generic.deployable.DeployableFactory; +import org.jmock.MockObjectTestCase; + +/** + * Unit tests for {@link AbstractJonasJMXRemoteDeployer}. + */ +public class AbstractJonasJMXRemoteDeployerTest extends MockObjectTestCase +{ + + private RuntimeConfiguration runtime; + + private RemoteContainer container; + + private AbstractJonasJMXRemoteDeployer deployer; + + protected void setUp() throws Exception + { + runtime = new JonasRuntimeConfiguration(); + container = new Jonas4xRemoteContainer(runtime); + deployer = new TestDeployer(container); + } + + public void testGetRemoteFileName() + { + + DeployableFactory factory = new DefaultDeployableFactory(); + + Deployable deployable = + factory.createDeployable("jonas4x", "/foo/bar.war", DeployableType.WAR); + + assertEquals("foo.war", deployer.getRemoteFileName(deployable, "foo.pipo")); + assertEquals("foo.war", deployer.getRemoteFileName(deployable, "foo")); + assertEquals("bar.war", deployer.getRemoteFileName(deployable, null)); + + deployable = factory.createDeployable("jonas4x", "/foo/bar.war", DeployableType.WAR); + + ((WAR) deployable).setContext("/testContext"); + assertEquals("testContext.war", deployer.getRemoteFileName(deployable, null)); + + ((WAR) deployable).setContext("/"); + assertEquals("rootContext.war", deployer.getRemoteFileName(deployable, null)); + } + + public void testGetServerMBeanName() + { + try + { + String objectName = deployer.getServerMBeanName("foo", "bar").toString(); + assertEquals("foo:j2eeType=J2EEServer,name=bar", objectName); + } + catch (MalformedObjectNameException e) + { + fail("No error should be thrown"); + } + try + { + deployer.getServerMBeanName(null, "bar").toString(); + fail("error should be thrown"); + } + catch (MalformedObjectNameException e) + { + } + try + { + deployer.getServerMBeanName("", "bar").toString(); + fail("error should be thrown"); + } + catch (MalformedObjectNameException e) + { + } + } + + private class TestDeployer extends AbstractJonasJMXRemoteDeployer + { + + public TestDeployer(RemoteContainer container) + { + super(container); + } + + public MBeanServerConnectionFactory getMBeanServerConnectionFactory() + { + return null; + } + + } + +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xAdmin.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xAdmin.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xAdmin.java (revision 0) @@ -0,0 +1,104 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +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 + */ +public class Jonas4xAdmin implements JonasAdmin +{ + + /** + * Target jonas container, used for admin command line invocation setup + */ + private Jonas4xInstalledLocalContainer targetContainer; + + 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 undeployed + */ + public final boolean deploy(String beanFileName) + { + return genericDeployment(beanFileName, "-a"); + } + + 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; + } +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalContainer.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalContainer.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalContainer.java (revision 0) @@ -0,0 +1,260 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Map; + +import org.apache.tools.ant.taskdefs.Java; +import org.apache.tools.ant.types.Path; +import org.codehaus.cargo.container.ContainerCapability; +import org.codehaus.cargo.container.ContainerException; +import org.codehaus.cargo.container.configuration.LocalConfiguration; +import org.codehaus.cargo.container.internal.AntContainerExecutorThread; +import org.codehaus.cargo.container.jonas.internal.JonasContainerCapability; +import org.codehaus.cargo.container.spi.AbstractInstalledLocalContainer; + +/** + * Support for the Jonas JEE container. + */ +public class Jonas4xInstalledLocalContainer extends AbstractInstalledLocalContainer +{ + + /** + * Unique container id. + */ + public static final String ID = "jonas4x"; + + /** + * Container version + */ + private String version = null; + + /** + * Capability of the Jonas container. + */ + private ContainerCapability capability = new JonasContainerCapability(); + + /** + * {@inheritDoc} + * + * @see AbstractResinInstalledLocalContainer#AbstractInstalledLocalContainer(org.codehaus.cargo.container.configuration.LocalConfiguration) + */ + public Jonas4xInstalledLocalContainer(LocalConfiguration configuration) + { + super(configuration); + } + + /** + * {@inheritDoc} + * + * @see AbstractInstalledLocalContainer#doStart(Java) + */ + protected 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 AbstractInstalledLocalContainer#doStop(Java) + */ + protected 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(); + + } + + /** + * Setup of the target server name for the jonas admin command call + * + * @param java the target java ant task to setup + */ + protected void doServerNameParam(Java java) + { + String serverName = + getConfiguration().getPropertyValue(JonasPropertySet.JONAS_SERVER_NAME); + if (serverName != null && serverName.trim().length() == 0) + { + java.createArg().setValue("-n"); + java.createArg().setValue(serverName); + } + } + + /** + * Setup of the required java system properties to configure jonas properly + * + * @param java the target java ant task to setup + */ + protected void setupSysProps(Java java) + { + + Map configuredSysProps = getSystemProperties(); + addSysProp(java, configuredSysProps, "install.root", new File(getHome()).getAbsolutePath()); + addSysProp(java, configuredSysProps, "jonas.base", new File(getConfiguration().getHome()).getAbsolutePath()); + addSysProp(java, configuredSysProps, "java.endorsed.dirs", new File(getFileHandler().append( + getHome(), "lib/endorsed")).getAbsolutePath()); + addSysProp(java, configuredSysProps, "java.security.policy", new File(getFileHandler().append( + getConfiguration().getHome(), "conf/java.policy")).getAbsolutePath()); + addSysProp(java, configuredSysProps, "java.security.auth.login.config", new File(getFileHandler() + .append(getConfiguration().getHome(), "conf/jaas.config")).getAbsolutePath()); + addSysProp(java, configuredSysProps, "jonas.classpath", ""); + addSysProp(java, configuredSysProps, "java.awt.headless", "true"); + 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"); + + } + + private void addSysProp(Java java, Map configuredSysProps, String name, String value) + { + if (configuredSysProps == null || !configuredSysProps.containsKey(name)) + { + java.addSysproperty(getAntUtils().createSysProperty(name, value)); + } + } + + /** + * Configuring the target java ant task to launch a jonas command + * + * @param java the target java ant task to setup + */ + protected void doAction(Java java) + { + setupSysProps(java); + + java.setClassname("org.objectweb.jonas.server.Bootstrap"); + + Path classpath = java.createClasspath(); + classpath.createPathElement().setLocation( + new File(getHome(), "lib/common/ow_jonas_bootstrap.jar")); + classpath.createPathElement().setLocation( + new File(getHome(), "lib/commons/jonas/jakarta-commons/commons-logging-api.jar")); + classpath.createPathElement().setLocation(new File(getConfiguration().getHome(), "conf")); + try + { + addToolsJarToClasspath(classpath); + + } + catch (IOException ex) + { + throw new ContainerException("IOException occured during java command line setup", ex); + } + + java.setDir(new File(getConfiguration().getHome())); + } + + /** + * {@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 " + getVersion("4.x"); + } + + /** + * @param defaultVersion default version to use if we cannot find out the exact Jonas version + * @return the Jonas version found + */ + protected String getVersion(String defaultVersion) + { + String version = this.version; + + if (version == null) + { + try + { + URLClassLoader classloader = + new URLClassLoader(new URL[] {new File(getHome(), + "/lib/common/ow_jonas_bootstrap.jar").toURL()}); + Class versionClass = + classloader.loadClass("org.objectweb.jonas_lib.version.Version"); + Field versionField = versionClass.getField("NUMBER"); + version = (String) versionField.get(null); + + getLogger().info("Found Jonas version [" + version + "]", + this.getClass().getName()); + } + catch (Exception e) + { + getLogger().debug( + "Failed to get Jonas version, Error = [" + e.getMessage() + + "]. Using generic version [" + defaultVersion + "]", + this.getClass().getName()); + version = defaultVersion; + } + } + this.version = version; + return version; + } + +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xMEJBRemoteDeployer.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xMEJBRemoteDeployer.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xMEJBRemoteDeployer.java (revision 0) @@ -0,0 +1,327 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas; + +import java.io.IOException; +import java.util.Hashtable; +import java.util.Set; + +import javax.management.Attribute; +import javax.management.AttributeList; +import javax.management.AttributeNotFoundException; +import javax.management.InstanceAlreadyExistsException; +import javax.management.InstanceNotFoundException; +import javax.management.IntrospectionException; +import javax.management.InvalidAttributeValueException; +import javax.management.ListenerNotFoundException; +import javax.management.MBeanException; +import javax.management.MBeanInfo; +import javax.management.MBeanRegistrationException; +import javax.management.MBeanServerConnection; +import javax.management.NotCompliantMBeanException; +import javax.management.NotificationFilter; +import javax.management.NotificationListener; +import javax.management.ObjectInstance; +import javax.management.ObjectName; +import javax.management.QueryExp; +import javax.management.ReflectionException; +import javax.management.j2ee.Management; +import javax.management.j2ee.ManagementHome; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.rmi.PortableRemoteObject; + +import org.codehaus.cargo.container.RemoteContainer; +import org.codehaus.cargo.container.configuration.RuntimeConfiguration; +import org.codehaus.cargo.container.jonas.internal.AbstractJonasJMXRemoteDeployer; +import org.codehaus.cargo.container.jonas.internal.MBeanServerConnectionFactory; +import org.codehaus.cargo.container.property.RemotePropertySet; + +/** + * Remote deployer that uses Managment EJB (MEJB) to deploy to Jonas. + */ +public class Jonas4xMEJBRemoteDeployer extends AbstractJonasJMXRemoteDeployer { + + public Jonas4xMEJBRemoteDeployer( RemoteContainer container ) { + super(container); + } + + public MBeanServerConnectionFactory getMBeanServerConnectionFactory() { + return new MEJBMBeanServerConnectionFactory(); + } + + /** + * MEJB MBeanServerConnection proxy + */ + private class MEJBMBeanServerConnectionFactory implements + MBeanServerConnectionFactory { + + private Context context; + + /** + * Default MEJB jndi path + */ + private static final String DEFAULT_JNDI_MEJB_PATH = "ejb/mgmt/MEJB"; + + /** + * Default Jonas initial context factory + */ + private static final String DEFAULT_JNDI_INITIAL_CTX_FACTORY = "org.objectweb.carol.jndi.spi.MultiOrbInitialContextFactory"; + + /** + * Default URI + */ + private static final String DEFAULT_URI = "rmi://localhost:1099"; + + /** + * {@inheritDoc} + * + * @see org.codehaus.cargo.container.jonas.internal.MBeanServerConnectionFactory#getServerConnection() + */ + public MBeanServerConnection getServerConnection( + RuntimeConfiguration configuration ) throws Exception { + + String username = configuration + .getPropertyValue(RemotePropertySet.USERNAME); + String password = configuration + .getPropertyValue(RemotePropertySet.PASSWORD); + String jndiUrl = configuration.getPropertyValue(RemotePropertySet.URI); + String mejbJndiPath = configuration + .getPropertyValue(JonasPropertySet.JONAS_MEJB_JNDI_PATH); + String initialContextFactory = configuration + .getPropertyValue(JonasPropertySet.JONAS_MEJB_JNDI_INIT_CTX_FACT); + + if ( jndiUrl == null || jndiUrl.trim().length() == 0 ) { + jndiUrl = DEFAULT_URI; + } + + if ( mejbJndiPath == null ) { + mejbJndiPath = DEFAULT_JNDI_MEJB_PATH; + } + + if ( initialContextFactory == null ) { + initialContextFactory = DEFAULT_JNDI_INITIAL_CTX_FACTORY; + } + + Hashtable props = new Hashtable(); + props.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory); + props.put(Context.PROVIDER_URL, jndiUrl); + + if ( username != null && username.trim().length() > 0 ) { + props.put(Context.SECURITY_PRINCIPAL, username); + } + + if ( password != null && password.trim().length() > 0 ) { + props.put(Context.SECURITY_CREDENTIALS, password); + } + + context = new InitialContext(props); + Object objref = context.lookup(mejbJndiPath); + ManagementHome home = (ManagementHome) PortableRemoteObject.narrow( + objref, javax.management.j2ee.ManagementHome.class); + + final Management mejb = home.create(); + + MBeanServerConnection proxy = new MBeanServerConnection() { + + public void addNotificationListener( ObjectName arg0, + NotificationListener arg1, NotificationFilter arg2, Object arg3 ) + throws InstanceNotFoundException, IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public void addNotificationListener( ObjectName arg0, ObjectName arg1, + NotificationFilter arg2, Object arg3 ) + throws InstanceNotFoundException, IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public ObjectInstance createMBean( String arg0, ObjectName arg1 ) + throws ReflectionException, InstanceAlreadyExistsException, + MBeanRegistrationException, MBeanException, + NotCompliantMBeanException, IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public ObjectInstance createMBean( String arg0, ObjectName arg1, + ObjectName arg2 ) throws ReflectionException, + InstanceAlreadyExistsException, MBeanRegistrationException, + MBeanException, NotCompliantMBeanException, + InstanceNotFoundException, IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public ObjectInstance createMBean( String arg0, ObjectName arg1, + Object[] arg2, String[] arg3 ) throws ReflectionException, + InstanceAlreadyExistsException, MBeanRegistrationException, + MBeanException, NotCompliantMBeanException, IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public ObjectInstance createMBean( String arg0, ObjectName arg1, + ObjectName arg2, Object[] arg3, String[] arg4 ) + throws ReflectionException, InstanceAlreadyExistsException, + MBeanRegistrationException, MBeanException, + NotCompliantMBeanException, InstanceNotFoundException, IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public Object getAttribute( ObjectName arg0, String arg1 ) + throws MBeanException, AttributeNotFoundException, + InstanceNotFoundException, ReflectionException, IOException { + return mejb.getAttribute(arg0, arg1); + } + + public AttributeList getAttributes( ObjectName arg0, String[] arg1 ) + throws InstanceNotFoundException, ReflectionException, IOException { + return mejb.getAttributes(arg0, arg1); + } + + public String getDefaultDomain() throws IOException { + return mejb.getDefaultDomain(); + } + + public String[] getDomains() throws IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public Integer getMBeanCount() throws IOException { + + return mejb.getMBeanCount(); + } + + public MBeanInfo getMBeanInfo( ObjectName arg0 ) + throws InstanceNotFoundException, IntrospectionException, + ReflectionException, IOException { + return mejb.getMBeanInfo(arg0); + } + + public ObjectInstance getObjectInstance( ObjectName arg0 ) + throws InstanceNotFoundException, IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public Object invoke( ObjectName arg0, String arg1, Object[] arg2, + String[] arg3 ) throws InstanceNotFoundException, MBeanException, + ReflectionException, IOException { + return mejb.invoke(arg0, arg1, arg2, arg3); + } + + public boolean isInstanceOf( ObjectName arg0, String arg1 ) + throws InstanceNotFoundException, IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public boolean isRegistered( ObjectName arg0 ) throws IOException { + return mejb.isRegistered(arg0); + } + + public Set queryMBeans( ObjectName arg0, QueryExp arg1 ) + throws IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public Set queryNames( ObjectName arg0, QueryExp arg1 ) + throws IOException { + return mejb.queryNames(arg0, arg1); + } + + public void removeNotificationListener( ObjectName arg0, ObjectName arg1 ) + throws InstanceNotFoundException, ListenerNotFoundException, + IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public void removeNotificationListener( ObjectName arg0, + NotificationListener arg1 ) throws InstanceNotFoundException, + ListenerNotFoundException, IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public void removeNotificationListener( ObjectName arg0, + ObjectName arg1, NotificationFilter arg2, Object arg3 ) + throws InstanceNotFoundException, ListenerNotFoundException, + IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public void removeNotificationListener( ObjectName arg0, + NotificationListener arg1, NotificationFilter arg2, Object arg3 ) + throws InstanceNotFoundException, ListenerNotFoundException, + IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + public void setAttribute( ObjectName arg0, Attribute arg1 ) + throws InstanceNotFoundException, AttributeNotFoundException, + InvalidAttributeValueException, MBeanException, + ReflectionException, IOException { + mejb.setAttribute(arg0, arg1); + } + + public AttributeList setAttributes( ObjectName arg0, AttributeList arg1 ) + throws InstanceNotFoundException, ReflectionException, IOException { + return mejb.setAttributes(arg0, arg1); + } + + public void unregisterMBean( ObjectName arg0 ) + throws InstanceNotFoundException, MBeanRegistrationException, + IOException { + throw new UnsupportedOperationException( + "MEJB proxy does not support this method call"); + } + + }; + + return proxy; + } + + /** + * {@inheritDoc} + * + * @see org.codehaus.cargo.container.jonas.internal.MBeanServerConnectionFactory#destroy() + */ + public void destroy() { + if ( context != null ) { + try { + context.close(); + } catch ( Exception e ) { + } + context = null; + } + + } + } + +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalDeployer.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalDeployer.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xInstalledLocalDeployer.java (revision 0) @@ -0,0 +1,227 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +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.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 to Jonas. + */ +public class Jonas4xInstalledLocalDeployer extends AbstractCopyingInstalledLocalDeployer +{ + + /** + * Jonas admin used for hot deployment + */ + private JonasAdmin admin = null; + + /** + * {@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#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"); + } + } + } + + private void deploy(String targetDir, Deployable deployable, String fileName, + CopyingDeployable copying) throws CargoException + { + boolean isRunning = false; + + isRunning = admin.isServerRunning(); + if (!isRunning) + { + targetDir += "/autoload"; + } + copying.copyDeployable(targetDir, 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 webapps 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(); + } + + private interface CopyingDeployable + { + void copyDeployable(String deployableDir, Deployable deployable); + } + + private class GenericCopyingDeployable implements CopyingDeployable + { + + public void copyDeployable(String deployableDir, Deployable deployable) + { + getFileHandler().copyFile( + deployable.getFile(), + getFileHandler().append(deployableDir, + getFileHandler().getName(deployable.getFile()))); + } + + } + +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xRemoteContainer.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xRemoteContainer.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xRemoteContainer.java (revision 0) @@ -0,0 +1,72 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +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 + */ +public class Jonas4xRemoteContainer extends AbstractRemoteContainer +{ + + /** + * Unique container id. + */ + public static final String ID = "jonas4x"; + + private ContainerCapability cabability = new JonasContainerCapability(); + + public Jonas4xRemoteContainer(RuntimeConfiguration configuration) + { + super(configuration); + } + + /** + * {@inheritDoc} + * @see org.codehaus.cargo.container.Container#getCapability() + */ + public ContainerCapability getCapability() + { + return cabability; + } + + /** + * {@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"; + } + +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasRuntimeConfiguration.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasRuntimeConfiguration.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasRuntimeConfiguration.java (revision 0) @@ -0,0 +1,54 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +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. + */ +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"; + } + +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasStandaloneLocalConfiguration.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasStandaloneLocalConfiguration.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasStandaloneLocalConfiguration.java (revision 0) @@ -0,0 +1,373 @@ +/* + * ======================================================================== + * + * Copyright 2005-2006 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. + * + * ======================================================================== + */ +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.JonasStandaloneLocalConfigurationCapability; +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. + */ +public class JonasStandaloneLocalConfiguration extends AbstractStandaloneLocalConfiguration +{ + + protected final static String TOKEN_FILTER_KEY_USERS_ROLE = "cargo.servlet.users.role"; + + protected final static String TOKEN_FILTER_KEY_USERS_USER = "cargo.servlet.users.user"; + + public final static String JETTY_WEB_CONTAINER_CLASS_NAME = + "org.objectweb.jonas.web.jetty50.JettyJWebContainerServiceImpl"; + + public final static String CATALINA_WEB_CONTAINER_CLASS_NAME = + "org.objectweb.jonas.web.wrapper.catalina55.CatalinaJWebContainerServiceWrapper"; + + /** + * Jonas installed container + */ + private InstalledLocalContainer installedContainer; + + /** + * Jonas container capability. + */ + private static ConfigurationCapability capability = + new JonasStandaloneLocalConfigurationCapability(); + + /** + * {@inheritDoc} + * + * @see AbstractStandaloneLocalConfiguration#AbstractStandaloneLocalConfiguration(String) + */ + public JonasStandaloneLocalConfiguration(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 filename is one of cargo resources file. + * + * @param cargoFiles list of cargo resources files + * @param filename filename of the file + * @return true if filename 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; + + } + + protected String getWebContainerClassName(InstalledLocalContainer installedContainer) + throws CargoException + { + + String providedSetting = getPropertyValue(JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME); + if (providedSetting != null && providedSetting.trim().length() > 0) + { + return providedSetting; + } + + if (isWebContainerInstalled("lib/jetty/lib", installedContainer)) + { + return JETTY_WEB_CONTAINER_CLASS_NAME; + } + else if (isWebContainerInstalled("lib/catalina/server/lib", installedContainer)) + { + return CATALINA_WEB_CONTAINER_CLASS_NAME; + } + + 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"); + + } + + 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; + } + + protected void createUserFilterChain(FilterChain filterChain) + { + StringBuffer rolesBuffer = new StringBuffer(""); + StringBuffer usersBuffer = new StringBuffer(""); + 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("\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"; + } +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasExistingLocalConfiguration.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasExistingLocalConfiguration.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasExistingLocalConfiguration.java (revision 0) @@ -0,0 +1,118 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +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. + */ +public class JonasExistingLocalConfiguration extends AbstractExistingLocalConfiguration +{ + + /** + * Capability of the Jonas existing configuration. + */ + private static ConfigurationCapability capability = + new JonasExistingLocalConfigurationCapability(); + + /** + * {@inheritDoc} + * + * @see AbstractExistingLocalConfiguration#AbstractExistingLocalConfiguration(String) + */ + public JonasExistingLocalConfiguration(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"; + } + + 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"); + } + } + +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasPropertySet.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasPropertySet.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/JonasPropertySet.java (revision 0) @@ -0,0 +1,72 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas; + +/** + * Jonas specific properties. + */ +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 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 ot 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, 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"; +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasContainerCapability.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasContainerCapability.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasContainerCapability.java (revision 0) @@ -0,0 +1,39 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas.internal; + +import org.codehaus.cargo.container.deployable.DeployableType; +import org.codehaus.cargo.container.internal.J2EEContainerCapability; + +/** + * Capabilities of the Jonas container. + */ +public class JonasContainerCapability extends J2EEContainerCapability +{ + /** + * Add support for EJB deployable types. + * {@inheritDoc} + * @see J2EEContainerCapability#supportsDeployableType(DeployableType) + */ + public boolean supportsDeployableType(DeployableType type) + { + return (type == DeployableType.EJB) || super.supportsDeployableType(type); + } +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/MBeanServerConnectionFactory.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/MBeanServerConnectionFactory.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/MBeanServerConnectionFactory.java (revision 0) @@ -0,0 +1,46 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas.internal; + +import javax.management.MBeanServerConnection; + +import org.codehaus.cargo.container.configuration.RuntimeConfiguration; + +/** + * Factory to create a remote JMX mbean server connection + * + */ +public interface MBeanServerConnectionFactory +{ + + /** + * Create a new mbean server connection + * @param + * @return a MBeanServerConnection + * @throws Exception if the connection cannot be done + */ + MBeanServerConnection getServerConnection( RuntimeConfiguration configuration ) throws Exception; + + /** + * Destroys the factory and any underlying IO sockets + */ + void destroy(); + +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasAdmin.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasAdmin.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasAdmin.java (revision 0) @@ -0,0 +1,49 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas.internal; + +/** + * Jonas admin command line capabilities interface + */ +public interface JonasAdmin +{ + /** + * Look if a local server instance is running + * + * @return true if a local server instance is running + */ + boolean isServerRunning(); + + /** + * Undeploys the given bean name + * + * @param beanFileName the bean file name + * @return true if the bean has been correctly undeployed + */ + boolean unDeploy(String beanFileName); + + /** + * deploys the given bean name + * + * @param beanFileName the bean file name + * @return true if the bean has been correctly undeployed + */ + boolean deploy(String beanFileName); +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasRuntimeConfigurationCapability.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasRuntimeConfigurationCapability.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasRuntimeConfigurationCapability.java (revision 0) @@ -0,0 +1,56 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas.internal; + +import java.util.Map; + +import org.codehaus.cargo.container.jonas.JonasPropertySet; +import org.codehaus.cargo.container.property.RemotePropertySet; +import org.codehaus.cargo.container.spi.configuration.AbstractRuntimeConfigurationCapability; + +/** + * Capabilities of Jonas {@link org.codehaus.cargo.container.jonas.JonasRuntimeConfiguration} + * configuration. + */ +public class JonasRuntimeConfigurationCapability extends AbstractRuntimeConfigurationCapability +{ + + /** + * Initialize the configuration-specific supports Map. + */ + public JonasRuntimeConfigurationCapability() + { + super(); + this.defaultSupportsMap.put(RemotePropertySet.URI, Boolean.TRUE); + this.defaultSupportsMap.put(JonasPropertySet.JONAS_DEPLOYABLE_IDENTIFIER, Boolean.TRUE); + this.defaultSupportsMap.put(JonasPropertySet.JONAS_SERVER_NAME, Boolean.TRUE); + this.defaultSupportsMap.put(JonasPropertySet.JONAS_DOMAIN_NAME, Boolean.TRUE); + } + + /** + * {@inheritDoc} + * + * @see org.codehaus.cargo.container.spi.configuration.AbstractStandaloneLocalConfigurationCapability#getPropertySupportMap() + */ + protected Map getPropertySupportMap() + { + return this.defaultSupportsMap; + } +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasStandaloneLocalConfigurationCapability.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasStandaloneLocalConfigurationCapability.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasStandaloneLocalConfigurationCapability.java (revision 0) @@ -0,0 +1,59 @@ +/* + * ======================================================================== + * + * Copyright 2005-2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas.internal; + +import java.util.Map; + +import org.codehaus.cargo.container.jonas.JonasPropertySet; +import org.codehaus.cargo.container.property.GeneralPropertySet; +import org.codehaus.cargo.container.spi.configuration.AbstractStandaloneLocalConfigurationCapability; + +/** + * Capabilities of the Jonas + * {@link org.codehaus.cargo.container.jonas.JonasStandaloneLocalConfiguration} configuration. + */ +public class JonasStandaloneLocalConfigurationCapability extends + AbstractStandaloneLocalConfigurationCapability +{ + + /** + * Initialize Jonas-specific configuration Map. + */ + public JonasStandaloneLocalConfigurationCapability() + { + super(); + + this.defaultSupportsMap.put(GeneralPropertySet.PROTOCOL, Boolean.FALSE); + this.defaultSupportsMap.put(GeneralPropertySet.RMI_PORT, Boolean.TRUE); + this.defaultSupportsMap.put(JonasPropertySet.JONAS_REALM_NAME, Boolean.TRUE); + this.defaultSupportsMap.put(JonasPropertySet.JONAS_WEBCONTAINER_CLASS_NAME, Boolean.TRUE); + this.defaultSupportsMap.put(JonasPropertySet.JONAS_AVAILABLES_DATASOURCES, Boolean.TRUE); + } + + /** + * {@inheritDoc} + * + * @see org.codehaus.cargo.container.spi.configuration.AbstractStandaloneLocalConfigurationCapability#getPropertySupportMap() + */ + protected Map getPropertySupportMap() + { + return this.defaultSupportsMap; + } +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasExistingLocalConfigurationCapability.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasExistingLocalConfigurationCapability.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/JonasExistingLocalConfigurationCapability.java (revision 0) @@ -0,0 +1,52 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas.internal; + +import org.codehaus.cargo.container.spi.configuration.AbstractExistingLocalConfigurationCapability; +import org.codehaus.cargo.container.jonas.JonasPropertySet; +import org.codehaus.cargo.container.property.GeneralPropertySet; +import java.util.Map; + +/** + * Capabilities of the Jonas {@link JonasExistingLocalConfigurationCapability} configuration. + */ +public class JonasExistingLocalConfigurationCapability + extends AbstractExistingLocalConfigurationCapability +{ + + /** + * Initialize the configuration-specific supports Map. + */ + public JonasExistingLocalConfigurationCapability() + { + super(); + this.defaultSupportsMap.put(GeneralPropertySet.JVMARGS, Boolean.TRUE); + this.defaultSupportsMap.put(JonasPropertySet.JONAS_SERVER_NAME, Boolean.TRUE); + } + + /** + * {@inheritDoc} + * @see org.codehaus.cargo.container.spi.configuration.AbstractStandaloneLocalConfigurationCapability#getPropertySupportMap() + */ + protected Map getPropertySupportMap() + { + return this.defaultSupportsMap; + } +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/AbstractJonasJMXRemoteDeployer.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/AbstractJonasJMXRemoteDeployer.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/internal/AbstractJonasJMXRemoteDeployer.java (revision 0) @@ -0,0 +1,369 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas.internal; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + +import javax.management.InstanceNotFoundException; +import javax.management.MBeanException; +import javax.management.MBeanServerConnection; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; +import javax.management.ReflectionException; + +import org.codehaus.cargo.container.ContainerException; +import org.codehaus.cargo.container.RemoteContainer; +import org.codehaus.cargo.container.configuration.RuntimeConfiguration; +import org.codehaus.cargo.container.deployable.Deployable; +import org.codehaus.cargo.container.deployable.DeployableType; +import org.codehaus.cargo.container.deployable.WAR; +import org.codehaus.cargo.container.jonas.JonasPropertySet; +import org.codehaus.cargo.container.spi.deployer.AbstractRemoteDeployer; +import org.codehaus.cargo.util.DefaultFileHandler; +import org.codehaus.cargo.util.FileHandler; + +/** + * Abstract base class for jonas rmeote deployment trought JMX J2EE admin interface + */ +public abstract class AbstractJonasJMXRemoteDeployer extends AbstractRemoteDeployer +{ + + /** + * The default jonas target server name to be used for deployment + */ + private static final String DEFAULT_JONAS_SERVER_NAME = "jonas"; + + /** + * The default jonas target domain name to be used for deployment + */ + private static final String DEFAULT_JONAS_DOMAIN_NAME = "jonas"; + + private RuntimeConfiguration configuration = null; + + public AbstractJonasJMXRemoteDeployer(RemoteContainer container) + { + configuration = container.getConfiguration(); + + } + + public abstract MBeanServerConnectionFactory getMBeanServerConnectionFactory(); + + /** + * {@inheritDoc} + * + * @see org.codehaus.cargo.container.deployer.Deployer#deploy(Deployable) + */ + public void deploy(Deployable deployable) + { + if (deployable.getType() == DeployableType.WAR) + { + WAR war = (WAR) deployable; + if (war.isExpandedWar()) + { + getLogger().warn("Remote deployer does not supports expanded WAR deployment", + this.getClass().getName()); + return; + } + } + RemoteDeployerConfig config = getConfig(); + MBeanServerConnectionFactory factory = null; + try + { + + factory = getMBeanServerConnectionFactory(); + MBeanServerConnection mbsc = factory.getServerConnection(configuration); + + ObjectName serverMBeanName = getServerMBeanName(config.domainName, config.serverName); + + String filePathOnServer = + uploadDeployableOnServer(deployable, mbsc, serverMBeanName, config); + + Boolean deployed = isDeployed(mbsc, serverMBeanName, deployable, config); + if (deployed.booleanValue()) + { + return; + } + String operationName = null; + if (deployable.getType() == DeployableType.WAR) + { + operationName = "deployWar"; + } + else if (deployable.getType() == DeployableType.EAR) + { + operationName = "deployEar"; + } + else if (deployable.getType() == DeployableType.EJB) + { + operationName = "deployJar"; + } + getLogger().debug("Calling deployment operation " + operationName + " on server", + getClass().getName()); + mbsc.invoke(serverMBeanName, operationName, new Object[] {filePathOnServer}, + new String[] {String.class.getName()}); + } + catch (Exception ex) + { + throw new ContainerException("Deployment error", ex); + } + finally + { + if (factory != null) + { + factory.destroy(); + } + } + } + + /** + * {@inheritDoc} + * + * @see org.codehaus.cargo.container.deployer.Deployer#redeploy(Deployable) + */ + public void redeploy(Deployable deployable) + { + undeploy(deployable); + deploy(deployable); + } + + /** + * {@inheritDoc} + * + * @see org.codehaus.cargo.container.deployer.Deployer#undeploy(Deployable) + */ + public void undeploy(Deployable deployable) + { + RemoteDeployerConfig config = getConfig(); + MBeanServerConnectionFactory factory = null; + try + { + factory = getMBeanServerConnectionFactory(); + MBeanServerConnection mbsc = factory.getServerConnection(configuration); + + ObjectName serverMBeanName = getServerMBeanName(config.domainName, config.serverName); + + Boolean deployed = isDeployed(mbsc, serverMBeanName, deployable, config); + if (!deployed.booleanValue()) + { + getLogger().warn("Deployable " + deployable + " is not deployed", + this.getClass().getName()); + return; + } + + String operationName = null; + if (deployable.getType() == DeployableType.WAR) + { + operationName = "unDeployWar"; + } + else if (deployable.getType() == DeployableType.EAR) + { + operationName = "unDeployEar"; + } + else if (deployable.getType() == DeployableType.EJB) + { + operationName = "unDeployJar"; + } + String remoteFileName = getRemoteFileName(deployable, config.deployableIdentifier); + getLogger().debug("Calling undeployment operation " + operationName + " on server", + getClass().getName()); + mbsc.invoke(serverMBeanName, operationName, new Object[] {remoteFileName}, + new String[] {String.class.getName()}); + + // misc configuration property to avoid to remove the file on the server side. + // used to avoid a bug with jonas removeModuleFile remote method call + // who is removing a wrong file during the + // org.codehaus.cargo.sample.java.RemoteDeploymentTest + // unit test call + String skipRemoval = + this.configuration + .getPropertyValue("cargo.jonas.remote.deployer.skip.module.removal"); + if (skipRemoval == null || !Boolean.valueOf(skipRemoval).booleanValue()) + { + Boolean removed = + (Boolean) mbsc.invoke(serverMBeanName, "removeModuleFile", + new Object[] {remoteFileName}, new String[] {String.class.getName()}); + if (!removed.booleanValue()) + { + getLogger().warn("Unable to remove remote file " + remoteFileName, + this.getClass().getName()); + } + } + } + catch (Exception ex) + { + throw new ContainerException("Undeployment error", ex); + } + finally + { + if (factory != null) + { + factory.destroy(); + } + } + } + + protected String getRemoteFileName(Deployable deployable, String deployableIdentifier) + { + if (deployableIdentifier != null && deployableIdentifier.trim().length() > 0) + { + int identifierExtIndex = deployableIdentifier.lastIndexOf("."); + if (identifierExtIndex != -1) + { + deployableIdentifier = deployableIdentifier.substring(0, identifierExtIndex); + } + + if (deployable.getType() == DeployableType.WAR) + { + deployableIdentifier += ".war"; + } + else if (deployable.getType() == DeployableType.EAR) + { + deployableIdentifier += ".ear"; + } + else if (deployable.getType() == DeployableType.EJB) + { + deployableIdentifier += ".jar"; + } + return deployableIdentifier; + } + + 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"; + } + else + { + remoteFilePath = war.getContext() + ".war"; + } + } + return remoteFilePath; + } + + private Boolean isDeployed(MBeanServerConnection mbsc, ObjectName serverMBeanName, + Deployable deployable, RemoteDeployerConfig config) throws InstanceNotFoundException, + MBeanException, ReflectionException, IOException + { + + String operationName = null; + if (deployable.getType() == DeployableType.WAR) + { + operationName = "isWarDeployed"; + } + else if (deployable.getType() == DeployableType.EAR) + { + operationName = "isEarDeployed"; + } + else if (deployable.getType() == DeployableType.EJB) + { + operationName = "isJarDeployed"; + } + getLogger().debug("Calling operation " + operationName + " on server", + getClass().getName()); + + String remoteFilePath = getRemoteFileName(deployable, config.deployableIdentifier); + return (Boolean) mbsc.invoke(serverMBeanName, operationName, + new Object[] {remoteFilePath}, new String[] {String.class.getName()}); + } + + protected ObjectName getServerMBeanName(String domainName, String serverName) + throws MalformedObjectNameException + { + if (domainName == null || domainName.trim().length() == 0) + { + throw new MalformedObjectNameException("Empty domain name provided"); + } + + if (serverName == null || serverName.trim().length() == 0) + { + throw new MalformedObjectNameException("Empty server name provided"); + } + + return new ObjectName(domainName + ":j2eeType=J2EEServer,name=" + serverName); + } + + private RemoteDeployerConfig getConfig() + { + RemoteDeployerConfig config = new RemoteDeployerConfig(); + config.deployableIdentifier = + this.configuration.getPropertyValue(JonasPropertySet.JONAS_DEPLOYABLE_IDENTIFIER); + config.serverName = + this.configuration.getPropertyValue(JonasPropertySet.JONAS_SERVER_NAME); + config.domainName = + this.configuration.getPropertyValue(JonasPropertySet.JONAS_DOMAIN_NAME); + + if (config.serverName == null) + { + config.serverName = DEFAULT_JONAS_SERVER_NAME; + } + + if (config.domainName == null) + { + config.domainName = DEFAULT_JONAS_DOMAIN_NAME; + } + + return config; + } + + private String uploadDeployableOnServer(Deployable deployable, MBeanServerConnection mbsc, + ObjectName serverMBeanName, RemoteDeployerConfig config) throws FileNotFoundException, + InstanceNotFoundException, MBeanException, ReflectionException, IOException + { + File fle = new File(deployable.getFile()); + FileHandler fileHandler = new DefaultFileHandler(); + FileInputStream in = new FileInputStream(fle); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + fileHandler.copy(in, out); + in.close(); + getLogger().debug("Uploading file on server", this.getClass().getName()); + String remoteFileName = getRemoteFileName(deployable, config.deployableIdentifier); + String filePathOnServer = + (String) mbsc.invoke(serverMBeanName, "sendFile", new Object[] {out.toByteArray(), + remoteFileName, Boolean.TRUE}, new String[] {byte[].class.getName(), + String.class.getName(), boolean.class.getName()}); + + getLogger().debug("File uploaded on server : " + filePathOnServer, + this.getClass().getName()); + if (filePathOnServer == null || filePathOnServer.trim().length() == 0) + { + throw new ContainerException("Server returned a null uploaded file path"); + } + return filePathOnServer; + } + + private class RemoteDeployerConfig + { + + String deployableIdentifier; + + String serverName; + + String domainName; + + } +} Index: containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xJsr160RemoteDeployer.java =================================================================== --- containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xJsr160RemoteDeployer.java (revision 0) +++ containers/jonas/src/main/java/org/codehaus/cargo/container/jonas/Jonas4xJsr160RemoteDeployer.java (revision 0) @@ -0,0 +1,130 @@ +/* + * ======================================================================== + * + * Copyright 2006 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. + * + * ======================================================================== + */ +package org.codehaus.cargo.container.jonas; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.management.MBeanServerConnection; +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXServiceURL; + +import org.codehaus.cargo.container.RemoteContainer; +import org.codehaus.cargo.container.configuration.RuntimeConfiguration; +import org.codehaus.cargo.container.jonas.internal.AbstractJonasJMXRemoteDeployer; +import org.codehaus.cargo.container.jonas.internal.MBeanServerConnectionFactory; +import org.codehaus.cargo.container.property.RemotePropertySet; + +/** + * Remote deployer that uses JMX Remoting (JSR 160) to deploy to Jonas. + */ +public class Jonas4xJsr160RemoteDeployer extends AbstractJonasJMXRemoteDeployer +{ + + public Jonas4xJsr160RemoteDeployer(RemoteContainer container) + { + super(container); + } + + public MBeanServerConnectionFactory getMBeanServerConnectionFactory() + { + return new JMXRemotingMBeanServerConnectionFactory(); + } + + /** + * JMX remoting (JSR 160) implementation to get a remote MBeanServerConnection + */ + private class JMXRemotingMBeanServerConnectionFactory implements MBeanServerConnectionFactory + { + + /** + * The default JMX remote URL to use with Jonas server. + */ + private static final String DEFAULT_URI = + "service:jmx:rmi://localhost/jndi/rmi://localhost:1099/jrmpconnector_jonas"; + + private JMXConnector connector; + + /** + * {@inheritDoc} + * + * @see org.codehaus.cargo.container.jonas.internal.MBeanServerConnectionFactory#getServerConnection() + */ + public MBeanServerConnection getServerConnection(RuntimeConfiguration configuration) + throws IOException + { + + String username = configuration.getPropertyValue(RemotePropertySet.USERNAME); + String password = configuration.getPropertyValue(RemotePropertySet.PASSWORD); + String jmxRemoteURL = configuration.getPropertyValue(RemotePropertySet.URI); + + if (jmxRemoteURL == null || jmxRemoteURL.trim().length() == 0) + { + jmxRemoteURL = DEFAULT_URI; + } + + Map environment = new HashMap(); + + if (username != null && username.trim().length() > 0 && password != null + && password.trim().length() > 0) + { + Object credentials = new Object[] {username, password}; + environment.put(JMXConnector.CREDENTIALS, credentials); + } + + if (!environment.containsKey(JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER)) + { + environment.put(JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER, this + .getClass().getClassLoader()); + } + + JMXServiceURL address = new JMXServiceURL(jmxRemoteURL); + connector = JMXConnectorFactory.connect(address, environment); + + MBeanServerConnection mbsc = connector.getMBeanServerConnection(); + + return mbsc; + } + + /** + * {@inheritDoc} + * + * @see org.codehaus.cargo.container.jonas.internal.MBeanServerConnectionFactory#destroy() + */ + public void destroy() + { + if (connector != null) + { + try + { + connector.close(); + } + catch (IOException e) + { + } + connector = null; + } + + } + } + +} Index: containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jaas.config =================================================================== --- containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jaas.config (revision 0) +++ containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jaas.config (revision 0) @@ -0,0 +1,108 @@ +jaasclient { + // Login Module to use for the example jaasclient. + + //First, use a LoginModule for the authentication + // Use the resource @cargo.jonas.realm.name@ + + //By default it uses the server named 'jonas' to authenticate + // to specify a different server name, use attribute 'serverName="myJonas"' + org.objectweb.jonas.security.auth.spi.JResourceLoginModule required + resourceName="@cargo.jonas.realm.name@" + ; + + // The previous JResourceLoginModule was renamed to JDirectResourceLoginModule + // You need to activate the registration of resources in jonas.properties file + + + // Use the login module to propagate security to the JOnAS server + // globalCtx is set to true in order to set the security context + // for all the threads of the client container instead of only + // on the current thread. + // Useful with multithread applications (like Swing Clients) + org.objectweb.jonas.security.auth.spi.ClientLoginModule required + globalCtx="true" + ; +}; + + +jetty { + // Login Module to use for the web container Jetty + + + // Uncomment this if you want to check that the certificates + // were not revocated by the Certification Authority + //org.objectweb.jonas.security.auth.spi.CRLLoginModule required + //CRLsResourceName="Directory" + //CRLsDirectoryName="/home/jonas/CRLs" + //; + + + //LoginModule for the authentication + //add parameter certCallback="true" if you want use certificate callback + // Use the resource @cargo.jonas.realm.name@ + //By default it uses the server named 'jonas' to authenticate + // to specify a different server name, use attribute 'serverName="myJonas"' + org.objectweb.jonas.security.auth.spi.JResourceLoginModule required + resourceName="@cargo.jonas.realm.name@" + ; +}; + +tomcat { + // Login Module to use for the web container Tomcat + + + // Uncomment this if you want to check that the certificates + // were not revocated by the Certification Authority + //org.objectweb.jonas.security.auth.spi.CRLLoginModule required + //CRLsResourceName="Directory" + //CRLsDirectoryName="/home/jonas/CRLs" + //; + + + //LoginModule for the authentication + //add parameter certCallback="true" if you want use certificate callback + // Use the resource @cargo.jonas.realm.name@ + //By default it uses the server named 'jonas' to authenticate + // to specify a different server name, use attribute 'serverName="myJonas"' + org.objectweb.jonas.security.auth.spi.JResourceLoginModule required + resourceName="@cargo.jonas.realm.name@" + ; +}; + +test { + // Login Module to use for the a client without setting for all threads the identity + + //LoginModule for the authentication + //add parameter certCallback="true" if you want use certificate callback + // Use the resource @cargo.jonas.realm.name@ + //By default it uses the server named 'jonas' to authenticate + // to specify a different server name, use attribute 'serverName="myJonas"' + org.objectweb.jonas.security.auth.spi.JResourceLoginModule required + resourceName="@cargo.jonas.realm.name@" + ; + + //Security propagation + org.objectweb.jonas.security.auth.spi.ClientLoginModule required; +}; + +ask_remote { + // Ask the remote side + org.objectweb.jonas.security.auth.spi.RemoteLoginModule required + entryName="remote" providerURLs="rmi://localhost:1099, rmi://localhost:1979" serverName="jonas" serverNames="jonas,j1,j2,j3" + ; + +}; + + +remote { + // Do authentication and sign the Subject. + org.objectweb.jonas.security.auth.spi.JResourceLoginModule required + resourceName="@cargo.jonas.realm.name@" + ; + + // Specify the keystore to use with the alias and the associated password used to get the private key. + org.objectweb.jonas.security.auth.spi.SignLoginModule required + keystoreFile="/tmp/keystore" keystorePass="keystorepass" keyPass="keypass" alias="OW" + ; + +}; Index: containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jetty5.xml =================================================================== --- containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jetty5.xml (revision 0) +++ containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jetty5.xml (revision 0) @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + @cargo.hostname@ + 10 + 100 + 30000 + 5000 + 9043 + 9043 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.mortbay.jetty.servlet.XMLConfiguration + org.mortbay.jetty.servlet.JettyWebConfiguration + org.mortbay.jetty.servlet.TagLibConfiguration + org.objectweb.jonas.web.jetty50.JSR77Configuration + + + + + + + + + + + + + + + + + + Jonas Server Configuration Form-Based Authentication Area + @cargo.jonas.realm.name@ + + + + + + + + + + + /logs/yyyy_mm_dd.request.log + 90 + true + false + false + GMT + + + + + + + 2000 + true + + + + + + + + + + + Index: containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/server.xml =================================================================== --- containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/server.xml (revision 0) +++ containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/server.xml (revision 0) @@ -0,0 +1,349 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jonas.properties =================================================================== --- containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jonas.properties (revision 0) +++ containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jonas.properties (revision 0) @@ -0,0 +1,414 @@ +# --------------------------------------------------------------------------- +# JOnAS: Java(TM) Open Application Server +# Copyright (C) 1999-2005 Bull S.A. +# Contact: jonas-team@objectweb.org +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +# +# +# --------------------------------------------------------------------------- +# $Id: jonas.properties 9905 2007-01-05 12:34:30Z benoitf $ +# --------------------------------------------------------------------------- + + +###################### JOnAS Server configuration +# The current file is in the /conf directory. It can be copyed and +# customized in JONAS_BASE/conf directory +###################### + +# Enable the Security context propagation (for jrmp) +# In case of Jeremie, this has no effect : You should modify jonathan.xml +jonas.security.propagation true + +# Enable the Security manager +# default value is true (if not set) +# Setting this to false implies a colocated registry and setting in carol.properties: +# carol.jvm.rmi.local.registry=true +jonas.security.manager true + +# Enable csiv2 +jonas.csiv2.propagation true + +# Enable the Transaction context propagation +jonas.transaction.propagation true + +# Set the name of log configuration file +jonas.log.configfile trace + +# Set the list of the services launched in the JOnAS Server. +# Possible services are: registry,jmx,thread,security,jtm,db,mail,dbm,resource,jms,ejb,ws,web,ear,ha,discovery +# registry,jmx,jtm,ejb are mandatory +# (registry and jmx are automatically started even if not present in the list) +# Order in the list is important (see 'Configuring JOnAS services' in JOnAS documentation) +# +jonas.services registry,jmx,jtm,db,dbm,security,resource,ejb,ws,web,ear + +# +###################### JOnAS Registry service configuration +# +# Set the name of the implementation class of the Registry service +jonas.service.registry.class org.objectweb.jonas.registry.RegistryServiceImpl + +# Set the Registry launching mode +# If set to 'automatic', the registry is launched in the same JVM as Application Server, +# if it's not already started. +# If set to 'collocated', the registry is launched in the same JVM as Application Server +# If set to 'remote', the registry has to be launched before in a separate JVM +jonas.service.registry.mode collocated + +# +###################### JOnAS JMX service configuration +# +# Set the name of the implementation class of the jmx service +jonas.service.jmx.class org.objectweb.jonas.jmx.JmxServiceImpl + + +# +###################### JOnAS EJB Container service configuration +# +# Set the name of the implementation class of the ejb service +jonas.service.ejb.class org.objectweb.jonas.container.EJBServiceImpl + +# Set the list of directories that contains ejbjars that must be deployed by +# the JOnAS Server at launch time. +# Here should be given a coma-separated list of directories. +# If the directory has a relative path, this path is relative from where the +# Application Server is launched. +# If the directory is not found it will be searched in JONAS_BASE/ejbjars/ +# directory. +jonas.service.ejb.autoloaddir autoload + +# Set the list of ejbjars that must be deployed by the JOnAS Server at launch time. +# Here should be given a coma-separated list of ejb-jar files names or standard XML deployment +# descriptors files names. +# If the file name has a relative path, this path is relative from where the +# Application Server is launched. +jonas.service.ejb.descriptors + +# Set the XML deployment descriptors parsing mode (with or without validation) +jonas.service.ejb.parsingwithvalidation true + +# Set the size of the worker thread pool +jonas.service.ejb.minworkthreads 3 + +# Set the maximun size of the worker thread pool +jonas.service.ejb.maxworkthreads 80 + +# Set the max # of seconds that a thread will wait for work +# This is used to shrink the worker thread pool back to minimum +jonas.service.ejb.threadwaittimeout 60 + + +# If enabled, the GenIC tool will be called if : +# - JOnAS version of the ejb-jar is not the same version than the running JOnAS instance +# - Stubs/Skels stored in the ejb-jar are not the same than the JOnAS current protocols. +# By default, this is enabled +jonas.service.ejb.auto-genic true + +# Arguments for the auto GenIC +#jonas.service.ejb.auto-genic.args.0 -invokecmd +#jonas.service.ejb.auto-genic.args.1 -verbose + + +# +###################### JOnAS Web container service configuration +# +# Set the name of the implementation class of the web container service. +jonas.service.web.class @cargo.jonas.webcontainer.class.name@ + +# Set the list of directories that contains wars that must be deployed by +# the JOnAS Server at launch time. +# Here should be given a coma-separated list of directories. +# If the directory has a relative path, this path is relative from where the +# Application Server is launched. +# If the directory is not found it will be searched in JONAS_BASE/webapps/ +# directory. +jonas.service.web.autoloaddir autoload + +# Set the list of wars that must be depoyed by the JOnAS Server at launch time. +# Here should be given a coma-separated list of war files names. +# If the file name has a relative path, this path is relative from where the +# Application Server is launched. +jonas.service.web.descriptors + +# Set the XML deployment descriptors parsing mode for the WEB container +# service (with or without validation). +jonas.service.web.parsingwithvalidation true + +###################### JOnAS WebServices service configuration +# +# Set the name of the implementation class of the WebServices service. +jonas.service.ws.class org.objectweb.jonas.ws.axis.AxisWSServiceImpl + +# Set the JServiceFactory to use +jonas.service.ws.factory.class org.objectweb.jonas.ws.axis.JAxisServiceFactory + +# Set the XML deployment descriptors parsing mode for the WebServices +# service (with or without validation). +jonas.service.ws.parsingwithvalidation true + +# Set the WSDL Handler list for WSDL publication +# A minimum of 1 WSDLHandler is required ! +# This property is set with a coma-separated list of WSDLHandler properties +# file names (without the '.properties' suffix). +# Ex: file1,uddi (while the properties file names are +# file1.properties and uddi.properties) +jonas.service.ws.wsdlhandlers file1 + +# Set the Generator to use with wsgen +jonas.service.ws.wsgen.generator.factory org.objectweb.jonas_ws.wsgen.generator.ews.EWSGeneratorFactory + +# Set the prefix that will be used to compute URL endpoints for web services +#jonas.service.ws.url-prefix http://www.mydomain.com:8888 + +# Set automatic WsGen mode on/off +# If set to 'true', WsGen will automatically be applied to all deployed archives (EjbJars, Webapps, Applications) +# default to 'true' +#jonas.service.ws.auto-wsgen.engaged false + +# +###################### JOnAS JAXR service configuration (Deprecated) +# +# Set the name of the implementation class of the Registry service +#jonas.service.jaxr.class org.objectweb.jonas.jaxr.JAXRServiceImpl + +# Set the jonas jaxr factories. +# This property is set with a coma-separated list of JAXRFactory properties +# file names (without the '.properties' suffix). +# Ex: jaxr,jaxr2 (while the properties file names are +# jaxr.properties and jaxr2.properties) +#jonas.service.jaxr.factories jaxr + +# +###################### JOnAS EAR service configuration +# +# Set the name of the implementation class of the ear service. +jonas.service.ear.class org.objectweb.jonas.ear.EarServiceImpl + +# Set the list of directories that contains ears that must be deployed by +# the JOnAS Server at launch time. +# Here should be given a coma-separated list of directories. +# If the directory has a relative path, this path is relative from where the +# Application Server is launched. +# If the directory is not found it will be searched in JONAS_BASE/apps/ +# directory. +jonas.service.ear.autoloaddir autoload + +# Set the list of ears that must be depoyed by the JOnAS Server at launch time. +# Here should be given a coma-separated list of ear files names. +# If the file name has a relative path, this path is relative from where the +# Application Server is launched. +jonas.service.ear.descriptors + +# Set the XML deployment descriptors parsing mode for the EAR service +# (with or without validation). +jonas.service.ear.parsingwithvalidation true + +# +###################### JOnAS DBM Database service configuration +# +# Set the name of the implementation class of the dbm service +jonas.service.dbm.class org.objectweb.jonas.dbm.DataBaseServiceImpl + +# Set the jonas DataSources. This enables the JOnAS server to load +# the data dources, to load related jdbc drivers, and to register the data +# sources into JNDI. +# This property is set with a coma-separated list of Datasource properties +# file names (without the '.properties' suffix). +# Ex: Oracle1,InstantDB1 (while the Datasources properties file names are +# Oracle1.properties and InstantDB1.properties) +jonas.service.dbm.datasources @cargo.jonas.datasources.name@ + +# +###################### JOnAS Mail service configuration +# +# Set the name of the implementation class of the mail service +jonas.service.mail.class org.objectweb.jonas.mail.MailServiceImpl + +# Set the jonas mail factories. +# This property is set with a coma-separated list of MailFactory properties +# file names (without the '.properties' suffix). +# Ex: MailSession1,MailMimePartDS1 (while the properties file names are +# MailSession1.properties and MailMimePartDS1.properties) +jonas.service.mail.factories + +# +###################### JOnAS JTM Transaction service configuration +# + +# Set the name of the implementation class of the jtm service +jonas.service.jtm.class org.objectweb.jonas.jtm.TransactionServiceImpl + +# Set the Transaction Manager launching mode. +# If set to 'true', TM is remote: TM must be already launched in an other JVM. +# If set to 'false', TM is local: TM is going to run into the same JVM +# than the jonas Server. +jonas.service.jtm.remote false + +# Set the default transaction timeout, in seconds. +jonas.service.jtm.timeout 60 + + +# +###################### JOnAS SECURITY service configuration +# +# Set the name of the implementation class of the security service +jonas.service.security.class org.objectweb.jonas.security.JonasSecurityServiceImpl + +# Realm used for CsiV2 authentication +jonas.service.security.csiv2.realm @cargo.jonas.realm.name@ + +# Realm used for Web Service authentication +jonas.service.security.ws.realm @cargo.jonas.realm.name@ + +# Registration of realm resources into JNDI +# Disable by default so configuration is not available with clients +jonas.service.security.realm.jndi.registration false + +# Enable security context check on Remote Login Module +jonas.security.context.check false + +# Path to the keystore file +jonas.security.context.check.keystoreFile /tmp/keystore + +# Pass used for the keystore file +jonas.security.context.check.keystorePass keystorepass + +# Alias (stored in the keystore) +jonas.security.context.check.alias FB + +# +###################### JOnAS JMS service configuration +# +# Set the name of the implementation class of the jms service +jonas.service.jms.class org.objectweb.jonas.jms.JmsServiceImpl + +# Indicates the Jms service must be started with this class for administering the mom +jonas.service.jms.mom org.objectweb.jonas_jms.JmsAdminForJoram + +# Set the Jms Server launching mode +# If set to 'true' it is launched in the same JVM as Application Server +# If set to 'false' Jms Server is launched in a separate JVM +jonas.service.jms.collocated true + +# Set to the url connexion when the Jms server is not collocated +#jonas.service.jms.url joram://localhost:16010 + +# Set the list of administered objects topics to be created at Application Server launching time +# Note : When using resource service (default configuration), topics should go in joram-admin.cfg file +jonas.service.jms.topics sampleTopic + +# Set the list of administered objecst queuess to be created at Application Server launching time +# Note : When using resource service (default configuration), queues should go in joram-admin.cfg file +jonas.service.jms.queues sampleQueue + +# +###################### JOnAS J2CA resource service configuration +# +# Set the name of the implementation class of the J2CA resource service +jonas.service.resource.class org.objectweb.jonas.resource.ResourceServiceImpl + +# Set the list of directories that contains rars that must be deployed by +# the JOnAS Server at launch time. +# Here should be given a comma-separated list of directories. +# If the directory has a relative path, this path is relative from where the +# Application Server is launched. +# If the directory is not found it will be searched in JONAS_BASE/rars/ +# directory. +jonas.service.resource.autoloaddir autoload + +# Set the XML connector deployment descriptors parsing mode (with or without validation) +jonas.service.resource.parsingwithvalidation true + +# Set the min size of the worker thread pool used for all J2CA 1.5 Resource Adapters deployed +jonas.service.resource.minworkthreads 5 + +# Set the max size of the worker thread pool used for all J2CA 1.5 Resource Adapters deployed +jonas.service.resource.maxworkthreads 80 + +# Set the max # of seconds that a thread will wait for work +# This is used to shrink the worker thread pool back to minimum +jonas.service.resource.threadwaittimeout 60 + +# Set the max # of seconds of execution time for a work object +# This functionality may not be supported by all Resource Adapter +jonas.service.resource.execworktimeout 0 + +# Set the list of Resource Adapter to be used. +# This enables the JOnAS server to configure the resource adapter and register it into JNDI. +# This property is set with a coma-separated list of rar file names +# (with/without the '.rar' suffix). +# Ex: XXXX,YYYY (while the rar file names are XXXX.rar and YYYY.rar) +jonas.service.resource.resources + +###################### JOnAS DB service configuration +# +# Set the name of the implementation class of the db service (hsql for example) +jonas.service.db.class org.objectweb.jonas.db.hsqldb.HsqlDBServiceImpl +jonas.service.db.port 9001 +jonas.service.db.dbname db_jonas +jonas.service.db.user1 jonas:jonas +#jonas.service.db.user2 login:password + +###################### JOnAS Discovery service +# +# The server is not a master, unless this ligne is uncommented +#jonas.service.discovery.master = true +# For master servers, configure the client source port with this property +jonas.service.discovery.source.port=9888 +# +# Set the name of the implementation class and initialization parameters +jonas.service.discovery.class=org.objectweb.jonas.discovery.DiscoveryServiceImpl +jonas.service.discovery.ttl=1 +jonas.service.discovery.multicast.address=224.224.224.224 +jonas.service.discovery.multicast.port=9080 + +# A multicast greeting message is sent out when discovery service is started. +# The starting server listens at the port jonas.service.discovery.greeting.port +# (default 9899) for a response for jonas.service.discovery.greeting.timeout miliseconds +# (default 1000 ms). If a pre-existing server has the same server name as this one, +# this server's discovery service will be terminated. + +#jonas.service.discovery.greeting.port=9899 +#jonas.service.discovery.greeting.timeout=1000 + +###################### JOnAS HA service configuration +# +# Set the name of the implementation class of the HA service. +jonas.service.ha.class org.objectweb.jonas.ha.HaServiceImpl + +# Set the group communication framework to use +jonas.service.ha.gcl jgroups + +# Set the JGroups configuration file name +jonas.service.ha.jgroups.conf jgroups-ha.xml + +# Set the JGroups group name +jonas.service.ha.jgroups.groupname jonas-rep + +# Set the SFSB backup info timeout. The info stored in the backup node is removed when the timer expires. +jonas.service.ha.timeout 600 + +# Set the datasource for the tx table +jonas.service.ha.datasource jdbc_1 + +###################### JOnAS Thread Service +# +# Set the name of the implementation class of the thread service +# +jonas.service.thread.class org.objectweb.area.jonas.AreaService +jonas.service.thread.file jonas_areas.xml +jonas.service.thread.ejbareaname EJB \ No newline at end of file Index: containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/domain.xml =================================================================== --- containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/domain.xml (revision 0) +++ containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/domain.xml (revision 0) @@ -0,0 +1,46 @@ + + + jonas + A domain named jonas + + + + + + + + \ No newline at end of file Index: containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jonas-realm.xml =================================================================== --- containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jonas-realm.xml (revision 0) +++ containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jonas-realm.xml (revision 0) @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + @cargo.servlet.users.role@ + + + + + + + + + + + + + + + + + + + @cargo.servlet.users.user@ + + + + + + + + + + + + + + + + + + + + + + + + Index: containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/trace.properties =================================================================== --- containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/trace.properties (revision 0) +++ containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/trace.properties (revision 0) @@ -0,0 +1,311 @@ +# ----------------------------------------------------------------------- +# This is a default configuration file for monolog. +# +# 2 handlers have been defined : tty (System.out) and logf (file) +# +# Patterns for each handler may include these possible values : +# %h the thread name +# %O{1} the Class name (basename only) +# %M the method name +# %L the line number +# %d the date +# %l the level +# %m the message itself +# %n a new line +# +# A list of predefined loggers is given at the end of the file. +# Each logger inherits from its parent for properties not defined. +# The root logger is "root". It must always be defined. +# +# Each logger is associated with a level that can be one of : +# ERROR | WARN | INFO | DEBUG +# +# -> More info on http://www.objectweb.org/monolog/doc.html +# ----------------------------------------------------------------------- + +# ----------------------------------------------------------------------- +# Define which wrapper to use (= javaLog) +# ----------------------------------------------------------------------- +# For Log4j you need to add log4j.jar +# log.config.classname org.objectweb.util.monolog.wrapper.log4j.MonologLoggerFactory +log.config.classname org.objectweb.util.monolog.wrapper.javaLog.LoggerFactory + +# ----------------------------------------------------------------------- +# tty : console handler +# The switch attribute is used to log either on System.out or System.err +# depending of the level of the log. +# ----------------------------------------------------------------------- +handler.tty.type Console +handler.tty.output Switch +handler.tty.pattern %d : %O{1}.%M : %m%n + +# ----------------------------------------------------------------------- +# mesonly : console handler without header +# ----------------------------------------------------------------------- +handler.mesonly.type Console +handler.mesonly.output Switch +handler.mesonly.pattern %m%n + +# ----------------------------------------------------------------------- +# logf : file handler +# ----------------------------------------------------------------------- +handler.logf.type File +handler.logf.output automatic +handler.logf.pattern %d : %l : %h : %O{1}.%M : %m%n + +# ----------------------------------------------------------------------- +# wsdl : file handler +# ----------------------------------------------------------------------- +handler.wsdl.type File +handler.wsdl.output jonas_wsdls.log +handler.wsdl.pattern %d : %l : %h : %O{1}.%M : %m%n + +# ----------------------------------------------------------------------- +# jmxHandler : jmx handler +# ----------------------------------------------------------------------- +#handler.jmxHandler.type jmx +#handler.jmxHandler.output System.out +#handler.jmxHandler.pattern %m%n + + +# ----------------------------------------------------------------------- +# logf : rolling file handler +# ----------------------------------------------------------------------- +#handler.logf.type RollingFile +#handler.logf.output jonas.log +#handler.logf.pattern %d : %l : %h : %O{1}.%M : %m%n +#handler.logf.fileNumber 2 +#handler.logf.maxSize 10000 + +# ----------------------------------------------------------------------- +# logger definitions +# ----------------------------------------------------------------------- +logger.root.handler.0 tty +logger.root.handler.1 logf +#logger.root.handler.2 jmxHandler + +logger.root.level @cargo.logging@ + +logger.org.objectweb.level @cargo.logging@ + +#------- +# JOnAS +#------- +logger.org.objectweb.jonas.genic.handler.0 mesonly +logger.org.objectweb.jonas.genic.additivity false +logger.org.objectweb.jonas.genic.level @cargo.logging@ +#logger.org.objectweb.jonas.genic.level DEBUG +logger.org.objectweb.jonas.genic.velocity.level ERROR +#logger.org.objectweb.jonas_ejb.dd.level DEBUG +#logger.org.objectweb.jonas_ejb.mijorm.level DEBUG + +logger.org.objectweb.jonas_ws.wsgen.handler.0 mesonly +logger.org.objectweb.jonas_ws.wsgen.additivity false +logger.org.objectweb.jonas_ws.wsgen.level @cargo.logging@ +logger.org.objectweb.jonas_lib.genbase.level @cargo.logging@ +logger.org.objectweb.jonas_lib.genclientstub.level @cargo.logging@ + + +logger.org.objectweb.jonas.publication.handler.0 wsdl +logger.org.objectweb.jonas.publication.additivity false + +#logger.org.objectweb.common.level DEBUG + +#logger.org.objectweb.jonas.level DEBUG +#logger.org.objectweb.jonas.admin.level DEBUG +#logger.org.objectweb.jonas.db.level DEBUG +#logger.org.objectweb.jonas.dbm.level DEBUG +#logger.org.objectweb.jonas.discovery.level DEBUG +#logger.org.objectweb.jonas.ear.level DEBUG +#logger.org.objectweb.jonas.genic.level DEBUG +#logger.org.objectweb.jonas.jca.level DEBUG +#logger.org.objectweb.jonas.jca.process.level DEBUG +#logger.org.objectweb.jonas.jca.pool.level DEBUG +#logger.org.objectweb.jonas.jca.setter.level DEBUG +#logger.org.objectweb.jonas.jca.management.level DEBUG +#logger.org.objectweb.jonas.jdbc.level DEBUG +#logger.org.objectweb.jonas.jdbc.RA.level DEBUG +logger.org.objectweb.jonas.jdbc.sql.level DEBUG +#logger.org.objectweb.jonas.jmx.level DEBUG +#logger.org.objectweb.jonas.loader.level DEBUG +#logger.org.objectweb.jonas.mail.level DEBUG +#logger.org.objectweb.jonas.management.level DEBUG +#logger.org.objectweb.jonas.domain.management.level DEBUG +#logger.org.objectweb.jonas.management.j2eemanagement.level DEBUG +#logger.org.objectweb.jonas.management.j2eemanagement.event.level DEBUG +#logger.org.objectweb.jonas.naming.level DEBUG +#logger.org.objectweb.jonas.registry.level DEBUG +#logger.org.objectweb.jonas.security.level DEBUG +#logger.org.objectweb.jonas.security.jacc.level DEBUG +#logger.org.objectweb.jonas.security.ws.level DEBUG +#logger.org.objectweb.jonas.security.csiv2.level DEBUG +#logger.org.objectweb.jonas.security.csiv2_details.level DEBUG +#logger.org.objectweb.jonas.server.level DEBUG +#logger.org.objectweb.jonas.web.level DEBUG +#logger.org.objectweb.jonas.webapp.jadmin.servlet.level DEBUG +#logger.org.objectweb.jonas.ws.level DEBUG +#logger.org.objectweb.jonas.jaxr.level DEBUG + +#logger.org.objectweb.jonas_core.level DEBUG + +#logger.org.objectweb.jonas_ejb.level DEBUG +#logger.org.objectweb.jonas_ejb.coherence.level DEBUG +#logger.org.objectweb.jonas_ejb.context.level DEBUG +#logger.org.objectweb.jonas_ejb.dd.level DEBUG +#logger.org.objectweb.jonas_ejb.factory.level DEBUG +#logger.org.objectweb.jonas_ejb.genclass.level DEBUG +#logger.org.objectweb.jonas_ejb.interp.level DEBUG +#logger.org.objectweb.jonas_ejb.mdb.level DEBUG +#logger.org.objectweb.jonas_ejb.mijorm.level DEBUG +#logger.org.objectweb.jonas_ejb.query.level DEBUG +#logger.org.objectweb.jonas_ejb.security.level DEBUG +#logger.org.objectweb.jonas_ejb.ssfpool.level DEBUG +#logger.org.objectweb.jonas_ejb.swapper.level DEBUG +#logger.org.objectweb.jonas_ejb.synchro.level DEBUG +#logger.org.objectweb.jonas_ejb.thread.level DEBUG +#logger.org.objectweb.jonas_ejb.tx.level DEBUG +logger.org.objectweb.jonas_ejb.deployment.digester.level FATAL +#logger.org.objectweb.jonas_ejb.svc.level DEBUG +#logger.org.objectweb.jonas_jms.level DEBUG +#logger.org.objectweb.jonas_lib.deployment.work.level DEBUG + +#logger.org.objectweb.jonas_timer.level DEBUG + +#------- +# JOTM +#------- +logger.org.objectweb.jotm.level @cargo.logging@ +#logger.org.objectweb.jotm.jta.level INFO +#logger.org.objectweb.jotm.tm.level INFO +#logger.org.objectweb.jotm.recovery.level INFO + +#------- +# MEJB +#------- +#logger.org.objectweb.jonas.mejb.level DEBUG + +#------- +# CAROL +#------- +logger.org.objectweb.carol.level @cargo.logging@ +#logger.org.objectweb.carol.rmi.level INFO +#logger.org.objectweb.carol.jndi.level INFO +#logger.org.objectweb.carol.cmi.level INFO +#logger.org.objectweb.carol.cmi.des.level INFO +#logger.org.objectweb.carol.cmi.jndi.level INFO +#logger.org.objectweb.carol.cmi.registry.level INFO +#logger.org.objectweb.carol.cmi.ha.level INFO +#logger.org.objectweb.carol.cmi.stub.level INFO + +#------- +# JORM +#------- +logger.org.objectweb.jorm.level WARN +#logger.org.objectweb.jorm.compiler.level INFO +#logger.org.objectweb.jorm.xml2mi.level DEBUG +#logger.org.objectweb.jorm.mi2xml.level DEBUG +#logger.org.objectweb.jorm.metainfo.level DEBUG +#logger.org.objectweb.jorm.generator.level DEBUG +logger.org.objectweb.jorm.generator.velocity.level ERROR +#logger.org.objectweb.jorm.mapper.rdb.generator.level DEBUG + +#------- +# MEDOR +#------- +logger.org.objectweb.medor.level WARN +#logger.org.objectweb.medor.level DEBUG +#logger.org.objectweb.medor.optim.rule.level DEBUG +#logger.org.objectweb.medor.optim.rewriter.level DEBUG +#logger.org.objectweb.medor.eval.rdb.level DEBUG + +#------- +# JORAM +#------- +logger.fr.dyade.aaa.level ERROR +#logger.fr.dyade.aaa.agent.Agent.level DEBUG +#logger.fr.dyade.aaa.agent.Engine.level DEBUG +#logger.fr.dyade.aaa.agent.Service.level DEBUG +#logger.org.objectweb.joram.mom.Destination.level DEBUG +#logger.org.objectweb.joram.mom.Proxy.level DEBUG +#logger.org.objectweb.joram.client.jms.Client.level DEBUG +#logger.org.objectweb.joram.client.connector.Adapter.level DEBUG + +#------- +# SPEEDO +#------- +logger.org.objectweb.speedo.level WARN +## GENERATION +logger.org.objectweb.speedo.generation.SpeedoCompiler.level @cargo.logging@ +## RUN TIME +logger.org.objectweb.speedo.level WARN +logger.org.objectweb.speedo.init.level @cargo.logging@ +#logger.org.objectweb.speedo.po-manager-factory.level DEBUG +#logger.org.objectweb.speedo.po-manager-switch.level DEBUG +#logger.org.objectweb.speedo.po-manager-pool.level DEBUG +#logger.org.objectweb.speedo.po-manager-instanciator.level DEBUG +#logger.org.objectweb.speedo.po-manager.level DEBUG +#logger.org.objectweb.speedo.po-manager.query.level DEBUG +#logger.org.objectweb.speedo.mapper.level DEBUG +#logger.org.objectweb.speedo.mapper.mapper.level DEBUG +#logger.org.objectweb.speedo.mapper.mapper.sql.level DEBUG +#logger.org.objectweb.speedo.mapper.jorm-factory.level INFO +logger.org.objectweb.speedo.mapper.jorm-factory.class-properties.level @cargo.logging@ +#logger.org.objectweb.speedo.mapper.pool.level DEBUG +#logger.org.objectweb.speedo.mapper.storage-manager.level DEBUG +#logger.org.objectweb.speedo.memory-instance-manager.level DEBUG +#logger.org.objectweb.speedo.workingset-manager.level DEBUG +#logger.org.objectweb.speedo.naming-manager-factory.level DEBUG +#logger.org.objectweb.speedo.transaction.level DEBUG +#logger.org.objectweb.speedo.tpm.level DEBUG +#logger.org.objectweb.speedo.tpm.transactional-persistence-manager.level DEBUG +#logger.org.objectweb.speedo.tpm.cache-manager.level DEBUG +#logger.org.objectweb.speedo.tpm.cache-manager.bgcleaner.level DEBUG +#logger.org.objectweb.speedo.tpm.concurrency-manager.level DEBUG +#logger.org.objectweb.speedo.query-manager.level DEBUG +#logger.org.objectweb.speedo.query-manager.compiled-query.level DEBUG +#logger.org.objectweb.speedo.query-manager.compiled-query.allocator.level DEBUG +#logger.org.objectweb.speedo.query-manager.compiled-query.parser.level DEBUG +#logger.org.objectweb.speedo.query-manager.compiled-query.parser.variable.level DEBUG +#logger.org.objectweb.speedo.query-manager.compiled-query.parser.filter.level DEBUG +#logger.org.objectweb.speedo.compiled-query-cache.level DEBUG +#logger.org.objectweb.speedo.jca.level DEBUG +#logger.org.objectweb.speedo.txStatistic.level DEBUG +#logger.org.objectweb.speedo.jmx.level DEBUG + +# Struts +logger.org.apache.struts.util.level WARN + +#------------------------------ +# Tomcat 5.5 - Catalina logging +#------------------------------ +#logger.org.apache.catalina.core.ContainerBase.[jonas].level DEBUG +#logger.org.apache.catalina.core.ContainerBase.[jonas].[localhost].level DEBUG +#logger.org.apache.catalina.core.ContainerBase.[jonas].[localhost].[path].level DEBUG +### example for jonasAdmin ### +#logger.org.apache.catalina.core.ContainerBase.[jonas].[localhost].[jonasAdmin].level DEBUG + +#----------------------------- +# Jetty 5 (Avoid log of MBean registration (info level) +#----------------------------- +logger.org.mortbay.util.jmx.ModelMBeanImpl.level ERROR + +# ----------------------------------------------------------------------- +# MX4J - also need to set system proprty mx4j.log.priority to the corresponding level +# (fatal, error, warn, info, debug, trace) +# ----------------------------------------------------------------------- +#logger.mx4j.level DEBUG + +#--------- +# JGroups +#--------- +logger.org.jgroups.level FATAL + +# ----------------------------------------------------------------------- +# For Log file (tests) +# ----------------------------------------------------------------------- +handler.logtest.type File +handler.logtest.output jonas_tests.log +handler.logtest.pattern %d : %l : %h : %O{1}.%M : %m%n +logger.org.objectweb.jonas_tests.history.level @cargo.logging@ +logger.org.objectweb.jonas_tests.history.handler.0 logtest +logger.org.objectweb.jonas_tests.history.additivity false Index: containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jacorb.properties =================================================================== --- containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jacorb.properties (revision 0) +++ containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/jacorb.properties (revision 0) @@ -0,0 +1,737 @@ +## +## JacORB configuration options +## + +######################################## +# # +# Initial references configuration # +# # +######################################## + +# +# URLs where IORs are stored (used in orb.resolve_initial_service()) +# DO EDIT these! (Only those that you are planning to use, +# of course ;-). +# +# The ORBInitRef references are created on ORB startup time. In the +# cases of the services themselves, this may lead to exceptions being +# displayed (because the services aren't up yet). These exceptions +# are handled properly and cause no harm! + +#ORBInitRef.NameService=corbaloc::160.45.110.41:38693/StandardNS/NameServer-POA/_root +#ORBInitRef.NameService=file:/c:/NS_Ref +#ORBInitRef.NameService=http://www.x.y.z/~user/NS_Ref +#ORBInitRef.TradingService=http://www.x.y.z/~user/TraderRef + + +######################################## +# # +# Export of corbaloc IORs # +# # +######################################## + +# allow for more readable corbaloc URLs by mapping the +# actual object key to an arbitrary string. The mapping +# below would permit clients of a name service to +# access it using corbaloc::ipaddress:portnum/NameService +# Note: it is NOT necessary to define this property for +# the name service here because this is done already in the +# code of the ns implementation. +# This mapping can be altered programatically by the proprietary +# function ORB::addObjectKey(NameService, file:/home/rnc/NameSingleton.ior) +# +# The property also accepts the following mappings: +# IOR, resource, jndi, URL (e.g. file, http) +# examples: +# jacorb.orb.objectKeyMap.NameService=StandardNS/NameServer-POA/_root +# jacorb.orb.objectKeyMap.NameService=file:/home/rnc/NameSingleton.ior + +################################## +# # +# ORB version number output # +# # +################################## + +# if on, the ORB's version number and a copyright statement is printed +# any time the ORB is initialized +jacorb.orb.print_version=on + +################################## +# # +# Default Logging configuration # +# # +################################## + +# Name of the factory class that plugs in a given log kit +# The default value is JacORB's own factory for the Apache +# LogKit. Only edit (or uncomment) if you want a different +# log kit. +#jacorb.log.loggerFactory=org.jacorb.util.LogKitLoggerFactory + +# log levels: +# +# 0 = fatal errors only = "almost off" (FATAL ERRORS) +# 1 = non-fatal errors and exceptions (ERROR) +# 2 = important messages (WARN) +# 3 = informational messages and exceptions (INFO) +# 4 = debug-level output (DEBUG) (may confuse the unaware user :-) +# NOTE: the name of this property has changed from jacorb.verbosity!! +jacorb.log.default.verbosity=2 + +# where does output go? Terminal is default +#jacorb.logfile=LOGFILEPATH + +# If logging to file whether to append to existing file or overwrite +jacorb.logfile.append=off + +# If jacorb.logfile.append is on, set rolling log size in kilobytes. +# A value of 0 implies no rolling log +jacorb.logfile.maxLogSize=0 + +# hexdump outgoing messages +jacorb.debug.dump_outgoing_messages=off + +# hexdump incoming messages +jacorb.debug.dump_incoming_messages=off + +jacorb.util.tpool.log.verbosity=0 + +################################################## +# # +# WARNING: The following properties should # +# only be edited by the expert user. They # +# can be left untouched in most cases! # +# # +################################################## + + + +################################ +# # +# Basic ORB Configuration # +# # +################################ + +# the GIOP minor version number to use for newly created IORs +jacorb.giop_minor_version=2 + +# number of retries if connection cannot directly be established +jacorb.retries=1 + +# how many msecs. do we wait between retries +jacorb.retry_interval=500 + +# log2 of maximum buffer size managed by the internal +# buffer manager. +# +# This is NOT the maximum buffer size that +# can be used, but just the largest size of buffers that +# will be kept and managed. This value will be added to +# an internal constant of 5, so the real value in bytes +# is 2**(5+maxManagedBufSize-1). You only need to increase this +# value if you are dealing with LOTS of LARGE data structures. +# You may decrease it to make the buffer manager release large +# buffers immediately rather than keeping them for later +# reuse. +jacorb.maxManagedBufSize=18 + +# If this value is 0 an extra unlimited size buffer cache is created +# for the CDROutputStreams. If this value is > 0 then the cache will +# be purged every x msecs. If this value is -1 no caching of these +# buffers will take place. This will reduce memory footprint at the +# cost of decreased performance handling large data structures. +# This value defaults to 0 if not set. +#jacorb.bufferManagerMaxFlush=-1 + +# Normally, a jacorb server will close the TCP/IP connection right +# after sending a CloseConnection message. However, it may +# occasionally happen that the client sends a message into the closed +# connection because it hasn't handled the CloseConnection yet. To +# avoid this situation, closing of the TCP/IP connection can be delayed. +#jacorb.connection.delay_close=on +#jacorb.connection.timeout_after_closeconnection=20000 + +# Initial timeout for establishing a connection. +#jacorb.connection.client.connect_timeout=0 + +# Wait the specified number of msecs for a reply to a request. If +# exceeded, a org.omg.CORBA.TIMEOUT exception will be thrown +#jacorb.connection.client.pending_reply_timeout=0 + +# client-side connection idle timeout, set no non-zero to stop +# close the connection after so many msecs. +#jacorb.connection.client.idle_timeout=0 + +# shall the orb ignore pending messages when a connection idle timeout +# is detected? If "on", the connection is closed and all pending +# messages are cancelled. Default is "off" +#jacorb.connection.client.timeout_ignores_pending_messages=off + +# whenever a network failure is detected, the orb can either +# (infinitely) retry all pending requests, or propagate a COMM_FAILURE +# back into the client code. Default is "off", i.e. throw a +# COMM_FAILURE +#jacorb.connection.client.retry_on_failure=off + +# max time (msecs) a server keeps a connection open if nothing happens +#jacorb.connection.server.timeout=10000 + +# Max no of accepted connections on the server. +#jacorb.connection.max_server_connections= + +# The number of msecs that are waited until the next attempt to find +# an idle connection is made (i.e. do not continuously spin) +#jacorb.connection.wait_for_idle_interval=500 + +# The class name of the SelectionStrategy class +#jacorb.connection.selection_strategy_class= + +# The class name of the StatisticsProvider class +#jacorb.connection.statistics_provider_class= + +#jacorb.reference_caching=off + +# +# The following property specifies the class which is used for +# reference caching. WeakHashtable uses WeakReferences, so entries +# get gc'ed if only the Hashtable has a reference to them. This +# is useful if you have many references to short-living non-persistent +# CORBA objects. It is only available for java 1.2 and above. +# +# On the other hand the standard Hashtable keeps the references until +# they are explicitely deleted by calling _release(). This is useful +# for persistent and long-living CORBA objects. +# +#jacorb.hashtable_class=org.jacorb.util.WeakHashtable +# +jacorb.hashtable_class=java.util.Hashtable + +# use GIOP 1.2 byte order markers (since CORBA 2.4-5) +jacorb.use_bom=off + +# add additional IIOP 1.0 profiles even if we are using IIOP 1.2 +jacorb.giop.add_1_0_profiles=off + +# Use DNS names in IORs +jacorb.dns.enable=off + +# Compact Typecodes (0 - off, 1 - partial (not member_names), 2 - all) +jacorb.compactTypecodes=0 + +# Cache typecode on read +jacorb.cacheTypecodes=off + +# Cache poa names +jacorb.cachePoaNames=off + +########################################### +# # +# Interoperability # +# # +########################################### + +# Turn off indirection encoding for repeated typecodes. This fixes +# interoperability with certain broken ORB's eg. Orbix2000 +jacorb.interop.indirection_encoding_disable=off + +# Iona Comet CORBA/COM bridge can incorrectly encode buffer lengths. +# Enabling this property adds additional length checking and adjustment +# for interoperability with Comet. +jacorb.interop.comet=off + +# Some ORBs do not set a byte value of 1 as a CDR encoded boolean true +# value. Enabling this property interprets any non zero CDR encoded +# boolean value as true. +jacorb.interop.lax_boolean_encoding=off + +# Control whether the method create_abstract_interface_tc performs +# a validity check on the name parameter or not. Turning this check +# off circumvents a bug in Sun's implementation of javax.rmi.CORBA.ValueHander, +# which occasionally passes an invalid name (an empty string) to +# ORBSingleton.create_abstract_interface_tc. If you are using RMI valuetypes, +# you should turn this property off. +jacorb.interop.strict_check_on_tc_creation=off + +# Custom-marshalled RMI valuetypes should be encoded as chunks, but some +# ORBs are not able to decode chunked values. Disable this property for +# interoperability with the ORB in Sun's JDK 1.4.2. +jacorb.interop.chunk_custom_rmi_valuetypes=off +########################################### +# # +# Socket Factories # +# # +########################################### + +# A factory design pattern is used for the creation of sockets and server +# sockets. +# The jacorb.net.socket_factory property can be used to configure +# a socket factory that must implement the operations defined in the +# interface org.jacorb.orb.factory.SocketFactory. +# The jacorb.net.server_socket_factory property can be used to configure a +# server socket factory that must implement the operations defined in the +# interface org.jacorb.orb.factory.ServerSocketFactory. +# +#jacorb.net.socket_factory=org.jacorb.orb.factory.DefaultSocketFactory +#jacorb.net.server_socket_factory=org.jacorb.orb.factory.DefaultServerSocketFactory +#jacorb.net.socket_factory=org.jacorb.orb.factory.PortRangeSocketFactory +#jacorb.net.server_socket_factory=org.jacorb.orb.factory.PortRangeServerSocketFactory +# +# Additional socket factores are supported that allow for the configuration +# of maximum and minimum port numbers that can be used. This can be used to +# enable firewall traversal via a fixed port range. To use these socket factories +# configure one or both of the following property pairs. The first property pair +# configures the client socket factory and the second pair the server socket +# factory. +# +#jacorb.net.socket_factory.port.min +#jacorb.net.socket_factory.port.max +#jacorb.net.server_socket_factory.port.min +#jacorb.net.server_socket_factory.port.max + +########################################### +# # +# BiDirectional GIOP # +# # +########################################### + +# uncomment this initializer if you want to use BiDirectional GIOP + +#org.omg.PortableInterceptor.ORBInitializerClass.bidir_init=org.jacorb.orb.giop.BiDirConnectionInitializer + + +########################################### +# # +# Proxy address in IOR # +# # +########################################### + +# +# with these two properties it is possible to +# tell the ORB what IP/port IORs should contain, +# if the ServerSockets IP/port can't be used +# (e.g. for traffic through a firewall). +# +# WARNING: this is just "dumb" replacing, so you +# have to take care of your configuration! +# + +#jacorb.ior_proxy_host=1.2.3.4 +#jacorb.ior_proxy_port=4711 + + +########################################### +# # +# The Object Adapter Internet Address # +# # +########################################### + +# IP address on multi-homed host (this gets encoded in +# object references). NOTE: Adresses like 127.0.0.X +# will only be accessible from the same machine! +#OAIAddr=1.2.3.4 +#OAPort=4711 + + +############################ +# # +# Default Interceptors # +# Please leave them in! # +# # +############################ +org.omg.PortableInterceptor.ORBInitializerClass.standard_init=org.jacorb.orb.standardInterceptors.IORInterceptorInitializer + + + +############################################### +# # +# Implementation Repository Configuration # +# # +############################################### +# Switch off to avoid contacting the ImR on every server start-up +jacorb.use_imr=off + +# Switch off if you don't want to write the ImR address into server IORs +# (ignored if jacorb.use_imr=off) +jacorb.use_imr_endpoint=on + +# if set to "on", servers that don't already have an entry on their +# first call to the imr, will get automatically registered. Otherwise, +# an UnknownServer exception is thrown. +jacorb.imr.allow_auto_register=off + +# if set to "on", the imr will try to "ping" every object reference, +# that it is going to return. If the reference is not alive, TRANSIENT +# is thrown. +jacorb.imr.check_object_liveness=off + +ORBInitRef.ImplementationRepository=http://www.x.y.z/~user/ImR_Ref + +jacorb.imr.table_file=Z:\table.dat +jacorb.imr.backup_file=z:\backup.dat +jacorb.imr.ior_file=/home/bwana/brose/public_html/ImR_Ref +# Time (msecs) that the implementation will wait for a started server to register. +jacorb.imr.timeout= + +# Host for ImR endpoint +jacorb.imr.endpoint_host= +# Port number for IMR endpoint +jacorb.imr.endpoint_port_number= + +# how many millisecs should the imr wait, until a connection from an +# application client is terminated. Default is 2000. +jacorb.imr.connection_timeout=2000 + +# the implementation name, should be set to a different +# name in the code of persistent servers +jacorb.implname=StandardImplName + +# +# This is supposed to be a generic startup string for everything +# that calls Runtime.exec(). Might be replaced by jaco[.bat]. +# +jacorb.java_exec=java -Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB -Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton + +# with these two properties it is possible to +# tell the ORB what IP / hostname and port the IMR IOR and IMRified server IORs should +# contain, if the ServerSockets IP/port can't be used +# (e.g. for traffic through a firewall). +# +# WARNING: this is just "dumb" replacement, so you +# have to take care of your configuration! +# +#jacorb.imr.ior_proxy_host=1.2.3.4 +#jacorb.imr.ior_proxy_port=4711 + + +######################### +# # +# SSL Configuration # +# # +######################### + +# +# The port number used by SSL, will be dynmically assigned +# by default +# + +# This interceptor must be set if programs need access to +# certificates using the CORBA Security API, SSL works also +# without this interceptor + +#org.omg.PortableInterceptor.ORBInitializerClass.ForwardInit=org.jacorb.security.ssl.SecurityServiceInitializer +#org.omg.PortableInterceptor.ORBInitializerClass.ForwardInit=org.jacorb.security.ssl.iaik.SecurityServiceInitializer + +# qualified classname of access decision object +jacorb.security.access_decision=org.jacorb.security.level2.AccessDecisionImpl + +# list of qualified classnames of principal authenticator objects, +# separated by commas (no whitespaces!). The first entry (that can +# be successfully created) will be available through the +# principal_authenticator property. +jacorb.security.principal_authenticator=org.jacorb.security.level2.PrincipalAuthenticatorImpl + +# the qualified classname of the ssl socket factory class +jacorb.ssl.socket_factory=org.jacorb.security.ssl.sun_jsse.SSLSocketFactory +#jacorb.ssl.socket_factory=org.jacorb.security.ssl.iaik.SSLSocketFactory + +# the qualified classname of the ssl server socket factory class +jacorb.ssl.server_socket_factory=org.jacorb.security.ssl.sun_jsse.SSLServerSocketFactory +#jacorb.ssl.server_socket_factory=org.jacorb.security.ssl.iaik.SSLServerSocketFactory + +# IIOP/SSL parameters (numbers are hex values, without the leading "0x"): +# NoProtection = 1 +# EstablishTrustInClient = 40 +# EstablishTrustInTarget = 20 +# mutual authentication = 60 +# please see the programming guide for more explanation + +jacorb.security.support_ssl=off + +jacorb.security.ssl.client.supported_options=60 +jacorb.security.ssl.client.required_options=0 + +jacorb.security.ssl.server.supported_options=60 +jacorb.security.ssl.server.required_options=0 + +# +# If set, the following two values will be placed in the IOR, if +# "corbaloc:ssliop" ssliop. +# +# If not set, only EstablishTrustInTarget is used for both supported +# and required options. EstablishTrustInClient is not set, and the +# rest of the Association Options aren't currently used anyway. +#jacorb.security.ssl.corbaloc_ssliop.supported_options=0 +#jacorb.security.ssl.corbaloc_ssliop.required_options=0 + +# The name and location of the keystore. This may be absolute or +# relative to the home directory. +# +# NOTE (for Sun JSSE users): The "javax.net.ssl.trustStore[Password]" +# properties don't seem to take effect, so you may want to add trusted +# certificates to "normal" keystores. In this case, please set the +# property "jacorb.security.jsse.trustees_from_ks"is to "on", so trusted +# certificates are taken from the keystore instead of a dedicated +# truststore. +jacorb.security.keystore= +jacorb.security.keystore_password= + +# +# IAIK specific settings +# + + +# files with public key certs of trusted CAs +# +# WARNING: If no CA certs are present, the IAIK chain verifier will +# accept ALL otherwise valid chains! +# +jacorb.security.trustees= + +# the name of the default key alias to look up in the keystore +jacorb.security.default_user= +jacorb.security.default_password= + +# have iaiks ssl classes print debug output to stdout +jacorb.security.iaik_debug=off + +# +# Sun JSSE specific settings +# +# Use the keystore to take trusted certs from. +jacorb.security.jsse.trustees_from_ks=on + +# A comma-separated (no whitespaces!) list of cipher suite names. See +# the JSSE docs on how to obtain the correct cipher suite strings +jacorb.security.ssl.server.cipher_suites= +jacorb.security.ssl.client.cipher_suites= + +# Csiv2 interceptor will add this component( as it is based on EJB XML specific descriptor) +jacorb.security.ssl_components_added_by_ior_interceptor=on + + +######################### +# # +# POA Configuration # +# # +######################### + +# displays a GUI monitoring tool for servers +jacorb.poa.monitoring=off + +# POA log levels: +# 0 = fatal errors only = "almost off" (FATAL ERRORS) +# 1 = non-fatal errors and exceptions (ERROR) +# 2 = important messages (WARN) +# 3 = informational messages and exceptions (INFO) +# 4 = debug-level output (DEBUG) (may confuse the unaware user :-) +jacorb.poa.log.verbosity=2 + +# thread pool configuration for request processing +jacorb.poa.thread_pool_max=20 +jacorb.poa.thread_pool_min=5 + +# if set, request processing threads in thePOA +# will run at this priority. If not set or invalid, +# MAX_PRIORITY will be used. +#jacorb.poa.thread_priority= + +# Properties controlling the POA's request queue. If queue_wait is off, +# then if there are more than queue_max requests in the queue, the +# client gets TRANSIENT exceptions for any requests. If queue_wait is on, +# then the call blocks at the server side until no more than queue_min +# requests are left in the queue. The new request is then delivered as usual. +jacorb.poa.queue_wait=off +jacorb.poa.queue_max=100 +jacorb.poa.queue_min=10 + +# Set this to on for server-side checking of expired ReplyEndTimePolicy. +# (This also applies to RelativeRoundtripTimeoutPolicy.) When this is on, +# the clocks of the server and client machine need to be synchronized. +#jacorb.poa.check_reply_end_time=off + + +################################### +# # +# Transport Layer Configuration # +# # +################################### + +# Names of the factories classes for all installed transport plug-ins +# (comma-separated list). + +#jacorb.transport.factories=org.jacorb.orb.iiop.IIOPFactories + +# ProfileId tags of all installed transports that should actually +# listen on the server side. This is a comma-separated list of numbers, +# each number must correspond to one ProfileId tag from a factory in +# jacorb.transport.factories. In IORs produced by the server, the transport +# profiles will appear in the order indicated by this list. + +#jacorb.transport.server.listeners=0 + +# Name of a class that selects the transport profile to use on the +# client side. + +#jacorb.transport.client.selector=org.jacorb.orb.DefaultProfileSelector + + +################################## +# # +# Name Service Configuration # +# # +################################## + +# log levels: +# 0 = fatal errors only = "almost off" (FATAL ERRORS) +# 1 = non-fatal errors and exceptions (ERROR) +# 2 = important messages (WARN) +# 3 = informational messages and exceptions (INFO) +# 4 = debug-level output (DEBUG) (may confuse the unaware user :-) + +jacorb.naming.log.verbosity=3 + +# +# name of the logger factory. Implement your own subclass of +# org.jacorb.util.LoggerFactory and enter class name here to +# customize logging behavior. Built-in default is org.jacorb.util.LogKitLoggerFactory +#jacorb.log.loggerFactory= + +# Whether non active references are purged from name service +# when list operation is invoked. + +jacorb.naming.purge=on + +# Whether resolve should return references without trying to +# ping them to see if they're still alive first. + +jacorb.naming.noping=on + +# The file where the name server drops its IOR +#jacorb.naming.ior_filename=c:/NS_Ref + +######################################## +# # +# Trader configuration, please see # +# src/trading/README.PROPERTIES for # +# explanation # +# # +######################################## + +jtrader.util.max_threads=10 +jtrader.util.min_threads=1 +jtrader.util.query_timeout=5000 +jtrader.impl.cache_max=100 + +# boolean values, e.g. true / false +#jtrader.modifiable_properties= +#jtrader.dynamic_properties= +#jtrader.proxy_offers= + +jtrader.debug=false +jtrader.debug_verbosity=3 + +#integer values +jtrader.def_search_card= +jtrader.max_search_card= +jtrader.def_match_card= +jtrader.max_match_card= +jtrader.def_return_card= +jtrader.max_return_card= +jtrader.max_list= +jtrader.def_hop_count= +jtrader.max_hop_count= + +#FollowOptions +#always=2 +#if_no_local=1 +#local_only=0 +jtrader.def_follow_policy= +jtrader.max_follow_policy= +jtrader.max_link_follow_policy= + +######################################################## +# # +# Notification Service configuration, please see # +# the JacORB ProgrammingGuide for a explanation # +# # +######################################################## + +jacorb.notification.filter.thread_pool_size = 2 + +jacorb.notification.proxyconsumer.thread_pool_size = 2 + +jacorb.notification.proxysupplier.thread_pool_size = 4 + +jacorb.notification.supplier.poll_intervall = 1000 + +jacorb.notification.max_batch_size = 1 + +jacorb.notification.max_events_per_consumer = 100 + +jacorb.notification.order_policy = PriorityOrder + +jacorb.notification.discard_policy = PriorityOrder + +jacorb.notification.consumer.backout_interval = 5000 + +jacorb.notification.consumer.error_threshold = 3 + +# valid values: ThreadPool, ThreadPerProxy +jacorb.notification.proxysupplier.threadpolicy = ThreadPool + +jacorb.notification.default_filter_factory = builtin + +# jacorb.notification.supplier.max_number = 10 + +# jacorb.notification.start_time_supported = 10 + +jacorb.notification.stop_time_supported = on + +jacorb.notification.proxy.destroy_causes_disconnect = on + +# Notification Service log levels: +org.jacorb.notification.log.verbosity = INFO + +######################################## +# # +# SAS configuration # +# # +######################################## + +#commented (Uses JOnAS csiv2) + +# Use stateless mode (JOnAS) +#jacorb.security.sas.stateful=false + +#jacorb.SAS.log.verbosity=INFO +#jacorb.SAS.CSS.log.verbosity=INFO +#jacorb.SAS.TSS.log.verbosity=INFO + +# This option defines the specific SAS context generator/validator +# Currently supported contexts include: +# NullContext - Sends a NULL SAS Context +# GssUpContext - Uses GSSUP security +# KerberosContext - uses Kerberos security +# At least one context must be selected for SAS support +#jacorb.security.sas.contextClass=org.jacorb.security.sas.NullContext +#jacorb.security.sas.contextClass=org.jacorb.security.sas.GssUpContext +#jacorb.security.sas.contextClass=org.jacorb.security.sas.KerberosContext + +# This initializer installs the SAS interceptors +# Comment out this line if you do not want SAS support +#org.omg.PortableInterceptor.ORBInitializerClass.SAS=org.jacorb.security.sas.SASInitializer + +# This option is used for GSSUP security and sets up the GSS Provider +# Comment out this line if you are not using GSS UP authentication +#org.omg.PortableInterceptor.ORBInitializerClass.GSSUPProvider=org.jacorb.security.sas.GSSUPProviderInitializer + +######################################## +# # +# Custom configuration # +# # +######################################## + + +# any other custom properties can be added here. + +jacorb.config.log.verbosity=2 \ No newline at end of file Index: containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/carol.properties =================================================================== --- containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/carol.properties (revision 0) +++ containers/jonas/src/main/resources/org/codehaus/cargo/container/internal/resources/jonas4x/carol.properties (revision 0) @@ -0,0 +1,149 @@ +# Copyright (C) 2002-2005 ObjectWeb +# +# CAROL: Common Architecture for RMI ObjectWeb Layer +# +# This library is developed inside the ObjectWeb Consortium, +# http://www.objectweb.org +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +# +# -------------------------------------------------------------------------- +# $Id: carol.properties 8010 2006-02-13 16:54:11 +0000 (Mon, 13 Feb 2006) pelletib $ +# -------------------------------------------------------------------------- + +# jonas rmi activation (iiop, irmi, jrmp, jeremie, cmi) +carol.protocols=jrmp + +# RMI IRMI URL +carol.irmi.url=rmi://localhost:1098 + +# RMI JRMP URL +carol.jrmp.url=rmi://localhost:@cargo.rmi.port@ + +# RMI JEREMIE URL +carol.jeremie.url=jrmi://localhost:2000 + +# RMI IIOP URL +carol.iiop.url=iiop://localhost:2001 + + +###################################################################### +# Configuration for CMI (clustering) +###################################################################### + +# java.naming.provider.url property +# For a server : the URL on which the registry will be started +# For clients : lists the registries available +carol.cmi.url=cmi://localhost:2002 + +# JGroups configuration file +carol.cmi.jgroups.conf=jgroups-cmi.xml + +# Multicast address used by the registries in the cluster +# !!! Deprecated - Not used if carol.cmi.jgroups.conf is set +#carol.cmi.multicast.address=224.0.0.35:35467 + +# IP address or network mask of the local network interface to use to send +# multicast messages +# Needed only when the server has several network interfaces and the multicast +# messages do not go through to interface you want them to use +# Works only on JDK 1.4 +# !!! Deprecated - Not used if carol.cmi.jgroups.conf is set +#carol.cmi.multicast.itf 192.168.25.0/24 + +# Groupname for Javagroups. No need to change if don't know. +carol.cmi.multicast.groupname=G1 + +# Factor used for this server in wheighted round robin algorithms +carol.cmi.rr.factor=100 + +# If enabled, cluster stubs will print messages on some error cases +carol.cmi.stub.debug=false + + +###################################################################### +# Advanced Configuration for IRMI +###################################################################### +# Exported objects will listen on this port for remote method +# invocations. +#A value of 0 will cause a random port to be selected. +# This is the default value. +# Warning : if the port is set (not 0) with the value 'n', be aware that +# the port 'n + 1' will be used by the JMX server. +# So, for the firewall configuration, you have to open the port numbers 'n' +# and 'n+1'. +carol.irmi.server.port=0 + +# Use only a single interface when creating the registry +# (specified in carol.irmi.url property) +# Use all interfaces available [default configuration = false] +carol.irmi.interfaces.bind.single=false + +###################################################################### +# Advanced Configuration for JRMP +###################################################################### +# If true, local call with jrmp are optimized. If you get "ClassCastException +# with 2 beans in different jars, you should set it at "false". +carol.jvm.rmi.local.call=false + +# If true a local Naming context is used (to be used only with a collocated registry) +carol.jvm.rmi.local.registry=false + +# The value of this port is used to set the port of the objects listener. +# This allow to use this port for a firewall configuration. +# If registry and server are on same host, the two ports to open are the following and the registry port. +# 0 means random port [default configuration = 0] +carol.jrmp.server.port=0 + +# Use only a single interface when creating the registry +# (specified in carol.jrmp.url property) +# Use all interfaces available [default configuration = false] +carol.jrmp.interfaces.bind.single=false + + +###################################################################### +# Advanced Configuration for Jeremie +###################################################################### +# The value of this port is used to set the port of the objects listener. +# This allow to use this port for a firewall configuration. +# If registry and server are on same host, the two ports to open are the following and the registry port. +# 0 means random port [default configuration = 0] +carol.jeremie.server.port=0 + +###################################################################### +# Advanced Configuration for IIOP +###################################################################### +# The value of this port is used to set the port of the objects listener. +# This allow to use this port for a firewall configuration. +# If registry and server are on same host, the two ports to open are the following and the registry port. +# 0 means random port [default configuration = 0] +carol.iiop.server.port=0 + +# The value of this port is used to set the SSL port of the objects listener. +# Note that this port musn't not be set to 0 as it is used for CsiV2. +# but this port is used only if SSL mode is enable. +# So by default, there is no listener on this port +# [default configuration = not used] +carol.iiop.server.sslport=2003 + +# Delegate used by JOnAS for rmi-iiop protocol +carol.iiop.PortableRemoteObjectClass=org.objectweb.jonas_lib.naming.JacORBPRODelegate + + +###################################################################### +# Advanced JNDI Configuration +###################################################################### +carol.jndi.java.naming.factory.url.pkgs=org.objectweb.jonas.naming Index: containers/jonas/pom.xml =================================================================== --- containers/jonas/pom.xml (revision 0) +++ containers/jonas/pom.xml (revision 0) @@ -0,0 +1,70 @@ + + + + + 4.0.0 + + org.codehaus.cargo + cargo-core-containers + 1.0-SNAPSHOT + + cargo-core-container-jonas + Cargo Core Jonas Container + jar + Core API implementation for Jonas containers + + + + org.codehaus.cargo + cargo-core-api-generic + ${version} + test + + + + org.apache.geronimo.specs + geronimo-j2ee-management_1.0_spec + 1.1 + + + + org.apache.geronimo.specs + geronimo-ejb_2.1_spec + 1.1 + + + + + + + 1.4 + + + + mx4j + mx4j + 3.0.2 + + + mx4j + mx4j-remote + 3.0.2 + + + + + Index: api/container/src/main/java/org/codehaus/cargo/container/internal/util/ResourceUtils.java =================================================================== --- api/container/src/main/java/org/codehaus/cargo/container/internal/util/ResourceUtils.java (revision 1492) +++ api/container/src/main/java/org/codehaus/cargo/container/internal/util/ResourceUtils.java (working copy) @@ -31,12 +31,14 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLDecoder; import java.util.Vector; import org.apache.tools.ant.filters.util.ChainReaderHelper; import org.apache.tools.ant.types.FilterChain; +import org.codehaus.cargo.util.FileHandler; import org.codehaus.cargo.util.log.LoggedObject; /** @@ -52,6 +54,7 @@ * @param resourceName The name of the resource * @param destFile The file to which the contents of the resource should be copied * @throws IOException If an I/O error occurs while copying the resource + * @deprecated use {@link #copyResource(String, String, FileHandler)} instead */ public void copyResource(String resourceName, File destFile) throws IOException { @@ -84,14 +87,52 @@ } /** + * Copies a container resource from the JAR into the specified file. + * + * @param resourceName The name of the resource + * @param destFile The file to which the contents of the resource should be copied + * @param handler The file handler to use + * @throws IOException If an I/O error occurs while copying the resource + */ + public void copyResource(String resourceName, String destFile, FileHandler handler) throws IOException + { + InputStream in = ResourceUtils.class.getResourceAsStream(resourceName); + if (in == null) + { + throw new IOException("Resource [" + resourceName + "] not found"); + } + + OutputStream out = null; + try + { + out = handler.getOutputStream( destFile ); + + byte[] buf = new byte[4096]; + int numBytes; + while ((numBytes = in.read(buf)) > 0) + { + out.write(buf, 0, numBytes); + } + } + finally + { + in.close(); + if (out != null) + { + out.close(); + } + } + } + + /** * Copies a container resource from the JAR into the specified file, thereby applying the * specified filters. * - * @param resourceName The name of the resource, relative to the - * org.apache.cactus.integration.ant.container package + * @param resourceName The name of the resource package * @param destFile The file to which the contents of the resource should be copied * @param filterChain The ordered list of filter readers that should be applied while copying * @throws IOException If an I/O error occurs while copying the resource + * @deprecated use {@link #copyResource(String, String, FileHandler, FilterChain)} instead */ public void copyResource(String resourceName, File destFile, FilterChain filterChain) throws IOException @@ -144,6 +185,68 @@ } /** + * Copies a container resource from the JAR into the specified file, thereby applying the + * specified filters. + * + * @param resourceName The name of the resource package + * @param destFile The file to which the contents of the resource should be copied + * @param handler The file handler to be used for file copy + * @param filterChain The ordered list of filter readers that should be applied while copying + * @throws IOException If an I/O error occurs while copying the resource + */ + public void copyResource(String resourceName, String destFile, FileHandler handler, FilterChain filterChain) + throws IOException + { + InputStream resource = ResourceUtils.class.getResourceAsStream(resourceName); + if (resource == null) + { + throw new IOException("Resource [" + resourceName + "] not found"); + } + + BufferedReader in = null; + BufferedWriter out = null; + try + { + ChainReaderHelper helper = new ChainReaderHelper(); + helper.setBufferSize(8192); + helper.setPrimaryReader(new BufferedReader(new InputStreamReader(resource))); + Vector filterChains = new Vector(); + filterChains.add(filterChain); + helper.setFilterChains(filterChains); + in = new BufferedReader(helper.getAssembledReader()); + + out = new BufferedWriter(new OutputStreamWriter(handler.getOutputStream(destFile))); + + String line; + while ((line = in.readLine()) != null) + { + if (line.length() == 0) + { + out.newLine(); + } + else + { + out.write(line); + out.newLine(); + } + } + } + finally + { + if (in != null) + { + in.close(); + } + if (out != null) + { + out.close(); + } + } + } + + + + /** * Search for the given resource and return the directory or archive that contains it. * *

Doesn't work for archives in JDK 1.1 as the URL returned by getResource doesn't contain Index: api/generic/src/main/java/org/codehaus/cargo/generic/DefaultContainerFactory.java =================================================================== --- api/generic/src/main/java/org/codehaus/cargo/generic/DefaultContainerFactory.java (revision 1492) +++ api/generic/src/main/java/org/codehaus/cargo/generic/DefaultContainerFactory.java (working copy) @@ -91,6 +91,11 @@ registerContainer("jo1x", ContainerType.INSTALLED, "org.codehaus.cargo.container.jo.Jo1xInstalledLocalContainer"); + registerContainer("jonas4x", ContainerType.REMOTE, + "org.codehaus.cargo.container.jonas.Jonas4xRemoteContainer"); + registerContainer("jonas4x", ContainerType.INSTALLED, + "org.codehaus.cargo.container.jonas.Jonas4xInstalledLocalContainer"); + registerContainer("oc4j9x", ContainerType.INSTALLED, "org.codehaus.cargo.container.orion.Oc4j9xInstalledLocalContainer"); Index: api/generic/src/main/java/org/codehaus/cargo/generic/DefaultContainerCapabilityFactory.java =================================================================== --- api/generic/src/main/java/org/codehaus/cargo/generic/DefaultContainerCapabilityFactory.java (revision 1492) +++ api/generic/src/main/java/org/codehaus/cargo/generic/DefaultContainerCapabilityFactory.java (working copy) @@ -66,6 +66,9 @@ registerContainerCapability("jo1x", "org.codehaus.cargo.container.internal.ServletContainerCapability"); + + registerContainerCapability("jonas4x", + "org.codehaus.cargo.container.jonas.internal.JonasContainerCapability"); registerContainerCapability("oc4j9x", "org.codehaus.cargo.container.internal.J2EEContainerCapability"); Index: api/generic/src/main/java/org/codehaus/cargo/generic/deployer/DefaultDeployerFactory.java =================================================================== --- api/generic/src/main/java/org/codehaus/cargo/generic/deployer/DefaultDeployerFactory.java (revision 1492) +++ api/generic/src/main/java/org/codehaus/cargo/generic/deployer/DefaultDeployerFactory.java (working copy) @@ -84,6 +84,11 @@ registerDeployer("jo1x", DeployerType.INSTALLED, "org.codehaus.cargo.container.jo.Jo1xInstalledLocalDeployer"); + + registerDeployer("jonas4x", DeployerType.REMOTE, + "org.codehaus.cargo.container.jonas.Jonas4xJsr160RemoteDeployer"); + registerDeployer("jonas4x", DeployerType.INSTALLED, + "org.codehaus.cargo.container.jonas.Jonas4xInstalledLocalDeployer"); registerDeployer("resin2x", DeployerType.INSTALLED, "org.codehaus.cargo.container.resin.ResinInstalledLocalDeployer"); Index: api/generic/src/main/java/org/codehaus/cargo/generic/configuration/DefaultConfigurationFactory.java =================================================================== --- api/generic/src/main/java/org/codehaus/cargo/generic/configuration/DefaultConfigurationFactory.java (revision 1492) +++ api/generic/src/main/java/org/codehaus/cargo/generic/configuration/DefaultConfigurationFactory.java (working copy) @@ -94,6 +94,15 @@ registerConfiguration("jo1x", ContainerType.INSTALLED, ConfigurationType.STANDALONE, "org.codehaus.cargo.container.jo.Jo1xStandaloneLocalConfiguration"); + registerConfiguration("jonas4x", ContainerType.REMOTE, ConfigurationType.RUNTIME, + "org.codehaus.cargo.container.jonas.JonasRuntimeConfiguration"); + registerConfiguration("jonas4x", ContainerType.INSTALLED, ConfigurationType.EXISTING, + "org.codehaus.cargo.container.jonas.JonasExistingLocalConfiguration"); + registerConfiguration("jonas4x", ContainerType.INSTALLED, ConfigurationType.STANDALONE, + "org.codehaus.cargo.container.jonas.JonasStandaloneLocalConfiguration"); + registerConfiguration("jonas4x", ContainerType.REMOTE, ConfigurationType.STANDALONE, + "org.codehaus.cargo.container.jonas.JonasStandaloneLocalConfiguration"); + registerConfiguration("orion1x", ContainerType.INSTALLED, ConfigurationType.STANDALONE, "org.codehaus.cargo.container.orion.OrionStandaloneLocalConfiguration"); registerConfiguration("orion2x", ContainerType.INSTALLED, ConfigurationType.STANDALONE, Index: api/generic/src/main/java/org/codehaus/cargo/generic/configuration/DefaultConfigurationCapabilityFactory.java =================================================================== --- api/generic/src/main/java/org/codehaus/cargo/generic/configuration/DefaultConfigurationCapabilityFactory.java (revision 1492) +++ api/generic/src/main/java/org/codehaus/cargo/generic/configuration/DefaultConfigurationCapabilityFactory.java (working copy) @@ -93,6 +93,16 @@ registerConfigurationCapability("jo1x", ContainerType.INSTALLED, ConfigurationType.STANDALONE, "org.codehaus.cargo.container.jo.internal." + "Jo1xStandaloneLocalConfigurationCapability"); + + registerConfigurationCapability("jonas4x", ContainerType.REMOTE, + ConfigurationType.RUNTIME, "org.codehaus.cargo.container.jonas.internal." + + "JonasRuntimeConfigurationCapability"); + registerConfigurationCapability("jonas4x", ContainerType.INSTALLED, + ConfigurationType.EXISTING, "org.codehaus.cargo.container.jonas.internal." + + "JonasExistingLocalConfigurationCapability"); + registerConfigurationCapability("jonas4x", ContainerType.INSTALLED, + ConfigurationType.STANDALONE, "org.codehaus.cargo.container.jonas.internal." + + "JonasStandaloneLocalConfigurationCapability"); registerConfigurationCapability("orion1x", ContainerType.INSTALLED, ConfigurationType.STANDALONE, "org.codehaus.cargo.container.orion.internal." Index: api/util/src/test/java/org/codehaus/cargo/util/VFSFileHandler.java =================================================================== --- api/util/src/test/java/org/codehaus/cargo/util/VFSFileHandler.java (revision 1492) +++ api/util/src/test/java/org/codehaus/cargo/util/VFSFileHandler.java (working copy) @@ -109,6 +109,32 @@ } } + public String createDirectory(String parent, String file) + { + if (file == null) + { + file = ""; + } + + if (parent!= null && !parent.endsWith("/") && + !file.startsWith("/")) + { + parent += "/"; + } + + String filename = parent == null ? file : parent + file; + try + { + FileObject fileObject = getFileSystemManager().resolveFile(filename); + fileObject.createFolder(); + return fileObject.toString(); + } + catch (FileSystemException e) + { + throw new CargoException("Failed to create folder [" + filename + "]", e); + } + } + public boolean exists(String path) { boolean result; Index: api/util/src/test/java/org/codehaus/cargo/util/VFSFileHandlerTest.java =================================================================== --- api/util/src/test/java/org/codehaus/cargo/util/VFSFileHandlerTest.java (revision 1492) +++ api/util/src/test/java/org/codehaus/cargo/util/VFSFileHandlerTest.java (working copy) @@ -20,6 +20,7 @@ package org.codehaus.cargo.util; import junit.framework.TestCase; + import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.impl.StandardFileSystemManager; @@ -104,4 +105,23 @@ assertEquals(1, children.length); assertEquals("ram:///some/directory/file.txt", children[0]); } + + public void testCreateDirectory() + { + + this.fileHandler.createDirectory("ram://test", "test"); + assertTrue(this.fileHandler.exists("ram:///test/test")); + + this.fileHandler.createDirectory("ram://test2/", "test"); + assertTrue(this.fileHandler.exists("ram:///test2/test")); + + this.fileHandler.createDirectory("ram://test3", "/test"); + assertTrue(this.fileHandler.exists("ram:///test3/test")); + + this.fileHandler.createDirectory(null, "ram://test4"); + assertTrue(this.fileHandler.exists("ram:///test4")); + + this.fileHandler.createDirectory("ram://test5", null); + assertTrue(this.fileHandler.exists("ram:///test5")); + } } Index: api/util/src/main/java/org/codehaus/cargo/util/DefaultFileHandler.java =================================================================== --- api/util/src/main/java/org/codehaus/cargo/util/DefaultFileHandler.java (revision 1492) +++ api/util/src/main/java/org/codehaus/cargo/util/DefaultFileHandler.java (working copy) @@ -154,8 +154,8 @@ public String createDirectory(String parentDir, String name) { File dir = new File(parentDir, name); - dir.mkdirs(); - if (!dir.isDirectory()) + boolean created = dir.mkdirs(); + if (!created || !dir.isDirectory()) { throw new CargoException("Couldn't create directory " + dir.getAbsolutePath()); } Index: pom.xml =================================================================== --- pom.xml (revision 1486) +++ pom.xml (working copy) @@ -30,7 +30,7 @@ pom Cargo Core - 0.9.1 + ${version} scm:svn:http://svn.codehaus.org/cargo/core/trunk @@ -47,10 +47,16 @@ jmock jmock - 1.0.1 + 1.2.0 test + jmock + jmock-cglib + 1.2.0 + test + + commons-vfs commons-vfs 1.0