Discussion:
Provider registration in javax.ws.rs.core.Application
fulve
2017-11-09 15:33:14 UTC
Permalink
Hi everyone,

I have a WAR file that contains two javax.ws.rs.core.Application.
I want each sub app to have there own providers.

To acheive this I have disabled providers scanning :
<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
<pojo-deployment class-name="jaxrs-application">
<properties>

cxf.jaxrs.skip-provider-scanning = true
</properties>
</pojo-deployment>
</openejb-jar>


I can't register my providers, how am I supposed to do ?

I've tried overloading getClasses without success:

@ApplicationPath("/api")
public class MyApp extends Application{


/*@Override
public Set getSingletons() {
Set set = new LinkedHashSet();
set.add((Object) new MetiJaxbJsonProvider());
return set;
}*/

/*@Override
public Map<String, Object> getProperties() {
Map<String, Object> p = new HashMap<String, Object>();
p.put("cxf.jaxrs.providers", "jsonp");//Defines in resources.xml
return p;
}*/



@Override
public Set<Class&lt;?>> getClasses(){
Set<Class&lt;?>> classes = new LinkedHashSet<>(Class<?>);

classes.add(Class.forName("com.meti.dfex.auth.rs.mobi.poc.CnxServiceRest"));
classes.add(Class.forName(JSON_PROVIDER));
classes.add(Class.forName(OJECTMAPPER_PROVIDER));
classes.add(Class.forName(EXCEPTIONMAPPER_PROVIDER));

return classes ;
}
}


Am i missing something ?

Best Regards





--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Romain Manni-Bucau
2017-11-09 19:26:47 UTC
Permalink
Hello

Yes or you can list them in the same file. Dont have the property name
right now but google should find it easily otherwise i can share it
tomorrow.
Post by fulve
Hi everyone,
I have a WAR file that contains two javax.ws.rs.core.Application.
I want each sub app to have there own providers.
<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
<pojo-deployment class-name="jaxrs-application">
<properties>
cxf.jaxrs.skip-provider-scanning = true
</properties>
</pojo-deployment>
</openejb-jar>
I can't register my providers, how am I supposed to do ?
@ApplicationPath("/api")
public class MyApp extends Application{
public Set getSingletons() {
Set set = new LinkedHashSet();
set.add((Object) new MetiJaxbJsonProvider());
return set;
}*/
public Map<String, Object> getProperties() {
Map<String, Object> p = new HashMap<String, Object>();
p.put("cxf.jaxrs.providers", "jsonp");//Defines in resources.xml
return p;
}*/
@Override
public Set<Class&lt;?>> getClasses(){
Set<Class&lt;?>> classes = new LinkedHashSet<>(Class<?>);
classes.add(Class.forName("com.meti.dfex.auth.rs.mobi.
poc.CnxServiceRest"));
classes.add(Class.forName(JSON_PROVIDER));
classes.add(Class.forName(OJECTMAPPER_PROVIDER));
classes.add(Class.forName(EXCEPTIONMAPPER_PROVIDER));
return classes ;
}
}
Am i missing something ?
Best Regards
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-
f979441.html
fulve
2017-11-10 08:35:41 UTC
Permalink
Hello Romain

It works if I define the providers in the openejjb-jar.xml like this :

<pojo-deployment class-name="jaxrs-application">
<properties>
cxf.jaxrs.skip-provider-scanning = true
</properties>
</pojo-deployment>

<pojo-deployment class-name="com.meti.mlib.common.rs.WSMobiApplication">
<properties>
cxf.jaxrs.providers =
com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider, ....
cxf.jaxrs.skip-provider-scanning = true
</properties>
</pojo-deployment>
<pojo-deployment class-name="com.meti.mlib.common.rs.DefaultApplication">
<properties>
cxf.jaxrs.providers =
org.apache.johnzon.jaxrs.ConfigurableJohnzonProvider, ...
cxf.jaxrs.skip-provider-scanning = true
</properties>
</pojo-deployment>

Is there a way to do this programmaticly ?




--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Romain Manni-Bucau
2017-11-10 08:45:50 UTC
Permalink
Using standard API no but using openejb server events you can observe
https://github.com/apache/tomee/blob/master/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/event/ExtensionProviderRegistration.java

Romain Manni-Bucau
@rmannibucau | Blog | Old Blog | Github | LinkedIn
Post by fulve
Hello Romain
<pojo-deployment class-name="jaxrs-application">
<properties>
cxf.jaxrs.skip-provider-scanning = true
</properties>
</pojo-deployment>
<pojo-deployment class-name="com.meti.mlib.common.rs.WSMobiApplication">
<properties>
cxf.jaxrs.providers =
com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider, ....
cxf.jaxrs.skip-provider-scanning = true
</properties>
</pojo-deployment>
<pojo-deployment class-name="com.meti.mlib.common.rs.DefaultApplication">
<properties>
cxf.jaxrs.providers =
org.apache.johnzon.jaxrs.ConfigurableJohnzonProvider, ...
cxf.jaxrs.skip-provider-scanning = true
</properties>
</pojo-deployment>
Is there a way to do this programmaticly ?
--
Sent from: http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
Loading...