Пример #1
0
  public void stop() throws LifecycleException {
    System.out.println("Stopping wrapper " + name);
    // Shut down our servlet instance (if it has been initialized)
    try {
      instance.destroy();
    } catch (Throwable t) {
    }
    instance = null;
    if (!started) throw new LifecycleException("Wrapper " + name + " not started");
    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(STOP_EVENT, null);
    started = false;

    // Stop the Valves in our pipeline (including the basic), if any
    if (pipeline instanceof Lifecycle) {
      ((Lifecycle) pipeline).stop();
    }

    // Stop our subordinate components, if any
    if ((loader != null) && (loader instanceof Lifecycle)) {
      ((Lifecycle) loader).stop();
    }

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
  }
Пример #2
0
  /**
   * Gracefully shut down active use of the public methods of this Component.
   *
   * @exception IllegalStateException if this component has not been started
   * @exception LifecycleException if this component detects a fatal error that needs to be reported
   */
  public synchronized void stop() throws LifecycleException {

    // Validate and update our current component state
    if (!started) throw new LifecycleException(rb.getString(PIPLINE_NOT_STARTED));

    started = false;

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(STOP_EVENT, null);

    // Stop the Valves in our pipeline (including the basic), if any
    if ((basic != null) && (basic instanceof Lifecycle)) ((Lifecycle) basic).stop();
    /**
     * CR 6411114 (MBean deregistration moved to ValveBase.stop()) if( basic!=null ) {
     * unregisterValve(basic); }
     */
    for (int i = 0; i < valves.length; i++) {
      if (valves[i] instanceof Lifecycle) ((Lifecycle) valves[i]).stop();
      /** CR 6411114 (MBean deregistration moved to ValveBase.stop()) unregisterValve(valves[i]); */
    }

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
  }
 // ---------------------------------------------- Public Methods
 public void start() throws LifecycleException {
   lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, null);
   TaskQueue taskqueue = new TaskQueue(maxQueueSize);
   TaskThreadFactory tf = new TaskThreadFactory(namePrefix);
   lifecycle.fireLifecycleEvent(START_EVENT, null);
   executor =
       new ThreadPoolExecutor(
           getMinSpareThreads(),
           getMaxThreads(),
           maxIdleTime,
           TimeUnit.MILLISECONDS,
           taskqueue,
           tf) {
         @Override
         protected void afterExecute(Runnable r, Throwable t) {
           AtomicInteger atomic = submittedTasksCount;
           if (atomic != null) {
             atomic.decrementAndGet();
           }
         }
       };
   taskqueue.setParent((ThreadPoolExecutor) executor);
   submittedTasksCount = new AtomicInteger();
   lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
 }
 public void stop() throws LifecycleException {
   lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);
   lifecycle.fireLifecycleEvent(STOP_EVENT, null);
   if (executor != null) executor.shutdown();
   executor = null;
   submittedTasksCount = null;
   lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
 }
  /**
   * Gracefully terminate the active use of the public methods of this component. This method should
   * be the last one called on a given instance of this component.
   *
   * @exception LifecycleException if this component detects a fatal error that needs to be reported
   */
  public void stop() throws LifecycleException {

    if (debug >= 1) log("Stopping");

    // Validate and update our current component state
    if (!started) throw new LifecycleException(sm.getString("standardManager.notStarted"));
    lifecycle.fireLifecycleEvent(STOP_EVENT, null);
    started = false;

    // Stop the background reaper thread
    threadStop();

    // Write out sessions
    try {
      unload();
    } catch (IOException e) {
      log(sm.getString("standardManager.managerUnload"), e);
    }

    // Expire all active sessions
    Session sessions[] = findSessions();
    for (int i = 0; i < sessions.length; i++) {
      StandardSession session = (StandardSession) sessions[i];
      if (!session.isValid()) continue;
      try {
        session.expire();
      } catch (Throwable t) {;
      }
    }

    // Require a new random number generator if we are restarted
    this.random = null;
  }
Пример #6
0
  /**
   * Invoke a pre-startup initialization. This is used to allow connectors to bind to restricted
   * ports under Unix operating environments.
   */
  public void initialize() throws LifecycleException {
    if (initialized) {
      log.info(sm.getString("standardServer.initialize.initialized"));
      return;
    }
    lifecycle.fireLifecycleEvent(INIT_EVENT, null);
    initialized = true;

    if (oname == null) {
      try {
        oname = new ObjectName("Catalina:type=Server");
        Registry.getRegistry(null, null).registerComponent(this, oname, null);
      } catch (Exception e) {
        log.error("Error registering ", e);
      }
    }

    // Register global String cache
    try {
      ObjectName oname2 = new ObjectName(oname.getDomain() + ":type=StringCache");
      Registry.getRegistry(null, null).registerComponent(new StringCache(), oname2, null);
    } catch (Exception e) {
      log.error("Error registering ", e);
    }

    // Initialize our defined Services
    for (int i = 0; i < services.length; i++) {
      services[i].initialize();
    }
  }
