1 16 17 package org.apache.jk.config; 18 19 import java.io.File ; 20 import java.io.FileWriter ; 21 import java.io.IOException ; 22 import java.io.PrintWriter ; 23 import java.util.Vector ; 24 25 26 47 48 52 public class GeneratorJk2 implements WebXml2Jk.MappingGenerator { 53 WebXml2Jk wxml; 54 String vhost; 55 String cpath; 56 String worker; 57 PrintWriter 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 { 67 File base=wxml.getJkDir(); 68 File outF=new File (base, "jk2map.properties"); 69 out=new PrintWriter ( new FileWriter ( outF )); 70 71 out.println("# Autogenerated from web.xml" ); 72 } 73 74 public void generateEnd() { 75 out.close(); 76 } 77 78 public void generateServletMapping( String servlet, String url ) { 79 out.println( "[uri:" + vhost + cpath + url + "]"); 80 out.println( "group=" + worker ); 81 out.println( "servlet=" + servlet); 82 out.println( "host=" + vhost); 83 out.println( "context=" + cpath); 84 out.println(); 85 } 86 87 public void generateFilterMapping( String servlet, String url ) { 88 out.println( "[url:" + vhost + cpath + url + "]"); 89 out.println( "group=" + worker ); 90 out.println( "filter=" + servlet); 91 out.println( "host=" + vhost); 92 out.println( "context=" + cpath); 93 out.println(); 94 } 95 96 public void generateLoginConfig( String loginPage, 97 String errPage, String authM ) { 98 out.println("[url:" + vhost + cpath + loginPage + "]" ); 99 out.println( "group=" + worker ); 100 out.println( "host=" + vhost); 101 out.println( "context=" + cpath); 102 out.println(); 103 out.println("[url:" + vhost + cpath + errPage + "]" ); 104 out.println( "group=" + worker ); 105 out.println( "host=" + vhost); 106 out.println( "context=" + cpath); 107 out.println(); 108 } 109 110 public void generateErrorPage( int err, String location ) { 111 112 } 113 114 public void generateMimeMapping( String ext, String type ) { 115 116 } 117 118 public void generateWelcomeFiles( Vector wf ) { 119 120 } 121 122 123 public void generateConstraints( Vector urls, Vector methods, Vector roles, boolean isSSL ) { 124 for( int i=0; i<urls.size(); i++ ) { 125 String url=(String )urls.elementAt(i); 126 127 out.println("[url:" + vhost + cpath + url + "]"); 128 out.println( "group=" + worker ); 129 out.println( "host=" + vhost); 130 out.println( "context=" + cpath); 131 for( int j=0; j<roles.size(); j++ ) { 132 String role=(String )roles.elementAt(j); 133 out.println( "role=" + role); 134 } 135 for( int j=0; j<methods.size(); j++ ) { 136 String m=(String )methods.elementAt(j); 137 out.println( "method=" + m); 138 } 139 if( isSSL ) 140 out.println("ssl=true"); 141 } 142 } 143 } 144 | Popular Tags |