[udig-devel] Server-side uDig

Jesse Eichar jeichar at refractions.net
Mon Aug 7 17:30:44 PDT 2006


Good stuff!  I give you 10 point for creativity.  uDig as a servlet  
does that mean we have to change the name?

Seriously I think this is great.  I will do what I can to support  
your work.  Any suggestion you have that will make it better for  
servers please make a JIRA and we will start a thread there.

WRT the dependency/Null pointer issue.  I will comment on the Jira task.

Jesse

On 4-Aug-06, at 12:12 PM, Aleksander Bandelj wrote:

> I think uDig and technologies it builds on constitute a really nice  
> platform for client and server side GIS, so I started experimenting  
> with server part. So far, I am able to run uDig rendering headless  
> inside Eclipse Equinox OSGI container. It requires no modifications  
> to uDig and is also reasonably easy for those familiar with Eclipse  
> PDE. You need eclipse 3.2 and plugins from equinox incubator:
>
> org.eclipse.equinox.http.registry
> org.eclipse.equinox.servlet.bridge.http
> org.eclipse.equinox.jetty.http
>
> Then you simply create Equinox launch configuration which includes  
> these bundles and a servlet bundle which registers a servlet on  
> http registry extension point:
>
> <extension
>         point="org.eclipse.equinox.http.registry.servlets">
>         <servlet
>               alias="/udig"
>               class="test.UdigServlet"
>               load-on-startup="true"/>
>   </extension>
>
> I've attached a braindead sample servlet in case somebody is  
> interested.
>
> The only problem I've encountered (lost a hour tracking it down)  
> was with UiPlugin activator. It requires net.refractions.udig  
> plugin to parse uDig version and fails with NullPointerException if  
> not present, but net.refractions.udig for some reason isn't  
> available (maybe because it exports no classes, so Lazy-Start  
> doesn't work). Anyway, this is now http://jira.codehaus.org/browse/ 
> UDIG-957
>
> (I think net.refractions.udig.ui should depend on  
> net.refractions.udig, not the opposite. If net.refractions.udig is  
> a central point for version and property information, on which  
> other bundles depend, this dependency should be evident in bundle  
> manifest.)
>
> There is also a rather interesting Rich Server Platform proposal,  
> which talks of server-side Eclipse workbench and OSGI inside web  
> applications:
>
> http://www.eclipse.org/proposals/rsp/
>
> (Note that they are releasing updated demo and tutorial soon)
> package test;
>
> import java.awt.Color;
> import java.awt.Dimension;
> import java.awt.image.BufferedImage;
> import java.io.IOException;
> import javax.imageio.ImageIO;
> import javax.servlet.ServletException;
> import javax.servlet.ServletOutputStream;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import net.refractions.udig.project.internal.Map;
> import net.refractions.udig.project.internal.render.RenderExecutor;
> import net.refractions.udig.project.render.IRenderContext;
> import net.refractions.udig.project.tests.support.MapTests;
> import net.refractions.udig.style.sld.SLDContent;
> import net.refractions.udig.ui.tests.support.UDIGTestUtil;
> import org.eclipse.core.runtime.NullProgressMonitor;
> import org.eclipse.core.runtime.Platform;
> import org.geotools.feature.Feature;
> import org.geotools.styling.Style;
> import org.geotools.styling.StyleBuilder;
>
> public class UdigServlet extends HttpServlet {
>
> @Override
> public void doGet(HttpServletRequest req, HttpServletResponse res)  
> throws ServletException, IOException {
> 	res.setContentType("image/png");
> 	ServletOutputStream out= res.getOutputStream();
> 	try {
> 		Feature[] features= UDIGTestUtil.createDefaultTestFeatures 
> ("testType", 3); //$NON-NLS-1$
> 		Map map= MapTests.createNonDynamicMapAndRenderer 
> (MapTests.createGeoResource(features, true), new Dimension(512,
> 				512));
> 		map.getViewportModelInternal().zoomToExtent();
> 		StyleBuilder sb= new StyleBuilder();
> 		Style style= sb.createStyle(features[0].getFeatureType 
> ().getTypeName(), sb.createPolygonSymbolizer(Color.BLACK,
> 				Color.RED, 2));
> 		SLDContent.apply(map.getLayersInternal().get(0), style, null);
> 		RenderExecutor executor= map.getRenderManagerInternal 
> ().getRenderExecutor();
> 		try {
> 			executor.render();
> 			IRenderContext context= executor.getContext();
> 			BufferedImage image= context.getImage();
> 			Platform.getJobManager().join(map.getRenderManager(), new  
> NullProgressMonitor());
> 			ImageIO.write(image, "png", out);
> 		} finally {
> 			map.getRenderManagerInternal().stopRendering();
> 			executor.dispose();
> 			out.flush();
> 			out.close();
> 		}
> 	} catch (Exception ex) {
> 		ex.printStackTrace();
> 	} //$NON-NLS-1$
> }
> }
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel



More information about the udig-devel mailing list