Mapxtreme java IntraServletContainerRenderer实现

IntraServletContainerRenderer是Mapxtreme java的一种渲染器,他的特点是,图片直接发送到客户机,不需要通过中间层,可以提高图片显示的速度,下面是他的具体实现

MapJ mapJ = new MapJ();
		mapJ.loadMapDefinition("c://test.mdf");
		mapJ.setDeviceBounds(new DoubleRect(0,0,800d,600d));
		ServletConfig thisServletConfig = this.getServletConfig();
		ServletContext thisServletContext = thisServletConfig.getServletContext();
		this.logger.info("thisServletContext = " + thisServletContext.getContextPath());
		//这个路径的是这样,你的项目的mapxtreme的路径是
		//http://localhost:9090/test/mapxtreme
		//那么这里就写/test/mapxtreme就可以取到了
		ServletContext mxtServletContext = thisServletContext.getContext("/test/mapxtreme");
		this.logger.info("mxtServletContext = " + mxtServletContext);
		if(mxtServletContext != null) {
			try
			{
			IntraServletContainerRenderer isRenderer = new IntraServletContainerRenderer(mxtServletContext, "mapxtreme", request, response);
			ImageRequestComposer imageRC = ImageRequestComposer.create(mapJ, 256, Color.blue, "image/gif");
			isRenderer.render(imageRC);
			}
			catch(Exception e)
			{
			} 
		}

然后,还需要在web.xml里面还需要这么写

<!-- core MapXtreme Java servlet -->
	<servlet>
		<servlet-name>
			mapxtreme
		</servlet-name>
		<servlet-class>
			com.mapinfo.mapxtreme.MapXtremeServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<!-- internal servlets which are called by MapXtremeServlet -->
	<!-- these servlets should not be called directly!          -->
	<servlet>
		<servlet-name>
			mxtj_image
		</servlet-name>
		<servlet-class>
			com.mapinfo.mapxtreme.ImageHandlerServlet
		</servlet-class>
		<load-on-startup>2</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>
			mxtj_metadata
		</servlet-name>
		<servlet-class>
			com.mapinfo.mapxtreme.MetadataHandlerServlet
		</servlet-class>
		<load-on-startup>3</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>
			mxtj_vector
		</servlet-name>
		<servlet-class>
			com.mapinfo.mapxtreme.VectorHandlerServlet
		</servlet-class>
		<load-on-startup>4</load-on-startup>
	</servlet>


	<!-- Named Resources servlet -->
	<servlet>
		<servlet-name>
			namedresource
		</servlet-name>
		<servlet-class>
			com.mapinfo.jndi.namedres.NamedResourceServlet
		</servlet-class>
	</servlet>

	<!-- CoordTransform servlet -->
	<servlet>
		<servlet-name>
			coordtransform
		</servlet-name>
		<servlet-class>
			com.mapinfo.coordsys.io.CoordTransformServlet
		</servlet-class>
	</servlet>

	<!-- 这里就是mapxtreme的路径 -->
	<!-- servlet URL mappings -->
	<!-- mapxtreme -->
	<servlet-mapping>
		<servlet-name>
			mapxtreme
		</servlet-name>
		<url-pattern>
			/servlet/mapxtreme
		</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>
			mapxtreme
		</servlet-name>
		<url-pattern>
			/mapxtreme
		</url-pattern>
	</servlet-mapping>

	<!-- namedresource -->
	<servlet-mapping>
		<servlet-name>
			namedresource
		</servlet-name>
		<url-pattern>
			/servlet/namedresource
		</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>
			namedresource
		</servlet-name>
		<url-pattern>
			/namedresource
		</url-pattern>
	</servlet-mapping>

	<!-- coordtransform -->
	<servlet-mapping>
		<servlet-name>
			coordtransform
		</servlet-name>
		<url-pattern>
			/servlet/coordtransform
		</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>
			coordtransform
		</servlet-name>
		<url-pattern>
			/coordtransform
		</url-pattern>
	</servlet-mapping>

版权声明:本文为博主原创文章,未经博主允许不得转载。

你可能感兴趣的:(java,exception,servlet,Servlets,null,resources)