开发者

Software architecture: How to Abstract the Portlet API

We are using Spring MVC and we would like to build an A开发者_如何学JAVApplication that could run as a Portlet AND as a regulard WebApp the same code base.

We are willing to sacrifice some of the Portlet features and settle for a common set of Features.

Is there an API or Technique to achieve this?


If you are using Spring 2.5 or 3.0, you can look into using their @Controller annotations which are for this very purpose rather than extending Spring's AbstractController classes (which are specific to the Servlet or Portlet spec that you are trying to get away from).

Check out http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/portlet.html#portlet-annotation

"The @Controller annotation indicates that a particular class serves the role of a controller. There is no need to extend any controller base class or reference the Portlet API. You are of course still able to reference Portlet-specific features if you need to."

The @RequestMapping annotations may configured with different values I think depending on if you're using Servlet or Portlet spec... so if you still run into any snags you might look into having a Java class that implements all your basic logic and having some minimal facade annotated controllers, one for Servlet and one for Portlet, that simply delegate off to your one core logic class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