@Test public void getConnectionFactoryByApi() { ConnectionFactory<TestTwitterApi> connectionFactory = connectionFactoryLocator.getConnectionFactory(TestTwitterApi.class); assertSame(twitterConnectionFactory, connectionFactory); assertEquals("twitter", connectionFactory.getProviderId()); }
public ConnectionFactory<?> getConnectionFactory(String providerId) { ConnectionFactory<?> connectionFactory = connectionFactories.get(providerId); if (connectionFactory == null) { throw new IllegalArgumentException("No connection factory for service provider '" + providerId + "' is registered"); } return connectionFactory; }
ConnectionFactoryRegistry implements ConnectionFactoryLocator { public ConnectionFactory<?> getConnectionFactory(String providerId) { ConnectionFactory<?> connectionFactory = connectionFactories.get(providerId); if (connectionFactory == null) { throw new IllegalArgumentException("No connection factory for service provider '" + providerId + "' is registered"); } return connectionFactory; } }
ConnectionFactoryRegistry implements ConnectionFactoryLocator { public ConnectionFactory<?> getConnectionFactory(String providerId) { ConnectionFactory<?> connectionFactory = connectionFactories.get(providerId); if (connectionFactory == null) { throw new IllegalArgumentException("No connection factory for service provider '" + providerId + "' is registered"); } return connectionFactory; }  }
ConnectionFactoryRegistry implements ConnectionFactoryLocator { public ConnectionFactory<?> getConnectionFactory(String providerId) { ConnectionFactory<?> connectionFactory = connectionFactories.get(providerId); if (connectionFactory == null) { throw new IllegalArgumentException("No connection factory for service provider '" + providerId + "' is registered"); } return connectionFactory; }  void addConnectionFactory(ConnectionFactory<?> connectionFactory); void setConnectionFactories(List<ConnectionFactory<?>> connectionFactories); ConnectionFactory<?> getConnectionFactory(String providerId); @SuppressWarnings("unchecked") ConnectionFactory<A> getConnectionFactory(Class<A> apiType); Set<String> registeredProviderIds(); }
ConnectionFactoryRegistry implements ConnectionFactoryLocator { public ConnectionFactory<?> getConnectionFactory(String providerId) { ConnectionFactory<?> connectionFactory = connectionFactories.get(providerId); if (connectionFactory == null) { throw new IllegalArgumentException("No connection factory for service provider '" + providerId + "' is registered"); } return connectionFactory; }  void addConnectionFactory(ConnectionFactory<?> connectionFactory); void setConnectionFactories(List<ConnectionFactory<?>> connectionFactories); ConnectionFactory<?> getConnectionFactory(String providerId); @SuppressWarnings("unchecked") ConnectionFactory<A> getConnectionFactory(Class<A> apiType); Set<String> registeredProviderIds();  }