Fuse ESB Enterprise之WAR部署模型

1.  Build a WAR

     Modifying an Existing Maven Project

     (1) Package Type: war

<project .>
	...
	<packaging>war</packaging>
	...
</project>

     (2) JDK Compile Version

<project .>
	...
	<build>
		<defaultGoal>install</defaultGoal>
		<plugins>
			...
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
	...
</project>

     (3) Store resources under webapp/WEB-INF

     (4) Customize the Maven WAR plug-in

<project .>
	...
	<build>
		...
		<plugins>
			<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.1.1</version>
				<configuration>
					<!-- Optionally specify where the web.xml file comes from -->
					<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
					<!-- Optionally specify extra resources to include -->
					<webResources>
						<resource>
							<directory>src/main/resources</directory>
							<targetPath>WEB-INF</targetPath>
							<includes>
								<include>**/*</include>
							</includes>
						</resource>
					</webResources>
				</configuration>
			</plugin>
			...
		</plugins>
	</build>
</project>

     说明:

     webXml: 指明web.xml文件的位置,默认值为:src/main/webapp/WEB-INF/web.xml.

     webResources:指明附加的资源文件将要被打包至生成的JAR文件中的文件,包含下面的子元素:

     (1) webResources/resource: 每个resource元素执行需要打包的一系列资源文件;

     (2) webResources/resource/directory:指定一个目录下的资源文件需要被打包至生成的WAR文件中,该目录是针对于

     pom.xml文件的相对路径;

     (3) webResources/resource/targetPath:指定生成的WAR文件的路径;

     (4) webResources/resource/includes: 使用ANT风格的通配符模式指定需要包含在WAR文件中的资源文件;

     (5) webResources/resource/excludes:使用ANT风格的通配符模式指定不需要包含在WAR文件中的资源文件。

2. Bootstrapping a CXF Servlet in a WAR

    (1)配置CXFServlet:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
	<display-name>cxf</display-name>
	<description>cxf</description>
	<servlet>
		<servlet-name>cxf</servlet-name>
		<display-name>cxf</display-name>
		<description>Apache CXF Endpoint</description>
		<servlet-class>org.apache.cxf.transport.servlet.CXFSer
			vlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>cxf</servlet-name>
		<url-pattern>/services/*</url-pattern>
	</servlet-mapping>
	<session-config>
		<session-timeout>60</session-timeout>
	</session-config>
</web-app>

     (2) 配置Web Service 配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
	...
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>WEB-INF/cxf-servlet.xml</param-value>
	</context-param>
	...
</web-app>

3. Bootstrapping a Spring Context in a WAR

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
	http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>Camel Routes</display-name>
	<!-- location of spring xml files -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
			/WEB-INF/applicationContext.xml
		</paramvalue>
	</context-param>
	<!-- the listener that kick-starts Spring -->
	<listener>
		<listener-class>org.springframework.web.context.Con
			textLoaderListener</listener-class>
	</listener>
</web-app>

4. Deploying a WAR

    使用下面的war scheme: war:LocationURL[?Options]

    例如:karaf@root> install war:mvn:org.apache.wicket/wicket-examples/1.4.7/war?Web-ContextPath=wicket

    或者karaf@root> install war:file://wicket-examples-1.4.7.war?Web-ContextPath=wicket

    访问:默认的端口号是:8181,例如:http://localhost:8181/wicket

5. Web Container的其他配置请参考:

    http://team.ops4j.org/wiki//display/paxweb/Basic+Configuration

    http://team.ops4j.org/wiki//display/paxweb/SSL+Configuration

    http://team.ops4j.org/wiki//display/paxweb/JSP+Configuration

猜你喜欢

转载自springsfeng.iteye.com/blog/1585841
ESB