/** * Sets a configuration file property for the container's configuration * * This function is currently only used to specify a different context.xml file from the one * located in the installations 'conf' folder. * * @param filePath The path to the new configuration file * @param configDirDest The name of the directory that the configuration file be placed in * @param configFileDestName The name of destination file for the new configuration file */ private void setConfigFile(String filePath, String configDirDest, String configFileDestName) { FileConfig configFile = new FileConfig(); configFile.setFile(filePath); configFile.setToDir(configDirDest); configFile.setToFile(configFileDestName); getConfiguration().setConfigFileProperty(configFile); } }
/** * Copies the container configuration (found through {@link #getConfiguration()}) to the logging * directory specified by {@link #logDir} */ public void cleanUp() throws IOException { File configDir = new File(getConfiguration().getHome()); if (configDir.exists()) { logger.info("Deleting configuration folder {}", configDir.getAbsolutePath()); FileUtils.deleteDirectory(configDir); } }
private void dumpConfiguration() { System.out.println("-------------------------------------------"); System.out.println("Configuration for container " + this); System.out.println("-------------------------------------------"); LocalConfiguration configuration = getConfiguration(); System.out.format("Name: %s%n", configuration); System.out.format("Class: %s%n", configuration.getClass()); System.out.println("Properties:"); configuration.getProperties().entrySet().forEach(System.out::println); System.out.println("-------------------------------------------"); System.out.println(""); }
/** * Convenience method for retrieving the {@link LocalConfiguration}'s property value. * @param propertyName the property we want the value of. * @return the value of the named property. */ private String getPropertyValue(String propertyName) { return configuration.getPropertyValue(propertyName); }
/** * The container's port for the specified port type */ public String getPort(String portType) { LocalConfiguration config = getConfiguration(); config.applyPortOffset(); if (!container.getState().isStarted()) throw new IllegalStateException( "Container is not started, thus a port has not yet been assigned to the container."); return config.getPropertyValue(portType); }
/** * set the container's logging level */ public void setLoggingLevel(String loggingLevel) { this.loggingLevel = loggingLevel; LocalConfiguration config = getConfiguration(); config.setProperty(GeneralPropertySet.LOGGING, loggingLevel); container.setConfiguration(config); }
private void setPropertyIfSupported(String propertyKey, String propertyValue, LocalConfiguration configuration, String containerType) { if (configuration.getCapability().supportsProperty(propertyKey)) { configuration.setProperty(propertyKey, propertyValue); } else { System.out.println("Container " + containerId + "(" + containerType + ") does not support setting of the '" + propertyKey + "' property"); } }
/** * Returns a deployerURL based on default values. * @param configuration The server configuration object * @return The url for the deployer */ protected String createDefaultDeployerUrl(Configuration configuration) { String protocol = configuration.getPropertyValue(GeneralPropertySet.PROTOCOL); String host = configuration.getPropertyValue(GeneralPropertySet.HOSTNAME); String port = configuration.getPropertyValue(ServletPropertySet.PORT); String deployerUrl = protocol + "://" + host + ":" + port + "/" + DEFAULT_DEPLOYER_CONTEXT; return deployerUrl; }
/** * Deploys the {@link #warFile} to the cargo container ({@link #container}). */ public void deployWar() { // Get the cargo war from the war file WAR war = new WAR(warFile.getAbsolutePath()); // Set context access to nothing war.setContext(""); // Deploy the war the container's configuration getConfiguration().addDeployable(war); logger.info("Deployed WAR file at {}", war.getFile()); }
/** * @param configuration Configuration to use. */ public GeronimoUtils(Configuration configuration) { logger = configuration.getLogger(); this.configuration = configuration; }
/** * Defaults to the standalone configuration if type is not specified by the user. * * @param typeAsString the configuration type as a string * @see org.codehaus.cargo.generic.configuration.ConfigurationFactory */ public void setType(String typeAsString) { this.type = ConfigurationType.toType(typeAsString); }
/** * Edits the container's configuration so that the file's XML element specified by the XPath * parameter contains the given XML attributes * * Uses {@link XmlReplacement} instances to add XML attributes to the specified XML node without * actively updating the original XML file. * * This function is used to edit the system properties that need to be placed in the server.xml * file. Adding these replacement XML pieces to the container's configuration allows the * configuration to modify the server.xml file only when creating the standalone container * configuration. This means that the server.xml file located in the installation's 'conf' folder * remains static, which resolves possible concurrency issues that might arise if more than one * container is modifying the server.xml file. * * @param file The path to the XML file that will be edited * @param XPath The path within XML file that leads to the node that should be changed * @param attributes The attributes to add to the node */ private void writePropertiesToConfig(StandaloneLocalConfiguration config, String file, String XPath, HashMap<String, String> attributes) { for (String key : attributes.keySet()) { XmlReplacement property = new XmlReplacement(); property.setFile(file); property.setXpathExpression(XPath); property.setAttributeName(key); property.setValue(attributes.get(key)); config.addXmlReplacement(property); } }
/** * {@inheritDoc} */ @Override public String toString() { return getType(); } }
/** * Convenience method for retrieving the {@link LocalConfiguration}'s property value. * @param propertyName the property we want the value of. * @return the value of the named property. */ private String getPropertyValue(String propertyName) { return configuration.getPropertyValue(propertyName); }
int containerRmiPort = portSupplier.getAsInt(); int tomcatAjpPort = portSupplier.getAsInt(); config.setProperty(ServletPropertySet.PORT, Integer.toString(servletPort)); config.setProperty(GeneralPropertySet.RMI_PORT, Integer.toString(containerRmiPort)); config.setProperty(TomcatPropertySet.AJP_PORT, Integer.toString(tomcatAjpPort)); config.setProperty(GeneralPropertySet.PORT_OFFSET, "0"); int jvmJmxPort = portSupplier.getAsInt(); String jvmArgs = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" + jvmJmxPort; " --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED"; config.setProperty(GeneralPropertySet.START_JVMARGS, jvmArgs); container.setConfiguration(config);
/** * @param configuration Configuration to use. */ public GeronimoUtils(Configuration configuration) { logger = configuration.getLogger(); this.configuration = configuration; }
/** * Defaults to the standalone configuration if type is not specified by the user. * * @param typeAsString the configuration type as a string * @see org.codehaus.cargo.generic.configuration.ConfigurationFactory */ public void setType(String typeAsString) { this.type = ConfigurationType.toType(typeAsString); }
/** * @param type Configuration type. */ public void setType(ConfigurationType type) { this.type = type.getType(); }
ConfigurationType.STANDALONE, this.containerConfigHome.getAbsolutePath()); configuration.setProperty(GeneralPropertySet.LOGGING, loggingLevel); configuration.setProperty(GeneralPropertySet.JVMARGS, "-Djava.security.egd=file:/dev/./urandom");
/** * @return Configuration type. */ public ConfigurationType getType() { return ConfigurationType.toType(this.type); }