Class AbstractServiceChannel

  • All Implemented Interfaces:
    com.anaptecs.jeaf.core.servicechannel.api.ServiceChannel
    Direct Known Subclasses:
    JSEServiceChannel, LocalServiceChannelImpl

    public abstract class AbstractServiceChannel
    extends java.lang.Object
    implements com.anaptecs.jeaf.core.servicechannel.api.ServiceChannel
    This class is an abstract implementation of a JEAF service channel. Therefore it already provides all mechanisms for calls of services. However this class does not provide any platform specific mechanisms. This has to be provide by concrete implementations.
    Version:
    1.0
    Author:
    JEAF Development Team
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.anaptecs.jeaf.core.servicechannel.api.LifecycleManager lifecycleManager
      Reference to lifecycle manager.
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractServiceChannel​(com.anaptecs.jeaf.core.servicechannel.api.LifecycleManager pLifecycleManager)
      Initialize object.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract com.anaptecs.jeaf.core.api.ServiceInvocationContext createServiceInvocationContext​(java.lang.Class<? extends com.anaptecs.jeaf.core.api.Service> pTargetServiceClass, com.anaptecs.jeaf.core.api.Component pComponent, com.anaptecs.jeaf.xfun.api.info.ApplicationInfo pInvokingApplication, com.anaptecs.jeaf.core.api.SessionContext pSessionContext)
      Method creates a new instance of a service invocation context object.
      protected abstract com.anaptecs.jeaf.core.api.TxContext createTxContext()
      Method will be called in order to tell the concrete service channel implementation that a new transaction context has to be created.
      protected java.io.Serializable invokeService​(com.anaptecs.jeaf.core.servicechannel.api.Command pCommand, com.anaptecs.jeaf.core.spi.TransactionBehavior pTransactionBehavior)
      Method executes the passed command as a local service call.
      protected com.anaptecs.jeaf.xfun.api.health.HealthCheckResult performServiceCheck​(java.lang.Class<? extends com.anaptecs.jeaf.core.api.Service> pServiceClass, com.anaptecs.jeaf.xfun.api.health.CheckLevel pCheckLevel)
      Method checks the state of the passed service.
      protected abstract void releasingTxContext​(com.anaptecs.jeaf.core.api.TxContext pTxContext)
      Method will be called whenever a previously created transaction context is about to be released.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface com.anaptecs.jeaf.core.servicechannel.api.ServiceChannel

        checkService, executeCommandTxMandatory, executeCommandTxNever, executeCommandTxNotSupported, executeCommandTxRequired, executeCommandTxRequiresNew, executeCommandTxSupports
    • Field Detail

      • lifecycleManager

        protected final com.anaptecs.jeaf.core.servicechannel.api.LifecycleManager lifecycleManager
        Reference to lifecycle manager.
    • Constructor Detail

      • AbstractServiceChannel

        public AbstractServiceChannel​(com.anaptecs.jeaf.core.servicechannel.api.LifecycleManager pLifecycleManager)
        Initialize object. Thereby all global interceptors will be created.
        Parameters:
        pLifecycleManager - Lifecycle manager to which this service channel belongs to. The parameter must not be null.
    • Method Detail

      • createServiceInvocationContext

        protected abstract com.anaptecs.jeaf.core.api.ServiceInvocationContext createServiceInvocationContext​(java.lang.Class<? extends com.anaptecs.jeaf.core.api.Service> pTargetServiceClass,
                                                                                                              com.anaptecs.jeaf.core.api.Component pComponent,
                                                                                                              com.anaptecs.jeaf.xfun.api.info.ApplicationInfo pInvokingApplication,
                                                                                                              com.anaptecs.jeaf.core.api.SessionContext pSessionContext)
        Method creates a new instance of a service invocation context object. The method has to return a new instance for every call. There must not be any kind of pooling of invocation context objects.
        Parameters:
        pTargetServiceClass - Class object of service interface that is called. The parameter must not be null.
        pComponent - Component to which the represented service call belongs to. The parameter must not be null.
        pInvokingApplication - Information about the invoking application. The parameter must not be null.
        Returns:
        ServiceInvocationContext Created service invocation context object. The method must not return null.
      • createTxContext

        protected abstract com.anaptecs.jeaf.core.api.TxContext createTxContext()
        Method will be called in order to tell the concrete service channel implementation that a new transaction context has to be created. This could depending on the platform also mean that a new transaction has to be started. The returned transaction context represents the created transaction.
        Returns:
        TxContext Created transaction context object. The method must not return null.
      • releasingTxContext

        protected abstract void releasingTxContext​(com.anaptecs.jeaf.core.api.TxContext pTxContext)
        Method will be called whenever a previously created transaction context is about to be released. This means depending on the transactions state that is will either be committed or rolled back (see TxContext.getRollbackOnly()). It depends on the concrete implementation of the service channel, whether actions have to performed or not. The method will be called before the transaction context will be released and become invalid.
        Parameters:
        pTxContext - Transaction context that will be release. The parameter is never null.
      • invokeService

        protected final java.io.Serializable invokeService​(com.anaptecs.jeaf.core.servicechannel.api.Command pCommand,
                                                           com.anaptecs.jeaf.core.spi.TransactionBehavior pTransactionBehavior)
                                                    throws com.anaptecs.jeaf.xfun.api.errorhandling.ApplicationException,
                                                           com.anaptecs.jeaf.xfun.api.errorhandling.SystemException
        Method executes the passed command as a local service call. The command will be sent to the service instance that is stored in the service registry of this JVM. The method also handles the appropriate transaction handling for the service to execute.
        Parameters:
        pCommand - Command object that should be executed. The command objects contains all parameters that are required to perform the corresponding service call. The parameter must not be null.
        pTransactionBehavior - Transaction behavior that is used for the current service call. The parameter is passed for information only. This means it is required in order to publish the current transactional behavior to service implementations through the service invocation context. The parameter must not be null.
        Returns:
        Serializable Result of the command execution. The method may return null.
        Throws:
        com.anaptecs.jeaf.xfun.api.errorhandling.ApplicationException - Services may throw an ApplicationException in order to indicate an application specific problem.The current transaction will not be automatically roll backed.
        com.anaptecs.jeaf.xfun.api.errorhandling.SystemException - Service may throw a SystemException in order to indicate technical problems. In the case of an system exception the current transaction will be marked for roll back.
      • performServiceCheck

        protected final com.anaptecs.jeaf.xfun.api.health.HealthCheckResult performServiceCheck​(java.lang.Class<? extends com.anaptecs.jeaf.core.api.Service> pServiceClass,
                                                                                                com.anaptecs.jeaf.xfun.api.health.CheckLevel pCheckLevel)
        Method checks the state of the passed service. Method checks the current state of the service implementation that provides the passed service interface. Therefore JEAF provides a transaction context. The only action that will be performed within the transaction is the check of the service.
        Parameters:
        pServiceClass - Service whose state should be checked. The parameter must not be null.
        pCheckLevel - Level of check that should be performed. The parameter must not be null.
        Returns:
        HealthCheckResult Object describing the result of the check. The method may return null. This means that the service does not implement any checks.