You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2009/06/26 22:07:50 UTC

svn commit: r788850 - /incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/service/UIMA_Service.java

Author: cwiklik
Date: Fri Jun 26 20:07:49 2009
New Revision: 788850

URL: http://svn.apache.org/viewvc?rev=788850&view=rev
Log:
UIMA-1109 Modified service wrapper to provide a way to stop a service without resorting to CTRL-C. Once the service is launched it will expect either 'q' to quiesce the service and stop, or 's' to stop the service hard.

Modified:
    incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/service/UIMA_Service.java

Modified: incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/service/UIMA_Service.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/service/UIMA_Service.java?rev=788850&r1=788849&r2=788850&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/service/UIMA_Service.java (original)
+++ incubator/uima/sandbox/trunk/uima-as/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/service/UIMA_Service.java Fri Jun 26 20:07:49 2009
@@ -165,7 +165,7 @@
 	 * 
 	 * @throws Exception
 	 */
-	public void deploy( String[] springContextFiles ) throws Exception
+	public SpringContainerDeployer deploy( String[] springContextFiles ) throws Exception
 	{
 		SpringContainerDeployer springDeployer =
 			new SpringContainerDeployer();
@@ -190,6 +190,7 @@
 		//	the monitor thread
 		FileSystemXmlApplicationContext context = springDeployer.getSpringContext();
 		context.addApplicationListener(this);
+		return springDeployer;
 	}
 	/**
 	 * Creates an instance of a {@link JmxMonitor}, initializes it with the JMX Server URI and
@@ -406,7 +407,7 @@
 			//	Deploy components defined in Spring context files. This method blocks until
 			//	the container is fully initialized and all UIMA-AS components are succefully
 			//	deployed.
-			service.deploy( contextFiles );
+			SpringContainerDeployer serviceDeployer = service.deploy( contextFiles );
 			//	Check if we should start an optional JMX-based monitor that will provide service metrics
 			//	The monitor is enabled by existence of -Djmx.monitor.frequency=<number> parameter. By default
 			//	the monitor is not enabled.
@@ -417,6 +418,18 @@
 				//	If the monitor fails to initialize the service is not effected. 
 				service.startMonitor(Long.parseLong(monitorCheckpointFrequency));
 			}
+			boolean stopped = false;
+			while(!stopped) {
+			  System.out.println("Enter 'q' to quiesce and stop the service or 's' to stop it now:");
+			  int c = System.in.read();
+			  if ( c == 's') {
+			    stopped = true;
+			    serviceDeployer.undeploy(SpringContainerDeployer.STOP_NOW);
+			  } else if ( c == 'q') {
+          stopped = true;
+			    serviceDeployer.undeploy(SpringContainerDeployer.QUIESCE_AND_STOP);
+			  }
+			}
 		}
 		catch( Exception e)
 		{