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 [2/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...

Added: whirr/trunk/services/mahout/src/main/java/org/apache/whirr/service/mahout/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/mahout/src/main/java/org/apache/whirr/service/mahout/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/mahout/src/main/java/org/apache/whirr/service/mahout/osgi/Activator.java (added)
+++ whirr/trunk/services/mahout/src/main/java/org/apache/whirr/service/mahout/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,87 @@
+/*
+ * 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.mahout.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.mahout.MahoutClientClusterActionHandler;
+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 MahoutClientClusterActionHandler();
+  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", "mahout-client");
+    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();
+    }
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+  }
+}

Modified: whirr/trunk/services/pig/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/pig/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/pig/pom.xml (original)
+++ whirr/trunk/services/pig/pom.xml Sat Aug 18 19:46:56 2012
@@ -36,7 +36,7 @@
     <osgi.export>
       org.apache.whirr.service.pig*;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.pig.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
    <dependency>
@@ -74,6 +74,11 @@
       <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>

Added: whirr/trunk/services/pig/src/main/java/org/apache/whirr/service/pig/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/pig/src/main/java/org/apache/whirr/service/pig/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/pig/src/main/java/org/apache/whirr/service/pig/osgi/Activator.java (added)
+++ whirr/trunk/services/pig/src/main/java/org/apache/whirr/service/pig/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,87 @@
+/*
+ * 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.pig.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.pig.PigClientClusterActionHandler;
+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 PigClientClusterActionHandler();
+  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", "pig-client");
+    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();
+    }
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+  }
+}

Modified: whirr/trunk/services/puppet/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/puppet/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/puppet/pom.xml (original)
+++ whirr/trunk/services/puppet/pom.xml Sat Aug 18 19:46:56 2012
@@ -35,7 +35,7 @@
     <osgi.export>
       org.apache.whirr.service.puppet*;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.puppet.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -85,6 +85,11 @@
       <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>

Added: whirr/trunk/services/puppet/src/main/java/org/apache/whirr/service/puppet/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/puppet/src/main/java/org/apache/whirr/service/puppet/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/puppet/src/main/java/org/apache/whirr/service/puppet/osgi/Activator.java (added)
+++ whirr/trunk/services/puppet/src/main/java/org/apache/whirr/service/puppet/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,96 @@
+/*
+ * 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.puppet.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.ClusterActionHandlerFactory;
+import org.apache.whirr.service.puppet.PuppetClusterActionHandlerFactory;
+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 PuppetClusterActionHandlerFactory actionHandlerFactory = new PuppetClusterActionHandlerFactory();
+  private final ClusterActionHandler clusterActionHandler = actionHandlerFactory.create("puppet");
+  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", "puppet-install");
+    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();
+    }
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+  }
+}

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

Added: whirr/trunk/services/solr/src/main/java/org/apache/whirr/service/solr/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/solr/src/main/java/org/apache/whirr/service/solr/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/solr/src/main/java/org/apache/whirr/service/solr/osgi/Activator.java (added)
+++ whirr/trunk/services/solr/src/main/java/org/apache/whirr/service/solr/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,88 @@
+/*
+ * 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.solr.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.solr.SolrClusterActionHandler;
+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 SolrClusterActionHandler();
+  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", "solr");
+    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();
+    }
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+  }
+}

Modified: whirr/trunk/services/voldemort/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/voldemort/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/voldemort/pom.xml (original)
+++ whirr/trunk/services/voldemort/pom.xml Sat Aug 18 19:46:56 2012
@@ -37,7 +37,7 @@
     <osgi.export>
       org.apache.whirr.service.voldemort*;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.voldemort.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -100,6 +100,11 @@
       <artifactId>jdom</artifactId>
       <version>${jdom.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
  </dependencies>
   <build>
     <plugins>

Added: whirr/trunk/services/voldemort/src/main/java/org/apache/whirr/service/voldemort/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/voldemort/src/main/java/org/apache/whirr/service/voldemort/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/voldemort/src/main/java/org/apache/whirr/service/voldemort/osgi/Activator.java (added)
+++ whirr/trunk/services/voldemort/src/main/java/org/apache/whirr/service/voldemort/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,86 @@
+/*
+ * 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.voldemort.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.cassandra.CassandraClusterActionHandler;
+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();
+    }
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+  }
+}

Modified: whirr/trunk/services/yarn/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/yarn/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/yarn/pom.xml (original)
+++ whirr/trunk/services/yarn/pom.xml Sat Aug 18 19:46:56 2012
@@ -25,12 +25,22 @@
   </parent>
   <groupId>org.apache.whirr</groupId>
   <artifactId>whirr-yarn</artifactId>
-  <packaging>jar</packaging>
+  <packaging>bundle</packaging>
   <version>0.9.0-SNAPSHOT</version>
   <name>Apache Whirr YARN</name>
   <properties>
     <hadoop.version>0.20.2</hadoop.version>
+    <osgi.import>
+      !org.apache.whirr.service.yarn*,
+      org.apache.commons.configuration*;version="[1.6,2)",
+      *
+    </osgi.import>
+    <osgi.export>
+      org.apache.whirr.service.yarn*;version="${project.version}"
+    </osgi.export>
+    <osgi.bundle.activator>org.apache.whirr.service.yarn.osgi.Activator</osgi.bundle.activator>
   </properties>
+
   <dependencies>
     <dependency>
       <groupId>${project.groupId}</groupId>
@@ -117,6 +127,11 @@
       <version>0.23.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/yarn/src/main/java/org/apache/whirr/service/yarn/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/yarn/src/main/java/org/apache/whirr/service/yarn/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/yarn/src/main/java/org/apache/whirr/service/yarn/osgi/Activator.java (added)
+++ whirr/trunk/services/yarn/src/main/java/org/apache/whirr/service/yarn/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.yarn.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.yarn.YarnNodeManagerHandler;
+import org.apache.whirr.service.yarn.YarnResourceManagerHandler;
+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 nodeManagerClusterActionHandler = new YarnNodeManagerHandler();
+  private ServiceRegistration nodeManagerRegistration;
+
+  private final ClusterActionHandler resourceManagerClusterActionHandler = new YarnResourceManagerHandler();
+  private ServiceRegistration resourceManagerRegistration;
+
+  /**
+   * 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 nodeManagerProps = new Properties();
+    nodeManagerProps.put("name", "yarn-nodemanager");
+    nodeManagerRegistration = context.registerService(ClusterActionHandler.class.getName(), nodeManagerClusterActionHandler, nodeManagerProps);
+
+    Properties resourceManagerProps = new Properties();
+    resourceManagerProps.put("name", "yarn-resourcemanager");
+    resourceManagerRegistration = context.registerService(ClusterActionHandler.class.getName(), resourceManagerClusterActionHandler, resourceManagerProps);
+  }
+
+  /**
+   * 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 (nodeManagerRegistration != null) {
+      nodeManagerRegistration.unregister();
+    }
+    if (resourceManagerRegistration != null) {
+      resourceManagerRegistration.unregister();
+    }
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+  }
+}

Modified: whirr/trunk/services/zookeeper/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/services/zookeeper/pom.xml?rev=1374643&r1=1374642&r2=1374643&view=diff
==============================================================================
--- whirr/trunk/services/zookeeper/pom.xml (original)
+++ whirr/trunk/services/zookeeper/pom.xml Sat Aug 18 19:46:56 2012
@@ -37,7 +37,7 @@
     <osgi.export>
       org.apache.whirr.service.zookeeper*;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.zookeeper.osgi.Activator</osgi.bundle.activator>
   </properties>
   <dependencies>
     <dependency>
@@ -88,6 +88,11 @@
       <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/zookeeper/src/main/java/org/apache/whirr/service/zookeeper/osgi/Activator.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/zookeeper/src/main/java/org/apache/whirr/service/zookeeper/osgi/Activator.java?rev=1374643&view=auto
==============================================================================
--- whirr/trunk/services/zookeeper/src/main/java/org/apache/whirr/service/zookeeper/osgi/Activator.java (added)
+++ whirr/trunk/services/zookeeper/src/main/java/org/apache/whirr/service/zookeeper/osgi/Activator.java Sat Aug 18 19:46:56 2012
@@ -0,0 +1,87 @@
+/*
+ * 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.zookeeper.osgi;
+
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.zookeeper.ZooKeeperClusterActionHandler;
+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 ZooKeeperClusterActionHandler();
+  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", "zookeeper");
+    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();
+    }
+    if (functionLoader != null) {
+      functionLoader.stop();
+    }
+  }
+}