You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whirr.apache.org by ad...@apache.org on 2012/08/18 21:46:59 UTC

svn commit: r1374643 [1/2] - in /whirr/trunk: ./ core/ core/src/main/java/org/apache/whirr/osgi/ core/src/main/resources/OSGI-INF/blueprint/ platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/ platforms/karaf/feature/ platforms/karaf/featur...

Author: adriancole
Date: Sat Aug 18 19:46:56 2012
New Revision: 1374643

URL: http://svn.apache.org/viewvc?rev=1374643&view=rev
Log:
WHIRR-633: Align jclouds 1.5.0 modularity changes with Whirr

Added:
    whirr/trunk/core/src/main/java/org/apache/whirr/osgi/
    whirr/trunk/core/src/main/java/org/apache/whirr/osgi/Activator.java
    whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrFunctionLoaderTest.java
    whirr/trunk/services/cassandra/src/main/java/org/apache/whirr/service/cassandra/osgi/
    whirr/trunk/services/cassandra/src/main/java/org/apache/whirr/service/cassandra/osgi/Activator.java
    whirr/trunk/services/cdh/src/main/java/
    whirr/trunk/services/cdh/src/main/java/org/
    whirr/trunk/services/cdh/src/main/java/org/apache/
    whirr/trunk/services/cdh/src/main/java/org/apache/whirr/
    whirr/trunk/services/cdh/src/main/java/org/apache/whirr/service/
    whirr/trunk/services/cdh/src/main/java/org/apache/whirr/service/cdh/
    whirr/trunk/services/cdh/src/main/java/org/apache/whirr/service/cdh/osgi/
    whirr/trunk/services/cdh/src/main/java/org/apache/whirr/service/cdh/osgi/Activator.java
    whirr/trunk/services/chef/src/main/java/org/apache/whirr/service/chef/osgi/
    whirr/trunk/services/chef/src/main/java/org/apache/whirr/service/chef/osgi/Activator.java
    whirr/trunk/services/elasticsearch/src/main/java/org/apache/whirr/service/elasticsearch/osgi/
    whirr/trunk/services/elasticsearch/src/main/java/org/apache/whirr/service/elasticsearch/osgi/Activator.java
    whirr/trunk/services/ganglia/src/main/java/org/apache/whirr/service/ganglia/osgi/
    whirr/trunk/services/ganglia/src/main/java/org/apache/whirr/service/ganglia/osgi/Activator.java
    whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/osgi/
    whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/osgi/Activator.java
    whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/osgi/
    whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/osgi/Activator.java
    whirr/trunk/services/hbase/src/main/java/org/apache/whirr/service/hbase/osgi/
    whirr/trunk/services/hbase/src/main/java/org/apache/whirr/service/hbase/osgi/Activator.java
    whirr/trunk/services/mahout/src/main/java/org/apache/whirr/service/mahout/osgi/
    whirr/trunk/services/mahout/src/main/java/org/apache/whirr/service/mahout/osgi/Activator.java
    whirr/trunk/services/pig/src/main/java/org/apache/whirr/service/pig/osgi/
    whirr/trunk/services/pig/src/main/java/org/apache/whirr/service/pig/osgi/Activator.java
    whirr/trunk/services/puppet/src/main/java/org/apache/whirr/service/puppet/osgi/
    whirr/trunk/services/puppet/src/main/java/org/apache/whirr/service/puppet/osgi/Activator.java
    whirr/trunk/services/solr/src/main/java/org/apache/whirr/service/solr/osgi/
    whirr/trunk/services/solr/src/main/java/org/apache/whirr/service/solr/osgi/Activator.java
    whirr/trunk/services/voldemort/src/main/java/org/apache/whirr/service/voldemort/osgi/
    whirr/trunk/services/voldemort/src/main/java/org/apache/whirr/service/voldemort/osgi/Activator.java
    whirr/trunk/services/yarn/src/main/java/org/apache/whirr/service/yarn/osgi/
    whirr/trunk/services/yarn/src/main/java/org/apache/whirr/service/yarn/osgi/Activator.java
    whirr/trunk/services/zookeeper/src/main/java/org/apache/whirr/service/zookeeper/osgi/
    whirr/trunk/services/zookeeper/src/main/java/org/apache/whirr/service/zookeeper/osgi/Activator.java
Removed:
    whirr/trunk/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/cassandra/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/chef/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/elasticsearch/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/ganglia/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/hadoop/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/hama/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/hbase/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/mahout/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/pig/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/puppet/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/voldemort/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    whirr/trunk/services/zookeeper/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Modified:
    whirr/trunk/CHANGES.txt
    whirr/trunk/core/pom.xml
    whirr/trunk/platforms/karaf/feature/pom.xml
    whirr/trunk/platforms/karaf/feature/src/main/resources/features.xml
    whirr/trunk/platforms/karaf/itests/pom.xml
    whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrServicesTest.java
    whirr/trunk/pom.xml
    whirr/trunk/services/cassandra/pom.xml
    whirr/trunk/services/cdh/pom.xml
    whirr/trunk/services/chef/pom.xml
    whirr/trunk/services/elasticsearch/pom.xml
    whirr/trunk/services/ganglia/pom.xml
    whirr/trunk/services/hadoop/pom.xml
    whirr/trunk/services/hama/pom.xml
    whirr/trunk/services/hbase/pom.xml
    whirr/trunk/services/mahout/pom.xml
    whirr/trunk/services/pig/pom.xml
    whirr/trunk/services/puppet/pom.xml
    whirr/trunk/services/solr/pom.xml
    whirr/trunk/services/voldemort/pom.xml
    whirr/trunk/services/yarn/pom.xml
    whirr/trunk/services/zookeeper/pom.xml

Modified: whirr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/whirr/trunk/CHANGES.txt?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/CHANGES.txt (original)
+++ whirr/trunk/CHANGES.txt Sat Aug 18 19:46:56 2012
@@ -119,6 +119,8 @@ Release 0.8.0 - 2012-08-17
 
     WHIRR-593. Upgrade to jclouds 1.5.0 (adriancole)
 
+    WHIRR-633. Align jclouds 1.5.0 modularity changes with Whirr (iocanel via adriancole)
+
   BUG FIXES
 
     WHIRR-632. CDH4 only available on 64 bit. (abayer)

Modified: whirr/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/core/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/core/pom.xml (original)
+++ whirr/trunk/core/pom.xml Sat Aug 18 19:46:56 2012
@@ -33,7 +33,7 @@
       org.apache.commons.configuration*;version="[1.6,2)",
       *
     </osgi.import>
-    <osgi.fragment.host>jclouds-scriptbuilder;bundle-version="${jclouds.osgi.version.clean}"</osgi.fragment.host>
+    <osgi.bundle.activator>org.apache.whirr.osgi.Activator</osgi.bundle.activator>
     <osgi.export>
       org.apache.whirr*;version="${project.version}"
     </osgi.export>
@@ -159,6 +159,17 @@
       <artifactId>jopt-simple</artifactId>
       <version>${jopt.simple.version}</version>
     </dependency>
+
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <resources>

