pluto-drvier

来源:互联网 发布:美国进口数据查询 编辑:程序博客网 时间:2024/05/16 16:05

 web.xml

   <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/pluto-portal-driver-services-config.xml</param-value>
    </context-param>

web.xml里面可以定义两种参数:
(1)application范围内的参数,存放在servletcontext中,在web.xml中配置如下:

如上

(2)servlet范围内的参数,只能在servlet的init()方法中取得,在web.xml中配置如下:

<servlet>
    
<servlet-name>MainServlet</servlet-name>
    
<servlet-class>com.wes.controller.MainServlet</servlet-class>
    
<init-param>
       
<param-name>param1</param-name>
       
<param-value>avalible in servlet init()</param-value>
    
</init-param>
    
<load-on-startup>0</load-on-startup>
</servlet>

在servlet中可以通过代码分别取用:

package com.wes.controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

public class MainServlet extends HttpServlet ...{

    
public MainServlet() ...{
        
super();
     }

    
public void init() throws ServletException ...{
         System.out.println(
"下面的两个参数param1是在servlet中存放的");
         System.out.println(
this.getInitParameter("param1"));
         System.out.println(
"下面的参数是存放在servletcontext中的");
         System.out.println(getServletContext().getInitParameter(
"contextConfigLocation"));
      }

}

第一种参数在servlet里面可以通过getServletContext().getInitParameter("contextConfigLocation")得到
第二种参数只能在servlet的init()方法中通过this.getInitParameter("param1")取得

 

2009-2-26 9:55:18 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The Apache Tomcat Native library which allows optimal performance in production environments

......

[tomcat loading]

2009-2-26 9:55:20 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2009-2-26 9:55:20 org.springframework.web.context.ContextLoader initWebApplicationContext
信息: Root WebApplicationContext: initialization started
2009-2-26 9:55:20 org.apache.catalina.core.ApplicationContext log
信息: Loading Spring root WebApplicationContext
2009-2-26 9:55:21 org.springframework.core.CollectionFactory <clinit>
信息: JDK 1.4+ collections available
2009-2-26 9:55:21 org.springframework.core.CollectionFactory <clinit>
信息: Commons Collections 3.x available
2009-2-26 9:55:21 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from ServletContext resource [/WEB-INF/pluto-portal-driver-services-config.xml]
2009-2-26 9:55:21 org.springframework.context.support.AbstractRefreshableApplicationContext refreshBeanFactory
信息: Bean factory for application context [Root WebApplicationContext]: org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [PlutoServices,RequiredContainerServices,PortalContext,DriverConfiguration,AdminConfiguration,PortalURLParser,PropertyConfigService,RenderConfigService,SupportedModesService,SupportedWindowStatesService,PortalCallbackService,PropertyManager,CCPPProfileService,ContainerInvocationService,PortletRegistryService]; root of BeanFactory hierarchy
2009-2-26 9:55:21 org.springframework.context.support.AbstractApplicationContext refresh
信息: 15 beans defined in application context [Root WebApplicationContext]
2009-2-26 9:55:22 org.springframework.context.support.AbstractApplicationContext initMessageSource
信息: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@8905bd]
2009-2-26 9:55:22 org.springframework.context.support.AbstractApplicationContext initApplicationEventMulticaster
信息: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@1a734ff]
2009-2-26 9:55:22 org.springframework.ui.context.support.UiApplicationContextUtils initThemeSource
信息: Unable to locate ThemeSource with name 'themeSource': using default [org.springframework.ui.context.support.ResourceBundleThemeSource@1455d1c]
2009-2-26 9:55:22 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [PlutoServices,RequiredContainerServices,PortalContext,DriverConfiguration,AdminConfiguration,PortalURLParser,PropertyConfigService,RenderConfigService,SupportedModesService,SupportedWindowStatesService,PortalCallbackService,PropertyManager,CCPPProfileService,ContainerInvocationService,PortletRegistryService]; root of BeanFactory hierarchy]

 

转入:org.apache.pluto.driver.config.impl.DriverConfigurationImpl的构造方法

