> -----Original Message-----
> From: Sergey Beryozkin [mailto:[email protected]]
> Sent: Thursday, August 27, 2009 2:25 AM
> To: [email protected]
> Subject: Re: Need more info on configuring JAX-RS without Spring
>
> By the way, one question I wanted to ask : why is it that we see
> @XmlRootElement annotation on Catalog.Items class being available
> at runtime but do not see JAXRS annotations being there during the
init
> time ? Personally I do like this no-annotations featue but
> I'm just curious why JAXRS annotations can not be seen. Can it be that
> annotations are not visible during the spring injection time
> but are available later on at runtime ? Can you may be , just for
test,
> check the @Path annotation on the Catalog.class in the body
> of getItems() method, as well as @XmlRootElement on Items ?
Following this is my current "Catalog.java" source file, which contains
the two relevant classes. It now checks the "Catalog" class and method
annotations when the Catalog class is constructed, and in the
"getItem()" method. In the "Item" constructor, it checks the "Item"
annotations, and also rechecks the "Catalog" class and method
annotations.
What I found was that nothing ever found any annotations in the Catalog
class, but the "Item" constructor found the annotation in "Item". I'm
not sure what that means, but my next test is to move "Item" to a
separate source file. It shouldn't make any difference, but I'm going
to try it anyway.
--------------------------------
package com.att.ecom.catalog;
import java.lang.annotation.Annotation;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.xml.bind.annotation.XmlRootElement;
@Path("/catalog/")
@Produces("application/xml")
public class Catalog {
private int stuff;
public int getStuff() {return stuff;}
public void setStuff(int stuff) {this.stuff = stuff;}
// @GET
// @Path("/items/")
// public List<Item> getItems() {
// ArrayList<Item> result = new ArrayList<Item>();
// result.add(new Item());
// return (result);
// }
public Catalog() {
checkAnnotations();
}
private void checkAnnotations() {
try {
Annotation[] annotations = null;
annotations = getClass().getAnnotations();
System.out.println("class annotations[" +
annotations +
"] length[" +
annotations.length + "]");
annotations =
getClass().getMethod("getItem", new
Class[]{java.lang.String.class}).
getAnnotations();
System.out.println("method annotations[" +
annotations +
"] length[" +
annotations.length + "]");
} catch (SecurityException ex) {
ex.printStackTrace();
} catch (NoSuchMethodException ex) {
ex.printStackTrace();
}
}
@GET
@Path("/item/{id}")
public Item getItem(@PathParam("id") String id) {
checkAnnotations();
Item item = new Item();
item.setId(id);
item.setTitle("abc");
item.setDescription("def");
return item;
}
@XmlRootElement(name = "Item")
public static class Item {
private String id;
private String title;
private String description;
public Item() {
checkAnnotations();
}
private void checkAnnotations() {
try {
Annotation[] annotations = null;
annotations =
getClass().getAnnotations();
System.out.println("class annotations["
+ annotations +
"] length[" +
annotations.length + "]");
annotations =
Catalog.class.getAnnotations();
System.out.println("class annotations["
+ annotations +
"] length[" +
annotations.length + "]");
annotations =
Catalog.class.getMethod("getItem", new Class[]{java.lang.String.class}).
getAnnotations();
System.out.println("method annotations["
+ annotations +
"]
length[" + annotations.length + "]");
} catch (SecurityException ex) {
ex.printStackTrace();
} catch (NoSuchMethodException ex) {
ex.printStackTrace();
}
}
public String getTitle() { return title; }
public String getId() { return id; }
public String getDescription() { return description; }
public void setTitle(String title) { this.title = title;
}
public void setId(String id) { this.id = id; }
public void setDescription(String description) {
this.description = description; }
}
}
--------------------
>
> cheers, Sergey
>
> ----- Original Message -----
> From: "KARR, DAVID (ATTCINW)" <[email protected]>
> To: <[email protected]>
> Sent: Wednesday, August 26, 2009 6:18 PM
> Subject: RE: Need more info on configuring JAX-RS without Spring
>
>
> > -----Original Message-----
> > From: Sergey Beryozkin [mailto:[email protected]]
> > Sent: Wednesday, August 26, 2009 10:11 AM
> > To: Sergey Beryozkin; [email protected]
> > Subject: Re: Need more info on configuring JAX-RS without Spring
> >
> > In meantime, here is a system test that shows how it can be dome
> > without Spring :
> >
> >
>
http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/ap
> > ache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
>
> Ok, that's without Spring, but it's also using a standalone listener.
> How would you use the CXFServlet (or a variation of that for
NonSpring,
> I believe) in WebLogic, but configuring it without Spring?
>
> > ----- Original Message -----
> > From: "Sergey Beryozkin" <[email protected]>
> > To: <[email protected]>
> > Sent: Wednesday, August 26, 2009 6:01 PM
> > Subject: Re: Need more info on configuring JAX-RS without Spring
> >
> >
> > > No problems at all - I do have to document it better - I'll do it
> (as
> > well as DOSGO docs updates I promised to do today) the first
> > > thing tomorrow morning (with a clear head :-)).
> > > Hope the info I provided in the prev email will help a bit - I
> might
> > also check the emails later today...
> > >
> > > Sergey
> > >
> > > ----- Original Message -----
> > > From: "KARR, DAVID (ATTCINW)" <[email protected]>
> > > To: <[email protected]>
> > > Sent: Wednesday, August 26, 2009 5:37 PM
> > > Subject: Need more info on configuring JAX-RS without Spring
> > >
> > >
> > > Much as I hate to ask this, I need to get more info about how to
> > > configure JAX-RS services WITHOUT Spring, and without annotations.
> > >
> > > The manual has some high-level information about this, but not at
> the
> > > level of the model or resources. For instance, it talks about
> using
> > the
> > > JAXRSServerFactoryBean to set some high-level info, but nothing
> below
> > > the resource class itself, and nothing specifying paths.