psdi.server

Class BulletinBoardService

  • All Implemented Interfaces:
    java.rmi.Remote, MboServerInterface, MaxRemoteProxy, AppServiceRemote, BulletinBoardServiceRemote, Dependable, Service, ServiceRemote, FixedLoggerNames, FixedLoggers


    public class BulletinBoardService
    extends AppService
    implements BulletinBoardServiceRemote, Service
    BulletinBoardService is used for the communication among objects within the execution of the same thread. At most one bulletin board will exist in a MXServer. It is a service maintaining a bulletin board which allows threads to post and remove messages.

    Please note that this is not for inter-thread communication, for that purpose, please see psdi.server.SharedSpace.

    This service is not persistent. If the server hosting this service goes down, all already posted messages will be lost when the server starts up.

    Currently this service is implemented as a singleton service, which means only one MXServer in the enterprise can host the service. However, we are considering the future plan to upgrade it to be duplicated services by enabling posted messages to be broadcasted to all the bulletin boards.

    • Constructor Detail

      • BulletinBoardService

        public BulletinBoardService()
                             throws java.rmi.RemoteException
        Throws:
        java.rmi.RemoteException
      • BulletinBoardService

        public BulletinBoardService(MXServer mxServer)
                             throws java.rmi.RemoteException
        Parameters:
        mxServer - -- the "Server Environment" this Service is being created in.
        Throws:
        java.rmi.RemoteException
      • BulletinBoardService

        public BulletinBoardService(java.lang.String url,
                                    MXServer mxServer)
                             throws java.rmi.RemoteException
        Throws:
        java.rmi.RemoteException
    • Method Detail

      • post

        public void post(java.lang.String key)
        Post a message to the bulletin board. The message can be any string understood by the poster and the reader. It is recommended to contain the information of the package or object and the message itself. For example: Invoice.NOOPSYSCODE.

        The message will only be posted for this thread. If there is the same message posted by a different thread, it will be ignored. If the message is posted for the use by a method belonging to another object, which could be an rmi stub object, this method can NOT be used. Use the overloaded one post(String, UserInfo) instead.

        Method post() has to be called in pairs with remove(). One thread can post the same message at different moment for multiple time, but there should be one remove() paired up with one post() everytime when the message is posted. If exception could occur after the message is posted and before a remove() can be called, try-finally blocks need to be used to make sure remove() is guaranteed to be called.

        Example:
        MXServer.getBulletinBoard().post("Invoice.NOOPSYSCODE");
        try{
        doSomething();
        }
        finally{
        MXServer.getBulletinBoard().remove("Invoice.NOOPSYSCODE"); }

        Specified by:
        post in interface BulletinBoardServiceRemote
        Parameters:
        key - The message being posted. Key has to be different one another if they represent different meanings. It is recommended to contain the information of the package or object and the function. For example: Invoice.NOOPSYSCODE.
        See Also:
        BulletinBoardService.remove(java.lang.String)
      • post

        public void post(java.lang.String key,
                         UserInfo userInfo)
        Post a message to the bulletin board. The message can be any string understood by the poster and the reader. It is recommended to contain the information of the package or object and the message itself. For example: Invoice.NOOPSYSCODE.

        The message will only be posted for this user connection. If there is the same message posted by a different connection, it will be ignored. Method post() has to be called in pairs with remove(). One thread can post the same message at different moment for multiple time, but there should be one remove() paired up with one post() everytime when the message is posted. If exception could occur after the message is posted and before a remove() can be called, try-finally blocks need to be used to make sure remove() is guaranteed to be called.

        Example:
        MXServer.getBulletinBoard().post("Invoice.NOOPSYSCODE", UserInfo);
        try{
        doSomething();
        }
        finally{
        MXServer.getBulletinBoard().remove("Invoice.NOOPSYSCODE", UserInfo); }

        Specified by:
        post in interface BulletinBoardServiceRemote
        Parameters:
        key - The message being posted. Key has to be different one another if they represent different meanings. It is recommended to contain the information of the package or object and the function. For example: Invoice.NOOPSYSCODE.
        userInfo - The UserInfo object which contains the specific connection information. It has to be the one that the execution is performed on behalf, which has to be the same as the execution where reads and removes this message.
        See Also:
        BulletinBoardService.remove(String, UserInfo)
      • isPosted

        public boolean isPosted(java.lang.String key,
                                UserInfo userInfo)
        Check if a message is posted on the bulletin board by the same user connection. The message will be ignored if posted by another user connection. This method can only be used if the message was posted using method post(String, UserInfo) by the same connection.
        Specified by:
        isPosted in interface BulletinBoardServiceRemote
        Parameters:
        key - The message being checked. Key has to be different one another if they represent different meanings.
        userInfo - The UserInfo object which contains the specific connection information. It has to be the one that the execution is performed on behalf, which has to be the same as the execution where posts this message.
        See Also:
        BulletinBoardService.post(String, UserInfo), BulletinBoardService.remove(String, UserInfo)
      • remove

        public void remove(java.lang.String key)
        Remove one posting of the message from the bulletin board. One message can be posted by more than one objects to the bulleting board, remove method will just remove one of them. The post and remove should always be called in pairs. If exception could occur after the message is posted and before a remove() can be called, try-finally blocks need to be used to make sure remove() is guaranteed to be called. If a message is posted by calling method post(String), it has to be removed by remove(String). If it is posed by method post(String, UserInfo), it has to be removed by remove(String, UserInfo).

        Example:
        MXServer.getBulletinBoard().post("Invoice.NOOPSYSCODE");
        try{
        doSomething();
        }
        finally{
        MXServer.getBulletinBoard().remove("Invoice.NOOPSYSCODE"); }

        Specified by:
        remove in interface BulletinBoardServiceRemote
        Parameters:
        key - The message being posted. Key has to be different one another if they represent different meanings.
        userInfo - The UserInfo object which contains the specific connection information. It has to be the one that the execution is performed on behalf, which has to be the same as the execution where posts and reads this message.
        See Also:
        BulletinBoardService.post(java.lang.String)
      • remove

        public void remove(java.lang.String key,
                           UserInfo userInfo)
        Remove one posting of the message from the bulletin board. One message can be posted by more than one objects to the bulleting board, remove method will just remove one of them. The post and remove should always be called in pairs. If exception could occur after the message is posted and before a remove() can be called, try-finally blocks need to be used to make sure remove() is guaranteed to be called. If a message is posted by calling method post(String), it has to be removed by remove(String). If it is posed by method post(String, UserInfo), it has to be removed by remove(String, UserInfo).

        Example:
        MXServer.getBulletinBoard().post("Invoice.NOOPSYSCODE", UserInfo);
        try{
        doSomething();
        }
        finally{
        MXServer.getBulletinBoard().remove("Invoice.NOOPSYSCODE", UserInfo); }

        Specified by:
        remove in interface BulletinBoardServiceRemote
        Parameters:
        key - The message being posted. Key has to be different one another if they represent different meanings.
        See Also:
        BulletinBoardService.post(String, UserInfo)
      • restart

        public void restart()
        Indicates that the Service should reload any internal cache's of information it's holding.
        Specified by:
        restart in interface ServiceRemote
        Overrides:
        restart in class AppService
      • configure

        public void configure(java.util.Properties configData)
        Configuration information is presented in a Property object.
        Specified by:
        configure in interface Service
        Overrides:
        configure in class AppService
        See Also:
        Service
      • init

        public void init()
        Initialization should take place. This where long duration tasks and those that throw exceptions should take place, e.g. establishing network connections.
        Specified by:
        init in interface Service
        Overrides:
        init in class AppService
        See Also:
        Service
      • destroy

        public void destroy()
        Release system resources. The object should release all system resources. This will be called only once and is called to prepare the object for finalization.
        Specified by:
        destroy in interface Service
        Overrides:
        destroy in class AppService
        See Also:
        Service
      • setURL

        public void setURL(java.lang.String url)
        Required by ServiceRemote.
        Specified by:
        setURL in interface Service
        Overrides:
        setURL in class AppService
      • isInitialized

        public boolean isInitialized()
        Check if class has been initialized.
        Specified by:
        isInitialized in interface BulletinBoardServiceRemote
        Returns:
        True if the class has been initialized.