changeset 0:c504d87d9471

initial plugin
author Omair Majid <omajid@redhat.com>
date Thu, 14 Feb 2013 17:44:34 -0500
parents
children 5ed86f4d1723
files install.sh plugin.conf pom.xml src/main/java/hello/client/Activator.java src/main/resources/META-INF/Manifest.mf
diffstat 5 files changed, 153 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/install.sh	Thu Feb 14 17:44:34 2013 -0500
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+#
+# Installs this project as a plugin
+#
+
+PLUGIN_NAME="hello-world-plugin"
+PLUGIN_VERSION="0.1-SNAPSHOT"
+
+#
+# $1: path of thermostat installation
+#
+
+if [ "$#" -lt 1 ] ; then
+    echo "Need thermostat home as first argument"
+    exit 1
+fi
+
+THERMOSTAT_HOME="$1"
+PLUGIN_HOME="${THERMOSTAT_HOME}"/plugins/"${PLUGIN_NAME}"
+
+mkdir -p "${PLUGIN_HOME}"
+cp target/"${PLUGIN_NAME}"-"${PLUGIN_VERSION}".jar "${PLUGIN_HOME}/"
+cp plugin.conf "${PLUGIN_HOME}"/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugin.conf	Thu Feb 14 17:44:34 2013 -0500
@@ -0,0 +1,22 @@
+<?xml version="1.0" ?>
+<plugin>
+  <commands>
+    <existing>
+      <name>gui</name>
+      <bundles>
+        hello-world-plugin-0.1-SNAPSHOT.jar,
+      </bundles>
+    </existing>
+    <new>
+      <name>hello</name>
+      <description>print hello</description>
+      <usage>hello</usage>
+      <bundles>
+        hello-world-plugin-0.1-SNAPSHOT.jar,
+      </bundles>
+      <dependencies>
+        thermostat-client-core-0.6.0-SNAPSHOT.jar,
+      </dependencies>
+    </new>
+  </commands>
+</plugin>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pom.xml	Thu Feb 14 17:44:34 2013 -0500
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <!-- The Basics -->
+  <groupId>org.classpath.icedtea.omajid</groupId>
+  <artifactId>hello-world-plugin</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <version>4.2.0</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>com.redhat.thermostat</groupId>
+      <artifactId>thermostat-client-core</artifactId>
+      <version>0.6.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+	        <manifestFile>src/main/resources/META-INF/Manifest.mf</manifestFile>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/hello/client/Activator.java	Thu Feb 14 17:44:34 2013 -0500
@@ -0,0 +1,60 @@
+package test.client;
+
+import javax.swing.JOptionPane;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+import com.redhat.thermostat.client.osgi.service.MenuAction;
+import com.redhat.thermostat.common.cli.AbstractCommand;
+import com.redhat.thermostat.common.cli.CommandContext;
+import com.redhat.thermostat.common.cli.CommandException;
+import com.redhat.thermostat.common.cli.CommandRegistryImpl;
+
+public class Activator implements BundleActivator {
+    public void start(BundleContext context) throws Exception {
+        HelloWorldMenu menu = new HelloWorldMenu();
+        context.registerService(MenuAction.class.getName(), menu, null);
+        
+        new CommandRegistryImpl(context).registerCommand(new HelloCommand());
+    }
+
+    public void stop(BundleContext context) throws Exception {
+    }
+    
+    static class HelloWorldMenu implements MenuAction {
+        public String getName() {
+            return "Hello";
+        }
+
+        public String getDescription() {
+            return "Say Hello";
+        }
+
+        public void execute() {
+            JOptionPane.showMessageDialog(null, "Hello World!");
+        }
+
+        public Type getType() {
+            return Type.STANDARD;
+        }
+
+        public String[] getPath() {
+            return new String[] { "File", "Hello"};
+        }
+    }
+    
+    static class HelloCommand extends AbstractCommand {
+        public void run(CommandContext ctx) throws CommandException {
+            ctx.getConsole().getOutput().println("Hello World!");
+        }
+
+        public String getName() {
+            return "hello";
+        }
+        @Override
+        public boolean isStorageRequired() {
+            return false;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/resources/META-INF/Manifest.mf	Thu Feb 14 17:44:34 2013 -0500
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Bundle-Name: External Client Plugin
+Bundle-SymbolicName: test.client
+Bundle-Version: 1.0.0
+Bundle-Activator: test.client.Activator
+Import-Package: org.osgi.framework;version="1.3.0",com.redhat.thermostat.client.osgi.service,com.redhat.thermostat.common.cli,javax.swing