如何将 Grizzly 嵌入式服务器用于 Mule 和 Jersey

发布于 2024-08-06 16:29:47 字数 589 浏览 4 评论 0原文

我目前正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

零度° 2024-08-13 16:29:47

虽然这并不理想,因为 mule 实例默认无法使用 Grizzly,但我可以通过单独启动 mule 来实现此功能:

    DefaultMuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
    SpringXmlConfigurationBuilder configBuilder = new SpringXmlConfigurationBuilder("mule-config.xml");
    muleContext = muleContextFactory.createMuleContext(configBuilder);
    muleContext.start();

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:

    DefaultMuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
    SpringXmlConfigurationBuilder configBuilder = new SpringXmlConfigurationBuilder("mule-config.xml");
    muleContext = muleContextFactory.createMuleContext(configBuilder);
    muleContext.start();
瞳孔里扚悲伤 2024-08-13 16:29:47

我不确定你想要实现什么,但你可以使用 Mule Jersey 连接器。 Mule 将处理 HTTP 请求(而不是 Grizzly),并且您将保持 Jersey 处理不变。

<service name="helloWorldResource">
         <inbound>
            <inbound-endpoint address="jersey:http://localhost:63081/" synchronous="true"/>
         </inbound>
<component class="org.mule.transport.jersey.HelloWorldResource"/>
</service>

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.

<service name="helloWorldResource">
         <inbound>
            <inbound-endpoint address="jersey:http://localhost:63081/" synchronous="true"/>
         </inbound>
<component class="org.mule.transport.jersey.HelloWorldResource"/>
</service>

http://www.mulesoft.org/display/JERSEY/User's+Guide

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文