Пример #7
0
  /**
   * Stop the background thread we will use for request processing.
   *
   * @exception LifecycleException if a fatal shutdown error occurs
   */
  public void stop() throws LifecycleException {

    if (!started) throw new LifecycleException(sm.getString("httpProcessor.notStarted"));
    lifecycle.fireLifecycleEvent(STOP_EVENT, null);
    started = false;

    threadStop();
  }
Пример #8
0
  /**
   * Start the background thread we will use for request processing.
   *
   * @exception LifecycleException if a fatal startup error occurs
   */
  public void start() throws LifecycleException {

    if (started) throw new LifecycleException(sm.getString("httpProcessor.alreadyStarted"));
    lifecycle.fireLifecycleEvent(START_EVENT, null);
    started = true;

    threadStart();
  }
 /**
  * Gracefully terminate the active use of the public methods of this component. This method should
  * be the last one called on a given instance of this component.
  *
  * @exception LifecycleException if this component detects a fatal error that needs to be reported
  */
 public void stop() throws LifecycleException {
   // Validate and update our current component state
   if (!started) {
     return;
   }
   lifecycle.fireLifecycleEvent(STOP_EVENT, null);
   started = false;
 }
  /**
   * Gracefully terminate the active use of the public methods of this component. This method should
   * be the last one called on a given instance of this component.
   *
   * @exception LifecycleException if this component detects a fatal error that needs to be reported
   */
  public void stop() throws LifecycleException {

    // Validate and update our current component state
    if (!started) throw new LifecycleException(sm.getString("authenticator.notStarted"));
    lifecycle.fireLifecycleEvent(STOP_EVENT, null);
    started = false;

    sso = null;
  }
Пример #11
0
  /**
   * Gracefully terminate the active use of the public methods of this component. This method should
   * be the last one called on a given instance of this component. It should also send a
   * LifecycleEvent of type STOP_EVENT to any registered listeners.
   *
   * @throws LifecycleException if this component detects a fatal error that needs to be reported
   */
  public void stop() throws LifecycleException {

    // Validate and update our current component state
    if (!started) throw new LifecycleException(sm.getString("realmBase.notStarted"));
    lifecycle.fireLifecycleEvent(STOP_EVENT, null);
    started = false;

    // Clean up allocated resources
    md = null;
  }
Пример #12
0
  public synchronized void start() throws LifecycleException {
    System.out.println("Starting Wrapper " + name);
    if (started) throw new LifecycleException("Wrapper already started");

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, null);
    started = true;

    // Start our subordinate components, if any
    if ((loader != null) && (loader instanceof Lifecycle)) ((Lifecycle) loader).start();

    // Start the Valves in our pipeline (including the basic), if any
    if (pipeline instanceof Lifecycle) ((Lifecycle) pipeline).start();

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(START_EVENT, null);
    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
  }
Пример #13
0
  /**
   * Gracefully terminate the active use of the public methods of this component. This method should
   * be the last one called on a given instance of this component.
   *
   * @throws IllegalStateException if this component has not been started_
   * @throws org.apache.catalina.LifecycleException if this component detects a fatal error that
   *     needs to be reported
   */
  protected void stopManager() throws LifecycleException {
    log_.debug("Stopping JBossManager");

    // Validate and update our current component state
    if (!started_) throw new LifecycleException("JBossManager notStarted");
    lifecycle_.fireLifecycleEvent(STOP_EVENT, null);
    started_ = false;

    // unregister from the MBeanServer
    unregisterManagerMBean();
  }
  /**
   * Prepare for the beginning of active use of the public methods of this component. This method
   * should be called after <code>configure()</code>, and before any of the public methods of the
   * component are utilized.
   *
   * @exception LifecycleException if this component detects a fatal error that prevents this
   *     component from being used
   */
  public void start() throws LifecycleException {

    // Validate and update our current component state
    if (started) {
      throw new LifecycleException(sm.getString("requestFilterValve.alreadyStarted"));
    }
    if (!allowValid || !denyValid) {
      throw new LifecycleException(sm.getString("requestFilterValve.configInvalid"));
    }
    lifecycle.fireLifecycleEvent(START_EVENT, null);
    started = true;
  }
  /**
   * Gracefully shut down active use of the public methods of this Component.
   *
   * @throws LifecycleException if this component detects a fatal error that needs to be reported
   */
  public synchronized void stop() throws LifecycleException {

    // Validate and update our current component state
    if (!started) throw new LifecycleException(sm.getString("standardPipeline.notStarted"));

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(STOP_EVENT, null);
    started = false;

    // Stop the Valves in our pipeline (including the basic), if any
    if ((basic != null) && (basic instanceof Lifecycle)) ((Lifecycle) basic).stop();
    for (int i = 0; i < valves.length; i++) {
      if (valves[i] instanceof Lifecycle) ((Lifecycle) valves[i]).stop();
    }

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
  }
