public BaseMessageFilter addRemoteMessageFilter ( BaseMessageFilter messageFilter , RemoteSession remoteSession ) throws RemoteException { BaseMessageFilter remoteFilter = messageFilter ; // The actual remote filter. messageFilter . setRegistryID ( null ) ; // The needs to be null to add this filter to the receiver. messageFilter . setFilterID ( null ) ; // The needs to be null to add this filter to the receiver. remoteFilter . setCreateRemoteFilter ( true ) ; // This must be set by the session. remoteFilter . setUpdateRemoteFilter ( true ) ; // (This is a transient field you MUST set the initial value) Utility . getLogger ( ) . info ( "EJB addRemoteMessageFilter session: " + remoteSession ) ; // Give the filter the remote environment MessageManager messageManager = ( ( Application ) this . getTask ( ) . getApplication ( ) ) . getMessageManager ( ) ; if ( remoteSession == null ) messageManager . addMessageFilter ( remoteFilter ) ; // If there was a remote session, setupRemoteSessionFilter would have added the filter. else { remoteFilter = remoteSession . setupRemoteSessionFilter ( remoteFilter ) ; // This has the effect of calling: messageFilter.linkRemoteSession(remoteSession); remoteFilter = ( ( BaseMessageReceiver ) messageManager . getMessageQueue ( remoteFilter . getQueueName ( ) , remoteFilter . getQueueType ( ) ) . getMessageReceiver ( ) ) . getMessageFilter ( remoteFilter . getFilterID ( ) ) ; // Must look it up } remoteFilter . addMessageListener ( this ) ; messageFilter . setQueueName ( remoteFilter . getQueueName ( ) ) ; // Info to pass to client. messageFilter . setQueueType ( remoteFilter . getQueueType ( ) ) ; // Info to pass to client. messageFilter . setFilterID ( remoteFilter . getFilterID ( ) ) ; // Info to pass to client. messageFilter . setRegistryID ( remoteFilter . getRegistryID ( ) ) ; return messageFilter ; // All client needs if the name/type/and ID of the remote filter. (Don't pass the remoteFilter as it's class may not be accessable to thin). }
Given a copy of the client s message filter set up a remote filter .