modules/helpers/pluginGen/pom.xml | 46 +++++++++ modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java | 50 +++++++++- 2 files changed, 92 insertions(+), 4 deletions(-)
New commits: commit 152669d9dd859899b86c146d495abcb2eb9d47b4 Author: Simeon Pinder spinder@fulliautomatix.conchfritter.com Date: Wed Oct 24 19:07:33 2012 -0400
Add command line processing to modify ports or remote api choice.
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java index 30108cb..bb15fbd 100644 --- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java +++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java @@ -116,6 +116,10 @@ import org.rhq.helpers.ui.RemoteApi.Protocol; public class ManagedHive extends JFrame {
static Logger LOG = Logger.getLogger(ManagedHive.class.getName()); + private static String REMOTE_PROTOCOL = "--remote-protocol"; + private static String REMOTE_PROTOCOL_PORT = "--remote-port"; + private static String HELP = "--help"; + private static String HELP1 = "-h"; /******************* Startup/initialization & Components *************/ /** Simple command line launch mechanism * @param args @@ -123,9 +127,47 @@ public class ManagedHive extends JFrame { public static void main(String[] args) { //allow way to switch between protocols at server startup if (args.length > 0) { - String remoteApiProtocoal = args[0]; - if (remoteApiProtocoal.trim().equalsIgnoreCase("HTTP")) { - ManagedHive.defaultProtocol = Protocol.HTTP_JSON; + for (int i = 0; i < args.length; i++) { + String argument = args[i]; + argument = argument.toLowerCase(); + //determine remote protocol type + if (argument.startsWith(REMOTE_PROTOCOL)) { + //default to JSON over socket + ManagedHive.defaultProtocol = Protocol.JSON; + //split on = to get value + String[] selection = argument.split("="); + if ((selection != null) && (selection.length == 2) && (selection[1].equalsIgnoreCase("HTTP"))) { + ManagedHive.defaultProtocol = Protocol.HTTP_JSON; + } + } + //determine remote protocol port. This is optional and first available will be + //selected if the requested port is not actually available. + if (argument.startsWith(REMOTE_PROTOCOL_PORT)) { + //already defaulted to 9876 + //split on = to get value + String[] selection = argument.split("="); + if ((selection != null) && (selection.length == 2)) { + String value = selection[1]; + int valueInt = -1; + try { + valueInt = Integer.parseInt(value); + if ((valueInt > -1) && (valueInt < 66000)) { + ManagedHive.defaultRemoteApiPort = valueInt; + }//otherwise ignore + } catch (NumberFormatException nfe) { + } + } + } + + if ((argument.startsWith(HELP) || argument.startsWith(HELP1))) { + String acceptableInput = "Ex. java -jar ManagedHive.jar -Drhq.virtual.hive " + + "--remote-protocol=http --remote-port=9876 \n" + + "Ex. java -jar ManagedHive.jar -h \t(displays acceptable input and exits)\n" + + "Ex. java -jar ManagedHive.jar --help \t(displays acceptable input and exits)\n" + + "Ex. java -jar ManagedHive.jar \t\t(no arguments, runs with defaults. No discovery differentiator)"; + System.out.println(acceptableInput); + System.exit(0);//bail + } } } new ManagedHive();
commit cc7ca1b39b3962cb92f93f12407b2ffdd390fe8f Author: Simeon Pinder spinder@fulliautomatix.conchfritter.com Date: Wed Oct 24 16:51:44 2012 -0400
Fix small issue with runtime processing for remote interface.
diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java index bf9560e..30108cb 100644 --- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java +++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java @@ -124,7 +124,7 @@ public class ManagedHive extends JFrame { //allow way to switch between protocols at server startup if (args.length > 0) { String remoteApiProtocoal = args[0]; - if (remoteApiProtocoal.trim().toUpperCase().indexOf("HTTP") > 0) { + if (remoteApiProtocoal.trim().equalsIgnoreCase("HTTP")) { ManagedHive.defaultProtocol = Protocol.HTTP_JSON; } }
commit bb2797403b78852d15efad24ed1b6c5e41e0c4b4 Author: Simeon Pinder spinder@fulliautomatix.conchfritter.com Date: Wed Oct 24 16:26:24 2012 -0400
generate executable jar for Managed Resource.
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml index e1418f4..4bba6a8 100644 --- a/modules/helpers/pluginGen/pom.xml +++ b/modules/helpers/pluginGen/pom.xml @@ -71,6 +71,31 @@ <version>2.1</version> </plugin>
+ <!-- Builds standalone executable jar for the managed virtual resource. + Resource defaults to running simple socket managed interface. + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.0</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <finalName>ManagedHive</finalName> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <mainClass>org.rhq.helpers.ui.ManagedHive</mainClass> + </transformer> + </transformers> + </configuration> + </execution> + </executions> + </plugin> + </plugins>
</build>
commit 0105651cdb89c3b22717b0e774b89dae3b172bfb Author: Simeon Pinder spinder@fulliautomatix.conchfritter.com Date: Wed Oct 24 16:07:28 2012 -0400
update build dependencies.
diff --git a/modules/helpers/pluginGen/pom.xml b/modules/helpers/pluginGen/pom.xml index 62bf822..e1418f4 100644 --- a/modules/helpers/pluginGen/pom.xml +++ b/modules/helpers/pluginGen/pom.xml @@ -92,6 +92,27 @@ <artifactId>rhq-pluginAnnotations</artifactId> <version>4.5.0-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.2.1</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + <version>4.2.1</version> + </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-mapper-asl</artifactId> + <version>1.8.5</version> + </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-core-asl</artifactId> + <version>1.8.5</version> + </dependency> + </dependencies>
<profiles> diff --git a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java index 557fd34..bf9560e 100644 --- a/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java +++ b/modules/helpers/pluginGen/src/main/java/org/rhq/helpers/ui/ManagedHive.java @@ -64,13 +64,13 @@ import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener;
-import org.apache.commons.httpclient.HttpStatus; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpException; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.HttpResponseInterceptor; +import org.apache.http.HttpStatus; import org.apache.http.MethodNotSupportedException; import org.apache.http.entity.StringEntity; import org.apache.http.impl.DefaultConnectionReuseStrategy;
rhq-commits@lists.fedorahosted.org