You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by "Jason Zhang (JIRA)" <ji...@apache.org> on 2009/04/02 23:05:34 UTC

[jira] Updated: (SM-1839) Main entry improvement to allow run by procrun as Windows Service

     [ https://issues.apache.org/activemq/browse/SM-1839?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jason Zhang updated SM-1839:
----------------------------

    Attachment: Main.java

An patched Main.java is attached

> Main entry improvement to allow run by procrun as Windows Service
> -----------------------------------------------------------------
>
>                 Key: SM-1839
>                 URL: https://issues.apache.org/activemq/browse/SM-1839
>             Project: ServiceMix
>          Issue Type: Improvement
>          Components: servicemix-core
>    Affects Versions: 3.3
>         Environment: Windows 2000, 2003+
>            Reporter: Jason Zhang
>             Fix For: 3.3.1
>
>         Attachments: Main.java
>
>
> Basically, Apache Daemon procrun requires two entries, one for start and one for stop. org.apache.servicemix.Main only allow one entry. e.g. start. To use with procrun, Main.java need a bit of change to allow second entry (stop) and use this entry to unblock container. Here is the homemade patch for Main.java in trunk
> Index: src/main/java/org/apache/servicemix/Main.java
> ===================================================================
> --- src/main/java/org/apache/servicemix/Main.java	(revision 761422)
> +++ src/main/java/org/apache/servicemix/Main.java	(working copy)
> @@ -33,7 +33,10 @@
>   * @version $Revision$
>   */
>  public final class Main {
> -    
> +
> +    // singelton container
> +    private static SpringJBIContainer container;
> +
>      private Main() {
>      }
>  
> @@ -48,9 +51,18 @@
>              System.out.println();
>  
>              final ApplicationContext context;
> -            if (args.length <= 0) {
> +            if (args.length <= 0 || "start".equals(args[0])) {
>                  System.out.println("Loading Apache ServiceMix from servicemix.xml on the CLASSPATH");
>                  context = new ClassPathXmlApplicationContext("servicemix.xml");
> +            } else if ("stop".equals(args[0])) {
> +                System.out.println("Stopping Apache ServiceMix");
> +                if (container != null){
> +                    container.shutDown();
> +                    container.destroy();
> +                }
> +                // return here may cause jni hangs waiting Worker thread finish
> +                // but procrun can fix it by setting --StopTimeout
> +                return;
>              } else {
>                  String file = args[0];
>  
> @@ -65,7 +77,7 @@
>                  System.out.println("Loading Apache ServiceMix from file: " + file);
>                  context = new FileSystemXmlApplicationContext(file, processors);
>              }
> -            SpringJBIContainer container = (SpringJBIContainer) context.getBean("jbi");            
> +            container = (SpringJBIContainer) context.getBean("jbi");            
>              container.onShutDown(new Runnable() {
>                  public void run() {
>                      if (context instanceof DisposableBean) {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.