Package org.eclipse.jetty.util

Examples of org.eclipse.jetty.util.MultiException


    }
   
  @Override
    public void scan() throws Exception
    {
      MultiException mex = new MultiException();
        if (getContexts() == null)
            throw new IllegalArgumentException("No HandlerContainer");
       
        Resource r = Resource.newResource(getWebAppDir());
        if (!r.exists())
            throw new IllegalArgumentException("No such sipapps resource "+r);

        if (!r.isDirectory())
            throw new IllegalArgumentException("Not directory sipapps resource "+r);

        String[] files = r.list();

        files: for (int f = 0; files != null && f < files.length; f++)
        {
          try
          {
              String context = files[f];
 
              if (context.equalsIgnoreCase("CVS/") || context.equalsIgnoreCase("CVS")||context.startsWith("."))
                  continue;
 
              Resource app = r.addPath(r.encode(context));
 
              if (context.toLowerCase().endsWith(".war")
                  || context.toLowerCase().endsWith(".jar")
                  || context.toLowerCase().endsWith(".sar"))
              {
                context = context.substring(0, context.length() - 4);
                  Resource unpacked = r.addPath(context);
                  if (unpacked != null && unpacked.exists() && unpacked.isDirectory())
                      continue;
              }
              else if (!app.isDirectory())
              {
                  continue;
              }
 
              if (context.equalsIgnoreCase("root") || context.equalsIgnoreCase("root/"))
                  context = URIUtil.SLASH;
              else
                  context = "/" + context;
             
              if (context.endsWith("/") && context.length() > 0)
                  context = context.substring(0, context.length() - 1);
 
              // Check the context path has not already been added or the webapp itself is not already deployed
              if (!getAllowDuplicates())
              {             
                  Handler[] installed = getContexts().getChildHandlersByClass(ContextHandler.class);
                  for (int i=0; i<installed.length; i++)
                  {
                      ContextHandler c=(ContextHandler)installed[i];
                     
                      if (c instanceof SipAppContext)
                      {
                        SipAppContext sipAppContext = (SipAppContext) c;
                        if (context.equals(sipAppContext.getContextPath()))
                           continue files;
                      }
                     
                      if (context.equals(c.getContextPath()))
                          continue files;
                     
                      if (c.getBaseResource()!=null && c.getBaseResource().getFile().getAbsolutePath().equals(app.getFile().getAbsolutePath()))
                          continue files;         
                  }
              }
 
              // create a sipapp
              SipAppContext sac = null;
              if (getContexts() instanceof ContextHandlerCollection &&
                  SipAppContext.class.isAssignableFrom(((ContextHandlerCollection) getContexts()).getContextClass()))
              {
                  try
                  {
                      sac =(SipAppContext)((ContextHandlerCollection) getContexts()).getContextClass().newInstance();
                  }
                  catch (Exception e)
                  {
                      throw new Error(e);
                  }
              } else
              {
                  sac = new SipAppContext();
              }
             
              // configure it
              sac.setContextPath(context);
              if (getConfigurationClasses() != null)
                  sac.setConfigurationClasses(getConfigurationClasses());
             
              if (getDefaultsDescriptor() != null)
                  sac.setDefaultsDescriptor(getDefaultsDescriptor());
             
              if (getDefaultsSipDescriptor() != null)
                sac.setDefaultsSipDescriptor(getDefaultsSipDescriptor());
             
              sac.setExtractWAR(isExtract());
              sac.setWar(app.toString());
              sac.setParentLoaderPriority(isParentLoaderPriority());
             
              // add it
              getContexts().addHandler(sac);
              _deployed.add(sac);
             
              if (getContexts().isStarted())
                  sac.start();
          }
          catch (Throwable e)
          {
            mex.add(e);
      }
        }
        mex.ifExceptionThrow();
    }
View Full Code Here


    }
   
    @Override
    public void doStop() throws Exception
    {
      MultiException mex = new MultiException();
        for (int i = _deployed.size(); i-- > 0;)
        {
            ContextHandler wac = (ContextHandler)_deployed.get(i);
            try { wac.stop(); } catch (Throwable e) { mex.add(e);}
        }
        mex.ifExceptionThrow();
    }
View Full Code Here

 
  @SuppressWarnings("unchecked")
  public void contextDestroyed(ServletContextEvent event)
  { 
    Enumeration enumeration = event.getServletContext().getAttributeNames();
    MultiException mex = new MultiException();
   
    while (enumeration.hasMoreElements())
    {
      String key = (String) enumeration.nextElement();
      Object o = event.getServletContext().getAttribute(key);
     
      try
      {
        if (o instanceof LifeCycle)
          ((LifeCycle) o).stop();
      }
      catch (Exception e)
      {
        mex.add(e);
      }
    }
    try
    {
      mex.ifExceptionThrow();
    }
    catch (Exception e)
    {
      _log.warn("error while stopping kaleo", mex);
    }
View Full Code Here

  }
 
  @Override
  protected void doStop() throws Exception
 
    MultiException mex = new MultiException();
   
    synchronized (this)
    {
      if (_peers != null)
      {
        for (Peer peer : _peers)
        {
          try
          {
            peer.stop();
          }
          catch (Exception e)
          {
            Log.warn("failed to stop peer: " + peer, e);
          }
        }
       
        // Wait at most 1 seconds for DPA reception
        try
        {
          boolean allClosed = false;
          int iter = 20;
          while (iter-- > 0 && allClosed)
          {
            allClosed = true;
            for (Peer peer : _peers)
            {
              if (!peer.isClosed())
              {
                allClosed = false;
                Log.info("Wait 50ms for " + peer + " closing");
                Thread.sleep(50);
                break;
              }
            }
          }
        }
        catch (Exception e)
        {
          Log.ignore(e);
        }
      }
    } 
   
    if (_scheduler != null)
      _scheduler.shutdown();
   
    for (int i = 0; _connectors != null && i < _connectors.length; i++)
    {
      if (_connectors[i] instanceof LifeCycle)  
      {
        try
        {
          ((LifeCycle) _connectors[i]).stop();
        }
        catch (Exception e)
        {
          mex.add(e);
        }
      }
    }
       
    if (_router != null && _router instanceof LifeCycle)
      ((LifeCycle) _router).stop();
   
    mex.ifExceptionThrow();
  }
