我有一个小问题:是否有机会在一个项目中将球衣和彗星框架结合在一起?有人有例子吗?
实际项目: 我使用architype在jclipse中创建了一个maven项目:jersey-quickstart-grizzly2。 Jersey和Grizzly2的工作方式与泽西示例中的helloWorld应用程序相似(启用了SSL)。请参阅下面的代码。
现在我想知道如何添加Comet Servlet,Comet Context等?
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();
}
提前感谢您的回复!
答案 0 :(得分:0)
https://github.com/BangBoy/Grizzly-Jersey-Spring-Spring-Security
此网址使用spring ..还显示了如何整合Jersey&彗星加入Grizzly服务器。