configure server.xml Tomcat for async web services



I don't know if i can configure server.xml for async web services Jersey. For async i use Guava lib, and i define one services class with:



public GeneralServices() {

service = MoreExecutors.listeningDecorator(Executors
.newFixedThreadPool(10));

}

//methods


Now how i can tell Tomcat to instance this class when start? is possible?


If i have Grizzly is more easy because i have:



public static HttpServer startServer() {

final GeneralServices dao = new GeneralServices();
final ResourceConfig rc = new Application(dao);

return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
}

/**
* Main method.
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
final HttpServer server = startServer();
System.out.println(String.format("Jersey app started with WADL available at "
+ "%sapplication.wadl\nHit enter to stop it...", BASE_URI));
System.in.read();
server.stop();
}


but in Tomcat?


No comments:

Post a Comment