001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.jk.config;
019:
020: import java.io.File;
021: import java.io.FileWriter;
022: import java.io.IOException;
023: import java.io.PrintWriter;
024: import java.util.Vector;
025:
026: /* Naming conventions:
027:
028: JK_CONF_DIR == serverRoot/work ( XXX /jkConfig ? )
029:
030: - Each vhost has a sub-dir named after the canonycal name
031:
032: - For each webapp in a vhost, there is a separate WEBAPP_NAME.jkmap
033:
034: - In httpd.conf ( or equivalent servers ), in each virtual host you
035: should "Include JK_CONF_DIR/VHOST/jk_apache.conf". The config
036: file will contain the Alias declarations and other rules required
037: for apache operation. Same for other servers.
038:
039: - WebXml2Jk will be invoked by a config tool or automatically for each
040: webapp - it'll generate the WEBAPP.jkmap files and config fragments.
041:
042: WebXml2Jk will _not_ generate anything else but mappings.
043: It should _not_ try to guess locations or anything else - that's
044: another components' job.
045:
046: */
047:
048: /**
049: *
050: * @author Costin Manolache
051: */
052: public class GeneratorJk1 implements WebXml2Jk.MappingGenerator {
053: WebXml2Jk wxml;
054: String vhost;
055: String cpath;
056: String worker;
057: PrintWriter out;
058:
059: public void setWebXmlReader(WebXml2Jk wxml) {
060: this .wxml = wxml;
061: vhost = wxml.vhost;
062: cpath = wxml.cpath;
063: worker = wxml.worker;
064: }
065:
066: public void generateStart() throws IOException {
067: File base = wxml.getJkDir();
068: File outF = new File(base, "jk.conf");
069: out = new PrintWriter(new FileWriter(outF));
070:
071: out
072: .println("# This must be included in the virtual host section for "
073: + vhost);
074: }
075:
076: public void generateEnd() {
077: out.close();
078: }
079:
080: public void generateServletMapping(String servlet, String url) {
081: out.println("JkMount " + cpath + url + " " + worker);
082: }
083:
084: public void generateFilterMapping(String servlet, String url) {
085: out.println("JkMount " + cpath + url + " " + worker);
086: }
087:
088: public void generateLoginConfig(String loginPage, String errPage,
089: String authM) {
090: out.println("JkMount " + cpath + loginPage + " " + worker);
091: }
092:
093: public void generateErrorPage(int err, String location) {
094:
095: }
096:
097: public void generateMimeMapping(String ext, String type) {
098:
099: }
100:
101: public void generateWelcomeFiles(Vector wf) {
102:
103: }
104:
105: public void generateConstraints(Vector urls, Vector methods,
106: Vector roles, boolean isSSL) {
107: for (int i = 0; i < urls.size(); i++) {
108: String url = (String) urls.elementAt(i);
109:
110: out.println("JkMount " + cpath + url + " " + worker);
111: }
112: }
113: }
|