public DriverConfigurationImpl(PortalURLParser portalUrlParser【org.apache.pluto.driver.url.impl.PortalURLParserImpl】,
                                   PropertyConfigService propertyService【org.apache.pluto.driver.services.impl.resource.PropertyConfigServiceImpl】,
                                   RenderConfigService renderService【org.apache.pluto.driver.services.impl.resource.RenderConfigServiceImpl】,
                                   SupportedModesService supportedModesService,
                                   SupportedWindowStateService supportedWindowStateService【org.apache.pluto.driver.services.impl.resource.SupportedWindowStateServiceImpl】,
                                   PortalCallbackService portalCallback【org.apache.pluto.driver.services.container.PortalCallbackServiceImpl】)

参数都是由pluto-portal-driver-services-config.xml配置决定的

<bean id="DriverConfiguration"
          class="org.apache.pluto.driver.config.impl.DriverConfigurationImpl">

      <!-- ===== Portal Services ===== -->
      <constructor-arg><ref bean="PortalURLParser"/></constructor-arg>
      <constructor-arg><ref bean="PropertyConfigService"/></constructor-arg>
      <constructor-arg><ref bean="RenderConfigService"/></constructor-arg>
      <constructor-arg><ref bean="SupportedModesService"/></constructor-arg>
      <constructor-arg><ref bean="SupportedWindowStatesService"/></constructor-arg>

 <!-- === Container Services === -->
      <constructor-arg><ref bean="PortalCallbackService"/></constructor-arg>

2009-2-26 10:08:58 org.apache.pluto.core.PortletContextManager <clinit>
警告: Servlet 2.4 or below detected.  Unable to find getContextPath on ServletContext.

 

警告: Servlet 2.4 or below detected.  Unable to find getContextPath on ServletContext.
2009-2-26 10:17:18 org.springframework.web.context.ContextLoader initWebApplicationContext
信息: Using context class [org.springframework.web.context.support.XmlWebApplicationContext] for root WebApplicationContext
2009-2-26 10:17:18 org.springframework.web.context.ContextLoader initWebApplicationContext
信息: Root WebApplicationContext: initialization completed in 7844 ms
2009-2-26 10:17:18 org.apache.pluto.driver.PortalStartupListener contextInitialized
信息: Starting up Pluto Portal Driver. . .

 

【转入】

org.apache.pluto.driver.PortalStartupListener的方法:

public void contextInitialized(ServletContextEvent event) {
        LOG.info("Starting up Pluto Portal Driver. . .");

        ServletContext servletContext = event.getServletContext();

        WebApplicationContext springContext = null;
       
        try {
            springContext = (WebApplicationContext)
                servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
           
        } catch (RuntimeException ex) {
            String msg = "Problem getting Spring context: " + ex.getMessage();
            LOG.error(msg, ex);
            throw ex;
        }
    
        LOG.debug(" [1a] Loading DriverConfiguration. . . ");
        DriverConfiguration driverConfiguration = (DriverConfiguration)
                springContext.getBean("DriverConfiguration");

        driverConfiguration.init(servletContext);

        LOG.debug(" [1b] Registering DriverConfiguration. . .");
        servletContext.setAttribute(DRIVER_CONFIG_KEY, driverConfiguration);


        LOG.debug(" [2a] Loading Optional AdminConfiguration. . .");
        AdminConfiguration adminConfiguration = (AdminConfiguration)
                springContext.getBean("AdminConfiguration");

        if (adminConfiguration != null) {
            LOG.debug(" [2b] Registering Optional AdminConfiguration");
            servletContext.setAttribute(ADMIN_CONFIG_KEY, adminConfiguration);
        } else {
            LOG.info("Optional AdminConfiguration not found. Ignoring.");
        }

        initContainer(servletContext);

        LOG.info("********** Pluto Portal Driver Started **********/n/n");
    }

 

DriverConfiguration driverConfiguration = (DriverConfiguration)
                springContext.getBean("DriverConfiguration");

        driverConfiguration.init(servletContext);

org.apache.pluto.driver.config.impl.DriverConfigurationImpl的方法:

public void init(ServletContext context) {
        this.propertyService.init(context);
        this.renderService.init(context);
        this.supportedModesService.init(context);
        this.supportedWindowStateService.init(context);
    }

this.propertyService.init(context);对应如下代码:

package org.apache.pluto.driver.services.impl.resource.PropertyConfigServiceImpl的

