随笔-0  评论-0  文章-9  trackbacks-0
WebAdapterServlet  类将普通基于Servlet的开发变为了基于事件的开发,所以理清它的运行机制对于理解Millstone的运作情况非常重要。
 类中的域:

 private Class applicationClass;  
    
private Properties applicationProperties;
    
private UIDLTransformerFactory transformerFactory;
    
private CollectionThemeSource themeSource;
    
private String resourcePath = null;
    
//private boolean enableBrowserProbe = false;
    private boolean debugMode = false;
    
private int maxConcurrentTransformers;
    
private long transformerCacheTime;
    
private long themeCacheTime;
    
private WeakHashMap applicationToDirtyWindowSetMap = new WeakHashMap();
    
private WeakHashMap applicationToServerCommandStreamLock =
        
new WeakHashMap();
    
private WeakHashMap applicationToLastRequestDate = new WeakHashMap();
    
private List allWindows = new LinkedList();


1.  init()
 
String applicationClassName =
            servletConfig.getInitParameter(
"application");
从web.xml中得到运行的application 的类名
this.applicationProperties = new Properties();
        for (Enumeration e = servletConfig.getInitParameterNames();
            e.hasMoreElements();
            ) {
            String name = (String) e.nextElement();
            this.applicationProperties.setProperty(
                name,
                servletConfig.getInitParameter(name));
        }
将所有的web中的参数转移到applicationProperties中,以便使用.
 ServletContext context = servletConfig.getServletContext();
        
for (Enumeration e = context.getInitParameterNames();
            e.hasMoreElements();
            ) 
{
            String name 
= (String) e.nextElement();
            
this.applicationProperties.setProperty(
                name,
                context.getInitParameter(name));
        }


得到servelt的initparameter覆盖web.xml中的参数.
// Get the debug window parameter
        String debug = getApplicationOrSystemProperty(PARAMETER_DEBUG, "false");
        
// Enable application specific debug
        this.debugMode = debug.equals("true");
从application中或system 确定是否为debug 状态
// Add all specified theme sources
        this.themeSource = new CollectionThemeSource();
        List directorySources 
= getThemeSources();
        
for (Iterator i = directorySources.iterator(); i.hasNext();) {
            
this.themeSource.add((ThemeSource) i.next());
        }
增加指定的主题
// Add the default theme source
        String defaultThemeJar =
            getApplicationOrSystemProperty(
                PARAMETER_DEFAULT_THEME_JAR,
                DEFAULT_THEME_JAR);
        File f 
= findDefaultThemeJar(defaultThemeJar);
        
try {
            
// Add themes.jar if exists                         
            if (f != null && f.exists())
                
this.themeSource.add(new JarThemeSource(f, this""));
            
else {
                Log.warn(
"Default theme JAR not found: " + defaultThemeJar);
            }


        }
 catch (Exception e) {
            
throw new ServletException(
                
"Failed to load default theme from " + defaultThemeJar,
                e);
        }
 增加默任的主题

ClassLoader loader = this.getClass().getClassLoader();
        
try {
            
this.applicationClass = loader.loadClass(applicationClassName);
        }
 catch (ClassNotFoundException e) {
            
throw new ServletException(
                
"Failed to load application class: " + applicationClassName);
        }
最后是装载application的类.
posted on 2005-08-05 17:00 staunch 阅读(134) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: