You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2011/01/09 04:39:24 UTC

svn commit: r1056882 - in /felix/trunk/http/jetty: pom.xml src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java src/main/java/org/apache/felix/http/jetty/internal/JettyService.java

Author: fmeschbe
Date: Sun Jan  9 03:39:23 2011
New Revision: 1056882

URL: http://svn.apache.org/viewvc?rev=1056882&view=rev
Log:
FELIX-1978 Register the ManagedService as a service factory and dynamically import Configuration Admin API. This allows to start Jetty without Configuration Admin but to still receive configuration once the Configuration Admin service is providing configuration

Added:
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java   (with props)
Modified:
    felix/trunk/http/jetty/pom.xml
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java

Modified: felix/trunk/http/jetty/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/pom.xml?rev=1056882&r1=1056881&r2=1056882&view=diff
==============================================================================
--- felix/trunk/http/jetty/pom.xml (original)
+++ felix/trunk/http/jetty/pom.xml Sun Jan  9 03:39:23 2011
@@ -57,6 +57,9 @@
                             org.slf4j;resolution:=optional,
                             *;resolution:=optional
                         </Import-Package>
+                        <DynamicImport-Package>
+                            org.osgi.service.cm;version=1.2
+                        </DynamicImport-Package>
                     </instructions>
                 </configuration>
             </plugin>

Added: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java?rev=1056882&view=auto
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java (added)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java Sun Jan  9 03:39:23 2011
@@ -0,0 +1,54 @@
+/*
+ * 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.felix.http.jetty.internal;
+
+import java.util.Dictionary;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ManagedService;
+
+public class JettyManagedService implements ServiceFactory
+{
+
+    private final JettyService jettyService;
+
+    JettyManagedService(final JettyService jettyService)
+    {
+        this.jettyService = jettyService;
+    }
+
+    public Object getService(Bundle bundle, ServiceRegistration registration)
+    {
+        return new ManagedService()
+        {
+            public void updated(Dictionary properties)
+            {
+                jettyService.updated(properties);
+            }
+        };
+    }
+
+    public void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
+    {
+        // just have the reference dropped, nothing to cleanup
+    }
+
+}

Propchange: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java?rev=1056882&r1=1056881&r2=1056882&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java (original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java Sun Jan  9 03:39:23 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.felix.http.jetty.internal;
 
-import org.osgi.service.cm.ManagedService;
-import org.osgi.service.cm.ConfigurationException;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
@@ -38,7 +36,7 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 
 public final class JettyService
-    implements ManagedService, Runnable
+    implements Runnable
 {
     /** PID for configuration of the HTTP service. */
     private static final String PID = "org.apache.felix.http";
@@ -67,7 +65,8 @@ public final class JettyService
 
         Properties props = new Properties();
         props.put(Constants.SERVICE_PID, PID);
-        this.configServiceReg = this.context.registerService(ManagedService.class.getName(), this, props);
+        this.configServiceReg = this.context.registerService("org.osgi.service.cm.ManagedService",
+            new JettyManagedService(this), props);
 
         this.thread = new Thread(this, "Jetty HTTP Service");
         this.thread.start();
@@ -98,7 +97,6 @@ public final class JettyService
     }
 
     public void updated(Dictionary props)
-        throws ConfigurationException
     {
         this.config.update(props);