felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1456909 - in /felix/trunk/jaas: pom.xml src/main/java/org/apache/felix/jaas/internal/Activator.java src/main/java/org/apache/felix/jaas/internal/JaasWebConsolePlugin.java
Date Fri, 15 Mar 2013 11:57:26 GMT
Author: chetanm
Date: Fri Mar 15 11:57:26 2013
New Revision: 1456909

URL: http://svn.apache.org/r1456909
Log:
FELIX-3956 - JAAS Support bundle should have optional dependency on Servlet API

Using ServiceFactory to register the WebConsolePlugin to avoid direct dependency on Servlet
API. Also using DynamicImport-Package (without using wildcards) for the servlet api.

Modified:
    felix/trunk/jaas/pom.xml
    felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/Activator.java
    felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/JaasWebConsolePlugin.java

Modified: felix/trunk/jaas/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/jaas/pom.xml?rev=1456909&r1=1456908&r2=1456909&view=diff
==============================================================================
--- felix/trunk/jaas/pom.xml (original)
+++ felix/trunk/jaas/pom.xml Fri Mar 15 11:57:26 2013
@@ -94,10 +94,10 @@
                         <Bundle-Activator>
                             org.apache.felix.jaas.internal.Activator
                         </Bundle-Activator>
-                        <Import-Package>
-                          javax.servlet.*;resolution:=optional,
-                          *
-                        </Import-Package>
+                        <DynamicImport-Package>
+                          javax.servlet,
+                          javax.servlet.http
+                        </DynamicImport-Package>
                         <_removeheaders>
                             Embed-Dependency,Private-Package,Include-Resource
                         </_removeheaders>

Modified: felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/Activator.java?rev=1456909&r1=1456908&r2=1456909&view=diff
==============================================================================
--- felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/Activator.java (original)
+++ felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/Activator.java Fri Mar 15
11:57:26 2013
@@ -19,9 +19,14 @@
 
 package org.apache.felix.jaas.internal;
 
+import java.util.Properties;
+
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.osgi.service.log.LogService;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
 
 public class Activator implements BundleActivator
 {
@@ -66,11 +71,27 @@ public class Activator implements Bundle
     }
 
     private void registerWebConsolePlugin(BundleContext context){
-        try{
-            webConsolePlugin = new JaasWebConsolePlugin(context, configSpi,loginModuleCreator);
-        }catch(NoClassDefFoundError t){
-            //Servlet API is not present. This is an optional requirement
-            logger.log(LogService.LOG_INFO,"HTTP support not found. JAAS WebConsole Plugin
would not be registered");
+        Properties props = new Properties();
+        props.put(Constants.SERVICE_VENDOR, "Apache Software Foundation");
+        props.put(Constants.SERVICE_DESCRIPTION, "JAAS Web Console Plugin");
+        props.put("felix.webconsole.label", "jaas");
+        props.put("felix.webconsole.title", "JAAS");
+        props.put("felix.webconsole.configprinter.modes", "always");
+
+        //Registering a ServiceFactory to avoid dependency on Servlet API
+        context.registerService("" +
+                ".Servlet", new PluginServiceFactory(), props);
+    }
+
+    private class PluginServiceFactory implements ServiceFactory {
+
+        @Override
+        public Object getService(Bundle bundle, ServiceRegistration registration) {
+            return new JaasWebConsolePlugin(configSpi,loginModuleCreator);
+        }
+
+        @Override
+        public void ungetService(Bundle bundle, ServiceRegistration registration, Object
service) {
         }
     }
 

Modified: felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/JaasWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/JaasWebConsolePlugin.java?rev=1456909&r1=1456908&r2=1456909&view=diff
==============================================================================
--- felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/JaasWebConsolePlugin.java
(original)
+++ felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/JaasWebConsolePlugin.java
Fri Mar 15 11:57:26 2013
@@ -1,3 +1,4 @@
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -25,17 +26,14 @@ import static org.apache.felix.jaas.inte
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
 
-import javax.servlet.Servlet;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 
@@ -46,18 +44,10 @@ public class JaasWebConsolePlugin extend
 
     private final BundleLoginModuleCreator loginModuleCreator;
 
-    public JaasWebConsolePlugin(BundleContext context, ConfigSpiOsgi configSpi, BundleLoginModuleCreator
loginModuleCreator)
+    public JaasWebConsolePlugin(ConfigSpiOsgi configSpi, BundleLoginModuleCreator loginModuleCreator)
     {
         this.configSpi = configSpi;
         this.loginModuleCreator = loginModuleCreator;
-
-        Properties props = new Properties();
-        props.put(Constants.SERVICE_VENDOR, "Apache Software Foundation");
-        props.put(Constants.SERVICE_DESCRIPTION, "JAAS Web Console Plugin");
-        props.put("felix.webconsole.label", "jaas");
-        props.put("felix.webconsole.title", "JAAS");
-        props.put("felix.webconsole.configprinter.modes", "always");
-        context.registerService(Servlet.class.getName(), this, props);
     }
 
     @Override



Mime
View raw message