I have a small question: Is there a chance to combine the jersey and the comet framework together in one project? Does anyone have an example?
Actual projcet: I created a maven project in eclipse with the architype: jersey-quickstart-grizzly2. Jersey und Grizzly2 works like charm with the helloWorld Application from the Jersey examples (SSL is enabled). See code below.
Now I'm wondering how I can add a Comet Servlet, Comet Context, etc.?
public class Main {
// Base URI the Grizzly HTTP server will listen on
public static final String BASE_URI = "https://localhost:8081/myapp/";
private static String KEYSTORE_PATH = "";
private static String KEYSTORE_PASS = "";
/**
* Starts Grizzly HTTP server exposing JAX-RS resources defined in this application.
* @return Grizzly HTTP server.
*/
public static HttpServer startServer() {
System.out.println(UtilProperties.getInstance().loadProperty("url"));
// create a resource config that scans for JAX-RS resources and providers
final ResourceConfig rc = new ResourceConfig().packages("com.yes.httpremoteserver.HTTPRemoteServer");
// Grizzly ssl configuration
SSLContextConfigurator sslContext = new SSLContextConfigurator();
sslContext.setKeyStoreFile(KEYSTORE_PATH); // contains server keypair
sslContext.setKeyStorePass(KEYSTORE_PASS);
// create and start a new instance of grizzly http server
// exposing the Jersey application at BASE_URI
return GrizzlyHttpServerFactory.createHttpServer(
URI.create(BASE_URI),
rc,
true,
new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false));
}
/**
* Main method.
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
KEYSTORE_PATH = args[0];
System.out.println(args[0]);
System.out.println(args[1]);
KEYSTORE_PASS = args[1];
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.shutdown();
}
Thanks in advance for your responses!
https://github.com/BangBoy/Grizzly-Jersey-Spring-Spring-Security
this URL uses spring..but also shows how to integrate Jersey & Comet into a Grizzly server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.