Added: whirr/trunk/core/src/main/java/org/apache/whirr/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/osgi/Activator.java (added)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.osgi;
+
+import org.apache.whirr.ByonClusterController;
+import org.apache.whirr.ClusterController;
+import org.apache.whirr.ClusterControllerFactory;
+import org.apache.whirr.DynamicClusterControllerFactory;
+import org.apache.whirr.DynamicHandlerMapFactory;
+import org.apache.whirr.service.ClusterActionHandler;
+import org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.util.tracker.ServiceTracker;
+
+import java.util.Properties;
+
+
+public class Activator implements BundleActivator {
+
+  private DynamicHandlerMapFactory handlerMapFactory = new DynamicHandlerMapFactory();
+  private ServiceRegistration handlerMapFactoryRegistration;
+  private ServiceTracker handlerTracker;
+
+  private DynamicClusterControllerFactory clusterControllerFactory = new DynamicClusterControllerFactory();
+  private ServiceRegistration clusterControllerFactoryRegistration;
+  private ServiceTracker clusterControllerTracker;
+
+  private ClusterController defaultClusterController = new ClusterController();
+  private ServiceRegistration defaultClusterControllerRegistration;
+
+  private ClusterController byonClusterController = new ByonClusterController();
+  private ServiceRegistration byonClusterControllerRegistration;
+
+  private BundleFunctionLoader functionLoader;
+
+  /**
+   * Called when this bundle is started so the Framework can perform the
+   * bundle-specific activities necessary to start this bundle. This method
+   * can be used to register services or to allocate any resources that this
+   * bundle needs.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being started.
+   * @throws Exception If this method throws an exception, this
+   *                   bundle is marked as stopped and the Framework will remove this
+   *                   bundle's listeners, unregister all services registered by this
+   *                   bundle, and release all services used by this bundle.
+   */
+  @Override
+  public void start(BundleContext context) throws Exception {
+    //Initialize OSGi based FunctionLoader
+    functionLoader = new BundleFunctionLoader(context);
+    functionLoader.start();
+
+    //Register services
+    clusterControllerFactoryRegistration = context.registerService(ClusterControllerFactory.class.getName(), clusterControllerFactory, null);
+    handlerMapFactoryRegistration = context.registerService(DynamicHandlerMapFactory.class.getName(), handlerMapFactory, null);
+
+    //Start tracking
+    clusterControllerTracker = new ServiceTracker(context, ClusterController.class.getName(), null) {
+
+      @Override
+      public Object addingService(ServiceReference reference) {
+        Object service = super.addingService(reference);
+        clusterControllerFactory.bind((ClusterController) service);
+        return service;
+      }
+
+      @Override
+      public void removedService(ServiceReference reference, Object service) {
+        clusterControllerFactory.unbind((ClusterController) service);
+        super.removedService(reference, service);
+      }
+    };
+
+    clusterControllerTracker.open();
+
+
+    handlerTracker = new ServiceTracker(context, ClusterActionHandler.class.getName(), null) {
+
+      @Override
+      public Object addingService(ServiceReference reference) {
+        Object service = super.addingService(reference);
+        handlerMapFactory.bind((ClusterActionHandler) service);
+        return service;
+      }
+
+      @Override
+      public void removedService(ServiceReference reference, Object service) {
+        handlerMapFactory.unbind((ClusterActionHandler) service);
+        super.removedService(reference, service);
+      }
+    };
+
+    handlerTracker.open();
+
+    Properties defaultClusterControllerProperties = new Properties();
+    defaultClusterControllerProperties.setProperty("name", "default");
+    defaultClusterControllerRegistration = context.registerService(ClusterController.class.getName(), defaultClusterController, defaultClusterControllerProperties);
+
+    Properties byonClusterControllerProperties = new Properties();
+    byonClusterControllerProperties.setProperty("name", "byon");
+    byonClusterControllerRegistration = context.registerService(ClusterController.class.getName(), byonClusterController, byonClusterControllerProperties);
+  }
+
+  /**
+   * Called when this bundle is stopped so the Framework can perform the
+   * bundle-specific activities necessary to stop the bundle. In general, this
+   * method should undo the work that the <code>BundleActivator.start</code>
+   * method started. There should be no active threads that were started by
+   * this bundle when this bundle returns. A stopped bundle must not call any
+   * Framework objects.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being stopped.
+   * @throws Exception If this method throws an exception, the
+   *                   bundle is still marked as stopped, and the Framework will remove
+   *                   the bundle's listeners, unregister all services registered by the
+   *                   bundle, and release all services used by the bundle.
+   */
+  @Override
+  public void stop(BundleContext context) throws Exception {
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+
+    if (handlerMapFactoryRegistration != null) {
+      handlerMapFactoryRegistration.unregister();
+    }
+
+    if (clusterControllerFactoryRegistration != null) {
+      clusterControllerFactoryRegistration.unregister();
+    }
+
+    if (clusterControllerTracker != null) {
+      clusterControllerTracker.close();
+    }
+
+    if (handlerTracker != null) {
+      handlerTracker.close();
+    }
+  }
+}

Modified: whirr/trunk/platforms/karaf/feature/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/feature/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/feature/pom.xml (original)
+++ whirr/trunk/platforms/karaf/feature/pom.xml Sat Aug 18 19:46:56 2012
@@ -47,12 +47,13 @@
     <dnsjava.version>2.0.8</dnsjava.version>
     <javax.mail.bundle.version>1.4.1_4</javax.mail.bundle.version>
     <junit.bundle.version>4.9_1</junit.bundle.version>
-    <jclouds.karaf.version>1.4.0</jclouds.karaf.version>
+    <jclouds.karaf.version>1.5.0-beta.10_1</jclouds.karaf.version>
     <jopt.simple.bundle.version>4.3_1</jopt.simple.bundle.version>
     <jsch.bundle.version>0.1.44_2</jsch.bundle.version>
     <not-yet-commons-ssl.bundle.version>0.3.11_1
     </not-yet-commons-ssl.bundle.version>
     <servlet.spec.version>1.2</servlet.spec.version>
+    <tukaani.xz.version>1.0</tukaani.xz.version>
   </properties>
   <build>
     <resources>

Modified: whirr/trunk/platforms/karaf/feature/src/main/resources/features.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/feature/src/main/resources/features.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/feature/src/main/resources/features.xml (original)
+++ whirr/trunk/platforms/karaf/feature/src/main/resources/features.xml Sat Aug 18 19:46:56 2012
@@ -33,12 +33,14 @@
     <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-jxpath/${commons.jxpath.bundle.version}</bundle>
     <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ant/${ant.bundle.version}</bundle>
     <!--bundle dependency='true'>mvn:org.apache.commons/commons-vfs2/${commons.vfs2.version}</bundle-->
+    <bundle dependency='true'>mvn:org.apache.commons/commons-compress/${commons.compress.version}</bundle>
     <bundle dependency='true'>mvn:commons-digester/commons-digester/${commons.digester.version}</bundle>
     <bundle dependency='true'>mvn:commons-beanutils/commons-beanutils/${commons.beanutils.version}</bundle>
     <bundle dependency='true'>mvn:commons-collections/commons-collections/${commons.collections.version}</bundle>
     <bundle dependency='true'>mvn:commons-configuration/commons-configuration/${commons.configuration.version}</bundle>
     <bundle dependency='true'>mvn:commons-codec/commons-codec/${commons.codec.version}</bundle>
     <bundle dependency='true'>mvn:commons-lang/commons-lang/${commons.lang.version}</bundle>
