com.pusher.client.util
Class Factory

java.lang.Object
  extended by com.pusher.client.util.Factory

public class Factory
extends Object

This is a lightweight way of doing dependency injection and enabling classes to be unit tested in isolation. No class in this library instantiates another class directly, otherwise they would be tightly coupled. Instead, they all call the factory methods in this class when they want to create instances of another class. When unit testing we can use PowerMock to mock out the methods in this class to return mocks instead of the actual implementations. This allows us to test classes in isolation. Conventions: - any method that starts with "new", such as newPublicChannel(String) creates a new instance of that class every time it is called. - any method that starts with "get", such as getEventQueue() returns a singleton.


Constructor Summary
Factory()
           
 
Method Summary
static ChannelManager getChannelManager()
           
static InternalConnection getConnection(String apiKey, boolean encrypted)
           
static ExecutorService getEventQueue()
           
static PresenceChannelImpl newPresenceChannel(InternalConnection connection, String channelName, Authorizer authorizer)
           
static PrivateChannelImpl newPrivateChannel(InternalConnection connection, String channelName, Authorizer authorizer)
           
static ChannelImpl newPublicChannel(String channelName)
           
static URL newURL(String endPoint)
           
static WebSocketClient newWebSocketClientWrapper(URI uri, WebSocketListener proxy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Factory

public Factory()
Method Detail

getConnection

public static InternalConnection getConnection(String apiKey,
                                               boolean encrypted)

newWebSocketClientWrapper

public static WebSocketClient newWebSocketClientWrapper(URI uri,
                                                        WebSocketListener proxy)
                                                 throws SSLException
Throws:
SSLException

getEventQueue

public static ExecutorService getEventQueue()

newPublicChannel

public static ChannelImpl newPublicChannel(String channelName)

newPrivateChannel

public static PrivateChannelImpl newPrivateChannel(InternalConnection connection,
                                                   String channelName,
                                                   Authorizer authorizer)

newPresenceChannel

public static PresenceChannelImpl newPresenceChannel(InternalConnection connection,
                                                     String channelName,
                                                     Authorizer authorizer)

getChannelManager

public static ChannelManager getChannelManager()

newURL

public static URL newURL(String endPoint)
                  throws MalformedURLException
Throws:
MalformedURLException


Copyright © 2013 Pusher. All Rights Reserved.