/** * {@inheritDoc} */ @Override public void setProperty(String name, String value) { if (value != null) { getLogger().debug("Setting property [" + name + "] = [" + value + "]", this.getClass().getName()); this.properties.put(name, value); } else { getLogger().debug("Removing property [" + name + "]", this.getClass().getName()); this.properties.remove(name); } }
/** * Add extra container classpath entries specified by the user. * * @param java the java command used to start/stop the container */ protected void addExtraClasspath(JvmLauncher java) { for (String extraClasspathItem : extraClasspath) { java.addClasspathEntries(extraClasspathItem); getLogger().debug("Adding [" + extraClasspathItem + "] to execution classpath", this.getClass().getName()); } }
/** * Parse properties and add any users to pending configuration. Users will be retrieved from * their property: {@link ServletPropertySet#USERS} */ protected void addUsersFromProperties() { getLogger().debug("Searching properties for User definition", this.getClass().getName()); String usersProperty = getPropertyValue(ServletPropertySet.USERS); if (usersProperty != null) { getLogger().debug("Found User definition: value [" + usersProperty + "]", this.getClass().getName()); List<User> usersFromProp = User.parseUsers(usersProperty); getUsers().addAll(usersFromProp); } }
/** * Parse properties and add any Resources to pending configuration. Resources will be found if * their property name starts with: {@link ResourcePropertySet#RESOURCE} */ protected void addResourcesFromProperties() { getLogger().debug("Searching properties for Resource definitions", this.getClass().getName()); for (Map.Entry<String, String> property : getProperties().entrySet()) { String propertyName = property.getKey(); if (propertyName.startsWith(ResourcePropertySet.RESOURCE)) { String resourceProperty = property.getValue(); getLogger().debug("Found Resource definition: value [" + resourceProperty + "]", this.getClass().getName()); Resource resource = new ResourceConverter().fromPropertyString(resourceProperty); getResources().add(resource); } } }
/** * Notify listeners that deployable is deployed/undeployed. * @param isDeployed True is deployable is deployed, false otherwise. */ protected void notifyListeners(boolean isDeployed) { for (DeployableMonitorListener listener : listeners) { getLogger().debug("Notifying monitor listener [" + listener + "]", this.getClass().getName()); if (isDeployed) { listener.deployed(); } else { listener.undeployed(); } } }
/** * Extract the context name from the WAR file name (without the file extension). For example if * the WAR is named <code>test.war</code> then the context name is <code>test</code>. */ private void parseContext() { if (this.context == null) { String ctx = getFileHandler().getName(getFile()); int warIndex = ctx.toLowerCase().lastIndexOf(".war"); if (warIndex >= 0) { ctx = ctx.substring(0, warIndex); } getLogger().debug("Parsed web context = [" + ctx + "]", this.getClass().getName()); setContext(ctx); } }
/** * @return the list of applications available in Tomcat and their statuses. */ public String list() { getLogger().debug("Getting the list of applications and their statuses", this.getClass().getName()); try { return getTomcatManager().list(); } catch (IOException|TomcatManagerException exception) { throw new ContainerException("Failed to get the list of applications", exception); } }
/** * @return the list of applications available in Tomcat and their statuses. */ public String list() { getLogger().debug("Getting the list of applications and their statuses", this.getClass().getName()); try { return getTomcatManager().list(); } catch (IOException|TomcatManagerException exception) { throw new ContainerException("Failed to get the list of applications", exception); } }
/** * {@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; }
/** * {@inheritDoc} */ @Override protected void doStart(JvmLauncher java) throws Exception { this.getLogger().debug("Starting container " + getName(), this.getClass().getName()); java.setJarFile(new File(getConfiguration().getHome(), "bin/server.jar")); java.setSystemProperty("org.apache.geronimo.server.dir", getConfiguration().getHome()); java.setSystemProperty("java.io.tmpdir", new File(getConfiguration().getHome(), "/var/temp").getPath()); java.start(); waitForCompletion(true); // deploy scheduled deployables GeronimoInstalledLocalDeployer deployer = new GeronimoInstalledLocalDeployer(this); for (Deployable deployable : this.getConfiguration().getDeployables()) { deployer.redeploy(deployable); } }
/** * {@inheritDoc} */ @Override protected void doStart(JvmLauncher java) throws Exception { this.getLogger().debug("Starting container " + getName(), this.getClass().getName()); java.setJarFile(new File(getConfiguration().getHome(), "bin/server.jar")); java.setSystemProperty("org.apache.geronimo.server.dir", getConfiguration().getHome()); java.setSystemProperty("java.io.tmpdir", new File(getConfiguration().getHome(), "/var/temp").getPath()); java.start(); waitForCompletion(true); // deploy scheduled deployables GeronimoInstalledLocalDeployer deployer = new GeronimoInstalledLocalDeployer(this); for (Deployable deployable : this.getConfiguration().getDeployables()) { deployer.redeploy(deployable); } }
/** * {@inheritDoc} */ @Override public void doStop(JvmLauncher java) { File adminClientJar = new File(getHome() + "/j2ee/home/admin_client.jar"); java.setJarFile(adminClientJar); String shutdownURL = "deployer:oc4j:" + getConfiguration().getPropertyValue(GeneralPropertySet.HOSTNAME) + ":" + getConfiguration().getPropertyValue(GeneralPropertySet.RMI_PORT); getLogger().debug("Shutdown URL [" + shutdownURL + "]", this.getClass().getName()); java.addAppArguments(shutdownURL); java.addAppArguments("oc4jadmin"); java.addAppArguments(getConfiguration().getPropertyValue(Oc4jPropertySet.ADMIN_PWD)); java.addAppArguments("-shutdown"); java.start(); }
/** * {@inheritDoc} */ @Override public void doStop(JvmLauncher java) { File adminClientJar = new File(getHome() + "/j2ee/home/admin_client.jar"); java.setJarFile(adminClientJar); String shutdownURL = "deployer:oc4j:" + getConfiguration().getPropertyValue(GeneralPropertySet.HOSTNAME) + ":" + getConfiguration().getPropertyValue(GeneralPropertySet.RMI_PORT); getLogger().debug("Shutdown URL [" + shutdownURL + "]", this.getClass().getName()); java.addAppArguments(shutdownURL); java.addAppArguments("oc4jadmin"); java.addAppArguments(getConfiguration().getPropertyValue(Oc4jPropertySet.ADMIN_PWD)); java.addAppArguments("-shutdown"); java.start(); }
/** * {@inheritDoc} */ @Override protected void doStop(JvmLauncher java) throws Exception { this.getLogger().debug("Stopping container " + getName(), this.getClass().getName()); java.setJarFile(new File(getHome(), "bin/shutdown.jar")); java.setSystemProperty("org.apache.geronimo.server.dir", getConfiguration().getHome()); java.setSystemProperty("java.io.tmpdir", new File(getConfiguration().getHome(), "/var/temp").getPath()); java.addAppArguments("--user"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.USERNAME)); java.addAppArguments("--password"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.PASSWORD)); java.addAppArguments("--port"); java.addAppArguments(getConfiguration().getPropertyValue(GeneralPropertySet.RMI_PORT)); java.start(); }
/** * {@inheritDoc} */ @Override protected void doStop(JvmLauncher java) throws Exception { this.getLogger().debug("Stopping container " + getName(), this.getClass().getName()); java.setJarFile(new File(getHome(), "bin/shutdown.jar")); java.setSystemProperty("org.apache.geronimo.server.dir", getConfiguration().getHome()); java.setSystemProperty("java.io.tmpdir", new File(getConfiguration().getHome(), "/var/temp").getPath()); java.addAppArguments("--user"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.USERNAME)); java.addAppArguments("--password"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.PASSWORD)); java.addAppArguments("--port"); java.addAppArguments(getConfiguration().getPropertyValue(GeneralPropertySet.RMI_PORT)); java.start(); }
/** * {@inheritDoc} */ @Override protected void doStop(JvmLauncher java) throws Exception { this.getLogger().debug("Stopping container " + getName(), this.getClass().getName()); java.setJarFile(new File(getConfiguration().getHome(), "bin/shutdown.jar")); java.setSystemProperty("org.apache.geronimo.server.dir", getConfiguration().getHome()); java.setSystemProperty("java.io.tmpdir", new File(getConfiguration().getHome(), "/var/temp").getPath()); java.addAppArguments("--user"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.USERNAME)); java.addAppArguments("--password"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.PASSWORD)); java.addAppArguments("--port"); java.addAppArguments(getConfiguration().getPropertyValue(GeneralPropertySet.RMI_PORT)); java.start(); }
/** * {@inheritDoc} */ @Override protected void doStop(JvmLauncher java) throws Exception { this.getLogger().debug("Stopping container " + getName(), this.getClass().getName()); java.setJarFile(new File(getConfiguration().getHome(), "bin/shutdown.jar")); java.setSystemProperty("org.apache.geronimo.server.dir", getConfiguration().getHome()); java.setSystemProperty("java.io.tmpdir", new File(getConfiguration().getHome(), "/var/temp").getPath()); java.addAppArguments("--user"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.USERNAME)); java.addAppArguments("--password"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.PASSWORD)); java.addAppArguments("--port"); java.addAppArguments(getConfiguration().getPropertyValue(GeneralPropertySet.RMI_PORT)); java.start(); }
/** * {@inheritDoc} */ @Override protected void doStop(JvmLauncher java) throws Exception { this.getLogger().debug("Stopping container " + getName(), this.getClass().getName()); prepareJvmLauncher(java); java.setMainClass("org.apache.geronimo.cli.shutdown.ShutdownCLI"); java.addAppArguments("--user"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.USERNAME)); java.addAppArguments("--password"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.PASSWORD)); java.addAppArguments("--port"); java.addAppArguments(getConfiguration().getPropertyValue(GeneralPropertySet.RMI_PORT)); java.start(); }
/** * {@inheritDoc} */ @Override protected void doStop(JvmLauncher java) throws Exception { this.getLogger().debug("Stopping container " + getName(), this.getClass().getName()); prepareJvmLauncher(java); java.setMainClass("org.apache.geronimo.cli.shutdown.ShutdownCLI"); java.addAppArguments("--user"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.USERNAME)); java.addAppArguments("--password"); java.addAppArguments(getConfiguration().getPropertyValue(RemotePropertySet.PASSWORD)); java.addAppArguments("--port"); java.addAppArguments(getConfiguration().getPropertyValue(GeneralPropertySet.RMI_PORT)); java.start(); }