It is exactly the same way greeter_rest demo is done, can you please
check the way interface and impl bundle export and import packages ?

Cheers, Sergey

On Sun, Jun 19, 2011 at 10:48 AM, mah <[email protected]> wrote:
>
> Sergey Beryozkin-5 wrote:
>>
>> I think it's a matter of explicitly importing javax.ws.rs package with
>> ImportPackage for the case where annotations are expected to be
>> recognized
>>
>
> javax.ws.rs package is imported into bundle, where annotations are expected
> to be processed.
>
> The setup consists of two bundles. One defines the interface and supposed to
> expose REST webservice using annotations. Here is the interface itself
> (other classes used are plain Java classes):
>
> package org.apache.cxf.dosgi.samples.greeter.rest;
>
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.PathParam;
>
> @Path("greeter")
> public interface GreeterService {
>
>        @GET
>        @Path("greeting/{name}")
>    GreeterInfo greetMe(@PathParam("name") String name) throws
> GreeterException;
>
> }
>
>
> The generated MANIFEST.MF for interface bundle looks like this:
>
> Manifest-Version: 1.0
> Export-Package: org.apache.cxf.dosgi.samples.greeter.rest;uses:="javax
>  .ws.rs"
> Built-By: mah
> Tool: Bnd-0.0.238
> Bundle-Name: CXF Distributed OSGi Greeter Rest Demo Interface Bundle
> Created-By: Apache Maven Bundle Plugin
> Bundle-Vendor: The Apache Software Foundation
> Build-Jdk: 1.6.0_21
> Bundle-Version: 1.3.0.SNAPSHOT
> Bnd-LastModified: 1308169970661
> Bundle-ManifestVersion: 2
> Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
> Bundle-Description: This bundle contains the implementation of the CXF
>  Distributed OSGi Greeter Rest Demo Interfaces
> Bundle-DocURL: http://www.apache.org/
> Bundle-SymbolicName: cxf-dosgi-ri-samples-greeter-rest-interface
> Import-Package: javax.ws.rs;version="1.0",org.apache.cxf.dosgi.samples
>  .greeter.rest
>
>
> The interface implementation is in a separate bundle. Interface
> implementation class is plain Java class. The activator for implementation
> bundle looks like this:
>
> package org.apache.cxf.dosgi.samples.greeter.impl.rest;
>
> import java.util.Dictionary;
> import java.util.Hashtable;
>
> import org.apache.cxf.dosgi.samples.greeter.rest.GreeterService;
> import org.osgi.framework.BundleActivator;
> import org.osgi.framework.BundleContext;
> import org.osgi.framework.ServiceRegistration;
>
> public class Activator implements BundleActivator {
>    private ServiceRegistration registration;
>
>    public void start(BundleContext bc) throws Exception {
>        Dictionary props = getProperties("http://localhost:9090/greeter";);
>        registration = bc.registerService(GreeterService.class.getName(),
>                                          new GreeterServiceImpl(), props);
>    }
>
>    @SuppressWarnings("unchecked")
>        private Dictionary getProperties(String address) {
>        Dictionary props = new Hashtable();
>
>        props.put("service.exported.interfaces", "*");
>        props.put("service.exported.configs", "org.apache.cxf.rs");
>        props.put("service.exported.intents", "HTTP");
>        props.put("org.apache.cxf.rs.address", address);
>        props.put("org.apache.cxf.rs.databinding", "aegis");
>        return props;
>    }
>
>    public void stop(BundleContext bc) throws Exception {
>        registration.unregister();
>    }
> }
>
>
> And MANIFEST.MF for implentation bundle:
>
> Manifest-Version: 1.0
> Private-Package: org.apache.cxf.dosgi.samples.greeter.impl.rest
> Built-By: mah
> Tool: Bnd-0.0.238
> Bundle-Name: CXF Distributed OSGi Greeter Demo Service Rest Implementa
>  tion Bundle
> Created-By: Apache Maven Bundle Plugin
> Bundle-Vendor: The Apache Software Foundation
> DynamicImport-Package: org.apache.cxf.dosgi.dsw.qos,org.apache.cxf
> Build-Jdk: 1.6.0_21
> Bundle-Version: 1.3.0.SNAPSHOT
> Bnd-LastModified: 1308476484718
> Bundle-Activator: org.apache.cxf.dosgi.samples.greeter.impl.rest.Activ
>  ator
> Bundle-ManifestVersion: 2
> Bundle-Description: This bundle contains the implementation of the CXF
>  Distributed OSGi Greeter Rest Demo Implementation Bundle
> Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
> Bundle-DocURL: http://www.apache.org/
> Bundle-SymbolicName: cxf-dosgi-ri-samples-greeter-rest-impl
> Import-Package: org.apache.cxf.dosgi.samples.greeter.rest,org.osgi.fra
>  mework;version="1.4"
>
>
> Could that be a problem of CXF single distribution? I am using 1.3-SNAPSHOT.
>
>
> --
> View this message in context: 
> http://cxf.547215.n5.nabble.com/CXF-DOSGi-is-ignoring-JAX-RS-annotations-tp4495048p4503099.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>



-- 
Sergey Beryozkin

Application Integration Division of Talend
http://sberyozkin.blogspot.com

Reply via email to