天天看点

Windchill的web中的Spring

Windchill的web中的Spring

windchill的web.xml文件中有如下代码:

<servlet-mapping>
    <servlet-name>MVCDispatcher</servlet-name>
    <url-pattern>/servlet/WizardServlet/*</url-pattern>
    <url-pattern>/servlet/ActionsMenu/*</url-pattern>
    <url-pattern>/servlet/RecentList/*</url-pattern>
    <url-pattern>/servlet/Navigation/*</url-pattern>
    <url-pattern>/servlet/SuggestServlet/*</url-pattern>
    <url-pattern>/servlet/TypeBasedIncludeServlet/*</url-pattern>
    <url-pattern>/servlet/UIValidationAJAXServlet/*</url-pattern>
    <url-pattern>/ptc1/*</url-pattern>
    <url-pattern>/app/*</url-pattern>
    <url-pattern>/gwt/*</url-pattern>
  </servlet-mapping>

<servlet>
    <description>MVC Dispatcher Servlet</description>
    <servlet-name>MVCDispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextClass</param-name>
      <param-value>com.ptc.mvc.components.support.ComponentXmlWebApplicationContext</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>           

web.xml的上述配置内容,实际上依据spring的规则,默认制定了名为MVCDispatcher-servlet.xml这个文件为Spring容器的web层配置文件

也就是说MVCDispatcher-servlet.xml制定controller的位置,配置文件的样子如下图:

Windchill的web中的Spring

好的,这说明我们找到了windchill中springmvc的配置文件。

实际上web.xml文件中当然也配置了spring本身,代码如下:

<context-param>
    <description>Location of Spring root web application context</description>
    <param-name>contextConfigLocation</param-name>
    <param-value>config/mvc/applicationContext.xml</param-value>
  </context-param>           

如下图位置的这个配置文件,就是spring本身的配置文件。

Windchill的web中的Spring

我们先来看看Windchill中Spring配置文件applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!-- 整个spring容器最底层一个注册的bean,估计这个bean是ptc封装的数据库访问类 The shared DataSourceConfig for a given servlet context -->
    <bean id="dataSourceConfig" class="com.ptc.mvc.ds.server.DefaultDataSourceConfig"/>

    <!-- Creates DataSourceSession instances, manages the thread pools -->
    <bean id="dataSourceManager" class="com.ptc.mvc.ds.server.DefaultDataSourceManager">
        <constructor-arg ref="dataSourceConfig" />
    </bean>
            
    <!-- JMX monitor -->
     <bean  class="com.ptc.mvc.ds.server.jmx.DataSourceMonitor">
         <property name="manager" ref="dataSourceManager" />
      </bean>
    
</beans>           

上述applicationContext.xml似乎只配置了一个数据库访问的ptc自己封装的类

然后我们看看springmvc的配置文件,如下:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
        
    <import resource="classpath:config/mvc/mvc.xml" />
    <import resource="classpath:config/mvc/jca-mvc.xml" />
    <import resource="classpath:config/mvc/*-configs.xml" />
    <import resource="classpath:config/mvc/custom.xml" />

    <bean id="defaultHandlerMappings"
        class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="locations">
            <list>
                <value>classpath:/config/mvc/*-urlMappings.properties</value>
                <value>classpath:/config/mvc/custom.properties</value>
            </list>
        </property>
    </bean>
</beans>           

如上所示,springmvc的配置文件导入了另外4个配置文件,如下图:

Windchill的web中的Spring

windchill的springmvc配置文件居然加载了133个另外的配置文件。