Package javax.resource.spi.work

Examples of javax.resource.spi.work.WorkException


         result = verifyWorkMethods(workClass, RUN_METHOD_NAME, null, workClass.getName() +
                                    ": Run method is not defined");
    
         if (!result)
         {
            throw new WorkException(bundle.runMethodIsSynchronized(workClass.getName()));
         }
     
         result = verifyWorkMethods(workClass, RELEASE_METHOD_NAME, null, workClass.getName() +
                                    ": Release method is not defined");
     
         if (!result)
         {
            throw new WorkException(bundle.releaseMethodIsSynchronized(workClass.getName()));
         }

         validatedWork.add(work.getClass().getName());
      }
   }
View Full Code Here


            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(securityContext);
                  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);

            fireWorkContextSetupComplete(securityContext);
         }
         catch (Throwable t)
         {
            log.securityContextSetupFailed(t.getMessage(), t);
            fireWorkContextSetupFailed(securityContext);
            throw new WorkException(bundle.securityContextSetupFailed(t.getMessage()), t);
         }
      }
      else if (securityContext != null && workManager.getCallbackSecurity() == null)
      {
         log.securityContextSetupFailedCallbackSecurityNull();
         fireWorkContextSetupFailed(securityContext);
         throw new WorkException(bundle.securityContextSetupFailedSinceCallbackSecurityWasNull());
      }
  
      if (ctx != null)
      {
         Xid xid = ctx.getXid();
View Full Code Here

        });
        long t = System.currentTimeMillis();
        try {
            latch.await();
        } catch (InterruptedException e) {
            throw new WorkException("Interrupted", e);
        }
        return System.currentTimeMillis() - t;
    }
View Full Code Here

     */
    private void executeWork(WorkerContext work, WorkExecutor workExecutor, Executor pooledExecutor) throws WorkException {
        work.workAccepted(this);
        try {
            workExecutor.doExecute(work, pooledExecutor);
            WorkException exception = work.getWorkException();
            if (null != exception) {
                throw exception;
            }
        } catch (InterruptedException e) {
            WorkCompletedException wcj = new WorkCompletedException(
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());
      }
  
      if (ctx != null)
      {
         Xid xid = ctx.getXid();
View Full Code Here

         log.tracef("doWork(%s, %s, %s, %s)", work, startTimeout, execContext, workListener);

      if (shutdown.get())
         throw new WorkRejectedException(bundle.workmanagerShutdown());

      WorkException exception = null;
      WorkWrapper wrapper = null;
      try
      {
         if (work == null)
            throw new WorkRejectedException(bundle.workIsNull());

         if (startTimeout < 0)
            throw new WorkRejectedException(bundle.startTimeoutIsNegative(startTimeout));

         checkAndVerifyWork(work, execContext);
     
         if (workListener != null)
         {
            WorkEvent event = new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null);
            workListener.workAccepted(event);
         }

         if (execContext == null)
         {
            execContext = new ExecutionContext()
         }

         final CountDownLatch completedLatch = new CountDownLatch(1);

         wrapper = new WorkWrapper(this, work, execContext, workListener, null, completedLatch,
                                   System.currentTimeMillis());

         setup(wrapper, workListener);

         BlockingExecutor executor = getExecutor(work);

         if (startTimeout == WorkManager.INDEFINITE)
         {
            executor.executeBlocking(wrapper);
         }
         else
         {
            executor.executeBlocking(wrapper, startTimeout, TimeUnit.MILLISECONDS);
         }

         completedLatch.await();
      }
      catch (ExecutionTimedOutException etoe)
      {
         exception = new WorkRejectedException(etoe);
         exception.setErrorCode(WorkRejectedException.START_TIMED_OUT)
      }
      catch (RejectedExecutionException ree)
      {
         exception = new WorkRejectedException(ree);
      }
View Full Code Here

      log.tracef("startWork(%s, %s, %s, %s)", work, startTimeout, execContext, workListener);

      if (shutdown.get())
         throw new WorkRejectedException(bundle.workmanagerShutdown());

      WorkException exception = null;
      WorkWrapper wrapper = null;
      try
      {
         if (work == null)
            throw new WorkRejectedException(bundle.workIsNull());

         if (startTimeout < 0)
            throw new WorkRejectedException(bundle.startTimeoutIsNegative(startTimeout));

         long started = System.currentTimeMillis();

         checkAndVerifyWork(work, execContext);
     
         if (workListener != null)
         {
            WorkEvent event = new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null);
            workListener.workAccepted(event);
         }

         if (execContext == null)
         {
            execContext = new ExecutionContext()
         }

         final CountDownLatch startedLatch = new CountDownLatch(1);

         wrapper = new WorkWrapper(this, work, execContext, workListener, startedLatch, null,
                                   System.currentTimeMillis());

         setup(wrapper, workListener);

         BlockingExecutor executor = getExecutor(work);

         if (startTimeout == WorkManager.INDEFINITE)
         {
            executor.executeBlocking(wrapper);
         }
         else
         {
            executor.executeBlocking(wrapper, startTimeout, TimeUnit.MILLISECONDS);
         }

         startedLatch.await();

         return System.currentTimeMillis() - started;
      }
      catch (ExecutionTimedOutException etoe)
      {
         exception = new WorkRejectedException(etoe);
         exception.setErrorCode(WorkRejectedException.START_TIMED_OUT)
      }
      catch (RejectedExecutionException ree)
      {
         exception = new WorkRejectedException(ree);
      }
View Full Code Here

      log.tracef("scheduleWork(%s, %s, %s, %s)", work, startTimeout, execContext, workListener);

      if (shutdown.get())
         throw new WorkRejectedException(bundle.workmanagerShutdown());

      WorkException exception = null;
      WorkWrapper wrapper = null;
      try
      {
         if (work == null)
            throw new WorkRejectedException(bundle.workIsNull());

         if (startTimeout < 0)
            throw new WorkRejectedException(bundle.startTimeoutIsNegative(startTimeout));

         checkAndVerifyWork(work, execContext);
     
         if (workListener != null)
         {
            WorkEvent event = new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null);
            workListener.workAccepted(event);
         }

         if (execContext == null)
         {
            execContext = new ExecutionContext()
         }

         wrapper = new WorkWrapper(this, work, execContext, workListener, null, null,
                                   System.currentTimeMillis());

         setup(wrapper, workListener);

         BlockingExecutor executor = getExecutor(work);

         if (startTimeout == WorkManager.INDEFINITE)
         {
            executor.executeBlocking(wrapper);
         }
         else
         {
            executor.executeBlocking(wrapper, startTimeout, TimeUnit.MILLISECONDS);
         }
      }
      catch (ExecutionTimedOutException etoe)
      {
         exception = new WorkRejectedException(etoe);
         exception.setErrorCode(WorkRejectedException.START_TIMED_OUT)
      }
      catch (RejectedExecutionException ree)
      {
         exception = new WorkRejectedException(ree);
      }
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.