Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * IronJacamar, a Java EE Connector Architecture implementation
    * Copyright 2010, Red Hat Inc, and individual contributors
    * as indicated by the @author tags. See the copyright.txt file in the
    * distribution for a full listing of individual contributors.
    *
    * This is free software; you can redistribute it and/or modify it
    * under the terms of the GNU Lesser General Public License as
    * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this software; if not, write to the Free
   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   */
  
  package org.jboss.jca.core.workmanager;
  
  
  import java.util.HashSet;
  import java.util.List;
  import java.util.Set;
  
  
The work manager implementation.

Author(s):
Jesper Pedersen
  
  public class WorkManagerImpl implements WorkManager
  {
   
The logger
  
     private static CoreLogger log = Logger.getMessageLogger(CoreLogger.classWorkManagerImpl.class.getName());

   
Whether trace is enabled
  
     private static boolean trace = .isTraceEnabled();

   
The bundle
  
     private static CoreBundle bundle = Messages.getBundle(CoreBundle.class);

   
Work run method nam
  
     private static final String RUN_METHOD_NAME = "run";

   
Work release method nam
  
     private static final String RELEASE_METHOD_NAME = "release";

   
Supported work context se
  
     private static final Set<Class<? extends WorkContext>> SUPPORTED_WORK_CONTEXT_CLASSES =
           new HashSet<Class<? extends WorkContext>>(4);

   
The id
  
     private String id;

   
The name
  
     private String name;

   
Running in spec compliant mode
  
    private boolean specCompliant;

   
The short running executor
 
The long running executor
 
The XA terminator
 
    private XATerminator xaTerminator;

   
Validated work instances
 
    private Set<StringvalidatedWork;

   
Security module for callback
 
    private Callback callbackSecurity;

   
Resource adapter
 
    private ResourceAdapter resourceAdapter;

   
Shutdown
 
    private AtomicBoolean shutdown;

   
Active work wrappers
 
    private Set<WorkWrapperactiveWorkWrappers;

   
Enable statistics
 
    private boolean statisticsEnabled;

   
Statistics
 
    private WorkManagerStatisticsImpl statistics;

   
Default supported workcontext type
 
    static
    {
    }

   
Constructor - by default the WorkManager is running in spec-compliant mode
 
    public WorkManagerImpl()
    {
        = null;
        = null;
        = true;
        = new HashSet<String>();
        = null;
        = new AtomicBoolean(false);
        = new HashSet<WorkWrapper>();
        = true;
        = new WorkManagerStatisticsImpl();
    }

   
Get the unique id of the work manager

Returns:
The value
 
    public String getId()
    {
       if ( == null)
          return ;
 
       return ;
    }

   
Set the unique id of the work manager

Parameters:
v The value
 
    public void setId(String v)
    {
        = v;
    }

   
Get the name of the work manager

Returns:
The value
 
    public String getName()
    {
       return ;
    }

   
Set the name of the work manager

Parameters:
v The value
 
    public void setName(String v)
    {
        = v;
    }

   
Retrieve the executor for short running tasks

Returns:
The executor
 
    {
       return ;
    }

   
Set the executor for short running tasks

Parameters:
executor The executor
 
    public void setShortRunningThreadPool(BlockingExecutor executor)
    {
       if ()
          .trace("short running executor:" + (executor != null ? executor.getClass() : "null"));
 
       if (executor != null)
       {
          if (executor instanceof StatisticsExecutor)
          {
             this. = (StatisticsExecutorexecutor;
          }
          else
          {
             this. = new StatisticsExecutorImpl(executor);
          }
       }
    }

   
Retrieve the executor for long running tasks

Returns:
The executor
 
    {
       return ;
    }

   
Set the executor for long running tasks

Parameters:
executor The executor
 
    public void setLongRunningThreadPool(BlockingExecutor executor)
    {
       if ()
          .trace("long running executor:" + (executor != null ? executor.getClass() : "null"));
  
       if (executor != null)
       {
          if (executor instanceof StatisticsExecutor)
          {
             this. = (StatisticsExecutorexecutor;
          }
          else
          {
             this. = new StatisticsExecutorImpl(executor);
          }
       }
    }

   
Get the XATerminator

Returns:
The XA terminator
 
    public XATerminator getXATerminator()
    {
       return ;
    }

   
Set the XATerminator

Parameters:
xaTerminator The XA terminator
 
    public void setXATerminator(XATerminator xaTerminator)
    {
       this. = xaTerminator;
    }

   
Is spec compliant

Returns:
True if spec compliant; otherwise false
 
    public boolean isSpecCompliant()
    {
       return ;
    }

   
Set spec compliant flag

Parameters:
v The value
 
    public void setSpecCompliant(boolean v)
    {
        = v;
    }

   
Get the callback security module

Returns:
The value
 
    public Callback getCallbackSecurity()
    {
       return ;
    }

   
Set callback security module

Parameters:
v The value
 
    public void setCallbackSecurity(Callback v)
    {
        = v;
    }

   
Get the resource adapter

Returns:
The value
 
    {
       return ;
    }

   
Set the resource adapter

Parameters:
v The value
 
    public void setResourceAdapter(ResourceAdapter v)
    {
        = v;
    }

   
 
    public boolean isStatisticsEnabled()
    {
       return ;
    }

   
 
    public void setStatisticsEnabled(boolean v)
    {
        = v;
    }

   
Get the statistics

Returns:
The value
 
    {
       return ;
    }

   
Set the statistics

Parameters:
v The value
 
    {
        = v;
    }

   
Clone the WorkManager implementation

Returns:
A copy of the implementation
Throws:
java.lang.CloneNotSupportedException Thrown if the copy operation isn't supported
 
    @Override
    public WorkManager clone() throws CloneNotSupportedException
    {
       WorkManagerImpl wm = (WorkManagerImplsuper.clone();
       wm.setId(getId());
       wm.setName(getName());
       wm.setXATerminator(getXATerminator());
       wm.setStatistics();
 
       return wm;
    }

   
 
    public void doWork(Work workthrows WorkException
    {
       doWork(work.nullnull);
    }

   
 
    public void doWork(Work worklong startTimeoutExecutionContext execContextWorkListener workListener)
       throws WorkException
    {
       if ()
          .tracef("doWork(%s, %s, %s, %s)"workstartTimeoutexecContextworkListener);
 
       WorkException exception = null;
       WorkWrapper wrapper = null;
       try
       {
          doFirstChecks(workstartTimeoutexecContext);
 
          if (workListener != null)
          {
             WorkEvent event = new WorkEvent(this.worknull);
             workListener.workAccepted(event);
          }
 
          deltaDoWorkAccepted();
 
          if (execContext == null)
          {
             execContext = new ExecutionContext();
          }
 
          final CountDownLatch completedLatch = new CountDownLatch(1);
 
          wrapper = new WorkWrapper(thisworkexecContextworkListenernullcompletedLatch,
                                    System.currentTimeMillis());
 
          setup(wrapperworkListener);
 
          BlockingExecutor executor = getExecutor(work);
 
          if (startTimeout == .)
          {
             executor.executeBlocking(wrapper);
          }
          else
          {
             executor.executeBlocking(wrapperstartTimeout.);
          }
 
          completedLatch.await();
       }
       catch (ExecutionTimedOutException etoe)
       {
          exception = new WorkRejectedException(etoe);
          exception.setErrorCode(.);
       }
       catch (RejectedExecutionException ree)
       {
          exception = new WorkRejectedException(ree);
       }
       catch (WorkCompletedException wce)
       {
          if (wrapper != null)
             wrapper.setWorkException(wce);
       }
       catch (WorkException we)
       {
          exception = we;
       }
       catch (InterruptedException ie)
       {
          Thread.currentThread().interrupt();
          exception = new WorkRejectedException(.interruptedWhileRequestingPermit());
       }
       finally
       {
          if (exception != null)
          {
             if (workListener != null)
             {
                WorkEvent event = new WorkEvent(this.workexception);
                workListener.workRejected(event);
             }
 
             if ()
                .tracef("Exception %s for %s"exceptionthis);
 
             deltaDoWorkRejected();
 
             throw exception;
          }
 
          if (wrapper != null)
          {
             checkWorkCompletionException(wrapper);
          }
       }
    }

   
 
    public long startWork(Work workthrows WorkException
    {
       return startWork(work.nullnull);
    }

   
 
    public long startWork(Work worklong startTimeoutExecutionContext execContextWorkListener workListener)
       throws WorkException
    {
       .tracef("startWork(%s, %s, %s, %s)"workstartTimeoutexecContextworkListener);
 
       WorkException exception = null;
       WorkWrapper wrapper = null;
       try
       {
          long started = System.currentTimeMillis();
 
          doFirstChecks(workstartTimeoutexecContext);
 
          if (workListener != null)
          {
             WorkEvent event = new WorkEvent(this.worknull);
             workListener.workAccepted(event);
          }
 
          deltaStartWorkAccepted();
 
          if (execContext == null)
          {
             execContext = new ExecutionContext();
          }
 
          final CountDownLatch startedLatch = new CountDownLatch(1);
 
          wrapper = new WorkWrapper(thisworkexecContextworkListenerstartedLatchnull,
                                    System.currentTimeMillis());
 
          setup(wrapperworkListener);
 
          BlockingExecutor executor = getExecutor(work);
 
          if (startTimeout == .)
          {
             executor.executeBlocking(wrapper);
          }
          else
          {
             executor.executeBlocking(wrapperstartTimeout.);
          }
 
          startedLatch.await();
 
          return System.currentTimeMillis() - started;
       }
       catch (ExecutionTimedOutException etoe)
       {
          exception = new WorkRejectedException(etoe);
          exception.setErrorCode(.);
       }
       catch (RejectedExecutionException ree)
       {
          exception = new WorkRejectedException(ree);
       }
       catch (WorkCompletedException wce)
       {
          if (wrapper != null)
             wrapper.setWorkException(wce);
       }
       catch (WorkException we)
       {
          exception = we;
       }
       catch (InterruptedException ie)
       {
          Thread.currentThread().interrupt();
          exception = new WorkRejectedException(.interruptedWhileRequestingPermit());
       }
       finally
       {
          if (exception != null)
          {
             if (workListener != null)
             {
                WorkEvent event = new WorkEvent(this.workexception);
                workListener.workRejected(event);
             }
 
             if ()
                .tracef("Exception %s for %s"exceptionthis);
 
             deltaStartWorkRejected();
 
             throw exception;
          }
 
          if (wrapper != null)
             checkWorkCompletionException(wrapper);
       }
 
       return .;
    }

   
 
    public void scheduleWork(Work workthrows WorkException
    {
       scheduleWork(work.nullnull);
    }

   
 
    public void scheduleWork(Work worklong startTimeoutExecutionContext execContextWorkListener workListener)
       throws WorkException
    {
       .tracef("scheduleWork(%s, %s, %s, %s)"workstartTimeoutexecContextworkListener);
 
       WorkException exception = null;
       WorkWrapper wrapper = null;
       try
       {
          doFirstChecks(workstartTimeoutexecContext);
 
          if (workListener != null)
          {
             WorkEvent event = new WorkEvent(this.worknull);
             workListener.workAccepted(event);
          }
 
          deltaScheduleWorkAccepted();
 
          if (execContext == null)
          {
             execContext = new ExecutionContext();
          }
 
          wrapper = new WorkWrapper(thisworkexecContextworkListenernullnull,
                                    System.currentTimeMillis());
 
          setup(wrapperworkListener);
 
          BlockingExecutor executor = getExecutor(work);
 
          if (startTimeout == .)
          {
             executor.executeBlocking(wrapper);
          }
          else
          {
             executor.executeBlocking(wrapperstartTimeout.);
          }
       }
       catch (ExecutionTimedOutException etoe)
       {
          exception = new WorkRejectedException(etoe);
          exception.setErrorCode(.);
       }
       catch (RejectedExecutionException ree)
       {
          exception = new WorkRejectedException(ree);
       }
       catch (WorkCompletedException wce)
       {
          if (wrapper != null)
             wrapper.setWorkException(wce);
       }
       catch (WorkException we)
       {
          exception = we;
       }
       catch (InterruptedException ie)
       {
          Thread.currentThread().interrupt();
          exception = new WorkRejectedException(.interruptedWhileRequestingPermit());
       }
       finally
       {
          if (exception != null)
          {
             if (workListener != null)
             {
                WorkEvent event = new WorkEvent(this.workexception);
                workListener.workRejected(event);
             }
 
             if ()
                .tracef("Exception %s for %s"exceptionthis);
 
             deltaScheduleWorkRejected();
 
             throw exception;
          }
 
          if (wrapper != null)
             checkWorkCompletionException(wrapper);
       }
    }

   
Delta doWork accepted
 
    protected void deltaDoWorkAccepted()
    {
       if ()
          .deltaDoWorkAccepted();
    }

   
Delta doWork rejected
 
    protected void deltaDoWorkRejected()
    {
       if ()
          .deltaDoWorkRejected();
    }

   
Delta startWork accepted
 
    protected void deltaStartWorkAccepted()
    {
       if ()
          .deltaStartWorkAccepted();
    }

   
Delta startWork rejected
 
    protected void deltaStartWorkRejected()
    {
       if ()
          .deltaStartWorkRejected();
    }

   
Delta scheduleWork accepted
 
    protected void deltaScheduleWorkAccepted()
    {
       if ()
    }

   
Delta scheduleWork rejected
 
    protected void deltaScheduleWorkRejected()
    {
       if ()
    }

   
Delta work successful
 
    protected void deltaWorkSuccessful()
    {
       if ()
          .deltaWorkSuccessful();
    }

   
Delta work failed
 
    protected void deltaWorkFailed()
    {
       if ()
          .deltaWorkFailed();
    }

   
Do first checks for work starting methods

Parameters:
work to check
startTimeout to check
execContext to check
Throws:
javax.resource.spi.work.WorkException in case of check don't pass
 
    public void doFirstChecks(Work worklong startTimeoutExecutionContext execContextthrows WorkException
    {
       if (isShutdown())
          throw new WorkRejectedException(.workmanagerShutdown());
 
       if (work == null)
          throw new WorkRejectedException(.workIsNull());
 
       if (startTimeout < 0)
          throw new WorkRejectedException(.startTimeoutIsNegative(startTimeout));
 
       checkAndVerifyWork(workexecContext);
    }

   
 
    public boolean cancelShutdown()
    {
       .set(false);
       return true;
    }

   
 
    public void prepareShutdown()
    {
       .set(true);
    }

   
 
    public void shutdown()
    {
       prepareShutdown();
 
       synchronized ()
       {
          for (WorkWrapper ww : )
          {
             ww.getWork().release();
          }
       }
    }

   
 
    public boolean isShutdown()
    {
       return .get();
    }

   
Add work wrapper to active set

Parameters:
ww The work wrapper
 
    void addWorkWrapper(WorkWrapper ww)
    {
       synchronized ()
       {
          .add(ww);
 
          if ()
             .setWorkActive(.size());
       }
    }

   
Remove work wrapper from active set

Parameters:
ww The work wrapper
 
    {
       synchronized ()
       {
          .remove(ww);
 
          if ()
             .setWorkActive(.size());
       }
    }

   
Get the executor

Parameters:
work The work instance
Returns:
The executor
 
    private BlockingExecutor getExecutor(Work work)
    {
       BlockingExecutor executor = ;
       if ( != null && WorkManagerUtil.isLongRunning(work))
       {
          executor = ;
       }
 
       fireHintsComplete(work);
 
       return executor;
    }

   
Fire complete for HintsContext

Parameters:
work The work instance
 
    private void fireHintsComplete(Work work)
    {
       if (work != null && work instanceof WorkContextProvider)
       {
          WorkContextProvider wcProvider = (WorkContextProviderwork;
          List<WorkContextcontexts = wcProvider.getWorkContexts();
 
          if (contexts != null && contexts.size() > 0)
          {
             Iterator<WorkContextit = contexts.iterator();
             while (it.hasNext())
             {
                WorkContext wc = it.next();
                if (wc instanceof HintsContext)
                {
                   HintsContext hc = (HintsContextwc;
                   if (hc instanceof WorkContextLifecycleListener)
                   {
                      WorkContextLifecycleListener listener = (WorkContextLifecycleListener)hc;
                      listener.contextSetupComplete();   
                   }
                }
             }
          }
       }
    }

   
Check and verify work before submitting.

Parameters:
work the work instance
executionContext any execution context that is passed by apadater
Throws:
javax.resource.spi.work.WorkException if any exception occurs
 
    private void checkAndVerifyWork(Work workExecutionContext executionContextthrows WorkException
    {
       if ()
       {
          verifyWork(work);
       }
 
       if (work instanceof WorkContextProvider)
       {
          //Implements WorkContextProvider and not-null ExecutionContext
          if (executionContext != null)
          {
          }
       }
    }

   
Verify the given work instance.

Parameters:
work The work
Throws:
javax.resource.spi.work.WorkException Thrown if a spec compliant issue is found
 
    private void verifyWork(Work workthrows WorkException
    {
       Class<? extends WorkworkClass = work.getClass();
       String className = workClass.getName();
 
       if (!.contains(className))
       {
 
          if (isWorkMethodSynchronized(workClass))
             throw new WorkException(.runMethodIsSynchronized(className));
 
          if (isWorkMethodSynchronized(workClass))
             throw new WorkException(.releaseMethodIsSynchronized(className));
 
          .add(className);
       }
    }

   
Checks, if Work implementation class method is synchronized

Parameters:
workClass - implementation class
methodName - could be "run" or "release"
Returns:
true, if method is synchronized, false elsewhere
 
    private boolean isWorkMethodSynchronized(Class<? extends WorkworkClassString methodName)
    {
       try
       {
          Method method = workClass.getMethod(methodNamenew Class[0]);
          if (Modifier.isSynchronized(method.getModifiers()))
             return true;
       }
       catch (NoSuchMethodException e)
       {
          //Never happens, Work implementation should have these methods
       }
 
       return false;
    }

   
Checks work completed status.

Parameters:
wrapper work wrapper instance
Throws:
javax.resource.spi.work.WorkException if work is completed with an exception
 
    private void checkWorkCompletionException(WorkWrapper wrapperthrows WorkException
    {
       if (wrapper.getWorkException() != null)
       {
          if ()
             .tracef("Exception %s for %s"wrapper.getWorkException(), this);
 
          deltaWorkFailed();
 
          throw wrapper.getWorkException();
       }
 
       deltaWorkSuccessful();
    }

   
Setup work context's of the given work instance.

Parameters:
wrapper The work wrapper instance
workListener The work listener
Throws:
javax.resource.spi.work.WorkCompletedException if any work context related exceptions occurs
javax.resource.spi.work.WorkException if any exception occurs
   private void setup(WorkWrapper wrapperWorkListener workListenerthrows WorkCompletedExceptionWorkException
   {
      if ()
         .tracef("Setting up work: %s, work listener: %s"wrapperworkListener);
      Work work = wrapper.getWork();
      if ( != null)
      {
         if (work.getClass().getClassLoader() instanceof WorkClassLoader)
         {
            WorkClassLoader wcl = (WorkClassLoader)work.getClass().getClassLoader();
            ResourceAdapterClassLoader racl =
                                              wcl);
            wcl.setResourceAdapterClassLoader(racl);
         }
         if (work instanceof ResourceAdapterAssociation)
         {
            try
            {
               ResourceAdapterAssociation raa = (ResourceAdapterAssociation)work;
               raa.setResourceAdapter();
            }
            catch (Throwable t)
            {
               throw new WorkException(.resourceAdapterAssociationFailed(work.getClass().getName()), t);
            }
         }
      }
      //If work is an instanceof WorkContextProvider
      if (work instanceof WorkContextProvider)
      {
         WorkContextProvider wcProvider = (WorkContextProviderwork;
         List<WorkContextcontexts = wcProvider.getWorkContexts();
         if (contexts != null && contexts.size() > 0)
         {
            boolean isTransactionContext = false;
            boolean isSecurityContext = false;
            boolean isHintcontext = false;
            for (WorkContext context : contexts)
            {
               Class<? extends WorkContextcontextType = null;
               // Get supported work context class
               contextType = getSupportedWorkContextClass(context.getClass());
               // Not supported
               if (contextType == null)
               {
                  if ()
                  {
                     .trace("Not supported work context class : " + context.getClass().getName());
                  }
                  WorkCompletedException wce =
                     new WorkCompletedException(.unsupportedWorkContextClass(context.getClass().getName()),
                                                .);
                                             workListenerworkwce);
                  throw wce;
               }
               // Duplicate checks
               else
               {
                  // TransactionContext duplicate
                  if (isTransactionContext(contextType))
                  {
                     if (isTransactionContext)
                     {
                        if ()
                        {
                           .trace("Duplicate transaction work context : " + context.getClass().getName());
                        }
                        WorkCompletedException wce =
                           new WorkCompletedException(.duplicateTransactionWorkContextClass(context.getClass()
                              .getName()), .);
                        fireWorkContextSetupFailed(context.,
                                                   workListenerworkwce);
                        throw wce;
                     }
                     else
                     {
                        isTransactionContext = true;
                     }
                  }
                  // SecurityContext duplicate
                  else if (isSecurityContext(contextType))
                  {
                     if (isSecurityContext)
                     {
                        if ()
                        {
                           .trace("Duplicate security work context : " + context.getClass().getName());
                        }
                        WorkCompletedException wce =
                           new WorkCompletedException(.duplicateSecurityWorkContextClass(context.getClass()
                              .getName()), .);
                        fireWorkContextSetupFailed(context.,
                                                   workListenerworkwce);
                        throw wce;
                     }
                     else
                     {
                        isSecurityContext = true;
                     }
                  }
                  // HintContext duplicate
                  else if (isHintContext(contextType))
                  {
                     if (isHintcontext)
                     {
                        if ()
                        {
                           .trace("Duplicate hint work context : " + context.getClass().getName());
                        }
                        WorkCompletedException wce =
                           new WorkCompletedException(.duplicateHintWorkContextClass(context.getClass()
                              .getName()), .);
                        fireWorkContextSetupFailed(context.,
                                                   workListenerworkwce);
                        throw wce;
                     }
                     else
                     {
                        isHintcontext = true;
                     }
                  }
               }
               // Add workcontext instance to the work
               wrapper.addWorkContext(contextTypecontext);
            }
         }
      }
   }

   
Calls listener with given error code.

Parameters:
workContext work context listener
errorCode error code
workListener work listener
work work instance
exception exception
   private void fireWorkContextSetupFailed(Object workContextString errorCode,
                                           WorkListener workListenerWork workWorkException exception)
   {
      if (workListener != null)
      {
         WorkEvent event = new WorkEvent(this.worknull);
         workListener.workStarted(event);
      }
      if (workContext instanceof WorkContextLifecycleListener)
      {
         WorkContextLifecycleListener listener = (WorkContextLifecycleListenerworkContext;
         listener.contextSetupFailed(errorCode);
      }
      if (workListener != null)
      {
         WorkEvent event = new WorkEvent(this.workexception);
         workListener.workCompleted(event);
      }
   }

   
Returns true if contexts is a transaction context.

Parameters:
workContextType context type
Returns:
true if contexts is a transaction context
   private boolean isTransactionContext(Class<? extends WorkContextworkContextType)
   {
      if (workContextType.isAssignableFrom(TransactionContext.class))
      {
         return true;
      }
      return false;
   }

   
Returns true if contexts is a security context.

Parameters:
workContextType context type
Returns:
true if contexts is a security context
   private boolean isSecurityContext(Class<? extends WorkContextworkContextType)
   {
      if (workContextType.isAssignableFrom(SecurityContext.class))
      {
         return true;
      }
      return false;
   }

   
Returns true if contexts is a hint context.

Parameters:
workContextType context type
Returns:
true if contexts is a hint context
   private boolean isHintContext(Class<? extends WorkContextworkContextType)
   {
      if (workContextType.isAssignableFrom(HintsContext.class))
      {
         return true;
      }
      return false;
   }

   
Returns work context class if given work context is supported by server, returns null instance otherwise.

Parameters:
<T> work context class
adaptorWorkContext adaptor supplied work context class
Returns:
work context class
   @SuppressWarnings("unchecked")
   private <T extends WorkContextClass<T> getSupportedWorkContextClass(Class<T> adaptorWorkContext)
   {
      for (Class<? extends WorkContextsupportedWorkContext : )
      {
         // Assignable or not
         if (supportedWorkContext.isAssignableFrom(adaptorWorkContext))
         {
            Class clz = adaptorWorkContext;
            while (clz != null)
            {
               // Supported by the server
               if (clz.equals(supportedWorkContext))
               {
                  return clz;
               }
               clz = clz.getSuperclass();
            }
         }
      }
      return null;
   }

   
String representation

Returns:
The string
   public String toString()
   {
      StringBuilder sb = new StringBuilder();
      sb.append(getClass().getName()).append("@").append(Integer.toHexString(System.identityHashCode(this)));
      sb.append("[id=").append(getId());
      sb.append(" name=").append();
      sb.append(" specCompliant=").append();
      sb.append(" shortRunningExecutor=").append();
      sb.append(" longRunningExecutor=").append();
      sb.append(" xaTerminator=").append();
      sb.append(" validatedWork=").append();
      sb.append(" callbackSecurity=").append();
      sb.append(" resourceAdapter=").append();