org.apache.camel.Endpoint Java Examples
The following examples show how to use
org.apache.camel.Endpoint.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwaggerProxyComponentTest.java From syndesis with Apache License 2.0 | 6 votes |
@Test public void testSwaggerProxyComponent() throws Exception { CamelContext context = new DefaultCamelContext(); ComponentProxyFactory factory = new ConnectorFactory(); ComponentProxyComponent proxy = factory.newInstance("swagger-1", "rest-openapi"); try { proxy.setCamelContext(context); proxy.start(); Endpoint endpoint = proxy.createEndpoint("swagger-1:http://foo.bar"); assertThat(endpoint).isInstanceOfSatisfying(DelegateEndpoint.class, e -> { assertThat(e.getEndpoint()).isInstanceOf(RestOpenApiEndpoint.class); assertThat(e.getEndpoint()).hasFieldOrPropertyWithValue("componentName", SyndesisRestSwaggerComponent.COMPONENT_NAME); }); } finally { proxy.stop(); } }
Example #2
Source File: AbstractCamelProvisioningManager.java From syncope with Apache License 2.0 | 6 votes |
protected PollingConsumer getConsumer(final String uri) { if (!knownURIs.contains(uri)) { knownURIs.add(uri); Endpoint endpoint = contextFactory.getCamelContext().getEndpoint(uri); PollingConsumer pollingConsumer = null; try { pollingConsumer = endpoint.createPollingConsumer(); consumerMap.put(uri, pollingConsumer); pollingConsumer.start(); } catch (Exception ex) { LOG.error("Unexpected error in Consumer creation ", ex); } return pollingConsumer; } else { return consumerMap.get(uri); } }
Example #3
Source File: AWSS3RawOptionsTest.java From syndesis with Apache License 2.0 | 6 votes |
@Override protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); camelContext.setAutoStartup(false); camelContext.addComponent("aws-s3", new S3Component() { @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { final S3Configuration configuration = new S3Configuration(); setProperties(configuration, parameters); return new S3Endpoint(uri, this, configuration) { @Override public void doStart() throws Exception { // don't let the endpoint to start as it would try to // process the keys } }; } }); return camelContext; }
Example #4
Source File: ActivitiComponent.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override protected Endpoint createEndpoint(String s, String s1, Map<String, Object> parameters) throws Exception { ActivitiEndpoint ae = new ActivitiEndpoint(s, getCamelContext()); ae.setIdentityService(identityService); ae.setRuntimeService(runtimeService); ae.setRepositoryService(repositoryService); ae.setCopyVariablesToProperties(this.copyVariablesToProperties); ae.setCopyVariablesToBodyAsMap(this.copyVariablesToBodyAsMap); ae.setCopyCamelBodyToBody(this.copyCamelBodyToBody); Map<String, Object> returnVars = IntrospectionSupport.extractProperties(parameters, "var.return."); if (returnVars != null && returnVars.size() > 0) { ae.getReturnVarMap().putAll(returnVars); } return ae; }
Example #5
Source File: FlowableComponent.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override protected Endpoint createEndpoint(String s, String s1, Map<String, Object> parameters) throws Exception { FlowableEndpoint ae = new FlowableEndpoint(s, getCamelContext()); ae.setIdentityService(identityService); ae.setRuntimeService(runtimeService); ae.setRepositoryService(repositoryService); ae.setManagementService(managementService); ae.setCopyVariablesToProperties(this.copyVariablesToProperties); ae.setCopyVariablesToBodyAsMap(this.copyVariablesToBodyAsMap); ae.setCopyCamelBodyToBody(this.copyCamelBodyToBody); Map<String, Object> returnVars = IntrospectionSupport.extractProperties(parameters, "var.return."); if (returnVars != null && returnVars.size() > 0) { ae.getReturnVarMap().putAll(returnVars); } return ae; }
Example #6
Source File: SalesforceStreamingConnectorFactory.java From syndesis with Apache License 2.0 | 6 votes |
@Override protected Endpoint createDelegateEndpoint(ComponentDefinition definition, String scheme, Map<String, String> options) { final String sObjectName = options.get(SalesforceEndpointConfig.SOBJECT_NAME); final String query = "SELECT Id FROM " + sObjectName; final String topicName = SalesforceUtil.topicNameFor(options); options.put("topicName", topicName); options.put(SalesforceEndpointConfig.SOBJECT_QUERY, query); options.remove(SalesforceEndpointConfig.SOBJECT_NAME); if (!topicName.endsWith("_d")) { setBeforeConsumer( new Enricher( new ConstantExpression(scheme + ":getSObject?rawPayload=true&sObjectName=" + sObjectName) ) ); } return super.createDelegateEndpoint(definition, scheme, options); }
Example #7
Source File: K8NatsComponent.java From funktion-connectors with Apache License 2.0 | 6 votes |
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { K8NatsConfiguration config = new K8NatsConfiguration(); setProperties(config, parameters); String topic = remaining.split("\\?")[0]; if (topic != null){ config.setTopic(topic); } String servers = config.getServiceName() + ":" + config.getPort(); config.setServers(servers); NatsEndpoint endpoint = new NatsEndpoint(uri, this, config); return endpoint; }
Example #8
Source File: K8ElasticSearchComponent.java From funktion-connectors with Apache License 2.0 | 6 votes |
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { K8ElasticSearchConfiguration config = new K8ElasticSearchConfiguration(); setProperties(config, parameters); config.setLocal(false); String serviceName = config.getServiceName(); config.setClusterName(serviceName); String operation = remaining; if (operation != null){ config.setOperation(operation); } config.setTransportAddressesList(parseTransportAddresses(config.getTransportAddresses(), config)); Endpoint endpoint = new ElasticsearchEndpoint(uri, this, config, getClient()); return endpoint; }
Example #9
Source File: InboundEndpointTest.java From vertx-camel-bridge with Apache License 2.0 | 6 votes |
@Test public void testWithDirectEndpoint2(TestContext context) throws Exception { Async async = context.async(); Endpoint endpoint = camel.getEndpoint("direct:foo"); bridge = CamelBridge.create(vertx, new CamelBridgeOptions(camel) .addInboundMapping(fromCamel(endpoint).toVertx("test"))); vertx.eventBus().consumer("test", message -> { context.assertEquals("hello", message.body()); async.complete(); }); camel.start(); BridgeHelper.startBlocking(bridge); ProducerTemplate producer = camel.createProducerTemplate(); producer.asyncSendBody(endpoint, "hello"); }
Example #10
Source File: InboundEndpointTest.java From vertx-camel-bridge with Apache License 2.0 | 6 votes |
@Test public void testWithDirectEndpointAndCustomType(TestContext context) throws Exception { Async async = context.async(); Endpoint endpoint = camel.getEndpoint("direct:foo"); vertx.eventBus().registerDefaultCodec(Person.class, new PersonCodec()); bridge = CamelBridge.create(vertx, new CamelBridgeOptions(camel) .addInboundMapping(fromCamel("direct:foo").toVertx("test"))); vertx.eventBus().<Person>consumer("test", message -> { context.assertEquals("bob", message.body().getName()); async.complete(); }); camel.start(); BridgeHelper.startBlocking(bridge); ProducerTemplate producer = camel.createProducerTemplate(); producer.asyncSendBody(endpoint, new Person().setName("bob")); }
Example #11
Source File: InboundEndpointTest.java From vertx-camel-bridge with Apache License 2.0 | 6 votes |
@Test public void testWithDirectEndpoint(TestContext context) throws Exception { Async async = context.async(); Endpoint endpoint = camel.getEndpoint("direct:foo"); bridge = CamelBridge.create(vertx, new CamelBridgeOptions(camel) .addInboundMapping(fromCamel("direct:foo").toVertx("test"))); vertx.eventBus().consumer("test", message -> { context.assertEquals("hello", message.body()); async.complete(); }); camel.start(); BridgeHelper.startBlocking(bridge); ProducerTemplate producer = camel.createProducerTemplate(); producer.asyncSendBody(endpoint, "hello"); }
Example #12
Source File: QuteComponent.java From camel-quarkus with Apache License 2.0 | 6 votes |
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { boolean cache = getAndRemoveParameter(parameters, "contentCache", Boolean.class, Boolean.TRUE); QuteEndpoint answer = new QuteEndpoint(uri, this, remaining); answer.setContentCache(cache); answer.setAllowTemplateFromHeader(allowTemplateFromHeader); answer.setQuteEngine(quteEngine); setProperties(answer, parameters); // if its a http resource then append any remaining parameters and update the resource uri if (ResourceHelper.isHttpUri(remaining)) { remaining = ResourceHelper.appendParameters(remaining, parameters); answer.setResourceUri(remaining); } return answer; }
Example #13
Source File: DnsIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testDnsComponent() throws Exception { CamelContext camelctx = new DefaultCamelContext(); Endpoint endpoint = camelctx.getEndpoint("dns:lookup"); Assert.assertNotNull(endpoint); Assert.assertEquals(endpoint.getClass().getName(), "org.apache.camel.component.dns.DnsEndpoint"); }
Example #14
Source File: OutboundEndpointTest.java From vertx-camel-bridge with Apache License 2.0 | 5 votes |
@Test public void testWithStreams() throws Exception { File root = new File("target/junk"); File file = new File(root, "foo.txt"); if (file.exists()) { file.delete(); } root.mkdirs(); Endpoint endpoint = camel.getEndpoint("stream:file?fileName=target/junk/foo.txt"); camel.addEndpoint("output", endpoint); bridge = CamelBridge.create(vertx, new CamelBridgeOptions(camel) .addOutboundMapping(fromVertx("test").toCamel("output"))); camel.start(); BridgeHelper.startBlocking(bridge); long date = System.currentTimeMillis(); vertx.eventBus().send("test", date); await().atMost(DEFAULT_TIMEOUT).until(() -> file.isFile() && FileUtils.readFileToString(file).length() > 0); String string = FileUtils.readFileToString(file); assertThat(string).contains(Long.toString(date)); long date2 = System.currentTimeMillis(); vertx.eventBus().send("test", date2); await().atMost(DEFAULT_TIMEOUT).until(() -> FileUtils.readFileToString(file).length() > string.length()); assertThat(FileUtils.readFileToString(file)).containsSequence(Long.toString(date), Long.toString(date2)); }
Example #15
Source File: CamelBehavior.java From flowable-engine with Apache License 2.0 | 5 votes |
protected FlowableEndpoint getEndpoint(String key) { for (Endpoint e : camelContextObj.getEndpoints()) { if (e.getEndpointKey().equals(key) && (e instanceof FlowableEndpoint)) { return (FlowableEndpoint) e; } } throw new FlowableException("Endpoint not defined for " + key); }
Example #16
Source File: WebhookComponentProducer.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { TestWebhookEndpoint endpoint = new TestWebhookEndpoint(uri, this); endpoint.setWebhookHandler(processor -> exchange -> { exchange.getMessage().setBody("Camel Quarkus Webhook"); processor.process(exchange); }); return endpoint; }
Example #17
Source File: CamelBridgeImpl.java From vertx-camel-bridge with Apache License 2.0 | 5 votes |
private Endpoint validate(CamelMapping mapping) { Objects.requireNonNull(mapping.getAddress(), "The vert.x event bus address must not be `null`"); Objects.requireNonNull(mapping.getUri(), "The endpoint uri must not be `null`"); Endpoint endpoint = camel.getEndpoint(mapping.getUri()); Objects.requireNonNull(endpoint, "Cannot find the endpoint " + mapping.getUri() + " in the camel context"); return endpoint; }
Example #18
Source File: InboundEndpointTest.java From vertx-camel-bridge with Apache License 2.0 | 5 votes |
@Test public void testWithDirectEndpointWithPublishAndCustomType(TestContext context) throws Exception { Async async = context.async(); Async async2 = context.async(); Endpoint endpoint = camel.getEndpoint("direct:foo"); vertx.eventBus().registerDefaultCodec(Person.class, new PersonCodec()); bridge = CamelBridge.create(vertx, new CamelBridgeOptions(camel) .addInboundMapping(fromCamel(endpoint).toVertx("test").usePublish())); vertx.eventBus().<Person>consumer("test", message -> { context.assertEquals("bob", message.body().getName()); async.complete(); }); vertx.eventBus().<Person>consumer("test", message -> { context.assertEquals("bob", message.body().getName()); async2.complete(); }); camel.start(); BridgeHelper.startBlocking(bridge); ProducerTemplate producer = camel.createProducerTemplate(); producer.asyncSendBody(endpoint, new Person().setName("bob")); }
Example #19
Source File: InboundEndpointTest.java From vertx-camel-bridge with Apache License 2.0 | 5 votes |
@Test @Ignore public void testWithStompAndJson(TestContext context) throws Exception { StompServerHandler serverHandler = StompServerHandler.create(vertx); StompServer.create(vertx).handler(serverHandler).listen(ar -> { stomp = ar.result(); }); await().atMost(DEFAULT_TIMEOUT).until(() -> stomp != null); Async async = context.async(); Endpoint endpoint = camel.getEndpoint("stomp:queue"); bridge = CamelBridge.create(vertx, new CamelBridgeOptions(camel) .addInboundMapping(fromCamel(endpoint).toVertx("test"))); vertx.eventBus().<Buffer>consumer("test", message -> { // We get a buffer. JsonObject json = message.body().toJsonObject(); context.assertEquals("bar", json.getString("foo")); async.complete(); }); camel.start(); BridgeHelper.startBlocking(bridge); StompClient.create(vertx).connect(connection -> { connection.result().send("queue", Buffer.buffer(new JsonObject().put("foo", "bar").encode())); connection.result().close(); }); }
Example #20
Source File: KnativeHttpTransport.java From camel-k-runtime with Apache License 2.0 | 5 votes |
@Override public Consumer createConsumer(Endpoint endpoint, KnativeTransportConfiguration config, KnativeEnvironment.KnativeServiceDefinition service, Processor processor) { Processor next = KnativeHttpSupport.remapCloudEventHeaders(processor, config.getCloudEvent()); if (config.isRemoveCloudEventHeadersInReply()) { next = KnativeHttpSupport.withoutCloudEventHeaders(next, config.getCloudEvent()); } return new KnativeHttpConsumer(this, endpoint, service, this.router, next); }
Example #21
Source File: KnativeComponent.java From camel-k-runtime with Apache License 2.0 | 5 votes |
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { if (ObjectHelper.isEmpty(remaining)) { throw new IllegalArgumentException("Expecting URI in the form of: 'knative:type/name', got '" + uri + "'"); } final String type = ObjectHelper.supplyIfEmpty(StringHelper.before(remaining, "/"), () -> remaining); final String name = StringHelper.after(remaining, "/"); final KnativeConfiguration conf = getKnativeConfiguration(); conf.getFilters().putAll( PropertiesHelper.extractProperties(parameters, "filter.", true) ); conf.getTransportOptions().putAll( PropertiesHelper.extractProperties(parameters, "transport.", true) ); conf.getCeOverride().putAll( PropertiesHelper.extractProperties(parameters, "ce.override.", true) ); // set properties from the endpoint uri PropertyBindingSupport.bindProperties(getCamelContext(), conf, parameters); if (ObjectHelper.isEmpty(conf.getServiceName())) { conf.setServiceName(name); } return new KnativeEndpoint(uri, this, Knative.Type.valueOf(type), name, conf); }
Example #22
Source File: KnativeTransportNoop.java From camel-k-runtime with Apache License 2.0 | 5 votes |
@Override public Producer createProducer(Endpoint endpoint, KnativeTransportConfiguration configuration, KnativeEnvironment.KnativeServiceDefinition service) { return new DefaultProducer(endpoint) { @Override public void process(Exchange exchange) throws Exception { } }; }
Example #23
Source File: DeprovisionProducer.java From syncope with Apache License 2.0 | 5 votes |
public DeprovisionProducer( final Endpoint endpoint, final AnyTypeKind anyTypeKind, final UserDAO userDAO, final GroupDAO groupDAO, final AnyObjectDAO anyObjectDAO) { super(endpoint, anyTypeKind); this.userDAO = userDAO; this.groupDAO = groupDAO; this.anyObjectDAO = anyObjectDAO; }
Example #24
Source File: DataVecComponent.java From DataVec with Apache License 2.0 | 5 votes |
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { DataVecEndpoint endpoint = new DataVecEndpoint(uri, this); setProperties(endpoint, parameters); endpoint.setInputFormat(remaining); return endpoint; }
Example #25
Source File: TestComponent.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override protected Endpoint createEndpoint(final String uri, final String remaining, final Map<String, Object> parameters) throws Exception { final String value = String.class.cast(parameters.remove("value")); return new DefaultEndpoint() { @Override protected String createEndpointUri() { return uri; } @Override public Producer createProducer() throws Exception { return new DefaultProducer(this) { @Override public void process(final Exchange exchange) throws Exception { exchange.getIn().setBody(exchange.getIn().getBody(String.class) + value); } }; } @Override public Consumer createConsumer(final Processor processor) throws Exception { throw new UnsupportedOperationException(); } @Override public boolean isSingleton() { return true; } }; }
Example #26
Source File: ArdulinkComponent.java From Ardulink-2 with Apache License 2.0 | 5 votes |
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { EndpointConfig config = new EndpointConfig() .type(remaining) .listenTo(parsePins(getOptional(parameters, "listenTo").or(""))) .linkParams(parameters); parameters.clear(); ArdulinkEndpoint endpoint = new ArdulinkEndpoint(uri, this, config); setProperties(endpoint, parameters); return endpoint; }
Example #27
Source File: ComponentProxyComponent.java From syndesis with Apache License 2.0 | 5 votes |
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) { // merge parameters final Map<String, Object> options = new HashMap<>(); doAddOptions(options, this.remainingOptions); doAddOptions(options, parameters); // create the uri of the base component, DO NOT log the computed delegate final Map<String, String> endpointOptions = buildEndpointOptions(remaining, options); final String endpointScheme = componentSchemeAlias.orElse(componentScheme); ComponentDefinition definition = getDefinition(); final Endpoint delegate = createDelegateEndpoint(definition, endpointScheme, endpointOptions); LOGGER.info("Connector resolved: {} -> {}", URISupport.sanitizeUri(uri), URISupport.sanitizeUri(delegate.getEndpointUri())); // remove options already set on the endpoint options.keySet().removeIf(endpointOptions::containsKey); // Configure the delegated endpoint configureDelegateEndpoint(definition, delegate, options); final ComponentProxyEndpoint answer = new ComponentProxyEndpoint(uri, this, delegate); answer.setBeforeProducer(CamelContextAware.trySetCamelContext(getBeforeProducer(), getCamelContext())); answer.setAfterProducer(CamelContextAware.trySetCamelContext(getAfterProducer(), getCamelContext())); answer.setBeforeConsumer(CamelContextAware.trySetCamelContext(getBeforeConsumer(), getCamelContext())); answer.setAfterConsumer(CamelContextAware.trySetCamelContext(getAfterConsumer(), getCamelContext())); // clean-up parameters so that validation won't fail later on // in DefaultConnectorComponent.validateParameters() parameters.clear(); // remove temporary options this.remainingOptions.clear(); return answer; }
Example #28
Source File: StatusProducer.java From syncope with Apache License 2.0 | 5 votes |
public StatusProducer( final Endpoint endpoint, final AnyTypeKind anyTypeKind, final UserDAO userDAO, final UserWorkflowAdapter uwfAdapter) { super(endpoint, anyTypeKind); this.userDAO = userDAO; this.uwfAdapter = uwfAdapter; }
Example #29
Source File: CustomComponentTest.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void testCustomComponentEndpoint() throws Exception { final CamelContext context = new DefaultCamelContext(); final ComponentProxyComponent component = new ComponentProxyComponent("acme-1", "acme", AcmeComponent.class); component.setCamelContext(context); component.setOptions(CollectionHelper.mapOf("name", "test", "param", "p1")); component.start(); final Endpoint endpoint = component.createEndpoint("acme"); assertThat(endpoint).isInstanceOf(ComponentProxyEndpoint.class); assertThat(endpoint).hasFieldOrPropertyWithValue("delegateEndpointUri", "acme://test?param=p1"); }
Example #30
Source File: IgniteCamelStreamerTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception */ @Test public void testUserSpecifiedCamelContext() throws Exception { final AtomicInteger cnt = new AtomicInteger(); // Create a CamelContext with a probe that'll help us know if it has been used. CamelContext context = new DefaultCamelContext(); context.setTracing(true); context.addLifecycleStrategy(new LifecycleStrategySupport() { @Override public void onEndpointAdd(Endpoint endpoint) { cnt.incrementAndGet(); } }); streamer.setSingleTupleExtractor(singleTupleExtractor()); streamer.setCamelContext(context); // Subscribe to cache PUT events. CountDownLatch latch = subscribeToPutEvents(50); // Action time. streamer.start(); // Send messages. sendMessages(0, 50, false); // Assertions. assertTrue(latch.await(10, TimeUnit.SECONDS)); assertCacheEntriesLoaded(50); assertTrue(cnt.get() > 0); }