hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
190 stars 98 forks source link

how to pass parameters like @Context HttpHeaders head #107

Closed wandongwd closed 8 years ago

wandongwd commented 8 years ago

REST interface(IOpenstackHostImageRest.java):

@Path("/roc/vim/api")
public interface IOpenstackHostImageRest {
    @Path("/images/detail")
    @GET
        @Produces(MediaType.APPLICATION_JSON)
    public String getOpenstackImageList(@Context HttpHeaders head) throws Exception;
}

connector in a karaf instance (OpenstackServiceConsumer.java):
public static List<HostImage> getOpenstackHostImageList(HttpHeaders head)
    {   
        ClientConfig config = new ClientConfig(new OpenstackServiceHostImageProvider());
        IOpenstackHostImageRest imageRest = ConsumerFactory
                .createConsumer(BASEURL, config, IOpenstackHostImageRest.class);

        List<HostImage> imageList = null;
        try {
            String imageStr = imageRest.getOpenstackImageList(head);
            imageList = OpenstackServiceUtil.getImageEntityByJson(imageStr);            
        } catch (Exception e) {
            LOG.error("getHostImage error", e);
            e.printStackTrace();
        }       
        return imageList;
    }

problem: the server can't get the parameter @Context HttpHeaders head

hstaudacher commented 8 years ago

hmm, this should work. Can you put your annotations on the implementation and run a test please?

hstaudacher commented 8 years ago

No response so I will close the issue. Please feel free to reopen.