+    <bundle dependency='true'>wrap:mvn:org.tukaani/xz/${tukaani.xz.version}</bundle>
     <bundle dependency="true">wrap:mvn:dnsjava/dnsjava/${dnsjava.version}</bundle>
     <bundle dependency="true">mvn:org.apache.velocity/velocity/${velocity.version}</bundle>
     <bundle>mvn:org.apache.whirr/whirr-core/${project.version}</bundle>
@@ -51,6 +53,11 @@
     <bundle>mvn:org.apache.whirr/whirr-cassandra/${project.version}</bundle>
   </feature>
 
+  <feature name="whirr-cdh" version="${project.version}" description="Apache Whirr CDH Service" resolver="(obr)">
+    <feature version="${project.version}">whirr</feature>
+    <bundle>mvn:org.apache.whirr/whirr-cdh/${project.version}</bundle>
+  </feature>
+
   <feature name="whirr-chef" version="${project.version}" description="Apache Whirr Chef Service" resolver="(obr)">
     <feature version="${project.version}">whirr</feature>
     <bundle>mvn:org.apache.whirr/whirr-chef/${project.version}</bundle>
@@ -95,12 +102,21 @@
     <feature version="${project.version}">whirr</feature>
     <bundle>mvn:org.apache.whirr/whirr-puppet/${project.version}</bundle>
   </feature>
+  <feature name="whirr-solr" version="${project.version}" description="Apache Whirr Solr Service" resolver="(obr)">
+    <feature version="${project.version}">whirr</feature>
+    <bundle>mvn:org.apache.whirr/whirr-solr/${project.version}</bundle>
+  </feature>
 
   <feature name="whirr-voldemort" version="${project.version}" description="Apache Whirr Voldermort Service" resolver="(obr)">
     <feature version="${project.version}">whirr</feature>
     <bundle>mvn:org.apache.whirr/whirr-voldemort/${project.version}</bundle>
   </feature>
 
+  <feature name="whirr-yarn" version="${project.version}" description="Apache Whirr Yarn Service" resolver="(obr)">
+    <feature version="${project.version}">whirr</feature>
+    <bundle>mvn:org.apache.whirr/whirr-yarn/${project.version}</bundle>
+  </feature>
+
   <feature name="whirr-zookeeper" version="${project.version}" description="Apache Whirr Zookeeper Service" resolver="(obr)">
     <feature version="${project.version}">whirr</feature>
     <bundle>mvn:org.apache.whirr/whirr-zookeeper/${project.version}</bundle>

