/** * Create the autodeploy deployable (if the current project is a Java EE deployable) * @param container Container. * @return The autodeploy deployable. * @throws MojoExecutionException If deployable creation fails. */ protected org.codehaus.cargo.container.deployable.Deployable createAutoDeployDeployable( org.codehaus.cargo.container.Container container) throws MojoExecutionException { Deployable deployableElement = new Deployable(); return deployableElement.createDeployable(container.getId(), getCargoProject()); }
if (!getContainer().getType().isLocal() && !DEPLOYER_ACTIONS.contains(getAction())) && getContainer().getType() == ContainerType.INSTALLED && ((InstalledLocalContainer) getContainer()).getHome() == null) + " to the location where the " + getContainer().getName() + " is installed, or a nested [zipurlinstaller] element");
/** * @param container the container into which to perform deployment operations */ public AbstractDeployer(Container container) { setLogger(container.getLogger()); }
/** * {@inheritDoc} */ @Override public Deployer createDeployer(Container container) { Deployer deployer; DeployerType type = DeployerType.toType(container.getType()); if (isDeployerRegistered(container.getId(), type)) { getLogger().debug("Creating a default [" + type + "] deployer", this.getClass().getName()); deployer = createDeployer(container, type); } else { throw new ContainerException("There's no registered deployer matching your " + "container's type of [" + container.getType().getType() + "]"); } return deployer; }
org.codehaus.cargo.container.deployer.Deployer deployer) throws MojoExecutionException getLog().debug("Performing deployment action into [" + container.getName() + "]..."); deployableElement.createDeployable(container.getId(), getCargoProject()); DeployableMonitor monitor = createDeployableMonitor(container, deployableElement, deployable);
/** * Set up a logger for the container. */ protected void setupLogger() { getContainer().setLogger(getLogger()); if (getContainer().getType().isLocal()) { ((LocalContainer) getContainer()).getConfiguration().setLogger(getLogger()); } else { ((RemoteContainer) getContainer()).getConfiguration().setLogger(getLogger()); } }
/** * Start container with an empty EAR. * @throws Exception If anything goes wrong. */ public void testStartWithOneEmptyEarDeployed() throws Exception { // The Apache Geronimo server doesn't like empty EARs if (getContainer().getId().startsWith("geronimo")) { return; } Deployable ear = new DefaultDeployableFactory().createDeployable(getContainer().getId(), getTestData().getTestDataFileFor("empty-ear"), DeployableType.EAR); getLocalContainer().getConfiguration().addDeployable(ear); getLocalContainer().start(); assertEquals(State.STARTED, getContainer().getState()); getLocalContainer().stop(); assertEquals(State.STOPPED, getContainer().getState()); }
/** * {@inheritDoc} */ @Override public void doExecute() throws MojoExecutionException { // Creating the container not only instantiate the container and its configuration but it // also installs it if required. Container container = createContainer(); if (container.getType() == ContainerType.INSTALLED) { getLog().info("Container is installed at [" + ((InstalledLocalContainer) container).getHome()); } else { getLog().warn("Only installed containers types can be installed. You have specified a " + "[" + container.getType().getType() + "] one."); } } }
if (ContainerType.EMBEDDED.equals(getContainer().getType()) && getTestData().containerId.startsWith("jetty")) assertEquals(State.STARTED, getContainer().getState()); assertEquals(State.STARTED, getContainer().getState()); assertEquals(State.STOPPED, getContainer().getState()); assertEquals(State.STARTED, getContainer().getState()); assertEquals(State.STOPPED, getContainer().getState());
protected void deploy(DeployerFactory deployerFactory, final BuildListener listener, Container container, File f, String contextPath) { Deployer deployer = deployerFactory.createDeployer(container); listener.getLogger().println("Deploying " + f + " to container " + container.getName()); deployer.setLogger(new LoggerImpl(listener.getLogger())); String extension = FilenameUtils.getExtension(f.getAbsolutePath()); if ("WAR".equalsIgnoreCase(extension)) { WAR war = createWAR(f); if (!StringUtils.isEmpty(contextPath)) { war.setContext(contextPath); } deployer.redeploy(war); } else if ("EAR".equalsIgnoreCase(extension)) { EAR ear = createEAR(f); deployer.redeploy(ear); } else { throw new RuntimeException("Extension File Error."); } }
/** * Wait indefinitely till the container is stopped. * * @param container the local container */ public static void waitTillContainerIsStopped(Container container) { while (container.getState() == State.STARTED) { try { Thread.sleep(SLEEP); } catch (InterruptedException e) { throw new CargoException("Aborting container wait.", e); } } } }
/** * Set up a logger for the container. */ protected void setupLogger() { getContainer().setLogger(getLogger()); if (getContainer().getType().isLocal()) { ((LocalContainer) getContainer()).getConfiguration().setLogger(getLogger()); } else { ((RemoteContainer) getContainer()).getConfiguration().setLogger(getLogger()); } }
/** * {@inheritDoc} */ @Override public Deployer createDeployer(Container container) { Deployer deployer; DeployerType type = DeployerType.toType(container.getType()); if (isDeployerRegistered(container.getId(), type)) { getLogger().debug("Creating a default [" + type + "] deployer", this.getClass().getName()); deployer = createDeployer(container, type); } else { throw new ContainerException("There's no registered deployer matching your " + "container's type of [" + container.getType().getType() + "]"); } return deployer; }
if (getContainer().getId().startsWith("glassfish")) Deployable bundle = new DefaultDeployableFactory().createDeployable(getContainer().getId(), getTestData().getTestDataFileFor("simple-bundle"), DeployableType.BUNDLE); assertEquals(State.STARTED, getContainer().getState()); final long timeout = System.currentTimeMillis() + 30 * 1000; while (!bundleOutput.isFile() && System.currentTimeMillis() < timeout) System.gc(); if (getContainer().getId().startsWith("geronimo")) assertEquals(State.STOPPED, getContainer().getState()); reader = new BufferedReader(new FileReader(bundleOutput)); assertEquals("Goodbye, World", reader.readLine());
/** * {@inheritDoc} */ @Override public void doExecute() throws MojoExecutionException { Container container = createContainer(); if (container.getType() != ContainerType.INSTALLED) { throw new MojoExecutionException("Only installed local containers can be packaged"); } InstalledLocalContainer installedContainer = (InstalledLocalContainer) container; // Note: The configuration must have been generated at this point. In the future we might // want to raise a warning if it hasn't been. createPackager(installedContainer).packageContainer(installedContainer); }
protected void deploy(DeployerFactory deployerFactory, final BuildListener listener, Container container, File f) { Deployer deployer = deployerFactory.createDeployer(container); listener.getLogger().println("Deploying "+f+" to container "+container.getName()); deployer.setLogger(new LoggerImpl(listener.getLogger())); deployer.redeploy(createDeployable(f)); }
/** * Smoke test: startup with no deployable. * @throws Exception If anything goes wrong. */ public void testStartWithNoDeployable() throws Exception { setContainer(createContainer(createConfiguration(ConfigurationType.STANDALONE))); getLocalContainer().start(); assertEquals(State.STARTED, getContainer().getState()); try { getLocalContainer().start(); fail("the second start attempt did not fail"); } catch (ContainerException expected) { assertTrue(expected.getMessage() + " does not contain the word 'restart'", expected.getMessage().contains("restart")); } getLocalContainer().stop(); assertEquals(State.STOPPED, getContainer().getState()); }