Package com.brienwheeler.lib.svc

Examples of com.brienwheeler.lib.svc.ServiceOperationException


  {
    try {
      return resource.getFile().lastModified();
    }
    catch (IOException e) {
      throw new ServiceOperationException("error determining lastModified time for ClassPathTemplateSource " + resource.getPath(), e);
    }
  }
View Full Code Here


      StringWriter writer = new StringWriter();
      template.process(templateModel, writer);
      doSendEmail(recipient, defaultSubject, writer.toString());
    }
    catch (Exception e) {
      throw new ServiceOperationException(e);
    }
  }
View Full Code Here

      message.setText(body);
      Transport.send(message);
      log.info("sent email to " + recipient.getAddress() + " (" + subject + ")");
    }
    catch (MessagingException e) {
      throw new ServiceOperationException(e);
    }
  }
View Full Code Here

            done = true;
            break;
           
          case STARTING :
            if (waitForStateChangeEx() != ServiceState.RUNNING)
              throw new ServiceOperationException("start operation in other thread failed");
            break;
             
          case STOPPING :
            waitForStateChangeEx();
            break;
           
          case STOP_FAILED :
            throw new ServiceOperationException("previous stop operation failed");
           
          case RUNNING :
            incrementRefCount();
            return;
        }
      }
    }
   
    try
    {
      registerWithWorkPublishers();
     
      if (autoStartSubServices)
        autoStartSubServices();
     
      onStart();
     
      synchronized (state)
      {
        changeState(ServiceState.RUNNING);
        incrementRefCount();
      }
    }
    catch (InterruptedException e)
    {
      cleanPartialStart();
      Thread.currentThread().interrupt();
      throw new ServiceOperationException("start operation thread interrupted", e);
    }
    catch (RuntimeException e)
    {
      cleanPartialStart();
      throw e;
View Full Code Here

    try {
      return waitForStateChange();
    }
    catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new ServiceOperationException("service operation thread interrupted", e);
    }
  }
View Full Code Here

          case STOPPED :
            return;
           
          case STOPPING :
            if (waitForStateChangeEx() != ServiceState.STOPPED)
              throw new ServiceOperationException("stop operation in other thread failed");
            return;
           
          case STOP_FAILED :
            throw new ServiceOperationException("previous stop operation failed");

          case STARTING :
            waitForStateChangeEx();
            break;
         
          case RUNNING :
            int newRefCount = decrementRefCount();
            if (newRefCount > 0)
              return;
           
            changeState(ServiceState.STOPPING);
            done = true;
            break;
        }
      }
     
      // wait supplied grace period, then interrupt any threads working in the service
      if (!serviceThreads.isEmpty())
      {
        // wait for threads to drain.  < 0 means wait forever, 0 means don't wait, > 0 means number
        // of milliseconds to wait
        long now = System.currentTimeMillis();
        long drainEnd = gracePeriod < 0 ? Long.MAX_VALUE : now + gracePeriod;
        while (!serviceThreads.isEmpty() && (now < drainEnd))
        {
          try {
            if (log.isDebugEnabled())
              log.debug(logId + ": waiting " + (drainEnd - now) + "ms for worker threads to drain");
            state.wait(drainEnd - now);
            now = System.currentTimeMillis();
          }
          catch (InterruptedException e) {
            interrupted = true;
            error = new ServiceOperationException("stop operation thread interrupted", e);
            break;
          }
        }

        for (Thread serviceThread : serviceThreads)
        {
          if (log.isDebugEnabled())
            log.debug(logId + ": interrupting worker thread " + ObjectUtils.getUniqueId(serviceThread));
          serviceThread.interrupt();
        }
      }
    }

    // first call subclass onStop()
    try {
      onStop();
    }
    catch (InterruptedException e) {
      interrupted = true;
      // don't overwrite potential SOE from InterruptedException handler above
      if (error == null)
        error = new ServiceOperationException("stop operation thread interrupted", e);
    }
    catch (RuntimeException e)
    {
      // don't overwrite potential SOE from InterruptedException handler above
      if (error == null)
View Full Code Here

TOP

Related Classes of com.brienwheeler.lib.svc.ServiceOperationException

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.