View Full Code Here

  @Override
  protected void doStart() throws Exception
    {
    Log.info("cipango-" + __sipVersion);

    MultiException mex = new MultiException();
   
    if (_sipThreadPool == null)
      setSipThreadPool(new QueuedThreadPool());
   
    if (_sessionManager == null)
      setSessionManager(new SessionManager());
   
    try
    {
      super.doStart();
    }
    catch (Throwable t) { mex.add(t); }

    if (_applicationRouter == null)
      setApplicationRouter(ApplicationRouterLoader.loadApplicationRouter());

    try
    {
      _applicationRouter.init();
     
      List<String> appNames = new ArrayList<String>();
      SipAppContext[] contexts = ((SipContextHandlerCollection) getHandler()).getSipContexts();
      if (contexts != null)
      {
        for (SipAppContext context : contexts)
          if (context.hasSipServlets() && context.isAvailable())
            appNames.add(context.getName());
      }
      _applicationRouter.applicationDeployed(appNames);
     
      _sessionManager.start();
      _connectorManager.start();
     
      if (contexts != null)
      {
        for (SipAppContext context : contexts)
          context.serverStarted();
      }
    }
    catch (Throwable t) { mex.add(t); }
   
    mex.ifExceptionThrow();
   
    Events.fire(Events.START, "Cipango " + __sipVersion + " started");
  }
View Full Code Here

  @Override
    protected void doStop() throws Exception
    {
    Events.fire(Events.STOP, "Stopping Cipango " + __sipVersion);
   
      MultiException mex = new MultiException();
       
        try
        {
          _applicationRouter.destroy();
          _connectorManager.stop();
        _sessionManager.stop();
    }
        catch (Throwable e) { mex.add(e); }

        try
        {
      super.doStop();
    }
        catch (Throwable e) { mex.add(e); }
              
        mex.ifExceptionThrow();
    }
View Full Code Here

    DiameterMessageListener[] oldLoggers = _listeners == null ? null : _listeners.clone();
    if (_server != null)
      _server.getContainer().update(this, oldLoggers, loggers, "loggers", true);
    _listeners = loggers;

    MultiException mex = new MultiException();
    for (int i = 0; oldLoggers != null && i < oldLoggers.length; i++)
    {
      if (oldLoggers[i] != null)
      {
        try
        {
          if (oldLoggers[i] instanceof LifeCycle)
          {
            LifeCycle lifeCycle = (LifeCycle) oldLoggers[i];
            if (lifeCycle.isStarted())
              lifeCycle.stop();
          }
        }
        catch (Throwable e)
        {
          mex.add(e);
        }
      }
    }
    if (isStarted())
      try { doStart(); } catch (Throwable e) { mex.add(e); }
   
    mex.ifExceptionThrowRuntime();
  }
View Full Code Here

        }
    }

    protected void doStop() throws Exception
    {
        MultiException mex = new MultiException();
       
        if (_connectors != null)
        {
            for (int i = _connectors.length; i--> 0;)
            {
                try
                {
                    _connectors[i].stop();
                }
                catch(Throwable e)
                {
                    mex.add(e);
                }
            }
        }
       

      if (_accessLog instanceof LifeCycle)
        try { ((LifeCycle) _accessLog).stop(); } catch (Throwable t) { Log.warn(t); }
       
        super.doStop();
       
        mex.ifExceptionThrow();
    }
View Full Code Here

    AccessLog[] oldLoggers = _loggers == null ? null : _loggers.clone();
    if (_server != null)
      _server.getContainer().update(this, oldLoggers, loggers, "loggers", true);
    _loggers = loggers;

    MultiException mex = new MultiException();
    for (int i = 0; oldLoggers != null && i < oldLoggers.length; i++)
    {
      if (oldLoggers[i] != null)
      {
        try
        {
          if (oldLoggers[i] instanceof LifeCycle)
          {
            LifeCycle lifeCycle = (LifeCycle) oldLoggers[i];
            if (lifeCycle.isStarted())
              lifeCycle.stop();
          }
        }
        catch (Throwable e)
        {
          mex.add(e);
        }
      }
    }
    if (isStarted())
      try { doStart(); } catch (Throwable e) { mex.add(e); }
   
    mex.ifExceptionThrowRuntime();
  }
View Full Code Here

       
  }
 
  protected void doStop() throws Exception
  {
    MultiException mx = new MultiException();
   
    try { super.doStop(); } catch(Exception e) { mx.add(e); }
     
    if (_sipServlets != null)
    {
          for (int i = _sipServlets.length; i-- > 0;)
          {
              try
              {
                _sipServlets[i].stop();
              }
              catch(Exception e)
              {
                  Log.warn(Log.EXCEPTION, e);
                  //mx.add(e);
              }
          }
    }
        mx.ifExceptionThrow()
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.util.MultiException

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.