Пример #16
0
  /**
   * Gracefully terminate the active use of the public methods of this component. This method should
   * be the last one called on a given instance of this component. It should also send a
   * LifecycleEvent of type STOP_EVENT to any registered listeners.
   *
   * @exception LifecycleException if this component detects a fatal error that needs to be reported
   */
  public void stop() throws LifecycleException {

    // Validate and update our current component state
    if (!started) return;

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);

    lifecycle.fireLifecycleEvent(STOP_EVENT, null);
    started = false;

    // Stop our defined Services
    for (int i = 0; i < services.length; i++) {
      if (services[i] instanceof Lifecycle) ((Lifecycle) services[i]).stop();
    }

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);

    if (port == -1) stopAwait();
  }
Пример #17
0
  /**
   * Prepare for the beginning of active use of the public methods of this component. This method
   * should be called after <code>configure()</code>, and before any of the public methods of the
   * component are utilized.
   *
   * @throws IllegalStateException if this component has already been started_
   * @throws org.apache.catalina.LifecycleException if this component detects a fatal error that
   *     prevents this component from being used
   */
  protected void startManager() throws LifecycleException {
    log_.debug("Starting JBossManager");

    // Validate and update our current component state
    if (started_) throw new LifecycleException("JBossManager alreadyStarted");

    backgroundProcessAllowed.set(true);

    lifecycle_.fireLifecycleEvent(START_EVENT, null);
    started_ = true;

    // register ClusterManagerMBean to the MBeanServer
    registerManagerMBean();
  }
Пример #18
0
  /**
   * Prepare for the beginning of active use of the public methods of this component. This method
   * should be called before any of the public methods of this component are utilized. It should
   * also send a LifecycleEvent of type START_EVENT to any registered listeners.
   *
   * @exception LifecycleException if this component detects a fatal error that prevents this
   *     component from being used
   */
  public void start() throws LifecycleException {

    // Validate and update our current component state
    if (started) {
      log.debug(sm.getString("standardServer.start.started"));
      return;
    }

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, null);

    lifecycle.fireLifecycleEvent(START_EVENT, null);
    started = true;

    // Start our defined Services
    synchronized (services) {
      for (int i = 0; i < services.length; i++) {
        if (services[i] instanceof Lifecycle) ((Lifecycle) services[i]).start();
      }
    }

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
  }
Пример #19
0
  /**
   * Prepare for the beginning of active use of the public methods of this component. This method
   * should be called before any of the public methods of this component are utilized. It should
   * also send a LifecycleEvent of type START_EVENT to any registered listeners.
   *
   * @throws LifecycleException if this component detects a fatal error that prevents this component
   *     from being used
   */
  public void start() throws LifecycleException {

    // Validate and update our current component state
    if (started) throw new LifecycleException(sm.getString("realmBase.alreadyStarted"));
    lifecycle.fireLifecycleEvent(START_EVENT, null);
    started = true;

    // Create a MessageDigest instance for credentials, if desired
    if (digest != null) {
      try {
        md = MessageDigest.getInstance(digest);
      } catch (NoSuchAlgorithmException e) {
        throw new LifecycleException(sm.getString("realmBase.algorithm", digest), e);
      }
    }
  }
