在cq5中扩展ProfileImages servlet

问题描述:

我想从/ libs/foundation/src/impl/src/main/java/com/day/cq/wcm/foundation/pro file/impl/ProfileImages.java扩展ProfileImages servlet在cq5中扩展ProfileImages servlet

并捆绑为OSGI服务。

我有以下注释

@Component(immediate=true) 
@SlingServlet(
    resourceTypes = {"nt:file"}, 
    methods = {"GET"}, 
    selectors = {"adjust","adjust.small"}, 
    extensions = {"res", "jpg", "png", "gif"} 
) 

我看到我在OSGi控制台束和服务的服务。但是它没有这样做是用来做

ProfileImages创建缩略图,如果我们调用以下URL ProfileImages的servlet

http://mydomain.com:4502/content/dam/geometrixx/portraits/scott_reynolds.jpg.prof.thumbnail.100.100.jpg

如果我的servlet调用,我应该得到相同的响应

http://mydomain.com:4502/content/dam/geometrixx/portraits/scott_reynolds.jpg.adjust.small.100.100.jpg

但是我得到的是404是从DefaultGetServlet

看来,吊带SERVET是不是能解决我的servlet

有一件事我需要知道的是如何让我的服务

Apache的吊索的Servlet Resolverorg.apache.sling.servlets.resolver

更新

我的servlet正在做同样的事情,以下服务吊索的servlet解析器

服务ID 843种类型: org.apache.sling.api.resource.ResourceProvider

描述:在 [/libs/foundation/components/primary/nt/file/prof/thumbnail.gif.servl 等,/libs/foundation/components/primary/nt/file/prof.gif ServletResourceProvider为Servlet的.servlet, /libs/foundation/components/primary/nt/file/prof/thumbnail.res.servle t,/libs/foundation/components/primary/nt/file/prof.jpg.servlet, /libs /基础/组件/ primary/nt/file/prof.png.servlet, /lib/foundation/components/primary/nt/file/prof/thumbnail.jpg.servle t,/libs/foundation/components/primary/nt/file/prof.res.servlet]

我的服务应与身份证件和吊带的东西像解析器

...../adjust.small.jpg.servlet上市,.../adjust.res.servlet 我使用CRXDE用于开发的web版本 是否有任何配置需要我通过资源解析器获取我的服务?

+0

我没有使用maven这个,是否有必要有maven来解决问题 – user1130906

+0

不,maven是没有必要的。 – Woodifer

您的servlet无法解析,因为它没有在Declarative Services Runtime中注册。 @Component和@SlingServlet注释在运行时不进行评估,它们是Apache Felix SCR插件项目的一部分,它提供了一个maven插件和ant任务来创建“OSGi声明性服务”描述符。 http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin.html

要将您的Servlet注册为OSGi服务,需要OSGI-INF/serviceComponents.xml文件。

因此,如果您打算使用scr注释,那么恐怕您不会在使用构建生命周期工具来构建您的OSGi包之前上传到CQ5。 否则您必须手动创建服务组件文件。