/** * {@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); }
/** * {@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."); } } }
/** * {@inheritDoc} */ @Override public void doExecute() throws MojoExecutionException { Container container = createContainer(); if (!container.getType().isLocal()) { throw new MojoExecutionException("Only local containers can be stopped"); } try { ((LocalContainer) container).stop(); waitDeployableMonitor(container, false); } catch (Exception ex) { throw new MojoExecutionException( "Cannot start container [" + container + "]", ex); } } }
/** * {@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; }
/** * {@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 (!container.getType().isLocal())
if (!container.getType().isLocal())
/** * {@inheritDoc} */ @Override protected void tearDown() { // Reset context classloader. See the comment in setUp(). if (getTestData().containerType == ContainerType.EMBEDDED) { Thread.currentThread().setContextClassLoader(null); } // Stop any local container that is still running if (this.container != null && this.container.getType().isLocal()) { LocalContainer container = (LocalContainer) this.container; if (container.getState().isStarted() || container.getState().isStarting()) { getLogger().info( "Container is in the [" + container.getState() + "] state" + ", shutting it down now", this.getClass().getName()); container.stop(); } } getLogger().info("Ending test [" + getName() + "]", this.getClass().getName()); }
/** * {@inheritDoc} */ @Override public void execute() { this.container = makeContainer(); // Verify that the task is correctly set up. verify(); // Setup all attributes and nested elements setupLogger(); if (getContainer().getType().isLocal()) { setupOutput(); setupTimeout(); if (getContainer().getType() == ContainerType.INSTALLED) { setupHome(); setupExtraClasspath(); setupSharedClasspath(); setupSystemProperties(); } } // Save the reference id if specified if (getId() != null) { getProject().addReference(getId(), getContainer()); } executeActions(); }
/** * {@inheritDoc} */ @Override public void execute() { this.container = makeContainer(); // Verify that the task is correctly set up. verify(); // Setup all attributes and nested elements setupLogger(); if (getContainer().getType().isLocal()) { setupOutput(); setupTimeout(); if (getContainer().getType() == ContainerType.INSTALLED) { setupHome(); setupExtraClasspath(); setupSharedClasspath(); setupSystemProperties(); } } // Save the reference id if specified if (getId() != null) { getProject().addReference(getId(), getContainer()); } executeActions(); }
/** * 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()); } }
/** * 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()); } }
/** * Creates a container of a given type for a given configuration. * @param type Container type. * @param configuration Container configuration. * @return {@link Container} of a given {@link ContainerType} for the given * {@link Configuration}. */ public Container createContainer(ContainerType type, Configuration configuration) { Container container = CONTAINER_FACTORY.createContainer(getTestData().containerId, type, configuration); container.setLogger(getLogger()); // Set up local container-specific settings if (container.getType().isLocal()) { setUpLocalSettings(configuration, (LocalContainer) container); } return container; }
if (ContainerType.EMBEDDED.equals(getContainer().getType()) && getTestData().containerId.startsWith("jetty"))