FELIX-3956 - JAAS Support bundle should have optional dependency on Servlet API

Marking the javax.servlet package as optional. And handling exception while creating plugin instance in absence of servlet api

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1453296 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/jaas/pom.xml b/jaas/pom.xml
index 8e5072e..167b41e 100644
--- a/jaas/pom.xml
+++ b/jaas/pom.xml
@@ -87,6 +87,10 @@
                         <Bundle-Activator>
                             org.apache.felix.jaas.internal.Activator
                         </Bundle-Activator>
+                        <Import-Package>
+                          javax.servlet.*;resolution:=optional,
+                          *
+                        </Import-Package>
                         <_removeheaders>
                             Embed-Dependency,Private-Package,Include-Resource
                         </_removeheaders>
diff --git a/jaas/src/main/java/org/apache/felix/jaas/internal/Activator.java b/jaas/src/main/java/org/apache/felix/jaas/internal/Activator.java
index 71d43d3..cca5ff2 100644
--- a/jaas/src/main/java/org/apache/felix/jaas/internal/Activator.java
+++ b/jaas/src/main/java/org/apache/felix/jaas/internal/Activator.java
@@ -21,6 +21,7 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
 
 public class Activator implements BundleActivator
 {
@@ -38,7 +39,7 @@
         loginModuleCreator = new BundleLoginModuleCreator(context, logger);
         jaasConfigFactory = new JaasConfigFactory(context, loginModuleCreator, logger);
         configSpi = new ConfigSpiOsgi(context, logger);
-        webConsolePlugin = new JaasWebConsolePlugin(context, configSpi,loginModuleCreator);
+        registerWebConsolePlugin(context);
 
         logger.open();
         loginModuleCreator.open();
@@ -63,4 +64,14 @@
             logger.close();
         }
     }
+
+    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");
+        }
+    }
+
 }