Thanks Simon, we read and re-read the docs, and also we got the sources for
all projects. But we are really stuck :(
Well, we don't intend to use the ServletBridge, since we would like to
launch our framework, and for what we've seen, the servletbridge does this
right?
So we have our own servlet that lauches the framework, and creates an
instance of HttpServiceServlet (this one is our delegate servlet)
We also have a bundle with an activator and a HttpServiceTracker to register
a simple servlet within the HTTPService
The problem is that the tracker addingService *never* gets called. We tried
everything here, no success in any atempt.
Here's some of our code:
//our servlet that will forward to the httpserviceservlet:
@Override
public void init() throws ServletException {
ServletContextResourceProvider rp = new
ServletContextResourceProvider(getServletContext());
Logger logger = new ServletContextLogger(getServletContext());
Map<Object, Object> props = loadProperties();
this.osl = new OSL(rp,props,logger);
this.delegatee = new HttpServiceServlet();
this.delegatee.init(getServletConfig());
super.init();
}
@Override
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
Servlet delegatee = getDelegatee();
if (delegatee == null) {
((HttpServletResponse)
res).sendError(HttpServletResponse.SC_NOT_FOUND);
} else {
delegatee.service(req, res);
}
}
The OSL Class:
public class OSL implements BundleActivator {
private Felix felix;
private ReadWriteLock felixLock;
private ResourceProvider resourceProvider;
private Logger logger;
private BundleActivator httpServiceActivator;
public OSL(ResourceProvider rp, Map<Object, Object> props, Logger
logger){
this.resourceProvider = rp;
this.logger = logger;
List<BundleActivator> activators = new ArrayList<BundleActivator>();
activators.add(this);
activators.add(new BootstrapInstaller(logger,rp));
props.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, activators);
Felix tmpFelix = new Felix(props);
try {
tmpFelix.start();
this.felix = tmpFelix;
} catch (Exception e) {
e.printStackTrace();
}
}
public void start(BundleContext context) throws Exception {
this.httpServiceActivator = new Activator();
this.httpServiceActivator.start(context);
}
And our servlet activator:
public class Activator implements BundleActivator {
private ServiceTracker httpServiceTracker;
public void start(BundleContext context) throws Exception {
httpServiceTracker = new HttpServiceTracker(context);
httpServiceTracker.open();
}
public void stop(BundleContext arg0) throws Exception {
httpServiceTracker.close();
httpServiceTracker = null;
}
private class HttpServiceTracker extends ServiceTracker {
public HttpServiceTracker(BundleContext context) {
super(context, HttpService.class.getName(), null);
}
public Object addingService(ServiceReference reference) {
HttpService httpService = (HttpService)
context.getService(reference);
try {
httpService.registerServlet("/dummy", new DummyServlet(),
null, null); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
}
return httpService;
}
public void removedService(ServiceReference reference, Object
service) {
HttpService httpService = (HttpService) service;
httpService.unregister("/dummy"); //$NON-NLS-1$
super.removedService(reference, service);
}
}
}
Since the tracker never gets called, we never register the servlet, and
hence the ProxyServlet has no registrations inside, and respond with an
error.
What else can we be doing wrong?
Regards
On Thu, Jan 22, 2009 at 5:13 PM, Simon Kaegi <[email protected]> wrote:
> Although these days I'm spending more of my time on provisioning the
> servletbridge is indeed still developed as it's used/supported
> commercially.
>
> Here's a couple of links to get you started...
> http://www.eclipse.org/equinox/server/http_in_container.php
> The build script demonstrated is a toy.
>
> You might look at the WAR file on that page to get an idea of the expected
> structure and minimal set of bundles to assemble your own from the various
> released pieces.
>
> Most of the equinox server-side components you need come as part of the sdk
> except the "2" servletbridge bundles.
> You can of course directly download everything you need from
> http://download.eclipse.org/equinox/
> and
> http://download.eclipse.org/tools/orbit/downloads/
>
> HTH
> -Simon
>
> ----- Original Message -----
> From: "Niclas Hedhman" <[email protected]>
> To: "General OPS4J" <[email protected]>
> Sent: Thursday, January 22, 2009 7:53 AM
> Subject: Re: Help with HTTP Service
>
>
> > On Thu, Jan 22, 2009 at 1:49 PM, Vinicius Carvalho
> > <[email protected]> wrote:
> >> Thanks, that's servletbridge I need indeed. Do you guys provide an
> >> implementation?
> >
> > Nope. I have thought about it a couple of times, but...
> >
> > ServletBridge is a project in its own right, originally developed
> > (maybe still) by Simon Kaegi.
> >
> >
> > Cheers
> > Niclas
> > --
> > http://www.qi4j.org - New Energy for Java
> >
> > _______________________________________________
> > general mailing list
> > [email protected]
> > http://lists.ops4j.org/mailman/listinfo/general
>
>
> _______________________________________________
> general mailing list
> [email protected]
> http://lists.ops4j.org/mailman/listinfo/general
>
_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general