KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > httpserver > NbServletsInterceptor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

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 JavaDoc;
26 import java.lang.reflect.*;
27 import java.util.*;
28 import java.util.StringTokenizer JavaDoc;
29 import org.openide.ErrorManager;
30
31 import org.openide.util.SharedClassObject;
32
33 /**
34  * @author costin@dnt.ro
35  */

36 public class NbServletsInterceptor extends BaseInterceptor {
37
38     public NbServletsInterceptor() {
39     }
40
41     private ServletWrapper addServlet( Context ctx, String JavaDoc name, String JavaDoc 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"); // NOI18N
57
ctx.addServletMapping(op.getWrapperBaseURL () + "*", "WrapperServlet"); // NOI18N
58
}
59     
60     public void contextInit(Context ctx) throws TomcatException {
61     if( ctx.getDebug() > 0 ) ctx.log("NbServletsInterceptor - init " + ctx.getPath() + " " + ctx.getDocBase() ); // NOI18N
62
ContextManager cm=ctx.getContextManager();
63     
64     try {
65         // Default init
66
addNbServlets( ctx );
67
68     } catch (Exception JavaDoc e) {
69             ErrorManager em = ErrorManager.getDefault();
70             em.annotate(e, "NbServletsInterceptor failed"); // NOI18N
71
em.notify(ErrorManager.INFORMATIONAL, e);
72     }
73
74     }
75
76 }
77
78
Popular Tags