Changeset 641


Ignore:
Timestamp:
04/05/11 18:56:13 (2 years ago)
Author:
philsmart
Message:
 
Location:
raptor-mua/trunk/src/main
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • raptor-mua/trunk/src/main/config/jetty.xml

    r638 r641  
    66        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> 
    77 
     8    <!-- Bean that enables java system properties --> 
     9    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" > 
     10        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /> 
     11    </bean> 
     12 
     13 
     14    <!--  The Jetty Server configuration, You DO NOT need to adjust values below this point --> 
    815    <bean id="Server" 
    916          class="org.mortbay.jetty.Server" init-method="start" destroy-method="stop"> 
     
    2734                                    <bean class="org.mortbay.jetty.webapp.WebAppContext"> 
    2835                                        <property name="contextPath" value="/MUA"/> 
    29                                         <property name="war" value="target/conf"> 
    30                                         </property> 
     36                                        <property name="war" value="${user.dir}/target/conf"/> 
     37                                        <property name="descriptor" value="${user.dir}/target/conf/web.xml"/> 
    3138                                    </bean> 
    3239                                </list> 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/server/RunServer.java

    r638 r641  
    1717 
    1818import java.io.File; 
     19import java.io.FileInputStream; 
     20import java.io.FileNotFoundException; 
     21import java.io.IOException; 
    1922import java.net.URL; 
    2023import java.security.ProtectionDomain; 
     24import java.util.Properties; 
    2125 
    2226import javax.xml.ws.Endpoint; 
     
    4650public class RunServer { 
    4751 
    48         /** 
    49          * Programmatically start a Jetty Server instance, and set the web.xml in the 
    50          * configuration directory to initialise the servlet. 
    51          *  
    52          * @param args 
    53          * @throws Exception 
    54          */ 
    55         public static void main(String args[]) { 
     52    /** 
     53     * Programmatically start a Jetty Server instance, and set the web.xml in the configuration directory to initialise the servlet. 
     54     * 
     55     * @param args 
     56     * @throws IOException 
     57     * @throws FileNotFoundException 
     58     * @throws Exception 
     59     */ 
     60    public static void main(String args[]) throws FileNotFoundException, IOException { 
    5661 
    57                 String configurationFiles = System.getProperty("configurationFiles", System.getProperty("user.dir") 
    58                                 + "/target/conf"); 
    59                 int portNumber = Integer.parseInt(System.getProperty("port", "8080")); 
     62        String configurationFiles = System.getProperty("configurationFiles", System.getProperty("user.dir") + "/target/conf"); 
    6063 
    61                 System.out.println("[INFO] Jetty Config: Using Port " + portNumber); 
    62                 System.out.println("[INFO] Servlet and Spring Config: Configuration files at " + configurationFiles); 
     64        Properties props = new Properties(); 
     65        props.load(new FileInputStream(configurationFiles + "/server.properties")); 
    6366 
    64                 Server server = new Server();    
    65                  
    66                 SslSocketConnector sslConnector = new SslSocketConnector(); 
    67                 sslConnector.setPort(8443);  
    68                 sslConnector.setMaxIdleTime(30000);  
    69                 sslConnector.setKeystore("/home/philsmart/Downloads/jetty-distribution-7.2.2.v20101205/etc/keystore");  
    70                 sslConnector.setPassword("changeit");  
    71                 sslConnector.setKeyPassword("changeit");  
    72                 sslConnector.setTruststore("/home/philsmart/Downloads/jetty-distribution-7.2.2.v20101205/etc/keystore");  
    73                 sslConnector.setTrustPassword("changeit");  
    74                  
    75                 SocketConnector connector = new SocketConnector();  
    76                 connector.setPort(portNumber);  
    77                 connector.setMaxIdleTime(30000);  
    78                 connector.setConfidentialPort(8443);  
     67        int portNumber = Integer.parseInt(props.getProperty("jetty.port", "8443")); 
     68        String keyStoreLocaion = props.getProperty("jetty.keyStoreLocation", ""); 
     69        String keyStorePassword = props.getProperty("jetty.keyStorePassword", "changeit"); 
     70        String trustStoreLocaion = props.getProperty("jetty.trustStoreLocaion", ""); 
     71        String trustStorePassword = props.getProperty("jetty.trustStorePassword", "changeit"); 
     72        String webappContextPath = props.getProperty("jetty.webapp.contextPath", "/MUA"); 
    7973 
    80                 server.setConnectors(new Connector[]{connector, sslConnector}); 
    81                          
    82                 WebAppContext webappcontext = new WebAppContext(); 
    83                 webappcontext.setDescriptor(configurationFiles+"/web.xml"); 
    84                 webappcontext.setContextPath("/MUA"); 
    85                 webappcontext.setWar(configurationFiles); 
    86                  
    87                 HandlerCollection handlers= new HandlerCollection(); 
    88                 handlers.setHandlers(new Handler[]{webappcontext, new DefaultHandler()}); 
     74        System.out.println("[INFO] Jetty Config: Using Port " + portNumber); 
     75        System.out.println("[INFO] Servlet and Spring Config: Configuration files at " + configurationFiles); 
    8976 
    90                 server.setHandler(handlers); 
    91                 try { 
    92                         server.start(); 
    93                         server.join(); 
    94                 } catch (Exception e) { 
    95                         e.printStackTrace(); 
    96                         System.exit(100); 
    97                 } 
     77        Server server = new Server(); 
    9878 
     79        SslSocketConnector sslConnector = new SslSocketConnector(); 
     80        sslConnector.setPort(portNumber); 
     81        sslConnector.setMaxIdleTime(30000); 
     82        sslConnector.setKeystore(keyStoreLocaion); 
     83        sslConnector.setPassword(keyStorePassword); 
     84        sslConnector.setKeyPassword(keyStorePassword); 
     85        sslConnector.setTruststore(trustStoreLocaion); 
     86        sslConnector.setTrustPassword(trustStorePassword); 
     87 
     88        server.setConnectors(new Connector[] {  sslConnector }); 
     89 
     90        WebAppContext webappcontext = new WebAppContext(); 
     91        webappcontext.setDescriptor(configurationFiles+"/web.xml"); 
     92        webappcontext.setContextPath(webappContextPath); 
     93        webappcontext.setWar(configurationFiles); 
     94 
     95        HandlerCollection handlers = new HandlerCollection(); 
     96        handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() }); 
     97 
     98        server.setHandler(handlers); 
     99 
     100        try { 
     101            server.start(); 
     102            server.join(); 
     103        } catch (Exception e) { 
     104            e.printStackTrace(); 
     105            System.exit(100); 
    99106        } 
    100107 
     108    } 
     109 
    101110} 
Note: See TracChangeset for help on using the changeset viewer.