@Test() public void testMultiThreadedGetNonThreadSafePublisher() throws InterruptedException, ExecutionException, IOException { SharedResourcesBroker broker = SharedResourcesBrokerFactory.<SimpleScopeType>createDefaultTopLevelBroker(ConfigFactory.empty(), SimpleScopeType.GLOBAL.defaultScopeInstance()); ExecutorService service = Executors.newFixedThreadPool(40); List<Future<?>> futures = new ArrayList<>(); for (int i = 0; i < 100000; i++) { futures.add(service.submit(new GetNonThreadSafePublisher(broker))); } for (Future f: futures) { f.get(); } service.shutdown(); service.awaitTermination(100, TimeUnit.SECONDS); }
public static <S extends ScopeType<S>> DataPublisher get(String publisherClassName, State state, SharedResourcesBroker<S> broker) throws IOException { try { return broker.getSharedResource(new DataPublisherFactory<S>(), new DataPublisherKey(publisherClassName, state)); } catch (NotConfiguredException nce) { throw new IOException(nce); } }
DataPublisherFactory implements SharedResourceFactory<DataPublisher, DataPublisherKey, S> { public static <S extends ScopeType<S>> DataPublisher get(String publisherClassName, State state, SharedResourcesBroker<S> broker) throws IOException { try { return broker.getSharedResource(new DataPublisherFactory<S>(), new DataPublisherKey(publisherClassName, state)); } catch (NotConfiguredException nce) { throw new IOException(nce); } } }
DataPublisherFactory implements SharedResourceFactory<DataPublisher, DataPublisherKey, S> { public static <S extends ScopeType<S>> DataPublisher get(String publisherClassName, State state, SharedResourcesBroker<S> broker) throws IOException { try { return broker.getSharedResource(new DataPublisherFactory<S>(), new DataPublisherKey(publisherClassName, state)); } catch (NotConfiguredException nce) { throw new IOException(nce); } }  }
DataPublisherFactory implements SharedResourceFactory<DataPublisher, DataPublisherKey, S> { public static <S extends ScopeType<S>> DataPublisher get(String publisherClassName, State state, SharedResourcesBroker<S> broker) throws IOException { try { return broker.getSharedResource(new DataPublisherFactory<S>(), new DataPublisherKey(publisherClassName, state)); } catch (NotConfiguredException nce) { throw new IOException(nce); } }  static DataPublisher get(String publisherClassName, State state,
      SharedResourcesBroker<S> broker); static boolean isPublisherCacheable(DataPublisher publisher); @Override String getName(); @Override SharedResourceFactoryResponse<DataPublisher> createResource(SharedResourcesBroker<S> broker,
      ScopedConfigView<S, DataPublisherKey> config); @Override S getAutoScope(SharedResourcesBroker<S> broker, ConfigView<S, DataPublisherKey> config); }
DataPublisherFactory implements SharedResourceFactory<DataPublisher, DataPublisherKey, S> { public static <S extends ScopeType<S>> DataPublisher get(String publisherClassName, State state, SharedResourcesBroker<S> broker) throws IOException { try { return broker.getSharedResource(new DataPublisherFactory<S>(), new DataPublisherKey(publisherClassName, state)); } catch (NotConfiguredException nce) { throw new IOException(nce); } }  static DataPublisher get(String publisherClassName, State state,
      SharedResourcesBroker<S> broker); static boolean isPublisherCacheable(DataPublisher publisher); @Override String getName(); @Override SharedResourceFactoryResponse<DataPublisher> createResource(SharedResourcesBroker<S> broker,
      ScopedConfigView<S, DataPublisherKey> config); @Override S getAutoScope(SharedResourcesBroker<S> broker, ConfigView<S, DataPublisherKey> config); static final String FACTORY_NAME; }