当前位置: 首页>>代码示例>>Java>>正文


Java RemoteCache.addClientListener方法代码示例

本文整理汇总了Java中org.infinispan.client.hotrod.RemoteCache.addClientListener方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteCache.addClientListener方法的具体用法?Java RemoteCache.addClientListener怎么用?Java RemoteCache.addClientListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.infinispan.client.hotrod.RemoteCache的用法示例。


在下文中一共展示了RemoteCache.addClientListener方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
@Override
public InfinispanEventListener start(InfinispanConsumer consumer) {
    if (consumer.getConfiguration().isSync()) {
        throw new UnsupportedOperationException("Sync listeners not supported for remote caches.");
    }
    RemoteCache<?, ?> remoteCache = InfinispanUtil.asRemote(consumer.getCache());
    InfinispanConfiguration configuration = consumer.getConfiguration();
    InfinispanEventListener listener;
    if (configuration.hasCustomListener()) {
        listener = configuration.getCustomListener();
        listener.setInfinispanConsumer(consumer);
    } else {
        listener = new InfinispanRemoteEventListener(consumer, configuration.getEventTypes());
    }
    remoteCache.addClientListener(listener);
    listener.setCacheName(remoteCache.getName());
    return listener;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:InfinispanConsumerRemoteHandler.java

示例2: main

import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
   // Create a configuration for a locally-running server
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.addServer().host("127.0.0.1").port(ConfigurationProperties.DEFAULT_HOTROD_PORT);
   // Connect to the server
   RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
   // Obtain the remote cache
   RemoteCache<String, String> cache = cacheManager.getCache();
   // Register a listener
   MyListener listener = new MyListener();
   cache.addClientListener(listener);
   // Store some values
   cache.put("key1", "value1");
   cache.put("key2", "value2");
   cache.put("key1", "newValue");
   // Remote events are asynchronous, so wait a bit
   Thread.sleep(1000);
   // Remove listener
   cache.removeClientListener(listener);
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:23,代码来源:InfinispanRemoteListen.java

示例3: main

import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) {
	// Create a configuration for a locally-running server
	ConfigurationBuilder builder = new ConfigurationBuilder();

	
	int BeosBankCacheAfricaPort = 11322;
	builder.addServer().host("127.0.0.1").port(BeosBankCacheAfricaPort);
	// Connect to the server
	RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
	// Obtain the remote cache
	RemoteCache<String, Object> cache = cacheManager.getCache("beosbank-repl");
	cache.addClientListener(new DatagridClientListener());
	// Create a Money Transfer Object from XML Message using BeaoIO API
	try {
		StreamFactory factory = StreamFactory.newInstance();
		factory.loadResource("mapping.xml");
		Unmarshaller unmarshaller = factory.createUnmarshaller("MoneyTransferStream");

		String record;

		// Read Transactions and put in cache
		for (String inputFile : inputFileNames) {
			record = FileUtils.getContentsAsString(new File(INPUT_DIR + inputFile));
			MoneyTransfert mt = (MoneyTransfert) unmarshaller.unmarshal(record);
			cache.put(mt.getId() + "", mt);
		}

		// Inspect the cache .
		System.out.println(cache.size());
		System.out.println(cache.get("3"));

		// Stop the cache
		cache.stop();

	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
开发者ID:PacktPublishing,项目名称:JBoss-Developers-Guide,代码行数:41,代码来源:ReplicatedCacheClusterDemo.java

示例4: main

import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) {
	// Create a configuration for a locally-running server
	ConfigurationBuilder builder = new ConfigurationBuilder();
	int BeosBankCacheAfricaPort = 11322;
	builder.addServer().host("127.0.0.1").port(BeosBankCacheAfricaPort);
	// Connect to the server
	RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
	// Obtain the remote cache
	RemoteCache<String, Object> cache = cacheManager.getCache();
	cache.addClientListener(new DatagridClientListener());

	// Create a Money Transfer Object from XML Message using BeaoIO API
	try {
		StreamFactory factory = StreamFactory.newInstance();
		factory.loadResource("mapping.xml");
		Unmarshaller unmarshaller = factory.createUnmarshaller("MoneyTransferStream");

		String record;

		// Read Transactions and put in cache
		for (String inputFile : inputFileNames) {
			record = FileUtils.getContentsAsString(new File(INPUT_DIR + inputFile));
			MoneyTransfert mt = (MoneyTransfert) unmarshaller.unmarshal(record);
			cache.put(mt.getId() + "", mt);
		}

		// Inspect the cache .
		System.out.println(cache.size());
		System.out.println(cache.get("3"));

		// Stop the cache
		cache.stop();

	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
开发者ID:PacktPublishing,项目名称:JBoss-Developers-Guide,代码行数:40,代码来源:RemoteCacheClusterDemo.java

示例5: main

import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) {
	// Create a configuration for a locally-running server
	ConfigurationBuilder builder = new ConfigurationBuilder();
	builder.addServer().host("127.0.0.1").port(ConfigurationProperties.DEFAULT_HOTROD_PORT);
	// Connect to the server
	RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
	// Obtain the remote cache
	RemoteCache<String, Object> cache = cacheManager.getCache();
	cache.addClientListener(new DatagridClientListener());

	// Create a Money Transfer Object from XML Message using BeaoIO API
	try {
		StreamFactory factory = StreamFactory.newInstance();
		factory.loadResource("mapping.xml");
		Unmarshaller unmarshaller = factory.createUnmarshaller("MoneyTransferStream");

		String record;

		// Read Transactions and put in cache
		for (String inputFile : inputFileNames) {
			record = FileUtils.getContentsAsString(new File(INPUT_DIR + inputFile));
			MoneyTransfert mt = (MoneyTransfert) unmarshaller.unmarshal(record);
			cache.put(mt.getId() + "", mt);
		}

		// Inspect the cache .
		System.out.println(cache.size());
		System.out.println(cache.get("3"));

		// Stop the cache
		cache.stop();

	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
开发者ID:PacktPublishing,项目名称:JBoss-Developers-Guide,代码行数:39,代码来源:RemoteCacheDemo.java

示例6: main

import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.addServer().host(ISPN_IP).port(ConfigurationProperties.DEFAULT_HOTROD_PORT);
    RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
    RemoteCache<String, byte[]> cacheImg = cacheManager.getCache(IMAGE_CACHE_NAME);
    RemoteCache<String, String> jpgCache = cacheManager.getCache(JPG_CACHE_NAME);
    RemoteCache<String, String> resultCache = cacheManager.getCache(RESULT_CACHE_NAME);
    cacheImg.addClientListener(new MnistListener(MODEL_PATH, CHECKPOINT_PATH, jpgCache, resultCache));

    System.out.printf("Client will be listening for %d minutes\n", DURATION);
    Thread.sleep(TimeUnit.MINUTES.toMillis(DURATION));

    cacheManager.stop();
}
 
开发者ID:infinispan-demos,项目名称:tf-ispn-demo,代码行数:15,代码来源:MnistClassifier.java

示例7: execute

import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
@Override
public void execute(String restOfTheLine) throws Exception {

    RemoteCache defaultCache = insureConnected();

    //noinspection unchecked
    Set<Object> listeners = defaultCache.getListeners();

    if (!listeners.isEmpty()) {
        throw new UserErrorException("a listener has been already registered");
    }

    defaultCache.addClientListener(new CacheClientListener());
    //defaultCache.addClientListener(new StatisticsEnabledCacheClientListener());
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:16,代码来源:Listen.java

示例8: main

import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) {
// Create a configuration for a locally-running server
		ConfigurationBuilder builder = new ConfigurationBuilder();
	
		
		int BeosBankCacheAfricaPort = 11322;
		builder.addServer().host("127.0.0.1").port(BeosBankCacheAfricaPort);
		// Connect to the server
		RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
		// Obtain the remote cache
		RemoteCache<String, Object> cache = cacheManager.getCache("beosbank-repl");
		cache.addClientListener(new DatagridClientListener());

		// Create a Money Transfer Object from XML Message using BeaoIO API
		try {
			StreamFactory factory = StreamFactory.newInstance();
			factory.loadResource("mapping.xml");
			Unmarshaller unmarshaller = factory.createUnmarshaller("MoneyTransferStream");

			String record;

			// Read Transactions and put in cache
			for (String inputFile : inputFileNames) {
				record = FileUtils.getContentsAsString(new File(INPUT_DIR + inputFile));
				MoneyTransfert mt = (MoneyTransfert) unmarshaller.unmarshal(record);
				cache.put(mt.getId() + "", mt);
			}

			// Inspect the cache .
			System.out.println(cache.size());
			System.out.println(cache.get("3"));

			// Stop the cache
			cache.stop();

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
 
开发者ID:PacktPublishing,项目名称:JBoss-Developers-Guide,代码行数:42,代码来源:ReplicatedCacheClusterDemo2.java

示例9: main

import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) {
	// Create a configuration for a locally-running server
	ConfigurationBuilder builder = new ConfigurationBuilder();

	
	int BeosBankCacheAfricaPort = 11322;
	builder.addServer().host("127.0.0.1").port(BeosBankCacheAfricaPort);
	// Connect to the server
	RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
	// Obtain the remote cache
	RemoteCache<String, Object> cache = cacheManager.getCache("beosbank-repl");
	cache.addClientListener(new DatagridClientListener());

	// Create a Money Transfer Object from XML Message using BeaoIO API
	try {
		StreamFactory factory = StreamFactory.newInstance();
		factory.loadResource("mapping.xml");
		Unmarshaller unmarshaller = factory.createUnmarshaller("MoneyTransferStream");

		String record;

		// Read Transactions and put in cache
		for (String inputFile : inputFileNames) {
			record = FileUtils.getContentsAsString(new File(INPUT_DIR + inputFile));
			MoneyTransfert mt = (MoneyTransfert) unmarshaller.unmarshal(record);
			cache.put(mt.getId() + "", mt);
		}

		// Inspect the cache .
		System.out.println(cache.size());
		System.out.println(cache.get("3"));

		// Stop the cache
		cache.stop();

	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
开发者ID:PacktPublishing,项目名称:JBoss-Developers-Guide,代码行数:42,代码来源:ReplicatedCacheClusterDemo.java


注:本文中的org.infinispan.client.hotrod.RemoteCache.addClientListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。