public Object provideInjection(InjectionContext context) throws InjectionProviderException {
   try {
     return Contexts.context(contextType);
   } catch (IllegalArgumentException e) {
     throw new InjectionProviderException(
         "Could not find context of given type:" + contextType.getName(), e);
   }
 }
Ejemplo n.º 2
0
  /**
   * Schedule a {@link Runnable} object for execution after the completion of the current
   * transaction.
   *
   * @param runnable
   */
  void scheduleRunnable(final Runnable runnable) {
    assertTransaction();
    _contexts.registerCommitSynchronizer(
        new Runnable() {

          public void run() {
            _exec.submit(new ServerRunnable(runnable));
          }
        });
  }
Ejemplo n.º 3
0
  public MessageExchange getMessageExchange(final String mexId) throws BpelEngineException {

    final MessageExchangeDAO inmemdao = getInMemMexDAO(mexId);

    Callable<MessageExchange> loadMex =
        new Callable<MessageExchange>() {

          public MessageExchange call() {
            MessageExchangeDAO mexdao =
                (inmemdao == null)
                    ? mexdao = _contexts.dao.getConnection().getMessageExchange(mexId)
                    : inmemdao;
            if (mexdao == null) return null;

            ProcessDAO pdao = mexdao.getProcess();
            ODEProcess process =
                pdao == null ? null : _registeredProcesses.get(pdao.getProcessId());

            if (process == null) {
              String errmsg = __msgs.msgProcessNotActive(pdao.getProcessId());
              __log.error(errmsg);
              // TODO: Perhaps we should define a checked exception for this
              // condition.
              throw new BpelEngineException(errmsg);
            }

            InvocationStyle istyle = mexdao.getInvocationStyle();
            if (istyle == InvocationStyle.RELIABLE || istyle == InvocationStyle.TRANSACTED)
              assertTransaction();

            switch (mexdao.getDirection()) {
              case MessageExchangeDAO.DIR_BPEL_INVOKES_PARTNERROLE:
                return process.createPartnerRoleMex(mexdao);
              case MessageExchangeDAO.DIR_PARTNER_INVOKES_MYROLE:
                return process.lookupMyRoleMex(mexdao);
              default:
                String errmsg =
                    "BpelEngineImpl: internal error, invalid MexDAO direction: " + mexId;
                __log.fatal(errmsg);
                throw new BpelEngineException(errmsg);
            }
          }
        };

    try {
      if (inmemdao != null || _contexts.isTransacted()) return loadMex.call();
      else return enqueueTransaction(loadMex).get();
    } catch (ContextException e) {
      throw new BpelEngineException(e);
    } catch (Exception e) {
      throw new BpelEngineException(e);
    }
  }
Ejemplo n.º 4
0
  public void onScheduledJob(final JobInfo jobInfo) throws JobProcessorException {
    try {
      final WorkEvent we = new WorkEvent(jobInfo.jobDetail);
      ODEProcess process = _registeredProcesses.get(we.getProcessId());
      if (process == null) {
        // If the process is not active, it means that we should not be
        // doing any work on its behalf, therefore we will reschedule the
        // events for some time in the future (1 minute).

        // 31-05-2010
        // According to the bpel server logic, we won't find a process with matching
        // process id in future for this type of case where we can't find the process at
        // first job invocation. Because all the processes(both hydrated and dehydrated) are there
        // in _registeredProcesses Map. And even we deploy a new version of the process, it's
        // QName will be different because of the versioning.
        // So I am removing scheduling part.
        // TODO: Let's revert the logic if an issue occurred because of this.
        _contexts.execTransaction(
            new Callable<Void>() {
              public Void call() throws Exception {
                _contexts.scheduler.jobCompleted(jobInfo.jobName);
                // Date future = new Date(System.currentTimeMillis() + (60 * 1000));
                // __log.info(__msgs.msgReschedulingJobForInactiveProcess(we.getProcessId(),
                // jobInfo.jobName, future));
                // _contexts.scheduler.schedulePersistedJob(we.getDetail(), future);
                return null;
              }
            });
        return;
      }

      if (we.getType().equals(WorkEvent.Type.INVOKE_CHECK)) {
        if (__log.isDebugEnabled())
          __log.debug("handleWorkEvent: InvokeCheck event for mexid " + we.getMexId());

        PartnerRoleMessageExchange mex =
            (PartnerRoleMessageExchange) getMessageExchange(we.getMexId());
        if (mex.getStatus() == MessageExchange.Status.ASYNC
            || mex.getStatus() == MessageExchange.Status.ACK) {
          String msg =
              "Dangling invocation (mexId=" + we.getMexId() + "), forcing it into a failed state.";
          if (__log.isDebugEnabled()) __log.debug(msg);
          mex.replyWithFailure(MessageExchange.FailureType.COMMUNICATION_ERROR, msg, null);
        }
        return;
      }

      process.handleWorkEvent(jobInfo);
    } catch (Exception ex) {
      throw new JobProcessorException(ex, jobInfo.jobDetail.get("inmem") == null);
    }
  }
