Package javax.resource.spi.work

Examples of javax.resource.spi.work.WorkException


            return false
         }
      }
      catch (NoSuchMethodException nsme)
      {
         throw new WorkException(errorMessage);
      }
     
      return true;
   }
View Full Code Here


            ResourceAdapterAssociation raa = (ResourceAdapterAssociation)work;
            raa.setResourceAdapter(resourceAdapter);
         }
         catch (Throwable t)
         {
            throw new WorkException(bundle.resourceAdapterAssociationFailed(work.getClass().getName()), t);
         }
      }

      //If work is an instanceof WorkContextProvider
      if (work instanceof WorkContextProvider)
View Full Code Here

                  log.tracef("Creating security context: %s", scDomain);

               if (scDomain == null || scDomain.trim().equals(""))
               {
                  fireWorkContextSetupFailed(ctx);
                  throw new WorkException(bundle.securityContextSetupFailedSinceCallbackSecurityDomainWasEmpty());
               }

               sc = SecurityContextFactory.createSecurityContext(scDomain);
               SecurityContextAssociation.setSecurityContext(sc);
            }
            else
            {
               sc = SecurityContextAssociation.getSecurityContext();

               if (trace)
                  log.tracef("Using security context: %s", sc);
            }

            executionSubject = sc.getSubjectInfo().getAuthenticatedSubject();

            if (executionSubject == null)
            {
               if (trace)
                  log.tracef("Creating empty subject");

               executionSubject = new Subject();
            }

            // Resource adapter callback
            securityContext.setupSecurityContext(cbh, executionSubject, serviceSubject);

            List<Callback> callbacks = new ArrayList<Callback>();
            if (workManager.getCallbackSecurity().isMappingRequired())
            {
               // JCA 1.6: 16.4.4
            }

            if (workManager.getCallbackSecurity().getDefaultPrincipal() != null)
            {
               Principal defaultPrincipal = workManager.getCallbackSecurity().getDefaultPrincipal();
               CallerPrincipalCallback cpc =
                  new CallerPrincipalCallback(executionSubject, defaultPrincipal);

               callbacks.add(cpc);
            }

            if (workManager.getCallbackSecurity().getDefaultGroups() != null)
            {
               String[] defaultGroups = workManager.getCallbackSecurity().getDefaultGroups();
               GroupPrincipalCallback gpc =
                  new GroupPrincipalCallback(executionSubject, defaultGroups);

               callbacks.add(gpc);
            }

            if (callbacks.size() > 0)
            {
               Callback[] cb = new Callback[callbacks.size()];
               cbh.handle(callbacks.toArray(cb));
            }

            if (trace)
               log.tracef("Setting authenticated subject (%s) on security context (%s)", executionSubject, sc);

            // Set the authenticated subject
            sc.getSubjectInfo().setAuthenticatedSubject(executionSubject);
         }
         catch (Throwable t)
         {
            log.securityContextSetupFailed(t.getMessage(), t);
            fireWorkContextSetupFailed(ctx);
            throw new WorkException(bundle.securityContextSetupFailed(t.getMessage()), t);
         }
      }
      else if (securityContext != null && workManager.getCallbackSecurity() == null)
      {
         log.securityContextSetupFailedCallbackSecurityNull();
         fireWorkContextSetupFailed(ctx);
         throw new WorkException(bundle.securityContextSetupFailedSinceCallbackSecurityWasNull());
      }
  
      //Fires Context setup complete
      fireWorkContextSetupComplete(ctx);
     
View Full Code Here

    throws WorkException
  {
    boolean isStart = false;
   
    try {
      WorkException exn = null;
     
      synchronized (this) {
        if (_isClosed)
          exn = new WorkException(L.l("Work task can't be started from closed context."));
        else if (_activeTasks.contains(work))
          exn = new WorkException(L.l("Reentrant Work tasks are not allowed."));
        else {
          isStart = true;

          _activeTasks.add(work);
        }
View Full Code Here

                         boolean waitForStart)
    throws WorkException
  {
    boolean isStart = false;
   
    WorkException exn = null;

    try {
      synchronized (this) {
        if (_isClosed)
          exn = new WorkException(L.l("Work task can't be started from closed context."));
        else if (_activeTasks.contains(work))
          exn = new WorkException(L.l("Reentrant Work tasks are not allowed."));
        else
          _activeTasks.add(work);
      }

      if (exn != null) {
View Full Code Here

        if (workType == DO) {
            // wait for completion
            try {
                worker.waitForCompletion();
            } catch (InterruptedException e) {
                WorkException workException = new WorkException("Work submission thread was interrupted", e);
                workException.setErrorCode(INTERNAL);
                throw workException;
            }

            // if work threw an exception, rethrow it
            WorkException workCompletedException = worker.getWorkException();
            if (workCompletedException != null) {
                throw workCompletedException;
            }
        } else if (workType == START) {
            // wait for work to start
            try {
                worker.waitForStart();
            } catch (InterruptedException e) {
                WorkException workException = new WorkException("Work submission thread was interrupted", e);
                workException.setErrorCode(INTERNAL);
                throw workException;
            }

            // if work threw a rejection exception, rethrow it (it is the exception for timeout)
            WorkException workCompletedException = worker.getWorkException();
            if (workCompletedException instanceof WorkRejectedException) {
                throw workCompletedException;
            }
        }
View Full Code Here

        public void workRejected(WorkEvent event) {
            // Don't log doWork or startWork since exception is propagated to caller
            if (workType == DO || workType == START) {
                return;
            }
            WorkException exception = event.getException();
            if (exception != null) {
                if (WorkException.START_TIMED_OUT.equals(exception.getErrorCode())) {
                    logger.error(exception.getMessage());
                }
            }
        }
View Full Code Here

    }

    private WorkEvent getTestWorkEvent()
    {
        return new WorkEvent(this, // source
            WorkEvent.WORK_REJECTED, getTestWork(), new WorkException(new Throwable("testThrowable")));
    }
View Full Code Here

        try
        {
            work.workAccepted(this);
            workExecutor.doExecute(work, workExecutorService);
            WorkException exception = work.getWorkException();
            if (null != exception)
            {
                throw exception;
            }
        }
View Full Code Here

    }

    private WorkEvent getTestWorkEvent()
    {
        WorkEvent event = new WorkEvent(this, // source
            WorkEvent.WORK_REJECTED, getTestWork(), new WorkException(new Throwable("testThrowable")));
        return event;
    }
View Full Code Here

TOP

Related Classes of javax.resource.spi.work.WorkException

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.