Hi,
Actually I am trying to ignore registering filter in every bundle, if some
bundle developer forgot to add filter, will have impact. So using
whiteboard / blueprint to register filter in all web bundles.
<reference-list id="servletContext"
interface="javax.servlet.ServletContext">
<reference-listener ref="contextListener" bind-method="addContext" />
</reference-list>
<bean id="gzipFilter" class="org.js.assembler. GZIPFilter ">
<property name="bundleContext" ref="blueprintBundleContext" />
</bean>
<bean id="contextListener" class="org.js.assembler.ContextListener">
<property name=" gzipFilter " ref=" gzipFilter " />
</bean>
ContextListener.addContext methos
public void addContext(Object resource, Map prop) throws Exception {
Long serviceId = (Long) prop.get(Constants.SERVICE_ID);
ServiceReference serviceReference =
FrameworkUtils.resolveService(bundleContext, serviceId);
Bundle bundle = serviceReference.getBundle();
Dictionary<String, Object> properties = new Hashtable<String, Object>();
properties.put("urlPatterns", "/*");
bundle.getBundleContext().registerService("javax.servlet.Filter", this.
gzipFilter , properties);
if (LOG.isDebugEnabled()) {
LOG.debug("context added, service ID : " + serviceId);
LOG.debug(" gzipFilter added, Bundle ID :" + bundle.getBundleId());
}
}
above code is working fine in Web Application Bundles,(
pax-web-extender-whiteboard)
I want to know how to do the same thing in wars (pax-web-extender-war) ? I
have so many bundles in WAB, I am trying to avoid converting WAB to web
Application bundles...
Any inputs please ?
On Wed, Jun 13, 2012 at 7:52 PM, Achim Nierbeck <[email protected]>wrote:
> Hi,
>
> well the thing is you only have one http-context per bundle, this way
> it's hard to do this with whiteboard, cause you would need to share
> your http-context. But afaik on this list someone on this list did
> document a way how to handle this with a service :)
>
> For sharing Filters across multiple http-contextes I suggest using the
> classical Activator, this way you are able to re-use some sort of
> Class or maybe central service when registering your bundle with a
> http-context.
>
>
> I hope I did get right what you are trying to do :)
> regards, Achim
>
> 2012/6/13 Dattu Barla <[email protected]>:
> > Hi,
> >
> > my application has many Web bundles, currently I am deploying with pax
> web
> > WAR Extender.
> > Every web bundle needs javascript GZIP Filter and auth Filter etc... so
> is
> > there any way to add common filters for all web bundles
> without specifying
> > in web.xml ? (kind of AOP)
> > currently I am planning to do with white board pattern, to do this I
> need to
> > add Filter programmatically.
> > I did this with Web Application Bundles (If bundle is web bundle then add
> > filter service using service listener ), any idea how to do this for
> wars?
> > or any other suggestions ?
> >
> >
> > --
> > Thanks
> > Dattu
> >
> > _______________________________________________
> > general mailing list
> > [email protected]
> > http://lists.ops4j.org/mailman/listinfo/general
> >
>
>
>
> --
>
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
> Committer & Project Lead
> OPS4J Pax for Vaadin
> <http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project
> Lead
> blog <http://notizblog.nierbeck.de/>
>
> _______________________________________________
> general mailing list
> [email protected]
> http://lists.ops4j.org/mailman/listinfo/general
>
--
Thanks
Dattu
_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general