本文整理汇总了Java中org.apache.camel.Component类的典型用法代码示例。如果您正苦于以下问题:Java Component类的具体用法?Java Component怎么用?Java Component使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Component类属于org.apache.camel包,在下文中一共展示了Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.camel.Component; //导入依赖的package包/类
@PostConstruct
public void start() throws Exception {
camel = new DefaultCamelContext();
camel.start();
final Component component = camel.getComponent(getConnectorAction(), true, false);
if (component == null) {
log.error("Component {} does not exist", getConnectorAction());
} else {
verifier = component.getExtension(verifierExtensionClass).orElse(null);
if (verifier == null) {
log.warn("Component {} does not support verifier extension", getConnectorAction());
}
}
}
示例2: getComponentVerifierExtension
import org.apache.camel.Component; //导入依赖的package包/类
private ComponentVerifierExtension getComponentVerifierExtension(CamelContext context, String scheme) {
if (verifierExtension == null) {
synchronized (this) {
if (verifierExtension == null) {
Component component = context.getComponent(scheme, true, false);
if (component == null) {
log.error("Component {} does not exist", scheme);
} else {
verifierExtension = component.getExtension(verifierExtensionClass).orElse(null);
if (verifierExtension == null) {
log.warn("Component {} does not support verifier extension", scheme);
}
}
}
}
}
return verifierExtension;
}
示例3: shouldPassSpecificationToRestSwaggerComponent
import org.apache.camel.Component; //导入依赖的package包/类
@Test
public void shouldPassSpecificationToRestSwaggerComponent() throws Exception {
final Component component = camelContext.getComponent("swagger-operation");
assertThat(component).isNotNull();
final String specification = IOUtils.toString(SwaggerConnectorComponentTest.class.getResource("/petstore.json"),
StandardCharsets.UTF_8);
IntrospectionSupport.setProperties(component, new HashMap<>(Collections.singletonMap("specification", specification)));
final Endpoint endpoint = component.createEndpoint("swagger-operation://?operationId=addPet");
assertThat(endpoint).isNotNull();
final Optional<RestSwaggerEndpoint> maybeRestSwagger = camelContext.getEndpoints().stream()
.filter(RestSwaggerEndpoint.class::isInstance).map(RestSwaggerEndpoint.class::cast).findFirst();
assertThat(maybeRestSwagger).hasValueSatisfying(restSwagger -> {
assertThat(restSwagger.getSpecificationUri()).isNotNull();
assertThat(restSwagger.getOperationId()).isEqualTo("addPet");
});
}
示例4: ping
import org.apache.camel.Component; //导入依赖的package包/类
public void ping() throws Exception {
// need to create Camel
CamelContext camel = new DefaultCamelContext();
// get the connector to use
Component mention = camel.getComponent("salesforce-upsert-contact-connector");
Optional<ComponentVerifierExtension> ext = mention.getExtension(ComponentVerifierExtension.class);
// the connector must support ping check if its verifiable
if (ext.isPresent()) {
ComponentVerifierExtension verifier = ext.get();
Map<String, Object> parameters = loadParameters();
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
System.out.println("=============================================");
System.out.println("");
System.out.println("Ping check result: " + result.getStatus());
System.out.println("");
System.out.println("=============================================");
} else {
System.out.println("Component does not support ping check");
}
}
示例5: ping
import org.apache.camel.Component; //导入依赖的package包/类
public void ping() throws Exception {
// need to create Camel
CamelContext camel = new DefaultCamelContext();
// get the connector to use
Component mention = camel.getComponent("twitter-mention-connector");
Optional<ComponentVerifierExtension> ext = mention.getExtension(ComponentVerifierExtension.class);
// the connector must support ping check if its verifiable
if (ext.isPresent()) {
ComponentVerifierExtension verifier = ext.get();
Map<String, Object> parameters = loadParameters();
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
System.out.println("=============================================");
System.out.println("");
System.out.println("Ping check result: " + result.getStatus());
System.out.println("");
System.out.println("=============================================");
} else {
System.out.println("Component does not support ping check");
}
}
示例6: ping
import org.apache.camel.Component; //导入依赖的package包/类
public void ping() throws Exception {
// need to create Camel
CamelContext camel = new DefaultCamelContext();
// get the connector to use
Component get = camel.getComponent("http-get-connector");
Optional<ComponentVerifierExtension> ext = get.getExtension(ComponentVerifierExtension.class);
// the connector must support ping check if its verifiable
if (ext.isPresent()) {
ComponentVerifierExtension verifier = ext.get();
Map<String, Object> parameters = loadParameters();
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
System.out.println("=============================================");
System.out.println("");
System.out.println("Ping check result: " + result.getStatus());
System.out.println("");
System.out.println("=============================================");
} else {
System.out.println("Component does not support ping check");
}
}
示例7: getComponent
import org.apache.camel.Component; //导入依赖的package包/类
protected Component getComponent(String name, CamelContext context) throws Exception {
LOG.trace("Finding Component: {}", name);
try {
ServiceReference<?>[] refs = bundleContext.getServiceReferences(ComponentResolver.class.getName(), "(component=" + name + ")");
if (refs != null) {
for (ServiceReference<?> ref : refs) {
Object service = bundleContext.getService(ref);
if (ComponentResolver.class.isAssignableFrom(service.getClass())) {
ComponentResolver resolver = (ComponentResolver) service;
return resolver.resolveComponent(name, context);
}
}
}
return null;
} catch (InvalidSyntaxException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
}
示例8: isPropertyPlaceholder
import org.apache.camel.Component; //导入依赖的package包/类
private static boolean isPropertyPlaceholder(CamelContext context, Object value) {
if (context != null) {
Component component = context.hasComponent("properties");
if (component != null) {
PropertiesComponent pc;
try {
pc = context.getTypeConverter().mandatoryConvertTo(PropertiesComponent.class, component);
} catch (Exception e) {
return false;
}
if (value.toString().contains(pc.getPrefixToken()) && value.toString().contains(pc.getSuffixToken())) {
return true;
}
}
}
return false;
}
示例9: testGuice
import org.apache.camel.Component; //导入依赖的package包/类
@Test
public void testGuice() throws Exception {
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.PROVIDER_URL, GuiceInitialContextFactory.class.getName());
env.put(Injectors.MODULE_CLASS_NAMES, MyModule.class.getName());
InitialContext context = new InitialContext(env);
Injector injector = (Injector) context.lookup(Injector.class.getName());
assertNotNull("Found injector", injector);
Object value = context.lookup("foo");
assertNotNull("Should have found a value for foo!", value);
CamelContext camelContext = injector.getInstance(CamelContext.class);
Component component = camelContext.getComponent("foo");
assertThat(component, is(MockComponent.class));
Endpoint endpoint = camelContext.getEndpoint("foo:cheese");
assertThat(endpoint, is(MockEndpoint.class));
}
示例10: removeComponent
import org.apache.camel.Component; //导入依赖的package包/类
public Component removeComponent(String componentName) {
synchronized (components) {
Component oldComponent = components.remove(componentName);
if (oldComponent != null) {
try {
stopServices(oldComponent);
} catch (Exception e) {
log.warn("Error stopping component " + oldComponent + ". This exception will be ignored.", e);
}
for (LifecycleStrategy strategy : lifecycleStrategies) {
strategy.onComponentRemove(componentName, oldComponent);
}
}
// keep reference to properties component up to date
if (oldComponent != null && "properties".equals(componentName)) {
propertiesComponent = null;
}
return oldComponent;
}
}
示例11: createEndpoint
import org.apache.camel.Component; //导入依赖的package包/类
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
String splitURI[] = ObjectHelper.splitOnCharacter(remaining, ":", 2);
if (splitURI[1] != null) {
String contextId = splitURI[0];
String localEndpoint = splitURI[1];
Component component = getCamelContext().getComponent(contextId);
if (component != null) {
LOG.debug("Attempting to create local endpoint: {} inside the component: {}", localEndpoint, component);
Endpoint endpoint = component.createEndpoint(localEndpoint);
if (endpoint == null) {
// throw the exception tell we cannot find an then endpoint from the given context
throw new ResolveEndpointFailedException("Cannot create a endpoint with uri" + localEndpoint + " for the CamelContext Component " + contextId);
} else {
ContextEndpoint answer = new ContextEndpoint(uri, this, endpoint);
answer.setContextId(contextId);
answer.setLocalEndpointUrl(localEndpoint);
return answer;
}
} else {
throw new ResolveEndpointFailedException("Cannot create the camel context component for context " + contextId);
}
} else { // the uri is wrong
throw new ResolveEndpointFailedException("The uri " + remaining + "from camel context component is wrong");
}
}
示例12: doStart
import org.apache.camel.Component; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
Optional<Component> component = createNewBaseComponent();
if (component.isPresent()) {
componentSchemeAlias = Optional.of(componentScheme + "-" + componentId);
if (!catalog.findComponentNames().contains(componentSchemeAlias)) {
catalog.addComponent(
componentSchemeAlias.get(),
definition.getComponent().getJavaType(),
catalog.componentJSonSchema(componentScheme)
);
}
LOGGER.info("Register component: {} (type: {}) with scheme: {} and alias: {}",
this.componentId,
component.get().getClass().getName(),
this.componentScheme,
this.componentSchemeAlias.get()
);
// remove old component if present so
getCamelContext().removeComponent(this.componentSchemeAlias.get());
// ensure component is started and stopped when Camel shutdown
getCamelContext().addService(component, true, true);
getCamelContext().addComponent(this.componentSchemeAlias.get(), component.get());
} else {
this.componentSchemeAlias = Optional.empty();
}
LOGGER.debug("Starting connector: {}", componentId);
super.doStart();
}
示例13: components
import org.apache.camel.Component; //导入依赖的package包/类
@Override
public ImmutableMap<String, Component> components() {
MailComponent mailComponent = new MailComponent();
return ImmutableMap.of(
"smtp", mailComponent,
"smtps", mailComponent,
"freemarker", new FreemarkerComponent()
);
}
示例14: components
import org.apache.camel.Component; //导入依赖的package包/类
@Override
public ImmutableMap<String, Component> components() {
return ImmutableMap.of(
"freemarker", new FreemarkerComponent(),
"ovhSms", new OvhSmsComponent()
);
}
示例15: ArdulinkEndpoint
import org.apache.camel.Component; //导入依赖的package包/类
public ArdulinkEndpoint(String uri, Component ardulinkComponent,
EndpointConfig config) throws IOException {
super(uri, ardulinkComponent);
this.config = config;
this.link = createLink();
for (Pin pin : config.getPins()) {
this.link.startListening(pin);
}
}