当前位置: 首页>>代码示例>>Java>>正文


Java ModelCamelContext类代码示例

本文整理汇总了Java中org.apache.camel.model.ModelCamelContext的典型用法代码示例。如果您正苦于以下问题:Java ModelCamelContext类的具体用法?Java ModelCamelContext怎么用?Java ModelCamelContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ModelCamelContext类属于org.apache.camel.model包,在下文中一共展示了ModelCamelContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeUrlFromCamelRoutes

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
private void removeUrlFromCamelRoutes(ApplicationOptions options) throws Exception {
    String servicePath = options.getContextPath();
    String toUri = null;

    if (options.isRequiresSSL()) {
        toUri = "https://" + InetAddress.getLocalHost().getHostAddress() + ":" + options.getHttpsPort() +
                options.getContextPath() + "?bridgeEndpoint=true&throwExceptionOnFailure=false&matchOnUriPrefix=true";
    } else {
        toUri = "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + options.getPort() +
                options.getContextPath() + "?bridgeEndpoint=true&throwExceptionOnFailure=false&matchOnUriPrefix=true";
    }
    final InputStream in = com.beyondj.gateway.support.JsonRuleBaseBuilder.newRuleBase().rule(servicePath, toUri).inputStream();

    ModelCamelContext modelCamelContext = (ModelCamelContext) camelContext;
    RouteDefinition routeDefinition = modelCamelContext.getRouteDefinition(GatewayRouter.GATEWAY_ROUTE_ID);

    if (routeDefinition == null) {
        int port = Integer.valueOf(
                config.getProperty(SYSTEM_GATEWAY_ROUTE_PORT));
        camelContext.addRoutes(new GatewayRouter(coreMetricsService, scalingDataService, port));
    }

    LoadBalancerDefinition loadBalancerDefinition = getLoadBalancerDefinition(options);
    Map<String, HttpProxyRule> rules = JsonRuleBaseReader.parseJson(loadBalancerDefinition, in);
    gatewayRulesService.removeGatewayRules(rules);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:27,代码来源:SystemGatewayActor.java

示例2: advice

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
void advice(@Observes CamelContextStartingEvent event,
            @Uri("mock:messages") MockEndpoint messages,
            ModelCamelContext context) throws Exception {
    messages.expectedMessageCount(2);
    messages.expectedBodiesReceived("Hello", "Bye");

    verifier.messages = messages;

    context.getRouteDefinition("route")
        .adviceWith(context, new AdviceWithRouteBuilder() {
            @Override
            public void configure() {
                weaveAddLast().to("mock:messages");
            }
        });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:AdviceTest.java

示例3: checkInitialized

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
@SuppressWarnings("deprecation")
protected void checkInitialized() throws Exception {
    if (initialized.compareAndSet(false, true)) {
        // Set the CamelContext ErrorHandler here
        ModelCamelContext camelContext = getContext();
        if (camelContext.getErrorHandlerBuilder() != null) {
            setErrorHandlerBuilder(camelContext.getErrorHandlerBuilder());
        }
        configure();
        // mark all route definitions as custom prepared because
        // a route builder prepares the route definitions correctly already
        for (RouteDefinition route : getRouteCollection().getRoutes()) {
            route.markPrepared();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:RouteBuilder.java

示例4: lookupErrorHandlerBuilder

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
protected static ErrorHandlerFactory lookupErrorHandlerBuilder(ModelCamelContext camelContext) {
    @SuppressWarnings("deprecation")
    ErrorHandlerFactory answer = camelContext.getErrorHandlerBuilder();
    if (answer instanceof ErrorHandlerBuilderRef) {
        ErrorHandlerBuilderRef other = (ErrorHandlerBuilderRef) answer;
        String otherRef = other.getRef();
        if (isErrorHandlerBuilderConfigured(otherRef)) {
            answer = camelContext.getRegistry().lookupByNameAndType(otherRef, ErrorHandlerBuilder.class);
            if (answer == null) {
                throw new IllegalArgumentException("ErrorHandlerBuilder with id " + otherRef + " not found in registry.");
            }
        }
    }

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:ErrorHandlerBuilderRef.java

示例5: assertValidContext

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
protected void assertValidContext(CamelContext context) {
    assertNotNull("No context found!", context);

    List<RouteDefinition> routes = ((ModelCamelContext)context).getRouteDefinitions();
    LOG.debug("Found routes: " + routes);

    assertEquals("One Route should be found", 1, routes.size());

    for (RouteDefinition route : routes) {
        List<FromDefinition> inputs = route.getInputs();
        assertEquals("Number of inputs", 1, inputs.size());
        FromDefinition fromType = inputs.get(0);
        assertEquals("from URI", "seda:test.a", fromType.getUri());

        List<?> outputs = route.getOutputs();
        assertEquals("Number of outputs", 1, outputs.size());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:XmlConfigTestSupport.java

示例6: setUpMocking

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
@Before
public void setUpMocking() throws Exception {
	ModelCamelContext modelCamelContext = (ModelCamelContext)camelContext;
	
	modelCamelContext.getRouteDefinition("mainRoute").adviceWith(modelCamelContext, new AdviceWithRouteBuilder() {
		@Override
		public void configure() throws Exception {
			mockEndpoints();
		}
	});
	
	modelCamelContext.getRouteDefinition("standardXMLRoute").adviceWith(modelCamelContext, new AdviceWithRouteBuilder() {
		@Override
		public void configure() throws Exception {
			mockEndpoints();
		}
	});
	
	modelCamelContext.getRouteDefinition("t5XMLRoute").adviceWith(modelCamelContext, new AdviceWithRouteBuilder() {
		@Override
		public void configure() throws Exception {
			mockEndpoints();
		}
	});
	camelContext.start();
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:27,代码来源:RouteTest.java

示例7: getDecimalFormatForConfiguration

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
/**
 * @return Decimal format from EDI configuration
 */
private DecimalFormat getDecimalFormatForConfiguration()
{
	final DecimalFormat decimalFormat = (DecimalFormat)NumberFormat.getInstance();

	final ModelCamelContext context = getContext();
	decimalFormat.setMaximumFractionDigits(Integer.valueOf(Util.resolvePropertyPlaceholders(context, "edi.decimalformat.maximumFractionDigits")));

	final boolean isGroupingUsed = Boolean.valueOf(Util.resolvePropertyPlaceholders(context, "edi.decimalformat.isGroupingUsed"));
	decimalFormat.setGroupingUsed(isGroupingUsed);

	final DecimalFormatSymbols decimalFormatSymbols = decimalFormat.getDecimalFormatSymbols();

	if (isGroupingUsed)
	{
		final char groupingSeparator = Util.resolvePropertyPlaceholders(context, "edi.decimalformat.symbol.groupingSeparator").charAt(0);
		decimalFormatSymbols.setGroupingSeparator(groupingSeparator);
	}

	final char decimalSeparator = Util.resolvePropertyPlaceholders(context, "edi.decimalformat.symbol.decimalSeparator").charAt(0);
	decimalFormatSymbols.setDecimalSeparator(decimalSeparator);

	decimalFormat.setDecimalFormatSymbols(decimalFormatSymbols); // though it seems redundant, it won't be set otherwise for some reason...

	return decimalFormat;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:29,代码来源:AbstractEDIRoute.java

示例8: createContextWithGivenRoute

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
protected void createContextWithGivenRoute(RouteBuilder route, int timeWork) throws Exception, InterruptedException {
    SimpleRegistry registry = new SimpleRegistry();
    ModelCamelContext context = new DefaultCamelContext(registry);
    Tracer tracer = new Tracer();
    tracer.setLogName("MyTracerLog");
    tracer.getDefaultTraceFormatter().setShowProperties(false);
    tracer.getDefaultTraceFormatter().setShowHeaders(false);
    tracer.getDefaultTraceFormatter().setShowBody(true);
    context.addInterceptStrategy(tracer);
    context.addRoutes(route);
    context.addComponent("activeMq", activeMq);

    this.camelContext = context;
    this.ct = context.createConsumerTemplate();
    this.pt = context.createProducerTemplate();

    context.start();
    context.setTracing(false);
    Thread.sleep(timeWork);
    context.stop();
}
 
开发者ID:przodownikR1,项目名称:cxf_over_jms_kata,代码行数:22,代码来源:CommonCreateCamelContext.java

示例9: main

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
public static void main(String... args) throws Exception {

        // 这是camel上下文对象,整个路由的驱动全靠它了。
        ModelCamelContext camelContext = new DefaultCamelContext();
        // 启动route
        camelContext.start();
        // 将我们编排的一个完整消息路由过程,加入到上下文中
        camelContext.addRoutes(new ApacheCamelExample());

        /*
         * ==========================
         * 为什么我们先启动一个Camel服务
         * 再使用addRoutes添加编排好的路由呢?
         * 这是为了告诉各位读者,Apache Camel支持 动态加载/卸载编排 的路由
         * 这很重要,因为后续设计的Broker需要依赖这种能力
         * ==========================
         */

        // 通用没有具体业务意义的代码,只是为了保证主线程不退出
        synchronized (ApacheCamelExample.class) {
            ApacheCamelExample.class.wait();
        }
    }
 
开发者ID:asdf2014,项目名称:yuzhouwan,代码行数:24,代码来源:ApacheCamelExample.java

示例10: copyRoutesToElement

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
public void copyRoutesToElement(CamelContext context, CamelContextFactoryBean contextElement) {
    if (context instanceof ModelCamelContext) {
        copyRoutesToElement(((ModelCamelContext) context).getRouteDefinitions(), contextElement);
    } else {
        LOG.error("Invalid camel context! ({})", context.getClass().getName());
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:8,代码来源:RouteXml.java

示例11: addUrlToCamelRoutes

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
private void addUrlToCamelRoutes(ApplicationOptions options) throws Exception {

        if(options.getDeploymentType() == DeploymentType.SERVLET_CONTAINER) {
            String servicePath = options.getContextPath();

            String toUri = null;
            if (options.isRequiresSSL()) {
                toUri = "https://" + InetAddress.getLocalHost().getHostAddress() + ":" + options.getHttpsPort() +
                        options.getContextPath() + "?bridgeEndpoint=true&throwExceptionOnFailure=false&matchOnUriPrefix=true";
            } else {
                toUri = "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + options.getPort() +
                        options.getContextPath() + "?bridgeEndpoint=true&throwExceptionOnFailure=false&matchOnUriPrefix=true";
            }
            final InputStream in = com.beyondj.gateway.support.JsonRuleBaseBuilder.newRuleBase().rule(servicePath, toUri).inputStream();

            ModelCamelContext modelCamelContext = (ModelCamelContext) camelContext;
            RouteDefinition routeDefinition = modelCamelContext.getRouteDefinition(GatewayRouter.GATEWAY_ROUTE_ID);

            if (routeDefinition == null) {
                int port = Integer.valueOf(
                        config.getProperty(SYSTEM_GATEWAY_ROUTE_PORT));
                camelContext.addRoutes(new GatewayRouter(coreMetricsService, scalingDataService, port));
            }

            LoadBalancerDefinition loadBalancerDefinition = getLoadBalancerDefinition(options);
            Map<String, HttpProxyRule> rules = JsonRuleBaseReader.parseJson(loadBalancerDefinition, in);

            LOG.debug("ADDING GatewayRule {}", rules);
            gatewayRulesService.updateGatewayRules(rules);

            options.setFullUrl(toUri);
            StartUpValidationMessage startUpValidationMessage = new StartUpValidationMessage();
            startUpValidationMessage.setApplicationOptions(options);
            startUpValidationMessage.setProxyRules(rules);
            ActorRef postSystemLaunchActor = systemSingletonService.getPostSystemLaunchActor();
            postSystemLaunchActor.tell(startUpValidationMessage, getSelf());
      }
    }
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:39,代码来源:SystemGatewayActor.java

示例12: testRetrieveLargeBinaryFromFedora

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
/**
 * Verify the binary can be retrieved from Fedora. The request should <em>not</em> be intercepted.
 *
 * @throws Exception if unexpected things go wrong
 */
@Test
public void testRetrieveLargeBinaryFromFedora() throws Exception {

    // Record 'true' if the intercepting route is triggered
    final AtomicBoolean intercepted = new AtomicBoolean(false);
    ctx.getRouteDefinition(INTERCEPT_ROUTE_ID).adviceWith((ModelCamelContext) ctx, new AdviceWithRouteBuilder() {

        @Override
        public void configure() throws Exception {
            weaveAddFirst().process((ex) -> intercepted.set(true));
        }
    });

    final long expectedSize = (2 * 1024 * 1024) + 1;
    final long actualSize;
    final String actualDigest;

    try (FcrepoResponse r = client.get(binaryResource).perform();
            DigestInputStream body = new DigestInputStream(r.getBody(), sha1)) {
        actualSize = drain(body);
        actualDigest = asHex(body.getMessageDigest().digest());
    }

    // The resource can be retrieved intact
    assertEquals(expectedSize, actualSize);
    assertEquals(binaryResourceSha, actualDigest);

    // And the request was not proxied by API-X
    assertFalse(String.format("Unexpected interception of a Fedora resource URI %s by route %s",
            binaryResource.toString(), INTERCEPT_ROUTE_ID), intercepted.get());
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-api-x,代码行数:37,代码来源:StreamingIT.java

示例13: testRetrieveLargeBinaryFromApix

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
/**
 * Verify the binary can be retrieved through the API-X proxy. The request should be intercepted and proxied by
 * API-X.
 *
 * @throws Exception if unexpected things go wrong
 */
@Test
public void testRetrieveLargeBinaryFromApix() throws Exception {

    // Record 'true' if the intercepting route is triggered
    final AtomicBoolean intercepted = new AtomicBoolean(false);
    ctx.getRouteDefinition(INTERCEPT_ROUTE_ID).adviceWith((ModelCamelContext) ctx, new AdviceWithRouteBuilder() {

        @Override
        public void configure() throws Exception {
            weaveAddFirst().process((ex) -> intercepted.set(true));
        }
    });

    final long expectedSize = (2 * 1024 * 1024) + 1;
    final long actualSize;
    final String actualDigest;

    final URI proxiedResource = proxied(binaryResource);
    try (FcrepoResponse r = KarafIT.attempt(30, () -> client.get(proxiedResource).perform());
            DigestInputStream body = new DigestInputStream(r.getBody(), sha1)) {
        actualSize = drain(body);
        actualDigest = asHex(body.getMessageDigest().digest());
    }

    // The request _was_ proxied by API-X
    assertTrue(String.format("Expected the retrieval of %s to be proxied by API-X, route id %s",
            proxiedResource, INTERCEPT_ROUTE_ID), intercepted.get());

    // And resource can be retrieved intact
    assertEquals(expectedSize, actualSize);
    assertEquals(binaryResourceSha, actualDigest);
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-api-x,代码行数:39,代码来源:StreamingIT.java

示例14: advice

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
static void advice(@Observes CamelContextStartingEvent event,
                   ModelCamelContext context) throws Exception {
    // Add a mock endpoint to the end of the route
    context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() {
            weaveAddLast().to("mock:outbound");
        }
    });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:CdiPropertiesTest.java

示例15: pipeMatrixStream

import org.apache.camel.model.ModelCamelContext; //导入依赖的package包/类
void pipeMatrixStream(@Observes CamelContextStartingEvent event,
                      ModelCamelContext context) throws Exception {
    context.getRouteDefinition("matrix")
        .adviceWith(context, new AdviceWithRouteBuilder() {
            @Override
            public void configure() {
                weaveAddLast().to("mock:matrix");
            }
        });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:CdiXmlTest.java


注:本文中的org.apache.camel.model.ModelCamelContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。