Package org.jbpm.pvm.internal.env

Examples of org.jbpm.pvm.internal.env.EnvironmentImpl


 
    IdentitySessionFactory identitySessionFactory = EnvironmentImpl.getFromCurrent(IdentitySessionFactory.class);
    try {
      IdentitySession identitySession = identitySessionFactory.createIdentitySession(realmName);
     
      EnvironmentImpl environment = EnvironmentImpl.getCurrent();
        StandardTransaction transaction = environment.get(StandardTransaction.class);
        if (transaction != null) {
          IdentitySessionResource identitySessionResource = new IdentitySessionResource(identitySession);
          transaction.enlistResource(identitySessionResource);
        }
       
View Full Code Here


  public EnvDescriptor(Class<?> type) {
    this.type = type;
  }

  public Object construct(WireContext wireContext) {
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
   
    if (environment==null) {
      throw new WireException("no environment to get object "+(objectName!=null ? objectName : typeName));
    }
   
    if (objectName!=null) {
      log.trace("looking up "+objectName+" by name in environment");
      return environment.get(objectName);
    }

    log.trace("looking up an object of type "+typeName+" in environment");
    if (type==null) {
      try {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        type = classLoader.loadClass(typeName);
      } catch (Exception e) {
        throw new WireException("couldn't load class "+typeName, e);
      }
    }
    return environment.get(type);
  }
View Full Code Here

  protected boolean close = true;
  protected String standardTransactionName;
  protected String connectionName;

  public Object construct(WireContext wireContext) {
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    if (environment==null) {
      throw new WireException("no environment");
    }

    // get the hibernate-session-factory
    SessionFactory sessionFactory = null;
    if (factoryName!=null) {
      sessionFactory = (SessionFactory) wireContext.get(factoryName);
    } else {
      sessionFactory = environment.get(SessionFactory.class);
    }
    if (sessionFactory==null) {
      throw new WireException("couldn't find hibernate-session-factory "+(factoryName!=null ? "'"+factoryName+"'" : "by type ")+"to open a hibernate-session");
    }

    // open the hibernate-session
    Session session = null;
    if (useCurrent) {
      if (log.isTraceEnabled()) log.trace("getting current hibernate session");
      session = sessionFactory.getCurrentSession();
     
    } else if (connectionName!=null) {
      Connection connection = (Connection) wireContext.get(connectionName);
      if (log.isTraceEnabled()) log.trace("creating hibernate session with connection "+connection);
      session = sessionFactory.openSession(connection);

    } else {
      if (log.isTraceEnabled()) log.trace("creating hibernate session");
      session = sessionFactory.openSession();
    }
   
    StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
    if (standardTransaction!=null) {
      HibernateSessionResource hibernateSessionResource = new HibernateSessionResource(session);
      standardTransaction.enlistResource(hibernateSessionResource);
    }
View Full Code Here

              autoWireValue = wireContext.get(fieldType)
            }
            // if auto wire value has not been found in current context,
            // search in environment
            if (autoWireValue == null) {
              EnvironmentImpl currentEnvironment = EnvironmentImpl.getCurrent();
              if (currentEnvironment != null) {
                autoWireValue = currentEnvironment.get(fieldName);
                if (autoWireValue == null) {
                  autoWireValue = currentEnvironment.get(fieldType);
                }
              }
            }
           
            if (autoWireValue!=null) {
View Full Code Here

      performAtomicOperationSync(operation);
    }
  }
 
  public void sendContinuationMessage(AtomicOperation operation) {
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    MessageSession messageSession = environment.get(MessageSession.class);
    if (messageSession==null) {
      throw new JbpmException("no message-session configured to send asynchronous continuation message");
    }
    MessageImpl<?> asyncMessage = operation.createAsyncMessage(this);
    setState(Execution.STATE_ASYNC);
View Full Code Here

      atomicOperations = new LinkedList<AtomicOperation>();
      atomicOperations.offer(operation);
     
      ExecutionContext originalExecutionContext = null;
      ExecutionContext executionContext = null;
      EnvironmentImpl environment = EnvironmentImpl.getCurrent();
      if (environment!=null) {
        originalExecutionContext = (ExecutionContext) environment.getContext(Context.CONTEXTNAME_EXECUTION);
        if ( (originalExecutionContext!=null)
             && (originalExecutionContext.getExecution()==this)
           ) {
          originalExecutionContext = null;
        } else {
          executionContext = new ExecutionContext(this);
          environment.setContext(executionContext);
        }
      }
     
      try {
        while (! atomicOperations.isEmpty()) {
          AtomicOperation atomicOperation = atomicOperations.poll();
          atomicOperation.perform(this);
        }

      } catch (RuntimeException e ) {
        throw e;
      } finally {
        atomicOperations = null;
       
        if (executionContext!=null) {
          environment.removeContext(executionContext);
        }
        if (originalExecutionContext!=null) {
          environment.setContext(originalExecutionContext);
        }
      }
    } else {
      atomicOperations.offer(operation);
    }
View Full Code Here

    }

    // identify the wireContext
    WireContext wireContext = null;
    if (contextName!=null) {
      EnvironmentImpl environment = EnvironmentImpl.getCurrent();
      if (environment!=null) {
        try {
          wireContext = (WireContext) environment.getContext(contextName);
          if (wireContext==null) {
            throw new WireException("couldn't subscribe because context "+contextName+" doesn't exist");
          }
        } catch (ClassCastException e) {
          throw new WireException("couldn't subscribe because context "+contextName+" is not a WireContext", e);
View Full Code Here

  protected abstract Class<? extends Type> getIdType();
 
  public boolean matches(String name, Object value) {
    boolean matches = false;
   
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    if (environment!=null) {
      SessionFactory sessionFactory = null;
      if (hibernateSessionFactoryName!=null) {
        sessionFactory = (SessionFactory) environment.get(hibernateSessionFactoryName);
      } else {
        sessionFactory = environment.get(SessionFactory.class);
      }
      if (sessionFactory!=null) {
        ClassMetadata classMetadata = sessionFactory.getClassMetadata(value.getClass());
        matches =  ( (classMetadata!=null)
                     && (classMetadata.getIdentifierType().getClass()==getIdType())
View Full Code Here

  public Object construct(WireContext wireContext) {
    if (contextName==null) {
      return wireContext;
    }
    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    if (environment==null) {
      throw new WireException("can't get context '"+contextName+"': no current environment");
    }
    return environment.getContext(contextName);
  }
View Full Code Here

      catch (MessagingException e) {
        throw new JbpmException("failed to add " + addresses + " to senders", e);
      }
    }

    EnvironmentImpl environment = EnvironmentImpl.getCurrent();
    IdentitySession identitySession = environment.get(IdentitySession.class);
    AddressResolver addressResolver = environment.get(AddressResolver.class);

    // resolve and tokenize users
    String userList = fromTemplate.getUsers();
    if (userList != null) {
      String[] userIds = tokenizeActors(userList, execution);
View Full Code Here

TOP

Related Classes of org.jbpm.pvm.internal.env.EnvironmentImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.