Pax Web Whiteboard ResourceMapping可以指向包外的路径吗?

时间:2012-05-29 13:49:43

标签: pax pax-web

我尝试将以下ResourceMapping注册为OSGi服务:

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;
    }

}

但在http://127.0.0.1:8282/resources/aFileUnderMyPath下的浏览器中看不到结果。我可以看到Pax Web正在日志中访问我的映射。这是可能的还是我需要编写一个servlet呢?

1 个答案:

答案 0 :(得分:2)

简短的回答是否定的。

path相对于捆绑包已解析,因此您的绝对路径将转换为某个网址语法错误。

为什么不将文件加载到捆绑包中并从那里提供?我们根据一些版本控制约定动态地为我们需要服务的资源加载bundle。