View Javadoc

1   //========================================================================
2   //$Id: AbstractJetty6Mojo.java 2147 2007-10-23 05:08:49Z gregw $
3   //Copyright 2000-2004 Mort Bay Consulting Pty. Ltd.
4   //------------------------------------------------------------------------
5   //Licensed under the Apache License, Version 2.0 (the "License");
6   //you may not use this file except in compliance with the License.
7   //You may obtain a copy of the License at 
8   //http://www.apache.org/licenses/LICENSE-2.0
9   //Unless required by applicable law or agreed to in writing, software
10  //distributed under the License is distributed on an "AS IS" BASIS,
11  //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  //See the License for the specific language governing permissions and
13  //limitations under the License.
14  //========================================================================
15  
16  package org.mortbay.jetty.plugin;
17  
18  import java.io.File;
19  
20  import org.mortbay.jetty.Connector;
21  import org.mortbay.jetty.RequestLog;
22  import org.mortbay.jetty.plugin.util.JettyPluginServer;
23  import org.mortbay.jetty.security.UserRealm;
24  import org.mortbay.xml.XmlConfiguration;
25  
26  /**
27   * AbstractJetty6Mojo
28   *
29   * Base class for all jetty6 mojos.
30   *
31   */
32  public abstract class AbstractJetty6Mojo extends AbstractJettyMojo
33  {
34      
35      /**
36       * List of connectors to use. If none are configured
37       * then we use a single SelectChannelConnector at port 8080
38       * 
39       * @parameter 
40       */
41      private Connector[] connectors;
42      
43      
44      /**
45       * List of security realms to set up. Optional.
46       * @parameter
47       */
48      private UserRealm[] userRealms;
49      
50      
51  
52      /**
53       * A RequestLog implementation to use for the webapp at runtime.
54       * Optional.
55       * @parameter
56       */
57      private RequestLog requestLog;
58      
59      
60      
61      /**
62       * @see org.mortbay.jetty.plugin.AbstractJettyMojo#getConfiguredUserRealms()
63       */
64      public Object[] getConfiguredUserRealms()
65      {
66          return this.userRealms;
67      }
68  
69      /**
70       * @see org.mortbay.jetty.plugin.AbstractJettyMojo#getConfiguredConnectors()
71       */
72      public Object[] getConfiguredConnectors()
73      {
74          return this.connectors;
75      }
76  
77  
78      public Object getConfiguredRequestLog()
79      {
80          return this.requestLog;
81      }
82   
83      
84      public void applyJettyXml() throws Exception
85      {
86          
87          if (getJettyXmlFile() == null)
88              return;
89          
90          getLog().info( "Configuring Jetty from xml configuration file = " + getJettyXmlFile() );        
91          XmlConfiguration xmlConfiguration = new XmlConfiguration(getJettyXmlFile().toURL());
92          xmlConfiguration.configure(getServer().getProxiedObject());   
93      }
94  
95     
96      /**
97       * @see org.mortbay.jetty.plugin.AbstractJettyMojo#createServer()
98       */
99      public JettyPluginServer createServer() throws Exception
100     {
101         return new Jetty6PluginServer();
102     }
103 
104 }