本文整理汇总了Java中org.apache.camel.impl.SimpleRegistry类的典型用法代码示例。如果您正苦于以下问题:Java SimpleRegistry类的具体用法?Java SimpleRegistry怎么用?Java SimpleRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleRegistry类属于org.apache.camel.impl包,在下文中一共展示了SimpleRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
camelContext = new DefaultCamelContext();
SimpleRegistry registry = new SimpleRegistry();
Map<String, Object> params = new HashMap<String, Object>();
params.put("custName", "Willem");
// bind the params
registry.put("params", params);
camelContext.setRegistry(registry);
template = camelContext.createProducerTemplate();
ServiceHelper.startServices(template, camelContext);
Endpoint value = camelContext.getEndpoint(getEndpointUri());
assertNotNull("Could not find endpoint!", value);
assertTrue("Should be a JPA endpoint but was: " + value, value instanceof JpaEndpoint);
endpoint = (JpaEndpoint)value;
transactionTemplate = endpoint.createTransactionTemplate();
entityManager = endpoint.createEntityManager();
}
示例2: setUp
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
// create the registry to be the SimpleRegistry which is just a Map based implementation
SimpleRegistry registry = new SimpleRegistry();
// register our HelloBean under the name helloBean
registry.put("helloBean", new HelloBean());
// tell Camel to use our SimpleRegistry
context = new DefaultCamelContext(registry);
// create a producer template to use for testing
template = context.createProducerTemplate();
// add the route using an inlined RouteBuilder
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from("direct:hello").bean("helloBean", "hello");
}
});
// star Camel
context.start();
}
示例3: setup
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
/** Prepares Db and data source, which must be added to Camel registry. */
@BeforeClass
public static void setup() throws Exception {
DeleteDbFiles.execute("~", "jbpm-db-test", true);
h2Server = Server.createTcpServer(new String[0]);
h2Server.start();
setupDb();
DataSource ds = setupDataSource();
SimpleRegistry simpleRegistry = new SimpleRegistry();
simpleRegistry.put("myDs", ds);
handler = new CamelHandler(new SQLURIMapper(), new RequestPayloadMapper("payload"), new ResponsePayloadMapper("queryResult"), new DefaultCamelContext(simpleRegistry));
}
示例4: createCamelContext
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@Override
protected CamelContext createCamelContext() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
ActiveMQConnectionFactory connectionFactory =
new ActiveMQConnectionFactory("vm://embedded?broker.persistent=false");
registry.put("connectionFactory", connectionFactory);
JmsTransactionManager jmsTransactionManager = new JmsTransactionManager();
jmsTransactionManager.setConnectionFactory(connectionFactory);
registry.put("jmsTransactionManager", jmsTransactionManager);
SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy();
propagationRequired.setTransactionManager(jmsTransactionManager);
propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
registry.put("PROPAGATION_REQUIRED", propagationRequired);
SpringTransactionPolicy propagationNotSupported = new SpringTransactionPolicy();
propagationNotSupported.setTransactionManager(jmsTransactionManager);
propagationNotSupported.setPropagationBehaviorName("PROPAGATION_NOT_SUPPORTED");
registry.put("PROPAGATION_NOT_SUPPORTED", propagationNotSupported);
CamelContext camelContext = new DefaultCamelContext(registry);
ActiveMQComponent activeMQComponent = new ActiveMQComponent();
activeMQComponent.setConnectionFactory(connectionFactory);
activeMQComponent.setTransactionManager(jmsTransactionManager);
camelContext.addComponent("jms", activeMQComponent);
return camelContext;
}
示例5: unregisterExecutorComponent
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@SuppressWarnings("Convert2streamapi")
private void unregisterExecutorComponent(Executor... executors) {
for (Executor executor : executors) {
//unregister beans
Registry registry = context.getRegistry();
if (registry instanceof PropertyPlaceholderDelegateRegistry) {
registry = ((PropertyPlaceholderDelegateRegistry) registry).getRegistry();
}
SimpleRegistry openexRegistry = (SimpleRegistry) registry;
Set<Map.Entry<String, Object>> beansEntries = executor.beans().entrySet();
for (Map.Entry<String, Object> beansEntry : beansEntries) {
if (openexRegistry.containsKey(beansEntry.getKey())) {
openexRegistry.remove(beansEntry.getKey());
}
}
//unregister components
Set<String> keys = executor.components().keySet();
for (String key : keys) {
if (context.getComponentNames().contains(key)) {
context.removeComponent(key);
}
}
}
}
示例6: registerExecutorComponent
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@SuppressWarnings("Convert2streamapi")
private void registerExecutorComponent(Executor... executors) {
for (Executor executor : executors) {
//register beans
Registry registry = context.getRegistry();
if (registry instanceof PropertyPlaceholderDelegateRegistry) {
registry = ((PropertyPlaceholderDelegateRegistry) registry).getRegistry();
}
SimpleRegistry openexRegistry = (SimpleRegistry) registry;
Set<Map.Entry<String, Object>> beansEntries = executor.beans().entrySet();
for (Map.Entry<String, Object> beansEntry : beansEntries) {
if (!openexRegistry.containsKey(beansEntry.getKey())) {
openexRegistry.put(beansEntry.getKey(), beansEntry.getValue());
}
}
//register components
Set<Map.Entry<String, org.apache.camel.Component>> components = executor.components().entrySet();
for (Map.Entry<String, org.apache.camel.Component> entry : components) {
if (!context.getComponentNames().contains(entry.getKey())) {
context.addComponent(entry.getKey(), entry.getValue());
}
}
}
}
示例7: testLoadRegistry
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
public void testLoadRegistry() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
registry.put("myBean", "This is a log4j logging configuation file");
CamelContext context = new DefaultCamelContext(registry);
context.start();
InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, "ref:myBean");
assertNotNull(is);
String text = context.getTypeConverter().convertTo(String.class, is);
assertNotNull(text);
assertTrue(text.contains("log4j"));
is.close();
context.stop();
}
示例8: testErrorListener
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
public void testErrorListener() throws Exception {
try {
SimpleRegistry registry = new SimpleRegistry();
registry.put("myListener", listener);
RouteBuilder builder = createRouteBuilder();
CamelContext context = new DefaultCamelContext(registry);
context.addRoutes(builder);
context.start();
fail("Should have thrown an exception due XSLT file not found");
} catch (FailedToCreateRouteException e) {
// expected
}
assertFalse(listener.isWarning());
assertTrue("My error listener should been invoked", listener.isError());
assertTrue("My error listener should been invoked", listener.isFatalError());
}
示例9: createCamelContext
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@Override
protected CamelContext createCamelContext() throws Exception {
final PropertiesComponent pc = new PropertiesComponent("classpath:org/apache/camel/component/properties/myproperties.properties");
pc.setPropertiesResolver(new PropertiesResolver() {
public Properties resolveProperties(CamelContext context, boolean ignoreMissingLocation, String... uri) throws Exception {
resolvedCount++;
return new DefaultPropertiesResolver(pc).resolveProperties(context, ignoreMissingLocation, uri);
}
});
// put the properties component into the registry so that it survives restarts
SimpleRegistry registry = new SimpleRegistry();
registry.put("properties", pc);
return new DefaultCamelContext(registry);
}
示例10: shouldFailWhenThereIsNoJobLauncher
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@Test(expected = FailedToCreateRouteException.class)
public void shouldFailWhenThereIsNoJobLauncher() throws Exception {
// Given
SimpleRegistry registry = new SimpleRegistry();
registry.put("mockJob", job);
CamelContext camelContext = new DefaultCamelContext(registry);
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("spring-batch:mockJob");
}
});
// When
camelContext.start();
}
示例11: shouldFailWhenThereIsMoreThanOneJobLauncher
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@Test(expected = FailedToCreateRouteException.class)
public void shouldFailWhenThereIsMoreThanOneJobLauncher() throws Exception {
// Given
SimpleRegistry registry = new SimpleRegistry();
registry.put("mockJob", job);
registry.put("launcher1", jobLauncher);
registry.put("launcher2", jobLauncher);
CamelContext camelContext = new DefaultCamelContext(registry);
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("spring-batch:mockJob");
}
});
// When
camelContext.start();
}
示例12: shouldResolveAnyJobLauncher
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@Test
public void shouldResolveAnyJobLauncher() throws Exception {
// Given
SimpleRegistry registry = new SimpleRegistry();
registry.put("mockJob", job);
registry.put("someRandomName", jobLauncher);
CamelContext camelContext = new DefaultCamelContext(registry);
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("spring-batch:mockJob");
}
});
// When
camelContext.start();
// Then
SpringBatchEndpoint batchEndpoint = camelContext.getEndpoint("spring-batch:mockJob", SpringBatchEndpoint.class);
JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
assertSame(jobLauncher, batchEndpointJobLauncher);
}
示例13: createCamelContext
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@Override
public CamelContext createCamelContext() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
registry.put("testStrategy", new ListAggregationStrategy());
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(broker.getTcpConnectorUri());
SjmsComponent sjmsComponent = new SjmsComponent();
sjmsComponent.setConnectionFactory(connectionFactory);
SjmsBatchComponent sjmsBatchComponent = new SjmsBatchComponent();
sjmsBatchComponent.setConnectionFactory(connectionFactory);
CamelContext context = new DefaultCamelContext(registry);
context.addComponent("sjms", sjmsComponent);
context.addComponent("sjms-batch", sjmsBatchComponent);
return context;
}
示例14: createCamelContext
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@Override
protected CamelContext createCamelContext() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
registry.put("aggStrategy", AggregationStrategies.groupedExchange());
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(broker.getTcpConnectorUri());
SjmsComponent sjmsComponent = new SjmsComponent();
sjmsComponent.setConnectionFactory(connectionFactory);
SjmsBatchComponent sjmsBatchComponent = new SjmsBatchComponent();
sjmsBatchComponent.setConnectionFactory(connectionFactory);
CamelContext context = new DefaultCamelContext(registry);
context.addComponent("sjms-batch", sjmsBatchComponent);
context.addComponent("sjms", sjmsComponent);
return context;
}
示例15: invalidConfiguration
import org.apache.camel.impl.SimpleRegistry; //导入依赖的package包/类
@Test
public void invalidConfiguration() throws Exception {
// Given
SimpleRegistry registry = new SimpleRegistry();
registry.put("eventBus", new EventBus());
CamelContext context = new DefaultCamelContext(registry);
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("guava-eventbus:eventBus?listenerInterface=org.apache.camel.component.guava.eventbus.CustomListener&eventClass=org.apache.camel.component.guava.eventbus.MessageWrapper").
to("mock:customListenerEvents");
}
});
try {
context.start();
fail("Should throw exception");
} catch (FailedToCreateRouteException e) {
IllegalStateException ise = assertIsInstanceOf(IllegalStateException.class, e.getCause());
assertEquals("You cannot set both 'eventClass' and 'listenerInterface' parameters.", ise.getMessage());
}
}