Class Factory


  • public class Factory
    extends java.lang.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.

    An instance of Factory is provided on construction to each class which may require it, the initial factory is instantiated in the Pusher constructor, the only constructor which a library consumer should need to call directly.

    Conventions:

    - any method that starts with "new", such as newPublicChannel(String) creates a new instance of that class every time it is called.

    • Constructor Summary

      Constructors 
      Constructor Description
      Factory()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pusher.client.channel.impl.ChannelManager getChannelManager()  
      com.pusher.client.connection.impl.InternalConnection getConnection​(java.lang.String apiKey, PusherOptions options, java.util.function.Consumer<PusherEvent> eventHandler)  
      java.util.concurrent.ScheduledExecutorService getTimers()  
      com.pusher.client.channel.impl.PresenceChannelImpl newPresenceChannel​(com.pusher.client.connection.impl.InternalConnection connection, java.lang.String channelName, ChannelAuthorizer channelAuthorizer)  
      com.pusher.client.channel.impl.PrivateChannelImpl newPrivateChannel​(com.pusher.client.connection.impl.InternalConnection connection, java.lang.String channelName, ChannelAuthorizer channelAuthorizer)  
      com.pusher.client.channel.impl.PrivateEncryptedChannelImpl newPrivateEncryptedChannel​(com.pusher.client.connection.impl.InternalConnection connection, java.lang.String channelName, ChannelAuthorizer channelAuthorizer)  
      com.pusher.client.channel.impl.ChannelImpl newPublicChannel​(java.lang.String channelName)  
      InternalUser newUser​(com.pusher.client.connection.impl.InternalConnection connection, UserAuthenticator userAuthenticator)  
      com.pusher.client.connection.websocket.WebSocketClientWrapper newWebSocketClientWrapper​(java.net.URI uri, java.net.Proxy proxy, com.pusher.client.connection.websocket.WebSocketListener webSocketListener)  
      void queueOnEventThread​(java.lang.Runnable r)  
      void shutdownThreads()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • getConnection

        public com.pusher.client.connection.impl.InternalConnection getConnection​(java.lang.String apiKey,
                                                                                  PusherOptions options,
                                                                                  java.util.function.Consumer<PusherEvent> eventHandler)
      • newWebSocketClientWrapper

        public com.pusher.client.connection.websocket.WebSocketClientWrapper newWebSocketClientWrapper​(java.net.URI uri,
                                                                                                       java.net.Proxy proxy,
                                                                                                       com.pusher.client.connection.websocket.WebSocketListener webSocketListener)
                                                                                                throws javax.net.ssl.SSLException
        Throws:
        javax.net.ssl.SSLException
      • getTimers

        public java.util.concurrent.ScheduledExecutorService getTimers()
      • newPublicChannel

        public com.pusher.client.channel.impl.ChannelImpl newPublicChannel​(java.lang.String channelName)
      • newPrivateChannel

        public com.pusher.client.channel.impl.PrivateChannelImpl newPrivateChannel​(com.pusher.client.connection.impl.InternalConnection connection,
                                                                                   java.lang.String channelName,
                                                                                   ChannelAuthorizer channelAuthorizer)
      • newPrivateEncryptedChannel

        public com.pusher.client.channel.impl.PrivateEncryptedChannelImpl newPrivateEncryptedChannel​(com.pusher.client.connection.impl.InternalConnection connection,
                                                                                                     java.lang.String channelName,
                                                                                                     ChannelAuthorizer channelAuthorizer)
      • newPresenceChannel

        public com.pusher.client.channel.impl.PresenceChannelImpl newPresenceChannel​(com.pusher.client.connection.impl.InternalConnection connection,
                                                                                     java.lang.String channelName,
                                                                                     ChannelAuthorizer channelAuthorizer)
      • getChannelManager

        public com.pusher.client.channel.impl.ChannelManager getChannelManager()