/** * Is the publisher cacheable in the SharedResourcesBroker? * @param publisher * @return true if cacheable, else false */ public static boolean isPublisherCacheable(DataPublisher publisher) { // only threadsafe publishers are cacheable. non-threadsafe publishers are marked immediately for invalidation return publisher.supportsCapability(Capability.THREADSAFE, Collections.EMPTY_MAP); }
@Test public void testGetNonThreadSafePublisher() throws IOException { SharedResourcesBroker broker = SharedResourcesBrokerFactory.<SimpleScopeType>createDefaultTopLevelBroker(ConfigFactory.empty(), SimpleScopeType.GLOBAL.defaultScopeInstance()); DataPublisher publisher1 = DataPublisherFactory.get(TestNonThreadsafeDataPublisher.class.getName(), null, broker); DataPublisher publisher2 = DataPublisherFactory.get(TestNonThreadsafeDataPublisher.class.getName(), null, broker); // should get different publishers Assert.assertNotEquals(publisher1, publisher2); // Check capabilities Assert.assertTrue(publisher1.supportsCapability(DataPublisher.REUSABLE, Collections.EMPTY_MAP)); Assert.assertFalse(publisher1.supportsCapability(Capability.THREADSAFE, Collections.EMPTY_MAP)); }
/** * Is the publisher cacheable in the SharedResourcesBroker? * @param publisher * @return true if cacheable, else false */ public static boolean isPublisherCacheable(DataPublisher publisher) { // only threadsafe publishers are cacheable. non-threadsafe publishers are marked immediately for invalidation return publisher.supportsCapability(Capability.THREADSAFE, Collections.EMPTY_MAP); }