Modified: whirr/trunk/platforms/karaf/itests/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/itests/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/itests/pom.xml (original)
+++ whirr/trunk/platforms/karaf/itests/pom.xml Sat Aug 18 19:46:56 2012
@@ -95,6 +95,12 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.jclouds</groupId>
+      <artifactId>jclouds-scriptbuilder</artifactId>
+      <version>${jclouds.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.openengsb.labs.paxexam.karaf</groupId>
       <artifactId>paxexam-karaf-container</artifactId>
       <scope>test</scope>

Added: whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrFunctionLoaderTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrFunctionLoaderTest.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrFunctionLoaderTest.java (added)
+++ whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrFunctionLoaderTest.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.karaf.itest;
+
+
+import junit.framework.Assert;
+import org.jclouds.scriptbuilder.domain.OsFamily;
+import org.jclouds.scriptbuilder.functionloader.osgi.ServiceFunctionLoader;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openengsb.labs.paxexam.karaf.options.LogLevelOption;
+import org.ops4j.pax.exam.MavenUtils;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.ExamReactorStrategy;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
+
+import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.logLevel;
+import static org.ops4j.pax.exam.CoreOptions.scanFeatures;
+
+@RunWith(JUnit4TestRunner.class)
+@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
+public class WhirrFunctionLoaderTest extends WhirrKarafTestSupport {
+
+  @Test
+  public void testServices() throws InterruptedException {
+    ServiceFunctionLoader loader = new ServiceFunctionLoader(bundleContext);
+
+    //Install all services
+    executeCommand("features:install whirr-cassandra");
+    executeCommand("features:install whirr-chef");
+    executeCommand("features:install whirr-elasticsearch");
+    executeCommand("features:install whirr-ganglia");
+    executeCommand("features:install whirr-hadoop");
+    executeCommand("features:install whirr-hama");
+    executeCommand("features:install whirr-hbase");
+    executeCommand("features:install whirr-puppet");
+    executeCommand("features:install whirr-pig");
+    executeCommand("features:install whirr-solr");
+    executeCommand("features:install whirr-mahout");
+    executeCommand("features:install whirr-yarn");
+    executeCommand("features:install whirr-zookeeper");
+
+    System.err.println(executeCommand("osgi:list"));
+
+    //Test that services properly register to OSGi service registry.
+    getOsgiService("org.apache.whirr.ClusterController", "(name=default)", SERVICE_TIMEOUT);
+
+    //Check Cassandra Functions
+    String function = loader.loadFunction("cleanup_cassandra", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("configure_cassandra", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("install_cassandra", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("start_cassandra", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("stop_cassandra", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check Chef Functions
+    function = loader.loadFunction("install_chef", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check Elastic Search Functions
+    function = loader.loadFunction("cleanup_elasticsearch", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("configure_elasticsearch", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("install_elasticsearch", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("start_elasticsearch", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("stop_elasticsearch", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check Ganglia Functions
+    function = loader.loadFunction("configure_ganglia", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("install_ganglia", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check Hadoop Functions
+    function = loader.loadFunction("configure_hadoop", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("install_hadoop", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check Hama Functions
+    function = loader.loadFunction("configure_hama", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("install_hama", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("start_hama", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check HBase Functions
+    function = loader.loadFunction("configure_hbase", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("install_hbase", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check Mahout Functions
+    function = loader.loadFunction("configure_mahout_client", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check Pig Functions
+    function = loader.loadFunction("configure_pig_client", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check Puppet Functions
+    function = loader.loadFunction("install_puppet", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check Solr Functions
+    function = loader.loadFunction("configure_solr", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("install_solr", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("start_solr", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("stop_solr", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check Yarn Functions
+    function = loader.loadFunction("configure_hadoop_mr2", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("install_hadoop_mr2", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("start_mr_jobhistory", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("start_yarn", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("configure_yarn", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+
+    //Check Zookeeper Functions
+    function = loader.loadFunction("cleanup_zookeeper", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("configure_zookeeper", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("install_zookeeper", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("start_zookeeper", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+    function = loader.loadFunction("stop_zookeeper", OsFamily.UNIX);
+    Assert.assertNotNull(function);
+  }
+
+
+  @Configuration
+  public Option[] config() {
+    return new Option[]{
+            whirrDistributionConfiguration(), keepRuntimeFolder(), logLevel(LogLevelOption.LogLevel.ERROR),
+            scanFeatures(String.format(WHIRR_FEATURE_URL, MavenUtils
+                    .getArtifactVersion(WHIRR_KARAF_GROUP_ID, WHIRR_KARAF_ARTIFACT_ID)), "whirr").start()
+    };
+  }
+}

Modified: whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrServicesTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrServicesTest.java?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrServicesTest.java (original)
+++ whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrServicesTest.java Sat Aug 18 19:46:56 2012
@@ -29,6 +29,7 @@ import org.ops4j.pax.exam.junit.ExamReac
 import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
 
+import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.debugConfiguration;
 import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
 import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.logLevel;
 import static org.ops4j.pax.exam.CoreOptions.scanFeatures;
@@ -50,6 +51,7 @@ public class WhirrServicesTest extends W
     executeCommand("features:install whirr-puppet");
     executeCommand("features:install whirr-pig");
     executeCommand("features:install whirr-mahout");
+    executeCommand("features:install whirr-yarn");
     executeCommand("features:install whirr-zookeeper");
 
     System.err.println(executeCommand("osgi:list"));
@@ -67,6 +69,7 @@ public class WhirrServicesTest extends W
     testService("puppet-install");
     testService("pig-client");
     testService("mahout-client");
+    testService("yarn-nodemanager","yarn-resourcemanager");
     testService("zookeeper");
   }
 

Modified: whirr/trunk/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/pom.xml (original)
+++ whirr/trunk/pom.xml Sat Aug 18 19:46:56 2012
@@ -80,6 +80,7 @@
     <log4j.version>1.2.16</log4j.version>
     <mockito.version>1.9.0</mockito.version>
     <not.yet.commons.ssl.version>0.3.11</not.yet.commons.ssl.version>
+    <osgi.version>4.2.0</osgi.version>
     <protobuff.version>2.3.0</protobuff.version>
     <slf4j.version>1.6.4</slf4j.version>
     <voldermort.version>0.90</voldermort.version>
@@ -242,6 +243,16 @@
         <artifactId>dnsjava</artifactId>
         <version>${dnsjava.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.core</artifactId>
+        <version>${osgi.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.compendium</artifactId>
+        <version>${osgi.version}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
@@ -467,121 +478,6 @@
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-antrun-plugin</artifactId>
-        <version>1.6</version>
-        <inherited>true</inherited>
-        <executions>
-          <execution>
-            <id>create-prop</id>
-            <phase>initialize</phase>
-            <configuration>
-              <target>
-                <taskdef resource="net/sf/antcontrib/antcontrib.properties"
-                         classpathref="maven.plugin.classpath"/>
-                <property name="ant.regexp.regexpimpl"
-                          value="org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp"/>
-                <property name="whirr.mv" value="${project.version}"/>
-                <property name="jclouds.mv" value="${jclouds.version}"/>
-                <echo message="Whirr Maven version: ${whirr.mv}"/>
-                <echo message="Jclouds Maven version: ${jclouds.mv}"/>
-                <propertyregex property="whirr.ov.p1" input="${whirr.mv}"
-                               regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
-                               replace="\1" defaultValue="0"/>
-                <propertyregex property="whirr.ov.p2" input="${whirr.mv}"
-                               regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
-                               replace=".\2" defaultValue=".0"/>
-                <propertyregex property="whirr.ov.p3" input="${whirr.mv}"
-                               regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
-                               replace=".\3" defaultValue=".0"/>
-                <propertyregex property="whirr.ov.p4" input="${whirr.mv}"
-                               regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
-                               replace=".\4" defaultValue=""/>
-                <propertyregex property="whirr.ov.p1a" input="${whirr.ov.p1}"
-                               regexp="(.+)" replace="\1" defaultValue="0"/>
-                <propertyregex property="whirr.ov.p2a" input="${whirr.ov.p2}"
-                               regexp="(\..+)" replace="\1" defaultValue=".0"/>
-                <propertyregex property="whirr.ov.p3a" input="${whirr.ov.p3}"
-                               regexp="(\..+)" replace="\1" defaultValue=".0"/>
-                <propertyregex property="whirr.ov.p4a" input="${whirr.ov.p4}"
-                               regexp="(\..+)" replace="\1" defaultValue=""/>
-                <property name="whirr.ov"
-                          value="${whirr.ov.p1a}${whirr.ov.p2a}${whirr.ov.p3a}${whirr.ov.p4a}"/>
-
-                <propertyregex property="jclouds.ov.p1" input="${jclouds.mv}"
-                               regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
-                               replace="\1" defaultValue="0"/>
-                <propertyregex property="jclouds.ov.p2" input="${jclouds.mv}"
-                               regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
-                               replace=".\2" defaultValue=".0"/>
-                <propertyregex property="jclouds.ov.p3" input="${jclouds.mv}"
-                               regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
-                               replace=".\3" defaultValue=".0"/>
-                <propertyregex property="jclouds.ov.p4" input="${jclouds.mv}"
-                               regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
-                               replace=".\4" defaultValue=""/>
-                <propertyregex property="jclouds.ov.p1a"
-                               input="${jclouds.ov.p1}" regexp="(.+)"
-                               replace="\1" defaultValue="0"/>
-                <propertyregex property="jclouds.ov.p2a"
-                               input="${jclouds.ov.p2}" regexp="(\..+)"
-                               replace="\1" defaultValue=".0"/>
-                <propertyregex property="jclouds.ov.p3a"
-                               input="${jclouds.ov.p3}" regexp="(\..+)"
-                               replace="\1" defaultValue=".0"/>
-                <propertyregex property="jclouds.ov.p4a"
-                               input="${jclouds.ov.p4}" regexp="(\..+)"
-                               replace="\1" defaultValue=""/>
-                <property name="jclouds.ov"
-                          value="${jclouds.ov.p1a}${jclouds.ov.p2a}${jclouds.ov.p3a}${jclouds.ov.p4a}"/>
-                <echo message="Whirr OSGi version: ${whirr.ov}"/>
-                <echo message="Jclouds OSGi version: ${jclouds.ov}"/>
-                <mkdir dir="target"/>
-                <echo file="target/whirr.osgi.version.txt">
-                  whirr.osgi.version.clean = ${whirr.ov}
-                  jclouds.osgi.version.clean = ${jclouds.ov}
-                </echo>
-              </target>
-            </configuration>
-            <goals>
-              <goal>run</goal>
-            </goals>
-          </execution>
-        </executions>
-        <dependencies>
-          <dependency>
-            <groupId>ant-contrib</groupId>
-            <artifactId>ant-contrib</artifactId>
-            <version>1.0b3</version>
-            <exclusions>
-              <exclusion>
-                <groupId>ant</groupId>
-                <artifactId>ant</artifactId>
-              </exclusion>
-            </exclusions>
-          </dependency>
-        </dependencies>
-      </plugin>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>properties-maven-plugin</artifactId>
-        <version>1.0-alpha-2</version>
-        <inherited>true</inherited>
-        <executions>
-          <execution>
-            <phase>initialize</phase>
-            <goals>
-              <goal>read-project-properties</goal>
-            </goals>
-            <configuration>
-              <files>
-                <file>target/whirr.osgi.version.txt</file>
-              </files>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
     </plugins>
     <pluginManagement>
       <plugins>

Modified: whirr/trunk/services/cassandra/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/cassandra/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/cassandra/pom.xml (original)
+++ whirr/trunk/services/cassandra/pom.xml Sat Aug 18 19:46:56 2012
@@ -37,7 +37,7 @@
     <osgi.export>
       org.apache.whirr.service.cassandra*;version="${project.version}"
     </osgi.export>
-    <osgi.fragment.host>jclouds-scriptbuilder;bundle-version="${jclouds.osgi.version.clean}"</osgi.fragment.host>
+    <osgi.bundle.activator>org.apache.whirr.service.cassandra.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -91,7 +91,13 @@
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
       <scope>test</scope>
-    </dependency>   
+    </dependency>
+
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Added: whirr/trunk/services/cassandra/src/main/java/org/apache/whirr/service/cassandra/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/cassandra/src/main/java/org/apache/whirr/service/cassandra/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/cassandra/src/main/java/org/apache/whirr/service/cassandra/osgi/Activator.java (added)
+++ whirr/trunk/services/cassandra/src/main/java/org/apache/whirr/service/cassandra/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.whirr.service.cassandra.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.cassandra.CassandraClusterActionHandler;
+import org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import java.util.Properties;
+
+public class Activator implements BundleActivator {
+
+  private BundleFunctionLoader functionLoader;
+  private final ClusterActionHandler clusterActionHandler = new CassandraClusterActionHandler();
+  private ServiceRegistration registration;
+
+  /**
+   * Called when this bundle is started so the Framework can perform the
+   * bundle-specific activities necessary to start this bundle. This method
+   * can be used to register services or to allocate any resources that this
+   * bundle needs.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being started.
+   * @throws Exception If this method throws an exception, this
+   *                   bundle is marked as stopped and the Framework will remove this
+   *                   bundle's listeners, unregister all services registered by this
+   *                   bundle, and release all services used by this bundle.
+   */
+  @Override
+  public void start(BundleContext context) throws Exception {
+    //Initialize OSGi based FunctionLoader
+    functionLoader = new BundleFunctionLoader(context);
+    functionLoader.start();
+
+    Properties props = new Properties();
+    props.put("name", "cassandra");
+    registration = context.registerService(ClusterActionHandler.class.getName(), clusterActionHandler, props);
+  }
+
+  /**
+   * Called when this bundle is stopped so the Framework can perform the
+   * bundle-specific activities necessary to stop the bundle. In general, this
+   * method should undo the work that the <code>BundleActivator.start</code>
+   * method started. There should be no active threads that were started by
+   * this bundle when this bundle returns. A stopped bundle must not call any
+   * Framework objects.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being stopped.
+   * @throws Exception If this method throws an exception, the
+   *                   bundle is still marked as stopped, and the Framework will remove
+   *                   the bundle's listeners, unregister all services registered by the
+   *                   bundle, and release all services used by the bundle.
+   */
+  @Override
+  public void stop(BundleContext context) throws Exception {
+    if (registration != null) {
+      registration.unregister();
+    }
+  }
+}

Modified: whirr/trunk/services/cdh/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/cdh/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/cdh/pom.xml (original)
+++ whirr/trunk/services/cdh/pom.xml Sat Aug 18 19:46:56 2012
@@ -36,6 +36,7 @@
     <osgi.export>
       functions*;version="${project.version}"
     </osgi.export>
+    <osgi.bundle.activator>org.apache.whirr.service.cdh.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -135,6 +136,11 @@
       <version>3.4.3-cdh4.0.1</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Added: whirr/trunk/services/cdh/src/main/java/org/apache/whirr/service/cdh/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/cdh/src/main/java/org/apache/whirr/service/cdh/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/cdh/src/main/java/org/apache/whirr/service/cdh/osgi/Activator.java (added)
+++ whirr/trunk/services/cdh/src/main/java/org/apache/whirr/service/cdh/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.whirr.service.cdh.osgi;
+
+import org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+  private BundleFunctionLoader functionLoader;
+
+
+  /**
+   * Called when this bundle is started so the Framework can perform the
+   * bundle-specific activities necessary to start this bundle. This method
+   * can be used to register services or to allocate any resources that this
+   * bundle needs.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being started.
+   * @throws Exception If this method throws an exception, this
+   *                   bundle is marked as stopped and the Framework will remove this
+   *                   bundle's listeners, unregister all services registered by this
+   *                   bundle, and release all services used by this bundle.
+   */
+  @Override
+  public void start(BundleContext context) throws Exception {
+    //Initialize OSGi based FunctionLoader
+    functionLoader = new BundleFunctionLoader(context);
+    functionLoader.start();
+  }
+
+  /**
+   * Called when this bundle is stopped so the Framework can perform the
+   * bundle-specific activities necessary to stop the bundle. In general, this
+   * method should undo the work that the <code>BundleActivator.start</code>
+   * method started. There should be no active threads that were started by
+   * this bundle when this bundle returns. A stopped bundle must not call any
+   * Framework objects.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being stopped.
+   * @throws Exception If this method throws an exception, the
+   *                   bundle is still marked as stopped, and the Framework will remove
+   *                   the bundle's listeners, unregister all services registered by the
+   *                   bundle, and release all services used by the bundle.
+   */
+  @Override
+  public void stop(BundleContext context) throws Exception {
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+  }
+}

Modified: whirr/trunk/services/chef/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/chef/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/chef/pom.xml (original)
+++ whirr/trunk/services/chef/pom.xml Sat Aug 18 19:46:56 2012
@@ -35,7 +35,7 @@
     <osgi.export>
       org.apache.whirr.service.chef*;version="${project.version}"
     </osgi.export>
-    <osgi.fragment.host>jclouds-scriptbuilder;bundle-version="${jclouds.osgi.version.clean}"</osgi.fragment.host>
+    <osgi.bundle.activator>org.apache.whirr.service.chef.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -84,7 +84,13 @@
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
       <scope>test</scope>
-    </dependency>  
+    </dependency>
+
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Added: whirr/trunk/services/chef/src/main/java/org/apache/whirr/service/chef/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/chef/src/main/java/org/apache/whirr/service/chef/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/chef/src/main/java/org/apache/whirr/service/chef/osgi/Activator.java (added)
+++ whirr/trunk/services/chef/src/main/java/org/apache/whirr/service/chef/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.whirr.service.chef.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.ClusterActionHandlerFactory;
+import org.apache.whirr.service.chef.ChefClusterActionHandlerFactory;
+import org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import java.util.Properties;
+
+public class Activator implements BundleActivator {
+
+  private BundleFunctionLoader functionLoader;
+
+  private final ChefClusterActionHandlerFactory actionHandlerFactory = new ChefClusterActionHandlerFactory();
+  private final ClusterActionHandler clusterActionHandler = actionHandlerFactory.create("chef");
+  private ServiceRegistration handlerRegistration;
+  private ServiceRegistration factoryRegistration;
+
+  /**
+   * Called when this bundle is started so the Framework can perform the
+   * bundle-specific activities necessary to start this bundle. This method
+   * can be used to register services or to allocate any resources that this
+   * bundle needs.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being started.
+   * @throws Exception If this method throws an exception, this
+   *                   bundle is marked as stopped and the Framework will remove this
+   *                   bundle's listeners, unregister all services registered by this
+   *                   bundle, and release all services used by this bundle.
+   */
+  @Override
+  public void start(BundleContext context) throws Exception {
+    //Initialize OSGi based FunctionLoader
+    functionLoader = new BundleFunctionLoader(context);
+    functionLoader.start();
+
+    factoryRegistration = context.registerService(ClusterActionHandlerFactory.class.getName(), actionHandlerFactory, null);
+
+    Properties props = new Properties();
+    props.put("name", "chef");
+    handlerRegistration = context.registerService(ClusterActionHandler.class.getName(), clusterActionHandler, props);
+  }
+
+  /**
+   * Called when this bundle is stopped so the Framework can perform the
+   * bundle-specific activities necessary to stop the bundle. In general, this
+   * method should undo the work that the <code>BundleActivator.start</code>
+   * method started. There should be no active threads that were started by
+   * this bundle when this bundle returns. A stopped bundle must not call any
+   * Framework objects.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being stopped.
+   * @throws Exception If this method throws an exception, the
+   *                   bundle is still marked as stopped, and the Framework will remove
+   *                   the bundle's listeners, unregister all services registered by the
+   *                   bundle, and release all services used by the bundle.
+   */
+  @Override
+  public void stop(BundleContext context) throws Exception {
+    if (handlerRegistration != null) {
+      handlerRegistration.unregister();
+    }
+    if (factoryRegistration != null) {
+      factoryRegistration.unregister();
+    }
+  }
+}

Modified: whirr/trunk/services/elasticsearch/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/elasticsearch/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/elasticsearch/pom.xml (original)
+++ whirr/trunk/services/elasticsearch/pom.xml Sat Aug 18 19:46:56 2012
@@ -37,7 +37,7 @@
     <osgi.export>
       org.apache.whirr.service.elasticsearch*;version="${project.version}"
     </osgi.export>
-    <osgi.fragment.host>jclouds-scriptbuilder;bundle-version="${jclouds.osgi.version.clean}"</osgi.fragment.host>
+    <osgi.bundle.activator>org.apache.whirr.service.elasticsearch.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -86,6 +86,12 @@
       <artifactId>log4j</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Added: whirr/trunk/services/elasticsearch/src/main/java/org/apache/whirr/service/elasticsearch/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/elasticsearch/src/main/java/org/apache/whirr/service/elasticsearch/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/elasticsearch/src/main/java/org/apache/whirr/service/elasticsearch/osgi/Activator.java (added)
+++ whirr/trunk/services/elasticsearch/src/main/java/org/apache/whirr/service/elasticsearch/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.whirr.service.elasticsearch.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.elasticsearch.ElasticSearchHandler;
+import org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import java.util.Properties;
+
+public class Activator implements BundleActivator {
+
+  private BundleFunctionLoader functionLoader;
+  private final ClusterActionHandler clusterActionHandler = new ElasticSearchHandler();
+  private ServiceRegistration registration;
+
+  /**
+   * Called when this bundle is started so the Framework can perform the
+   * bundle-specific activities necessary to start this bundle. This method
+   * can be used to register services or to allocate any resources that this
+   * bundle needs.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being started.
+   * @throws Exception If this method throws an exception, this
+   *                   bundle is marked as stopped and the Framework will remove this
+   *                   bundle's listeners, unregister all services registered by this
+   *                   bundle, and release all services used by this bundle.
+   */
+  @Override
+  public void start(BundleContext context) throws Exception {
+    //Initialize OSGi based FunctionLoader
+    functionLoader = new BundleFunctionLoader(context);
+    functionLoader.start();
+
+    Properties props = new Properties();
+    props.put("name", "elasticsearch");
+    registration = context.registerService(ClusterActionHandler.class.getName(), clusterActionHandler, props);
+  }
+
+  /**
+   * Called when this bundle is stopped so the Framework can perform the
+   * bundle-specific activities necessary to stop the bundle. In general, this
+   * method should undo the work that the <code>BundleActivator.start</code>
+   * method started. There should be no active threads that were started by
+   * this bundle when this bundle returns. A stopped bundle must not call any
+   * Framework objects.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being stopped.
+   * @throws Exception If this method throws an exception, the
+   *                   bundle is still marked as stopped, and the Framework will remove
+   *                   the bundle's listeners, unregister all services registered by the
+   *                   bundle, and release all services used by the bundle.
+   */
+  @Override
+  public void stop(BundleContext context) throws Exception {
+    if (registration != null) {
+      registration.unregister();
+    }
+  }
+}

Modified: whirr/trunk/services/ganglia/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/ganglia/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/ganglia/pom.xml (original)
+++ whirr/trunk/services/ganglia/pom.xml Sat Aug 18 19:46:56 2012
@@ -36,7 +36,7 @@
     <osgi.export>
       org.apache.whirr.service.ganglia*;version="${project.version}"
     </osgi.export>
-    <osgi.fragment.host>jclouds-scriptbuilder;bundle-version="${jclouds.osgi.version.clean}"</osgi.fragment.host>
+    <osgi.bundle.activator>org.apache.whirr.service.ganglia.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -82,6 +82,12 @@
       <artifactId>log4j</artifactId>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Added: whirr/trunk/services/ganglia/src/main/java/org/apache/whirr/service/ganglia/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/ganglia/src/main/java/org/apache/whirr/service/ganglia/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/ganglia/src/main/java/org/apache/whirr/service/ganglia/osgi/Activator.java (added)
+++ whirr/trunk/services/ganglia/src/main/java/org/apache/whirr/service/ganglia/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.whirr.service.ganglia.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.ganglia.GangliaMetadClusterActionHandler;
+import org.apache.whirr.service.ganglia.GangliaMonitorClusterActionHandler;
+import org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import java.util.Properties;
+
+public class Activator implements BundleActivator {
+
+  private BundleFunctionLoader functionLoader;
+  private final ClusterActionHandler metadClusterActionHandler = new GangliaMetadClusterActionHandler();
+  private ServiceRegistration metadRegistration;
+
+  private final ClusterActionHandler monitorClusterActionHandler = new GangliaMonitorClusterActionHandler();
+  private ServiceRegistration monitorRegistration;
+
+  /**
+   * Called when this bundle is started so the Framework can perform the
+   * bundle-specific activities necessary to start this bundle. This method
+   * can be used to register services or to allocate any resources that this
+   * bundle needs.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being started.
+   * @throws Exception If this method throws an exception, this
+   *                   bundle is marked as stopped and the Framework will remove this
+   *                   bundle's listeners, unregister all services registered by this
+   *                   bundle, and release all services used by this bundle.
+   */
+  @Override
+  public void start(BundleContext context) throws Exception {
+    //Initialize OSGi based FunctionLoader
+    functionLoader = new BundleFunctionLoader(context);
+    functionLoader.start();
+
+    Properties metadProps = new Properties();
+    metadProps.put("name", "ganglia-metad");
+    metadRegistration = context.registerService(ClusterActionHandler.class.getName(), metadClusterActionHandler, metadProps);
+
+    Properties monitorProps = new Properties();
+    monitorProps.put("name", "ganglia-monitor");
+    monitorRegistration = context.registerService(ClusterActionHandler.class.getName(), monitorClusterActionHandler, monitorProps);
+
+
+  }
+
+  /**
+   * Called when this bundle is stopped so the Framework can perform the
+   * bundle-specific activities necessary to stop the bundle. In general, this
+   * method should undo the work that the <code>BundleActivator.start</code>
+   * method started. There should be no active threads that were started by
+   * this bundle when this bundle returns. A stopped bundle must not call any
+   * Framework objects.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being stopped.
+   * @throws Exception If this method throws an exception, the
+   *                   bundle is still marked as stopped, and the Framework will remove
+   *                   the bundle's listeners, unregister all services registered by the
+   *                   bundle, and release all services used by the bundle.
+   */
+  @Override
+  public void stop(BundleContext context) throws Exception {
+    if (metadRegistration != null) {
+      metadRegistration.unregister();
+    }
+    if (monitorRegistration != null) {
+      metadRegistration.unregister();
+    }
+  }
+}

Modified: whirr/trunk/services/hadoop/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/hadoop/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/hadoop/pom.xml (original)
+++ whirr/trunk/services/hadoop/pom.xml Sat Aug 18 19:46:56 2012
@@ -37,7 +37,7 @@
     <osgi.export>
       org.apache.whirr.service.hadoop*;version="${project.version}"
     </osgi.export>
-    <osgi.fragment.host>jclouds-scriptbuilder;bundle-version="${jclouds.osgi.version.clean}"</osgi.fragment.host>
+    <osgi.bundle.activator>org.apache.whirr.service.hadoop.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -120,6 +120,12 @@
       <version>1.9.3</version>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Added: whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/osgi/Activator.java (added)
+++ whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.whirr.service.hadoop.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.hadoop.HadoopDataNodeClusterActionHandler;
+import org.apache.whirr.service.hadoop.HadoopJobTrackerClusterActionHandler;
+import org.apache.whirr.service.hadoop.HadoopNameNodeClusterActionHandler;
+import org.apache.whirr.service.hadoop.HadoopTaskTrackerClusterActionHandler;
+import org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import java.util.Properties;
+
+public class Activator implements BundleActivator {
+
+  private BundleFunctionLoader functionLoader;
+
+  private final ClusterActionHandler dataNodeClusterActionHandler = new HadoopDataNodeClusterActionHandler();
+  private ServiceRegistration dataNodeRegistration;
+
+  private final ClusterActionHandler nameNodeClusterActionHandler = new HadoopNameNodeClusterActionHandler();
+  private ServiceRegistration nameNodeRegistration;
+
+  private final ClusterActionHandler jobTrackerClusterActionHandler = new HadoopJobTrackerClusterActionHandler();
+  private ServiceRegistration jobTrackerRegistration;
+
+  private final ClusterActionHandler taskTrackerClusterActionHandler = new HadoopTaskTrackerClusterActionHandler();
+  private ServiceRegistration taskTrackerRegistration;
+
+  /**
+   * Called when this bundle is started so the Framework can perform the
+   * bundle-specific activities necessary to start this bundle. This method
+   * can be used to register services or to allocate any resources that this
+   * bundle needs.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being started.
+   * @throws Exception If this method throws an exception, this
+   *                   bundle is marked as stopped and the Framework will remove this
+   *                   bundle's listeners, unregister all services registered by this
+   *                   bundle, and release all services used by this bundle.
+   */
+  @Override
+  public void start(BundleContext context) throws Exception {
+    //Initialize OSGi based FunctionLoader
+    functionLoader = new BundleFunctionLoader(context);
+    functionLoader.start();
+
+    Properties dataNodeProps = new Properties();
+    dataNodeProps.put("name", "hadoop-datanode");
+    dataNodeRegistration = context.registerService(ClusterActionHandler.class.getName(), dataNodeClusterActionHandler, dataNodeProps);
+
+    Properties nameNodeProps = new Properties();
+    nameNodeProps.put("name", "hadoop-namenode");
+    nameNodeRegistration = context.registerService(ClusterActionHandler.class.getName(), nameNodeClusterActionHandler, nameNodeProps);
+
+    Properties jobTrackerProps = new Properties();
+    jobTrackerProps.put("name", "hadoop-jobtracker");
+    jobTrackerRegistration = context.registerService(ClusterActionHandler.class.getName(), jobTrackerClusterActionHandler, jobTrackerProps);
+
+    Properties taskTrackerProps = new Properties();
+    taskTrackerProps.put("name", "hadoop-tasktracker");
+    taskTrackerRegistration = context.registerService(ClusterActionHandler.class.getName(), taskTrackerClusterActionHandler, taskTrackerProps);
+  }
+
+  /**
+   * Called when this bundle is stopped so the Framework can perform the
+   * bundle-specific activities necessary to stop the bundle. In general, this
+   * method should undo the work that the <code>BundleActivator.start</code>
+   * method started. There should be no active threads that were started by
+   * this bundle when this bundle returns. A stopped bundle must not call any
+   * Framework objects.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being stopped.
+   * @throws Exception If this method throws an exception, the
+   *                   bundle is still marked as stopped, and the Framework will remove
+   *                   the bundle's listeners, unregister all services registered by the
+   *                   bundle, and release all services used by the bundle.
+   */
+  @Override
+  public void stop(BundleContext context) throws Exception {
+    if (dataNodeRegistration != null) {
+      dataNodeRegistration.unregister();
+    }
+    if (nameNodeRegistration != null) {
+      nameNodeRegistration.unregister();
+    }
+    if (jobTrackerRegistration != null) {
+      jobTrackerRegistration.unregister();
+    }
+    if (taskTrackerRegistration != null) {
+      taskTrackerRegistration.unregister();
+    }
+
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+  }
+}

Modified: whirr/trunk/services/hama/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/hama/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/hama/pom.xml (original)
+++ whirr/trunk/services/hama/pom.xml Sat Aug 18 19:46:56 2012
@@ -39,7 +39,7 @@
     <osgi.export>
       org.apache.whirr.service.hama*;version="${project.version}"
     </osgi.export>
-    <osgi.fragment.host>jclouds-scriptbuilder;bundle-version="${jclouds.osgi.version.clean}"</osgi.fragment.host>
+    <osgi.bundle.activator>org.apache.whirr.service.hama.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -128,6 +128,12 @@
       <version>${zookeeper.version}</version>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Added: whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/osgi/Activator.java (added)
+++ whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.whirr.service.hama.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.hama.HamaGroomServerClusterActionHandler;
+import org.apache.whirr.service.hama.HamaMasterClusterActionHandler;
+import org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import java.util.Properties;
+
+public class Activator implements BundleActivator {
+
+  private BundleFunctionLoader functionLoader;
+
+  private final ClusterActionHandler groomClusterActionHandler = new HamaGroomServerClusterActionHandler();
+  private ServiceRegistration groomRegistration;
+
+  private final ClusterActionHandler masterClusterActionHandler = new HamaMasterClusterActionHandler();
+  private ServiceRegistration masterRegistration;
+
+  /**
+   * Called when this bundle is started so the Framework can perform the
+   * bundle-specific activities necessary to start this bundle. This method
+   * can be used to register services or to allocate any resources that this
+   * bundle needs.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being started.
+   * @throws Exception If this method throws an exception, this
+   *                   bundle is marked as stopped and the Framework will remove this
+   *                   bundle's listeners, unregister all services registered by this
+   *                   bundle, and release all services used by this bundle.
+   */
+  @Override
+  public void start(BundleContext context) throws Exception {
+    //Initialize OSGi based FunctionLoader
+    functionLoader = new BundleFunctionLoader(context);
+    functionLoader.start();
+
+    Properties groomProps = new Properties();
+    groomProps.put("name", "hama-groomserver");
+    groomRegistration = context.registerService(ClusterActionHandler.class.getName(), groomClusterActionHandler, groomProps);
+
+    Properties masterProps = new Properties();
+    masterProps.put("name", "hama-master");
+    groomRegistration = context.registerService(ClusterActionHandler.class.getName(), masterClusterActionHandler, masterProps);
+  }
+
+  /**
+   * Called when this bundle is stopped so the Framework can perform the
+   * bundle-specific activities necessary to stop the bundle. In general, this
+   * method should undo the work that the <code>BundleActivator.start</code>
+   * method started. There should be no active threads that were started by
+   * this bundle when this bundle returns. A stopped bundle must not call any
+   * Framework objects.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being stopped.
+   * @throws Exception If this method throws an exception, the
+   *                   bundle is still marked as stopped, and the Framework will remove
+   *                   the bundle's listeners, unregister all services registered by the
+   *                   bundle, and release all services used by the bundle.
+   */
+  @Override
+  public void stop(BundleContext context) throws Exception {
+    if (groomRegistration != null) {
+      groomRegistration.unregister();
+    }
+    if (masterRegistration != null) {
+      masterRegistration.unregister();
+    }
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+  }
+}

Modified: whirr/trunk/services/hbase/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/hbase/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/hbase/pom.xml (original)
+++ whirr/trunk/services/hbase/pom.xml Sat Aug 18 19:46:56 2012
@@ -37,7 +37,7 @@
     <osgi.export>
       org.apache.whirr.service.hbase*;version="${project.version}"
     </osgi.export>
-    <osgi.fragment.host>jclouds-scriptbuilder;bundle-version="${jclouds.osgi.version.clean}"</osgi.fragment.host>
+    <osgi.bundle.activator>org.apache.whirr.service.hbase.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -121,6 +121,12 @@
       <classifier>tests</classifier>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Added: whirr/trunk/services/hbase/src/main/java/org/apache/whirr/service/hbase/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/hbase/src/main/java/org/apache/whirr/service/hbase/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/hbase/src/main/java/org/apache/whirr/service/hbase/osgi/Activator.java (added)
+++ whirr/trunk/services/hbase/src/main/java/org/apache/whirr/service/hbase/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.whirr.service.hbase.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.hbase.HBaseAvroServerClusterActionHandler;
+import org.apache.whirr.service.hbase.HBaseMasterClusterActionHandler;
+import org.apache.whirr.service.hbase.HBaseRegionServerClusterActionHandler;
+import org.apache.whirr.service.hbase.HBaseRestServerClusterActionHandler;
+import org.apache.whirr.service.hbase.HBaseThriftServerClusterActionHandler;
+import org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import java.util.Properties;
+
+public class Activator implements BundleActivator {
+
+  private BundleFunctionLoader functionLoader;
+
+  private final ClusterActionHandler masterClusterActionHandler = new HBaseMasterClusterActionHandler();
+  private ServiceRegistration masterRegistration;
+
+  private final ClusterActionHandler regionServerClusterActionHandler = new HBaseRegionServerClusterActionHandler();
+  private ServiceRegistration regionServerRegistration;
+
+  private final ClusterActionHandler restServerClusterActionHandler = new HBaseRestServerClusterActionHandler();
+  private ServiceRegistration restServerRegistration;
+
+  private final ClusterActionHandler avroServerClusterActionHandler = new HBaseAvroServerClusterActionHandler();
+  private ServiceRegistration avroServerRegistration;
+
+  private final ClusterActionHandler thriftServerClusterActionHandler = new HBaseThriftServerClusterActionHandler();
+  private ServiceRegistration thriftServerRegistration;
+
+  /**
+   * Called when this bundle is started so the Framework can perform the
+   * bundle-specific activities necessary to start this bundle. This method
+   * can be used to register services or to allocate any resources that this
+   * bundle needs.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being started.
+   * @throws Exception If this method throws an exception, this
+   *                   bundle is marked as stopped and the Framework will remove this
+   *                   bundle's listeners, unregister all services registered by this
+   *                   bundle, and release all services used by this bundle.
+   */
+  @Override
+  public void start(BundleContext context) throws Exception {
+    //Initialize OSGi based FunctionLoader
+    functionLoader = new BundleFunctionLoader(context);
+    functionLoader.start();
+
+    Properties masterProps = new Properties();
+    masterProps.put("name", "hbase-master");
+    masterRegistration = context.registerService(ClusterActionHandler.class.getName(), masterClusterActionHandler, masterProps);
+
+    Properties regionServerProps = new Properties();
+    regionServerProps.put("name", "hbase-regionserver");
+    regionServerRegistration = context.registerService(ClusterActionHandler.class.getName(), regionServerClusterActionHandler, regionServerProps);
+
+    Properties restServerProps = new Properties();
+    restServerProps.put("name", "hbase-restserver");
+    restServerRegistration = context.registerService(ClusterActionHandler.class.getName(), restServerClusterActionHandler, restServerProps);
+
+    Properties avroServerProps = new Properties();
+    avroServerProps.put("name", "hbase-avroserver");
+    avroServerRegistration = context.registerService(ClusterActionHandler.class.getName(), avroServerClusterActionHandler, avroServerProps);
+
+    Properties thriftServerProps = new Properties();
+    thriftServerProps.put("name", "hbase-thriftserver");
+    thriftServerRegistration = context.registerService(ClusterActionHandler.class.getName(), thriftServerClusterActionHandler, thriftServerProps);
+  }
+
+  /**
+   * Called when this bundle is stopped so the Framework can perform the
+   * bundle-specific activities necessary to stop the bundle. In general, this
+   * method should undo the work that the <code>BundleActivator.start</code>
+   * method started. There should be no active threads that were started by
+   * this bundle when this bundle returns. A stopped bundle must not call any
+   * Framework objects.
+   * <p/>
+   * <p/>
+   * This method must complete and return to its caller in a timely manner.
+   *
+   * @param context The execution context of the bundle being stopped.
+   * @throws Exception If this method throws an exception, the
+   *                   bundle is still marked as stopped, and the Framework will remove
+   *                   the bundle's listeners, unregister all services registered by the
+   *                   bundle, and release all services used by the bundle.
+   */
+  @Override
+  public void stop(BundleContext context) throws Exception {
+    if (masterRegistration != null) {
+      masterRegistration.unregister();
+    }
+
+    if (regionServerRegistration != null) {
+      regionServerRegistration.unregister();
+    }
+
+    if (restServerRegistration != null) {
+      restServerRegistration.unregister();
+    }
+    if (avroServerRegistration != null) {
+      avroServerRegistration.unregister();
+    }
+    if (thriftServerRegistration != null) {
+      thriftServerRegistration.unregister();
+    }
+    if (masterRegistration != null) {
+      masterRegistration.unregister();
+    }
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+  }
+}

Modified: whirr/trunk/services/mahout/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/mahout/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/mahout/pom.xml (original)
+++ whirr/trunk/services/mahout/pom.xml Sat Aug 18 19:46:56 2012
@@ -36,7 +36,7 @@
     <osgi.export>
       org.apache.whirr.service.mahout*;version="${project.version}"
     </osgi.export>
-    <osgi.fragment.host>jclouds-scriptbuilder;bundle-version="${jclouds.osgi.version.clean}"</osgi.fragment.host>
+    <osgi.bundle.activator>org.apache.whirr.service.mahout.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -74,6 +74,12 @@
       <artifactId>slf4j-log4j12</artifactId>
       <scope>test</scope>
      </dependency>
+
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>