Hello Thomas,

Just a remark, when you define a DM @Component annotation on a class which
implements an interface, then the interface is automatically registered in
the OSGi service registry. So, in the case of your MyManualServlet, since
you are registering it manually from the @Start method, then I think you
should add the "provides={}" attribute in the @Component annotation in
order to indicate that you don't want the annotation to auto-register your
servlet.

Something like this:

@Component(provides={})
public class MyManualServlet implements Servlet {
     @ServiceDependency
     private volatile HttpService httpService;

    @Start
    public void start(){
        try {
           httpService.registerServlet("/testtwo", this, null, null);
        } catch (ServletException e) {
          e.printStackTrace();
        } catch (NamespaceException e) {
          e.printStackTrace();
        }
    }
...

Now, I did not yet played with the latest http servlet from felix-trunk.
So, can you please indicate me the exact list of bundles you are using at
runtime ?  I will then try to do what you are trying to do what you are
trying to do, and will see if I reproduce the problem.

Looking at the previous posts you did, it sounds like you are using the
http api/base/runtime bundles at runtime ?

kind regards;
/Pierre

On Fri, May 22, 2015 at 12:50 PM, Thomas Driessen <
thomas.dries...@ds-lab.org> wrote:

> Hi again,
>
> I have two Servlets and one Filter.
> The first servlet is registrated via whiteboard like this:
>
> @Component(properties={
> @Property(name="osgi.http.whiteboard.servlet.name", value="MyServlet"),
> @Property(name="osgi.http.whiteboard.servlet.pattern", value="/testone")})
> public class MyWhiteboardServlet implements Servlet {
> ...
>
> The second Servlet is registrated directly via HttpService like this:
>
> @Component
> public class MyManualServlet implements Servlet {
>  @ServiceDependency
> private volatile HttpService httpService;
>  @Start
> public void start(){
> try {
> httpService.registerServlet("/testtwo", this, null, null);
> } catch (ServletException e) {
> e.printStackTrace();
> } catch (NamespaceException e) {
> e.printStackTrace();
> }
> }
> ...
>
> Then I added a Filter also via whiteboard registration like this:
>
> @Component(properties={
> @Property(name="osgi.http.whiteboard.filter.name", value="MyFilter"),
> @Property(name="osgi.http.whiteboard.filter.pattern", value="/*")})
> public class MyFilter implements Filter {
> ...
>
> Everythings starts up fine, but when it comes to requests, only the
> "MyWhiteboardServlet" is filtered correctly. When I try to access the
> "MyManualServlet" nothing happens and the Filter is not invoked.
>
> Is this an intended behaviour?
>
> I know I'm mixing up different registration styles, but I assumed, that
> internally both are registered the same way?
> In my current project I'm forced to support both styles, as some third
> party libraries I use, are using the direct registration, while others use
> the whiteboard registration.
>
> Any advice on this problem is appreciated :)
>
> Best regards,
> Thomas
> --
> M.Sc. Thomas Driessen
> Software Methodologies for Distributed Systems
> Institute of Computer Science
> University of Augsburg
> Universitätsstr. 6a
> 86135 Augsburg, Germany
>
> Tel:    +49 821 598-2486
> email: thomas.dries...@informatik.uni-augsburg.de
>

Reply via email to