本文整理汇总了Java中org.apache.camel.component.infinispan.InfinispanConstants类的典型用法代码示例。如果您正苦于以下问题:Java InfinispanConstants类的具体用法?Java InfinispanConstants怎么用?Java InfinispanConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InfinispanConstants类属于org.apache.camel.component.infinispan包,在下文中一共展示了InfinispanConstants类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCachePut
import org.apache.camel.component.infinispan.InfinispanConstants; //导入依赖的package包/类
@Test
public void testCachePut() throws Exception {
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:put")
.to("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&command=PUT");
}
});
camelctx.start();
try {
Map<String, Object> headers = new HashMap<>();
headers.put(InfinispanConstants.KEY, CACHE_KEY_NAME);
headers.put(InfinispanConstants.VALUE, CACHE_VALUE_KERMIT);
ProducerTemplate template = camelctx.createProducerTemplate();
template.requestBodyAndHeaders("direct:put", null, headers);
String name = (String) cacheContainer.getCache().get(CACHE_KEY_NAME);
Assert.assertEquals("Kermit", name);
} finally {
camelctx.stop();
}
}
示例2: process
import org.apache.camel.component.infinispan.InfinispanConstants; //导入依赖的package包/类
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
Map<String,Object> tuple= (Map<String, Object>) in.getBody();
MoneyTransfer mt = new MoneyTransfer();
mt.setId((Long)tuple.get(MoneyTransfer.FIELD_ID));
mt.setKeycode((String)tuple.get(MoneyTransfer.FIELD_KEYCODE));
mt.setPaymentMethod((String)tuple.get(MoneyTransfer.FIELD_PAYMENT_METHOD));
mt.setAmount_hf_sender_currency((BigDecimal)tuple.get(MoneyTransfer.FIELD_AMOUNT_HF_SENDER_CUR));
mt.setStatus((String)tuple.get(MoneyTransfer.FIELD_STATUS));
in.setBody(mt);
in.setHeader(InfinispanConstants.KEY, mt.getKeycode());
}
示例3: buildQuery
import org.apache.camel.component.infinispan.InfinispanConstants; //导入依赖的package包/类
public static Query buildQuery(InfinispanConfiguration configuration, BasicCache<Object, Object> cache, Message message) {
InfinispanQueryBuilder queryBuilder = message.getHeader(InfinispanConstants.QUERY_BUILDER, InfinispanQueryBuilder.class);
if (queryBuilder == null) {
queryBuilder = configuration.getQueryBuilder();
}
return buildQuery(queryBuilder, cache);
}
示例4: testCacheGet
import org.apache.camel.component.infinispan.InfinispanConstants; //导入依赖的package包/类
@Test
public void testCacheGet() throws Exception {
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:get")
.to("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&command=GET")
.to("mock:end");
}
});
cacheContainer.getCache().put(CACHE_KEY_NAME, CACHE_VALUE_KERMIT);
camelctx.start();
try {
Map<String, Object> headers = new HashMap<>();
headers.put(InfinispanConstants.KEY, CACHE_KEY_NAME);
ProducerTemplate template = camelctx.createProducerTemplate();
String name = template.requestBodyAndHeaders("direct:get", null, headers, String.class);
Assert.assertEquals("Kermit", name);
} finally {
camelctx.stop();
}
}
示例5: testCacheRemove
import org.apache.camel.component.infinispan.InfinispanConstants; //导入依赖的package包/类
@Test
public void testCacheRemove() throws Exception {
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:remove")
.to("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&command=REMOVE");
}
});
cacheContainer.getCache().put(CACHE_KEY_NAME, CACHE_VALUE_KERMIT);
camelctx.start();
try {
Assert.assertTrue(cacheContainer.getCache().containsKey(CACHE_KEY_NAME));
Map<String, Object> headers = new HashMap<>();
headers.put(InfinispanConstants.KEY, CACHE_KEY_NAME);
ProducerTemplate template = camelctx.createProducerTemplate();
template.requestBodyAndHeaders("direct:remove", null, headers);
Assert.assertFalse(cacheContainer.getCache().containsKey(CACHE_KEY_NAME));
} finally {
camelctx.stop();
}
}
示例6: testCacheEntryCreatedEvent
import org.apache.camel.component.infinispan.InfinispanConstants; //导入依赖的package包/类
@Test
public void testCacheEntryCreatedEvent() throws Exception {
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&sync=false&eventTypes=CACHE_ENTRY_CREATED")
.to("mock:result");
}
});
camelctx.start();
try {
cacheContainer.getCache().put(CACHE_KEY_NAME, CACHE_VALUE_KERMIT);
cacheContainer.getCache().put(CACHE_KEY_AGE, CACHE_VALUE_AGE);
MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mockEndpoint.expectedMessageCount(4);
mockEndpoint.message(0).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_CREATED");
mockEndpoint.message(0).outHeader(InfinispanConstants.IS_PRE).isEqualTo(true);
mockEndpoint.message(0).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);
mockEndpoint.message(1).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_CREATED");
mockEndpoint.message(1).outHeader(InfinispanConstants.IS_PRE).isEqualTo(false);
mockEndpoint.message(1).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);
mockEndpoint.message(2).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_CREATED");
mockEndpoint.message(2).outHeader(InfinispanConstants.IS_PRE).isEqualTo(true);
mockEndpoint.message(2).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_AGE);
mockEndpoint.message(3).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_CREATED");
mockEndpoint.message(3).outHeader(InfinispanConstants.IS_PRE).isEqualTo(false);
mockEndpoint.message(3).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_AGE);
mockEndpoint.assertIsSatisfied();
} finally {
camelctx.stop();
}
}
示例7: testCacheEntryRemovedEvent
import org.apache.camel.component.infinispan.InfinispanConstants; //导入依赖的package包/类
@Test
public void testCacheEntryRemovedEvent() throws Exception {
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&sync=false&eventTypes=CACHE_ENTRY_REMOVED")
.to("mock:result");
}
});
cacheContainer.getCache().put(CACHE_KEY_NAME, CACHE_VALUE_KERMIT);
cacheContainer.getCache().put(CACHE_KEY_AGE, CACHE_VALUE_AGE);
camelctx.start();
try {
MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mockEndpoint.expectedMessageCount(2);
mockEndpoint.message(0).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_REMOVED");
mockEndpoint.message(0).outHeader(InfinispanConstants.IS_PRE).isEqualTo(true);
mockEndpoint.message(0).outHeader(InfinispanConstants.CACHE_NAME).isNotNull();
mockEndpoint.message(0).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);
mockEndpoint.message(1).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_REMOVED");
mockEndpoint.message(1).outHeader(InfinispanConstants.IS_PRE).isEqualTo(false);
mockEndpoint.message(1).outHeader(InfinispanConstants.CACHE_NAME).isNotNull();
mockEndpoint.message(1).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);
cacheContainer.getCache().remove("name");
mockEndpoint.assertIsSatisfied();
} finally {
camelctx.stop();
}
}
示例8: testCacheEntryModifiedEvent
import org.apache.camel.component.infinispan.InfinispanConstants; //导入依赖的package包/类
@Test
public void testCacheEntryModifiedEvent() throws Exception {
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("infinispan://" + cacheName + "?cacheContainer=#" + CONTAINER_NAME + "&sync=false&eventTypes=CACHE_ENTRY_MODIFIED")
.to("mock:result");
}
});
cacheContainer.getCache().put(CACHE_KEY_NAME, CACHE_VALUE_KERMIT);
camelctx.start();
try {
MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mockEndpoint.expectedMessageCount(2);
mockEndpoint.message(0).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_MODIFIED");
mockEndpoint.message(0).outHeader(InfinispanConstants.IS_PRE).isEqualTo(true);
mockEndpoint.message(0).outHeader(InfinispanConstants.CACHE_NAME).isNotNull();
mockEndpoint.message(0).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);
mockEndpoint.message(1).outHeader(InfinispanConstants.EVENT_TYPE).isEqualTo("CACHE_ENTRY_MODIFIED");
mockEndpoint.message(1).outHeader(InfinispanConstants.IS_PRE).isEqualTo(false);
mockEndpoint.message(1).outHeader(InfinispanConstants.CACHE_NAME).isNotNull();
mockEndpoint.message(1).outHeader(InfinispanConstants.KEY).isEqualTo(CACHE_KEY_NAME);
cacheContainer.getCache().replace(CACHE_KEY_NAME, CACHE_VALUE_BOB);
mockEndpoint.assertIsSatisfied();
} finally {
camelctx.stop();
}
}