Question

I've tried to register the following ResourceMapping as an OSGi service:

package ru.focusmedia.odp.server.poim.http;

import org.ops4j.pax.web.extender.whiteboard.ResourceMapping;

import ru.focusmedia.odp.server.poim.api.PoimConfig;

import aQute.bnd.annotation.component.Component;

@Component(immediate = true)
public class PoimResourceMapping implements ResourceMapping {
    private String httpContextId;
    private String alias = "...";
    private String someAbsolutePath = "...";

    @Override
    public String getHttpContextId() {
        return httpContextId;
    }

    @Override
    public String getAlias() {
        return "/resources";
    }

    @Override
    public String getPath() {
        return someAbsolutePath;
    }

}

but don't see the result in browser under http://127.0.0.1:8282/resources/aFileUnderMyPath. I can see that Pax Web is accessing my mapping in the log. Is this possible or do I need to write a servlet instead?

Was it helpful?

Solution

The short answer is no.

The path is resolved relative to the bundle and therefore your absolute path will turn in some url syntax error.

Why not loading your file in a bundle and serving it from there? We dynamically load bundles with resources that we need to serve following some versioning conventions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top