本文整理汇总了Java中org.apache.camel.impl.SimpleRegistry.put方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleRegistry.put方法的具体用法?Java SimpleRegistry.put怎么用?Java SimpleRegistry.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.impl.SimpleRegistry
的用法示例。
在下文中一共展示了SimpleRegistry.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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));
}
示例3: 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;
}
示例4: 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());
}
}
}
}
示例5: 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;
}
示例6: 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());
}
示例7: 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);
}
示例8: 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();
}
示例9: 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();
}
示例10: 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);
}
示例11: testSendA19
import org.apache.camel.impl.SimpleRegistry; //导入方法依赖的package包/类
public void testSendA19() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
HL7MLLPCodec codec = new HL7MLLPCodec();
codec.setCharset("iso-8859-1");
codec.setConvertLFtoCR(true);
registry.put("hl7codec", codec);
CamelContext camelContext = new DefaultCamelContext(registry);
camelContext.start();
ProducerTemplate template = camelContext.createProducerTemplate();
String line1 = "MSH|^~\\&|MYSENDER|MYRECEIVER|MYAPPLICATION||200612211200||QRY^A19|1234|P|2.4";
String line2 = "QRD|200612211200|R|I|GetPatient|||1^RD|0101701234|DEM||";
StringBuilder in = new StringBuilder();
in.append(line1);
in.append("\r");
in.append(line2);
template.requestBody("mina2:tcp://127.0.0.1:" + MINA2_PORT + "?sync=true&codec=#hl7codec", in.toString());
template.stop();
camelContext.stop();
}
示例12: init
import org.apache.camel.impl.SimpleRegistry; //导入方法依赖的package包/类
@Override
public void init(ServiceDomain domain) {
if (_logger.isDebugEnabled()) {
_logger.debug("Initialization of CamelExchangeBus for domain " + domain.getName());
}
SimpleRegistry registry = _camelContext.getWritebleRegistry();
for (Processors processor : Processors.values()) {
registry.put(processor.name(), processor.create(domain));
}
// CAMEL-7728 introduces an issue on finding BeanManager due to the fact that default
// applicationContextClassLoader in the CamelContext is not a bundle deployment class loader.
// We need to ensure the applicationContextClassLoader is the bundle deployment class loader
// for now. This will be unnecessary once CAMEL-7759 is merged.
_camelContext.setApplicationContextClassLoader(Thread.currentThread().getContextClassLoader());
}
示例13: 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").beanRef("helloBean");
}
});
// star Camel
context.start();
}
示例14: CmdProducer
import org.apache.camel.impl.SimpleRegistry; //导入方法依赖的package包/类
@Inject
CmdProducer(CommandsDataSetsRoute datasetRoute) throws Exception {
main = new Main() ;
main.enableHangupSupport();
registry = new SimpleRegistry();
context = new DefaultCamelContext(registry);
populate();
registry.put("createCommandDataset", new CreateCommandDataSet(ids, dataSetSize));
registry.put("increaseCommandDataset", new IncreaseCommandDataSet(ids, dataSetSize));
registry.put("decreaseCommandDataset", new DecreaseCommandDataSet(ids, dataSetSize));
context.addRoutes(datasetRoute);
main.getCamelContexts().clear();
main.getCamelContexts().add(context);
main.setDuration(-1);
main.start();
}
示例15: createCamelContext
import org.apache.camel.impl.SimpleRegistry; //导入方法依赖的package包/类
@Override
protected CamelContext createCamelContext() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
dataSource = EmbeddedDataSourceFactory.getDataSource("sql/schema.sql");
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
registry.put("transactionManager", transactionManager);
SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy();
propagationRequired.setTransactionManager(transactionManager);
propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED");
registry.put("PROPAGATION_REQUIRED", propagationRequired);
auditLogDao = new AuditLogDao(dataSource);
messageDao = new MessageDao(dataSource);
CamelContext camelContext = new DefaultCamelContext(registry);
SqlComponent sqlComponent = new SqlComponent();
sqlComponent.setDataSource(dataSource);
camelContext.addComponent("sql", sqlComponent);
return camelContext;
}