Logo Search packages:      
Sourcecode: nailgun version File versions  Download package

void com::martiansoftware::nailgun::NGServer::shutdown ( boolean  exitVM  )  [inline]

Shuts down the server. The server will stop listening and its thread will finish. Any running nails will be allowed to finish.

Any nails that provide a

public static void nailShutdown(NGServer)
method will have this method called with this NGServer as its sole parameter.

Parameters:
exitVM if true, this method will also exit the JVM after calling nailShutdown() on any nails. This may prevent currently running nails from exiting gracefully, but may be necessary in order to perform some tasks, such as shutting down any AWT or Swing threads implicitly launched by your nails.

Definition at line 282 of file NGServer.java.

References allNailStats, err, com::martiansoftware::nailgun::Alias::getAliasedClass(), getAliasManager(), com::martiansoftware::nailgun::NailStats::getNailClass(), getOrCreateStatsFor(), in, originalSecurityManager, out, serversocket, sessionPool, com::martiansoftware::nailgun::NGSessionPool::shutdown(), and shutdown.

                                           {
            synchronized(this) {
                  if (shutdown) return;
                  shutdown = true;
            }
            
            try {
                  serversocket.close();
            } catch (Throwable toDiscard) {}
            
            sessionPool.shutdown();
            
            Class[] argTypes = new Class[1];
            argTypes[0] = NGServer.class;
            Object[] argValues = new Object[1];
            argValues[0] = this;
            
            // make sure that all aliased classes have associated nailstats
            // so they can be shut down.
            for (Iterator i = getAliasManager().getAliases().iterator(); i.hasNext();) {
                  Alias alias = (Alias) i.next();
                  getOrCreateStatsFor(alias.getAliasedClass());
            }
            
            synchronized(allNailStats) {
                  for (Iterator i = allNailStats.values().iterator(); i.hasNext();) {
                        NailStats ns = (NailStats) i.next();
                        Class nailClass = ns.getNailClass();
                        
                        // yes, I know this is lazy, relying upon the exception
                        // to handle the case of no nailShutdown method.
                        try {
                              Method nailShutdown = nailClass.getMethod("nailShutdown", argTypes);
                              nailShutdown.invoke(null, argValues);
                        } catch (Throwable toDiscard) {}
                  }
            }
            
            // restore system streams
            System.setIn(in);
            System.setOut(out);
            System.setErr(err);
            
            System.setSecurityManager(originalSecurityManager);
            
            if (exitVM) {
                  System.exit(0);
            }
      }


Generated by  Doxygen 1.6.0   Back to index