Hi,
Consider the following activator code:

package rest.sample.greetings;
>
> import java.util.Dictionary;
> import java.util.Hashtable;
>
> import org.osgi.framework.BundleActivator;
> import org.osgi.framework.BundleContext;
> import org.osgi.framework.ServiceRegistration;
>
> import rest.sample.greetings.impl.ByeServiceImpl;
> import rest.sample.greetings.impl.HelloServiceImpl;
>
>
>
> public class Activator implements BundleActivator {
>
>     private ServiceRegistration registration;
>     private ServiceRegistration registration2;
>
>     public void start(BundleContext context) throws Exception {
>         System.out.println("START GREETINGS BUNDLE");
>         Dictionary<String, Object> props1 = getProperties();
>         registration  =
> context.registerService(HelloServiceImpl.class.getName(), new
> HelloServiceImpl(context), props1);
>         Dictionary<String, Object> props2 = getProperties();
>         registration2 =
> context.registerService(ByeServiceImpl.class.getName(), new
> ByeServiceImpl(context), props2);
>
>
>
>     }
>
>
>     private Dictionary<String, Object> getProperties() {
>         Dictionary<String, Object> props = new Hashtable<String, Object>();
>         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", "http://localhost:8181/";);
>         return props;
>     }
>
>
>
>     public void stop(BundleContext context) throws Exception {
>         registration.unregister();
>         registration2.unregister();
>
>     }
> }
>




package rest.sample.greetings.api;
>
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.MediaType;
>
> @Path("/bye")
> public interface ByeService {
>
>     @GET
>     @Path("/sayBye")
>     @Produces(MediaType.TEXT_PLAIN)
>     public String sayBye();
>
> }
>
>

package rest.sample.greetings.api;
>
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.MediaType;
>
> @Path("/hello")
> public interface HelloService {
>
>     @GET
>     @Path("/sayHello")
>     @Produces(MediaType.TEXT_PLAIN)
>     public String sayHello();
>
> }
>




When the two services are registered, seems that the last one overwrite se
first one.

if I try to invoke the services, with the following respective URI:

http://localhost:8181/hello/sayHello


http://localhost:8181/bye/sayBye


only one works, and for the other one is reported the following error:

[qtp22790308-54 - /hello/sayHello] WARN
> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor - No root resource
> matching request path /hello/sayHello has been found, Relative Path:
> /hello/sayHello.
>

i'm using the multibundle-ditribution 1.5

how can I invoke both services?

thanks for your attention.

Reply via email to