Пример #20
0
  /**
   * Gracefully shut down active use of the public methods of this Component.
   *
   * @exception LifecycleException if this component detects a fatal error that needs to be reported
   */
  public synchronized void stop() throws LifecycleException {

    // Validate and update our current component state
    if (!started)
      throw new LifecycleException(sm.getString("fastEngineMapper.notStarted", engine.getName()));

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(STOP_EVENT, null);
    started = false;

    // Deconfigure based on our associated Engine properties
    engine.removePropertyChangeListener(this);
    setDefaultHost(null);
    engine.removeContainerListener(this);

    // Clear our mapping cache
    cache.clear();
  }
  /**
   * Prepare for the beginning of active use of the public methods of this component. This method
   * should be called after <code>configure()</code>, and before any of the public methods of the
   * component are utilized.
   *
   * @exception LifecycleException if this component detects a fatal error that prevents this
   *     component from being used
   */
  public void start() throws LifecycleException {

    // Validate and update our current component state
    if (started) throw new LifecycleException(sm.getString("authenticator.alreadyStarted"));
    lifecycle.fireLifecycleEvent(START_EVENT, null);
    if ("org.apache.catalina.core.StandardContext".equals(context.getClass().getName())) {
      try {
        Class paramTypes[] = new Class[0];
        Object paramValues[] = new Object[0];
        Method method = context.getClass().getMethod("getDebug", paramTypes);
        Integer result = (Integer) method.invoke(context, paramValues);
        setDebug(result.intValue());
      } catch (Exception e) {
        log("Exception getting debug value", e);
      }
    }
    started = true;

    // Look up the SingleSignOn implementation in our request processing
    // path, if there is one
    Container parent = context.getParent();
    while ((sso == null) && (parent != null)) {
      if (!(parent instanceof Pipeline)) {
        parent = parent.getParent();
        continue;
      }
      Valve valves[] = ((Pipeline) parent).getValves();
      for (int i = 0; i < valves.length; i++) {
        if (valves[i] instanceof SingleSignOn) {
          sso = (SingleSignOn) valves[i];
          break;
        }
      }
      if (sso == null) parent = parent.getParent();
    }
    if (debug >= 1) {
      if (sso != null) log("Found SingleSignOn Valve at " + sso);
      else log("No SingleSignOn Valve is present");
    }
  }
Пример #22
0
  /**
   * Prepare for active use of the public methods of this Component.
   *
   * @exception LifecycleException if this component detects a fatal error that prevents it from
   *     being started
   */
  public synchronized void start() throws LifecycleException {

    // Validate and update our current component state
    if (started)
      throw new LifecycleException(
          sm.getString("fastEngineMapper.alreadyStarted", engine.getName()));
    started = true;

    // Configure based on our associated Engine properties
    engine.addContainerListener(this);
    engine.addPropertyChangeListener(this);
    setDefaultHost(engine.getDefaultHost());

    // Cache mappings for our child hosts
    Container children[] = engine.findChildren();
    for (int i = 0; i < children.length; i++) {
      addHost((Host) children[i]);
    }

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(START_EVENT, null);
  }
Пример #23
0
  /**
   * Prepare for the beginning of active use of the public methods of this component. This method
   * should be called after <code>configure()</code>, and before any of the public methods of the
   * component are utilized.
   *
   * @exception LifecycleException if this component detects a fatal error that prevents this
   *     component from being used
   */
  public void start() throws LifecycleException {

    if (debug >= 1) log("Starting");

    // Validate and update our current component state
    if (started) throw new LifecycleException(sm.getString("standardManager.alreadyStarted"));
    lifecycle.fireLifecycleEvent(START_EVENT, null);
    started = true;

    // Force initialization of the random number generator
    if (debug >= 1) log("Force random number initialization starting");
    String dummy = generateSessionId();
    if (debug >= 1) log("Force random number initialization completed");

    // Load unloaded sessions, if any
    try {
      load();
    } catch (Throwable t) {
      log(sm.getString("standardManager.managerLoad"), t);
    }

    // Start the background reaper thread
    threadStart();
  }
 /**
  * Remove a lifecycle event listener from this component.
  *
  * @param listener The listener to add
  */
 public void removeLifecycleListener(LifecycleListener listener) {
   lifecycle.removeLifecycleListener(listener);
 }
 /**
  * Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners
  * registered, a zero-length array is returned.
  */
 public LifecycleListener[] findLifecycleListeners() {
   return lifecycle.findLifecycleListeners();
 }
 /**
  * Add a lifecycle event listener to this component.
  *
  * @param listener The listener to add
  */
 public void addLifecycleListener(LifecycleListener listener) {
   lifecycle.addLifecycleListener(listener);
 }
Пример #27
0
 /**
  * Prepare for the beginning of active use of the public methods of this component. This method
  * should be called after <code>configure()</code>, and before any of the public methods of the
  * component are utilized.
  *
  * @exception LifecycleException if this component detects a fatal error that prevents this
  *     component from being used
  */
 public void start() throws LifecycleException {
   // Validate and update our current component state
   if (started) throw new LifecycleException(sm.getString(getStoreName() + ".alreadyStarted"));
   lifecycle.fireLifecycleEvent(START_EVENT, null);
   started = true;
 }