Class EventWrapperFactory<T>

  • Type Parameters:
    T - annotated type of user-defined handler


    public class EventWrapperFactory<T>
    extends java.lang.Object
    Factory class for creating and registering "EventWrapper" objects within a JAPI Sessions.

    EventWrapper is object that wraps user-defined handler annotated with annotations from sk.ipesoft.d2000.d2japi.annotations.eventBinding package. It is registered in JAPI Session for handling incoming RPC and SBA calls and it transforms them into calls to user-defined handler.

    • Method Detail

      • createFactory

        public static <T> EventWrapperFactory<T> createFactory​(java.lang.Class<T> type,
                                                               D2Session session)
                                                        throws java.lang.InterruptedException,
                                                               java.util.concurrent.ExecutionException
        Create new EventWrapperFactory instance for annotated T type. Use default instance of UnivalConvertor of session's connector.
        Type Parameters:
        T - annotated type of user-defined handler
        Parameters:
        type - Reference to T type
        session - connected JAPI Session object used for resolving D2000 names to HOBJ. It can be different than one passed to registerNewHandler(D2Session, Object) method, but MUST be connected to the same D2000 kernel.
        Returns:
        new instance of EventWrapperFactory
        Throws:
        java.util.concurrent.ExecutionException - throw when error occurs during name resolution
        java.lang.InterruptedException - thrown when interrupted during waiting for result of JAPI Session requests
        java.lang.IllegalArgumentException - when type is annotated incorrectly
      • createFactory

        public static <T> EventWrapperFactory<T> createFactory​(java.lang.Class<T> type,
                                                               D2Session session,
                                                               UnivalConvertor convertor)
                                                        throws java.lang.InterruptedException,
                                                               java.util.concurrent.ExecutionException
        Create new EventWrapperFactory instance for annotated T type. Use custom instance of UnivalConvertor.
        Type Parameters:
        T - annotated type of user-defined handler
        Parameters:
        type - Reference to T type
        session - connected JAPI Session object used for resolving D2000 names to HOBJ. It can be different than one passed to registerNewHandler(D2Session, Object) method, but MUST be connected to the same D2000 kernel.
        convertor - instance of UnivalConvertor, could be shared by several factories to improve performance
        Returns:
        new instance of EventWrapperFactory
        Throws:
        java.util.concurrent.ExecutionException - throw when error occurs during name resolution
        java.lang.InterruptedException - thrown when interrupted during waiting for result of JAPI Session requests
        java.lang.IllegalArgumentException - when type is annotated incorrectly
      • registerNewHandler

        public void registerNewHandler​(D2Session session,
                                       T handler)
        Create new instance of EventWrapper and register it in session for handling incoming RPC and SBA calls.
        Parameters:
        session - JAPI session for registration
        handler - user-defined handler that new EventWrapper wraps