如何将 Grizzly 嵌入式服务器用于 Mule 和 Jersey
我目前正在使用 JerseyTest 和 Grizzly 嵌入式服务器来测试一些代码。我做了一些非常简单的配置,将其指向正确的资源:
Map<String, String> initParams = new HashMap<String, String>();
initParams.put("com.sun.jersey.config.property.packages", "com.sample.service");
ApplicationDescriptor appDescriptor = new ApplicationDescriptor();
appDescriptor.setServletInitParams(initParams);
super.setupTestEnvironment(appDescriptor);
这工作正常,并且 Jersey 组件可用并且按预期工作。
我现在正在尝试向其中一些 Jersey 调用添加一些 Mule 功能,但是 Grizzly 没有正确初始化/配置 Mule。有人运行过这种设置吗?我需要对 JerseyTest/GrizzlyWebServer 进行哪些额外配置才能使其正确初始化 Mule?
I'm currently using JerseyTest w/ Grizzly embedded server to test some code. I do some very simple configuration to point it to the proper resources:
Map<String, String> initParams = new HashMap<String, String>();
initParams.put("com.sun.jersey.config.property.packages", "com.sample.service");
ApplicationDescriptor appDescriptor = new ApplicationDescriptor();
appDescriptor.setServletInitParams(initParams);
super.setupTestEnvironment(appDescriptor);
This works fine and the Jersey components are available and working as expected.
I'm now trying to add some Mule functionality to some of these Jersey calls, but Mule is not being properly initialized/configured by Grizzly. Has anyone gotten this kind of setup running? What additional configuration do I need to do with JerseyTest/GrizzlyWebServer to get it to initialize Mule properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然这并不理想,因为 mule 实例默认无法使用 Grizzly,但我可以通过单独启动 mule 来实现此功能:
While it is not ideal because the mule instance is not able to use Grizzly by default, I was able to get this working by staring up mule separately with:
我不确定你想要实现什么,但你可以使用 Mule Jersey 连接器。 Mule 将处理 HTTP 请求(而不是 Grizzly),并且您将保持 Jersey 处理不变。
http://www.mulesoft.org/display/JERSEY/User's+指导
I'm not sure what you're trying to achieve but you can use the Mule Jersey connector. Mule will handle the HTTP requests (instead of Grizzly) and you'll keep the Jersey processing as is.
http://www.mulesoft.org/display/JERSEY/User's+Guide