Package org.jboss.mx.loading.ClassLoadingTask

Examples of org.jboss.mx.loading.ClassLoadingTask.ThreadTask


            task.state = ClassLoadingTask.WAIT_ON_EVENT;
         }
         return;
      }

      ThreadTask threadTask = (ThreadTask) taskList.removeFirst();
      ClassLoadingTask loadTask = threadTask.getLoadTask();

      if( trace )
         log.trace("Begin nextTask("+taskList.size()+"), LoadTask="+loadTask);
      try
      {
         if( threadTask.t == null )
         {
            if( trace )
               log.trace("Rescheduling threadTask="+threadTask);
            // This is a task without a thread, schedule it
            scheduleTask(loadTask, threadTask.ucl, threadTask.order, true, trace);
         }
         else
         {
            if( trace )
               log.trace("Running threadTask="+threadTask);
            // Load the class using this thread
            threadTask.run();
         }
      }
      catch(Throwable e)
      {
         loadTask.loadException = e;
      }
      finally
      {
         // We must release the loadLock acquired in beginLoadTask
         if( threadTask.releaseInNextTask == true )
         {
            if( trace )
               log.trace("Releasing loadLock and ownership of UCL: "+threadTask.ucl);
            loadClassThreads.remove(threadTask.ucl);
            synchronized( threadTask.ucl )
            {
               threadTask.ucl.release();
               threadTask.ucl.notifyAll();
            }
         }
      }

      // If the ThreadTasks are complete mark the ClassLoadingTask finished
      if( loadTask.threadTaskCount == 0 )
      {
         Class loadedClass = threadTask.getLoadedClass();
         if( loadedClass != null )
         {
            ClassLoader loader = loadedClass.getClassLoader();
            // Place the loaded class into the repositry cache
            repository.cacheLoadedClass(threadTask.getClassname(),
               loadedClass, loader);
         }
         synchronized( loadTask )
         {
            loadTask.state = ClassLoadingTask.FINISHED;
View Full Code Here


      int size = taskList != null ? taskList.size() : 0;
      synchronized( taskList )
      {
         for(int i = 0; i < size; i ++)
         {
            ThreadTask threadTask = (ThreadTask) taskList.removeFirst();
            ClassLoadingTask loadTask = threadTask.getLoadTask();
            // Insert the task into the requestingThread task list
            if( trace )
               log.trace("Reassigning task: "+threadTask+", to: "+loadTask.requestingThread);
            threadTask.t = null;
            LinkedList toTaskList = (LinkedList) loadTasksByThread.get(loadTask.requestingThread);
View Full Code Here

               }
            }
         }
      }

      ThreadTask subtask = task.newThreadTask(ucl, t, order, reschedule,
         releaseInNextTask);
      // Add the task to the owning thread
      LinkedList taskList = (LinkedList) loadTasksByThread.get(t);
      taskList.add(subtask);
      // Order the tasks by either the heirarchial order, or the repository order
View Full Code Here

            log.trace("End nextTask(FINISHED), task="+task);
            return;
         }
      }

      ThreadTask threadTask = (ThreadTask) taskList.remove(0);
      ClassLoadingTask loadTask = threadTask.getLoadTask();
      if( trace )
         log.trace("Begin nextTask("+taskList.size()+"), loadTask="+loadTask);

      RepositoryClassLoader ucl3 = threadTask.ucl;
      try
      {
         if( threadTask.t == null )
         {
            /* This is a task that has been reassigned back to the original
            requesting thread ClassLoadingTask, so a new ThreadTask must
            be scheduled.
            */
            if( trace )
               log.trace("Rescheduling threadTask="+threadTask);
            scheduleTask(loadTask, ucl3, threadTask.order, true, trace);
         }
         else
         {
            if( trace )
               log.trace("Running threadTask="+threadTask);
            // Load the class using this thread
            threadTask.run();
         }
      }
      catch(Throwable e)
      {
       log.trace("Class loading Task Run failed with exception", e);
       boolean retry = e instanceof ClassCircularityError
            || e.getClass().equals(LinkageError.class);
         int numCCE = loadTask.incNumCCE();
        
         if( retry && numCCE <= 10 )
         {
            log.info("Rescheduling failed Class loading Task");
          /* Reschedule this task after all existing tasks to allow the
            current load tasks which are conflicting to complete.
            */
            try
            {
               // Reschedule and update the loadTask.threadTaskCount
               scheduleTask(loadTask, ucl3, Integer.MAX_VALUE, true, trace);
            }
            catch(Throwable ex)
            {
               loadTask.setLoadError(ex);
               log.error("Failed to reschedule task after LinkageError", ex);              
            }
            if( trace )
               log.trace("Post LinkageError state, loadTask="+loadTask);
         }
         else
         {
            loadTask.setLoadError(e);
            log.error("Not resheduling failed loading task, loadTask="+loadTask, e);
         }
      }
      finally
      {
         // We must release the loadLock acquired in beginLoadTask
         if( threadTask.releaseInNextTask == true )
         {
            if( trace )
               log.trace("Releasing loadLock and ownership of UCL: "+threadTask.ucl);
            synchronized( registrationLock )
            {
               loadClassThreads.remove(threadTask.ucl);
            }
            synchronized( threadTask.ucl )
            {
               ucl3.release();
               ucl3.notifyAll();
            }
         }
      }

      // If the ThreadTasks are complete mark the ClassLoadingTask finished
      if( loadTask.threadTaskCount == 0 )
      {
         Class loadedClass = threadTask.getLoadedClass();
         if( loadedClass != null )
         {
            ClassLoader loader = loadedClass.getClassLoader();
            ClassLoader wrapper = repository.getWrappingClassLoader(loader);
            if (wrapper != null)
               loader=wrapper;
            // Place the loaded class into the repositry cache
            repository.cacheLoadedClass(threadTask.getClassname(),
               loadedClass, loader);
         }
         /*
         synchronized( loadTask )
         {
View Full Code Here

      int size = taskList != null ? taskList.size() : 0;
      synchronized( taskList )
      {
         for(int i = 0; i < size; i ++)
         {
            ThreadTask threadTask = (ThreadTask) taskList.remove(0);
            ClassLoadingTask loadTask = threadTask.getLoadTask();
            /* Synchronize on loadTask and reassign the thread task back to the
            requesting thread of loadTask. We need to synchronize on loadTask
            to ensure that the transfer of this task back to loadTask.requestingThread
            is atomic wrt loadTask.requestingThread checking its task list.
            synchronized( loadTask )
View Full Code Here

   static private void scheduleTask(ClassLoadingTask task, RepositoryClassLoader ucl,
      int order, boolean reschedule, boolean trace) throws ClassNotFoundException
   {
      Thread t = null;
      boolean releaseInNextTask = false;
      ThreadTask subtask = null;
      List taskList = null;
      synchronized( registrationLock )
      {
         // Find the thread that owns the ucl
         t = (Thread) loadClassThreads.get(ucl);
View Full Code Here

TOP

Related Classes of org.jboss.mx.loading.ClassLoadingTask.ThreadTask

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.