Can Pax Web Whiteboard ResourceMapping have path pointing outside the bundle?

StackOverflow https://stackoverflow.com/questions/10800518

  •  11-06-2021
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top