Ejemplo n.º 5
0
  // embeddeding implementation of sthg (JPA, JSF) can lead to classloading issues if we don't
  // enrich the webapp
  // with our integration jars
  // typically the class will try to be loaded by the common classloader
  // but the interface implemented or the parent class
  // will be in the webapp
  @Override
  public void start() throws LifecycleException {
    super.start(); // do it first otherwise we can't use this as classloader

    // mainly for tomee-maven-plugin
    initAdditionalRepos();
    if (additionalRepos != null && !additionalRepos.isEmpty()) {
      for (final File f : additionalRepos) {
        final DirResourceSet webResourceSet =
            new PremptiveDirResourceSet(resources, "/", f.getAbsolutePath(), "/");
        resources.addPreResources(webResourceSet);
      }
      resources.setCachingAllowed(false);
    }

    // add configurer enrichments
    if (configurer != null) {
      // add now we removed all we wanted
      final URL[] enrichment = configurer.additionalURLs();
      for (final URL url : enrichment) {
        super.addURL(url);
      }
    }

    // add internal enrichments
    for (final URL url : SystemInstance.get().getComponent(WebAppEnricher.class).enrichment(this)) {
      super.addURL(url);
    }

    // WEB-INF/jars.xml
    final File war = Contexts.warPath(CONTEXT.get());
    final File jarsXml = new File(war, "WEB-INF/" + QuickJarsTxtParser.FILE_NAME);
    final ClassLoaderConfigurer configurerTxt = QuickJarsTxtParser.parse(jarsXml);
    if (configurerTxt != null) {
      configurer = new CompositeClassLoaderConfigurer(configurer, configurerTxt);
    }

    stopped = false;
  }
Ejemplo n.º 6
0
 protected void assertNoTransaction() {
   if (_contexts.isTransacted())
     throw new BpelEngineException("Operation must be performed outside of a transaction!");
 }
Ejemplo n.º 7
0
 protected void assertTransaction() {
   if (!_contexts.isTransacted())
     throw new BpelEngineException("Operation must be performed in a transaction!");
 }
Ejemplo n.º 8
0
 public void setBindingContext(BindingContext bc) {
   _contexts.bindingContext = bc;
 }
Ejemplo n.º 9
0
 /**
  * Set the DAO connection factory. The DAO is used by the BPEL engine to persist information about
  * active processes.
  *
  * @param daoCF {@link BpelDAOConnectionFactory} implementation.
  */
 public void setDaoConnectionFactory(BpelDAOConnectionFactory daoCF) throws BpelEngineException {
   _contexts.dao = daoCF;
 }
Ejemplo n.º 10
0
 public void setEndpointReferenceContext(EndpointReferenceContext eprContext)
     throws BpelEngineException {
   _contexts.eprContext = eprContext;
 }
Ejemplo n.º 11
0
 public void setScheduler(Scheduler scheduler) throws BpelEngineException {
   _contexts.scheduler = scheduler;
 }
Ejemplo n.º 12
0
 public void setMessageExchangeContext(MessageExchangeContext mexContext)
     throws BpelEngineException {
   _contexts.mexContext = mexContext;
 }
Ejemplo n.º 13
0
 public void setTransactionManager(TransactionManager txm) {
   _contexts.txManager = txm;
 }
Ejemplo n.º 14
0
 public void setInMemDaoConnectionFactory(BpelDAOConnectionFactory daoCF) {
   _contexts.inMemDao = daoCF;
 }
Ejemplo n.º 15
0
 /**
  * Set the DAO connection factory. The DAO is used by the BPEL engine to persist information about
  * active processes.
  *
  * @param daoCF {@link BpelDAOConnectionFactory} implementation.
  */
 public void setDaoConnectionFactory(BpelDAOConnectionFactory daoCF) throws BpelEngineException {
   JdbcDelegate.setGlobalDAOConnFac(daoCF);
   _contexts.dao = daoCF;
 }
Ejemplo n.º 16
0
 public void setCronScheduler(CronScheduler cronScheduler) throws BpelEngineException {
   _contexts.cronScheduler = cronScheduler;
 }