Class EventProxyFactory<T>

  • Type Parameters:
    T - annotated interface


    public class EventProxyFactory<T>
    extends java.lang.Object
    Factory class for creating "EventProxy" objects.

    EventProxy is object that represents "callable" object in D2000 (Event, Schema or JAPI Session). EventProxy implements an user defined interface annotated with annotations from sk.ipesoft.d2000.d2japi.annotations.eventBinding package. Its implementation transforms method calls to RPC and SBA calls.

    EventProxy instance is associated with one JAPI Session instance - the one passed to one of create or createDefault methods. All RPC and SBA calls are send from associated session.

    RPC and SBA calls made via certain EventProxy instance are all addressed to D2000 callable object identified by:

    ProcessHOBJ
    HOBJ of EventHandler process, HI process, JAPI Session.
    ObjectHOBJ
    HOBJ of Event or Schema. Use 0 in case of JAPI Session.
    InstanceID
    Number of instance, default is 0.

    HOBJs of process and object can be obtained from optional attribute of annotation Event.name(). If provided, the name is resolved to HOBJ of object. When name of D2000 Event is provided, its parent HOBJ is used as HOBJ of process. When name of D2000 Schema is provided only HOBJ of object is usable.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T create​(int processHobj, int objectHobj, int instanceId, D2Session session)
      Create new instance of EventProxy.
      T create​(int processHobj, int instanceId, D2Session session)
      Create new instance of EventProxy.
      T create​(int processHobj, D2Session session)
      Create new instance of EventProxy.
      T create​(java.lang.String processName, int instanceId, D2Session session)
      Create new instance of EventProxy synchronously.
      T create​(java.lang.String processName, java.lang.String objectName, int instanceId, D2Session session)
      Create new instance of EventProxy.
      T create​(java.lang.String processName, D2Session session)
      Create new instance of EventProxy synchronously.
      FutureEvent<T> createAsync​(java.lang.String processName, int instanceId, D2Session session)
      Create new instance of EventProxy asynchronously.
      FutureEvent<T> createAsync​(java.lang.String processName, D2Session session)
      Create new instance of EventProxy asynchronously.
      T createDefault​(java.lang.String objectName, D2Session session)
      Create new instance of EventProxy synchronously.
      T createDefault​(D2Session session)
      Create new instance of EventProxy.
      FutureEvent<T> createDefaultAsync​(java.lang.String objectName, D2Session session)
      Create new instance of EventProxy asynchronously.
      static <T> EventProxyFactory<T> createFactory​(java.lang.Class<T> type, D2Session session)
      Create instance of EventProxyFactory that would create instances implementing T interface.
      static <T> EventProxyFactory<T> createFactory​(java.lang.Class<T> type, D2Session session, UnivalConvertor convertor)
      Create instance of EventProxyFactory that would create instances implementing T interface.
      • Methods inherited from class java.lang.Object

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

      • createFactory

        public static <T> EventProxyFactory<T> createFactory​(java.lang.Class<T> type,
                                                             D2Session session)
                                                      throws java.util.concurrent.ExecutionException,
                                                             java.lang.InterruptedException
        Create instance of EventProxyFactory that would create instances implementing T interface. Use default instance of UnivalConvertor of session's connector.
        Type Parameters:
        T - annotated interface
        Parameters:
        type - reference to the type of annotated interface
        session - connected JAPI Session object used for resolving D2000 names to HOBJ. It can be different than one passed to any of create and createDefault methods, but MUST be connected to the same D2000 kernel.
        Returns:
        new instance of EventProxyFactory
        Throws:
        java.util.concurrent.ExecutionException - encapsulates exception thrown by JAPI Session
        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> EventProxyFactory<T> createFactory​(java.lang.Class<T> type,
                                                             D2Session session,
                                                             UnivalConvertor convertor)
                                                      throws java.util.concurrent.ExecutionException,
                                                             java.lang.InterruptedException
        Create instance of EventProxyFactory that would create instances implementing T interface. Use custom instance of UnivalConvertor.
        Type Parameters:
        T - annotated interface
        Parameters:
        type - reference to the type of annotated interface
        session - connected JAPI Session object used for resolving D2000 names to HOBJ. It can be different than one passed to any of create and createDefault methods, 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 EventProxyFactory
        Throws:
        java.util.concurrent.ExecutionException - encapsulates exception thrown by JAPI Session
        java.lang.InterruptedException - thrown when interrupted during waiting for result of JAPI Session requests
        java.lang.IllegalArgumentException - when type is annotated incorrectly
      • createDefault

        public T createDefault​(D2Session session)
        Create new instance of EventProxy. Use ObjectHOBJ and ProcessHOBJ derived from Event.name() and InstanceID set to 0.
        Parameters:
        session - associate session
        Returns:
        new instance of EventProxy
      • createDefault

        public T createDefault​(java.lang.String objectName,
                               D2Session session)
                        throws java.lang.InterruptedException,
                               java.util.concurrent.ExecutionException
        Create new instance of EventProxy synchronously. Use ObjectHOBJ and ProcessHOBJ derived from objectName parameter and InstanceID set to 0.
        Parameters:
        objectName - name of D2000 callable object.
        session - associate session
        Returns:
        new instance of EventProxy
        Throws:
        java.lang.InterruptedException - thrown when interrupted during resolving objectName
        java.util.concurrent.ExecutionException - thrown when JAPI session throws exception during resolving objectName
      • createDefaultAsync

        public FutureEvent<T> createDefaultAsync​(java.lang.String objectName,
                                                 D2Session session)
        Create new instance of EventProxy asynchronously. Use ObjectHOBJ and ProcessHOBJ derived from objectName parameter and InstanceID set to 0.
        Parameters:
        objectName - name of D2000 callable object.
        session - associate session
        Returns:
        new instance of EventProxy
      • create

        public T create​(java.lang.String processName,
                        D2Session session)
                 throws java.lang.InterruptedException,
                        java.util.concurrent.ExecutionException
        Create new instance of EventProxy synchronously. Use ObjectHOBJ derived from Event.name(), ProcessHOBJ derived from processName parameter and InstanceID set to 0.
        Parameters:
        processName - name D2000 process
        session - associate session
        Returns:
        new instance of EventProxy
        Throws:
        java.lang.InterruptedException - thrown when interrupted during resolving objectName
        java.util.concurrent.ExecutionException - thrown when JAPI session throws exception during resolving objectName
      • createAsync

        public FutureEvent<T> createAsync​(java.lang.String processName,
                                          D2Session session)
        Create new instance of EventProxy asynchronously. Use ObjectHOBJ derived from Event.name(), ProcessHOBJ derived from processName parameter and InstanceID set to 0.
        Parameters:
        processName - name D2000 process
        session - associate session
        Returns:
        new instance of EventProxy
      • create

        public T create​(int processHobj,
                        D2Session session)
        Create new instance of EventProxy. Use ObjectHOBJ derived from Event.name(), ProcessHOBJ passed in processHobj parameter InstanceID set to 0.
        Parameters:
        processHobj - HOBJ of D2000 process
        session - associate session
        Returns:
        new instance of EventProxy
      • create

        public T create​(java.lang.String processName,
                        int instanceId,
                        D2Session session)
                 throws java.lang.InterruptedException,
                        java.util.concurrent.ExecutionException
        Create new instance of EventProxy synchronously. Use ObjectHOBJ derived from Event.name(), ProcessHOBJ derived from processName parameter and InstanceID passed in instanceId parameter.
        Parameters:
        processName - name D2000 process
        instanceId - ID of callable object instance
        session - associate session
        Returns:
        new instance of EventProxy
        Throws:
        java.lang.InterruptedException - thrown when interrupted during resolving objectName
        java.util.concurrent.ExecutionException - thrown when JAPI session throws exception during resolving objectName
      • createAsync

        public FutureEvent<T> createAsync​(java.lang.String processName,
                                          int instanceId,
                                          D2Session session)
        Create new instance of EventProxy asynchronously. Use ObjectHOBJ derived from Event.name(), ProcessHOBJ derived from processName parameter and InstanceID passed in instanceId parameter.
        Parameters:
        processName - name D2000 process
        instanceId - ID of callable object instance
        session - associate session
        Returns:
        new instance of EventProxy
      • create

        public T create​(int processHobj,
                        int instanceId,
                        D2Session session)
        Create new instance of EventProxy. Use ObjectHOBJ derived from Event.name(), ProcessHOBJ passed in processHobj parameter and InstanceID passed in instanceId parameter.
        Parameters:
        processHobj - HOBJ of D2000 process
        instanceId - ID of callable object instance
        session - associate session
        Returns:
        new instance of EventProxy
      • create

        public T create​(java.lang.String processName,
                        java.lang.String objectName,
                        int instanceId,
                        D2Session session)
                 throws java.lang.InterruptedException,
                        java.util.concurrent.ExecutionException
        Create new instance of EventProxy. Use ObjectHOBJ derived from objectName parameter, ProcessHOBJ derived from processName parameter and InstanceID passed in instanceId parameter.
        Parameters:
        processName - name of D2000 process
        objectName - name of D2000 callable object
        instanceId - ID of callable object instance
        session - associate session
        Returns:
        new instance of EventProxy
        Throws:
        java.lang.InterruptedException - thrown when interrupted during resolving objectName and processName
        java.util.concurrent.ExecutionException - thrown when JAPI session throws exception during resolving objectName and processName
      • create

        public T create​(int processHobj,
                        int objectHobj,
                        int instanceId,
                        D2Session session)
        Create new instance of EventProxy. Use ObjectHOBJ passed in objectName parameter, ProcessHOBJ passed in processName parameter and InstanceID passed in instanceId parameter.
        Parameters:
        processHobj - HOBJ of D2000 process
        objectHobj - HOBJ of D2000 callable object
        instanceId - ID of callable object instance
        session - associate session
        Returns:
        new instance of EventProxy