1 19 20 package org.netbeans.modules.httpserver; 21 22 import org.apache.tomcat.core.*; 23 import java.beans.*; 24 import java.io.*; 25 import java.io.IOException ; 26 import java.lang.reflect.*; 27 import java.util.*; 28 import java.util.StringTokenizer ; 29 import org.openide.ErrorManager; 30 31 import org.openide.util.SharedClassObject; 32 33 36 public class NbServletsInterceptor extends BaseInterceptor { 37 38 public NbServletsInterceptor() { 39 } 40 41 private ServletWrapper addServlet( Context ctx, String name, String classN ) 42 throws TomcatException { 43 ServletWrapper sw=new ServletWrapper(); 44 sw.setContext(ctx); 45 sw.setServletName( name ); 46 sw.setServletClass( classN); 47 ctx.addServlet( sw ); 48 sw.setLoadOnStartUp(0); 49 return sw; 50 } 51 52 private void addNbServlets( Context ctx ) throws TomcatException { 53 HttpServerSettings op = HttpServerSettings.getDefault(); 54 ServletWrapper sw; 55 56 sw=addServlet( ctx, "WrapperServlet", "org.netbeans.modules.httpserver.WrapperServlet"); ctx.addServletMapping(op.getWrapperBaseURL () + "*", "WrapperServlet"); } 59 60 public void contextInit(Context ctx) throws TomcatException { 61 if( ctx.getDebug() > 0 ) ctx.log("NbServletsInterceptor - init " + ctx.getPath() + " " + ctx.getDocBase() ); ContextManager cm=ctx.getContextManager(); 63 64 try { 65 addNbServlets( ctx ); 67 68 } catch (Exception e) { 69 ErrorManager em = ErrorManager.getDefault(); 70 em.annotate(e, "NbServletsInterceptor failed"); em.notify(ErrorManager.INFORMATIONAL, e); 72 } 73 74 } 75 76 } 77 78 | Popular Tags |