Class BeanManager

java.lang.Object
com.groiss.component.BeanManager

public class BeanManager extends Object
Manages transaction aware components (="beans"). The beans should implement javax.ejb.SessionSynchronization.
  • Method Details

    • beforeCompletion

      public static void beforeCompletion(VoidCallable callable)
      Register a callable to be executed before transaction commit. Exceptions thrown by the callable will lead to rollback of the transaction.
      Parameters:
      callable - the VoidCallable to execute
    • afterCommit

      public static void afterCommit(VoidCallable callable)
      Register a callable to be executed after transaction commit. Exceptions thrown by the callable will be caught and ignored.
      Parameters:
      callable - the VoidCallable to execute
    • afterRollback

      public static void afterRollback(VoidCallable callable)
      Register a callable to be executed after transaction rollback. Exceptions thrown by the callable will be caught and ignored.
      Parameters:
      callable - the VoidCallable to execute
    • executeDeferred

      public static void executeDeferred(VoidCallable callable)
      Register a callable to be executed by the EventDispatcher thread after transaction commit. Each callable is executed in its own transaction. Exceptions lead to rollback of this separate transaction.
      Parameters:
      callable - the VoidCallable to execute
    • getBean

      public static Object getBean(String key)
      Gets a bean instance for a bean class registered with a key.
      Parameters:
      key - the key which was used to register a bean class
      Returns:
      a bean instance
    • addBean

      public static void addBean(String key, Class<?> service, boolean isSystemBean)
      Add a bean to the list of known bean classes.
      Parameters:
      key - a unique key for the bean
      service - the beans class
      isSystemBean - true, if the bean is an internal @enterprise bean. Do not use this call in application code.
    • addBean

      public static void addBean(String key, Class<?> service)
      Add a bean to the list of known user bean classes.
      Parameters:
      key - a unique key for the bean
      service - the beans class
    • commit

      public static void commit()
      Commits the transaction and releases all beans.
    • rollback

      public static void rollback()
      Rolls back the transaction and releases all beans.
    • rollbackTransaction

      public static void rollbackTransaction(UserTransaction ut)
    • hasActiveUserTransaction

      public static boolean hasActiveUserTransaction()
    • getUserTransaction

      public static UserTransaction getUserTransaction()
      The client or the bean manager itself gets a UserTransaction.
    • getUserTransaction

      public static UserTransaction getUserTransaction(String name)
      The client or the bean manager itself gets a UserTransaction.
    • bindThreadToTransaction

      @Deprecated(since="11.0", forRemoval=true) public static void bindThreadToTransaction(UserTransaction ut)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • unbindThreadFromTransaction

      public static void unbindThreadFromTransaction()
    • setExplicitTransactionMode

      @Deprecated(since="11.0", forRemoval=true) public static void setExplicitTransactionMode(boolean value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      If set to true, a thread will not get a usertransaction when calling method getUserTransaction() or method getUserTransaction(String) with null as parameter. Instead an exception will be thrown.