KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jk > config > GeneratorJk1


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.jk.config;
18
19 import java.io.File JavaDoc;
20 import java.io.FileWriter JavaDoc;
21 import java.io.IOException JavaDoc;
22 import java.io.PrintWriter JavaDoc;
23 import java.util.Vector JavaDoc;
24
25
26 /* Naming conventions:
27
28 JK_CONF_DIR == serverRoot/work ( XXX /jkConfig ? )
29
30 - Each vhost has a sub-dir named after the canonycal name
31
32 - For each webapp in a vhost, there is a separate WEBAPP_NAME.jkmap
33
34 - In httpd.conf ( or equivalent servers ), in each virtual host you
35 should "Include JK_CONF_DIR/VHOST/jk_apache.conf". The config
36 file will contain the Alias declarations and other rules required
37 for apache operation. Same for other servers.
38
39 - WebXml2Jk will be invoked by a config tool or automatically for each
40 webapp - it'll generate the WEBAPP.jkmap files and config fragments.
41
42 WebXml2Jk will _not_ generate anything else but mappings.
43 It should _not_ try to guess locations or anything else - that's
44 another components' job.
45
46 */

47
48 /**
49  *
50  * @author Costin Manolache
51  */

52 public class GeneratorJk1 implements WebXml2Jk.MappingGenerator {
53     WebXml2Jk wxml;
54     String JavaDoc vhost;
55     String JavaDoc cpath;
56     String JavaDoc worker;
57     PrintWriter JavaDoc out;
58     
59     public void setWebXmlReader(WebXml2Jk wxml ) {
60         this.wxml=wxml;
61         vhost=wxml.vhost;
62         cpath=wxml.cpath;
63         worker=wxml.worker;
64     }
65
66     public void generateStart( ) throws IOException JavaDoc {
67         File JavaDoc base=wxml.getJkDir();
68         File JavaDoc outF=new File JavaDoc(base, "jk.conf");
69         out=new PrintWriter JavaDoc( new FileWriter JavaDoc( outF ));
70         
71         out.println("# This must be included in the virtual host section for " + vhost );
72     }
73
74     public void generateEnd() {
75         out.close();
76     }
77
78     
79     public void generateServletMapping( String JavaDoc servlet, String JavaDoc url ) {
80         out.println( "JkMount " + cpath + url + " " + worker);
81     }
82
83     public void generateFilterMapping( String JavaDoc servlet, String JavaDoc url ) {
84         out.println( "JkMount " + cpath + url + " " + worker);
85     }
86
87     public void generateLoginConfig( String JavaDoc loginPage,
88                                         String JavaDoc errPage, String JavaDoc authM ) {
89         out.println( "JkMount " + cpath + loginPage + " " + worker);
90     }
91
92     public void generateErrorPage( int err, String JavaDoc location ) {
93
94     }
95
96     public void generateMimeMapping( String JavaDoc ext, String JavaDoc type ) {
97
98     }
99     
100     public void generateWelcomeFiles( Vector JavaDoc wf ) {
101
102     }
103                                             
104     
105     public void generateConstraints( Vector JavaDoc urls, Vector JavaDoc methods, Vector JavaDoc roles, boolean isSSL ) {
106         for( int i=0; i<urls.size(); i++ ) {
107             String JavaDoc url=(String JavaDoc)urls.elementAt(i);
108
109             out.println( "JkMount " + cpath + url + " " + worker);
110         }
111     }
112 }
113
Popular Tags