Java Reference
In-Depth Information
<bean
<bean id= "customer" class= "com.restfully.shop.services
.CustomerResourceBean" //>
<bean
<bean id= "product" class= "com.restfully.shop.services
.ProductResourceBean" //>
<bean
<bean id= "order" class= "com.restfully.shop.services
.OrderResourceBean" //>
<bean
<bean id= "store" class= "com.restfully.shop.services
.StoreResourceBean" //>
</beans>
The rest of the Spring XML file defines all of the JAX-RS resource beans.
The Spring XML file is loaded and registered with the JAX-RS runtime by the ShoppingAp-
plication class:
src/main/java/com/restfully/shop/services/ShoppingApplication.java
@ApplicationPath ( "/services" )
public
public class
class ShoppingApplication
ShoppingApplication extends
extends Application
{
private
private Set < Class <?>> classes = new
new HashSet < Class <?>>();
public
public ShoppingApplication ()
{
classes . add ( EntityNotFoundExceptionMapper . class );
}
public
public Set < Class <?>> getClasses ()
{
return
return classes ;
}
protected
protected ApplicationContext springContext ;
@Context
protected
protected ServletContext servletContext ;
public
public Set < Object > getSingletons ()
{
try
try
{
InitialContext ctx = new
new InitialContext ();
String xmlFile =
( String ) servletContext . getInitParameter ( "spring-beans-file" );
springContext = new
new ClassPathXmlApplicationContext ( xmlFile );
}
catch
catch ( Exception ex )
Search WWH ::




Custom Search