Deployable war = new DefaultDeployableFactory().createDeployable( containerId, deployablePath,
/** * {@inheritDoc} */ @Override public Deployable createDeployable(String containerId, String deployableLocation, DeployableType deployableType) { Deployable deployable; DeployableFactoryParameters parameters = new DeployableFactoryParameters(); parameters.deployable = deployableLocation; // First, try to locate a container-specific deployable mapping if (isDeployableRegistered(containerId, deployableType)) { deployable = createImplementation( new RegistrationKey(new SimpleContainerIdentity(containerId), deployableType.getType()), parameters, "deployable"); } else { // Use a default deployable deployable = createImplementation( new RegistrationKey(new SimpleContainerIdentity(DEFAULT_CONTAINER_ID), deployableType.getType()), parameters, "deployable"); } return deployable; }
/** * {@inheritDoc} */ @Override public boolean isDeployableRegistered(String containerId, DeployableType deployableType) { return hasMapping(new RegistrationKey(new SimpleContainerIdentity(containerId), deployableType.getType())); }
Deployable war = DEPLOYABLE_FACTORY.createDeployable(containerType, this.deployableLocation.getAbsolutePath(), DeployableType.WAR);
+ "], location = [" + getLocation() + "]"); DeployableFactory factory = new DefaultDeployableFactory();
/** * Register deployable classes mappings. * * @param classLoader ClassLoader to discover implementations from. See * {@link AbstractFactoryRegistry#register(ClassLoader, DeployableFactory)} for the * details of what this value means. */ public DefaultDeployableFactory(ClassLoader classLoader) { // The default implementation of every Cargo supported deployable is registered here. // In order not to have to individually register against each container id we // create a fictitious default container id. registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.WAR, WAR.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.EJB, EJB.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.EAR, EAR.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.SAR, SAR.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.RAR, RAR.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.FILE, File.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.BUNDLE, Bundle.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.HAR, HAR.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.AOP, AOP.class); AbstractFactoryRegistry.register(classLoader, this); }
/** * Register deployable classes mappings. * * @param classLoader ClassLoader to discover implementations from. See * {@link AbstractFactoryRegistry#register(ClassLoader, DeployableFactory)} for the * details of what this value means. */ public DefaultDeployableFactory(ClassLoader classLoader) { // The default implementation of every Cargo supported deployable is registered here. // In order not to have to individually register against each container id we // create a fictitious default container id. registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.WAR, WAR.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.EJB, EJB.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.EAR, EAR.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.SAR, SAR.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.RAR, RAR.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.FILE, File.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.BUNDLE, Bundle.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.HAR, HAR.class); registerDeployable(DEFAULT_CONTAINER_ID, DeployableType.AOP, AOP.class); AbstractFactoryRegistry.register(classLoader, this); }
Deployable war = new DefaultDeployableFactory().createDeployable( containerId, deployablePath, DeployableType.WAR);
/** * {@inheritDoc} */ @Override public Deployable createDeployable(String containerId, String deployableLocation, DeployableType deployableType) { Deployable deployable; DeployableFactoryParameters parameters = new DeployableFactoryParameters(); parameters.deployable = deployableLocation; // First, try to locate a container-specific deployable mapping if (isDeployableRegistered(containerId, deployableType)) { deployable = createImplementation( new RegistrationKey(new SimpleContainerIdentity(containerId), deployableType.getType()), parameters, "deployable"); } else { // Use a default deployable deployable = createImplementation( new RegistrationKey(new SimpleContainerIdentity(DEFAULT_CONTAINER_ID), deployableType.getType()), parameters, "deployable"); } return deployable; }
/** * {@inheritDoc} */ @Override public boolean isDeployableRegistered(String containerId, DeployableType deployableType) { return hasMapping(new RegistrationKey(new SimpleContainerIdentity(containerId), deployableType.getType())); }
Deployable war = new DefaultDeployableFactory().createDeployable( containerId, deployablePath, DeployableType.WAR);
warTask.execute(); return new DefaultDeployableFactory().createDeployable(getContainer().getId(), updatedWar.getPath(), DeployableType.WAR);
/** * Deploy WAR statically. * @throws Exception If anything goes wrong. */ public void testDeployWarStatically() throws Exception { Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(), getTestData().getTestDataFileFor("simple-war"), DeployableType.WAR); getLocalContainer().getConfiguration().addDeployable(war); URL warPingURL = new URL("http://localhost:" + getTestData().port + "/simple-war/index.jsp"); startAndStop(warPingURL); }
/** * Tests servlet. * @param type WAR type. * @throws MalformedURLException If URL cannot be built. */ protected void testWar(String type) throws MalformedURLException { Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(), getTestData() .getTestDataFileFor(type + "-war"), DeployableType.WAR); getLocalContainer().getConfiguration().addDeployable(war); URL warPingURL = new URL("http://localhost:" + getTestData().port + "/" + type + "-war/test"); startAndStop(warPingURL); }
/** * Test deployment of a WAR with relative path. * @throws Exception If anything goes wrong. */ public void testDeployWarDefinedWithRelativePath() throws Exception { // Copies the testdata artifact File artifactDir = new File(getTestData().targetDir).getParentFile(); File artifactFile = new File(artifactDir, "simple.war").getAbsoluteFile(); Copy copyTask = (Copy) new AntUtils().createProject().createTask("copy"); copyTask.setTofile(artifactFile); copyTask.setFile(new File(getTestData().getTestDataFileFor("simple-war"))); copyTask.execute(); Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(), artifactFile.getAbsolutePath(), DeployableType.WAR); getLocalContainer().getConfiguration().addDeployable(war); URL warPingURL = new URL("http://localhost:" + getTestData().port + "/simple/index.jsp"); startAndStop(warPingURL); }
/** * Test start with one expanded WAR. * @throws Exception If anything goes wrong. */ public void testStartWithOneExpandedWarDeployed() throws Exception { // The Apache Geronimo server doesn't support expanded WARs if (getContainer().getId().startsWith("geronimo")) { return; } // Copy the war from the Maven local repository in order to expand it File artifactDir = new File(getTestData().targetDir).getParentFile(); Expand expandTask = (Expand) new AntUtils().createProject().createTask("unwar"); expandTask.setDest(new File(artifactDir, "expanded-war")); expandTask.setSrc(new File(getTestData().getTestDataFileFor("expanded-war"))); expandTask.execute(); Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(), new File(artifactDir, "expanded-war").getPath(), DeployableType.WAR); getLocalContainer().getConfiguration().addDeployable(war); URL warPingURL = new URL("http://localhost:" + getTestData().port + "/expanded-war" + "/index.html"); startAndStop(warPingURL); } }
/** * Start container with port offset. * @throws Exception If anything goes wrong. */ public void testStartWithPortOffset() throws Exception { int offsetValue = Integer.valueOf(OFFSET); int portWithOffset = getTestData().port + offsetValue; Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(), getTestData().getTestDataFileFor("simple-war"), DeployableType.WAR); getLocalContainer().getConfiguration().addDeployable(war); URL warPingURL = new URL("http://localhost:" + portWithOffset + "/simple-war/index.jsp"); getLocalContainer().start(); PingUtils.assertPingTrue(warPingURL.getPath() + " not started", warPingURL, getLogger()); getLocalContainer().stop(); PingUtils.assertPingFalse(warPingURL.getPath() + " not stopped", warPingURL, getLogger()); } }
/** * Start spawned container. * @throws Exception If anything goes wrong. */ public void testStartSpawned() throws Exception { Deployable war = new DefaultDeployableFactory().createDeployable(getContainer().getId(), getTestData().getTestDataFileFor("simple-war"), DeployableType.WAR); getLocalContainer().getConfiguration().addDeployable(war); URL pingURL = new URL("http://localhost:" + getTestData().port + "/simple-war/index.jsp"); getLocalContainer().start(); PingUtils.assertPingTrue(pingURL.getPath() + " not started", pingURL, getLogger()); getLocalContainer().stop(); PingUtils.assertPingFalse(pingURL.getPath() + " not stopped", pingURL, getLogger()); } }
/** * Test static AOP deployment. * @throws Exception If anything goes wrong. */ public void testDeployAopStatically() throws Exception { Deployable aop = new DefaultDeployableFactory().createDeployable(getContainer().getId(), getTestData() .getTestDataFileFor("simple-aop"), DeployableType.AOP); getLocalContainer().getConfiguration().addDeployable(aop); getLocalContainer().start(); assertEquals(State.STARTED, getContainer().getState()); // We're verifying that the AOP is successfully deployed by querying for the defined // pointcut name via jmx MBeanServerConnection server = createMBeanServerConnection(); ObjectName objectName = ObjectName.getInstance(JBOSSAOP_ASPECTMANAGER_OBJECT_NAME); String pointcuts = (String) server.invoke(objectName, "pointcuts", new Object[] {}, new String[] {}); getLogger().debug("Registered aop pointcuts: " + pointcuts.toString(), this.getClass().getName()); assertTrue("Dummy cargo aop pointcut not found", pointcuts.contains("cargoTestDataSimpleAop")); getLocalContainer().stop(); } }
/** * Test deployment of a WAR with root path. * @throws Exception If anything goes wrong. */ public void testDeployWarDefinedWithRootPath() throws Exception { WAR war = (WAR) new DefaultDeployableFactory().createDeployable(getContainer().getId(), getTestData().getTestDataFileFor("simple-war"), DeployableType.WAR); war.setContext("/"); getLocalContainer().getConfiguration().addDeployable(war); URL warPingURL = new URL("http://localhost:" + getTestData().port + "/index.jsp"); getLocalContainer().start(); PingUtils.assertPingTrue(warPingURL.getPath() + " not started", "Sample page for testing", warPingURL, getLogger()); getLocalContainer().stop(); PingUtils.assertPingFalse(warPingURL.getPath() + " not stopped", warPingURL, getLogger()); }