Package org.jbpm.pvm.internal.env

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


    throw new RuntimeException("Not implemented");
  }

  public void signalExecution(String executionId, String signal)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      ExecutionService execService = this.processEngine.getExecutionService();

      if(null==signal)
        execService.signalExecutionById(executionId);
      else
        execService.signalExecutionById(executionId, signal);
    }
    finally
    {
      env.close();
    }

  }
View Full Code Here


  public List<DeploymentRef> getDeployments()
  {
    List<DeploymentRef> results = new ArrayList<DeploymentRef>();

    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      RepositoryService repositoryService = this.processEngine.getRepositoryService();
      DeploymentQuery dquery = repositoryService.createDeploymentQuery();

      List<Deployment> dpls = dquery.list();

      for(Deployment dpl : dpls)
      {
        DeploymentRef ref = ModelAdaptor.adoptDeployment(dpl);

        // active processes
        ProcessDefinitionQuery pdQuery = repositoryService.createProcessDefinitionQuery();
        pdQuery.deploymentId(dpl.getId());
        List<ProcessDefinition> activePds = pdQuery.list();

        for(ProcessDefinition p : activePds)
        {
          ref.getDefinitions().add(p.getId());
        }

        // suspended  processes
        ProcessDefinitionQuery pdQuery2 = repositoryService.createProcessDefinitionQuery();
        pdQuery2.deploymentId(dpl.getId());
        pdQuery2.suspended();
        List<ProcessDefinition> suspendedPds = pdQuery2.list();

        for(ProcessDefinition p : suspendedPds)
        {
          ref.getDefinitions().add(p.getId());
        }

        results.add(ref);
      }

      return results;
    }
    finally
    {
      env.close();
    }
  }
View Full Code Here

    }
  }

  public void deleteDeployment(String id)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      RepositoryService repositoryService = this.processEngine.getRepositoryService();
      repositoryService.deleteDeploymentCascade(id);
    }
    finally
    {
      env.close();
    }

  }
View Full Code Here

  }

  public void suspendDeployment(String id, boolean isSuspended)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      RepositoryService repositoryService = this.processEngine.getRepositoryService();
      if(isSuspended)
        repositoryService.suspendDeployment(id);
      else
        repositoryService.resumeDeployment(id);
    }
    finally
    {
      env.close();
    }

  }
View Full Code Here

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

  public Object construct(WireContext wireContext) {
    Environment environment = Environment.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) {
    Environment environment = Environment.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) {
              Environment currentEnvironment = Environment.getCurrent();
              if (currentEnvironment != null) {
                autoWireValue = currentEnvironment.get(fieldName);
                if (autoWireValue == null) {
                  autoWireValue = currentEnvironment.get(fieldType);
                }
              }
            }
           
            if (autoWireValue!=null) {
View Full Code Here

public class StandardTransactionInterceptor extends Interceptor {
 
  private static final Log log = Log.getLog(StandardTransactionInterceptor.class.getName());
 
  public <T> T execute(Command<T> command) {
    Environment environment = Environment.getCurrent();
    if (environment==null) {
      throw new JbpmException("no environment for managing hibernate transaction");
    }

    StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
    if (standardTransaction==null) {
      throw new JbpmException("no standard-transaction in environment");
    }
   
    standardTransaction.begin();
View Full Code Here

    return evaluation;
  }

  private Environment getEnvironment()
  {
    Environment environment = Environment.getCurrent();
    if (environment==null)
      throw new RuntimeException("Failed to access current environment");
    return environment;

  }
View Full Code Here

  private boolean useCurrent;

  @SuppressWarnings("unchecked")
  public <T> T execute(Command<T> command) {
    Environment environment = Environment.getCurrent();
    if (environment == null) {
      throw new JbpmException("no environment for managing hibernate transaction");
    }

    StandardTransaction standardTransaction = environment.get(StandardTransaction.class);

    PlatformTransactionManager platformTransactionManager = environment.get(PlatformTransactionManager.class);
    if (platformTransactionManager == null) {
      throw new JbpmException("No platformTransaction manager defined.");
    }

    if (standardTransaction != null) {
      standardTransaction.begin();
    }

    try {
      DefaultTransactionDefinition definition = new DefaultTransactionDefinition();


      if (useCurrent) {
        definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_MANDATORY);
      } else {
        definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
      }

      TransactionTemplate template = new TransactionTemplate(platformTransactionManager, definition);
      TransactionCallback transactionCallback = new CommandTransactionCallback<T>(command, next, platformTransactionManager);
      T t = (T) template.execute(transactionCallback);

      Session session = environment.get(Session.class);
     
      if (session.isOpen()) {
        session.flush();       
      }
      return t;
View Full Code Here

TOP

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

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.