1 17 package org.apache.servicemix; 18 19 import java.io.File ; 20 import java.util.ArrayList ; 21 import java.util.List ; 22 23 import org.apache.servicemix.jbi.config.spring.XBeanProcessor; 24 import org.apache.servicemix.jbi.container.SpringJBIContainer; 25 import org.springframework.beans.factory.DisposableBean; 26 import org.springframework.context.ApplicationContext; 27 import org.apache.xbean.server.repository.FileSystemRepository; 28 import org.apache.xbean.server.spring.configuration.ClassLoaderXmlPreprocessor; 29 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext; 30 import org.apache.xbean.spring.context.FileSystemXmlApplicationContext; 31 32 37 public class Main { 38 39 public static void main(String args[]) { 40 try { 41 String version = ""; 42 Package p = Package.getPackage("org.apache.servicemix"); 43 if (p != null) { 44 version = ": " + p.getImplementationVersion(); 45 } 46 System.out.println("Starting Apache ServiceMix ESB" + version); 47 System.out.println(); 48 49 ApplicationContext context = null; 50 if (args.length <= 0) { 51 System.out.println("Loading Apache ServiceMix from servicemix.xml on the CLASSPATH"); 52 context = new ClassPathXmlApplicationContext("servicemix.xml"); 53 } 54 else { 55 String file = args[0]; 56 57 if (file.equals("-?") || file.equals("?") || file.equals("--help") || file.equals("-h")) { 58 System.out.println("Usage: Main [-v1] [xmlConfigFile]"); 59 System.out.println("If an XML config file is not specified then servicemix.xml is used from the CLASSPATH"); 60 return; 61 } 62 63 List processors = new ArrayList (); 64 processors.add(new ClassLoaderXmlPreprocessor(new FileSystemRepository(new File (".")))); 65 if (file.equals("-v1")) { 66 67 processors.add(new XBeanProcessor()); 68 if (args.length <= 1) { 69 System.out.println("Loading Apache ServiceMix (compatible 1.x) from servicemix.xml on the CLASSPATH"); 70 context = new ClassPathXmlApplicationContext("servicemix.xml", processors); 71 } 72 else { 73 file = args[1]; 74 System.out.println("Loading Apache ServiceMix (compatible 1.x) from file: " + file); 75 context = new FileSystemXmlApplicationContext(file, processors); 76 } 77 } 78 else { 79 System.out.println("Loading Apache ServiceMix from file: " + file); 80 context = new FileSystemXmlApplicationContext(file, processors); 81 } 82 } 83 SpringJBIContainer container = (SpringJBIContainer) context.getBean("jbi"); 84 Object lock = new Object (); 85 container.setShutdownLock(lock); 86 87 synchronized (lock) { 89 lock.wait(); 90 } 91 if (context instanceof DisposableBean) { 92 ((DisposableBean) context).destroy(); 93 } 94 } 95 catch (Exception e) { 96 System.out.println("Caught: " + e); 97 e.printStackTrace(); 98 } 99 } 100 } 101 | Popular Tags |