stanbol-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reto Bachmann-Gmür <r...@apache.org>
Subject Registering individual jax-rs resources
Date Thu, 11 Aug 2011 13:00:34 GMT
Hello

As you might know the registration of JAX-RS resources is different in
Stanbol and in Clerezza, this is the main reason one cannot run the
two UIs simultaneously. It would however be handy to have some of the
clerezza tools (like graph-management and backup) available in stanbol
as well.

In clerezza a jax-rs resource is simply a service, in stanbol we have
WebFragment-services that provide jax-rs resources as well as some
non-jax-rs that make up a web-fragment. I've written a component that
picks up clerezza style root-resources and wrapps them for Stanbol.

The wrapper looks like this:

/**
 * A WebFragment holding one Jax-rs resource
 */
class ResourceHolder(component: Object) extends WebFragment {

    def getName() = component.getClass.getName

    def getStaticResourceClassPath(): String = null

    import java.util._
    def getJaxrsResourceClasses(): Set[Class[_]] =
Collections.emptySet[Class[_]]

    def getJaxrsResourceSingletons(): Set[Object] =
Collections.singleton(component);

    def getTemplateLoader(): TemplateLoader = null;

    def getLinkResources(): List[LinkResource] =
Collections.emptyList[LinkResource]

    def getScriptResources(): List[ScriptResource] =
Collections.emptyList[ScriptResource];

    def getNavigationLinks(): List[NavigationLink] =
Collections.emptyList[NavigationLink];

    def getBundleContext(): BundleContext = null;
}

The log output indicates that for every new fragment jersey is reinitialized:

2011-08-11 14:34:40,856 [ForkJoinPool-1-worker-15] INFO
ForkJoinPool-1-worker-15
org.apache.stanbol.webfragmentcreator.WFCreator - regstering:
org.apache.clerezza.rdf.web.core.PlatformRestorer@16e4d6b
2011-08-11 14:34:40,887 [ForkJoinPool-1-worker-15] INFO
ForkJoinPool-1-worker-15
org.apache.stanbol.commons.web.base.JerseyEndpoint - Unregistering
aliases [/static/home, /static/enhancer, /static/entityhub,
/static/owl, /static/ontonet, /static/rules, /]
2011-08-11 14:34:40,888 [ForkJoinPool-1-worker-15] INFO
ForkJoinPool-1-worker-15
org.apache.stanbol.commons.web.base.JerseyEndpoint - Initializing the
Jersey subsystem
2011-08-11 14:34:40,888 [ForkJoinPool-1-worker-15] INFO
ForkJoinPool-1-worker-15
org.apache.stanbol.commons.web.base.JerseyEndpoint - Registering web
fragment 'home' into jaxrs application
2011-08-11 14:34:40,888 [ForkJoinPool-1-worker-15] INFO
ForkJoinPool-1-worker-15
org.apache.stanbol.commons.web.base.JerseyEndpoint - Registering web
fragment 'sparql' into jaxrs application
...
2011-08-11 14:34:40,905 [ForkJoinPool-1-worker-15] INFO
ForkJoinPool-1-worker-15
org.apache.stanbol.commons.web.base.JerseyEndpoint - Registering web
fragment 'org.apache.clerezza.rdf.web.core.PlatformRestorer' into
jaxrs application
2011-08-11 14:34:40,906 [ForkJoinPool-1-worker-15] INFO
ForkJoinPool-1-worker-15
com.sun.jersey.server.impl.application.WebApplicationImpl - Initiating
Jersey application, version 'Jersey: 1.7 05/20/2011 11:04 AM'

However I cannot access the my root resources wrapped by the above
wrapper. Is there any other requirement of the JerseyEndpoint to
actually register the resource with Jersey?

Cheers,
Reto

Mime
View raw message