sorry but these provided sources are really hard to read :/

do you have a link to the sources, like a github repo?

regards, Achim


2017-04-13 17:43 GMT+02:00 Peter Schyma <[email protected]>:

> Hi,
>
> I'm trying to register resources via DS in a shared servlet context but
> the registered ServletContextHelper is called with strange resource name
> parameter values.
>
> @Component(
>   service = Object.class,
>   scope = ServiceScope.PROTOTYPE,
>   property = {
>     HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX + "=/web",
>     HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN + 
> "=/resources/*",
>     DemoServletContext.CONTEXT_SERVICE_SELECTOR
>   }
> )
> public class DemoResourceService {
>   // nothing to implement
> }
>
> Code hier eingeben...
>
> @Component(
>   service = ServletContextHelper.class,
>   scope = ServiceScope.BUNDLE,
>   property = {
>     HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + 
> DemoServletContext.NAME,
>     HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH + "=/demo",
>   }
> )
> public class DemoServletContext
>   extends ServletContextHelper {
>
>   private static final Logger LOGGER = 
> LoggerFactory.getLogger(DemoServletContext.class);
>
>
>   public static final String NAME = "demo-ctx";
>
>
>   public static final String CONTEXT_SERVICE_SELECTOR = 
> HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT +
>     "=(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=" + 
> DemoServletContext.NAME + ")";
>
>
>   private ServletContextHelper delegate;
>
>
>   @Activate
>   public void activate(BundleContext bundleContext) {
>     delegate = new ServletContextHelper(bundleContext.getBundle()) {
>     };
>   }
>
>
>   @Override
>   public URL getResource(String name) {
>     LOGGER.info("requested resource: {}", name);
>     return delegate.getResource(name);
>   }
>
>
>   @Override
>   public String getMimeType(String name) {
>     return delegate.getMimeType(name);
>   }
>
>
>   @Override
>   public Set<String> getResourcePaths(String path) {
>     return delegate.getResourcePaths(path);
>   }
>
>
>   @Override
>   public String getRealPath(String path) {
>     return delegate.getRealPath(path);
>   }
>
> }
>
>
> Using this simple setup and issuing a request for "
> http://localhost:8181/demo/resources/demo.html"; prints "requested
> resource: //webdemo.html" in Karaf.
>
> I tested this with Karaf 4.1.1 and Pax Web 6.1.0-SNAPSHOT.
>
> Removing the context selector does not make the resources accessible at "
> http://localhost:8181/resources/demo.html";. I don't see any output
> related to looking up the file. Accessing /resources/ emits following in
> the log:
> 2017-04-13 17:35:22,994 | DEBUG | tp1929020177-132 | DefaultHttpContext
>             | 240 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT |
> Searching bundle [servlet-context-test [242]] for resource [web]
> 2017-04-13 17:35:22,994 | DEBUG | tp1929020177-132 | DefaultHttpContext
>             | 240 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT |
> Searching bundle [servlet-context-test [242]] for resource [web/index.html
> ]
> 2017-04-13 17:35:22,994 | DEBUG | tp1929020177-132 | DefaultHttpContext
>             | 240 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT |
> Searching bundle [servlet-context-test [242]] for resource [web/index.jsp]
>
> Am I missing something?
>
> Thanks
> Peter
>
> --
> --
> ------------------
> OPS4J - http://www.ops4j.org - [email protected]
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

-- 
-- 
------------------
OPS4J - http://www.ops4j.org - [email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to