I have recently wrote a very simple Restful service deployed to JBoss AS 7.
I have a JAX-RS interface defiled as (using scala):
@Provider
@Path("/customers")
trait ICustomerService {
@GET
@Path("/{id}")
@Produces(Array("application/xml"))
def getCustomer(@PathParam("id") id: Int): StreamingOutput
}
And a class implements it (using scala):
class ServiceFacade extends ICustomerService {
val ctx = new ClassPathXmlApplicationContext("orderservice.xml")
val customerService = ctx.getBean("customerService").asInstanceOf[CustomerService]
def getCustomer(id: Int): StreamingOutput = {
customerService.getCustomer(id)
}
}
Here the problem comes. Everytime I issue a request from a client browser, a new ServiceFacade is created by Jboss, thus the Spring xml file is parsed once.
Is there anyway I can create the ServiceFacade myself in a spring config and simply let JBoss uses it rather than create for every single clieng request?
Many thanks.