public void init(ServletContext ctx) {
        try {
            InputStream in = ctx.getResourceAsStream(ResourceConfigReader.CONFIG_FILE);
            config = ResourceConfigReader.getFactory().parse(in);
        }
        catch(Exception e) {
            LOG.error("Unable to parse resource config "+e.getMessage(), e);
            throw new DriverConfigurationException(e);
        }
    }方法

其中ResourceConfigReader.CONFIG_FILE是在org.apache.pluto.driver.services.impl.resource.ResourceConfigReader类中静态定义的

public static final String CONFIG_FILE =
        "/WEB-INF/pluto-portal-driver-config.xml";

 

this.renderService.init(context);对应如下代码:

org.apache.pluto.driver.services.impl.resource.RenderConfigServiceImpl的

public void init(ServletContext ctx) {
        try {
            InputStream in = ctx.getResourceAsStream(ResourceConfigReader.CONFIG_FILE);
            config = ResourceConfigReader.getFactory().parse(in);
        }
        catch(Exception e) {
            throw new DriverConfigurationException(e);
        }
    }

 

this.supportedModesService.init(context);对应如下代码:

org.apache.pluto.driver.services.impl.resource.SupportedModesServiceImpl的

public void init(ServletContext ctx) throws DriverConfigurationException {
        this.servletContext = ctx;
        this.portletContextService = portletContextService = PlutoServices.getServices().getPortletContextService();
        loadPortalModes();
    }

 

this.supportedWindowStateService.init(context);对应如下代码:

 

org.apache.pluto.driver.services.impl.resource.SupportedWindowStateServiceImpl的

public void init(ServletContext ctx) throws DriverConfigurationException
    {
        LOG.debug( "Initializing SupportedWindowStateService... " );

        servletContext = ctx;
       
        portalSupportedWindowStates = propertyService.getSupportedWindowStates();
        if ( LOG.isDebugEnabled() )
        {
            StringBuffer msg = new StringBuffer();
           
            if ( portalSupportedWindowStates != null )
            {
                msg.append( "Portal supports [" + portalSupportedWindowStates.size() + "] window states.  ");
                for ( Iterator i = portalSupportedWindowStates.iterator(); i.hasNext(); )
                {
                    msg.append( "[" + i.next() + "]" );
                    if ( i.hasNext() )
                    {
                        msg.append(", ");
                    }
                }
                LOG.debug(msg.toString());
            }   
        }
       
        if ( portalSupportedWindowStates == null )
        {
            final String msg = "Portal supported window states is null!";
            LOG.error( msg );
            throw new DriverConfigurationException( msg );
        }
        LOG.debug( "SupportedWindowStateService initialized." );       
    }

 

 

2009-2-26 10:31:15 org.apache.pluto.PortletContainerFactory createContainer
信息: Portlet Container [Pluto Portal Driver] created.
2009-2-26 10:31:15 org.apache.pluto.core.PortletContainerImpl infoWithName
信息: Portlet Container [Pluto Portal Driver]: Container initialized successfully.
2009-2-26 10:31:15 org.apache.pluto.driver.PortalStartupListener initContainer
信息: Pluto portlet container started.
2009-2-26 10:33:41 org.apache.pluto.driver.PortalStartupListener contextInitialized
信息: ********** Pluto Portal Driver Started **********
2009-2-26 10:33:55 org.apache.pluto.util.ClasspathScanner scan
信息: Found 1 resources for path '/META-INF/pluto.properties'.
2009-2-26 10:33:55 org.apache.pluto.core.PortletContextManager computeContextPath
信息: Found 3 application id resolvers.
2009-2-26 10:33:58 org.apache.pluto.core.PortletContextManager fireRegistered
信息: Portlet Context '/vwb' registered.
2009-2-26 10:33:58 org.apache.pluto.core.PortletContextManager register
信息: Registered portlet application for context '/vwb'
2009-2-26 10:33:58 org.apache.pluto.core.PortletContextManager register
信息: Registering 3 portlets for context /vwb
2009-2-26 10:33:58 org.apache.pluto.core.PortletContextManager register
信息: Portlet application for context '/vwb' already registered.
2009-2-26 10:33:58 org.apache.pluto.core.PortletContextManager register
信息: Portlet application for context '/vwb' already registered.

原创粉丝点击