modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java | 54 - modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java | 4 modules/plugins/jboss-as-7/d2d.sh | 2 modules/plugins/jboss-as-7/pom.xml | 15 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Authenticator.java | 26 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 35 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java | 6 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java | 246 ++--- modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 10 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 19 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 63 + modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java | 9 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java | 57 - modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java | 57 - modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java | 4 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java | 3 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java | 2 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java | 2 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java | 27 modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 418 +++++---- modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java | 3 modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java | 16 modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java | 133 ++ modules/plugins/jboss-as-7/src/test/resources/host1.xml | 92 ++ modules/plugins/jboss-as-7/src/test/resources/host2.xml | 91 ++ modules/plugins/jboss-as-7/src/test/resources/standalone70.xml | 433 +++++++++ modules/plugins/jboss-as-7/src/test/resources/standalone71.xml | 453 ++++++++++ 27 files changed, 1897 insertions(+), 383 deletions(-)
New commits: commit 19097edb5d591dae5ae6fdf7565b682cd5b1506c Author: Heiko W. Rupp hwr@redhat.com Date: Fri Nov 18 15:23:26 2011 +0100
Several improvements to the AS7 plugin:
* BZ 754858 - in as7.1 the management port is now determined via socket binding reference. Also allow discover older versions. The xml parsing code has been rewritten to use XPath expressions. * BZ 754849 supply authentication to the remote. The JVM calls back to the AS7 Authenticator when needed. * Prevent a NPE in the case we get no results. * Add an operation to install a management user. * BZ 709678 - update jboss web to latest code and enable updating of properties. * Allow to merge in new/changed properties instead of requiring to supply the whole configuration in the standalone container.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java index 10b1b1b..07e2965 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java @@ -21,7 +21,6 @@ package org.rhq.core.pc; import java.io.*; import java.util.ArrayList; import java.util.EnumSet; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -31,6 +30,7 @@ import java.util.Stack; import org.rhq.core.clientapi.agent.PluginContainerException; import org.rhq.core.clientapi.agent.configuration.ConfigurationUpdateRequest; import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.Property; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; import org.rhq.core.domain.configuration.definition.PropertyDefinition; @@ -75,8 +75,6 @@ public class StandaloneContainer { InventoryManager inventoryManager; /** Global operation counter */ Integer opId = 0; - /** Map of resource plugin configurations */ - Map<Integer, Configuration> resConfigMap = new HashMap<Integer, Configuration>(); /** variable set by find() and which can be used in set() */ int dollarR = 0; /** Do we read from stdin ? */ @@ -340,32 +338,58 @@ public class StandaloneContainer {
}
- private void setResourcePluginConfig(String[] tokens,boolean pluginConfig) { + private void setResourcePluginConfig(String[] tokens,boolean isPluginConfig) throws PluginContainerException { if (resourceId == 0) { System.err.println("No resource set"); return; }
+ Configuration newConfig = null; Configuration config = null; - if (tokens.length > 1) - config = createConfigurationFromString(tokens[1]); - else { + boolean merge=false; + int pos = 1; + if (tokens.length < 2) { + System.err.println("Need at least 1 token"); + return; + } + if (tokens[1].equals("-m")) { + merge = true; + pos++; + } + if (tokens.length < pos+1) { System.err.println("Need at least 1 token"); return; }
- ConfigurationUpdateRequest request = new ConfigurationUpdateRequest(1,config,resourceId); + newConfig = createConfigurationFromString(tokens[pos]);
ConfigurationManager cm = pc.getConfigurationManager();
- if (pluginConfig) { - pc.getInventoryManager().getResourceContainer(resourceId).getResource().setPluginConfiguration(config); - } else - cm.updateResourceConfiguration(request); - - + if (isPluginConfig) { + Resource targetResource = pc.getInventoryManager().getResourceContainer(resourceId).getResource(); + config = targetResource.getPluginConfiguration(); + if (merge) { + // copy over existing properties that are not in newConfig + for (Property p : config.getProperties()) { + if (newConfig.get(p.getName())==null) + newConfig.put(p); + } + }
+ targetResource.setPluginConfiguration(newConfig); + } else { + config = pc.getConfigurationManager().loadResourceConfiguration(resourceId); + if (merge) { + // copy over existing properties that are not in newConfig + for (Property p : config.getProperties()) { + if (newConfig.get(p.getName())==null) + newConfig.put(p); + } + } + ConfigurationUpdateRequest request = new ConfigurationUpdateRequest(1,newConfig,resourceId); + cm.updateResourceConfiguration(request); + } }
@@ -715,7 +739,7 @@ public class StandaloneContainer { }
private void showConfig(Configuration config) { - System.out.println(config.getProperties()); + System.out.println(config.getProperties()); // TODO convert to input format or key=value or json }
} diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java index c992000..0f1d01d 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java @@ -47,8 +47,8 @@ public enum Command { WAIT("w", "milliseconds", 1, "Waits the given amount of time"), P_CONFIG("pc", "", 0, "Shows the plugin configuration of the current resource."), R_CONFIG("rc", "", 0, "Shows the resource configuration of the current resource."), - SR_CONFIG("rcs", "", 0, "[parameters] set resource config "), - SP_CONFIG("pcs", "", 0, "[parameters] set plugin config ") + SR_CONFIG("rcs", "", 1, "[-m] [parameters] set resource config. '-m' merges with current config; default is overwrite."), + SP_CONFIG("pcs", "", 1, "[-m] [parameters] set plugin config.'-m' merges with current config; default is overwrite.") ;
private String abbrev; diff --git a/modules/plugins/jboss-as-7/d2d.sh b/modules/plugins/jboss-as-7/d2d.sh index 16c1e57..d36d8e9 100755 --- a/modules/plugins/jboss-as-7/d2d.sh +++ b/modules/plugins/jboss-as-7/d2d.sh @@ -1,2 +1,2 @@ #!/bin/sh -java -cp target/rhq-jboss-as-7-plugin-4.1.0-SNAPSHOT.jar:/im/rhq/modules/enterprise/agent/target/rhq-agent/lib/commons-logging-1.1.0.jboss.jar:/Users/hrupp/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.7.4/jackson-core-asl-1.7.4.jar:/Users/hrupp/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.7.4/jackson-mapper-asl-1.7.4.jar org.rhq.modules.plugins.jbossas7.Domain2Descriptor $* +java -cp target/rhq-jboss-as-7-plugin-4.3.0-SNAPSHOT.jar:/im/rhq/modules/enterprise/agent/target/rhq-agent/lib/commons-logging-1.1.0.jboss.jar:/Users/hrupp/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.7.4/jackson-core-asl-1.7.4.jar:/Users/hrupp/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.7.4/jackson-mapper-asl-1.7.4.jar org.rhq.modules.plugins.jbossas7.Domain2Descriptor $* diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml index e069be3..8220355 100644 --- a/modules/plugins/jboss-as-7/pom.xml +++ b/modules/plugins/jboss-as-7/pom.xml @@ -17,6 +17,7 @@ <properties> <json.version>${project.json.version}</json.version> <jackson.version>1.7.4</jackson.version> + <jboss.sasl.version>1.0.0.Beta9</jboss.sasl.version> </properties>
<build> @@ -49,6 +50,11 @@ <artifactId>jackson-core-asl</artifactId> <version>${jackson.version}</version> </artifactItem> + <artifactItem> + <groupId>org.jboss.sasl</groupId> + <artifactId>jboss-sasl</artifactId> + <version>${jboss.sasl.version}</version> + </artifactItem>
</artifactItems> <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory> @@ -76,7 +82,7 @@ <plugins>
<plugin> - <artifactId>maven-antrun-plugin</artifactId> + <artifactId>maven-antrun-plugin</artifactId> <executions>
<execution> @@ -204,6 +210,13 @@ <scope>provided</scope> </dependency>
+ <!-- for the password hashing - we may want to copy the relevant stuff over ourselves --> + <dependency> + <groupId>org.jboss.sasl</groupId> + <artifactId>jboss-sasl</artifactId> + <version>${jboss.sasl.version}</version> + </dependency> + <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Authenticator.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Authenticator.java new file mode 100644 index 0000000..703e177 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Authenticator.java @@ -0,0 +1,26 @@ +package org.rhq.modules.plugins.jbossas7; + +import java.net.Authenticator; +import java.net.PasswordAuthentication; + +/** + * Authenticator to authenticate against as7 + * @author Heiko W. Rupp + */ +public class AS7Authenticator extends Authenticator { + + private String user; + private String pass; + + public AS7Authenticator(String user, String pass) { + this.user = user; + this.pass = pass; + if (this.pass==null) + this.pass=""; // prevent NPE later + } + + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(user,pass.toCharArray()); + } +} diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java index 40561a0..cf0b5b9 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java @@ -23,15 +23,14 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; +import java.net.Authenticator; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig;
@@ -51,15 +50,17 @@ public class ASConnection { String urlString; private ObjectMapper mapper; public static boolean verbose = false; // This is a variable on purpose, so devs can switch it on in the debugger or in the agent - private HttpURLConnection conn; + Authenticator passwordAuthenticator ;
/** * Construct an ASConnection object. The real "physical" connection is done in * #executeRaw. * @param host Host of the DomainController or standalone server * @param port Port of the JSON api. + * @param user user needed for authentication + * @param password password needed for authentication */ - public ASConnection(String host, int port) { + public ASConnection(String host, int port, String user, String password) {
try { url = new URL("http", host, port, MANAGEMENT); @@ -69,6 +70,9 @@ public class ASConnection { throw new IllegalArgumentException(e.getMessage()); }
+ passwordAuthenticator = new AS7Authenticator(user,password); + Authenticator.setDefault(passwordAuthenticator); + // read system property "as7plugin.verbose" verbose = Boolean.getBoolean("as7plugin.verbose");
@@ -92,14 +96,15 @@ public class ASConnection { InputStream inputStream = null; BufferedReader br = null; InputStream es = null; + HttpURLConnection conn=null; long t1 = System.currentTimeMillis(); try { - conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("POST"); - conn.addRequestProperty("Content-Type","application/json"); + conn.addRequestProperty("Content-Type", "application/json"); conn.addRequestProperty("Accept","application/json"); + OutputStream out = conn.getOutputStream();
String result = mapper.writeValueAsString(operation); @@ -236,6 +241,7 @@ public class ASConnection {
if (node==null) { log.warn("Operation [" + op + "] returned null"); + return null; } try { Result res; @@ -250,22 +256,5 @@ public class ASConnection { } }
- public void writeValue(OutputStream out, Object value) throws IOException, JsonGenerationException, - JsonMappingException { - // JsonGenerator jgen = _jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8); - // JsonGenerator jgen = mapper.createJsonGenerator(out, JsonEncoding.UTF8); - // JsonGenerator jgen = new Js - // boolean closed = false; - // try { - // writeValue(jgen, value); - // closed = true; - // jgen.close(); - // } finally { - // if (!closed) { - // jgen.close(); - // } - // } - - }
} diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java index d17a311..a5b8bdd 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java @@ -26,6 +26,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.net.Authenticator; import java.net.HttpURLConnection; import java.net.URL;
@@ -55,15 +56,18 @@ public class ASUploadConnection {
private static final Log log = LogFactory.getLog(ASUploadConnection.class);
+ Authenticator passwordAuthenticator ; BufferedOutputStream os = null; InputStream is = null; private HttpURLConnection connection; private String host; private int port;
- public ASUploadConnection(String dcHost, int port) { + public ASUploadConnection(String dcHost, int port, String user, String password) { this.host = dcHost; this.port = port; + passwordAuthenticator = new AS7Authenticator(user,password); + Authenticator.setDefault(passwordAuthenticator); }
public OutputStream getOutputStream(String fileName) { diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java index 8736495..78b1543 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java @@ -24,15 +24,16 @@ import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList;
-import org.rhq.core.pluginapi.inventory.ResourceComponent; -import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.system.ProcessInfo;
/** @@ -40,14 +41,24 @@ import org.rhq.core.system.ProcessInfo; * in the area of processes and host.xml * @author Heiko W. Rupp */ -public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> implements ResourceDiscoveryComponent<T> { +public class AbstractBaseDiscovery { static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file="; private static final String DJBOSS_SERVER_HOME_DIR = "-Djboss.home.dir"; static final int DEFAULT_MGMT_PORT = 9990; private static final String JBOSS_AS_PREFIX = "jboss-as-"; + static final String CALL_READ_STANDALONE_OR_HOST_XML_FIRST = "hostXml is null. You need to call 'readStandaloneOrHostXml' first."; protected Document hostXml; protected final Log log = LogFactory.getLog(this.getClass()); private static final String JBOSS_EAP_PREFIX = "jboss-eap-"; + private XPathFactory factory; + + + + protected AbstractBaseDiscovery() { + synchronized (this) { + factory = XPathFactory.newInstance(); + } + }
/** * Read the host.xml or standalone.xml file depending on isDomainMode. If isDomainMode is true, @@ -58,6 +69,10 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl */ protected void readStandaloneOrHostXml(ProcessInfo processInfo, boolean isDomainMode) { String hostXmlFile = getHostXmlFileLocation(processInfo,isDomainMode); + readStandaloneOrHostXmlFromFile(hostXmlFile); + } + + protected void readStandaloneOrHostXmlFromFile(String hostXmlFile) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = factory.newDocumentBuilder(); @@ -107,99 +122,50 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl */ protected HostPort getManagementPortFromHostXml(String[] commandLine) { if (hostXml==null) - throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first."); - Element host = hostXml.getDocumentElement(); - NodeList interfaceParent = host.getElementsByTagName("management-interfaces"); - if (interfaceParent ==null || interfaceParent.getLength()==0) { - log.warn("No <management-interfaces> found in host.xml"); - return new HostPort(); - } - NodeList mgmtInterfaces = interfaceParent.item(0).getChildNodes(); - if (mgmtInterfaces==null || mgmtInterfaces.getLength()==0) { - log.warn("No <*-interface> found in host.xml"); - return new HostPort(); + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST); + + String portString; + String interfaceExpession; + + String socketBindingName = obtainXmlPropertyViaXPath( + "//management/management-interfaces/http-interface/socket-binding/@http"); + if (socketBindingName==null || socketBindingName.isEmpty()) { + // old AS7.0, early 7.1 style + portString = obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@port"); + String interfaceName = obtainXmlPropertyViaXPath( + "//management/management-interfaces/http-interface/@interface"); + interfaceExpession = obtainXmlPropertyViaXPath( + "/server/interfaces/interface[@name='" + interfaceName + "']/inet-address/@value"); } - for (int i = 0 ; i < mgmtInterfaces.getLength(); i++) { - if (!(mgmtInterfaces.item(i) instanceof Element)) - continue; - - Element mgmtInterface = (Element) mgmtInterfaces.item(i); - if (mgmtInterface.getNodeName().equals("http-interface")) { - String tmp = mgmtInterface.getAttribute("port"); // TODO if we don't find it, check for socket-binding - int port; - if (!tmp.isEmpty()) - port = Integer.valueOf(tmp); - else - port = DEFAULT_MGMT_PORT; - HostPort hp = new HostPort(); - hp.isLocal=true; // TODO adjust when host != localhost - hp.port = port; - - String nIf = mgmtInterface.getAttribute("interface"); - if (!nIf.isEmpty()) - hp.host = getInterface(nIf, commandLine); - else - hp.host = "localhost"; - return hp; - } - } - return new HostPort(); - } + else { + // later AS7.1 and EAP6 + portString = obtainXmlPropertyViaXPath( + "/server/socket-binding-group/socket-binding[@name='" + socketBindingName + "']/@port"); + String interfaceName = obtainXmlPropertyViaXPath( + "/server/socket-binding-group/socket-binding[@name='" + socketBindingName + "']/@interface");
- /** - * Try to obtain the management interface IP from the host/standalone.xml files - * - * @param nIf Interface to look for - * @param commandLine Command line arguments of the process - * @return IP address to use - */ - private String getInterface(String nIf, String[] commandLine) { - if (hostXml==null) - throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first."); + // TODO the next may also be expressed differently + interfaceExpession = obtainXmlPropertyViaXPath( + "/server/interfaces/interface[@name='" + interfaceName + "']/inet-address/@value");
- Element host = hostXml.getDocumentElement(); - NodeList interfaceParent = host.getElementsByTagName("interfaces"); - if (interfaceParent ==null || interfaceParent.getLength()==0) { - log.warn("No <interfaces> found in host.xml"); - return null; - } - NodeList mgmtInterfaces = interfaceParent.item(0).getChildNodes(); - if (mgmtInterfaces==null || mgmtInterfaces.getLength()==0) { - log.warn("No <*-interface> found in host.xml"); - return null; } - for (int i = 0 ; i < mgmtInterfaces.getLength(); i++) { - if (!(mgmtInterfaces.item(i) instanceof Element)) - continue; - Element mgmtInterface = (Element) mgmtInterfaces.item(i); - if (mgmtInterface.getNodeName().equals("interface")) { - String name = mgmtInterface.getAttribute("name"); - if (!name.equals(nIf)) - continue; - - NodeList nl = mgmtInterface.getChildNodes(); - if (nl!=null) { - for (int j = 0 ; j < nl.getLength(); j++) { - if (!(nl.item(j) instanceof Element)) - continue; - - String nodeName = nl.item(j).getNodeName(); - if (nodeName.equals("any-ipv4-address")) - return "0.0.0.0"; - - String value = ((Element) nl.item(j)).getAttribute("value"); - value = replaceExpression(value, commandLine); - return value; - - // TODO check for <any> and so on - } - } - } + HostPort hp = new HostPort(); + + if (!interfaceExpession.isEmpty()) + hp.host = replaceDollarExpression(interfaceExpession, commandLine); + else + hp.host = "localhost"; // Fallback
+ + if (portString!=null && !portString.isEmpty()) { + hp.port = Integer.valueOf(portString); } - return null; // TODO: Customise this generated block + else + hp.port = 9990; // Fallback to default + return hp; }
+ /** * Check if the passed value has an expression in the form of ${var} or ${var:default}, * try to resolve it. Resolution is done by looking at the command line to see if @@ -209,7 +175,7 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl * @param commandLine The command line from the process * @return resolved value */ - private String replaceExpression(String value, String[] commandLine) { + private String replaceDollarExpression(String value, String[] commandLine) { if (!value.contains("${")) return value;
@@ -250,12 +216,12 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl
/** * Try to determine the host name - that is the name of a standalone server or a - * host in domain mode by looking at the standalone/host.xml files + * host in domain mode by looking at the standalone.xml/host.xml files * @return server name */ protected String findHostName() { if (hostXml==null) - throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first."); + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST);
String hostName = hostXml.getDocumentElement().getAttribute("name"); return hostName; @@ -267,29 +233,53 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl */ protected HostPort getDomainControllerFromHostXml() { if (hostXml==null) - throw new IllegalArgumentException("hostXml is null. You need to call 'readStandaloneOrHostXml' first."); - - Element host = hostXml.getDocumentElement(); - NodeList dcParent = host.getElementsByTagName("domain-controller"); - if (dcParent==null || dcParent.getLength()==0) - return new HostPort(false); - NodeList interfs = dcParent.item(0).getChildNodes(); - for (int i = 0; i < interfs.getLength(); i++) { - if (!(interfs.item(i)instanceof Element)) - continue; - - Element interf = (Element) interfs.item(i); - if (interf.getNodeName().equals("local")) - return new HostPort(); - - // not local, so get the remote - HostPort hp = new HostPort(false); - hp.host = interf.getAttribute("host"); - hp.port = Integer.parseInt(interf.getAttribute("port")); - return hp; + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST); + + + // first check remote, as we can't distinguish between a missing local element or + // and empty one which is the default + String remoteHost = obtainXmlPropertyViaXPath("/host/domain-controller/remote/@host"); + String portString = obtainXmlPropertyViaXPath("/host/domain-controller/remote/@port"); + + HostPort hp; + if (!remoteHost.isEmpty() && !portString.isEmpty()) { + hp = new HostPort(false); + hp.host = remoteHost; + hp.port = Integer.parseInt(portString); } + else { + hp = new HostPort(true); + hp.port = 9999; + } + + return hp; + + } + + String getManagementSecurtiyRealmFromHostXml() { + if (hostXml==null) + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST); + + String realm = obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@security-realm"); + + return realm; + } + + String getSecurityPropertyFileFromHostXml(String baseDir, AS7Mode mode, String realm) { + if (hostXml==null) + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST); + + // TODO make realm variable + String fileName = obtainXmlPropertyViaXPath("//security-realms/security-realm[@name='" + realm + "']/authentication/properties/@path"); + String relDir = obtainXmlPropertyViaXPath("//security-realms/security-realm[@name='" + realm + "']/authentication/properties/@relative-to"); + + String fullName ; + if (relDir.equals("jboss.server.config.dir")) + fullName = baseDir + File.separator + mode.getBaseDir() + File.separator + "configuration" + File.separator + fileName; + else + fullName = relDir + File.separator + fileName;
- return new HostPort(false); + return fullName; }
/** @@ -332,6 +322,34 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent<?>> impl }
/** + * Run the passed xpathExpression on the prepopulated hostXml document and + * return the target element or attribute as a String. + * @param xpathExpression XPath Expression to evaluate + * @return String value of the Element or Attribute the XPath was pointing to. + * Null in case the xpathExpression could not be evaluated. + * @throws IllegalArgumentException if hostXml is null + * + */ + protected String obtainXmlPropertyViaXPath(String xpathExpression) { + if (hostXml==null) + throw new IllegalArgumentException(CALL_READ_STANDALONE_OR_HOST_XML_FIRST); + + + XPath xpath = factory.newXPath(); + try { + XPathExpression expr = xpath.compile(xpathExpression); + + Object result = expr.evaluate(hostXml, XPathConstants.STRING); + + return result.toString(); + } catch (XPathExpressionException e) { + log.error("Evaluation XPath expression failed: " + e.getMessage()); + return null; + } + } + + + /** * Helper class that holds information about the host,port tuple */ protected static class HostPort { diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java index 7395233..3f03e52 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java @@ -89,6 +89,8 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo String host; int port; private boolean verbose = ASConnection.verbose; + String managementUser; + String managementPassword;
/** * Return availability of this resource @@ -99,7 +101,7 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo ReadResource op = new ReadResource(address); Result res = connection.execute(op);
- return res.isSuccess()? AvailabilityType.UP: AvailabilityType.DOWN; + return (res!=null && res.isSuccess()) ? AvailabilityType.UP: AvailabilityType.DOWN; }
@@ -115,7 +117,9 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo host = pluginConfiguration.getSimpleValue("hostname", LOCALHOST); String portString = pluginConfiguration.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT); port = Integer.parseInt(portString); - connection = new ASConnection(host,port); + managementUser = pluginConfiguration.getSimpleValue("user","-unset-"); + managementPassword = pluginConfiguration.getSimpleValue("password","-unset-"); + connection = new ASConnection(host,port, managementUser, managementPassword); } else { connection = ((BaseComponent)context.getParentResourceComponent()).getASConnection(); @@ -310,7 +314,7 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo ContentServices contentServices = cctx.getContentServices(); String resourceTypeName = report.getResourceType().getName();
- ASUploadConnection uploadConnection = new ASUploadConnection(host,port); + ASUploadConnection uploadConnection = new ASUploadConnection(host,port, managementUser, managementPassword); OutputStream out = uploadConnection.getOutputStream(details.getFileName()); contentServices.downloadPackageBitsForChildResource(cctx, resourceTypeName, details.getKey(), out);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java index 54e7e78..3f049dc 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java @@ -75,7 +75,7 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou String serverNameFull; String serverName; String psName = psr.getProcessScan().getName(); - String description = discoveryContext.getResourceType().getDescription(); + String description; String homeDir = getHomeDirFromCommandLine(commandLine); String version = determineServerVersionFromHomeDir(homeDir); boolean isEAP = false; @@ -115,7 +115,7 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou String host = findHost(psr.getProcessInfo(), true); config.put(new PropertySimple("domainHost", host));
- fillUserPassFromFile(config, "domain", homeDir); + fillUserPassFromFile(config, AS7Mode.DOMAIN, homeDir);
// provide running config String domainConfig = getServerConfigFromCommandLine(commandLine, AS7Mode.DOMAIN); @@ -157,7 +157,7 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou config.put(new PropertySimple("config",serverConfig)); config.put(new PropertySimple("startScript",AS7Mode.STANDALONE.getStartScript()));
- fillUserPassFromFile(config, "standalone", serverNameFull); + fillUserPassFromFile(config, AS7Mode.STANDALONE, serverNameFull);
//preload server.log file for event log monitoring logFile = bootLogFile.substring(0, bootLogFile.lastIndexOf("/")) + File.separator + "server.log"; @@ -173,6 +173,8 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou HostPort managmentPort = getManagementPortFromHostXml(commandLine); config.put(new PropertySimple("hostname", managmentPort.host)); config.put(new PropertySimple("port", managmentPort.port)); + config.put(new PropertySimple("realm",getManagementSecurtiyRealmFromHostXml())); + // String javaClazz = psr.getProcessInfo().getName();
/* @@ -207,11 +209,14 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
}
- private void fillUserPassFromFile(Configuration config, String mode, String baseDir) { + private void fillUserPassFromFile(Configuration config, AS7Mode mode, String baseDir) { + +// String configDir = baseDir + File.separator + mode + File.separator + "configuration"; + String realm = getManagementSecurtiyRealmFromHostXml(); + String fileName = getSecurityPropertyFileFromHostXml(baseDir,mode, realm);
- String configDir = baseDir + File.separator + mode + File.separator + "configuration";
- File file = new File(configDir, "mgmt-users.properties"); + File file = new File(fileName); if (!file.exists() || !file.canRead()) { if (log.isDebugEnabled()) log.debug("No console user properties file found at [" + file.getAbsolutePath() @@ -234,7 +239,7 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou String user = line.substring(0, line.indexOf("=")); String pass = line.substring(line.indexOf("=") + 1); config.put(new PropertySimple("user", user)); - config.put(new PropertySimple("password", pass)); +// config.put(new PropertySimple("password", pass)); // this is now hashed, so no point in supplying it
} } catch (IOException e) { diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java index 581c4e1..3a3fa03 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java @@ -19,13 +19,20 @@ package org.rhq.modules.plugins.jbossas7;
import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import java.net.ConnectException; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; +import java.util.Properties;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
+import org.jboss.sasl.util.UsernamePasswordHashUtil; + import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.pluginapi.operation.OperationResult; import org.rhq.core.pluginapi.util.ProcessExecutionUtility; @@ -137,6 +144,11 @@ public class BaseServerComponent extends BaseComponent { */ protected OperationResult postProcessResult(String name, Result res) { OperationResult operationResult = new OperationResult(); + if (res==null) { + operationResult.setErrorMessage("No result received from server"); + return operationResult; + } + if (name.equals("shutdown") || name.equals("reload")) { /* * Shutdown needs a special treatment, because after sending the operation, if shutdown suceeds, @@ -168,4 +180,55 @@ public class BaseServerComponent extends BaseComponent { return operationResult; }
+ protected OperationResult installManagementUser(Configuration parameters, Configuration pluginConfig, AS7Mode mode) { + String user = parameters.getSimpleValue("user",""); + String password = parameters.getSimpleValue("password",""); + + OperationResult result = new OperationResult(); + if (user.isEmpty() || password.isEmpty()) { + result.setErrorMessage("User and Password must not be empty"); + return result; + } + + String baseDir = pluginConfig.getSimpleValue("baseDir",""); + if (baseDir.isEmpty()) { + result.setErrorMessage("No baseDir found, can not continue"); + return result; + } + String standaloneXmlFile = pluginConfig.getSimpleValue("config",mode.getDefaultXmlFile()); + + String standaloneXml = baseDir + File.separator + mode.getBaseDir() + File.separator + "configuration" + File.separator + standaloneXmlFile; + + AbstractBaseDiscovery abd = new AbstractBaseDiscovery(); + abd.readStandaloneOrHostXmlFromFile(standaloneXml); + + String realm = pluginConfig.getSimpleValue("realm","ManagementRealm"); + String propertiesFilePath = abd.getSecurityPropertyFileFromHostXml(baseDir,mode, realm); + + + Properties p = new Properties(); + try { + UsernamePasswordHashUtil util = new UsernamePasswordHashUtil(); + String value = util.generateHashedHexURP(user, realm, password.toCharArray()); + + + FileInputStream fis = new FileInputStream(propertiesFilePath); + p.load(fis); + fis.close(); + p.setProperty(user,value); + FileOutputStream fos = new FileOutputStream(propertiesFilePath); + p.store(fos,null); + fos.flush(); + fos.close(); + } catch (IOException e) { + log.error(e.getMessage()); + result.setErrorMessage(e.getMessage()); + } catch (NoSuchAlgorithmException nsae) { + log.error(nsae.getMessage()); + result.setErrorMessage(nsae.getMessage()); + } + result.setSimpleResult("User/Password set or updated"); + + return result; + } } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java index c844d78..cbed07e 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadDelegate.java @@ -120,6 +120,15 @@ public class ConfigurationLoadDelegate implements ConfigurationFacet { operation = new ReadChildrenResources(address,type); operation.addAdditionalProperty("recursive", "true"); } + else if (groupName.startsWith("child:")) { + String subPath = groupName.substring("child:".length()); + if (!subPath.contains("=")) + throw new IllegalArgumentException("subPath of 'child:' expression has no ="); + + Address address1 = new Address(address); + address1.addSegment(subPath); + operation = new ReadResource(address1); + } else { throw new IllegalArgumentException("Unknown operation in group name [" + groupName + "]"); } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java index e966ba3..4f07bfc 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java @@ -50,7 +50,7 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet {
final Log log = LogFactory.getLog(this.getClass());
- private Address address; + private Address _address; private ASConnection connection; private ConfigurationDefinition configurationDefinition; private String namePropLocator; @@ -65,7 +65,7 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { public ConfigurationWriteDelegate(ConfigurationDefinition configDef, ASConnection connection, Address address) { this.configurationDefinition = configDef; this.connection = connection; - this.address = address; + this._address = address; }
/** @@ -89,7 +89,7 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet {
Configuration conf = report.getConfiguration();
- CompositeOperation cop = updateGenerateOperationFromProperties(conf); + CompositeOperation cop = updateGenerateOperationFromProperties(conf, _address);
Result result = connection.execute(cop); if (!result.isSuccess()) { @@ -103,13 +103,13 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet {
}
- protected CompositeOperation updateGenerateOperationFromProperties(Configuration conf) { + protected CompositeOperation updateGenerateOperationFromProperties(Configuration conf, Address address) {
CompositeOperation cop = new CompositeOperation();
for (PropertyDefinition propDef : configurationDefinition.getNonGroupedProperties()) {
- updateProperty(conf, cop, propDef); + updateProperty(conf, cop, propDef, address); } for (PropertyGroupDefinition pgd: configurationDefinition.getGroupDefinitions()) { String groupName = pgd.getName(); @@ -126,8 +126,21 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { } List<PropertyDefinition> definitions = configurationDefinition.getPropertiesInGroup(groupName); for (PropertyDefinition def : definitions) { - updateProperty(conf,cop,def); + updateProperty(conf,cop,def, address); } + } if (groupName.startsWith("child:")) { + String subPath = groupName.substring("child:".length()); + if (!subPath.contains("=")) + throw new IllegalArgumentException("subPath of 'child:' expression has no ="); + + Address address1 = new Address(address); + address1.addSegment(subPath); + + List<PropertyDefinition> definitions = configurationDefinition.getPropertiesInGroup(groupName); + for (PropertyDefinition def : definitions) { + updateProperty(conf,cop,def, address1); + } +
} // TODO handle attribute: case } @@ -135,7 +148,8 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { return cop; }
- private void updateProperty(Configuration conf, CompositeOperation cop, PropertyDefinition propDef) { + private void updateProperty(Configuration conf, CompositeOperation cop, PropertyDefinition propDef, + Address baseAddress) {
// Skip over read-only properties, the AS can not use them anyway if (propDef.isReadOnly()) @@ -147,7 +161,7 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { PropertyList pl = (PropertyList) conf.get("*"); // TODO loop over the list content
for (Property prop2 : pl.getList()) { - updateHandlePropertyMapSpecial(cop, (PropertyMap) prop2, (PropertyDefinitionMap) propDef); + updateHandlePropertyMapSpecial(cop, (PropertyMap) prop2, (PropertyDefinitionMap) propDef, baseAddress); } } else { @@ -155,25 +169,27 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { Property prop = conf.get(propDef.getName());
if (prop instanceof PropertySimple) { - updateHandlePropertySimple(cop, (PropertySimple)prop, (PropertyDefinitionSimple) propDef); + updateHandlePropertySimple(cop, (PropertySimple)prop, (PropertyDefinitionSimple) propDef, baseAddress); } else if (prop instanceof PropertyList) { - updateHandlePropertyList(cop, (PropertyList) prop, (PropertyDefinitionList) propDef); + updateHandlePropertyList(cop, (PropertyList) prop, (PropertyDefinitionList) propDef, baseAddress); } else { - updateHandlePropertyMap(cop,(PropertyMap)prop,(PropertyDefinitionMap)propDef); + updateHandlePropertyMap(cop,(PropertyMap)prop,(PropertyDefinitionMap)propDef, baseAddress); } } }
- private void updateHandlePropertyMap(CompositeOperation cop, PropertyMap prop, PropertyDefinitionMap propDef) { - Map<String,Object> results = updateHandleMap(prop,propDef); + private void updateHandlePropertyMap(CompositeOperation cop, PropertyMap prop, PropertyDefinitionMap propDef, + Address address) { + Map<String,Object> results = updateHandleMap(prop,propDef, address); Operation writeAttribute = new WriteAttribute(address,prop.getName(),results); cop.addStep(writeAttribute); }
- private void updateHandlePropertyMapSpecial(CompositeOperation cop, PropertyMap prop, PropertyDefinitionMap propDef) { - Map<String,Object> results = updateHandleMap(prop,propDef); + private void updateHandlePropertyMapSpecial(CompositeOperation cop, PropertyMap prop, PropertyDefinitionMap propDef, + Address address) { + Map<String,Object> results = updateHandleMap(prop,propDef, address); if (prop.get(namePropLocator)==null) { throw new IllegalArgumentException("There is no element in the map with the name " + namePropLocator); } @@ -186,7 +202,8 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { } }
- private void updateHandlePropertyList(CompositeOperation cop, PropertyList prop, PropertyDefinitionList propDef) { + private void updateHandlePropertyList(CompositeOperation cop, PropertyList prop, PropertyDefinitionList propDef, + Address address) { PropertyDefinition memberDef = propDef.getMemberDefinition();
// We need to collect the list members, create an array and attach this to the cop @@ -201,7 +218,8 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet {
} if (memberDef instanceof PropertyDefinitionMap) { - Map<String,Object> mapResult = updateHandleMap((PropertyMap) inner,(PropertyDefinitionMap)memberDef); + Map<String,Object> mapResult = updateHandleMap((PropertyMap) inner,(PropertyDefinitionMap)memberDef, + address); values.add(mapResult); } } @@ -210,7 +228,8 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { }
- private void updateHandlePropertySimple(CompositeOperation cop, PropertySimple propertySimple, PropertyDefinitionSimple propDef) { + private void updateHandlePropertySimple(CompositeOperation cop, PropertySimple propertySimple, + PropertyDefinitionSimple propDef, Address address) {
// If the property value is null and the property is optional, skip too if (propertySimple.getStringValue()==null && !propDef.isRequired()) @@ -221,7 +240,7 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet { cop.addStep(writeAttribute); }
- private Map<String, Object> updateHandleMap(PropertyMap map, PropertyDefinitionMap mapDef) { + private Map<String, Object> updateHandleMap(PropertyMap map, PropertyDefinitionMap mapDef, Address address) { Map<String,PropertyDefinition> memberDefinitions = mapDef.getPropertyDefinitions();
Map<String,Object> results = new HashMap<String,Object>(); diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java index df5362c..bc7d601 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java @@ -54,28 +54,47 @@ public class Domain2Descriptor { private void run(String[] args) {
D2DMode mode = null; + String user = null; + String pass = null; + int pos = 0; - if (args[0].startsWith("-")) { - if (args[0].equals("-m")) - mode = D2DMode.METRICS; - else if (args[0].equals("-p")) - mode = D2DMode.PROPERTIES; - else if (args[0].equals("-o")) - mode = D2DMode.OPERATION; - else { - usage(); - return; + boolean optionFound=false; + + String arg; + do { + arg = args[pos]; + if (arg.startsWith("-")) { + if (args[0].equals("-m")) + mode = D2DMode.METRICS; + else if (arg.equals("-p")) + mode = D2DMode.PROPERTIES; + else if (arg.equals("-o")) + mode = D2DMode.OPERATION; + else if (arg.startsWith("-U")) { + String tmp = arg.substring(2); + if (!tmp.contains(":")) + usage(); + user = tmp.substring(0,tmp.indexOf(":")); + pass = tmp.substring(tmp.indexOf(":")+1); + } + else { + usage(); + return; + } + pos++; + optionFound=true; } - pos++; - } + else + optionFound=false; + }while(optionFound);
- String path = args[pos]; + String path = arg; path = path.replaceAll("/",","); // Allow path from jboss-admin.sh's pwd command String childType = null; if (args.length>pos+1) childType = args[pos+1];
- ASConnection conn = new ASConnection("localhost",9990); + ASConnection conn = new ASConnection("localhost",9990, user, pass);
Address address = new Address(path); Operation op = new Operation("read-resource-description",address); @@ -87,6 +106,10 @@ public class Domain2Descriptor { op.addAdditionalProperty("include-runtime",true);
ComplexResult res = conn.executeComplex(op); + if (res==null) { + System.err.println("Got no result"); + return; + } if (!res.isSuccess()) { System.err.println("Failure: " + res.getFailureDescription()); return; @@ -313,6 +336,8 @@ public class Domain2Descriptor { typeString = "long"; break; case BIG_DECIMAL: typeString = "long"; break; // TODO better float or double? + case DOUBLE: + typeString = "long"; break; // TODO float or double? case LIST: typeString = "-list-"; break; // Handled below @@ -412,6 +437,7 @@ public class Domain2Descriptor { System.out.println(" -p create properties (default)"); System.out.println(" -m create metrics"); System.out.println(" -o create operations"); + System.out.println(" -U<user>:<pass> - supply credentials to talk to AS7" ); }
public enum Type { @@ -421,7 +447,8 @@ public class Domain2Descriptor { LONG, BIG_DECIMAL, OBJECT, - LIST + LIST, + DOUBLE
; } diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java index 6168dad..f4fa473 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java @@ -61,6 +61,10 @@ public class HostControllerComponent extends BaseServerComponent implements Oper
return postProcessResult(name,res); } + else if (name.equals("installRhqUser")) { + return installManagementUser(parameters, pluginConfiguration, AS7Mode.HOST); + } +
// Defer other stuff to the base component for now return super.invokeOperation(name, parameters); diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java index 8df1c47..3e90588 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java @@ -48,6 +48,7 @@ import org.rhq.modules.plugins.jbossas7.json.ReadResource; * * @author Heiko W. Rupp */ +@SuppressWarnings("unused") public class ManagedASDiscovery extends AbstractBaseDiscovery
{ @@ -138,7 +139,7 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery }
private ServerInfo getBindingsFromDC(HostPort domainController, String serverGroup) { - ASConnection dcConnection = new ASConnection(domainController.host, domainController.port); + ASConnection dcConnection = new ASConnection(domainController.host, domainController.port, "-TODO-", "-TODO-"); // TODO where do we get these from? List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(); Address theAddress = new Address("server-group", serverGroup); Operation op = new ReadResource(theAddress); diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java index c703635..c5a17a8 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java @@ -74,7 +74,7 @@ public class ServerGroupComponent extends ManagedASComponent implements ContentF
for (ResourcePackageDetails details : packages) {
- ASUploadConnection uploadConnection = new ASUploadConnection(host,port); + ASUploadConnection uploadConnection = new ASUploadConnection(host,port, super.managementUser, super.managementPassword); String fileName = details.getFileName(); OutputStream out = uploadConnection.getOutputStream(fileName); contentServices.downloadPackageBits(cctx, details.getKey(), out, false); diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java index 11a0e4d..f3c3184 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java @@ -40,6 +40,8 @@ public class StandaloneASComponent extends BaseServerComponent implements Operat } else if (name.equals("restart")) { return restartServer(parameters, AS7Mode.STANDALONE);
+ } else if (name.equals("installRhqUser")) { + return installManagementUser(parameters, pluginConfiguration, AS7Mode.STANDALONE); }
// reload, shutdown go to the remote server diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java index c0a9196..51fc3a2 100644 --- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java @@ -83,11 +83,7 @@ public class Address {
if (tmp.contains("=")) { // strip / from the start of the key if it happens to be there - if (tmp.startsWith("/")) - tmp = tmp.substring(1); - - String[] pair = tmp.split("="); - PROPERTY_VALUE valuePair = new PROPERTY_VALUE(pair[0], pair[1]); + PROPERTY_VALUE valuePair = pathFromSegment(tmp); this.path.add(valuePair); } } @@ -95,6 +91,19 @@ public class Address { }
/** + * Generates a path from a segment in the form of key=value. + * @param segment A segment in the form key=value + * @return A path + */ + private PROPERTY_VALUE pathFromSegment(String segment) { + if (segment.startsWith("/")) + segment = segment.substring(1); + + String[] pair = segment.split("="); + return new PROPERTY_VALUE(pair[0], pair[1]); + } + + /** * Add a key value pair to the path * @param key Key part of this path element * @param value Value part of this path element @@ -103,6 +112,14 @@ public class Address { path.add(new PROPERTY_VALUE(key,value)); }
+ public void addSegment(String segment) { + if (!segment.contains("=")) + throw new IllegalArgumentException("Segment [" + segment + "] contains no '='"); + + PROPERTY_VALUE pv = pathFromSegment(segment); + path.add(pv); + } + @Override public String toString() { StringBuilder builder = new StringBuilder( "Address{" + diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml index 8048100..ee6b902 100644 --- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml @@ -50,31 +50,11 @@ xmlns:c="urn:xmlns:rhq-configuration" >
- <depends plugin="JMX" useClasses="true"/> -
<!-- TODO I think we should introduce an abstract AS7 plugin that contains some base functionality and then ~~ additional 'Personalities' for the kinds of servers (PM, SM, Standalone AS, Managed AS) -->
- <!-- TODO do we want to show the process controller at all? We have no benefit from it - <server name="ProcessController" - discovery="BaseProcessDiscovery" - class="BaseComponent" - description="Reaper process for other AS7 services" - > - - <plugin-configuration> - <c:simple-property name="hostname" default="localhost" required="true"/> - <c:simple-property name="port" default="9990" type="integer" required="true"/> - - </plugin-configuration> - - <process-scan name="ProcessController" query="process|basename|match=^java.*,arg|org.jboss.as.process-controller|match=.*"/> - - - </server> - --> <server name="JBossAS7 Host Controller" discovery="BaseProcessDiscovery" class="HostControllerComponent" @@ -84,8 +64,8 @@ <plugin-configuration> <c:simple-property name="hostname" default="localhost" required="true" description="Host name of the domain API"/> <c:simple-property name="port" default="9990" type="integer" required="true" description="Port of the domain API"/> - <c:simple-property name="user" type="string" description="Management user for a secured Host controller" required="false"/> - <c:simple-property name="password" type="password" description="Password for the management user" required="false"/> + <c:simple-property name="user" type="string" default="rhqadmin" description="Management user for a secured Host controller" required="false"/> + <c:simple-property name="password" type="password" default="rhqadmin" description="Password for the management user" required="false"/> <c:simple-property name="domainConfig" type="string" default="domain.xml" description="Running configuration (domain part)" displayName="Domain Configuration"/> <c:simple-property name="hostConfig" type="string" default="host.xml" description="Running configuration (host part)" displayName="Host Configuration"/> <c:simple-property name="baseDir" type="file" description="Base directory of the server installation" displayName="Base directory" readOnly="true" required="false"/> @@ -179,6 +159,15 @@ <c:simple-property name="operationResult" description="Outcome of the stop operation"/> </results> </operation> + <operation name="installRhqUser" description="Installs a user in the server for management" displayName="Install RHQ user"> + <parameters> + <c:simple-property name="user" displayName="Username" description="Name of the management user" default="rhqadmin"/> + <c:simple-property name="password" displayName="Password" description="Password of this management user" default="rhqadmin" type="password"/> + </parameters> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation>
<metric property="_internal:mgmtRequests" category="performance" dataType="measurement" defaultInterval="120000" @@ -192,6 +181,11 @@ displayType="summary" measurementType="dynamic" description="Max time for a request since last metric get" units="milliseconds" displayName="Maximum request time"/>
+ <metric property="server-state" dataType="trait" displayName="Server state" description="Detailed server state" + displayType="summary"/> + <metric property="release-codename" dataType="trait" displayName="Code name of the release" displayType="summary"/> + <metric property="release-version" dataType="trait" displayName="Version of the server" displayType="summary"/> + <event name="logEntry" description="an entry in a log file"/>
<resource-configuration> @@ -206,11 +200,10 @@ </c:group> -->
- <c:group name="children:extension" displayName="Installed extensions"> - + <c:group name="children:extension" displayName="Installed extensions" hiddenByDefault="true"> <c:list-property name="*" displayName="Installed extensions" readOnly="true" required="false"> <c:map-property name="*" displayName="Name" readOnly="true"> - <c:simple-property name="module" displayName="Module name"/> + <c:simple-property name="module" displayName="Module name" readOnly="true"/> </c:map-property> </c:list-property> </c:group> @@ -332,8 +325,8 @@ <plugin-configuration> <c:simple-property name="hostname" default="localhost" required="true"/> <c:simple-property name="port" default="9990" type="integer" required="true"/> - <c:simple-property name="user" type="string" description="Management user for a secured AS" required="false"/> - <c:simple-property name="password" type="password" description="Password for the management user" required="false"/> + <c:simple-property name="user" default="rhqadmin" type="string" description="Management user for a secured AS" required="false"/> + <c:simple-property name="password" default="rhqadmin" type="password" description="Password for the management user" required="false"/> <c:simple-property name="config" type="string" default="standalone.xml" description="Running configuration" displayName="Configuration"/> <c:simple-property name="baseDir" type="file" description="Base directory of the server installation" displayName="Base directory" readOnly="true" required="false"/> <c:simple-property name="startScript" type="file" default="bin/standalone.sh" description="Script used to start the server. If the path is not absolute, it is relative to the base directory"/> @@ -404,6 +397,15 @@ <c:simple-property name="operationResult"/> </results> </operation> + <operation name="installRhqUser" description="Installs a user in the server for management" displayName="Install RHQ user"> + <parameters> + <c:simple-property name="user" displayName="Username" description="Name of the management user" default="rhqadmin"/> + <c:simple-property name="password" displayName="Password" description="Password of this management user" default="rhqadmin" type="password"/> + </parameters> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation>
<metric property="_internal:mgmtRequests" category="performance" dataType="measurement" defaultInterval="120000" @@ -416,6 +418,11 @@ displayType="summary" measurementType="dynamic" description="Max time for a request since last metric get" units="milliseconds" displayName="Maximum request time"/>
+ <metric property="server-state" dataType="trait" displayName="Server state" description="Detailed server state" + displayType="summary"/> + <metric property="release-codename" dataType="trait" displayName="Code name of the release" displayType="summary"/> + <metric property="release-version" dataType="trait" displayName="Version of the server" displayType="summary"/> + <event name="logEntry" description="an entry in a log file"/>
<resource-configuration> @@ -431,11 +438,10 @@ </c:group> -->
- <c:group name="children:extension" displayName="Installed extensions"> - + <c:group name="children:extension" displayName="Installed extensions" hiddenByDefault="true"> <c:list-property name="*" displayName="Installed extensions" readOnly="true" required="false"> <c:map-property name="*" displayName="Name" readOnly="true"> - <c:simple-property name="module" displayName="Module name"/> + <c:simple-property name="module" displayName="Module name" readOnly="true"/> </c:map-property> </c:list-property> </c:group> @@ -515,31 +521,98 @@ </results> </operation>
- <metric property="status" dataType="trait" displayName="Server state" description="Detailed server state" + <metric property="server-state" dataType="trait" displayName="Server state" description="Detailed server state" displayType="summary"/> + <metric property="release-codename" dataType="trait" displayName="Code name of the release" displayType="summary"/> + <metric property="release-version" dataType="trait" displayName="Version of the server" displayType="summary"/>
<event name="logEntry" description="an entry in a log file"/>
</server>
- <server name="JBoss AS JVM" - description="JVM of the JBossAS" - sourcePlugin="JMX" - sourceType="JMX Server" - discovery="org.rhq.plugins.jmx.EmbeddedJMXServerDiscoveryComponent" - class="org.rhq.plugins.jmx.JMXServerComponent" - singleton="true"> + <server name="JVM" + discovery="SubsystemDiscovery" + class="BaseComponent" + description="Information about the underlying JVM" + singleton="true"> <runs-inside> <parent-resource-type name="JBossAS7 Managed Server" plugin="jboss-as-7"/> <parent-resource-type name="JBossAS7 Standalone Server" plugin="jboss-as-7"/> </runs-inside> - </server>
- <server name="Messaging" + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="core-service=platform-mbean"/> + </plugin-configuration> + + <service name="Operating System" + discovery="SubsystemDiscovery" + class="BaseComponent" + singleton="true" + > + + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="type=operating-system"/> + </plugin-configuration> + + <metric property="available-processors" + description="The number of processors available to the Java virtual machine."/> + <metric property="system-load-average" + description="The system load average for the last minute. The load average may not be available on some platforms; if the load average is not available, a negative value is returned."/> + </service> + + <service name="Runtime" + discovery="SubsystemDiscovery" + class="BaseComponent" + singleton="true" + > + + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="type=runtime"/> + </plugin-configuration> + + <metric property="uptime" description="The uptime of the Java virtual machine in milliseconds."/> + </service> + + <service name="Threading" + discovery="SubsystemDiscovery" + class="BaseComponent" + > + + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="type=threading"/> + </plugin-configuration> + + <metric property="thread-count" description="The current number of live threads including both daemon and non-daemon threads."/> + <metric property="peak-thread-count" description="The peak live thread count since the Java virtual machine started or peak was reset."/> + <metric property="total-started-thread-count" description="The total number of threads created and also started since the Java virtual machine started."/> + <metric property="daemon-thread-count" description="The current number of live daemon threads."/> + <metric property="current-thread-cpu-time" description="The total CPU time for the current thread in nanoseconds, or -1 if 'thread-cpu-time-enabled' is 'false'. A Java virtual machine implementation may not support CPU time measurement. If 'thread-cpu-time-supported', is 'false' undefined."/> + <metric property="current-thread-user-time" description="The CPU time that the current thread has executed in user mode in nanoseconds, or -1 if 'thread-cpu-time-enabled' is 'false'. A Java virtual machine implementation may not support CPU time measurement. If 'thread-cpu-time-supported', is 'false' the result will be undefined "/> + + <resource-configuration> + <c:simple-property name="thread-contention-monitoring-enabled" required="false" type="boolean" readOnly="false" description="Whether thread contention monitoring is enabled."/> + <c:simple-property name="thread-cpu-time-enabled" required="false" type="boolean" readOnly="false" description="Whether thread CPU time measurement is enabled."/> + <c:list-property name="all-thread-ids" description="All live thread IDs. If a security manager is installed and the caller does not have ManagementPermission('monitor'), the result will be und + ." > + <c:simple-property name="all-thread-ids" /> + </c:list-property> + <c:simple-property name="thread-contention-monitoring-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine supports thread contention monitoring."/> + <c:simple-property name="thread-cpu-time-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine implementation supports CPU time measurement for any thread."/> + <c:simple-property name="current-thread-cpu-time-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine supports CPU time measurement for the current thread."/> + <c:simple-property name="object-monitor-usage-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine supports monitoring of object monitor usage."/> + <c:simple-property name="synchronizer-usage-supported" required="false" type="boolean" readOnly="true" description="Whether the Java virtual machine supports monitoring of ownable synchronizer usage."/> + </resource-configuration> + </service> + + + + </server> + + <server name="Messaging-Provider" discovery="SubsystemDiscovery" class="BaseComponent" - description="The HornetQ based messaging subsystem" + description="The messaging subsystems" singleton="true" > <runs-inside> @@ -551,82 +624,94 @@ <c:simple-property name="path" readOnly="true" default="subsystem=messaging"/> </plugin-configuration>
- <operation name="destination:add" displayName="Add destination" description="Add a Queue or Topic"> - <parameters> - <c:simple-property name="name" description="Name of the Destination" required="true"/> - <c:list-property name="entries" description="The JNDI names the destination should be bound to." required="true"> - <c:simple-property name="entry" description="A single JNDI name. Note, this is relative to java:jboss/jms/"/> - </c:list-property> - <c:simple-property name="type" description="Type of Destination to create" default="Queue"> - <c:property-options> - <c:option value="jms-queue" name="Queue"/> - <c:option value="jms-topic" name="Topic"/> - </c:property-options> - </c:simple-property> - <c:simple-property name="durable" description="Defines whether the queue is durable (for Queues only)." type="boolean" default="false"/> - </parameters> - <results> - <c:simple-property name="operationResult"/> - </results> - </operation> - <operation name="destination:remove" displayName="Remove Destination" description="Remove a destination"> - <parameters> - <c:simple-property name="name" description="Name of the Destination" required="true"/> - </parameters> - <results> - <c:simple-property name="operationResult"/> - </results> - </operation> - - <resource-configuration> - <c:simple-property name="journal-min-files" /> - <c:simple-property name="journal-type" /> - </resource-configuration> + <server name="HornetQ" + discovery="SubsystemDiscovery" + class="BaseComponent" + description="The HornetQ based messaging subsystem" + >
- <service name="JMS Queue" - discovery="SubsystemDiscovery" - class="JmsComponent" - createDeletePolicy="delete-only" - > <plugin-configuration> - <c:simple-property name="path" readOnly="true" default="jms-queue"/> + <c:simple-property name="path" readOnly="true" default="hornetq-server"/> </plugin-configuration>
+ + <operation name="destination:add" displayName="Add destination" description="Add a Queue or Topic"> + <parameters> + <c:simple-property name="name" description="Name of the Destination" required="true"/> + <c:list-property name="entries" description="The JNDI names the destination should be bound to." required="true"> + <c:simple-property name="entry" description="A single JNDI name. Note, this is relative to java:jboss/jms/"/> + </c:list-property> + <c:simple-property name="type" description="Type of Destination to create" default="Queue"> + <c:property-options> + <c:option value="jms-queue" name="Queue"/> + <c:option value="jms-topic" name="Topic"/> + </c:property-options> + </c:simple-property> + <c:simple-property name="durable" description="Defines whether the queue is durable (for Queues only)." type="boolean" default="false"/> + </parameters> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation> + <operation name="destination:remove" displayName="Remove Destination" description="Remove a destination"> + <parameters> + <c:simple-property name="name" description="Name of the Destination" required="true"/> + </parameters> + <results> + <c:simple-property name="operationResult"/> + </results> + </operation> + <resource-configuration> - <c:simple-property name="durable" required="false" type="boolean" readOnly="true" default="false" - description="Whether the queue is durable or not."/> - <c:list-property name="entries" required="false" readOnly="true" - description="The jndi names the queue will be bound to."> - <c:simple-property name="entries" type="string"/> - </c:list-property> - <c:simple-property name="selector" required="false" type="string" readOnly="true" description="The queue selector."/> - </resource-configuration> - </service> - <service name="JMS Topic" - discovery="SubsystemDiscovery" - class="JmsComponent" - createDeletePolicy="delete-only" - > - <plugin-configuration> - <c:simple-property name="path" readOnly="true" default="jms-topic"/> - </plugin-configuration> - <resource-configuration> - <c:list-property name="entries" required="false" readOnly="true" - description="The jndi names the queue will be bound to."> - <c:simple-property name="entries" type="string"/> - </c:list-property> + <c:simple-property name="journal-min-files" /> + <c:simple-property name="journal-type" /> </resource-configuration> - </service> - <service name="Connection-Factory" - discovery="SubsystemDiscovery" - class="JmsComponent" - createDeletePolicy="both" - > - <plugin-configuration> - <c:simple-property name="path" readOnly="true" default="connection-factory"/> - </plugin-configuration> - </service>
+ <service name="JMS Queue" + discovery="SubsystemDiscovery" + class="JmsComponent" + createDeletePolicy="delete-only" + > + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="jms-queue"/> + </plugin-configuration> + + <resource-configuration> + <c:simple-property name="durable" required="false" type="boolean" readOnly="true" default="false" + description="Whether the queue is durable or not."/> + <c:list-property name="entries" required="false" readOnly="true" + description="The jndi names the queue will be bound to."> + <c:simple-property name="entries" type="string"/> + </c:list-property> + <c:simple-property name="selector" required="false" type="string" readOnly="true" description="The queue selector."/> + </resource-configuration> + </service> + <service name="JMS Topic" + discovery="SubsystemDiscovery" + class="JmsComponent" + createDeletePolicy="delete-only" + > + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="jms-topic"/> + </plugin-configuration> + <resource-configuration> + <c:list-property name="entries" required="false" readOnly="true" + description="The jndi names the queue will be bound to."> + <c:simple-property name="entries" type="string"/> + </c:list-property> + </resource-configuration> + </service> + <service name="Connection-Factory" + discovery="SubsystemDiscovery" + class="JmsComponent" + createDeletePolicy="both" + > + <plugin-configuration> + <c:simple-property name="path" readOnly="true" default="connection-factory"/> + </plugin-configuration> + </service> + + </server> </server>
<server name="JBossWeb" @@ -649,61 +734,64 @@ description="The web container's default virtual server."/> <c:simple-property name="native" required="false" type="boolean" readOnly="true" defaultValue="true" description="Add the native initialization listener to the web container."/> - <c:map-property name="configuration" description="The common web container configuration." > - <c:map-property name="static-resources" description="Configuration for static resources" > - <c:simple-property name="listings" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="instance-id" readOnly="true" required="false" type="string" description="The identifier for this server instance."/> + <c:group name="child:configuration=static-resources" displayName="Static Resources" > + <c:simple-property name="listings" required="false" type="boolean" defaultValue="false" description="Enable folder listings."/> - <c:simple-property name="sendfile" required="false" type="integer" readOnly="true" defaultValue="49152" + <c:simple-property name="sendfile" required="false" type="integer" defaultValue="49152" description="Enable sendfile if possible, for files bigger than the specified byte size."/> - <c:simple-property name="read-only" required="false" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="file-encoding" required="false" description="Force a file encoding." type="string"/> + <c:simple-property name="read-only" required="false" type="boolean" defaultValue="true" description="Allow write HTTP methods (PUT, DELETE)."/> - <c:simple-property name="webdav" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="webdav" required="false" type="boolean" defaultValue="false" description="Enable WebDAV functionality."/> <c:simple-property name="secret" required="false" type="string" readOnly="true" description="Secret for WebDAV locking operations."/> - <c:simple-property name="max-depth" required="false" type="integer" readOnly="true" defaultValue="3" + <c:simple-property name="max-depth" required="false" type="integer" defaultValue="3" description="Maximum recursion for PROPFIND."/> - <c:simple-property name="disabled" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="disabled" required="false" type="boolean" defaultValue="false" + description="Enable the default Servlet mapping."/> + </c:group> + <c:group name="child:configuration=jsp-configuration" displayName="JSP Configuration"> + <c:simple-property name="development" required="false" type="boolean" default="false" + description="Enable the development mode, which gives more information when an error occurs. And also enables automatic JSP recompiles."/> + <c:simple-property name="disabled" required="false" type="boolean" defaultValue="false" description="Enable the JSP container."/> - </c:map-property> - <c:map-property name="jsp-configuration" description="JSP container configuration"> - <c:simple-property name="development" required="false" type="boolean" readOnly="true" defaultValue="false" - description="Enable the development mode, which gives more information when an error occurs."/> - <c:simple-property name="file-encoding" required="false" type="string" readOnly="true" description="Force a file encoding."/> - <c:simple-property name="keep-generated" required="false" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="keep-generated" required="false" type="boolean" defaultValue="true" description="Keep the generated Servlets."/> <c:simple-property name="trim-spaces" required="false" type="boolean" readOnly="true" defaultValue="true" - description="Trim some spaces from the generated Servlet."/> - <c:simple-property name="tag-pooling" required="false" type="boolean" readOnly="true" defaultValue="true" + description="Trim some spaces from the generated Servlet."/> <!-- TODO make r/w when https://issues.jboss.org/browse/AS7-3097 is solved --> + <c:simple-property name="tag-pooling" required="false" type="boolean" defaultValue="true" description="Enable tag pooling."/> - <c:simple-property name="mapped-file" required="false" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="mapped-file" required="false" type="boolean" defaultValue="true" description="Map to the JSP source."/> - <c:simple-property name="check-interval" required="false" type="integer" readOnly="true" defaultValue="0" - description="Check interval for JSP updates using a background thread."/> - <c:simple-property name="modification-test-interval" required="false" type="integer" readOnly="true" defaultValue="4" + <c:simple-property name="check-interval" required="false" type="integer" defaultValue="60" + description="Check interval for JSP updates using a background thread."/> <!-- TODO revisit default when https://issues.jboss.org/browse/AS7-3098 is fixed --> + <c:simple-property name="modification-test-interval" required="false" type="integer" defaultValue="4" description="Minimum amount of time between two tests for updates, in seconds."/> - <c:simple-property name="recompile-on-fail" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="recompile-on-fail" required="false" type="boolean" defaultValue="false" description="Retry failed JSP compilations on each request."/> - <c:simple-property name="smap" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="smap" required="false" type="boolean" defaultValue="false" description="Enable SMAP."/> - <c:simple-property name="dump-smap" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="dump-smap" required="false" type="boolean" defaultValue="false" description="Write SMAP data to a file."/> - <c:simple-property name="generate-strings-as-char-arrays" required="false" type="boolean" readOnly="true" + <c:simple-property name="generate-strings-as-char-arrays" required="false" type="boolean" defaultValue="false" description="Generate String constants as char arrays."/> - <c:simple-property name="error-on-use-bean-invalid-class-attribute" required="false" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="error-on-use-bean-invalid-class-attribute" required="false" type="boolean" defaultValue="false" description="Enable errors when using a bad class in useBean."/> - <c:simple-property name="scratch-dir" required="false" type="string" readOnly="true" description="Specify a different work directory."/> - <c:simple-property name="source-vm" required="false" type="string" readOnly="true" defaultValue="1.5" + <c:simple-property name="scratch-dir" required="false" type="string" description="Specify a different work directory."/> + <c:simple-property name="source-vm" required="false" type="string" defaultValue="1.5" description="Source VM level for compilation."/> - <c:simple-property name="target-vm" required="false" type="string" readOnly="true" defaultValue="1.5" + <c:simple-property name="target-vm" required="false" type="string" defaultValue="1.5" description="Target VM level for compilation."/> - <c:simple-property name="java-encoding" required="false" type="string" readOnly="true" defaultValue="UTF-8" + <c:simple-property name="java-encoding" required="false" type="string" defaultValue="UTF-8" description="Specify the encoding used for Java sources."/> - <c:simple-property name="x-powered-by" required="false" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="x-powered-by" required="false" type="boolean" defaultValue="true" description="Enable advertising the JSP engine in x-powered-by."/> - <c:simple-property name="display-source-fragment" required="false" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="display-source-fragment" required="false" type="boolean" defaultValue="true" description="When a runtime error occurs, attempts to display corresponding JSP source fragment."/> - </c:map-property> + </c:group> + <!-- <c:group name="child:configuration=container" displayName="Container"> <c:list-property name="mime-mapping" description="A mime-mapping definition." > <c:map-property name="mime-mapping" > <c:simple-property name="name" description="A MIME mapping name"/> @@ -713,8 +801,8 @@ <c:list-property name="welcome-file" description="A welcome file declaration." > <c:simple-property name="welcome-file" /> </c:list-property> - </c:map-property> - </resource-configuration> + </c:group> +--> </resource-configuration>
<service name="Connector" discovery="SubsystemDiscovery" @@ -726,41 +814,41 @@ </plugin-configuration>
- <metric property="bytesSent" measurementType="trendsup"/> - <metric property="bytesReceived" measurementType="trendsup"/> - <metric property="processingTime" measurementType="trendsup" units="milliseconds"/> - <metric property="errorCount" measurementType="trendsup" displayType="summary"/> - <metric property="maxTime" units="milliseconds"/> - <metric property="requestCount" measurementType="trendsup" displayType="summary"/> + <metric property="bytesSent" measurementType="trendsup" description="Number of byte sent by the connector."/> + <metric property="bytesReceived" measurementType="trendsup" description="Number of byte received by the connector (POST data)."/> + <metric property="processingTime" measurementType="trendsup" units="milliseconds" description="Processing time used by the connector. Im milli-seconds."/> + <metric property="errorCount" measurementType="trendsup" displayType="summary" description="Number of error that occurs when processing requests by the connector."/> + <metric property="maxTime" units="milliseconds" description="Max time spent to process a requests."/> + <metric property="requestCount" measurementType="trendsup" displayType="summary" description="Number of the request processed by the connector."/>
<resource-configuration> - <c:simple-property name="protocol" required="true" type="string" readOnly="true" description="The web connector protocol."/> - <c:simple-property name="socket-binding" required="true" type="string" readOnly="true" + <c:simple-property name="protocol" required="true" type="string" description="The web connector protocol."/> + <c:simple-property name="socket-binding" required="true" type="string" description="The web connector socket-binding reference, this connector should be bound to."> <c:option-source target="configuration" expression="socket-binding=name:type=SocketBindingGroup"/> <!-- TODO different for Domain vs standalone --> </c:simple-property> - <c:simple-property name="scheme" type="string" readOnly="true" default="http" description="The web connector scheme." required="true"/> - <c:simple-property name="executor" type="string" readOnly="true" required="false" + <c:simple-property name="scheme" type="string" default="http" description="The web connector scheme." required="true"/> + <c:simple-property name="executor" type="string" required="false" description="The name of the executor that should be used for the processing threads of this connector. Defaults to using an internal pool."/> - <c:simple-property name="enabled" type="boolean" readOnly="true" defaultValue="true" + <c:simple-property name="enabled" type="boolean" default="true" description="Defines whether the connector should be started on startup."/> - <c:simple-property name="enable-lookups" type="boolean" readOnly="true" defaultValue="false" + <c:simple-property name="enable-lookups" type="boolean" defaultValue="false" description="Enable DNS lookups for Servlet API."/> - <c:simple-property name="proxy-name" type="string" readOnly="true" required="false" + <c:simple-property name="proxy-name" type="string" required="false" description="The host name that will be used when sending a redirect. The default value is null."/> - <c:simple-property name="proxy-port" type="integer" readOnly="true" required="false" + <c:simple-property name="proxy-port" type="integer" required="false" description="The port that will be used when sending a redirect."/> - <c:simple-property name="max-post-size" type="integer" readOnly="true" defaultValue="2097152" + <c:simple-property name="max-post-size" type="integer" defaultValue="2097152" description="Maximum size in bytes of a POST request that can be parsed by the container."/> - <c:simple-property name="max-save-post-size" type="integer" readOnly="true" defaultValue="4096" + <c:simple-property name="max-save-post-size" type="integer" defaultValue="4096" description="Maximum size in bytes of a POST request that will be saved during certain authentication schemes."/> <c:simple-property name="secure" type="boolean" readOnly="true" defaultValue="false" description="Indicates if content sent or recieved by the connector is secured from the user perspective."/> <c:simple-property name="redirect-port" type="integer" readOnly="true" defaultValue="8443" description="The port for redirection to a secure connector."/> - <c:simple-property name="max-connections" type="integer" readOnly="true" required="false" + <c:simple-property name="max-connections" type="integer" required="false" description="Amount of concurrent connections that can be processed by the connector with optimum performance. The default value depends on the connector used."/> - <c:list-property name="virtual-server" description="The list of virtual servers that can be accessed through this connector. The default is to allow all virtual servers." readOnly="true" required="false"> + <c:list-property name="virtual-server" description="The list of virtual servers that can be accessed through this connector. The default is to allow all virtual servers." required="false"> <c:simple-property name="virtual-server" /> </c:list-property> <c:map-property name="ssl" description="The SSL configuration of the connector." readOnly="true" required="false"> @@ -795,10 +883,10 @@ </plugin-configuration>
<resource-configuration> - <c:list-property name="alias" > + <c:list-property name="alias" description="The virtual server aliases" displayName="Virtual server aliases" > <c:simple-property name="alias" /> </c:list-property> - <c:simple-property name="default-web-module" type="string" readOnly="true" defaultValue="ROOT.war" + <c:simple-property name="default-web-module" type="string" defaultValue="ROOT.war" description="The web module deployment name that will be mapped as the root webapp."/> <c:map-property name="access-log" description="The access log configuration for this virtual server." > <c:simple-property name="pattern" type="string" readOnly="true" defaultValue="common" required="false" description="The access log pattern."/> @@ -825,7 +913,7 @@ </c:list-property> </c:map-property> </c:list-property> - <c:simple-property name="enable-welcome-root" type="boolean" /> + <c:simple-property name="enable-welcome-root" type="boolean" description="Whether or not the bundled welcome directory is used as the root web context."/> </resource-configuration> </service>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java index 16c94f9..0266071 100644 --- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/AbstractConfigurationHandlingTest.java @@ -28,7 +28,6 @@ import javax.xml.bind.util.ValidationEventCollector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codehaus.jackson.JsonNode; -import org.testng.annotations.BeforeSuite;
import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser; import org.rhq.core.clientapi.agent.metadata.InvalidPluginDescriptorException; @@ -97,7 +96,7 @@ public class AbstractConfigurationHandlingTest { JsonNode content;
public FakeConnection() { - super("localhost", 1234); + super("localhost", 1234, "fake", "fake"); }
public void setContent(JsonNode content) { diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java index d021ab2..a512133 100644 --- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java @@ -62,7 +62,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest conf.put(new PropertySimple("needed","test")); conf.put(new PropertySimple("optional",null));
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, null);
assert cop.numberOfSteps() == 1; Operation step1 = cop.step(0); @@ -89,7 +89,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
conf.put(propertyList);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, null);
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -120,7 +120,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
conf.put(propertyMap);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, null);
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -148,7 +148,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
conf.put(propertyMap);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, null);
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -176,7 +176,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
conf.put(propertyMap);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, null);
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -207,7 +207,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
conf.put(propertyList);
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, null);
assert cop.numberOfSteps() == 1 : "#Steps should be 1 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -240,7 +240,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest conf.put(propertyList); conf.put(new PropertySimple("port-offset",0));
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, null);
assert cop.numberOfSteps() == 3 : "#Steps should be 3 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); @@ -289,7 +289,7 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest conf.put(propertyList); conf.put(new PropertySimple("port-offset",0));
- CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf); + CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, null);
assert cop.numberOfSteps() == 5 : "#Steps should be 5 but were " + cop.numberOfSteps(); Operation step1 = cop.step(0); diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java new file mode 100644 index 0000000..2365d19 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/XmlFileReadingTest.java @@ -0,0 +1,133 @@ +package org.rhq.modules.plugins.jbossas7; + +import java.net.URL; + +import org.testng.annotations.Test; + +/** + * Test the ability to read information from the AS7 xml files (standalone.xml and so on) + * @author Heiko W. Rupp + */ +@Test +public class XmlFileReadingTest { + + public void hostPort70() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("standalone70.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + AbstractBaseDiscovery.HostPort hp = bd.getManagementPortFromHostXml(new String[]{}); + System.out.println(hp); + assert hp.host.equals("127.0.0.70") : "Host is " + hp.host; + assert hp.port==19990 : "Port is " + hp.port; + } + + public void hostPort71() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("standalone71.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + AbstractBaseDiscovery.HostPort hp = bd.getManagementPortFromHostXml(new String[]{}); + System.out.println(hp); + // hp : HostPort{host='localhost', port=9990, isLocal=true} + assert hp.host.equals("127.0.0.71") : "Host is " + hp.host; + assert hp.port==29990 : "Port is " + hp.port; + } + + public void domainController1() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("host1.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + AbstractBaseDiscovery.HostPort hp = bd.getDomainControllerFromHostXml(); + assert hp.isLocal : "DC is not local as expected: " + hp; + + } + + public void domainController2() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("host2.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + AbstractBaseDiscovery.HostPort hp = bd.getDomainControllerFromHostXml(); + assert "192.168.100.1".equals(hp.host) : "DC is at " + hp.host; + assert hp.port == 9559 : "DC port is at " + hp.port; + } + + + + public void testXpath70() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("standalone70.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + +/* + String realm = bd.obtainXmlPropertyViaXPath("/management/management-interfaces/http-interface/@security-realm"); + assert "ManagementRealm".equals(realm) : "Realm was " + realm; +*/ + + String pathExpr = "//management/management-interfaces/http-interface/@port"; + String port = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "19990".equals(port) : "Port was [" + port + "]"; + + pathExpr = "//management/management-interfaces/http-interface/@interface"; + String interfName = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "management".equals(interfName) : "Interface was " + interfName; + + pathExpr = "/server/interfaces/interface[@name='" + interfName + "']/inet-address/@value"; + String interfElem = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "${jboss.bind.address.management:127.0.0.70}".equals(interfElem) : "InterfElem was " + interfElem; + + } + + + public void testXpath71() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("standalone71.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + String realm = bd.obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@security-realm"); + assert "ManagementRealm".equals(realm) : "Realm was " + realm; + String sbindingRef = bd.obtainXmlPropertyViaXPath( + ("//management/management-interfaces/http-interface/socket-binding/@http")); + assert "management-http".equals(sbindingRef): "Socketbinding was " + sbindingRef; + + String pathExpr = "/server/socket-binding-group/socket-binding[@name='" + sbindingRef + "']/@port"; + String port = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "29990".equals(port) : "Port was [" + port + "]"; + + pathExpr = "/server/socket-binding-group/socket-binding[@name='" + sbindingRef + "']/@interface"; + String interfName = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "management".equals(interfName) : "Interface was " + interfName; + + pathExpr = "/server/interfaces/interface[@name='" + interfName + "']/inet-address/@value"; + String interfElem = bd.obtainXmlPropertyViaXPath(pathExpr); + assert "${jboss.bind.address.management:127.0.0.71}".equals(interfElem) : "InterfElem was " + interfElem; + + } + + public void testGetRealm() throws Exception { + + BaseProcessDiscovery bd = new BaseProcessDiscovery(); + URL url = getClass().getClassLoader().getResource("standalone71.xml"); + bd.readStandaloneOrHostXmlFromFile(url.getFile()); + + String realm = bd.obtainXmlPropertyViaXPath("//management/management-interfaces/http-interface/@security-realm"); + assert "ManagementRealm".equals(realm) : "Realm was " + realm; + + String xpathExpression = "//management//security-realm[@name ='%s']/authentication/properties/@path"; + + String propsFileName = bd.obtainXmlPropertyViaXPath(String.format(xpathExpression,realm)); + assert "mgmt-users.properties".equals(propsFileName) : "File name was " + propsFileName; + + String propsFilePathRel = bd.obtainXmlPropertyViaXPath("//management//security-realm[@name ='" + realm + "']/authentication/properties/@relative-to"); + assert "jboss.server.config.dir".equals(propsFilePathRel) : "Path was " + propsFileName; + + } +} diff --git a/modules/plugins/jboss-as-7/src/test/resources/host1.xml b/modules/plugins/jboss-as-7/src/test/resources/host1.xml new file mode 100644 index 0000000..2e35b78 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/resources/host1.xml @@ -0,0 +1,92 @@ +<!-- + ~ JBoss, Home of Professional Open Source. + ~ Copyright 2010, Red Hat, Inc., and individual contributors + ~ as indicated by the @author tags. See the copyright.txt file in the + ~ distribution for a full listing of individual contributors. + ~ + ~ This is free software; you can redistribute it and/or modify it + ~ under the terms of the GNU Lesser General Public License as + ~ published by the Free Software Foundation; either version 2.1 of + ~ the License, or (at your option) any later version. + ~ + ~ This software is distributed in the hope that it will be useful, + ~ but WITHOUT ANY WARRANTY; without even the implied warranty of + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + ~ Lesser General Public License for more details. + ~ + ~ You should have received a copy of the GNU Lesser General Public + ~ License along with this software; if not, write to the Free + ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. + --> + +<host xmlns="urn:jboss:domain:1.1" + name="master"> + + <management> + <security-realms> + <security-realm name="ManagementRealm"> + <authentication> + <properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/> + </authentication> + </security-realm> + </security-realms> + <management-interfaces> + <native-interface security-realm="ManagementRealm"> + <socket interface="management" port="9999"/> + </native-interface> + <http-interface security-realm="ManagementRealm"> + <socket interface="management" port="9990"/> + </http-interface> + </management-interfaces> + </management> + + <domain-controller> + <local/> + <!-- Alternative remote domain controller configuration with a host and port --> + <!-- <remote host="192.168.100.1" port="9999"/> --> + </domain-controller> + + <interfaces> + <interface name="management"> + <inet-address value="${jboss.bind.address.management:127.0.0.1}"/> + </interface> + <interface name="public"> + <inet-address value="${jboss.bind.address:127.0.0.1}"/> + </interface> + </interfaces> + + <jvms> + <jvm name="default"> + <heap size="64m" max-size="128m"/> + </jvm> + </jvms> + + <servers> + <server name="server-one" group="main-server-group"> + <!-- server-one inherits the default socket-group declared in the server-group --> + <jvm name="default"> + <!-- Remote JPDA debugging for a specific server + <jvm-options> + <option value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"/> + </jvm-options> + --> + </jvm> + </server> + + <server name="server-two" group="main-server-group" auto-start="true"> + <!-- server-two avoids port conflicts by incrementing the ports in + the default socket-group declared in the server-group --> + <socket-binding-group ref="standard-sockets" port-offset="150"/> + <jvm name="default"> + <heap size="64m" max-size="256m"/> + </jvm> + </server> + + <server name="server-three" group="other-server-group" auto-start="false"> + <!-- server-three avoids port conflicts by incrementing the ports in + the default socket-group declared in the server-group --> + <socket-binding-group ref="ha-sockets" port-offset="250"/> + </server> + </servers> +</host> diff --git a/modules/plugins/jboss-as-7/src/test/resources/host2.xml b/modules/plugins/jboss-as-7/src/test/resources/host2.xml new file mode 100644 index 0000000..38ada1a --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/resources/host2.xml @@ -0,0 +1,91 @@ +<!-- + ~ JBoss, Home of Professional Open Source. + ~ Copyright 2010, Red Hat, Inc., and individual contributors + ~ as indicated by the @author tags. See the copyright.txt file in the + ~ distribution for a full listing of individual contributors. + ~ + ~ This is free software; you can redistribute it and/or modify it + ~ under the terms of the GNU Lesser General Public License as + ~ published by the Free Software Foundation; either version 2.1 of + ~ the License, or (at your option) any later version. + ~ + ~ This software is distributed in the hope that it will be useful, + ~ but WITHOUT ANY WARRANTY; without even the implied warranty of + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + ~ Lesser General Public License for more details. + ~ + ~ You should have received a copy of the GNU Lesser General Public + ~ License along with this software; if not, write to the Free + ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. + --> + +<host xmlns="urn:jboss:domain:1.1" + name="master"> + + <management> + <security-realms> + <security-realm name="ManagementRealm"> + <authentication> + <properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/> + </authentication> + </security-realm> + </security-realms> + <management-interfaces> + <native-interface security-realm="ManagementRealm"> + <socket interface="management" port="9999"/> + </native-interface> + <http-interface security-realm="ManagementRealm"> + <socket interface="management" port="9990"/> + </http-interface> + </management-interfaces> + </management> + + <domain-controller> + <!-- Alternative remote domain controller configuration with a host and port --> + <remote host="192.168.100.1" port="9559"/> + </domain-controller> + + <interfaces> + <interface name="management"> + <inet-address value="${jboss.bind.address.management:127.0.0.1}"/> + </interface> + <interface name="public"> + <inet-address value="${jboss.bind.address:127.0.0.1}"/> + </interface> + </interfaces> + + <jvms> + <jvm name="default"> + <heap size="64m" max-size="128m"/> + </jvm> + </jvms> + + <servers> + <server name="server-one" group="main-server-group"> + <!-- server-one inherits the default socket-group declared in the server-group --> + <jvm name="default"> + <!-- Remote JPDA debugging for a specific server + <jvm-options> + <option value="-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"/> + </jvm-options> + --> + </jvm> + </server> + + <server name="server-two" group="main-server-group" auto-start="true"> + <!-- server-two avoids port conflicts by incrementing the ports in + the default socket-group declared in the server-group --> + <socket-binding-group ref="standard-sockets" port-offset="150"/> + <jvm name="default"> + <heap size="64m" max-size="256m"/> + </jvm> + </server> + + <server name="server-three" group="other-server-group" auto-start="false"> + <!-- server-three avoids port conflicts by incrementing the ports in + the default socket-group declared in the server-group --> + <socket-binding-group ref="ha-sockets" port-offset="250"/> + </server> + </servers> +</host> diff --git a/modules/plugins/jboss-as-7/src/test/resources/standalone70.xml b/modules/plugins/jboss-as-7/src/test/resources/standalone70.xml new file mode 100644 index 0000000..e07b9ef --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/resources/standalone70.xml @@ -0,0 +1,433 @@ +<!-- + ~ JBoss, Home of Professional Open Source. + ~ Copyright 2011, Red Hat, Inc., and individual contributors + ~ as indicated by the @author tags. See the copyright.txt file in the + ~ distribution for a full listing of individual contributors. + ~ + ~ This is free software; you can redistribute it and/or modify it + ~ under the terms of the GNU Lesser General Public License as + ~ published by the Free Software Foundation; either version 2.1 of + ~ the License, or (at your option) any later version. + ~ + ~ This software is distributed in the hope that it will be useful, + ~ but WITHOUT ANY WARRANTY; without even the implied warranty of + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + ~ Lesser General Public License for more details. + ~ + ~ You should have received a copy of the GNU Lesser General Public + ~ License along with this software; if not, write to the Free + ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. + --> + +<server xmlns="urn:jboss:domain:1.1"> + + <extensions> + <extension module="org.jboss.as.clustering.infinispan"/> + <extension module="org.jboss.as.connector"/> + <extension module="org.jboss.as.deployment-scanner"/> + <extension module="org.jboss.as.ee"/> + <extension module="org.jboss.as.ejb3"/> + <extension module="org.jboss.as.jacorb"/> + <extension module="org.jboss.as.jaxrs"/> + <extension module="org.jboss.as.jmx"/> + <extension module="org.jboss.as.jpa"/> + <extension module="org.jboss.as.logging"/> + <extension module="org.jboss.as.mail"/> + <extension module="org.jboss.as.messaging"/> + <extension module="org.jboss.as.naming"/> + <extension module="org.jboss.as.osgi"/> + <extension module="org.jboss.as.remoting"/> + <extension module="org.jboss.as.sar"/> + <extension module="org.jboss.as.security"/> + <extension module="org.jboss.as.threads"/> + <extension module="org.jboss.as.transactions"/> + <extension module="org.jboss.as.web"/> + <extension module="org.jboss.as.webservices"/> + <extension module="org.jboss.as.weld"/> + </extensions> + + <management> + <security-realms> + <security-realm name="PropertiesMgmtSecurityRealm"> + <authentication> + <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/> + </authentication> + </security-realm> + </security-realms> + <management-interfaces> + <native-interface interface="management" port="9999"/> + <http-interface interface="management" port="19990"/> + </management-interfaces> + </management> + + <profile> + <subsystem xmlns="urn:jboss:domain:logging:1.1"> + <console-handler name="CONSOLE"> + <level name="INFO"/> + <formatter> + <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> + </formatter> + </console-handler> + + <periodic-rotating-file-handler name="FILE"> + <level name="INFO"/> + <formatter> + <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> + </formatter> + <file relative-to="jboss.server.log.dir" path="server.log"/> + <suffix value=".yyyy-MM-dd"/> + </periodic-rotating-file-handler> + + <logger category="com.arjuna"> + <level name="WARN"/> + </logger> + <logger category="org.apache.tomcat.util.modeler"> + <level name="WARN"/> + </logger> + <logger category="sun.rmi"> + <level name="WARN"/> + </logger> + <logger category="jacorb"> + <level name="WARN"/> + </logger> + <!-- set jacorb.config to ERROR to avoid the "jacorb.properties not found" messages during startup --> + <logger category="jacorb.config"> + <level name="ERROR"/> + </logger> + + <root-logger> + <level name="INFO"/> + <handlers> + <handler name="CONSOLE"/> + <handler name="FILE"/> + </handlers> + </root-logger> + </subsystem> + <subsystem xmlns="urn:jboss:domain:datasources:1.0"> + <datasources> + <datasource jndi-name="java:jboss/datasources/ExampleDS" enabled="true" use-java-context="true" + pool-name="H2DS"> + <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url> + <driver>h2</driver> + <pool></pool> + <security> + <user-name>sa</user-name> + <password>sa</password> + </security> + </datasource> + <drivers> + <driver name="h2" module="com.h2database.h2"> + <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> + </driver> + </drivers> + </datasources> + </subsystem> + <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.0"> + <deployment-scanner scan-interval="5000" relative-to="jboss.server.base.dir" path="deployments"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:ee:1.0" /> + <subsystem xmlns="urn:jboss:domain:ejb3:1.2" > + + <remote connector-ref="remoting-connector" thread-pool-name="default" /> + <async thread-pool-name="default" /> + + <timer-service thread-pool-name="default" > + <data-store path="timer-service-data" relative-to="jboss.server.data.dir"/> + </timer-service> + + <!-- EJB3 pools --> + <pools> + <bean-instance-pools> + <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" + instance-acquisition-timeout-unit="MINUTES"/> + + <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" + instance-acquisition-timeout-unit="MINUTES"/> + </bean-instance-pools> + </pools> + + <!-- Default MDB configurations --> + <mdb> + <resource-adapter-ref resource-adapter-name="hornetq-ra"/> + <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/> + </mdb> + + <!-- Session bean configurations --> + <session-bean> + <stateless> + <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/> + </stateless> + </session-bean> + + <default-stateful-access-timeout>5000</default-stateful-access-timeout> + <default-singleton-access-timeout>5000</default-singleton-access-timeout> + + <thread-pools> + <thread-pool name="default" max-threads="10" keepalive-time="100" /> + </thread-pools> + </subsystem> + <subsystem xmlns="urn:jboss:domain:infinispan:1.0" default-cache-container="hibernate"> + <cache-container name="hibernate" default-cache="local-query"> + <local-cache name="entity"> + <eviction strategy="LRU" max-entries="10000"/> + <expiration max-idle="100000"/> + </local-cache> + <local-cache name="local-query"> + <eviction strategy="LRU" max-entries="10000"/> + <expiration max-idle="100000"/> + </local-cache> + <local-cache name="timestamps"> + <eviction strategy="NONE"/> + </local-cache> + </cache-container> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jacorb:1.0"> + <orb name="JBoss" print-version="off" giop-minor-version="2"> + <connection max-managed-buf-size="24" outbuf-cache-timeout="-1"/> + <naming root-context="JBoss/Naming/root" export-corbaloc="on"/> + </orb> + <poa monitoring="off" queue-wait="off"> + <request-processors pool-size="2" max-threads="8"/> + </poa> + <interop sun="on" chunk-custom-rmi-valuetypes="on" strict-check-on-tc-creation="off"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/> + <subsystem xmlns="urn:jboss:domain:jca:1.0"> + <archive-validation enabled="false"/> + <bean-validation enabled="false"/> + <default-workmanager> + <short-running-threads blocking="true"> + <core-threads count="10" per-cpu="20"/> + <queue-length count="10" per-cpu="20"/> + <max-threads count="10" per-cpu="20"/> + <keepalive-time time="10" unit="seconds"/> + </short-running-threads> + <long-running-threads blocking="true"> + <core-threads count="10" per-cpu="20"/> + <queue-length count="10" per-cpu="20"/> + <max-threads count="10" per-cpu="20"/> + <keepalive-time time="10" unit="seconds"/> + </long-running-threads> + </default-workmanager> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jmx:1.1" show-model="true"> + <jmx-connector registry-binding="jmx-connector-registry" server-binding="jmx-connector-server" /> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jpa:1.0"> + <jpa default-datasource=""/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:mail:1.0"> + <mail-session jndi-name="java:jboss/mail/Default"> + <smtp-server address="localhost" port="25"/> + </mail-session> + </subsystem> + <subsystem xmlns="urn:jboss:domain:messaging:1.1"> + <hornetq-server> + <!-- Default journal file size is 10Mb, reduced here to 100k for faster first boot --> + <journal-file-size>102400</journal-file-size> + <journal-min-files>2</journal-min-files> + <journal-type>NIO</journal-type> + <!-- disable messaging persistence --> + <persistence-enabled>false</persistence-enabled> + + <connectors> + <netty-connector name="netty" socket-binding="messaging"/> + <netty-connector name="netty-throughput" socket-binding="messaging-throughput"> + <param key="batch-delay" value="50"/> + </netty-connector> + <in-vm-connector name="in-vm" server-id="0"/> + </connectors> + + <acceptors> + <netty-acceptor name="netty" socket-binding="messaging"/> + <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput"> + <param key="batch-delay" value="50"/> + <param key="direct-deliver" value="false"/> + </netty-acceptor> + <in-vm-acceptor name="in-vm" server-id="0"/> + </acceptors> + + <security-settings> + <security-setting match="#"> + <permission type="createNonDurableQueue" roles="guest"/> + <permission type="deleteNonDurableQueue" roles="guest"/> + <permission type="consume" roles="guest"/> + <permission type="send" roles="guest"/> + </security-setting> + </security-settings> + + <address-settings> + <!--default for catch all--> + <address-setting match="#"> + <dead-letter-address>jms.queue.DLQ</dead-letter-address> + <expiry-address>jms.queue.ExpiryQueue</expiry-address> + <redelivery-delay>0</redelivery-delay> + <max-size-bytes>10485760</max-size-bytes> + <message-counter-history-day-limit>10</message-counter-history-day-limit> + <address-full-policy>BLOCK</address-full-policy> + </address-setting> + </address-settings> + + <!--JMS Stuff--> + <jms-connection-factories> + <connection-factory name="InVmConnectionFactory"> + <connectors> + <connector-ref connector-name="in-vm"/> + </connectors> + <entries> + <entry name="java:/ConnectionFactory"/> + </entries> + </connection-factory> + <connection-factory name="RemoteConnectionFactory"> + <connectors> + <connector-ref connector-name="netty"/> + </connectors> + <entries> + <entry name="RemoteConnectionFactory"/> + </entries> + </connection-factory> + <pooled-connection-factory name="hornetq-ra"> + <transaction mode="xa"/> + <connectors> + <connector-ref connector-name="in-vm"/> + </connectors> + <entries> + <entry name="java:/JmsXA"/> + </entries> + </pooled-connection-factory> + </jms-connection-factories> + + <jms-destinations> + <jms-queue name="testQueue"> + <entry name="queue/test"/> + </jms-queue> + <jms-topic name="testTopic"> + <entry name="topic/test"/> + </jms-topic> + </jms-destinations> + </hornetq-server> + </subsystem> + <subsystem xmlns="urn:jboss:domain:naming:1.0"/> + <subsystem xmlns="urn:jboss:domain:osgi:1.1" activation="lazy"> + <configuration pid="org.apache.felix.webconsole.internal.servlet.OsgiManager"> + <property name="manager.root" value="jboss-osgi"/> + </configuration> + <properties> + <!-- Specifies the beginning start level of the framework --> + <property name="org.osgi.framework.startlevel.beginning">1</property> + </properties> + <capabilities> + <!-- modules registered with the OSGi layer on startup --> + <capability name="javax.api"/> + <capability name="javax.servlet.api"/> + <capability name="javax.transaction.api"/> + <!-- bundles installed on startup --> + <capability name="org.apache.aries.util"/> + <capability name="org.jboss.osgi.webconsole"/> + <capability name="org.osgi.compendium"/> + <!-- bundles started in startlevel 1 --> + <capability name="org.apache.felix.log" startlevel="1"/> + <capability name="org.jboss.osgi.logging" startlevel="1"/> + <capability name="org.apache.felix.configadmin" startlevel="1"/> + <capability name="org.jboss.as.osgi.configadmin" startlevel="1"/> + <!-- bundles started in startlevel 2 --> + <capability name="org.apache.aries.jmx" startlevel="2"/> + <capability name="org.apache.felix.eventadmin" startlevel="2"/> + <capability name="org.apache.felix.metatype" startlevel="2"/> + <capability name="org.apache.felix.scr" startlevel="2"/> + <capability name="org.apache.felix.webconsole" startlevel="2"/> + <capability name="org.jboss.netty" startlevel="2"/> + <capability name="org.jboss.osgi.jmx" startlevel="2"/> + <capability name="org.jboss.osgi.http" startlevel="2"/> + <capability name="org.projectodd.stilts" startlevel="2"/> + <!-- bundles started in startlevel 3 --> + <capability name="org.jboss.osgi.blueprint" startlevel="3"/> + <capability name="org.jboss.osgi.webapp" startlevel="3"/> + <capability name="org.jboss.osgi.xerces" startlevel="3"/> + </capabilities> + </subsystem> + <subsystem xmlns="urn:jboss:domain:remoting:1.0"> + <connector name="remoting-connector" socket-binding="remoting"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0" /> + <subsystem xmlns="urn:jboss:domain:sar:1.0"/> + <subsystem xmlns="urn:jboss:domain:security:1.0"> + <security-domains> + <security-domain name="other" cache-type="default"> + <authentication> + <login-module code="UsersRoles" flag="required"/> + </authentication> + </security-domain> + </security-domains> + </subsystem> + <subsystem xmlns="urn:jboss:domain:threads:1.0"/> + <subsystem xmlns="urn:jboss:domain:transactions:1.0"> + <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/> + <core-environment> + <process-id> + <uuid/> + </process-id> + </core-environment> + <coordinator-environment default-timeout="300"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host"> + <connector name="http" scheme="http" protocol="HTTP/1.1" socket-binding="http"/> + <virtual-server name="default-host" enable-welcome-root="true"> + <alias name="localhost"/> + <alias name="example.com"/> + </virtual-server> + </subsystem> + <subsystem xmlns="urn:jboss:domain:webservices:1.0"> + <modify-wsdl-address>true</modify-wsdl-address> + <wsdl-host>localhost</wsdl-host> + <!-- + <wsdl-port>8080</wsdl-port> + <wsdl-secure-port>8443</wsdl-secure-port> + --> + <endpoint-config xmlns:ws="urn:jboss:jbossws-jaxws-config:4.0"> + ws:config-nameStandard-Endpoint-Config</ws:config-name> + </endpoint-config> + <endpoint-config xmlns:ws="urn:jboss:jbossws-jaxws-config:4.0"> + ws:config-nameRecording-Endpoint-Config</ws:config-name> + ws:pre-handler-chains + <handler-chain xmlns="http://java.sun.com/xml/ns/javaee"> + <protocol-bindings>##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM + </protocol-bindings> + <handler> + <handler-name>RecordingHandler</handler-name> + <handler-class>org.jboss.ws.common.invocation.RecordingServerHandler</handler-class> + </handler> + </handler-chain> + </ws:pre-handler-chains> + </endpoint-config> + </subsystem> + <subsystem xmlns="urn:jboss:domain:weld:1.0"/> + </profile> + + <interfaces> + <interface name="management"> + <inet-address value="${jboss.bind.address.management:127.0.0.70}"/> + </interface> + <interface name="public"> + <inet-address value="${jboss.bind.address:127.0.0.70}"/> + </interface> + </interfaces> + + <socket-binding-group name="standard-sockets" default-interface="public"> + <socket-binding name="http" port="8080"/> + <socket-binding name="https" port="8443"/> + <socket-binding name="jacorb" port="3528"/> + <socket-binding name="jacorb-ssl" port="3529"/> + <socket-binding name="jmx-connector-registry" interface="management" port="1090"/> + <socket-binding name="jmx-connector-server" interface="management" port="1091"/> + <socket-binding name="jndi" port="1099"/> + <socket-binding name="messaging" port="5445"/> + <socket-binding name="messaging-throughput" port="5455"/> + <socket-binding name="osgi-http" interface="management" port="8090"/> + <socket-binding name="remoting" port="4447"/> + <socket-binding name="txn-recovery-environment" port="4712"/> + <socket-binding name="txn-status-manager" port="4713"/> + </socket-binding-group> + +</server> diff --git a/modules/plugins/jboss-as-7/src/test/resources/standalone71.xml b/modules/plugins/jboss-as-7/src/test/resources/standalone71.xml new file mode 100644 index 0000000..0de6d00 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/test/resources/standalone71.xml @@ -0,0 +1,453 @@ +<!-- + ~ JBoss, Home of Professional Open Source. + ~ Copyright 2011, Red Hat, Inc., and individual contributors + ~ as indicated by the @author tags. See the copyright.txt file in the + ~ distribution for a full listing of individual contributors. + ~ + ~ This is free software; you can redistribute it and/or modify it + ~ under the terms of the GNU Lesser General Public License as + ~ published by the Free Software Foundation; either version 2.1 of + ~ the License, or (at your option) any later version. + ~ + ~ This software is distributed in the hope that it will be useful, + ~ but WITHOUT ANY WARRANTY; without even the implied warranty of + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + ~ Lesser General Public License for more details. + ~ + ~ You should have received a copy of the GNU Lesser General Public + ~ License along with this software; if not, write to the Free + ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. + --> + +<server xmlns="urn:jboss:domain:1.1"> + + <extensions> + <extension module="org.jboss.as.clustering.infinispan"/> + <extension module="org.jboss.as.cmp"/> + <extension module="org.jboss.as.connector"/> + <extension module="org.jboss.as.deployment-scanner"/> + <extension module="org.jboss.as.ee"/> + <extension module="org.jboss.as.ejb3"/> + <extension module="org.jboss.as.jacorb"/> + <extension module="org.jboss.as.jaxr"/> + <extension module="org.jboss.as.jaxrs"/> + <extension module="org.jboss.as.jdr"/> + <extension module="org.jboss.as.jmx"/> + <extension module="org.jboss.as.jpa"/> + <extension module="org.jboss.as.logging"/> + <extension module="org.jboss.as.mail"/> + <extension module="org.jboss.as.messaging"/> + <extension module="org.jboss.as.naming"/> + <extension module="org.jboss.as.osgi"/> + <extension module="org.jboss.as.pojo"/> + <extension module="org.jboss.as.remoting"/> + <extension module="org.jboss.as.sar"/> + <extension module="org.jboss.as.security"/> + <extension module="org.jboss.as.threads"/> + <extension module="org.jboss.as.transactions"/> + <extension module="org.jboss.as.web"/> + <extension module="org.jboss.as.webservices"/> + <extension module="org.jboss.as.weld"/> + </extensions> + + <management> + <security-realms> + <security-realm name="ManagementRealm"> + <authentication> + <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/> + </authentication> + </security-realm> + </security-realms> + <management-interfaces> + <native-interface security-realm="ManagementRealm"> + <socket-binding native="management-native"/> + </native-interface> + <http-interface security-realm="ManagementRealm"> + <socket-binding http="management-http"/> + </http-interface> + </management-interfaces> + </management> + + <profile> + <subsystem xmlns="urn:jboss:domain:logging:1.1"> + <console-handler name="CONSOLE"> + <level name="INFO"/> + <formatter> + <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> + </formatter> + </console-handler> + + <periodic-rotating-file-handler name="FILE"> + <formatter> + <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/> + </formatter> + <file relative-to="jboss.server.log.dir" path="server.log"/> + <suffix value=".yyyy-MM-dd"/> + <append value="true"/> + </periodic-rotating-file-handler> + + <logger category="com.arjuna"> + <level name="WARN"/> + </logger> + <logger category="org.apache.tomcat.util.modeler"> + <level name="WARN"/> + </logger> + <logger category="sun.rmi"> + <level name="WARN"/> + </logger> + <logger category="jacorb"> + <level name="WARN"/> + </logger> + <!-- set jacorb.config to ERROR to avoid the "jacorb.properties not found" messages during startup --> + <logger category="jacorb.config"> + <level name="ERROR"/> + </logger> + + <root-logger> + <level name="INFO"/> + <handlers> + <handler name="CONSOLE"/> + <handler name="FILE"/> + </handlers> + </root-logger> + </subsystem> + <subsystem xmlns="urn:jboss:domain:cmp:1.0"/> + <subsystem xmlns="urn:jboss:domain:datasources:1.0"> + <datasources> + <datasource jndi-name="java:jboss/datasources/ExampleDS" enabled="true" use-java-context="true" + pool-name="H2DS"> + <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url> + <driver>h2</driver> + <pool></pool> + <security> + <user-name>sa</user-name> + <password>sa</password> + </security> + </datasource> + <drivers> + <driver name="h2" module="com.h2database.h2"> + <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> + </driver> + </drivers> + </datasources> + </subsystem> + <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.0"> + <deployment-scanner scan-interval="5000" relative-to="jboss.server.base.dir" path="deployments"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:ee:1.0" /> + <subsystem xmlns="urn:jboss:domain:ejb3:1.2" > + + <remote connector-ref="remoting-connector" thread-pool-name="default" /> + <async thread-pool-name="default" /> + + <timer-service thread-pool-name="default" > + <data-store path="timer-service-data" relative-to="jboss.server.data.dir"/> + </timer-service> + + <!-- EJB3 pools --> + <pools> + <bean-instance-pools> + <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" + instance-acquisition-timeout-unit="MINUTES"/> + + <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" + instance-acquisition-timeout-unit="MINUTES"/> + </bean-instance-pools> + </pools> + + <!-- Default MDB configurations --> + <mdb> + <resource-adapter-ref resource-adapter-name="hornetq-ra"/> + <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/> + </mdb> + + <!-- Session bean configurations --> + <session-bean> + <stateless> + <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/> + </stateless> + <stateful default-access-timeout="5000"/> + <singleton default-access-timeout="5000"/> + </session-bean> + + <thread-pools> + <thread-pool name="default" max-threads="10" keepalive-time="100" /> + </thread-pools> + </subsystem> + <subsystem xmlns="urn:jboss:domain:infinispan:1.0" default-cache-container="hibernate"> + <cache-container name="hibernate" default-cache="local-query"> + <local-cache name="entity"> + <eviction strategy="LRU" max-entries="10000"/> + <expiration max-idle="100000"/> + </local-cache> + <local-cache name="local-query"> + <eviction strategy="LRU" max-entries="10000"/> + <expiration max-idle="100000"/> + </local-cache> + <local-cache name="timestamps"> + <eviction strategy="NONE"/> + </local-cache> + </cache-container> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jacorb:1.1"/> + <subsystem xmlns="urn:jboss:domain:jaxr:1.0"> + <datasource jndi-name="java:jboss/datasources/ExampleDS"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/> + <subsystem xmlns="urn:jboss:domain:jca:1.0"> + <archive-validation enabled="false"/> + <bean-validation enabled="false"/> + <default-workmanager> + <short-running-threads blocking="true"> + <core-threads count="10" per-cpu="20"/> + <queue-length count="10" per-cpu="20"/> + <max-threads count="10" per-cpu="20"/> + <keepalive-time time="10" unit="seconds"/> + </short-running-threads> + <long-running-threads blocking="true"> + <core-threads count="10" per-cpu="20"/> + <queue-length count="10" per-cpu="20"/> + <max-threads count="10" per-cpu="20"/> + <keepalive-time time="10" unit="seconds"/> + </long-running-threads> + </default-workmanager> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jdr:1.0"/> + <subsystem xmlns="urn:jboss:domain:jmx:1.1" show-model="true"> + <jmx-connector registry-binding="jmx-connector-registry" server-binding="jmx-connector-server" /> + </subsystem> + <subsystem xmlns="urn:jboss:domain:jpa:1.0"> + <jpa default-datasource=""/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:mail:1.0"> + <mail-session jndi-name="java:jboss/mail/Default"> + <smtp-server address="localhost" port="25"/> + </mail-session> + </subsystem> + <subsystem xmlns="urn:jboss:domain:messaging:1.1"> + <hornetq-server> + <!-- Default journal file size is 10Mb, reduced here to 100k for faster first boot --> + <journal-file-size>102400</journal-file-size> + <journal-min-files>2</journal-min-files> + <!-- disable messaging persistence --> + <persistence-enabled>false</persistence-enabled> + + <connectors> + <netty-connector name="netty" socket-binding="messaging-client"/> + <netty-connector name="netty-throughput" socket-binding="messaging-throughput-client"> + <param key="batch-delay" value="50"/> + </netty-connector> + <in-vm-connector name="in-vm" server-id="0"/> + </connectors> + + <acceptors> + <netty-acceptor name="netty" socket-binding="messaging"/> + <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput"> + <param key="batch-delay" value="50"/> + <param key="direct-deliver" value="false"/> + </netty-acceptor> + <in-vm-acceptor name="in-vm" server-id="0"/> + </acceptors> + + <security-settings> + <security-setting match="#"> + <permission type="createNonDurableQueue" roles="guest"/> + <permission type="deleteNonDurableQueue" roles="guest"/> + <permission type="consume" roles="guest"/> + <permission type="send" roles="guest"/> + </security-setting> + </security-settings> + + <address-settings> + <!--default for catch all--> + <address-setting match="#"> + <dead-letter-address>jms.queue.DLQ</dead-letter-address> + <expiry-address>jms.queue.ExpiryQueue</expiry-address> + <redelivery-delay>0</redelivery-delay> + <max-size-bytes>10485760</max-size-bytes> + <message-counter-history-day-limit>10</message-counter-history-day-limit> + <address-full-policy>BLOCK</address-full-policy> + </address-setting> + </address-settings> + + <!--JMS Stuff--> + <jms-connection-factories> + <connection-factory name="InVmConnectionFactory"> + <connectors> + <connector-ref connector-name="in-vm"/> + </connectors> + <entries> + <entry name="java:/ConnectionFactory"/> + </entries> + </connection-factory> + <connection-factory name="RemoteConnectionFactory"> + <connectors> + <connector-ref connector-name="netty"/> + </connectors> + <entries> + <entry name="RemoteConnectionFactory"/> + </entries> + </connection-factory> + <pooled-connection-factory name="hornetq-ra"> + <transaction mode="xa"/> + <connectors> + <connector-ref connector-name="in-vm"/> + </connectors> + <entries> + <entry name="java:/JmsXA"/> + </entries> + </pooled-connection-factory> + </jms-connection-factories> + + <jms-destinations> + <jms-queue name="testQueue"> + <entry name="queue/test"/> + </jms-queue> + <jms-topic name="testTopic"> + <entry name="topic/test"/> + </jms-topic> + </jms-destinations> + </hornetq-server> + </subsystem> + <subsystem xmlns="urn:jboss:domain:naming:1.0"/> + <subsystem xmlns="urn:jboss:domain:osgi:1.1" activation="lazy"> + <configuration pid="org.apache.felix.webconsole.internal.servlet.OsgiManager"> + <property name="manager.root" value="jboss-osgi"/> + </configuration> + <properties> + <!-- Specifies the beginning start level of the framework --> + <property name="org.osgi.framework.startlevel.beginning">1</property> + </properties> + <capabilities> + <!-- modules registered with the OSGi layer on startup --> + <capability name="javax.api"/> + <capability name="javax.servlet.api"/> + <capability name="javax.transaction.api"/> + <!-- bundles installed on startup --> + <capability name="org.apache.aries.util"/> + <capability name="org.jboss.osgi.webconsole"/> + <capability name="org.osgi.compendium"/> + <!-- bundles started in startlevel 1 --> + <capability name="org.apache.felix.log" startlevel="1"/> + <capability name="org.jboss.osgi.logging" startlevel="1"/> + <capability name="org.apache.felix.configadmin" startlevel="1"/> + <capability name="org.jboss.as.osgi.configadmin" startlevel="1"/> + <!-- bundles started in startlevel 2 --> + <capability name="org.apache.aries.jmx" startlevel="2"/> + <capability name="org.apache.felix.eventadmin" startlevel="2"/> + <capability name="org.apache.felix.metatype" startlevel="2"/> + <capability name="org.apache.felix.scr" startlevel="2"/> + <capability name="org.apache.felix.webconsole" startlevel="2"/> + <capability name="org.jboss.netty" startlevel="2"/> + <capability name="org.jboss.osgi.jmx" startlevel="2"/> + <capability name="org.jboss.osgi.http" startlevel="2"/> + <capability name="org.projectodd.stilts" startlevel="2"/> + <!-- bundles started in startlevel 3 --> + <capability name="org.jboss.osgi.blueprint" startlevel="3"/> + <capability name="org.jboss.osgi.webapp" startlevel="3"/> + <capability name="org.jboss.osgi.xerces" startlevel="3"/> + </capabilities> + </subsystem> + <subsystem xmlns="urn:jboss:domain:pojo:1.0" /> + <subsystem xmlns="urn:jboss:domain:remoting:1.0"> + <connector name="remoting-connector" socket-binding="remoting"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0" /> + <subsystem xmlns="urn:jboss:domain:sar:1.0"/> + <subsystem xmlns="urn:jboss:domain:security:1.0"> + <security-domains> + <security-domain name="other" cache-type="default"> + <authentication> + <login-module code="UsersRoles" flag="required"/> + </authentication> + </security-domain> + <security-domain name="jboss-web-policy" cache-type="default"> + <authorization> + <policy-module code="Delegating" flag="required"/> + </authorization> + </security-domain> + <security-domain name="jboss-ejb-policy" cache-type="default"> + <authorization> + <policy-module code="Delegating" flag="required"/> + </authorization> + </security-domain> + </security-domains> + </subsystem> + <subsystem xmlns="urn:jboss:domain:threads:1.0"/> + <subsystem xmlns="urn:jboss:domain:transactions:1.1"> + <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/> + <core-environment> + <process-id> + <uuid/> + </process-id> + </core-environment> + <coordinator-environment default-timeout="300"/> + </subsystem> + <subsystem xmlns="urn:jboss:domain:web:1.0" default-virtual-server="default-host"> + <connector name="http" scheme="http" protocol="HTTP/1.1" socket-binding="http"/> + <virtual-server name="default-host" enable-welcome-root="true"> + <alias name="localhost"/> + <alias name="example.com"/> + </virtual-server> + </subsystem> + <subsystem xmlns="urn:jboss:domain:webservices:1.0"> + <modify-wsdl-address>true</modify-wsdl-address> + <wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host> + <!-- + <wsdl-port>8080</wsdl-port> + <wsdl-secure-port>8443</wsdl-secure-port> + --> + <endpoint-config xmlns:ws="urn:jboss:jbossws-jaxws-config:4.0"> + ws:config-nameStandard-Endpoint-Config</ws:config-name> + </endpoint-config> + <endpoint-config xmlns:ws="urn:jboss:jbossws-jaxws-config:4.0"> + ws:config-nameRecording-Endpoint-Config</ws:config-name> + ws:pre-handler-chains + <handler-chain xmlns="http://java.sun.com/xml/ns/javaee"> + <protocol-bindings>##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM + </protocol-bindings> + <handler> + <handler-name>RecordingHandler</handler-name> + <handler-class>org.jboss.ws.common.invocation.RecordingServerHandler</handler-class> + </handler> + </handler-chain> + </ws:pre-handler-chains> + </endpoint-config> + </subsystem> + <subsystem xmlns="urn:jboss:domain:weld:1.0"/> + </profile> + + <interfaces> + <interface name="management"> + <inet-address value="${jboss.bind.address.management:127.0.0.71}"/> + </interface> + <interface name="public"> + <inet-address value="${jboss.bind.address:127.0.0.71}"/> + </interface> + </interfaces> + + <socket-binding-group name="standard-sockets" default-interface="public"> + <socket-binding name="http" port="8080"/> + <socket-binding name="https" port="8443"/> + <socket-binding name="jacorb" port="3528"/> + <socket-binding name="jacorb-ssl" port="3529"/> + <socket-binding name="jmx-connector-registry" interface="management" port="1090"/> + <socket-binding name="jmx-connector-server" interface="management" port="1091"/> + <socket-binding name="management-native" interface="management" port="9999"/> + <socket-binding name="management-http" interface="management" port="29990"/> + <socket-binding name="messaging" port="5445"/> + <socket-binding name="messaging-throughput" port="5455"/> + <socket-binding name="osgi-http" interface="management" port="8090"/> + <socket-binding name="remoting" port="4447"/> + <socket-binding name="txn-recovery-environment" port="4712"/> + <socket-binding name="txn-status-manager" port="4713"/> + <outbound-socket-binding name="messaging-client"> + <local-destination socket-binding-ref="messaging"/> + </outbound-socket-binding> + <outbound-socket-binding name="messaging-throughput-client"> + <local-destination socket-binding-ref="messaging-throughput"/> + </outbound-socket-binding> + </socket-binding-group> + +</server>