>A common trick is to no instantiate the plugin ahead of time but register a ServiceFactory whose getService method creates the plugin to use.
Interesting .. I was also not feeling good using the current approach. Would try that approach. Thanx for the pointer!! regards Chetan Chetan Mehrotra On Wed, Mar 6, 2013 at 5:37 PM, Felix Meschberger <[email protected]>wrote: > Hi Chetan > > A common trick is to no instantiate the plugin ahead of time but register > a ServiceFactory whose getService method creates the plugin to use. > > In a few Web Console servlets we do DynamicImport-Package for the servlet > API and thus can wire and use at the point where the service is used and > the API is presumably available. > > Regards > Felix > > Am 06.03.2013 um 12:25 schrieb <[email protected]>: > > > Author: chetanm > > Date: Wed Mar 6 11:25:01 2013 > > New Revision: 1453296 > > > > URL: http://svn.apache.org/r1453296 > > Log: > > 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 > > > > Modified: > > felix/trunk/jaas/pom.xml > > > felix/trunk/jaas/src/main/java/org/apache/felix/jaas/internal/Activator.java > > > > Modified: felix/trunk/jaas/pom.xml > > URL: > http://svn.apache.org/viewvc/felix/trunk/jaas/pom.xml?rev=1453296&r1=1453295&r2=1453296&view=diff > > > ============================================================================== > > --- felix/trunk/jaas/pom.xml (original) > > +++ felix/trunk/jaas/pom.xml Wed Mar 6 11:25:01 2013 > > @@ -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> > > > > 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=1453296&r1=1453295&r2=1453296&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 > Wed Mar 6 11:25:01 2013 > > @@ -21,6 +21,7 @@ package org.apache.felix.jaas.internal; > > > > 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 @@ public class Activator implements Bundle > > 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 @@ public class Activator implements Bundle > > 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"); > > + } > > + } > > + > > } > > > > > > > -- > Felix Meschberger | Principal Scientist | Adobe > > > > > > > >
