Class AbstractGatewayConnection

    • Field Detail

      • REDUNDANT_MASTER

        public static final java.lang.String REDUNDANT_MASTER
      • REDUNDANT_BACKUP

        public static final java.lang.String REDUNDANT_BACKUP
      • NO_NEW_ADDRESSES

        public static final java.lang.String NO_NEW_ADDRESSES
        See Also:
        Constant Field Values
      • GET_ADDRESSES_ERROR

        public static final java.lang.String GET_ADDRESSES_ERROR
        See Also:
        Constant Field Values
      • STATUS_CONNECT_INACTIVE

        public static final int STATUS_CONNECT_INACTIVE
        See Also:
        Constant Field Values
      • STATUS_CONNECTED_INCOMPATIBLE

        public static final int STATUS_CONNECTED_INCOMPATIBLE
        See Also:
        Constant Field Values
      • LOGGER_STATUS_LOOKUP

        public static final java.util.Map<java.lang.Integer,​java.lang.String> LOGGER_STATUS_LOOKUP
        Used for internal logging ONLY. Do not use to display messages to the user, as these strings are not internationalized.
      • connectTimeout

        protected int connectTimeout
      • socketTimeout

        protected int socketTimeout
      • opcBrowseTimeout

        protected int opcBrowseTimeout
      • httpConcurrency

        protected int httpConcurrency
      • log

        protected org.apache.log4j.Logger log
      • changeSupport

        protected java.beans.PropertyChangeSupport changeSupport
      • listenerList

        protected javax.swing.event.EventListenerList listenerList
      • currentAddress

        protected HttpURL currentAddress
        The current address that we are communicating with
      • gatewayAddresses

        protected java.util.List<HttpURL> gatewayAddresses
        A list of all gateway addresses that were passed in. The client starts in independent mode and cycles thru these addresses in the fishForAliveServer() method. The addresses are used later if a version mismatch exception is thrown when reconnecting to a gateway. Redundant master and backup addresses are not maintained in this list. They are held in the potentialMasterList and potentialBackup list respectively.
      • gatewayTimeZone

        protected java.util.TimeZone gatewayTimeZone
      • gatewayNodeRole

        protected java.lang.String gatewayNodeRole
    • Constructor Detail

      • AbstractGatewayConnection

        protected AbstractGatewayConnection​(LaunchContext launchContext)
    • Method Detail

      • newGatewayInterface

        protected GatewayInterface newGatewayInterface​(HttpURL addr)
        Creates a new GatewayInterface for the given URL, settings its connect and socket timeouts appropriately
      • getScope

        protected abstract int getScope()
        Returns the scope for this connection. Used to create an accurate version hash.
      • updateMasterAddresses

        public void updateMasterAddresses​(java.util.List<HttpURL> list)
        Synchronized method
      • updateBackupAddresses

        public void updateBackupAddresses​(java.util.List<HttpURL> list)
        Synchronized method
      • fishForAliveServer

        protected void fishForAliveServer​(boolean reLogin)
                                   throws VersionMismatchException
        Synchronized method- Tests communication with known servers, and sets the gateway interface to the first gateway that in can connect to. For redundant connections, this method also sets the gateway interface to either the last known master or the last known backup in a connection failure scenario. The connection status of the master and the backup is determined in a separate thread in the RedundancyMonitorTask.
        Throws:
        VersionMismatchException
      • setGatewayInterface

        protected void setGatewayInterface​(GatewayInterface gi)
        Sets the new gateway interface, and adds this as a gateway exception listener and a push notification listener. Also updates the gateway timezone.
      • updateGatewayMetaInfo

        public void updateGatewayMetaInfo()
        Updates the gateway timezone and role info
      • getGatewayNodeRole

        public java.lang.String getGatewayNodeRole()
        Description copied from interface: GatewayConnection
        Returns the string version of the currently connected gateway's "Node Role", which will be one of:
        • Independent
        • Master
        • Backup
        Specified by:
        getGatewayNodeRole in interface GatewayConnection
      • setConnectionUp

        protected void setConnectionUp​(boolean connectionUp)
        Synchronized method
      • onVersionMismatch

        protected abstract void onVersionMismatch()
        Called when the version is detected to have changed on the gateway. Connection will be closed at this point.
      • isConnectionRelated

        public static boolean isConnectionRelated​(java.lang.Exception ex)
      • getAllAddresses

        public java.util.List<HttpURL> getAllAddresses()
        Description copied from interface: GatewayConnection
        Returns a list of all possible Gateway addresses that are known to the client. This list includes redundant master and backup addresses. The list is used for client restarts.
        Specified by:
        getAllAddresses in interface GatewayConnection
      • getGatewayWebURL

        public java.lang.String getGatewayWebURL()
        Description copied from interface: GatewayConnection
        Returns the url to the web portion of the gateway, like "http[s]://<address>:<port>[/context]"
        Specified by:
        getGatewayWebURL in interface GatewayConnection
      • getScheme

        public java.lang.String getScheme()
        Description copied from interface: GatewayConnection
        Returns "http" or "https" depending on our transport scheme
        Specified by:
        getScheme in interface GatewayConnection
      • isConnected

        public boolean isConnected()
        Whether or not we are currently supposed to be in a connected state. If this is true and connectionUp is false, then we are reconnecting
        Specified by:
        isConnected in interface GatewayConnection
      • setConnected

        protected void setConnected​(boolean connected)
      • toString

        protected java.lang.String toString​(HttpURL url)
        Returns the HttpURL with the correct security scheme, like: "https://myserver:443/ContextPath"
      • removePushNotificationListeners

        public void removePushNotificationListeners​(java.lang.Class<?> c)
        Removes all PushNotificationListeners that are of same class as the passed class.
        Specified by:
        removePushNotificationListeners in interface GatewayConnection
        Parameters:
        c - The type of listener to remove
      • firePushNotification

        protected void firePushNotification​(PushNotification n)
      • fireConnectionEvent

        protected void fireConnectionEvent​(java.lang.String messageLookup,
                                           HttpURL gatewayAddr,
                                           boolean appendGatewayAddr)
        Overloaded method to allow a gateway's connection status to be updated. A BundleUtil lookup is made to get the actual string from the passed lookup. Be sure that the actual string returned from lookup contains at least one '%s' to display the gateway address. This method will also update the internal masterConnectionStatus and backupConnectionStatus variables for redundant systems, and the connectionStatus variable for independent systems.
      • fireConnectionEvent

        protected void fireConnectionEvent​(java.lang.String messageLookup,
                                           HttpURL gatewayAddr,
                                           java.lang.Exception ex,
                                           boolean appendGatewayAddr)
        Overloaded method to allow a gateway's connection status to be updated. A BundleUtil lookup is made to get the actual string from the passed lookup. Be sure that the actual string returned from lookup contains at least one '%s' to display the gateway address. This method will also update the internal masterConnectionStatus and backupConnectionStatus variables for redundant systems, and the connectionStatus variable for independent systems.
        Parameters:
        messageLookup - the String to pass to BundleUtil.get(), such as "GatewayConnectionManager.TestingWith"
        gatewayAddr - the Gateway HttpURL used in the connection event
        ex - exception that has just occurred. Pass in null if there were no exceptions thrown.
      • fireConnectionEvent

        protected void fireConnectionEvent​(java.lang.String message)
      • isLoggedIn

        public boolean isLoggedIn()
      • getProjectName

        public java.lang.String getProjectName()
        Description copied from interface: GatewayConnection
        The name of the project that we are currently logged into, if any.
        Specified by:
        getProjectName in interface GatewayConnection
      • getRoles

        public java.util.List<java.lang.String> getRoles()
        Description copied from interface: GatewayConnection
        The set of roles that the actively logged in user has, if any.
        Specified by:
        getRoles in interface GatewayConnection
      • getSecurityZones

        public java.util.List<java.lang.String> getSecurityZones()
        Description copied from interface: GatewayConnection
        The set of security zones that the actively logged in user has, if any.
        Specified by:
        getSecurityZones in interface GatewayConnection
      • setProjectName

        protected void setProjectName​(java.lang.String projectName)
      • addConnectionStatusListener

        public void addConnectionStatusListener​(ConnectionStatusListener listener)
        Description copied from interface: GatewayConnection
        Different from the ConnectionListener in the sense that this listener is intended for use in redundant setups, where the status of the inactive connection must be updated along with the status of the active connection. The passed ConnectionStatusListener will be continually updated with master/independent and backup connection status every few seconds.
        Specified by:
        addConnectionStatusListener in interface GatewayConnection
      • triggerConnectionStatusListeners

        public void triggerConnectionStatusListeners()
        Description copied from interface: GatewayConnection
        Manually update the status of all connection listeners. Use this in situations where listeners need an immediate update without waiting for the normal thread task to fire (such as when first displaying a status panel).
        Specified by:
        triggerConnectionStatusListeners in interface GatewayConnection