Java 如何启动具有最小依赖关系的Mule 3嵌入式系统?

Java 如何启动具有最小依赖关系的Mule 3嵌入式系统?,java,mule,Java,Mule,我希望在启动mule 3时,尽量减少外部依赖(无spring等)。如有任何提示,我们将不胜感激。多谢各位 以下示例使用入站VM端点和字符串追加器转换器创建流。我相信这会让你开始 MuleContext context = new DefaultMuleContextFactory().createMuleContext(); MuleRegistry registry = context.getRegistry(); EndpointBuilder testEndpoi

我希望在启动mule 3时,尽量减少外部依赖(无spring等)。如有任何提示,我们将不胜感激。多谢各位

以下示例使用入站VM端点和字符串追加器转换器创建流。我相信这会让你开始

    MuleContext context = new DefaultMuleContextFactory().createMuleContext();
    MuleRegistry registry = context.getRegistry();

    EndpointBuilder testEndpointBuilder = new EndpointURIEndpointBuilder("vm://testFlow.in",
        context);
    testEndpointBuilder.setExchangePattern(MessageExchangePattern.REQUEST_RESPONSE);
    registry.registerEndpointBuilder("testFlow.in", testEndpointBuilder);

    InboundEndpoint vmInboundEndpoint = testEndpointBuilder.buildInboundEndpoint();
    registry.registerEndpoint(vmInboundEndpoint);

    StringAppendTransformer stringAppendTransformer = new StringAppendTransformer(" world");
    stringAppendTransformer.setMuleContext(context);

    Flow testFlow = new Flow("testFlow", context);
    testFlow.setMessageSource(vmInboundEndpoint);
    testFlow.setMessageProcessors(Arrays.asList((MessageProcessor) stringAppendTransformer));
    registry.registerFlowConstruct(testFlow);

    context.start();

    MuleClient muleClient = new MuleClient(context);
    MuleMessage response = muleClient.send("vm://testFlow.in", "hello", null);
    Validate.isTrue(response.getPayloadAsString().equals("hello world"));

    muleClient.dispose();
    context.stop();

你好,大卫,非常感谢你。我想我们需要一个注册表;在context.getRegistry()之后-mule会抱怨缺少生命阶段,否则。效果很好!需要的依赖项是:commons beanutils、commons collections、commons io、commons lang、commons logging、commons pool、dom4j、geronimo-j2ee-connector、jaxen、jug,这与mule embedded相当于5.6M——这还不错。它现在也适用于我——我一定是在某个时候缺少依赖项导致了它。再次感谢。