简体   繁体   English

在cq5中扩展ProfileImages servlet

[英]Extending ProfileImages servlet in cq5

I am trying to extend ProfileImages servlet from /libs/foundation/src/impl/src/main/java/com/day/cq/wcm/foundation/pro file/impl/ProfileImages.java 我正在尝试从/ libs / foundation / src / impl / src / main / java / com / day / cq / wcm / foundation / pro文件/impl/ProfileImages.java扩展ProfileImages servlet

and bundling as an OSGI service. 并捆绑为OSGI服务。

I have the following annotations 我有以下注释

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

I see my service in bundles and Services in OSGI console. 我在OSGI控制台的捆绑包和服务中看到了我的服务。 However it is not doing as ProfileImages servlet used to do 但是,它不像以前的ProfileImages servlet那样做

ProfileImages create the thumbnail if we invoke the following URL 如果我们调用以下URL,ProfileImages将创建缩略图

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

If my servlet is invoke, I should get the same response 如果我的servlet被调用,我应该得到相同的响应

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

However I am getting is 404 which is from the DefaultGetServlet 但是我得到的是来自DefaultGetServlet的404

It seems that Sling servet is not able to resolve my servlet 似乎Sling servet无法解析我的servlet

One thing I need to know is how to get my service updated in 我需要知道的一件事是如何更新我的服务

Apache Sling Servlet Resolverorg.apache.sling.servlets.resolver Apache Sling Servlet Resolverorg.apache.sling.servlets.resolver

My servlet is doing the same thing as the following service in sling servlet resolver 我的servlet与sling servlet解析器中的以下服务相同

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

Description: ServletResourceProvider for Servlets at [/libs/foundation/components/primary/nt/file/prof/thumbnail.gif.servl et, /libs/foundation/components/primary/nt/file/prof.gif.servlet, /libs/foundation/components/primary/nt/file/prof/thumbnail.res.servle t, /libs/foundation/components/primary/nt/file/prof.jpg.servlet, /libs/foundation/components/primary/nt/file/prof.png.servlet, /libs/foundation/components/primary/nt/file/prof/thumbnail.png.servle t, /libs/foundation/components/primary/nt/file/prof/thumbnail.jpg.servle t, /libs/foundation/components/primary/nt/file/prof.res.servlet] 说明:位于[/libs/foundation/components/primary/nt/file/prof/thumbnail.gif.servl等,/ libs / foundation / components / primary / nt / file / prof.gif.servlet,/ libs的Servlet的ServletResourceProvider /foundation/components/primary/nt/file/prof/thumbnail.res.servle t,/ libs / foundation / components / primary / nt / file / prof.jpg.servlet,/ libs / foundation / components / primary / nt /文件/prof.png.servlet、/libs/foundation/components/primary/nt/file/prof/thumbnail.png.servle、/libs/foundation/components/primary/nt/file/prof/thumbnail.jpg.servle t,/ libs / foundation / components / primary / nt / file / prof.res.servlet]

My service should be listed in sling resolver with id and something like 我的服务应在吊索解析器中列出,并带有ID和类似内容

...../adjust.small.jpg.servlet, ..../adjust.res.servlet I am using CRXDE web version for development Is there any configurations I have to do to get my service in over resource resolver? ..... / adjust.small.jpg.servlet,.... / adjust.res.servlet我正在使用CRXDE Web版本进行开发是否需要做任何配置才能通过资源解析器获取服务?

Your servlet can not be resolved because it is not registered with the Declarative Services Runtime. 无法解析您的servlet,因为它未在Declarative Services运行时中注册。 The @Component and @SlingServlet annotations are not evaluated at runtime, they are part of the Apache Felix SCR Plugin Project which provides a maven plugin and ant task to create "OSGi Declarative Services" descriptors. @Component和@SlingServlet注释不会在运行时进行评估,它们是Apache Felix SCR插件项目的一部分,该项目提供了maven插件和ant任务来创建“ OSGi声明性服务”描述符。 http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin.html http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin.html

For registering your Servlet as an OSGi Service an OSGI-INF/serviceComponents.xml file is required. 要将Servlet注册为OSGi服务,需要OSGI-INF / serviceComponents.xml文件。

So I'm afraid you won't get around using a build lifecycle tool to build your OSGi bundle before uploading to CQ5, if you are planning to use the scr annotations. 因此,如果您打算使用scr批注,那么恐怕您在上载到CQ5之前不会使用构建生命周期工具来构建OSGi软件包。 Else you have to create your service component file manually. 否则,您必须手动创建服务组件文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM