Changeset 1179


Ignore:
Timestamp:
10/26/11 23:08:07 (20 months ago)
Author:
philsmart
Message:
 
Location:
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/server/RunServer.java

    r1030 r1179  
    1414 * limitations under the License. 
    1515 */ 
     16 
    1617package uk.ac.cardiff.raptormua.server; 
    1718 
    18 import java.io.File; 
    1919import java.io.FileInputStream; 
    2020import java.io.FileNotFoundException; 
    2121import java.io.IOException; 
    22 import java.net.URL; 
    23 import java.security.ProtectionDomain; 
    2422import java.util.Properties; 
    2523import java.util.TimeZone; 
    2624 
    27 import javax.xml.ws.Endpoint; 
    28  
    29 import org.apache.cxf.Bus; 
    30 import org.apache.cxf.BusFactory; 
    31 import org.apache.cxf.transport.servlet.CXFServlet; 
    3225import org.mortbay.jetty.Connector; 
    3326import org.mortbay.jetty.Handler; 
    3427import org.mortbay.jetty.Server; 
    35 import org.mortbay.jetty.bio.SocketConnector; 
    36 import org.mortbay.jetty.handler.ContextHandlerCollection; 
    3728import org.mortbay.jetty.handler.DefaultHandler; 
    3829import org.mortbay.jetty.handler.HandlerCollection; 
    39 import org.mortbay.jetty.nio.SelectChannelConnector; 
    4030import org.mortbay.jetty.security.SslSocketConnector; 
    41 import org.mortbay.jetty.servlet.Context; 
    42 import org.mortbay.jetty.servlet.ServletHolder; 
    4331import org.mortbay.jetty.webapp.WebAppContext; 
    44 import org.mortbay.log.Log; 
    4532import org.slf4j.LoggerFactory; 
    46 import org.springframework.context.support.ClassPathXmlApplicationContext; 
    47 import org.springframework.context.support.FileSystemXmlApplicationContext; 
    48 import org.springframework.web.servlet.DispatcherServlet; 
    4933 
    5034import ch.qos.logback.classic.LoggerContext; 
     
    5337import ch.qos.logback.core.util.StatusPrinter; 
    5438 
    55 import uk.ac.cardiff.raptor.remoting.server.sei.MultiUnitAggregator; 
    56 import uk.ac.cardiff.raptormua.wsinterface.impl.MultiUnitAggregatorImpl; 
    57  
    5839public class RunServer { 
    5940 
    60         /** 
    61          * Programmatically do the following: 
    62          * 1. Set the Apache CXF logger to use SLF4J 
    63          * 2. Configure the logback logger 
    64          * 3. Start a Jetty Server instance including trust and key stores, and set the web.xml in the configuration directory to initialise the servlet. 
    65          * 
    66          * @param args 
    67          * @throws IOException 
    68          * @throws FileNotFoundException 
    69          * @throws Exception 
    70          */ 
    71         public static void main(String args[]) throws FileNotFoundException, IOException { 
    72                 System.setProperty("org.apache.cxf.Logger", "org.apache.cxf.common.logging.Slf4jLogger"); 
    73                 TimeZone.setDefault(TimeZone.getTimeZone("Etc/UTC")); 
    74                 String configurationFiles = System.getProperty("configurationFiles", System.getProperty("user.dir") + "/target/conf"); 
     41    /** 
     42     * Programmatically do the following: 1. Set the Apache CXF logger to use SLF4J 2. Configure the logback logger 3. 
     43     * Start a Jetty Server instance including trust and key stores, and set the web.xml in the configuration directory 
     44     * to initialise the servlet. 
     45     *  
     46     * @param args 
     47     * @throws IOException 
     48     * @throws FileNotFoundException 
     49     * @throws Exception 
     50     */ 
     51    public static void main(String args[]) throws FileNotFoundException, IOException { 
     52        System.setProperty("org.apache.cxf.Logger", "org.apache.cxf.common.logging.Slf4jLogger"); 
     53        TimeZone.setDefault(TimeZone.getTimeZone("Etc/UTC")); 
     54        String configurationFiles = 
     55                System.getProperty("configurationFiles", System.getProperty("user.dir") + "/target/conf"); 
    7556 
    76                 configureLogger(configurationFiles+"/logging.xml"); 
     57        configureLogger(configurationFiles + "/logging.xml"); 
    7758 
    78                 Properties props = new Properties(); 
    79                 props.load(new FileInputStream(configurationFiles + "/server.properties")); 
     59        Properties props = new Properties(); 
     60        props.load(new FileInputStream(configurationFiles + "/server.properties")); 
    8061 
    81                 int portNumber = Integer.parseInt(props.getProperty("jetty.port", "8443")); 
    82                 String keyStoreLocaion = props.getProperty("jetty.keyStoreLocation", ""); 
    83                 String keyStorePassword = props.getProperty("jetty.keyStorePassword", "changeit"); 
    84                 String trustStoreLocaion = props.getProperty("jetty.trustStoreLocation", ""); 
    85                 String trustStorePassword = props.getProperty("jetty.trustStorePassword", "changeit"); 
    86                 String webappContextPath = props.getProperty("jetty.webapp.contextPath", "/MUA"); 
     62        int portNumber = Integer.parseInt(props.getProperty("jetty.port", "8443")); 
     63        String keyStoreLocaion = props.getProperty("jetty.keyStoreLocation", ""); 
     64        String keyStorePassword = props.getProperty("jetty.keyStorePassword", "changeit"); 
     65        String trustStoreLocaion = props.getProperty("jetty.trustStoreLocation", ""); 
     66        String trustStorePassword = props.getProperty("jetty.trustStorePassword", "changeit"); 
     67        String webappContextPath = props.getProperty("jetty.webapp.contextPath", "/MUA"); 
    8768 
     69        System.out.println("[INFO] Jetty Config: Using Port " + portNumber); 
     70        System.out.println("[INFO] Servlet and Spring Config: Configuration files at " + configurationFiles); 
    8871 
    89                 System.out.println("[INFO] Jetty Config: Using Port " + portNumber); 
    90                 System.out.println("[INFO] Servlet and Spring Config: Configuration files at " + configurationFiles); 
     72        Server server = new Server(); 
    9173 
    92                 Server server = new Server(); 
     74        SslSocketConnector sslConnector = new SslSocketConnector(); 
     75        sslConnector.setPort(portNumber); 
     76        sslConnector.setMaxIdleTime(30000); 
     77        sslConnector.setKeystore(keyStoreLocaion); 
     78        sslConnector.setPassword(keyStorePassword); 
     79        sslConnector.setKeyPassword(keyStorePassword); 
     80        sslConnector.setTruststore(trustStoreLocaion); 
     81        sslConnector.setTrustPassword(trustStorePassword); 
    9382 
    94                 SslSocketConnector sslConnector = new SslSocketConnector(); 
    95                 sslConnector.setPort(portNumber); 
    96                 sslConnector.setMaxIdleTime(30000); 
    97                 sslConnector.setKeystore(keyStoreLocaion); 
    98                 sslConnector.setPassword(keyStorePassword); 
    99                 sslConnector.setKeyPassword(keyStorePassword); 
    100                 sslConnector.setTruststore(trustStoreLocaion); 
    101                 sslConnector.setTrustPassword(trustStorePassword); 
    102                  
    103                 //SocketConnector connector = new SocketConnector(); 
    104                 //connector.setPort(portNumber); 
     83        // SocketConnector connector = new SocketConnector(); 
     84        // connector.setPort(portNumber); 
    10585 
    106                 // enable mutual authentication 
    107                 //sslConnector.setNeedClientAuth(true); 
     86        // enable mutual authentication 
     87        sslConnector.setNeedClientAuth(true); 
    10888 
    109                 server.setConnectors(new Connector[] { sslConnector }); 
     89        server.setConnectors(new Connector[] {sslConnector}); 
    11090 
    111                 WebAppContext webappcontext = new WebAppContext(); 
    112                 webappcontext.setDescriptor(configurationFiles + "/web.xml"); 
    113                 webappcontext.setContextPath(webappContextPath); 
    114                 webappcontext.setWar(configurationFiles); 
     91        WebAppContext webappcontext = new WebAppContext(); 
     92        webappcontext.setDescriptor(configurationFiles + "/web.xml"); 
     93        webappcontext.setContextPath(webappContextPath); 
     94        webappcontext.setWar(configurationFiles); 
    11595 
    116                 HandlerCollection handlers = new HandlerCollection(); 
    117                 handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() }); 
     96        HandlerCollection handlers = new HandlerCollection(); 
     97        handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()}); 
    11898 
    119                 server.setHandler(handlers); 
     99        server.setHandler(handlers); 
    120100 
    121                 try { 
    122                         server.start(); 
    123                         server.join(); 
    124                 } catch (Exception e) { 
    125                         e.printStackTrace(); 
    126                         System.exit(100); 
    127                 } 
     101        try { 
     102            server.start(); 
     103            server.join(); 
     104        } catch (Exception e) { 
     105            e.printStackTrace(); 
     106            System.exit(100); 
     107        } 
    128108 
    129         } 
     109    } 
    130110 
    131         private static void configureLogger(String logback) { 
    132                 LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); 
     111    private static void configureLogger(String logback) { 
     112        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); 
    133113 
    134                 try { 
    135                         JoranConfigurator configurator = new JoranConfigurator(); 
    136                         configurator.setContext(lc); 
    137                         lc.reset(); 
    138                         configurator.doConfigure(logback); 
    139                 } catch (JoranException je) { 
    140                         // StatusPrinter will handle thiss 
    141                 } 
    142                 StatusPrinter.print(lc); 
     114        try { 
     115            JoranConfigurator configurator = new JoranConfigurator(); 
     116            configurator.setContext(lc); 
     117            lc.reset(); 
     118            configurator.doConfigure(logback); 
     119        } catch (JoranException je) { 
     120            // StatusPrinter will handle thiss 
     121        } 
     122        StatusPrinter.print(lc); 
    143123 
    144         } 
     124    } 
    145125 
    146126} 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/service/impl/MUAProcessImpl.java

    r1082 r1179  
    4848 * All operations should go through this service class, so as to obey locks and synchronisation issues. Locks collisions 
    4949 * are thrown use a <code>SoapFault</code> . Fault codes are: Client (if a malformed input e.g. statistic name is wrong) 
    50  * Server (we use for locks, as server side issue) VersionMismatch MustUnderstand 
     50 * Server (we use if a lock is hit, as a server side issue). 
    5151 *  
    5252 * @author philsmart 
     
    9191            try { 
    9292                engine.release(); 
    93  
    9493            } catch (Exception e) { 
    9594                log.error("Error trying to release events {}", e.getMessage()); 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/wsinterface/impl/MultiUnitAggregatorImpl.java

    r1080 r1179  
    4646public class MultiUnitAggregatorImpl implements MultiUnitAggregator { 
    4747 
    48     /** The process service. */ 
     48    /** The mua process service. */ 
    4949    private MUAProcess processService; 
    5050 
     
    8282     */ 
    8383    public Capabilities getCapabilities() { 
    84         // TODO Auto-generated method stub 
    8584        return processService.getCapabilities(); 
    8685    } 
Note: See TracChangeset for help on using the changeset viewer.