Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 597609 Details for
Bug 839332
refactor the AS7 connection code out of the AS7 plugin into a common module for reuse
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
patch to refactor AS7 connection code to its own common client module
0001-BZ-839332-refactor-the-AS7-client-code-to-its-own-co.patch (text/plain), 231.30 KB, created by
John Mazzitelli
on 2012-07-11 15:33:36 UTC
(
hide
)
Description:
patch to refactor AS7 connection code to its own common client module
Filename:
MIME Type:
Creator:
John Mazzitelli
Created:
2012-07-11 15:33:36 UTC
Size:
231.30 KB
patch
obsolete
>From 4a1a0b4c62cc0ed0af8806434e1ebf17c96f2ac0 Mon Sep 17 00:00:00 2001 >From: John Mazzitelli <mazz@redhat.com> >Date: Wed, 11 Jul 2012 11:31:52 -0400 >Subject: [PATCH] [BZ 839332] refactor the AS7 client code to its own common, > reusable module > >--- > .classpath | 1 + > modules/common/jboss-as-7-client/pom.xml | 134 +++++ > .../common/jbossas7/client/AS7Authenticator.java | 26 + > .../rhq/common/jbossas7/client/ASConnection.java | 550 ++++++++++++++++++++ > .../common/jbossas7/client/ASUploadConnection.java | 251 +++++++++ > .../common/jbossas7/client/ConnectionStats.java | 61 +++ > .../rhq/common/jbossas7/client/json/Address.java | 219 ++++++++ > .../common/jbossas7/client/json/ComplexResult.java | 40 ++ > .../jbossas7/client/json/CompositeOperation.java | 77 +++ > .../rhq/common/jbossas7/client/json/Operation.java | 130 +++++ > .../jbossas7/client/json/PROPERTY_VALUE.java | 67 +++ > .../common/jbossas7/client/json/ReadAttribute.java | 36 ++ > .../jbossas7/client/json/ReadChildrenNames.java | 36 ++ > .../client/json/ReadChildrenResources.java | 36 ++ > .../common/jbossas7/client/json/ReadResource.java | 53 ++ > .../rhq/common/jbossas7/client/json/Remove.java | 36 ++ > .../rhq/common/jbossas7/client/json/Result.java | 159 ++++++ > .../jbossas7/client/json/WriteAttribute.java | 39 ++ > .../json/serializer/PropertyValueDeserializer.java | 52 ++ > .../json/serializer/PropertyValueSerializer.java | 45 ++ > modules/common/pom.xml | 1 + > modules/plugins/jboss-as-7/pom.xml | 11 + > .../modules/plugins/jbossas7/AS7Authenticator.java | 26 - > .../rhq/modules/plugins/jbossas7/AS7Component.java | 1 + > .../rhq/modules/plugins/jbossas7/ASConnection.java | 550 -------------------- > .../plugins/jbossas7/ASUploadConnection.java | 250 --------- > .../modules/plugins/jbossas7/BaseComponent.java | 23 +- > .../plugins/jbossas7/BaseProcessDiscovery.java | 7 +- > .../plugins/jbossas7/BaseServerComponent.java | 13 +- > .../jbossas7/ConfigurationLoadDelegate.java | 13 +- > .../jbossas7/ConfigurationWriteDelegate.java | 17 +- > .../plugins/jbossas7/CreateResourceDelegate.java | 7 +- > .../plugins/jbossas7/DatasourceComponent.java | 16 +- > .../plugins/jbossas7/DeploymentComponent.java | 12 +- > .../plugins/jbossas7/Domain2Descriptor.java | 7 +- > .../jbossas7/DomainDeploymentComponent.java | 12 +- > .../modules/plugins/jbossas7/HostComponent.java | 8 +- > .../plugins/jbossas7/HostControllerComponent.java | 6 +- > .../rhq/modules/plugins/jbossas7/JDRComponent.java | 6 +- > .../modules/plugins/jbossas7/LoggerComponent.java | 5 +- > .../plugins/jbossas7/ManagedASComponent.java | 12 +- > .../plugins/jbossas7/ManagedASDiscovery.java | 15 +- > .../plugins/jbossas7/ModClusterComponent.java | 6 +- > .../jbossas7/ModClusterConfigurationDiscovery.java | 9 +- > .../jbossas7/ModClusterContextComponent.java | 6 +- > .../ModClusterContextDiscoveryComponent.java | 7 +- > .../jbossas7/ModClusterDiscoveryComponent.java | 7 +- > .../plugins/jbossas7/ModuleOptionsComponent.java | 13 +- > .../jbossas7/ModuleOptionsDiscoveryComponent.java | 11 +- > .../modules/plugins/jbossas7/NamingComponent.java | 6 +- > .../rhq/modules/plugins/jbossas7/PluginStats.java | 61 --- > .../plugins/jbossas7/ServerGroupComponent.java | 14 +- > .../plugins/jbossas7/StandaloneASComponent.java | 8 +- > .../plugins/jbossas7/SubsystemDiscovery.java | 9 +- > .../plugins/jbossas7/ThreadingComponent.java | 6 +- > .../modules/plugins/jbossas7/VHostComponent.java | 4 +- > .../plugins/jbossas7/WebConnectorComponent.java | 6 +- > .../rhq/modules/plugins/jbossas7/json/Address.java | 219 -------- > .../plugins/jbossas7/json/ComplexResult.java | 40 -- > .../plugins/jbossas7/json/CompositeOperation.java | 77 --- > .../modules/plugins/jbossas7/json/Operation.java | 130 ----- > .../plugins/jbossas7/json/PROPERTY_VALUE.java | 67 --- > .../plugins/jbossas7/json/ReadAttribute.java | 36 -- > .../plugins/jbossas7/json/ReadChildrenNames.java | 36 -- > .../jbossas7/json/ReadChildrenResources.java | 36 -- > .../plugins/jbossas7/json/ReadResource.java | 53 -- > .../rhq/modules/plugins/jbossas7/json/Remove.java | 36 -- > .../rhq/modules/plugins/jbossas7/json/Result.java | 159 ------ > .../plugins/jbossas7/json/WriteAttribute.java | 39 -- > .../json/serializer/PropertyValueDeserializer.java | 52 -- > .../json/serializer/PropertyValueSerializer.java | 45 -- > .../AbstractConfigurationHandlingTest.java | 7 +- > .../plugins/jbossas7/CompositeOperationTest.java | 8 +- > .../plugins/jbossas7/ConfigurationLoadingTest.java | 4 +- > .../jbossas7/ConfigurationUpdatingTest.java | 8 +- > .../plugins/jbossas7/OperationJsonTest.java | 12 +- > .../modules/plugins/jbossas7/PathHandlingTest.java | 2 +- > .../plugins/jbossas7/TemplatedComponentTest.java | 3 +- > .../TemplatedSubResourcesComponentTest.java | 3 +- > .../itest/domain/SecurityModuleOptionsTest.java | 8 +- > .../itest/nonpc/AbstractIntegrationTest.java | 10 +- > .../jbossas7/itest/nonpc/ConfigurationTest.java | 2 +- > .../jbossas7/itest/nonpc/DatasourceDeployTest.java | 18 +- > .../plugins/jbossas7/itest/nonpc/MiscTest.java | 12 +- > .../jbossas7/itest/nonpc/ServerGroupTest.java | 4 +- > .../jbossas7/itest/nonpc/UploadAndDeployTest.java | 14 +- > 86 files changed, 2276 insertions(+), 2103 deletions(-) > create mode 100644 modules/common/jboss-as-7-client/pom.xml > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/AS7Authenticator.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ASConnection.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ASUploadConnection.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ConnectionStats.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Address.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ComplexResult.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/CompositeOperation.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Operation.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/PROPERTY_VALUE.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadAttribute.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadChildrenNames.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadChildrenResources.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadResource.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Remove.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Result.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/WriteAttribute.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/serializer/PropertyValueDeserializer.java > create mode 100644 modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/serializer/PropertyValueSerializer.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Authenticator.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/PluginStats.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ComplexResult.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/CompositeOperation.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadAttribute.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenResources.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Remove.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/WriteAttribute.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java > delete mode 100644 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java > >diff --git a/.classpath b/.classpath >index 443abde..3ff6da0 100644 >--- a/.classpath >+++ b/.classpath >@@ -12,6 +12,7 @@ > <classpathentry kind="src" path="modules/common/filetemplate-bundle/src/test/java"/> > <classpathentry kind="src" path="modules/common/jboss-as/src/main/java"/> > <classpathentry kind="src" path="modules/common/jboss-as/src/test/java"/> >+ <classpathentry kind="src" path="modules/common/jboss-as-7-client/src/main/java"/> > <classpathentry kind="src" path="modules/core/util/src/main/java"/> > <classpathentry kind="src" path="modules/core/util/src/test/java"/> > <classpathentry kind="src" path="modules/core/dbutils/src/main/java"/> >diff --git a/modules/common/jboss-as-7-client/pom.xml b/modules/common/jboss-as-7-client/pom.xml >new file mode 100644 >index 0000000..9ce52e8 >--- /dev/null >+++ b/modules/common/jboss-as-7-client/pom.xml >@@ -0,0 +1,134 @@ >+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> >+ >+ <modelVersion>4.0.0</modelVersion> >+ >+ <parent> >+ <groupId>org.rhq</groupId> >+ <artifactId>rhq-common-parent</artifactId> >+ <version>4.5.0-SNAPSHOT</version> >+ </parent> >+ >+ <artifactId>rhq-jboss-as-7-client</artifactId> >+ <packaging>jar</packaging> >+ >+ <name>JBossAS 7 Client Common Library</name> >+ <description>A library that can be used to talk to a JBossAS 7 instance</description> >+ >+ <properties> >+ <jackson.version>1.9.5</jackson.version> >+ </properties> >+ >+ <dependencies> >+ <!-- NOTE: jackson 2.0.0 has moved to a new groupId - artifacts are under >+ http://repo1.maven.org/maven2/com/fasterxml/jackson/ --> >+ <dependency> >+ <groupId>org.codehaus.jackson</groupId> >+ <artifactId>jackson-core-asl</artifactId> >+ <version>${jackson.version}</version> >+ </dependency> >+ >+ <dependency> >+ <groupId>org.codehaus.jackson</groupId> >+ <artifactId>jackson-mapper-asl</artifactId> >+ <version>${jackson.version}</version> >+ </dependency> >+ >+ <dependency> >+ <groupId>${project.groupId}</groupId> >+ <artifactId>rhq-core-plugin-api</artifactId> >+ <version>${project.version}</version> >+ </dependency> >+ </dependencies> >+ >+ <profiles> >+ <profile> >+ <id>cobertura</id> >+ <activation> >+ <activeByDefault>false</activeByDefault> >+ </activation> >+ <build> >+ <plugins> >+ <plugin> >+ <artifactId>maven-antrun-plugin</artifactId> >+ <dependencies> >+ <dependency> >+ <groupId>net.sourceforge.cobertura</groupId> >+ <artifactId>cobertura</artifactId> >+ <version>${cobertura.version}</version> >+ </dependency> >+ </dependencies> >+ <executions> >+ <execution> >+ <id>cobertura-instrument</id> >+ <phase>process-test-classes</phase> >+ <configuration> >+ <target> >+ <!-- prepare directory structure for cobertura--> >+ <mkdir dir="target/cobertura" /> >+ <mkdir dir="target/cobertura/backup" /> >+ <!-- backup all classes so that we can instrument the original classes--> >+ <copy toDir="target/cobertura/backup" verbose="true" overwrite="true"> >+ <fileset dir="target/classes"> >+ <include name="**/*.class" /> >+ </fileset> >+ </copy> >+ <!-- create a properties file and save there location of cobertura data file--> >+ <touch file="target/classes/cobertura.properties" /> >+ <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo> >+ <path id="cobertura.classpath"> >+ <fileset dir="${user.home}/.m2/repository/net/sourceforge/cobertura/cobertura/${cobertura.version}/"> >+ <include name="cobertura*.jar" /> >+ <include name="lib/**/*.jar" /> >+ </fileset> >+ </path> >+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" /> >+ <!-- instrument all classes in target/classes directory --> >+ <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes"> >+ <fileset dir="${project.build.directory}/classes"> >+ <include name="**/*.class" /> >+ </fileset> >+ </cobertura-instrument> >+ </target> >+ </configuration> >+ <goals> >+ <goal>run</goal> >+ </goals> >+ </execution> >+ <execution> >+ <id>cobertura-report</id> >+ <phase>prepare-package</phase> >+ <configuration> >+ <target> >+ <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" /> >+ <!-- prepare directory structure for cobertura--> >+ <mkdir dir="target/cobertura" /> >+ <mkdir dir="target/site/cobertura" /> >+ <!-- restore classes from backup folder to classes folder --> >+ <copy toDir="target/classes" verbose="true" overwrite="true"> >+ <fileset dir="target/cobertura/backup"> >+ <include name="**/*.class" /> >+ </fileset> >+ </copy> >+ <!-- delete backup folder--> >+ <delete dir="target/cobertura/backup" /> >+ <!-- create a code coverage report --> >+ <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura"> >+ <fileset dir="${basedir}/src/main/java"> >+ <include name="**/*.java" /> >+ </fileset> >+ </cobertura-report> >+ <!-- delete cobertura.properties file --> >+ <delete file="target/classes/cobertura.properties" /> >+ </target> >+ </configuration> >+ <goals> >+ <goal>run</goal> >+ </goals> >+ </execution> >+ </executions> >+ </plugin> >+ </plugins> >+ </build> >+ </profile> >+ </profiles> >+</project> >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/AS7Authenticator.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/AS7Authenticator.java >new file mode 100644 >index 0000000..c04f87f >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/AS7Authenticator.java >@@ -0,0 +1,26 @@ >+package org.rhq.common.jbossas7.client; >+ >+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/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ASConnection.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ASConnection.java >new file mode 100644 >index 0000000..bccaeb5 >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ASConnection.java >@@ -0,0 +1,550 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2012 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client; >+ >+import java.io.BufferedReader; >+import java.io.BufferedWriter; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.InputStreamReader; >+import java.io.OutputStream; >+import java.io.StringWriter; >+import java.net.Authenticator; >+import java.net.HttpURLConnection; >+import java.net.MalformedURLException; >+import java.net.SocketTimeoutException; >+import java.net.URL; >+import java.util.StringTokenizer; >+ >+import org.apache.commons.logging.Log; >+import org.apache.commons.logging.LogFactory; >+import org.codehaus.jackson.JsonNode; >+import org.codehaus.jackson.map.DeserializationConfig; >+import org.codehaus.jackson.map.ObjectMapper; >+import org.codehaus.jackson.map.SerializationConfig; >+import org.jetbrains.annotations.NotNull; >+ >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.Result; >+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; >+ >+/** >+ * Provide management connections to an AS7 instance and reading/writing data from/to it. >+ * >+ * @author Heiko W. Rupp >+ * @author Ian Springer >+ */ >+public class ASConnection { >+ >+ public static final String MANAGEMENT = "/management"; >+ private static final String FAILURE_DESCRIPTION = "\"failure-description\""; >+ >+ // This is a variable on purpose, so devs can switch it on in the debugger or in the agent >+ public static boolean verbose = false; >+ private static final int HTTP_TEMPORARY_REDIRECT = 307; >+ >+ private static final String POST_HTTP_METHOD = "POST"; >+ >+ private static final String CONTENT_LENGTH_HTTP_HEADER = "Content-Length"; >+ private static final String ACCEPT_HTTP_HEADER = "Accept"; >+ private static final String CONTENT_TYPE_HTTP_HEADER = "Content-Type"; >+ >+ private static final String JSON_MIME_TYPE = "application/json"; >+ >+ private final Log log = LogFactory.getLog(ASConnection.class); >+ >+ private URL url; >+ private String urlString; >+ private ObjectMapper mapper; >+ private Authenticator passwordAuthenticator; >+ private String host; >+ private int port; >+ >+ /** >+ * Construct an ASConnection object. The real "physical" connection is done in {@link #executeRaw(Operation)}. >+ * >+ * @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, String user, String password) { >+ if (host == null) { >+ throw new IllegalArgumentException("Management host cannot be null."); >+ } >+ if (port <= 0 || port > 65535) { >+ throw new IllegalArgumentException("Invalid port: " + port); >+ } >+ this.host = host; >+ this.port = port; >+ >+ try { >+ url = new URL("http", host, port, MANAGEMENT); >+ urlString = url.toString(); >+ } catch (MalformedURLException e) { >+ throw new IllegalArgumentException(e.getMessage()); >+ } >+ >+ passwordAuthenticator = new AS7Authenticator(user, password); >+ Authenticator.setDefault(passwordAuthenticator); >+ >+ // read system property "as7plugin.verbose" >+ verbose = Boolean.getBoolean("as7plugin.verbose"); >+ >+ mapper = new ObjectMapper(); >+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); >+ } >+ >+ /** >+ * Execute an operation against the domain api. This method is doing the >+ * real work by talking to the remote server and sending JSON data, that >+ * is obtained by serializing the operation. >+ * >+ * Please do not use this API , but execute() >+ * @return JsonNode that describes the result >+ * @param operation an Operation that should be run on the domain controller >+ * @see #execute(org.rhq.common.jbossas7.client.json.Operation) >+ * @see #execute(org.rhq.common.jbossas7.client.json.Operation, boolean) >+ * @see #executeComplex(org.rhq.common.jbossas7.client.json.Operation) >+ */ >+ public JsonNode executeRaw(Operation operation) { >+ return executeRaw(operation, 20); >+ } >+ >+ /** >+ * Execute an operation against the domain api. This method is doing the >+ * real work by talking to the remote server and sending JSON data, that >+ * is obtained by serializing the operation. >+ * >+ * Please do not use this API, but rather use {@link #execute(Operation)}. >+ * >+ * @param operation an Operation that should be run on the domain controller >+ * @param timeoutSec Timeout on connect and read in seconds >+ * >+ * @return JsonNode that describes the result >+ * >+ * @see #execute(org.rhq.common.jbossas7.client.json.Operation) >+ * @see #execute(org.rhq.common.jbossas7.client.json.Operation, boolean) >+ * @see #executeComplex(org.rhq.common.jbossas7.client.json.Operation) >+ */ >+ public JsonNode executeRaw(Operation operation, int timeoutSec) { >+ long requestStartTime = System.currentTimeMillis(); >+ >+ HttpURLConnection conn; >+ OutputStream out; >+ try { >+ conn = (HttpURLConnection) url.openConnection(); >+ conn.setDoOutput(true); >+ conn.setRequestMethod(POST_HTTP_METHOD); >+ conn.addRequestProperty(CONTENT_TYPE_HTTP_HEADER, JSON_MIME_TYPE); >+ conn.addRequestProperty(ACCEPT_HTTP_HEADER, JSON_MIME_TYPE); >+ conn.setInstanceFollowRedirects(false); >+ int timeoutMillis = timeoutSec * 1000; >+ conn.setConnectTimeout(timeoutMillis); >+ conn.setReadTimeout(timeoutMillis); >+ if (conn.getReadTimeout() != timeoutMillis) { >+ log.warn("Read timeout did not get set on HTTP connection - the JRE uses a broken timeout mechanism - nothing we can do."); >+ } >+ >+ out = conn.getOutputStream(); >+ } catch (IOException e) { >+ // This most likely just means the server is down. >+ if (log.isDebugEnabled()) { >+ log.debug("Failed to open connection to [" + urlString + "] in order to invoke [" + operation + "]: " >+ + e); >+ } >+ // TODO (ips): Would it make more sense to return null here, since we didn't even connect? >+ Result failure = new Result(); >+ failure.setFailureDescription(e.toString()); >+ failure.setOutcome("failure"); >+ failure.setRhqThrowable(e); >+ JsonNode ret = mapper.valueToTree(failure); >+ return ret; >+ } >+ >+ try { >+ String jsonToSend = mapper.writeValueAsString(operation); >+ >+ // Check for spaces in the path, which the AS7 server will reject. Log verbose error and >+ // generate failure indicator. >+ if ((operation != null) && (operation.getAddress() != null) && operation.getAddress().getPath() != null) { >+ if (containsSpaces(operation.getAddress().getPath())) { >+ Result noResult = new Result(); >+ String outcome = "- Path '" + operation.getAddress().getPath() >+ + "' is invalid as it contains spaces -"; >+ if (verbose) { >+ log.error(outcome); >+ } >+ noResult.setFailureDescription(outcome); >+ noResult.setOutcome("failure"); >+ JsonNode invalidPathResult = mapper.valueToTree(noResult); >+ return invalidPathResult; >+ } >+ } >+ >+ if (verbose) { >+ log.info("JSON to send: " + jsonToSend); >+ } >+ >+ mapper.writeValue(out, operation); >+ >+ out.flush(); >+ out.close(); >+ >+ ResponseStatus responseStatus = new ResponseStatus(conn); >+ if (isAuthorizationFailureResponse(responseStatus.getResponseCode())) { >+ handleAuthorizationFailureResponse(operation, responseStatus); >+ } >+ >+ String responseBody = getResponseBody(conn); >+ if (responseStatus.getResponseCode() >= 400) { >+ if (verbose) { >+ log.debug(operation + " failed with " + responseStatus + " - response body was [" + responseBody >+ + "]."); >+ } >+ >+ if (responseBody.contains("JBAS014807") || responseBody.contains("JBAS010850") || responseBody.contains("JBAS014793")) { >+ // management resource not found or not readable or no known child-type >+ if (log.isDebugEnabled()) { >+ log.debug("Requested management resource not found: " + operation.getAddress().getPath()); >+ } >+ } else { >+ log.warn("Received " + responseStatus + " response to " + operation + " - response body was [" + >+ responseBody + "]."); >+ } >+ } >+ >+ JsonNode operationResult; >+ if (!responseBody.isEmpty()) { >+ try { >+ operationResult = mapper.readTree(responseBody); >+ } catch (IOException ioe) { >+ log.error("Failed to deserialize response to " + operation + " to JsonNode - response status was " >+ + responseStatus + ", and body was [" + responseBody + "]: " + ioe); >+ Result result = new Result(); >+ result.setOutcome("failure"); >+ result.setFailureDescription("Failed to deserialize response to " + operation + " to JsonNode - response status was " >+ + responseStatus + ", and body was [" + responseBody + "]: " + ioe); >+ result.setRolledBack(responseBody.contains("rolled-back=true")); >+ result.setRhqThrowable(ioe); >+ operationResult = mapper.valueToTree(result); >+ } >+ >+ if (verbose) { >+ ObjectMapper om2 = new ObjectMapper(); >+ om2.configure(SerializationConfig.Feature.INDENT_OUTPUT, true); >+ try { >+ String resultString = om2.writeValueAsString(operationResult); >+ log.info(resultString); >+ } catch (IOException ioe) { >+ log.error("Failed to convert result of " + operation + " to string.", ioe); >+ } >+ } >+ } else { >+ Result noResult = new Result(); >+ noResult.setOutcome("failure"); >+ noResult.setFailureDescription("- empty response body with HTTP status code " + responseStatus + " -"); >+ operationResult = mapper.valueToTree(noResult); >+ } >+ >+ return operationResult; >+ } catch (IllegalArgumentException iae) { >+ log.error("Illegal argument for input " + operation + ": " + iae.getMessage()); >+ } catch (SocketTimeoutException ste) { >+ log.error(operation + " timed out: " + ste.getMessage()); >+ conn.disconnect(); >+ Result failure = new Result(); >+ failure.setFailureDescription(ste.getMessage()); >+ failure.setOutcome("failure"); >+ failure.setRhqThrowable(ste); >+ JsonNode ret = mapper.valueToTree(failure); >+ return ret; >+ } catch (IOException ioe) { >+ conn.disconnect(); >+ Result failure = new Result(); >+ failure.setFailureDescription(ioe.getMessage()); >+ failure.setOutcome("failure"); >+ failure.setRhqThrowable(ioe); >+ JsonNode ret = mapper.valueToTree(failure); >+ return ret; >+ } finally { >+ long requestEndTime = System.currentTimeMillis(); >+ ConnectionStats stats = ConnectionStats.getInstance(); >+ stats.incrementRequestCount(); >+ stats.addRequestTime(requestEndTime - requestStartTime); >+ } >+ >+ return null; >+ } >+ >+ // When no management users have been configured, a 307 (Temporary Redirect) response will be returned, and >+ // when authorization has failed due to an invalid username or password, a 401 (Unauthorized) response will be >+ // returned. >+ private boolean isAuthorizationFailureResponse(int responseCode) { >+ return responseCode == HttpURLConnection.HTTP_UNAUTHORIZED || responseCode == HTTP_TEMPORARY_REDIRECT; >+ } >+ >+ private void handleAuthorizationFailureResponse(Operation operation, ResponseStatus responseStatus) { >+ if (log.isDebugEnabled()) { >+ log.debug("Response to " + operation + " was " + responseStatus >+ + " - throwing InvalidPluginConfigurationException..."); >+ } >+ // Throw a InvalidPluginConfigurationException, so the user will get a yellow plugin connection >+ // warning message in the GUI. >+ String message; >+ if (responseStatus.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) { >+ message = "Credentials for plugin to connect to AS7 management interface are invalid - update Connection Settings with valid credentials."; >+ } else { >+ message = "Authorization to AS7 failed - did you install a management user?"; >+ } >+ throw new InvalidPluginConfigurationException(message); >+ } >+ >+ private String getResponseMessage(HttpURLConnection conn) throws IOException { >+ String responseMessage = conn.getResponseMessage(); >+ if ((responseMessage == null) && (conn.getResponseCode() == HTTP_TEMPORARY_REDIRECT)) { >+ responseMessage = "Temporary Redirect"; >+ } >+ return responseMessage; >+ } >+ >+ /** Method parses Operation.getAddress().getPath() for invalid spaces in the path passed in. >+ * >+ * @param path Operation.getAddress().getPath() value. >+ * @return boolean indicating invalid spaces found. >+ */ >+ private boolean containsSpaces(String path) { >+ boolean includesSpaces = false; >+ StringTokenizer components = new StringTokenizer(path, " "); >+ if (components.countTokens() > 1) { >+ includesSpaces = true; >+ } >+ return includesSpaces; >+ } >+ >+ /** >+ * Execute the passed Operation and return its Result. This is a shortcut of >+ * #execute(Operation, false) >+ * @param op Operation to execute >+ * @return Result of the execution >+ * @see #execute(org.rhq.common.jbossas7.client.json.Operation, boolean) >+ */ >+ public Result execute(Operation op) { >+ return execute(op, false, 10); >+ } >+ >+ /** >+ * Execute the passed Operation and return its Result. This is a shortcut of >+ * #execute(Operation, false) >+ * @param op Operation to execute >+ * @param timeoutSec Timeout to wait in seconds. Default is 10 sec >+ * @return Result of the execution >+ * @see #execute(org.rhq.common.jbossas7.client.json.Operation, boolean) >+ */ >+ public Result execute(Operation op, int timeoutSec) { >+ return execute(op, false, timeoutSec); >+ } >+ >+ /** >+ * Execute the passed Operation and return its ComplexResult. This is a shortcut of >+ * #execute(Operation, true) >+ * @param op Operation to execute >+ * @return ComplexResult of the execution >+ * @see #execute(org.rhq.common.jbossas7.client.json.Operation, boolean) >+ */ >+ public ComplexResult executeComplex(Operation op) { >+ return (ComplexResult) execute(op, true, 10); >+ } >+ >+ /** >+ * Execute the passed Operation and return its ComplexResult. This is a shortcut of >+ * #execute(Operation, true) >+ * @param op Operation to execute >+ * @param timeoutSec Timeout to wait in seconds. Default is 10 sec >+ * @return ComplexResult of the execution >+ * @see #execute(org.rhq.common.jbossas7.client.json.Operation, boolean) >+ */ >+ public ComplexResult executeComplex(Operation op, int timeoutSec) { >+ return (ComplexResult) execute(op, true, timeoutSec); >+ } >+ >+ /** >+ * Execute the passed Operation and return its Result. Depending on <i>isComplex</i> >+ * the return type is a simple Result or a ComplexResult. Default timeout here is 10sec >+ * @param op Operation to execute >+ * @param isComplex should a complex result be returned? >+ * @return ComplexResult of the execution >+ */ >+ public Result execute(Operation op, boolean isComplex) { >+ return execute(op, isComplex, 10); >+ } >+ >+ /** >+ * Execute the passed Operation and return its Result. Depending on <i>isComplex</i> >+ * the return type is a simple Result or a ComplexResult >+ * >+ * @param op Operation to execute >+ * @param isComplex should a complex result be returned? >+ * @param timeoutSec >+ * @return ComplexResult of the execution >+ */ >+ public Result execute(Operation op, boolean isComplex, int timeoutSec) { >+ JsonNode node = executeRaw(op, timeoutSec); >+ >+ if (node == null) { >+ log.warn("Operation [" + op + "] returned null."); >+ Result failure = new Result(); >+ failure.setFailureDescription("Operation [" + op + "] returned null."); >+ return failure; >+ } >+ Result res; >+ try { >+ //check for failure-description indicator, otherwise ObjectMapper will try to deserialize as json. Ex. >+ // {"outcome":"failed","failure-description":"JBAS014792: Unknown attribute number-of-timed-out-transactions","rolled-back":true} >+ String as7ResultSerialization = node.toString(); >+ >+ if (as7ResultSerialization.indexOf(FAILURE_DESCRIPTION) > -1) { >+ if (verbose) { >+ log.warn("------ Detected 'failure-description' when communicating with server." >+ + as7ResultSerialization); >+ } >+ } >+ >+ if (isComplex) { >+ res = mapper.readValue(node, ComplexResult.class); >+ } else { >+ res = mapper.readValue(node, Result.class); >+ } >+ return res; >+ } catch (IOException e) { >+ log.error(e.getMessage()); >+ if (verbose) { >+ log.error("----------- Operation execution unparsable. Request " + ":[" + op + "] Response:<" + node >+ + ">"); >+ } >+ Result failure = new Result(); >+ failure.setFailureDescription("Operation <" + op + "> returned unparsable JSON, <" + node + ">."); >+ return failure; >+ //don't return null. >+ } >+ } >+ >+ public String getHost() { >+ return host; >+ } >+ >+ public int getPort() { >+ return port; >+ } >+ >+ @NotNull >+ private String getResponseBody(HttpURLConnection connection) { >+ InputStream inputStream; >+ try { >+ inputStream = connection.getInputStream(); >+ } catch (IOException e) { >+ // This means the server returned a 4xx (client error) or 5xx (server error) response, e.g.: >+ // "java.io.IOException: Server returned HTTP response code: 500 for URL: http://127.0.0.1:9990/management" >+ // Unfortunately, AS7 incorrectly returns 500 responses for client errors (e.g. invalid resource path, >+ // attribute name, etc.). >+ inputStream = null; >+ } >+ if (inputStream == null) { >+ inputStream = connection.getErrorStream(); >+ } >+ if (inputStream == null) { >+ return ""; >+ } >+ >+ int contentLength = connection.getHeaderFieldInt(CONTENT_LENGTH_HTTP_HEADER, -1); >+ >+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); >+ StringWriter stringWriter = (contentLength != -1) ? new StringWriter(contentLength) : new StringWriter(); >+ BufferedWriter writer = new BufferedWriter(stringWriter); >+ try { >+ long numCharsCopied = 0; >+ char[] buffer = new char[1024]; >+ >+ int cnt; >+ while (((contentLength == -1) || (numCharsCopied < contentLength)) && ((cnt = reader.read(buffer)) != -1)) { >+ numCharsCopied += cnt; >+ writer.write(buffer, 0, cnt); >+ } >+ } catch (IOException e) { >+ throw new RuntimeException("Failed to read response.", e); >+ } finally { >+ try { >+ writer.close(); >+ } catch (IOException ioe) { >+ log.debug("Failed to close writer.", ioe); >+ } >+ >+ try { >+ reader.close(); >+ } catch (IOException ioe) { >+ log.debug("Failed to close reader.", ioe); >+ } >+ } >+ >+ return stringWriter.getBuffer().toString(); >+ } >+ >+ private class ResponseStatus { >+ >+ private Integer responseCode; >+ private String responseMessage; >+ >+ ResponseStatus(HttpURLConnection connection) throws IOException { >+ try { >+ responseCode = connection.getResponseCode(); >+ } catch (IOException e) { >+ // try one more time >+ responseCode = connection.getResponseCode(); >+ } >+ >+ try { >+ responseMessage = connection.getResponseMessage(); >+ } catch (IOException e) { >+ // try one more time >+ responseMessage = connection.getResponseMessage(); >+ } >+ >+ if (responseMessage == null) { >+ responseMessage = (getResponseCode() == HTTP_TEMPORARY_REDIRECT) ? "Temporary Redirect" : ""; >+ } >+ } >+ >+ public int getResponseCode() { >+ return responseCode; >+ } >+ >+ @NotNull >+ public String getResponseMessage() { >+ return responseMessage; >+ } >+ >+ @Override >+ public String toString() { >+ return getResponseCode() + " (" + getResponseMessage() + ")"; >+ } >+ >+ } >+ >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ASUploadConnection.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ASUploadConnection.java >new file mode 100644 >index 0000000..48c6f31 >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ASUploadConnection.java >@@ -0,0 +1,251 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client; >+ >+import java.io.BufferedOutputStream; >+import java.io.BufferedReader; >+import java.io.Closeable; >+import java.io.IOException; >+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; >+ >+import org.apache.commons.logging.Log; >+import org.apache.commons.logging.LogFactory; >+import org.codehaus.jackson.JsonNode; >+import org.codehaus.jackson.map.ObjectMapper; >+ >+ >+/** >+ * Connection for uploading of content. >+ * Partially taken from https://github.com/jbossas/jboss-as/blob/master/testsuite/smoke/src/test/java/org/jboss/as/test/surefire/servermodule/HttpDeploymentUploadUnitTestCase.java >+ * >+ * @author Jonathan Pearlin (of the original code) >+ * @author Heiko W. Rupp >+ */ >+public class ASUploadConnection { >+ >+ private static final String BOUNDARY_PARAM = "NeAG1QNIHHOyB5joAS7Rox!!"; >+ >+ private static final String BOUNDARY = "--" + BOUNDARY_PARAM; >+ >+ private static final String CRLF = "\r\n"; >+ >+ private static final String POST_REQUEST_METHOD = "POST"; >+ >+ private static final String UPLOAD_URL_PATH = ASConnection.MANAGEMENT + "/add-content"; >+ >+ 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; >+ private int timeout; >+ private static final int DEFAULT_TIMEOUT = 60; // 60sec >+ >+ public ASUploadConnection(String dcHost, int port, String user, String password) { >+ if (dcHost == null) { >+ throw new IllegalArgumentException("Management host cannot be null."); >+ } >+ if (port <= 0 || port > 65535) { >+ throw new IllegalArgumentException("Invalid port: " + port); >+ } >+ this.host = dcHost; >+ this.port = port; >+ if (user != null) { >+ passwordAuthenticator = new AS7Authenticator(user,password); >+ Authenticator.setDefault(passwordAuthenticator); >+ } >+ timeout = DEFAULT_TIMEOUT; >+ } >+ >+ public ASUploadConnection(ASConnection asConnection) { >+ this.host=asConnection.getHost(); >+ this.port=asConnection.getPort(); >+ this.timeout = DEFAULT_TIMEOUT; >+ } >+ >+ >+ public OutputStream getOutputStream(String fileName) { >+ String url = "http://" + host + ":" + port + UPLOAD_URL_PATH; >+ try { >+ // Create the HTTP connection to the upload URL >+ connection = (HttpURLConnection) new URL(url).openConnection(); >+ connection.setConnectTimeout(30 * 1000); // 30s >+ connection.setReadTimeout(timeout * 1000); // default 60s >+ connection.setDoInput(true); >+ connection.setDoOutput(true); >+ connection.setRequestMethod(POST_REQUEST_METHOD); >+ connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY_PARAM); >+ >+ // Grab the test WAR file and get a stream to its contents to be included in the POST. >+ os = new BufferedOutputStream(connection.getOutputStream()); >+ os.write(buildPostRequestHeader(fileName)); >+ >+ return os; >+ } >+ catch (Exception e) { >+ log.error("Failed to open output stream to URL [" + url + "]: " + e, e); >+ } >+ >+ return null; >+ } >+ >+ public JsonNode finishUpload() { >+ JsonNode tree = null; >+ try { >+ os.write(buildPostRequestFooter()); >+ os.flush(); >+ >+ int code = connection.getResponseCode(); >+ if (code != 200) { >+ log.warn("Response code for file upload: " + code + " " + connection.getResponseMessage()); >+ } >+ if (code == 500) >+ is = connection.getErrorStream(); >+ else >+ is = connection.getInputStream(); >+ >+ if (is != null) { >+ BufferedReader in = new BufferedReader(new InputStreamReader(is)); >+ String line; >+ StringBuilder builder = new StringBuilder(); >+ while ((line = in.readLine()) != null) { >+ builder.append(line); >+ } >+ >+ ObjectMapper mapper = new ObjectMapper(); >+ >+ String s = builder.toString(); >+ if (s!=null) >+ tree = mapper.readTree(s); >+ else >+ log.warn("- no result received from InputStream -"); >+ } >+ else >+ log.warn("- no InputStream available -"); >+ >+ } catch (IOException e) { >+ log.error(e); >+ } >+ finally { >+ closeQuietly(is); >+ closeQuietly(os); >+ } >+ >+ return tree; >+ } >+ >+ >+ private byte[] buildPostRequestHeader(String fileName) throws UnsupportedEncodingException { >+ final StringBuilder builder = new StringBuilder(); >+ builder.append(buildPostRequestHeaderSection("form-data; name=\"file\"; filename=\""+fileName+"\"", "application/octet-stream", "")); >+ return builder.toString().getBytes("US-ASCII"); >+ } >+ >+ private StringBuilder buildPostRequestHeaderSection(final String contentDisposition, final String contentType, final String content) { >+ final StringBuilder builder = new StringBuilder(); >+ builder.append(BOUNDARY); >+ builder.append(CRLF); >+ if(contentDisposition != null && contentDisposition.length() > 0) { >+ builder.append(String.format("Content-Disposition: %s", contentDisposition)); >+ } >+ builder.append(CRLF); >+ if(contentType != null && contentType.length() > 0) { >+ builder.append(String.format("Content-Type: %s", contentType)); >+ } >+ builder.append(CRLF); >+ if(content != null && content.length() > 0) { >+ builder.append(content); >+ } >+ builder.append(CRLF); >+ return builder; >+ } >+ >+ private byte[] buildPostRequestFooter() throws UnsupportedEncodingException{ >+ final StringBuilder builder = new StringBuilder(); >+ builder.append(CRLF); >+ builder.append(BOUNDARY); >+ builder.append("--"); >+ builder.append(CRLF); >+ return builder.toString().getBytes("US-ASCII"); >+ } >+ >+ public static String getFailureDescription(JsonNode jsonNode) { >+ if (jsonNode==null) >+ return "getFailureDescription: -input was null-"; >+ JsonNode node = jsonNode.findValue("failure-description"); >+ return node.getValueAsText(); >+ } >+ >+ public static boolean isErrorReply(JsonNode in) { >+ if (in == null) >+ return true; >+ >+ if (in.has("outcome")) { >+ String outcome = null; >+ try { >+ JsonNode outcomeNode = in.findValue("outcome"); >+ outcome = outcomeNode.getTextValue(); >+ if (outcome.equals("failed")) { >+ JsonNode reasonNode = in.findValue("failure-description"); >+ >+ String reason = reasonNode.getTextValue(); >+ return true; >+ } >+ } catch (Exception e) { >+ log.error(e); >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ private void closeQuietly(final Closeable closeable) { >+ if(closeable != null) { >+ try { >+ closeable.close(); >+ } catch (final IOException ignore) { >+ } >+ } >+ } >+ >+ /** >+ * Get the currently active upload timeout >+ * @return timeout in seconds >+ */ >+ public int getTimeout() { >+ return timeout; >+ } >+ >+ /** >+ * Set upload timeout in seconds. >+ * @param timeout upload timeout in seconds >+ */ >+ public void setTimeout(int timeout) { >+ this.timeout = timeout; >+ } >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ConnectionStats.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ConnectionStats.java >new file mode 100644 >index 0000000..823ad0d >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/ConnectionStats.java >@@ -0,0 +1,61 @@ >+package org.rhq.common.jbossas7.client; >+ >+import java.util.ArrayList; >+import java.util.List; >+import java.util.concurrent.atomic.AtomicLong; >+ >+/** >+ * Singleton that keeps track of some statistics of this plugin >+ * @author Heiko W. Rupp >+ */ >+public class ConnectionStats { >+ private static ConnectionStats ourInstance = new ConnectionStats(); >+ >+ AtomicLong requestCount = new AtomicLong(); >+ AtomicLong requestTime = new AtomicLong(); >+ private static final int FIFO_SIZE = 200; // Initial capacity >+ List<Long> maxTime = new ArrayList<Long>(FIFO_SIZE); >+ final Object lock = new Object(); >+ >+ >+ public static ConnectionStats getInstance() { >+ return ourInstance; >+ } >+ >+ private ConnectionStats() { >+ } >+ >+ public void incrementRequestCount() { >+ requestCount.incrementAndGet(); >+ } >+ >+ public void addRequestTime(long l) { >+ requestTime.addAndGet(l); >+ insertTime(l); >+ } >+ >+ public long getRequestCount() { >+ return requestCount.get(); >+ } >+ >+ public long getRequestTime() { >+ return requestTime.get(); >+ } >+ >+ public long getMaxTime() { >+ long max = 0; >+ synchronized (lock) { >+ for (Long i : maxTime) >+ if (i > max ) >+ max = i; >+ maxTime = new ArrayList<Long>(); >+ } >+ return max; >+ } >+ >+ private void insertTime(long time) { >+ synchronized (lock) { >+ maxTime.add(time); >+ } >+ } >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Address.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Address.java >new file mode 100644 >index 0000000..37c2898 >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Address.java >@@ -0,0 +1,219 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.codehaus.jackson.annotate.JsonIgnore; >+ >+/** >+ * An address in AS7 >+ * @author Heiko W. Rupp >+ */ >+public class Address { >+ >+ /** List of individual path components */ >+ List<PROPERTY_VALUE> path; >+ >+ /** Create an empty address */ >+ public Address() { >+ path = new ArrayList<PROPERTY_VALUE>(); >+ } >+ >+ /** >+ * Create an Address with an initial path element >+ * @param key key part of the path >+ * @param value value part of the path >+ */ >+ public Address(String key, String value) { >+ this(); >+ add(key, value); >+ } >+ >+ /** >+ * Construct an Address by cloning another >+ * @param other Address to clone >+ */ >+ public Address(Address other) { >+ this(); >+ if (other != null && other.path != null) >+ path.addAll(other.path); >+ } >+ >+ /** >+ * Construct an address from the passed list of path segments of property values. Should not be used >+ * outside the json package >+ * @param property_values list of values, each describing a key-value pair of a path >+ */ >+ Address(List<PROPERTY_VALUE> property_values) { >+ this(); >+ if (property_values != null) >+ path.addAll(property_values); >+ } >+ >+ /** >+ * Construct an Address from a path in the form (key=value)?(,key=value)* >+ * @param path Path string to parse >+ */ >+ public Address(String path) { >+ this(); >+ if (path == null || path.isEmpty()) >+ return; >+ // strips / from the start or end of the key if it happens to be there >+ if (path.startsWith("/")) { >+ path = path.substring(1); >+ } >+ if (path.endsWith("/")) { >+ path = path.substring(0,path.length()-1); >+ } >+ // Now split on comma boundaries >+ String[] components = path.split("[,]+"); >+ for (String component : components) { >+ String tmp = component.trim(); >+ // Split each segment on equals sign into key and value >+ if (tmp.contains("=")) { >+ PROPERTY_VALUE valuePair = pathFromSegment(tmp); >+ this.path.add(valuePair); >+ } >+ } >+ >+ } >+ >+ /** >+ * 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) { >+ 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 >+ */ >+ public void add(String key, String value) { >+ 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{" + "path: "); >+ if (path != null) { >+ Iterator<PROPERTY_VALUE> iterator = path.iterator(); >+ while (iterator.hasNext()) { >+ PROPERTY_VALUE pv = iterator.next(); >+ builder.append(pv.getKey()).append('=').append(pv.getValue()); >+ if (iterator.hasNext()) >+ builder.append(','); >+ } >+ } else { >+ builder.append("-empty-"); >+ } >+ >+ builder.append('}'); >+ return builder.toString(); >+ } >+ >+ /** >+ * Returns the Address as a string >+ * @return list of key value pairs for this path >+ */ >+ @JsonIgnore >+ public String getPath() { >+ StringBuilder builder = new StringBuilder(); >+ Iterator<PROPERTY_VALUE> iter = path.iterator(); >+ while (iter.hasNext()) { >+ PROPERTY_VALUE val = iter.next(); >+ builder.append(val.getKey()).append('=').append(val.getValue()); >+ if (iter.hasNext()) >+ builder.append(','); >+ } >+ return builder.toString(); >+ >+ } >+ >+ /** >+ * Add a whole address to the given path >+ * @param address Other address >+ * @see #Address(Address) >+ */ >+ public void add(Address address) { >+ if (address != null && address.path != null) >+ this.path.addAll(address.path); >+ } >+ >+ /** >+ * Indicates if this Address has path elements >+ * @return true if the address has no path elements >+ */ >+ @JsonIgnore >+ public boolean isEmpty() { >+ return path.isEmpty(); >+ } >+ >+ /** >+ * Returns the number of path elements of this address >+ * @return the number of path elements of this address >+ */ >+ public int size() { >+ return path.size(); >+ } >+ >+ /** >+ * Returns the n'th path element of the address >+ * @param n Number of the wanted path element >+ * @return A string representation of the wanted element >+ */ >+ public String get(int n) { >+ PROPERTY_VALUE property_value = path.get(n); >+ return property_value.getKey() + "=" + property_value.getValue(); >+ } >+ >+ /** >+ * Return the parent Address of the current one. That is the address with one >+ * path segment less. >+ * If the current address is empty (the root), an empty address is returned. >+ * @return parent Address >+ */ >+ public Address getParent() { >+ Address tmp = new Address(); >+ int l = path.size(); >+ if (l < 1) >+ return tmp; >+ >+ for (int i = 0; i < l - 1; i++) { >+ tmp.path.add(path.get(i)); >+ } >+ >+ return tmp; >+ } >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ComplexResult.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ComplexResult.java >new file mode 100644 >index 0000000..da7d672 >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ComplexResult.java >@@ -0,0 +1,40 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+import java.util.Map; >+ >+import org.rhq.common.jbossas7.client.json.Result; >+ >+/** >+ * A result object with a complex 'result' member >+ * @author Heiko W. Rupp >+ */ >+public class ComplexResult extends Result { >+ >+ private Map<String,Object> result; >+ >+ public Map<String, Object> getResult() { >+ return result; >+ } >+ >+ public void setResult(Map<String, Object> result) { >+ this.result = result; >+ } >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/CompositeOperation.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/CompositeOperation.java >new file mode 100644 >index 0000000..7af7dee >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/CompositeOperation.java >@@ -0,0 +1,77 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+ >+import org.codehaus.jackson.annotate.JsonProperty; >+ >+/** >+ * A composite operation contains multiple steps of a >+ * task that requires many individual operations to complete >+ * @author Heiko W. Rupp >+ */ >+public class CompositeOperation extends Operation { >+ >+ >+ >+ @JsonProperty >+ List<Operation> steps = new ArrayList<Operation>(); >+ >+ OperationHeaders operationHeaders; >+ >+ public CompositeOperation(List<Operation> steps) { >+ super("composite",new Address()); >+ this.steps = steps; >+ } >+ >+ public CompositeOperation() { >+ super("composite",new Address()); >+ } >+ >+ public void addStep(Operation step) { >+ steps.add(step); >+ } >+ >+ public void setOperationHeaders(OperationHeaders headers) { >+ operationHeaders = headers; >+ } >+ >+ private class OperationHeaders { >+ @JsonProperty("in-series") >+ List<PROPERTY_VALUE>inSeries = Collections.emptyList(); >+ @JsonProperty("rollback-across-groups") >+ boolean rollbackAcrossGroups; >+ } >+ >+ public int numberOfSteps() { >+ return steps.size(); >+ } >+ >+ public Operation step(int i) { >+ return steps.get(i); >+ } >+ >+ @Override >+ public String toString() { >+ return "CompositeOperation{steps=" + steps.size()+ "}"; >+ } >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Operation.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Operation.java >new file mode 100644 >index 0000000..62c26b4 >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Operation.java >@@ -0,0 +1,130 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.List; >+import java.util.Map; >+ >+import org.codehaus.jackson.annotate.JsonAnyGetter; >+import org.codehaus.jackson.annotate.JsonAnySetter; >+import org.codehaus.jackson.annotate.JsonIgnore; >+import org.codehaus.jackson.annotate.JsonProperty; >+ >+/** >+ * Operation to run on the server >+ * @author Heiko W. Rupp >+ */ >+public class Operation { >+ >+ @JsonProperty >+ private String operation; >+ @JsonProperty(value = "address") >+ private List<PROPERTY_VALUE> _address ; >+ @JsonIgnore >+ Address address ; >+ private Map<String,Object> additionalProperties; >+ >+ >+ public Operation(String operation, String addressKey, String addressValue) { >+ this.operation = operation; >+ this.address = new Address(addressKey,addressValue); >+ this._address = address.path; >+ additionalProperties = new HashMap<String, Object>(); >+ } >+ >+ public Operation(String operation, Address address) { >+ this.operation = operation; >+ additionalProperties = new HashMap<String, Object>(); >+ if (address!=null && address.path!=null) { >+ this.address = address; >+ this._address = address.path; >+ } else { >+ _address = Collections.emptyList(); >+ } >+ } >+ >+ public Operation(String operation, Address address, Map<String, Object> additionalProperties) { >+ this(operation,address); >+ this.additionalProperties = additionalProperties; >+ } >+ >+ public Operation() { >+ // needed for Jackson >+ } >+ >+ @JsonAnySetter >+ public void addAdditionalProperty(String key, Object value) { >+ if (additionalProperties == null) >+ additionalProperties = new HashMap<String, Object>(); >+ additionalProperties.put(key,value); >+ } >+ >+ @SuppressWarnings("unused") >+ public void setAdditionalProperties(Map<String, Object> additionalProperties) { >+ this.additionalProperties = additionalProperties; >+ } >+ >+ @JsonAnyGetter >+ public Map<String,Object> getAdditionalProperties() { >+ return this.additionalProperties; >+ } >+ >+ @JsonIgnore >+ public String getName() { >+ return (String) getProperty("name"); >+ } >+ >+ @JsonIgnore >+ public String getValue() { >+ return (String) getProperty("value"); >+ } >+ >+ private Object getProperty(String key) { >+ if (additionalProperties.containsKey(key)) >+ return additionalProperties.get(key); >+ else >+ return null; >+ } >+ >+ @JsonProperty >+ public String getOperation() { >+ return operation; >+ } >+ >+ @JsonIgnore >+ public Address getAddress() { >+ if (address==null) { >+ address = new Address(_address); >+ } >+ return address; >+ } >+ >+ >+ @Override >+ public String toString() { >+ return "Operation{" + >+ "operation='" + operation + '\'' + >+ ", address=" + address + >+ ", additionalProperties=" + additionalProperties + >+ '}'; >+ } >+} >+ >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/PROPERTY_VALUE.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/PROPERTY_VALUE.java >new file mode 100644 >index 0000000..729b501 >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/PROPERTY_VALUE.java >@@ -0,0 +1,67 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+import java.io.Serializable; >+ >+import org.codehaus.jackson.map.annotate.JsonDeserialize; >+import org.codehaus.jackson.map.annotate.JsonSerialize; >+ >+import org.rhq.common.jbossas7.client.json.serializer.PropertyValueDeserializer; >+import org.rhq.common.jbossas7.client.json.serializer.PropertyValueSerializer; >+ >+/** >+ * @author Heiko W. Rupp >+ */ >+@JsonSerialize(using = PropertyValueSerializer.class) >+@JsonDeserialize(using = PropertyValueDeserializer.class) >+public class PROPERTY_VALUE implements Serializable{ >+ >+ private String key; >+ private String value; >+ >+ public PROPERTY_VALUE(String key, String value) { >+ this.key = key; >+ this.value = value; >+ } >+ >+ public String getKey() { >+ return key; >+ } >+ >+ public String getValue() { >+ return value; >+ } >+ >+ public void setKey(String key) { >+ this.key = key; >+ } >+ >+ public void setValue(String value) { >+ this.value = value; >+ } >+ >+ @Override >+ public String toString() { >+ return "PROPERTY_VALUE{" + >+ "key='" + key + '\'' + >+ ", value='" + value + '\'' + >+ '}'; >+ } >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadAttribute.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadAttribute.java >new file mode 100644 >index 0000000..45a139f >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadAttribute.java >@@ -0,0 +1,36 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+/** >+ * Read Attribute operation >+ * @author Heiko W. Rupp >+ */ >+public class ReadAttribute extends Operation { >+ >+ public ReadAttribute(Address address, String name) { >+ super("read-attribute", address); >+ addAdditionalProperty("name", name); >+ } >+ >+ public void includeDefaults(boolean arg) { >+ addAdditionalProperty("include-defaults", arg); >+ } >+ >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadChildrenNames.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadChildrenNames.java >new file mode 100644 >index 0000000..fd00342 >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadChildrenNames.java >@@ -0,0 +1,36 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+/** >+ * Operation that reads names of children of a given type from an address >+ * @author Heiko W. Rupp >+ */ >+public class ReadChildrenNames extends Operation { >+ >+ /** >+ * Read children names of a given type below a given address >+ * @param address Address to look at e.g. /profile/default/subsystem/messaging >+ * @param childType e.g. queue >+ */ >+ public ReadChildrenNames(Address address, String childType) { >+ super("read-children-names",address); >+ addAdditionalProperty("child-type",childType); >+ } >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadChildrenResources.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadChildrenResources.java >new file mode 100644 >index 0000000..6e5123e >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadChildrenResources.java >@@ -0,0 +1,36 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+/** >+ * Operation that reads children of a given type from an address >+ * @author Heiko W. Rupp >+ */ >+public class ReadChildrenResources extends Operation { >+ >+ /** >+ * Read children names of a given type below a given address >+ * @param address Address to look at e.g. /profile/default/subsystem/messaging >+ * @param childType e.g. queue >+ */ >+ public ReadChildrenResources(Address address, String childType) { >+ super("read-children-resources",address); >+ addAdditionalProperty("child-type",childType); >+ } >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadResource.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadResource.java >new file mode 100644 >index 0000000..2acf8c1 >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/ReadResource.java >@@ -0,0 +1,53 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+/** >+ * Reads data for one AS 7 resource >+ * @author Heiko W. Rupp >+ */ >+public class ReadResource extends Operation { >+ >+ private static final String READ_RESOURCE = "read-resource"; >+ >+ public ReadResource(String resourceType,String typeValue) { >+ super(READ_RESOURCE,resourceType,typeValue); >+ } >+ >+ public ReadResource(String resourceType,String typeValue,boolean includeDefaults) { >+ super(READ_RESOURCE,resourceType,typeValue); >+ includeDefaults(includeDefaults); >+ } >+ >+ public ReadResource(Address address) { >+ super(READ_RESOURCE,address); >+ } >+ >+ public void includeRuntime(boolean arg) { >+ addAdditionalProperty("include-runtime",arg); >+ } >+ >+ public void includeDefaults(boolean arg) { >+ addAdditionalProperty("include-defaults",arg); >+ } >+ >+ public void recursive(boolean arg) { >+ addAdditionalProperty("recursive",arg); >+ } >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Remove.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Remove.java >new file mode 100644 >index 0000000..8190f3d >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Remove.java >@@ -0,0 +1,36 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+/** >+ * The :remove operation >+ * @author Heiko W. Rupp >+ */ >+public class Remove extends Operation{ >+ >+ private static final String REMOVE = "remove"; >+ >+ public Remove(Address address) { >+ super("remove",address); >+ } >+ >+ public Remove(String key, String value) { >+ super(REMOVE,key,value); >+ } >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Result.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Result.java >new file mode 100644 >index 0000000..4ee9e99 >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/Result.java >@@ -0,0 +1,159 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+import java.util.Map; >+ >+import org.codehaus.jackson.annotate.JsonIgnore; >+import org.codehaus.jackson.annotate.JsonProperty; >+ >+/** >+ * Counterpart of a result JSON object, e.g.: >+ * <pre> >+ * {"outcome" : "success", "result" : "no metrics available", "compensating-operation" : null} >+ * {"outcome" : "failed", "failure-description" : "JBAS010850: No handler for operation foo at address []", "rolled-back" : true} >+ * </pre> >+ * >+ * @author Heiko W. Rupp >+ */ >+public class Result { >+ >+ public static final String SUCCESS = "success"; >+ private String outcome; >+ private Object result; >+ @JsonProperty("failure-description") >+ private /*List<Map<String, String>>*/Object failureDescription; >+ @JsonIgnore >+ private boolean success = false; >+ @JsonProperty("rolled-back") >+ private boolean rolledBack = false; >+ @JsonIgnore >+ private Throwable rhqThrowable; >+ >+ /** Record throwables during low level processing */ >+ @JsonIgnore >+ private Map<String,Object> throwable; >+ >+ public Object getResponseHeaders() { >+ return responseHeaders; >+ } >+ >+ public void setResponseHeaders(Object responseHeaders) { >+ this.responseHeaders = responseHeaders; >+ } >+ >+ @JsonProperty("response-headers") >+ private Object responseHeaders; >+ >+ public Result() { >+ >+ } >+ >+ public String getOutcome() { >+ return outcome; >+ } >+ >+ public void setOutcome(String outcome) { >+ this.outcome = outcome; >+ if (outcome.equalsIgnoreCase(SUCCESS)) >+ success = true; >+ } >+ >+ @JsonIgnore >+ public boolean isReloadRequired() { >+ if (responseHeaders==null) >+ return false; >+ if (responseHeaders instanceof Map) { >+ Map<String,Object> map = (Map<String, Object>) responseHeaders; >+ if (map.containsKey("process-state") && map.get("process-state").equals("reload-required")) { >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ @JsonIgnore >+ public boolean isRestartRequired() { >+ if (responseHeaders == null) >+ return false; >+ if (responseHeaders instanceof Map) { >+ Map<String, Object> map = (Map<String, Object>) responseHeaders; >+ if (map.containsKey("process-state") && map.get("process-state").equals("restart-required")) { >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ public boolean isSuccess() { >+ return success; >+ } >+ >+ public Object getResult() { >+ return result; >+ } >+ >+ public void setResult(Object result) { >+ this.result = result; >+ } >+ >+ public String getFailureDescription() { >+ return failureDescription + ", rolled-back=" + rolledBack; >+ } >+ >+ public void setFailureDescription(/*List<Map<String, String>>*/Object failureDescription) { >+ this.failureDescription = failureDescription; >+ } >+ >+ public boolean isRolledBack() { >+ return rolledBack; >+ } >+ >+ public void setRolledBack(boolean rolledBack) { >+ this.rolledBack = rolledBack; >+ } >+ >+ public Map<String, Object> getThrowable() { >+ return throwable; >+ } >+ >+ public void setThrowable(Map<String,Object> throwable) { >+ this.throwable = throwable; >+ } >+ >+ @JsonIgnore >+ public Throwable getRhqThrowable() { >+ return rhqThrowable; >+ } >+ >+ @JsonIgnore >+ public void setRhqThrowable(Throwable rhqThrowable) { >+ this.rhqThrowable = rhqThrowable; >+ } >+ >+ @Override >+ public String toString() { >+ return "Result{" + >+ "outcome='" + outcome + '\'' + >+ ", failureDescription=" + failureDescription + >+ ", rolledBack=" + rolledBack + >+ '}'; >+ } >+ >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/WriteAttribute.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/WriteAttribute.java >new file mode 100644 >index 0000000..1e7be9f >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/WriteAttribute.java >@@ -0,0 +1,39 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json; >+ >+/** >+ * Operation to write one attribute >+ * @author Heiko W. Rupp >+ */ >+public class WriteAttribute extends Operation { >+ >+ private static final String WRITE_ATTRIBUTE = "write-attribute"; >+ >+ public WriteAttribute(Address address) { >+ super(WRITE_ATTRIBUTE,address); >+ } >+ >+ public WriteAttribute(Address address,String name, Object value) { >+ super(WRITE_ATTRIBUTE,address); >+ addAdditionalProperty("name",name); >+ addAdditionalProperty("value",value); >+ } >+ >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/serializer/PropertyValueDeserializer.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/serializer/PropertyValueDeserializer.java >new file mode 100644 >index 0000000..6cd329a >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/serializer/PropertyValueDeserializer.java >@@ -0,0 +1,52 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json.serializer; >+ >+import java.io.IOException; >+ >+import org.codehaus.jackson.JsonParser; >+import org.codehaus.jackson.JsonProcessingException; >+import org.codehaus.jackson.map.DeserializationContext; >+import org.codehaus.jackson.map.JsonDeserializer; >+ >+import org.rhq.common.jbossas7.client.json.PROPERTY_VALUE; >+ >+/** >+ * Deserialize {"foo":"bar"} into a PROPERTY_VALUE >+ * @author Heiko W. Rupp >+ */ >+public class PropertyValueDeserializer extends JsonDeserializer<PROPERTY_VALUE> { >+ >+ >+ @Override >+ public PROPERTY_VALUE deserialize(JsonParser jsonParser, >+ DeserializationContext deserializationContext) throws IOException, JsonProcessingException { >+ >+ String tmp = jsonParser.getText(); // { >+ jsonParser.nextToken(); >+ String key = jsonParser.getText(); >+ jsonParser.nextToken(); >+ String value = jsonParser.getText(); >+ jsonParser.nextToken(); >+ tmp = jsonParser.getText(); // } >+ >+ PROPERTY_VALUE pv = new PROPERTY_VALUE(key,value); >+ return pv; >+ } >+} >diff --git a/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/serializer/PropertyValueSerializer.java b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/serializer/PropertyValueSerializer.java >new file mode 100644 >index 0000000..8837a19 >--- /dev/null >+++ b/modules/common/jboss-as-7-client/src/main/java/org/rhq/common/jbossas7/client/json/serializer/PropertyValueSerializer.java >@@ -0,0 +1,45 @@ >+/* >+ * RHQ Management Platform >+ * Copyright (C) 2005-2011 Red Hat, Inc. >+ * All rights reserved. >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation version 2 of the License. >+ * >+ * This program 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 General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >+ */ >+package org.rhq.common.jbossas7.client.json.serializer; >+ >+import java.io.IOException; >+ >+import org.codehaus.jackson.JsonGenerator; >+import org.codehaus.jackson.JsonProcessingException; >+import org.codehaus.jackson.map.JsonSerializer; >+import org.codehaus.jackson.map.SerializerProvider; >+ >+import org.rhq.common.jbossas7.client.json.PROPERTY_VALUE; >+ >+/** >+ * Serialize the key/value pair from PROPERTY_VALUE into {"value of key":"value of value"} >+ * @author Heiko W. Rupp >+ */ >+public class PropertyValueSerializer extends JsonSerializer<PROPERTY_VALUE> { >+ >+ @Override >+ public void serialize(PROPERTY_VALUE property_value, JsonGenerator jsonGenerator, >+ SerializerProvider serializerProvider) throws IOException, JsonProcessingException { >+ >+ jsonGenerator.writeStartObject(); >+ jsonGenerator.writeFieldName(property_value.getKey()); >+ jsonGenerator.writeString(property_value.getValue()); >+ jsonGenerator.writeEndObject(); >+ } >+} >diff --git a/modules/common/pom.xml b/modules/common/pom.xml >index f364ae9..1f5a30a 100644 >--- a/modules/common/pom.xml >+++ b/modules/common/pom.xml >@@ -54,6 +54,7 @@ > > <modules> > <module>jboss-as</module> >+ <module>jboss-as-7-client</module> > <module>filetemplate-bundle</module> > <module>ant-bundle</module> > <module>drift</module> >diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml >index a640c0541..dcb098c 100644 >--- a/modules/plugins/jboss-as-7/pom.xml >+++ b/modules/plugins/jboss-as-7/pom.xml >@@ -65,6 +65,12 @@ > <version>${jboss.sasl.version}</version> > </dependency> > >+ <dependency> >+ <groupId>org.rhq</groupId> >+ <artifactId>rhq-jboss-as-7-client</artifactId> >+ <version>${project.version}</version> >+ </dependency> >+ > <!-- === Test Deps === --> > > <dependency> >@@ -120,6 +126,11 @@ > <artifactId>jboss-sasl</artifactId> > </artifactItem> > >+ <artifactItem> >+ <groupId>org.rhq</groupId> >+ <artifactId>rhq-jboss-as-7-client</artifactId> >+ </artifactItem> >+ > </artifactItems> > <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory> > </configuration> >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 >deleted file mode 100644 >index 703e177..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Authenticator.java >+++ /dev/null >@@ -1,26 +0,0 @@ >-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/AS7Component.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Component.java >index 0dd4acd..6fd6895 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Component.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AS7Component.java >@@ -1,5 +1,6 @@ > package org.rhq.modules.plugins.jbossas7; > >+import org.rhq.common.jbossas7.client.ASConnection; > import org.rhq.core.pluginapi.inventory.ResourceComponent; > > /** >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 >deleted file mode 100644 >index 0687516..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java >+++ /dev/null >@@ -1,550 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2012 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7; >- >-import java.io.BufferedReader; >-import java.io.BufferedWriter; >-import java.io.IOException; >-import java.io.InputStream; >-import java.io.InputStreamReader; >-import java.io.OutputStream; >-import java.io.StringWriter; >-import java.net.Authenticator; >-import java.net.HttpURLConnection; >-import java.net.MalformedURLException; >-import java.net.SocketTimeoutException; >-import java.net.URL; >-import java.util.StringTokenizer; >- >-import org.apache.commons.logging.Log; >-import org.apache.commons.logging.LogFactory; >-import org.codehaus.jackson.JsonNode; >-import org.codehaus.jackson.map.DeserializationConfig; >-import org.codehaus.jackson.map.ObjectMapper; >-import org.codehaus.jackson.map.SerializationConfig; >-import org.jetbrains.annotations.NotNull; >- >-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.Result; >- >-/** >- * Provide management connections to an AS7 instance and reading/writing data from/to it. >- * >- * @author Heiko W. Rupp >- * @author Ian Springer >- */ >-public class ASConnection { >- >- public static final String MANAGEMENT = "/management"; >- private static final String FAILURE_DESCRIPTION = "\"failure-description\""; >- >- // This is a variable on purpose, so devs can switch it on in the debugger or in the agent >- public static boolean verbose = false; >- private static final int HTTP_TEMPORARY_REDIRECT = 307; >- >- private static final String POST_HTTP_METHOD = "POST"; >- >- private static final String CONTENT_LENGTH_HTTP_HEADER = "Content-Length"; >- private static final String ACCEPT_HTTP_HEADER = "Accept"; >- private static final String CONTENT_TYPE_HTTP_HEADER = "Content-Type"; >- >- private static final String JSON_MIME_TYPE = "application/json"; >- >- private final Log log = LogFactory.getLog(ASConnection.class); >- >- private URL url; >- private String urlString; >- private ObjectMapper mapper; >- private Authenticator passwordAuthenticator; >- private String host; >- private int port; >- >- /** >- * Construct an ASConnection object. The real "physical" connection is done in {@link #executeRaw(Operation)}. >- * >- * @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, String user, String password) { >- if (host == null) { >- throw new IllegalArgumentException("Management host cannot be null."); >- } >- if (port <= 0 || port > 65535) { >- throw new IllegalArgumentException("Invalid port: " + port); >- } >- this.host = host; >- this.port = port; >- >- try { >- url = new URL("http", host, port, MANAGEMENT); >- urlString = url.toString(); >- } catch (MalformedURLException e) { >- throw new IllegalArgumentException(e.getMessage()); >- } >- >- passwordAuthenticator = new AS7Authenticator(user, password); >- Authenticator.setDefault(passwordAuthenticator); >- >- // read system property "as7plugin.verbose" >- verbose = Boolean.getBoolean("as7plugin.verbose"); >- >- mapper = new ObjectMapper(); >- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); >- } >- >- /** >- * Execute an operation against the domain api. This method is doing the >- * real work by talking to the remote server and sending JSON data, that >- * is obtained by serializing the operation. >- * >- * Please do not use this API , but execute() >- * @return JsonNode that describes the result >- * @param operation an Operation that should be run on the domain controller >- * @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation) >- * @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean) >- * @see #executeComplex(org.rhq.modules.plugins.jbossas7.json.Operation) >- */ >- public JsonNode executeRaw(Operation operation) { >- return executeRaw(operation, 20); >- } >- >- /** >- * Execute an operation against the domain api. This method is doing the >- * real work by talking to the remote server and sending JSON data, that >- * is obtained by serializing the operation. >- * >- * Please do not use this API, but rather use {@link #execute(Operation)}. >- * >- * @param operation an Operation that should be run on the domain controller >- * @param timeoutSec Timeout on connect and read in seconds >- * >- * @return JsonNode that describes the result >- * >- * @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation) >- * @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean) >- * @see #executeComplex(org.rhq.modules.plugins.jbossas7.json.Operation) >- */ >- public JsonNode executeRaw(Operation operation, int timeoutSec) { >- long requestStartTime = System.currentTimeMillis(); >- >- HttpURLConnection conn; >- OutputStream out; >- try { >- conn = (HttpURLConnection) url.openConnection(); >- conn.setDoOutput(true); >- conn.setRequestMethod(POST_HTTP_METHOD); >- conn.addRequestProperty(CONTENT_TYPE_HTTP_HEADER, JSON_MIME_TYPE); >- conn.addRequestProperty(ACCEPT_HTTP_HEADER, JSON_MIME_TYPE); >- conn.setInstanceFollowRedirects(false); >- int timeoutMillis = timeoutSec * 1000; >- conn.setConnectTimeout(timeoutMillis); >- conn.setReadTimeout(timeoutMillis); >- if (conn.getReadTimeout() != timeoutMillis) { >- log.warn("Read timeout did not get set on HTTP connection - the JRE uses a broken timeout mechanism - nothing we can do."); >- } >- >- out = conn.getOutputStream(); >- } catch (IOException e) { >- // This most likely just means the server is down. >- if (log.isDebugEnabled()) { >- log.debug("Failed to open connection to [" + urlString + "] in order to invoke [" + operation + "]: " >- + e); >- } >- // TODO (ips): Would it make more sense to return null here, since we didn't even connect? >- Result failure = new Result(); >- failure.setFailureDescription(e.toString()); >- failure.setOutcome("failure"); >- failure.setRhqThrowable(e); >- JsonNode ret = mapper.valueToTree(failure); >- return ret; >- } >- >- try { >- String jsonToSend = mapper.writeValueAsString(operation); >- >- // Check for spaces in the path, which the AS7 server will reject. Log verbose error and >- // generate failure indicator. >- if ((operation != null) && (operation.getAddress() != null) && operation.getAddress().getPath() != null) { >- if (containsSpaces(operation.getAddress().getPath())) { >- Result noResult = new Result(); >- String outcome = "- Path '" + operation.getAddress().getPath() >- + "' is invalid as it contains spaces -"; >- if (verbose) { >- log.error(outcome); >- } >- noResult.setFailureDescription(outcome); >- noResult.setOutcome("failure"); >- JsonNode invalidPathResult = mapper.valueToTree(noResult); >- return invalidPathResult; >- } >- } >- >- if (verbose) { >- log.info("JSON to send: " + jsonToSend); >- } >- >- mapper.writeValue(out, operation); >- >- out.flush(); >- out.close(); >- >- ResponseStatus responseStatus = new ResponseStatus(conn); >- if (isAuthorizationFailureResponse(responseStatus.getResponseCode())) { >- handleAuthorizationFailureResponse(operation, responseStatus); >- } >- >- String responseBody = getResponseBody(conn); >- if (responseStatus.getResponseCode() >= 400) { >- if (verbose) { >- log.debug(operation + " failed with " + responseStatus + " - response body was [" + responseBody >- + "]."); >- } >- >- if (responseBody.contains("JBAS014807") || responseBody.contains("JBAS010850") || responseBody.contains("JBAS014793")) { >- // management resource not found or not readable or no known child-type >- if (log.isDebugEnabled()) { >- log.debug("Requested management resource not found: " + operation.getAddress().getPath()); >- } >- } else { >- log.warn("Received " + responseStatus + " response to " + operation + " - response body was [" + >- responseBody + "]."); >- } >- } >- >- JsonNode operationResult; >- if (!responseBody.isEmpty()) { >- try { >- operationResult = mapper.readTree(responseBody); >- } catch (IOException ioe) { >- log.error("Failed to deserialize response to " + operation + " to JsonNode - response status was " >- + responseStatus + ", and body was [" + responseBody + "]: " + ioe); >- Result result = new Result(); >- result.setOutcome("failure"); >- result.setFailureDescription("Failed to deserialize response to " + operation + " to JsonNode - response status was " >- + responseStatus + ", and body was [" + responseBody + "]: " + ioe); >- result.setRolledBack(responseBody.contains("rolled-back=true")); >- result.setRhqThrowable(ioe); >- operationResult = mapper.valueToTree(result); >- } >- >- if (verbose) { >- ObjectMapper om2 = new ObjectMapper(); >- om2.configure(SerializationConfig.Feature.INDENT_OUTPUT, true); >- try { >- String resultString = om2.writeValueAsString(operationResult); >- log.info(resultString); >- } catch (IOException ioe) { >- log.error("Failed to convert result of " + operation + " to string.", ioe); >- } >- } >- } else { >- Result noResult = new Result(); >- noResult.setOutcome("failure"); >- noResult.setFailureDescription("- empty response body with HTTP status code " + responseStatus + " -"); >- operationResult = mapper.valueToTree(noResult); >- } >- >- return operationResult; >- } catch (IllegalArgumentException iae) { >- log.error("Illegal argument for input " + operation + ": " + iae.getMessage()); >- } catch (SocketTimeoutException ste) { >- log.error(operation + " timed out: " + ste.getMessage()); >- conn.disconnect(); >- Result failure = new Result(); >- failure.setFailureDescription(ste.getMessage()); >- failure.setOutcome("failure"); >- failure.setRhqThrowable(ste); >- JsonNode ret = mapper.valueToTree(failure); >- return ret; >- } catch (IOException ioe) { >- conn.disconnect(); >- Result failure = new Result(); >- failure.setFailureDescription(ioe.getMessage()); >- failure.setOutcome("failure"); >- failure.setRhqThrowable(ioe); >- JsonNode ret = mapper.valueToTree(failure); >- return ret; >- } finally { >- long requestEndTime = System.currentTimeMillis(); >- PluginStats stats = PluginStats.getInstance(); >- stats.incrementRequestCount(); >- stats.addRequestTime(requestEndTime - requestStartTime); >- } >- >- return null; >- } >- >- // When no management users have been configured, a 307 (Temporary Redirect) response will be returned, and >- // when authorization has failed due to an invalid username or password, a 401 (Unauthorized) response will be >- // returned. >- private boolean isAuthorizationFailureResponse(int responseCode) { >- return responseCode == HttpURLConnection.HTTP_UNAUTHORIZED || responseCode == HTTP_TEMPORARY_REDIRECT; >- } >- >- private void handleAuthorizationFailureResponse(Operation operation, ResponseStatus responseStatus) { >- if (log.isDebugEnabled()) { >- log.debug("Response to " + operation + " was " + responseStatus >- + " - throwing InvalidPluginConfigurationException..."); >- } >- // Throw a InvalidPluginConfigurationException, so the user will get a yellow plugin connection >- // warning message in the GUI. >- String message; >- if (responseStatus.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) { >- message = "Credentials for plugin to connect to AS7 management interface are invalid - update Connection Settings with valid credentials."; >- } else { >- message = "Authorization to AS7 failed - did you install a management user?"; >- } >- throw new InvalidPluginConfigurationException(message); >- } >- >- private String getResponseMessage(HttpURLConnection conn) throws IOException { >- String responseMessage = conn.getResponseMessage(); >- if ((responseMessage == null) && (conn.getResponseCode() == HTTP_TEMPORARY_REDIRECT)) { >- responseMessage = "Temporary Redirect"; >- } >- return responseMessage; >- } >- >- /** Method parses Operation.getAddress().getPath() for invalid spaces in the path passed in. >- * >- * @param path Operation.getAddress().getPath() value. >- * @return boolean indicating invalid spaces found. >- */ >- private boolean containsSpaces(String path) { >- boolean includesSpaces = false; >- StringTokenizer components = new StringTokenizer(path, " "); >- if (components.countTokens() > 1) { >- includesSpaces = true; >- } >- return includesSpaces; >- } >- >- /** >- * Execute the passed Operation and return its Result. This is a shortcut of >- * #execute(Operation, false) >- * @param op Operation to execute >- * @return Result of the execution >- * @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean) >- */ >- public Result execute(Operation op) { >- return execute(op, false, 10); >- } >- >- /** >- * Execute the passed Operation and return its Result. This is a shortcut of >- * #execute(Operation, false) >- * @param op Operation to execute >- * @param timeoutSec Timeout to wait in seconds. Default is 10 sec >- * @return Result of the execution >- * @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean) >- */ >- public Result execute(Operation op, int timeoutSec) { >- return execute(op, false, timeoutSec); >- } >- >- /** >- * Execute the passed Operation and return its ComplexResult. This is a shortcut of >- * #execute(Operation, true) >- * @param op Operation to execute >- * @return ComplexResult of the execution >- * @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean) >- */ >- public ComplexResult executeComplex(Operation op) { >- return (ComplexResult) execute(op, true, 10); >- } >- >- /** >- * Execute the passed Operation and return its ComplexResult. This is a shortcut of >- * #execute(Operation, true) >- * @param op Operation to execute >- * @param timeoutSec Timeout to wait in seconds. Default is 10 sec >- * @return ComplexResult of the execution >- * @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean) >- */ >- public ComplexResult executeComplex(Operation op, int timeoutSec) { >- return (ComplexResult) execute(op, true, timeoutSec); >- } >- >- /** >- * Execute the passed Operation and return its Result. Depending on <i>isComplex</i> >- * the return type is a simple Result or a ComplexResult. Default timeout here is 10sec >- * @param op Operation to execute >- * @param isComplex should a complex result be returned? >- * @return ComplexResult of the execution >- */ >- public Result execute(Operation op, boolean isComplex) { >- return execute(op, isComplex, 10); >- } >- >- /** >- * Execute the passed Operation and return its Result. Depending on <i>isComplex</i> >- * the return type is a simple Result or a ComplexResult >- * >- * @param op Operation to execute >- * @param isComplex should a complex result be returned? >- * @param timeoutSec >- * @return ComplexResult of the execution >- */ >- public Result execute(Operation op, boolean isComplex, int timeoutSec) { >- JsonNode node = executeRaw(op, timeoutSec); >- >- if (node == null) { >- log.warn("Operation [" + op + "] returned null."); >- Result failure = new Result(); >- failure.setFailureDescription("Operation [" + op + "] returned null."); >- return failure; >- } >- Result res; >- try { >- //check for failure-description indicator, otherwise ObjectMapper will try to deserialize as json. Ex. >- // {"outcome":"failed","failure-description":"JBAS014792: Unknown attribute number-of-timed-out-transactions","rolled-back":true} >- String as7ResultSerialization = node.toString(); >- >- if (as7ResultSerialization.indexOf(FAILURE_DESCRIPTION) > -1) { >- if (verbose) { >- log.warn("------ Detected 'failure-description' when communicating with server." >- + as7ResultSerialization); >- } >- } >- >- if (isComplex) { >- res = mapper.readValue(node, ComplexResult.class); >- } else { >- res = mapper.readValue(node, Result.class); >- } >- return res; >- } catch (IOException e) { >- log.error(e.getMessage()); >- if (verbose) { >- log.error("----------- Operation execution unparsable. Request " + ":[" + op + "] Response:<" + node >- + ">"); >- } >- Result failure = new Result(); >- failure.setFailureDescription("Operation <" + op + "> returned unparsable JSON, <" + node + ">."); >- return failure; >- //don't return null. >- } >- } >- >- public String getHost() { >- return host; >- } >- >- public int getPort() { >- return port; >- } >- >- @NotNull >- private String getResponseBody(HttpURLConnection connection) { >- InputStream inputStream; >- try { >- inputStream = connection.getInputStream(); >- } catch (IOException e) { >- // This means the server returned a 4xx (client error) or 5xx (server error) response, e.g.: >- // "java.io.IOException: Server returned HTTP response code: 500 for URL: http://127.0.0.1:9990/management" >- // Unfortunately, AS7 incorrectly returns 500 responses for client errors (e.g. invalid resource path, >- // attribute name, etc.). >- inputStream = null; >- } >- if (inputStream == null) { >- inputStream = connection.getErrorStream(); >- } >- if (inputStream == null) { >- return ""; >- } >- >- int contentLength = connection.getHeaderFieldInt(CONTENT_LENGTH_HTTP_HEADER, -1); >- >- BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); >- StringWriter stringWriter = (contentLength != -1) ? new StringWriter(contentLength) : new StringWriter(); >- BufferedWriter writer = new BufferedWriter(stringWriter); >- try { >- long numCharsCopied = 0; >- char[] buffer = new char[1024]; >- >- int cnt; >- while (((contentLength == -1) || (numCharsCopied < contentLength)) && ((cnt = reader.read(buffer)) != -1)) { >- numCharsCopied += cnt; >- writer.write(buffer, 0, cnt); >- } >- } catch (IOException e) { >- throw new RuntimeException("Failed to read response.", e); >- } finally { >- try { >- writer.close(); >- } catch (IOException ioe) { >- log.debug("Failed to close writer.", ioe); >- } >- >- try { >- reader.close(); >- } catch (IOException ioe) { >- log.debug("Failed to close reader.", ioe); >- } >- } >- >- return stringWriter.getBuffer().toString(); >- } >- >- private class ResponseStatus { >- >- private Integer responseCode; >- private String responseMessage; >- >- ResponseStatus(HttpURLConnection connection) throws IOException { >- try { >- responseCode = connection.getResponseCode(); >- } catch (IOException e) { >- // try one more time >- responseCode = connection.getResponseCode(); >- } >- >- try { >- responseMessage = connection.getResponseMessage(); >- } catch (IOException e) { >- // try one more time >- responseMessage = connection.getResponseMessage(); >- } >- >- if (responseMessage == null) { >- responseMessage = (getResponseCode() == HTTP_TEMPORARY_REDIRECT) ? "Temporary Redirect" : ""; >- } >- } >- >- public int getResponseCode() { >- return responseCode; >- } >- >- @NotNull >- public String getResponseMessage() { >- return responseMessage; >- } >- >- @Override >- public String toString() { >- return getResponseCode() + " (" + getResponseMessage() + ")"; >- } >- >- } >- >-} >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 >deleted file mode 100644 >index a7fe82d..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java >+++ /dev/null >@@ -1,250 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7; >- >-import java.io.BufferedOutputStream; >-import java.io.BufferedReader; >-import java.io.Closeable; >-import java.io.IOException; >-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; >- >-import org.apache.commons.logging.Log; >-import org.apache.commons.logging.LogFactory; >-import org.codehaus.jackson.JsonNode; >-import org.codehaus.jackson.map.ObjectMapper; >- >-/** >- * Connection for uploading of content. >- * Partially taken from https://github.com/jbossas/jboss-as/blob/master/testsuite/smoke/src/test/java/org/jboss/as/test/surefire/servermodule/HttpDeploymentUploadUnitTestCase.java >- * >- * @author Jonathan Pearlin (of the original code) >- * @author Heiko W. Rupp >- */ >-public class ASUploadConnection { >- >- private static final String BOUNDARY_PARAM = "NeAG1QNIHHOyB5joAS7Rox!!"; >- >- private static final String BOUNDARY = "--" + BOUNDARY_PARAM; >- >- private static final String CRLF = "\r\n"; >- >- private static final String POST_REQUEST_METHOD = "POST"; >- >- private static final String UPLOAD_URL_PATH = ASConnection.MANAGEMENT + "/add-content"; >- >- 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; >- private int timeout; >- private static final int DEFAULT_TIMEOUT = 60; // 60sec >- >- public ASUploadConnection(String dcHost, int port, String user, String password) { >- if (dcHost == null) { >- throw new IllegalArgumentException("Management host cannot be null."); >- } >- if (port <= 0 || port > 65535) { >- throw new IllegalArgumentException("Invalid port: " + port); >- } >- this.host = dcHost; >- this.port = port; >- if (user != null) { >- passwordAuthenticator = new AS7Authenticator(user,password); >- Authenticator.setDefault(passwordAuthenticator); >- } >- timeout = DEFAULT_TIMEOUT; >- } >- >- public ASUploadConnection(ASConnection asConnection) { >- this.host=asConnection.getHost(); >- this.port=asConnection.getPort(); >- this.timeout = DEFAULT_TIMEOUT; >- } >- >- >- public OutputStream getOutputStream(String fileName) { >- String url = "http://" + host + ":" + port + UPLOAD_URL_PATH; >- try { >- // Create the HTTP connection to the upload URL >- connection = (HttpURLConnection) new URL(url).openConnection(); >- connection.setConnectTimeout(30 * 1000); // 30s >- connection.setReadTimeout(timeout * 1000); // default 60s >- connection.setDoInput(true); >- connection.setDoOutput(true); >- connection.setRequestMethod(POST_REQUEST_METHOD); >- connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY_PARAM); >- >- // Grab the test WAR file and get a stream to its contents to be included in the POST. >- os = new BufferedOutputStream(connection.getOutputStream()); >- os.write(buildPostRequestHeader(fileName)); >- >- return os; >- } >- catch (Exception e) { >- log.error("Failed to open output stream to URL [" + url + "]: " + e, e); >- } >- >- return null; >- } >- >- public JsonNode finishUpload() { >- JsonNode tree = null; >- try { >- os.write(buildPostRequestFooter()); >- os.flush(); >- >- int code = connection.getResponseCode(); >- if (code != 200) { >- log.warn("Response code for file upload: " + code + " " + connection.getResponseMessage()); >- } >- if (code == 500) >- is = connection.getErrorStream(); >- else >- is = connection.getInputStream(); >- >- if (is != null) { >- BufferedReader in = new BufferedReader(new InputStreamReader(is)); >- String line; >- StringBuilder builder = new StringBuilder(); >- while ((line = in.readLine()) != null) { >- builder.append(line); >- } >- >- ObjectMapper mapper = new ObjectMapper(); >- >- String s = builder.toString(); >- if (s!=null) >- tree = mapper.readTree(s); >- else >- log.warn("- no result received from InputStream -"); >- } >- else >- log.warn("- no InputStream available -"); >- >- } catch (IOException e) { >- log.error(e); >- } >- finally { >- closeQuietly(is); >- closeQuietly(os); >- } >- >- return tree; >- } >- >- >- private byte[] buildPostRequestHeader(String fileName) throws UnsupportedEncodingException { >- final StringBuilder builder = new StringBuilder(); >- builder.append(buildPostRequestHeaderSection("form-data; name=\"file\"; filename=\""+fileName+"\"", "application/octet-stream", "")); >- return builder.toString().getBytes("US-ASCII"); >- } >- >- private StringBuilder buildPostRequestHeaderSection(final String contentDisposition, final String contentType, final String content) { >- final StringBuilder builder = new StringBuilder(); >- builder.append(BOUNDARY); >- builder.append(CRLF); >- if(contentDisposition != null && contentDisposition.length() > 0) { >- builder.append(String.format("Content-Disposition: %s", contentDisposition)); >- } >- builder.append(CRLF); >- if(contentType != null && contentType.length() > 0) { >- builder.append(String.format("Content-Type: %s", contentType)); >- } >- builder.append(CRLF); >- if(content != null && content.length() > 0) { >- builder.append(content); >- } >- builder.append(CRLF); >- return builder; >- } >- >- private byte[] buildPostRequestFooter() throws UnsupportedEncodingException{ >- final StringBuilder builder = new StringBuilder(); >- builder.append(CRLF); >- builder.append(BOUNDARY); >- builder.append("--"); >- builder.append(CRLF); >- return builder.toString().getBytes("US-ASCII"); >- } >- >- public static String getFailureDescription(JsonNode jsonNode) { >- if (jsonNode==null) >- return "getFailureDescription: -input was null-"; >- JsonNode node = jsonNode.findValue("failure-description"); >- return node.getValueAsText(); >- } >- >- static boolean isErrorReply(JsonNode in) { >- if (in == null) >- return true; >- >- if (in.has("outcome")) { >- String outcome = null; >- try { >- JsonNode outcomeNode = in.findValue("outcome"); >- outcome = outcomeNode.getTextValue(); >- if (outcome.equals("failed")) { >- JsonNode reasonNode = in.findValue("failure-description"); >- >- String reason = reasonNode.getTextValue(); >- return true; >- } >- } catch (Exception e) { >- log.error(e); >- return true; >- } >- } >- return false; >- } >- >- private void closeQuietly(final Closeable closeable) { >- if(closeable != null) { >- try { >- closeable.close(); >- } catch (final IOException ignore) { >- } >- } >- } >- >- /** >- * Get the currently active upload timeout >- * @return timeout in seconds >- */ >- public int getTimeout() { >- return timeout; >- } >- >- /** >- * Set upload timeout in seconds. >- * @param timeout upload timeout in seconds >- */ >- public void setTimeout(int timeout) { >- this.timeout = timeout; >- } >-} >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 2851128..94ded2e 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 >@@ -30,6 +30,18 @@ import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > import org.codehaus.jackson.JsonNode; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.ASUploadConnection; >+import org.rhq.common.jbossas7.client.ConnectionStats; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.CompositeOperation; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.PROPERTY_VALUE; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.ReadChildrenNames; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Remove; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.Property; > import org.rhq.core.domain.configuration.PropertyList; >@@ -64,15 +76,6 @@ import org.rhq.core.pluginapi.operation.OperationFacet; > import org.rhq.core.pluginapi.operation.OperationResult; > import org.rhq.core.pluginapi.util.StartScriptConfiguration; > import org.rhq.modules.plugins.jbossas7.helper.ServerPluginConfiguration; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Remove; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * The base class for all AS7 resource components. >@@ -246,7 +249,7 @@ public class BaseComponent<T extends ResourceComponent<?>> implements AS7Compone > > name = name.substring(INTERNAL_SIZE); > >- PluginStats stats = PluginStats.getInstance(); >+ ConnectionStats stats = ConnectionStats.getInstance(); > MeasurementDataNumeric data; > Double val; > if (name.equals("mgmtRequests")) { >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 ed716e1..9f2df7f 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 >@@ -38,6 +38,10 @@ import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > import org.w3c.dom.Document; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertyList; > import org.rhq.core.domain.configuration.PropertyMap; >@@ -58,9 +62,6 @@ import org.rhq.core.system.ProcessInfo; > import org.rhq.modules.plugins.jbossas7.helper.HostConfiguration; > import org.rhq.modules.plugins.jbossas7.helper.HostPort; > import org.rhq.modules.plugins.jbossas7.helper.ServerPluginConfiguration; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Abstract base discovery component for the two server types - "JBossAS7 Host Controller" and >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 8b85deb..04f3d72 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 >@@ -35,6 +35,13 @@ import org.jetbrains.annotations.NotNull; > > import org.jboss.sasl.util.UsernamePasswordHashUtil; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.domain.measurement.AvailabilityType; >@@ -55,12 +62,6 @@ import org.rhq.core.system.SystemInfo; > import org.rhq.core.util.PropertiesFileUpdate; > import org.rhq.modules.plugins.jbossas7.helper.HostConfiguration; > import org.rhq.modules.plugins.jbossas7.helper.ServerPluginConfiguration; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Base component for functionality that is common to Standalone Servers and Host Controllers. >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 0a49bd1..b5101eb 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 >@@ -27,6 +27,13 @@ import java.util.Map; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.ReadChildrenResources; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.Property; > import org.rhq.core.domain.configuration.PropertyList; >@@ -40,12 +47,6 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; > import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition; > import org.rhq.core.pluginapi.configuration.ConfigurationFacet; > import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.ReadChildrenResources; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > public class ConfigurationLoadDelegate implements ConfigurationFacet { > >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 366f840..5704a4a 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 >@@ -27,6 +27,15 @@ import java.util.Map; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.CompositeOperation; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadChildrenResources; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Remove; >+import org.rhq.common.jbossas7.client.json.Result; >+import org.rhq.common.jbossas7.client.json.WriteAttribute; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.ConfigurationUpdateStatus; > import org.rhq.core.domain.configuration.Property; >@@ -42,14 +51,6 @@ import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition; > import org.rhq.core.domain.configuration.definition.PropertySimpleType; > import org.rhq.core.pluginapi.configuration.ConfigurationFacet; > import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadChildrenResources; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Remove; >-import org.rhq.modules.plugins.jbossas7.json.Result; >-import org.rhq.modules.plugins.jbossas7.json.WriteAttribute; > > public class ConfigurationWriteDelegate implements ConfigurationFacet { > >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/CreateResourceDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/CreateResourceDelegate.java >index 4f14ea6..8c8b9fa 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/CreateResourceDelegate.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/CreateResourceDelegate.java >@@ -20,6 +20,10 @@ package org.rhq.modules.plugins.jbossas7; > > import java.util.AbstractMap.SimpleEntry; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Property; > import org.rhq.core.domain.configuration.PropertyList; > import org.rhq.core.domain.configuration.PropertyMap; >@@ -31,9 +35,6 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; > import org.rhq.core.domain.resource.CreateResourceStatus; > import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; > import org.rhq.core.pluginapi.inventory.CreateResourceReport; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > public class CreateResourceDelegate extends ConfigurationWriteDelegate implements CreateChildResourceFacet { > >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java >index a4efae1..15877a5 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java >@@ -9,6 +9,14 @@ import java.util.Set; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.CompositeOperation; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.Property; > import org.rhq.core.domain.configuration.PropertyList; >@@ -19,18 +27,10 @@ import org.rhq.core.domain.measurement.MeasurementReport; > import org.rhq.core.domain.measurement.MeasurementScheduleRequest; > import org.rhq.core.domain.resource.CreateResourceStatus; > import org.rhq.core.pluginapi.configuration.ConfigurationFacet; >-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; > import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; > import org.rhq.core.pluginapi.inventory.CreateResourceReport; > import org.rhq.core.pluginapi.operation.OperationFacet; > import org.rhq.core.pluginapi.operation.OperationResult; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Handle Datasorces (possibly jdbc-driver) related stuff >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DeploymentComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DeploymentComponent.java >index 7be42bb..34eee13 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DeploymentComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DeploymentComponent.java >@@ -15,6 +15,13 @@ import java.util.Set; > > import org.codehaus.jackson.JsonNode; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.ASUploadConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.PROPERTY_VALUE; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.content.PackageDetailsKey; > import org.rhq.core.domain.content.PackageType; >@@ -39,11 +46,6 @@ import org.rhq.core.util.Base64; > import org.rhq.core.util.ByteUtil; > import org.rhq.core.util.file.ContentFileInfo; > import org.rhq.core.util.file.JarContentFileInfo; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Deal with deployments >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 a532c3a..9fe5260 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 >@@ -25,9 +25,10 @@ import java.util.HashMap; > import java.util.Map; > import java.util.Set; > >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.Operation; > > /** > * Generate properties, metrics and operation templates for the plugin >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDeploymentComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDeploymentComponent.java >index 6192c18..d1e8e7d 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDeploymentComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDeploymentComponent.java >@@ -4,17 +4,17 @@ import java.util.ArrayList; > import java.util.Collection; > import java.util.List; > >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.CompositeOperation; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadChildrenNames; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.domain.measurement.AvailabilityType; > import org.rhq.core.pluginapi.operation.OperationFacet; > import org.rhq.core.pluginapi.operation.OperationResult; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Handle domain deployments >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostComponent.java >index 847e7ac..0f5f750 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostComponent.java >@@ -23,14 +23,14 @@ import java.util.Date; > import java.util.HashSet; > import java.util.Set; > >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.measurement.MeasurementDataTrait; > import org.rhq.core.domain.measurement.MeasurementReport; > import org.rhq.core.domain.measurement.MeasurementScheduleRequest; > import org.rhq.core.pluginapi.measurement.MeasurementFacet; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Component class for a host in a domain >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 565add2..bfa07af 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 >@@ -23,6 +23,9 @@ import java.util.Set; > > import org.jetbrains.annotations.NotNull; > >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.domain.measurement.MeasurementReport; >@@ -33,9 +36,6 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent; > import org.rhq.core.pluginapi.measurement.MeasurementFacet; > import org.rhq.core.pluginapi.operation.OperationFacet; > import org.rhq.core.pluginapi.operation.OperationResult; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Component class for AS7 host and domain controllers. >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JDRComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JDRComponent.java >index 2e11035..8ca287b 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JDRComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JDRComponent.java >@@ -20,14 +20,14 @@ package org.rhq.modules.plugins.jbossas7; > > import java.util.Map; > >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.pluginapi.inventory.ResourceComponent; > import org.rhq.core.pluginapi.operation.OperationFacet; > import org.rhq.core.pluginapi.operation.OperationResult; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Component for the JDR subsystem >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/LoggerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/LoggerComponent.java >index f9ff8a3..63ce69f 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/LoggerComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/LoggerComponent.java >@@ -25,13 +25,14 @@ import java.util.Map; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.Operation; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.Property; > import org.rhq.core.domain.configuration.PropertyList; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.pluginapi.operation.OperationResult; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.Operation; > > /** > * Component class that deals with the Logging subsystem >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java >index d26f54e..88a23ed 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASComponent.java >@@ -24,6 +24,12 @@ import java.util.HashSet; > import java.util.Map; > import java.util.Set; > >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.domain.measurement.AvailabilityType; >@@ -34,12 +40,6 @@ import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper; > import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; > import org.rhq.core.pluginapi.inventory.ResourceContext; > import org.rhq.core.pluginapi.operation.OperationResult; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * A component for a "Managed Server" Resource. >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 10889ce..def3704 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 >@@ -28,6 +28,14 @@ import java.util.Set; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.ReadChildrenNames; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertyList; > import org.rhq.core.domain.configuration.PropertyMap; >@@ -36,13 +44,6 @@ import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper; > import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; > import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; > import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Discovery class for managed AS 7 instances. >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java >index 427da83..ac4c683 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java >@@ -2,14 +2,14 @@ package org.rhq.modules.plugins.jbossas7; > > import java.util.ArrayList; > >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.pluginapi.configuration.ConfigurationFacet; > import org.rhq.core.pluginapi.operation.OperationFacet; > import org.rhq.core.pluginapi.operation.OperationResult; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Component class for ModCluster >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterConfigurationDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterConfigurationDiscovery.java >index d8f3ea1..08a5245 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterConfigurationDiscovery.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterConfigurationDiscovery.java >@@ -29,14 +29,15 @@ import org.apache.commons.logging.LogFactory; > import org.codehaus.jackson.map.DeserializationConfig; > import org.codehaus.jackson.map.ObjectMapper; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ReadChildrenNames; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; > import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Discover subsystems. We need to distinguish two cases denoted by the path >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterContextComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterContextComponent.java >index 836b6a7..6730919 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterContextComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterContextComponent.java >@@ -1,11 +1,11 @@ > package org.rhq.modules.plugins.jbossas7; > >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.measurement.AvailabilityType; > import org.rhq.core.pluginapi.availability.AvailabilityFacet; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.Result; > import org.rhq.modules.plugins.jbossas7.modcluster.ProxyInfo; > > /** >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterContextDiscoveryComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterContextDiscoveryComponent.java >index eed0c3b..48e372f 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterContextDiscoveryComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterContextDiscoveryComponent.java >@@ -25,11 +25,12 @@ import java.util.Set; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; > import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.Result; > import org.rhq.modules.plugins.jbossas7.modcluster.ProxyInfo; > > /** >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterDiscoveryComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterDiscoveryComponent.java >index a32a565..ae069ca 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterDiscoveryComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterDiscoveryComponent.java >@@ -8,15 +8,16 @@ import org.apache.commons.logging.LogFactory; > import org.codehaus.jackson.map.DeserializationConfig; > import org.codehaus.jackson.map.ObjectMapper; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; > import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; > import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; > import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Discovery class for ModCluster Domain node. >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModuleOptionsComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModuleOptionsComponent.java >index d486542..89b2b23 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModuleOptionsComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModuleOptionsComponent.java >@@ -11,6 +11,13 @@ import org.codehaus.jackson.annotate.JsonProperty; > import org.codehaus.jackson.map.annotate.JsonSerialize; > import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.ReadChildrenNames; >+import org.rhq.common.jbossas7.client.json.Result; >+import org.rhq.common.jbossas7.client.json.WriteAttribute; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.ConfigurationUpdateStatus; > import org.rhq.core.domain.configuration.PropertyMap; >@@ -23,12 +30,6 @@ import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; > import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; > import org.rhq.core.pluginapi.inventory.CreateResourceReport; > import org.rhq.core.pluginapi.inventory.DeleteResourceFacet; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; >-import org.rhq.modules.plugins.jbossas7.json.Result; >-import org.rhq.modules.plugins.jbossas7.json.WriteAttribute; > > /** > * Component class for Module Options. Necessary because Module Options are child >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModuleOptionsDiscoveryComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModuleOptionsDiscoveryComponent.java >index 619d7d5..391dae7 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModuleOptionsDiscoveryComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModuleOptionsDiscoveryComponent.java >@@ -7,6 +7,12 @@ import java.util.Set; > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.ReadChildrenNames; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; >@@ -14,11 +20,6 @@ import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException; > import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; > import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; > import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent.Value; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Discovery class for Module Options nodes. >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java >index 81d1999..0c28dad 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java >@@ -2,15 +2,15 @@ package org.rhq.modules.plugins.jbossas7; > > import java.util.Map; > >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertyList; > import org.rhq.core.domain.configuration.PropertyMap; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.pluginapi.operation.OperationFacet; > import org.rhq.core.pluginapi.operation.OperationResult; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Component for the naming subsystem >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/PluginStats.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/PluginStats.java >deleted file mode 100644 >index 1a44dde..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/PluginStats.java >+++ /dev/null >@@ -1,61 +0,0 @@ >-package org.rhq.modules.plugins.jbossas7; >- >-import java.util.ArrayList; >-import java.util.List; >-import java.util.concurrent.atomic.AtomicLong; >- >-/** >- * Singleton that keeps track of some statistics of this plugin >- * @author Heiko W. Rupp >- */ >-public class PluginStats { >- private static PluginStats ourInstance = new PluginStats(); >- >- AtomicLong requestCount = new AtomicLong(); >- AtomicLong requestTime = new AtomicLong(); >- private static final int FIFO_SIZE = 200; // Initial capacity >- List<Long> maxTime = new ArrayList<Long>(FIFO_SIZE); >- final Object lock = new Object(); >- >- >- public static PluginStats getInstance() { >- return ourInstance; >- } >- >- private PluginStats() { >- } >- >- public void incrementRequestCount() { >- requestCount.incrementAndGet(); >- } >- >- public void addRequestTime(long l) { >- requestTime.addAndGet(l); >- insertTime(l); >- } >- >- public long getRequestCount() { >- return requestCount.get(); >- } >- >- public long getRequestTime() { >- return requestTime.get(); >- } >- >- public long getMaxTime() { >- long max = 0; >- synchronized (lock) { >- for (Long i : maxTime) >- if (i > max ) >- max = i; >- maxTime = new ArrayList<Long>(); >- } >- return max; >- } >- >- private void insertTime(long time) { >- synchronized (lock) { >- maxTime.add(time); >- } >- } >-} >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 8d5c64e..44d5fb5 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 >@@ -29,6 +29,14 @@ import java.util.Set; > > import org.codehaus.jackson.JsonNode; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.ASUploadConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.CompositeOperation; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.PROPERTY_VALUE; >+import org.rhq.common.jbossas7.client.json.ReadChildrenNames; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.content.PackageDetailsKey; > import org.rhq.core.domain.content.PackageType; >@@ -45,12 +53,6 @@ import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; > import org.rhq.core.pluginapi.operation.OperationFacet; > import org.rhq.core.pluginapi.operation.OperationResult; > import org.rhq.modules.plugins.jbossas7.helper.ServerPluginConfiguration; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; >-import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Component dealing with server group specific things >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 6eb19f6..cd0069f 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 >@@ -23,6 +23,10 @@ import java.util.Set; > > import org.jetbrains.annotations.NotNull; > >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.Property; > import org.rhq.core.domain.configuration.PropertyList; >@@ -34,10 +38,6 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent; > import org.rhq.core.pluginapi.measurement.MeasurementFacet; > import org.rhq.core.pluginapi.operation.OperationFacet; > import org.rhq.core.pluginapi.operation.OperationResult; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Component class for standalone AS7 servers. >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java >index deec7a3..b5dcde9 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java >@@ -29,16 +29,17 @@ import org.apache.commons.logging.LogFactory; > import org.codehaus.jackson.map.DeserializationConfig; > import org.codehaus.jackson.map.ObjectMapper; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ReadChildrenNames; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.domain.resource.ResourceType; > import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; > import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; > import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Discover subsystems. We need to distinguish two cases denoted by the path >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ThreadingComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ThreadingComponent.java >index 9080262..db009f6 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ThreadingComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ThreadingComponent.java >@@ -21,11 +21,11 @@ package org.rhq.modules.plugins.jbossas7; > > import java.util.List; > >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.pluginapi.operation.OperationResult; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Component class for Threading within the runtime >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/VHostComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/VHostComponent.java >index 342bcba..02244bb 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/VHostComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/VHostComponent.java >@@ -24,12 +24,12 @@ import java.util.HashSet; > import java.util.List; > import java.util.Set; > >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.measurement.MeasurementDataTrait; > import org.rhq.core.domain.measurement.MeasurementReport; > import org.rhq.core.domain.measurement.MeasurementScheduleRequest; > import org.rhq.core.pluginapi.measurement.MeasurementFacet; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Component class for virtual hosts >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebConnectorComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebConnectorComponent.java >index 3af95fd..474ebea 100644 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebConnectorComponent.java >+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebConnectorComponent.java >@@ -22,15 +22,15 @@ package org.rhq.modules.plugins.jbossas7; > import java.util.HashSet; > import java.util.Set; > >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.domain.measurement.MeasurementDataNumeric; > import org.rhq.core.domain.measurement.MeasurementReport; > import org.rhq.core.domain.measurement.MeasurementScheduleRequest; > import org.rhq.core.pluginapi.measurement.MeasurementFacet; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Component class for the WebConnector (subsystem=web,connector=* ) >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 >deleted file mode 100644 >index fefad2f..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java >+++ /dev/null >@@ -1,219 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-import java.util.ArrayList; >-import java.util.Iterator; >-import java.util.List; >- >-import org.codehaus.jackson.annotate.JsonIgnore; >- >-/** >- * An address in AS7 >- * @author Heiko W. Rupp >- */ >-public class Address { >- >- /** List of individual path components */ >- List<PROPERTY_VALUE> path; >- >- /** Create an empty address */ >- public Address() { >- path = new ArrayList<PROPERTY_VALUE>(); >- } >- >- /** >- * Create an Address with an initial path element >- * @param key key part of the path >- * @param value value part of the path >- */ >- public Address(String key, String value) { >- this(); >- add(key, value); >- } >- >- /** >- * Construct an Address by cloning another >- * @param other Address to clone >- */ >- public Address(Address other) { >- this(); >- if (other != null && other.path != null) >- path.addAll(other.path); >- } >- >- /** >- * Construct an address from the passed list of path segments of property values. Should not be used >- * outside the json package >- * @param property_values list of values, each describing a key-value pair of a path >- */ >- Address(List<PROPERTY_VALUE> property_values) { >- this(); >- if (property_values != null) >- path.addAll(property_values); >- } >- >- /** >- * Construct an Address from a path in the form (key=value)?(,key=value)* >- * @param path Path string to parse >- */ >- public Address(String path) { >- this(); >- if (path == null || path.isEmpty()) >- return; >- // strips / from the start or end of the key if it happens to be there >- if (path.startsWith("/")) { >- path = path.substring(1); >- } >- if (path.endsWith("/")) { >- path = path.substring(0,path.length()-1); >- } >- // Now split on comma boundaries >- String[] components = path.split("[,]+"); >- for (String component : components) { >- String tmp = component.trim(); >- // Split each segment on equals sign into key and value >- if (tmp.contains("=")) { >- PROPERTY_VALUE valuePair = pathFromSegment(tmp); >- this.path.add(valuePair); >- } >- } >- >- } >- >- /** >- * 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) { >- 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 >- */ >- public void add(String key, String value) { >- 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{" + "path: "); >- if (path != null) { >- Iterator<PROPERTY_VALUE> iterator = path.iterator(); >- while (iterator.hasNext()) { >- PROPERTY_VALUE pv = iterator.next(); >- builder.append(pv.getKey()).append('=').append(pv.getValue()); >- if (iterator.hasNext()) >- builder.append(','); >- } >- } else { >- builder.append("-empty-"); >- } >- >- builder.append('}'); >- return builder.toString(); >- } >- >- /** >- * Returns the Address as a string >- * @return list of key value pairs for this path >- */ >- @JsonIgnore >- public String getPath() { >- StringBuilder builder = new StringBuilder(); >- Iterator<PROPERTY_VALUE> iter = path.iterator(); >- while (iter.hasNext()) { >- PROPERTY_VALUE val = iter.next(); >- builder.append(val.getKey()).append('=').append(val.getValue()); >- if (iter.hasNext()) >- builder.append(','); >- } >- return builder.toString(); >- >- } >- >- /** >- * Add a whole address to the given path >- * @param address Other address >- * @see #Address(Address) >- */ >- public void add(Address address) { >- if (address != null && address.path != null) >- this.path.addAll(address.path); >- } >- >- /** >- * Indicates if this Address has path elements >- * @return true if the address has no path elements >- */ >- @JsonIgnore >- public boolean isEmpty() { >- return path.isEmpty(); >- } >- >- /** >- * Returns the number of path elements of this address >- * @return the number of path elements of this address >- */ >- public int size() { >- return path.size(); >- } >- >- /** >- * Returns the n'th path element of the address >- * @param n Number of the wanted path element >- * @return A string representation of the wanted element >- */ >- public String get(int n) { >- PROPERTY_VALUE property_value = path.get(n); >- return property_value.getKey() + "=" + property_value.getValue(); >- } >- >- /** >- * Return the parent Address of the current one. That is the address with one >- * path segment less. >- * If the current address is empty (the root), an empty address is returned. >- * @return parent Address >- */ >- public Address getParent() { >- Address tmp = new Address(); >- int l = path.size(); >- if (l < 1) >- return tmp; >- >- for (int i = 0; i < l - 1; i++) { >- tmp.path.add(path.get(i)); >- } >- >- return tmp; >- } >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ComplexResult.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ComplexResult.java >deleted file mode 100644 >index 134026d..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ComplexResult.java >+++ /dev/null >@@ -1,40 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-import java.util.Map; >- >-import org.rhq.modules.plugins.jbossas7.json.Result; >- >-/** >- * A result object with a complex 'result' member >- * @author Heiko W. Rupp >- */ >-public class ComplexResult extends Result { >- >- private Map<String,Object> result; >- >- public Map<String, Object> getResult() { >- return result; >- } >- >- public void setResult(Map<String, Object> result) { >- this.result = result; >- } >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/CompositeOperation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/CompositeOperation.java >deleted file mode 100644 >index d6ecef0..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/CompositeOperation.java >+++ /dev/null >@@ -1,77 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-import java.util.ArrayList; >-import java.util.Collections; >-import java.util.List; >- >-import org.codehaus.jackson.annotate.JsonProperty; >- >-/** >- * A composite operation contains multiple steps of a >- * task that requires many individual operations to complete >- * @author Heiko W. Rupp >- */ >-public class CompositeOperation extends Operation { >- >- >- >- @JsonProperty >- List<Operation> steps = new ArrayList<Operation>(); >- >- OperationHeaders operationHeaders; >- >- public CompositeOperation(List<Operation> steps) { >- super("composite",new Address()); >- this.steps = steps; >- } >- >- public CompositeOperation() { >- super("composite",new Address()); >- } >- >- public void addStep(Operation step) { >- steps.add(step); >- } >- >- public void setOperationHeaders(OperationHeaders headers) { >- operationHeaders = headers; >- } >- >- private class OperationHeaders { >- @JsonProperty("in-series") >- List<PROPERTY_VALUE>inSeries = Collections.emptyList(); >- @JsonProperty("rollback-across-groups") >- boolean rollbackAcrossGroups; >- } >- >- public int numberOfSteps() { >- return steps.size(); >- } >- >- public Operation step(int i) { >- return steps.get(i); >- } >- >- @Override >- public String toString() { >- return "CompositeOperation{steps=" + steps.size()+ "}"; >- } >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java >deleted file mode 100644 >index 23df1a5..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java >+++ /dev/null >@@ -1,130 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-import java.util.Collections; >-import java.util.HashMap; >-import java.util.List; >-import java.util.Map; >- >-import org.codehaus.jackson.annotate.JsonAnyGetter; >-import org.codehaus.jackson.annotate.JsonAnySetter; >-import org.codehaus.jackson.annotate.JsonIgnore; >-import org.codehaus.jackson.annotate.JsonProperty; >- >-/** >- * Operation to run on the server >- * @author Heiko W. Rupp >- */ >-public class Operation { >- >- @JsonProperty >- private String operation; >- @JsonProperty(value = "address") >- private List<PROPERTY_VALUE> _address ; >- @JsonIgnore >- Address address ; >- private Map<String,Object> additionalProperties; >- >- >- public Operation(String operation, String addressKey, String addressValue) { >- this.operation = operation; >- this.address = new Address(addressKey,addressValue); >- this._address = address.path; >- additionalProperties = new HashMap<String, Object>(); >- } >- >- public Operation(String operation, Address address) { >- this.operation = operation; >- additionalProperties = new HashMap<String, Object>(); >- if (address!=null && address.path!=null) { >- this.address = address; >- this._address = address.path; >- } else { >- _address = Collections.emptyList(); >- } >- } >- >- public Operation(String operation, Address address, Map<String, Object> additionalProperties) { >- this(operation,address); >- this.additionalProperties = additionalProperties; >- } >- >- public Operation() { >- // needed for Jackson >- } >- >- @JsonAnySetter >- public void addAdditionalProperty(String key, Object value) { >- if (additionalProperties == null) >- additionalProperties = new HashMap<String, Object>(); >- additionalProperties.put(key,value); >- } >- >- @SuppressWarnings("unused") >- public void setAdditionalProperties(Map<String, Object> additionalProperties) { >- this.additionalProperties = additionalProperties; >- } >- >- @JsonAnyGetter >- public Map<String,Object> getAdditionalProperties() { >- return this.additionalProperties; >- } >- >- @JsonIgnore >- public String getName() { >- return (String) getProperty("name"); >- } >- >- @JsonIgnore >- public String getValue() { >- return (String) getProperty("value"); >- } >- >- private Object getProperty(String key) { >- if (additionalProperties.containsKey(key)) >- return additionalProperties.get(key); >- else >- return null; >- } >- >- @JsonProperty >- public String getOperation() { >- return operation; >- } >- >- @JsonIgnore >- public Address getAddress() { >- if (address==null) { >- address = new Address(_address); >- } >- return address; >- } >- >- >- @Override >- public String toString() { >- return "Operation{" + >- "operation='" + operation + '\'' + >- ", address=" + address + >- ", additionalProperties=" + additionalProperties + >- '}'; >- } >-} >- >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java >deleted file mode 100644 >index c9c9ac9..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java >+++ /dev/null >@@ -1,67 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-import java.io.Serializable; >- >-import org.codehaus.jackson.map.annotate.JsonDeserialize; >-import org.codehaus.jackson.map.annotate.JsonSerialize; >- >-import org.rhq.modules.plugins.jbossas7.json.serializer.PropertyValueDeserializer; >-import org.rhq.modules.plugins.jbossas7.json.serializer.PropertyValueSerializer; >- >-/** >- * @author Heiko W. Rupp >- */ >-@JsonSerialize(using = PropertyValueSerializer.class) >-@JsonDeserialize(using = PropertyValueDeserializer.class) >-public class PROPERTY_VALUE implements Serializable{ >- >- private String key; >- private String value; >- >- public PROPERTY_VALUE(String key, String value) { >- this.key = key; >- this.value = value; >- } >- >- public String getKey() { >- return key; >- } >- >- public String getValue() { >- return value; >- } >- >- public void setKey(String key) { >- this.key = key; >- } >- >- public void setValue(String value) { >- this.value = value; >- } >- >- @Override >- public String toString() { >- return "PROPERTY_VALUE{" + >- "key='" + key + '\'' + >- ", value='" + value + '\'' + >- '}'; >- } >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadAttribute.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadAttribute.java >deleted file mode 100644 >index 66911c7..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadAttribute.java >+++ /dev/null >@@ -1,36 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-/** >- * Read Attribute operation >- * @author Heiko W. Rupp >- */ >-public class ReadAttribute extends Operation { >- >- public ReadAttribute(Address address, String name) { >- super("read-attribute", address); >- addAdditionalProperty("name", name); >- } >- >- public void includeDefaults(boolean arg) { >- addAdditionalProperty("include-defaults", arg); >- } >- >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java >deleted file mode 100644 >index 514767e..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java >+++ /dev/null >@@ -1,36 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-/** >- * Operation that reads names of children of a given type from an address >- * @author Heiko W. Rupp >- */ >-public class ReadChildrenNames extends Operation { >- >- /** >- * Read children names of a given type below a given address >- * @param address Address to look at e.g. /profile/default/subsystem/messaging >- * @param childType e.g. queue >- */ >- public ReadChildrenNames(Address address, String childType) { >- super("read-children-names",address); >- addAdditionalProperty("child-type",childType); >- } >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenResources.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenResources.java >deleted file mode 100644 >index 8a7f9b4..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenResources.java >+++ /dev/null >@@ -1,36 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-/** >- * Operation that reads children of a given type from an address >- * @author Heiko W. Rupp >- */ >-public class ReadChildrenResources extends Operation { >- >- /** >- * Read children names of a given type below a given address >- * @param address Address to look at e.g. /profile/default/subsystem/messaging >- * @param childType e.g. queue >- */ >- public ReadChildrenResources(Address address, String childType) { >- super("read-children-resources",address); >- addAdditionalProperty("child-type",childType); >- } >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java >deleted file mode 100644 >index 1eece34..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java >+++ /dev/null >@@ -1,53 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-/** >- * Reads data for one AS 7 resource >- * @author Heiko W. Rupp >- */ >-public class ReadResource extends Operation { >- >- private static final String READ_RESOURCE = "read-resource"; >- >- public ReadResource(String resourceType,String typeValue) { >- super(READ_RESOURCE,resourceType,typeValue); >- } >- >- public ReadResource(String resourceType,String typeValue,boolean includeDefaults) { >- super(READ_RESOURCE,resourceType,typeValue); >- includeDefaults(includeDefaults); >- } >- >- public ReadResource(Address address) { >- super(READ_RESOURCE,address); >- } >- >- public void includeRuntime(boolean arg) { >- addAdditionalProperty("include-runtime",arg); >- } >- >- public void includeDefaults(boolean arg) { >- addAdditionalProperty("include-defaults",arg); >- } >- >- public void recursive(boolean arg) { >- addAdditionalProperty("recursive",arg); >- } >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Remove.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Remove.java >deleted file mode 100644 >index 2d1eb79..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Remove.java >+++ /dev/null >@@ -1,36 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-/** >- * The :remove operation >- * @author Heiko W. Rupp >- */ >-public class Remove extends Operation{ >- >- private static final String REMOVE = "remove"; >- >- public Remove(Address address) { >- super("remove",address); >- } >- >- public Remove(String key, String value) { >- super(REMOVE,key,value); >- } >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java >deleted file mode 100644 >index 3fbdb90..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java >+++ /dev/null >@@ -1,159 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-import java.util.Map; >- >-import org.codehaus.jackson.annotate.JsonIgnore; >-import org.codehaus.jackson.annotate.JsonProperty; >- >-/** >- * Counterpart of a result JSON object, e.g.: >- * <pre> >- * {"outcome" : "success", "result" : "no metrics available", "compensating-operation" : null} >- * {"outcome" : "failed", "failure-description" : "JBAS010850: No handler for operation foo at address []", "rolled-back" : true} >- * </pre> >- * >- * @author Heiko W. Rupp >- */ >-public class Result { >- >- public static final String SUCCESS = "success"; >- private String outcome; >- private Object result; >- @JsonProperty("failure-description") >- private /*List<Map<String, String>>*/Object failureDescription; >- @JsonIgnore >- private boolean success = false; >- @JsonProperty("rolled-back") >- private boolean rolledBack = false; >- @JsonIgnore >- private Throwable rhqThrowable; >- >- /** Record throwables during low level processing */ >- @JsonIgnore >- private Map<String,Object> throwable; >- >- public Object getResponseHeaders() { >- return responseHeaders; >- } >- >- public void setResponseHeaders(Object responseHeaders) { >- this.responseHeaders = responseHeaders; >- } >- >- @JsonProperty("response-headers") >- private Object responseHeaders; >- >- public Result() { >- >- } >- >- public String getOutcome() { >- return outcome; >- } >- >- public void setOutcome(String outcome) { >- this.outcome = outcome; >- if (outcome.equalsIgnoreCase(SUCCESS)) >- success = true; >- } >- >- @JsonIgnore >- public boolean isReloadRequired() { >- if (responseHeaders==null) >- return false; >- if (responseHeaders instanceof Map) { >- Map<String,Object> map = (Map<String, Object>) responseHeaders; >- if (map.containsKey("process-state") && map.get("process-state").equals("reload-required")) { >- return true; >- } >- } >- return false; >- } >- >- @JsonIgnore >- public boolean isRestartRequired() { >- if (responseHeaders == null) >- return false; >- if (responseHeaders instanceof Map) { >- Map<String, Object> map = (Map<String, Object>) responseHeaders; >- if (map.containsKey("process-state") && map.get("process-state").equals("restart-required")) { >- return true; >- } >- } >- return false; >- } >- >- public boolean isSuccess() { >- return success; >- } >- >- public Object getResult() { >- return result; >- } >- >- public void setResult(Object result) { >- this.result = result; >- } >- >- public String getFailureDescription() { >- return failureDescription + ", rolled-back=" + rolledBack; >- } >- >- public void setFailureDescription(/*List<Map<String, String>>*/Object failureDescription) { >- this.failureDescription = failureDescription; >- } >- >- public boolean isRolledBack() { >- return rolledBack; >- } >- >- public void setRolledBack(boolean rolledBack) { >- this.rolledBack = rolledBack; >- } >- >- public Map<String, Object> getThrowable() { >- return throwable; >- } >- >- public void setThrowable(Map<String,Object> throwable) { >- this.throwable = throwable; >- } >- >- @JsonIgnore >- public Throwable getRhqThrowable() { >- return rhqThrowable; >- } >- >- @JsonIgnore >- public void setRhqThrowable(Throwable rhqThrowable) { >- this.rhqThrowable = rhqThrowable; >- } >- >- @Override >- public String toString() { >- return "Result{" + >- "outcome='" + outcome + '\'' + >- ", failureDescription=" + failureDescription + >- ", rolledBack=" + rolledBack + >- '}'; >- } >- >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/WriteAttribute.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/WriteAttribute.java >deleted file mode 100644 >index 1121883..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/WriteAttribute.java >+++ /dev/null >@@ -1,39 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json; >- >-/** >- * Operation to write one attribute >- * @author Heiko W. Rupp >- */ >-public class WriteAttribute extends Operation { >- >- private static final String WRITE_ATTRIBUTE = "write-attribute"; >- >- public WriteAttribute(Address address) { >- super(WRITE_ATTRIBUTE,address); >- } >- >- public WriteAttribute(Address address,String name, Object value) { >- super(WRITE_ATTRIBUTE,address); >- addAdditionalProperty("name",name); >- addAdditionalProperty("value",value); >- } >- >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java >deleted file mode 100644 >index c49f8a2..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java >+++ /dev/null >@@ -1,52 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json.serializer; >- >-import java.io.IOException; >- >-import org.codehaus.jackson.JsonParser; >-import org.codehaus.jackson.JsonProcessingException; >-import org.codehaus.jackson.map.DeserializationContext; >-import org.codehaus.jackson.map.JsonDeserializer; >- >-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; >- >-/** >- * Deserialize {"foo":"bar"} into a PROPERTY_VALUE >- * @author Heiko W. Rupp >- */ >-public class PropertyValueDeserializer extends JsonDeserializer<PROPERTY_VALUE> { >- >- >- @Override >- public PROPERTY_VALUE deserialize(JsonParser jsonParser, >- DeserializationContext deserializationContext) throws IOException, JsonProcessingException { >- >- String tmp = jsonParser.getText(); // { >- jsonParser.nextToken(); >- String key = jsonParser.getText(); >- jsonParser.nextToken(); >- String value = jsonParser.getText(); >- jsonParser.nextToken(); >- tmp = jsonParser.getText(); // } >- >- PROPERTY_VALUE pv = new PROPERTY_VALUE(key,value); >- return pv; >- } >-} >diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java >deleted file mode 100644 >index e7dda18..0000000 >--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java >+++ /dev/null >@@ -1,45 +0,0 @@ >-/* >- * RHQ Management Platform >- * Copyright (C) 2005-2011 Red Hat, Inc. >- * All rights reserved. >- * >- * This program is free software; you can redistribute it and/or modify >- * it under the terms of the GNU General Public License as published by >- * the Free Software Foundation version 2 of the License. >- * >- * This program 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 General Public License for more details. >- * >- * You should have received a copy of the GNU General Public License >- * along with this program; if not, write to the Free Software >- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. >- */ >-package org.rhq.modules.plugins.jbossas7.json.serializer; >- >-import java.io.IOException; >- >-import org.codehaus.jackson.JsonGenerator; >-import org.codehaus.jackson.JsonProcessingException; >-import org.codehaus.jackson.map.JsonSerializer; >-import org.codehaus.jackson.map.SerializerProvider; >- >-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; >- >-/** >- * Serialize the key/value pair from PROPERTY_VALUE into {"value of key":"value of value"} >- * @author Heiko W. Rupp >- */ >-public class PropertyValueSerializer extends JsonSerializer<PROPERTY_VALUE> { >- >- @Override >- public void serialize(PROPERTY_VALUE property_value, JsonGenerator jsonGenerator, >- SerializerProvider serializerProvider) throws IOException, JsonProcessingException { >- >- jsonGenerator.writeStartObject(); >- jsonGenerator.writeFieldName(property_value.getKey()); >- jsonGenerator.writeString(property_value.getValue()); >- jsonGenerator.writeEndObject(); >- } >-} >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 5eaa0e9..544418f 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 >@@ -37,6 +37,10 @@ import org.codehaus.jackson.map.JsonMappingException; > import org.codehaus.jackson.map.ObjectMapper; > import org.codehaus.jackson.node.ObjectNode; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser; > import org.rhq.core.clientapi.agent.metadata.InvalidPluginDescriptorException; > import org.rhq.core.clientapi.descriptor.DescriptorPackages; >@@ -44,9 +48,6 @@ import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor; > import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor; > import org.rhq.core.clientapi.descriptor.plugin.ServiceDescriptor; > import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Base class for configuration handling tests >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/CompositeOperationTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/CompositeOperationTest.java >index 869ab9d..b12ae5a 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/CompositeOperationTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/CompositeOperationTest.java >@@ -22,10 +22,10 @@ import org.codehaus.jackson.JsonNode; > import org.codehaus.jackson.map.ObjectMapper; > import org.testng.annotations.Test; > >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.CompositeOperation; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.PROPERTY_VALUE; > > /** > * Test composite operations >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java >index f38a117..4870465 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationLoadingTest.java >@@ -30,6 +30,8 @@ import org.testng.Assert; > import org.testng.annotations.BeforeSuite; > import org.testng.annotations.Test; > >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.Property; > import org.rhq.core.domain.configuration.PropertyList; >@@ -41,8 +43,6 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionList; > import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap; > import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; > import org.rhq.core.domain.configuration.definition.PropertySimpleType; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Tests loading configurations >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 ba2f13c..a695394 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 >@@ -29,15 +29,15 @@ import org.testng.Assert; > import org.testng.annotations.BeforeSuite; > import org.testng.annotations.Test; > >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.CompositeOperation; >+import org.rhq.common.jbossas7.client.json.Operation; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertyList; > import org.rhq.core.domain.configuration.PropertyMap; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; >-import org.rhq.modules.plugins.jbossas7.json.Operation; > > /** > * Test updating the AS7 configuration >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java >index a106fe3..263ec2b 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java >@@ -26,12 +26,12 @@ import org.codehaus.jackson.map.ObjectMapper; > import org.codehaus.jackson.map.SerializationConfig; > import org.testng.annotations.Test; > >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; >-import org.rhq.modules.plugins.jbossas7.json.Result; >-import org.rhq.modules.plugins.jbossas7.json.WriteAttribute; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.PROPERTY_VALUE; >+import org.rhq.common.jbossas7.client.json.Result; >+import org.rhq.common.jbossas7.client.json.WriteAttribute; > > /** > * @author Heiko W. Rupp >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java >index cf75ea2..8738781 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java >@@ -20,7 +20,7 @@ package org.rhq.modules.plugins.jbossas7; > > import org.testng.annotations.Test; > >-import org.rhq.modules.plugins.jbossas7.json.Address; >+import org.rhq.common.jbossas7.client.json.Address; > > /** > * Test handling of path elements. >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/TemplatedComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/TemplatedComponentTest.java >index 061390c..b9f109c 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/TemplatedComponentTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/TemplatedComponentTest.java >@@ -38,6 +38,8 @@ import org.testng.IObjectFactory; > import org.testng.annotations.ObjectFactory; > import org.testng.annotations.Test; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.Property; > import org.rhq.core.domain.configuration.PropertySimple; >@@ -47,7 +49,6 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinition; > import org.rhq.core.domain.resource.ResourceType; > import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; > import org.rhq.core.pluginapi.inventory.ResourceContext; >-import org.rhq.modules.plugins.jbossas7.json.Address; > > /** > * @author Stefan Negrea >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/TemplatedSubResourcesComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/TemplatedSubResourcesComponentTest.java >index cefd3f1..e0a8280 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/TemplatedSubResourcesComponentTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/TemplatedSubResourcesComponentTest.java >@@ -38,13 +38,14 @@ import org.testng.IObjectFactory; > import org.testng.annotations.ObjectFactory; > import org.testng.annotations.Test; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; > import org.rhq.core.domain.configuration.definition.PropertyDefinition; > import org.rhq.core.domain.resource.ResourceType; > import org.rhq.core.pluginapi.inventory.CreateResourceReport; >-import org.rhq.modules.plugins.jbossas7.json.Address; > > /** > * @author Stefan Negrea >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java >index 7be0689..27e5454 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java >@@ -36,6 +36,10 @@ import org.codehaus.jackson.map.JsonMappingException; > import org.codehaus.jackson.map.ObjectMapper; > import org.testng.annotations.Test; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.clientapi.agent.inventory.CreateResourceRequest; > import org.rhq.core.clientapi.agent.inventory.CreateResourceResponse; > import org.rhq.core.clientapi.agent.inventory.DeleteResourceRequest; >@@ -53,14 +57,10 @@ import org.rhq.core.domain.resource.ResourceCategory; > import org.rhq.core.domain.resource.ResourceType; > import org.rhq.core.pc.configuration.ConfigurationManager; > import org.rhq.core.pc.inventory.InventoryManager; >-import org.rhq.modules.plugins.jbossas7.ASConnection; > import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent; > import org.rhq.modules.plugins.jbossas7.ModuleOptionsComponent.Value; > import org.rhq.modules.plugins.jbossas7.itest.AbstractJBossAS7PluginTest; > import org.rhq.modules.plugins.jbossas7.itest.standalone.StandaloneServerComponentTest; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.Result; > import org.rhq.test.arquillian.RunDiscovery; > > /** >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/AbstractIntegrationTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/AbstractIntegrationTest.java >index bb1eca2..34b0761 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/AbstractIntegrationTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/AbstractIntegrationTest.java >@@ -39,6 +39,11 @@ import org.apache.commons.logging.LogFactory; > import org.codehaus.jackson.JsonNode; > import org.testng.annotations.Test; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.ASUploadConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.PROPERTY_VALUE; > import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser; > import org.rhq.core.clientapi.agent.metadata.InvalidPluginDescriptorException; > import org.rhq.core.clientapi.descriptor.DescriptorPackages; >@@ -47,12 +52,7 @@ import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor; > import org.rhq.core.clientapi.descriptor.plugin.ServiceDescriptor; > import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; > import org.rhq.core.util.stream.StreamUtil; >-import org.rhq.modules.plugins.jbossas7.ASConnection; >-import org.rhq.modules.plugins.jbossas7.ASUploadConnection; > import org.rhq.modules.plugins.jbossas7.itest.AbstractJBossAS7PluginTest; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; > > /** > * Abstract base class for integration tests that do not run against an RHQ plugin container. >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/ConfigurationTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/ConfigurationTest.java >index d28fa79..e9d84f5 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/ConfigurationTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/ConfigurationTest.java >@@ -6,6 +6,7 @@ import java.util.Map; > import org.testng.annotations.BeforeSuite; > import org.testng.annotations.Test; > >+import org.rhq.common.jbossas7.client.json.Address; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.ConfigurationUpdateStatus; > import org.rhq.core.domain.configuration.Property; >@@ -16,7 +17,6 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; > import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; > import org.rhq.modules.plugins.jbossas7.ConfigurationLoadDelegate; > import org.rhq.modules.plugins.jbossas7.ConfigurationWriteDelegate; >-import org.rhq.modules.plugins.jbossas7.json.Address; > > /** > * Tests related to configurations >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/DatasourceDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/DatasourceDeployTest.java >index 01a0dd0..6ee4dac 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/DatasourceDeployTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/DatasourceDeployTest.java >@@ -26,19 +26,19 @@ import java.util.Map; > > import org.testng.annotations.Test; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadChildrenNames; >+import org.rhq.common.jbossas7.client.json.ReadResource; >+import org.rhq.common.jbossas7.client.json.Remove; >+import org.rhq.common.jbossas7.client.json.Result; >+import org.rhq.common.jbossas7.client.json.WriteAttribute; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.pluginapi.operation.OperationResult; >-import org.rhq.modules.plugins.jbossas7.ASConnection; > import org.rhq.modules.plugins.jbossas7.DatasourceComponent; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames; >-import org.rhq.modules.plugins.jbossas7.json.ReadResource; >-import org.rhq.modules.plugins.jbossas7.json.Remove; >-import org.rhq.modules.plugins.jbossas7.json.Result; >-import org.rhq.modules.plugins.jbossas7.json.WriteAttribute; > > /** > * Integration test for deploying datasources and installing jdbc drivers >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/MiscTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/MiscTest.java >index 2f8023a..a34321c 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/MiscTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/MiscTest.java >@@ -2,12 +2,12 @@ package org.rhq.modules.plugins.jbossas7.itest.nonpc; > > import java.util.Map; > >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.ComplexResult; >-import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.ReadAttribute; >-import org.rhq.modules.plugins.jbossas7.json.Result; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.ComplexResult; >+import org.rhq.common.jbossas7.client.json.CompositeOperation; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.ReadAttribute; >+import org.rhq.common.jbossas7.client.json.Result; > > import static org.testng.Assert.*; > >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/ServerGroupTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/ServerGroupTest.java >index a64c9cb..2efe6de 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/ServerGroupTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/ServerGroupTest.java >@@ -18,15 +18,15 @@ > */ > package org.rhq.modules.plugins.jbossas7.itest.nonpc; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Remove; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.domain.resource.CreateResourceStatus; > import org.rhq.core.domain.resource.ResourceCategory; > import org.rhq.core.domain.resource.ResourceType; > import org.rhq.core.pluginapi.inventory.CreateResourceReport; >-import org.rhq.modules.plugins.jbossas7.ASConnection; > import org.rhq.modules.plugins.jbossas7.HostControllerComponent; >-import org.rhq.modules.plugins.jbossas7.json.Remove; > > /** > * Tests around server groups >diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/UploadAndDeployTest.java >index 8ddb308..1902dd0 100644 >--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/UploadAndDeployTest.java >+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/nonpc/UploadAndDeployTest.java >@@ -28,6 +28,13 @@ import java.util.UUID; > import org.codehaus.jackson.JsonNode; > import org.testng.annotations.Test; > >+import org.rhq.common.jbossas7.client.ASConnection; >+import org.rhq.common.jbossas7.client.json.Address; >+import org.rhq.common.jbossas7.client.json.CompositeOperation; >+import org.rhq.common.jbossas7.client.json.Operation; >+import org.rhq.common.jbossas7.client.json.PROPERTY_VALUE; >+import org.rhq.common.jbossas7.client.json.Remove; >+import org.rhq.common.jbossas7.client.json.Result; > import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.content.PackageDetailsKey; > import org.rhq.core.domain.content.transfer.ResourcePackageDetails; >@@ -36,15 +43,8 @@ import org.rhq.core.domain.resource.Resource; > import org.rhq.core.domain.resource.ResourceType; > import org.rhq.core.pluginapi.inventory.CreateResourceReport; > import org.rhq.core.pluginapi.inventory.ResourceContext; >-import org.rhq.modules.plugins.jbossas7.ASConnection; > import org.rhq.modules.plugins.jbossas7.BaseComponent; > import org.rhq.modules.plugins.jbossas7.StandaloneASComponent; >-import org.rhq.modules.plugins.jbossas7.json.Address; >-import org.rhq.modules.plugins.jbossas7.json.CompositeOperation; >-import org.rhq.modules.plugins.jbossas7.json.Operation; >-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE; >-import org.rhq.modules.plugins.jbossas7.json.Remove; >-import org.rhq.modules.plugins.jbossas7.json.Result; > > /** > * Test uploading and deploying to the domain >-- >1.7.6.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 839332
: 597609