1




A portlet-API based approach for application
integration




Wolfgang Habicht
Magnolia Conference, Basel




2009-09...
2




Agenda

Motivation
Concept
The portlet API and portlet basics
Implementation details
Magnolia integration
Real world...
3




Application Integration

Application integration is a generic problem
§ Not CMS specific
§ Depending on specific app...
4




Discussed solution

Possible solution for
§ Seamless integration into Magnolia
§ Small, new applications

Portlet-AP...
5




Concept

§ Two-phase model
            Phase 1                   Phase 2




            action                    r...
6




Interaction overview
7




Portlet

§ JSR-168 (and JSR-286)
§ Standard for developing portal components with Java
§ Run in a Portlet Container ...
8




Portlet API (simplified)

  interface Portlet
  {
    void init(PortletConfig);
    void processAction(ActionRequest...
9




Portlet API (simplified)

  interface Portlet
  {
    void init(PortletConfig);
    void processAction(ActionRequest...
10




Portlet API (simplified, continued)



  interface PortletResponse
  {
  }




  interface ActionResponse extends P...
11




Portlet API (simplified, continued)

  interface RenderRequest extends PortletRequest
  {
  }


  interface RenderR...
12




Portlet API (simplified, continued)

  interface RenderRequest extends PortletRequest
  {
  }


  interface RenderR...
13




Portlet API usage example
public class DemoPortlet implements Portlet
{
  public void init(PortletConfig config) {
...
14




Portlet API usage example
public class DemoPortlet implements Portlet
{
  public void init(PortletConfig config) {
...
15




Portlet API usage example
public class DemoPortlet implements Portlet
{
  public void init(PortletConfig config) {
...
16




createActionURL

Creates a link to the active portlet on the current
page with specified action

§ Use the original...
17




API extensions



ActionResponse {
  HttpServletResponse handleResponseMyself();
}

§ Portlet must (and can!) do an...
18




Reply caching

§ Not every page load has an “action” and “render” phase!

Example: Page with a shopping cart and a ...
19




Implementation details

ActionRequestImpl:
  § Special handling for action and uuid
  § Needs access to HttpServlet...
20




Implementation details (2)

PortletURLImpl:
  § “Merge” parameters and action/portletId and create
     parameter s...
21




Keeping the RenderRequest
§ Put portlet id, portlet object and RenderRequest in a
  container
§ Store container in ...
22




Default action

Provide a default action per portlet and page

§ Place the same portlet on different pages with dif...
23




Integration into Magnolia

Action phase:
§ Add a portlet filter
§ Alternative: action phase in template’s model (Mg...
24




PortletFilter

 Get all portlets                                                    Call
                          ...
25




Render a portlet

§ JSP or Freemarker-template with only one tag:
  <mgnlportlet:portlet/>
  (integrated in Magnoli...
26




Configuration (backend)

§ configure portlet classname and portletId
§ content2bean à pass any configuration value(...
27




Configuration (frontend)

Portlet-Paragraph to add Portlets
à choose portlet
  and default action




Alternativ: “...
28




Advanced configuration (portlet config dialog)




                                            g
                  ...
29




Advanced configuration (subparagraphs)



                                          g dialog
                      ...
30




Interaction overview (repetition)
31




Putting all together: seamless Magnolia integration
                      applicational pages


                   ...
32




Unaddressed issues



§ Caching
§ Deployment
§ Several applications on same page may conflict (due to
  redirects)
...
33




Real world experiences

§ Used in production
§ Several applications integrated and live:
  § virtual portfolio syst...
34




Real world experiences (2)

§   Well-suited for small applications
§   Multi-page setup is fragile
§   Additional c...
35




Findings

  Intuitive and flexible
  Simple API (no specific framework to use)
  Proper model phase support
  Fusin...
36




Any Questions?
Upcoming SlideShare
Loading in …5
×

A portlet-API based approach for application integration

2,902 views

Published on

A portlet-API based approach for application integration

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,902
On SlideShare
0
From Embeds
0
Number of Embeds
399
Actions
Shares
0
Downloads
74
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

A portlet-API based approach for application integration

  1. 1. 1 A portlet-API based approach for application integration Wolfgang Habicht Magnolia Conference, Basel 2009-09-10
  2. 2. 2 Agenda Motivation Concept The portlet API and portlet basics Implementation details Magnolia integration Real world experiences & findings
  3. 3. 3 Application Integration Application integration is a generic problem § Not CMS specific § Depending on specific application issues In general huge range of options § Link, IFrame, “merged” content, integrated menu § Adapting the application may be possible. Needed effort???
  4. 4. 4 Discussed solution Possible solution for § Seamless integration into Magnolia § Small, new applications Portlet-API based approach offers: § Simple and flexible API § Dynamic flow over several pages § Different applications on the same page § Configuration in AdminCentral
  5. 5. 5 Concept § Two-phase model Phase 1 Phase 2 action render Somewhere in filter chain While page rendering
  6. 6. 6 Interaction overview
  7. 7. 7 Portlet § JSR-168 (and JSR-286) § Standard for developing portal components with Java § Run in a Portlet Container / Portal Server § Action / render phase § Simple API
  8. 8. 8 Portlet API (simplified) interface Portlet { void init(PortletConfig); void processAction(ActionRequest, ActionResponse); void render(RenderRequest, RenderResponse); void destroy(); } interface PortletRequest { Object getAttribute(String); Collection<String> getAttributeNames(); } interface ActionRequest extends PortletRequest { String getParameter(String); String[] getParameterValues(String name); Collection<String> getParameterNames(); }
  9. 9. 9 Portlet API (simplified) interface Portlet { void init(PortletConfig); void processAction(ActionRequest, ActionResponse); void render(RenderRequest, RenderResponse); void destroy(); } interface PortletRequest { Object getAttribute(String); Collection<String> getAttributeNames(); } interface ActionRequest extends PortletRequest { String getParameter(String); String[] getParameterValues(String name); Collection<String> getParameterNames(); }
  10. 10. 10 Portlet API (simplified, continued) interface PortletResponse { } interface ActionResponse extends PortletResponse { void sendRedirect(String); void setRenderParameter(String, Object); HttpServletResponse handleResponseMyself(); }
  11. 11. 11 Portlet API (simplified, continued) interface RenderRequest extends PortletRequest { } interface RenderResponse extends PortletResponse { PortletURL createActionURL(String); Writer getWriter(); } interface PortletURL { void setParameter(String, String) void setParameter(String, String[]) String toString(); }
  12. 12. 12 Portlet API (simplified, continued) interface RenderRequest extends PortletRequest { } interface RenderResponse extends PortletResponse { PortletURL createActionURL(String); Writer getWriter(); } interface PortletURL { void setParameter(String, String) void setParameter(String, String[]) String toString(); }
  13. 13. 13 Portlet API usage example public class DemoPortlet implements Portlet { public void init(PortletConfig config) { String myJspTemplate = config.getParameters().get("myJspTemplate"); } public void processAction(ActionRequest request, ActionResponse response) { String action = request.getAttribute(ActionRequest.ACTION_ATTRIBUTE_NAME); if ("redirect".equals(action)) response.sendRedirect(request.getParameter("target")); response.setRenderParameter("jsp", myJspTemplate); } public void render(RenderRequest request, RenderResponse response) { Writer out = response.getWriter(); PortletURL url = response.createActionURL("new_action"); out.write("<a href="" + url.toString() + "">execute new_action</a>"); String jspTemplateName = (String) request.getAttribute("jsp"); ((WebContext) MgnlContext.getInstance()).include(jspTemplateName, out); } public void destroy() { } }
  14. 14. 14 Portlet API usage example public class DemoPortlet implements Portlet { public void init(PortletConfig config) { String myJspTemplate = config.getParameters().get("myJspTemplate"); } public void processAction(ActionRequest request, ActionResponse response) { String action = request.getAttribute(ActionRequest.ACTION_ATTRIBUTE_NAME); if ("redirect".equals(action)) response.sendRedirect(request.getParameter("target")); response.setRenderParameter("jsp", myJspTemplate); } public void render(RenderRequest request, RenderResponse response) { Writer out = response.getWriter(); PortletURL url = response.createActionURL("new_action"); out.write("<a href="" + url.toString() + "">execute new_action</a>"); String jspTemplateName = (String) request.getAttribute("jsp"); ((WebContext) MgnlContext.getInstance()).include(jspTemplateName, out); } public void destroy() { } }
  15. 15. 15 Portlet API usage example public class DemoPortlet implements Portlet { public void init(PortletConfig config) { String myJspTemplate = config.getParameters().get("myJspTemplate"); } public void processAction(ActionRequest request, ActionResponse response) { String action = request.getAttribute(ActionRequest.ACTION_ATTRIBUTE_NAME); if ("redirect".equals(action)) response.sendRedirect(request.getParameter("target")); response.setRenderParameter("jsp", myJspTemplate); } public void render(RenderRequest request, RenderResponse response) { Writer out = response.getWriter(); PortletURL url = response.createActionURL("new_action"); out.write("<a href="" + url.toString() + "">execute new_action</a>"); String jspTemplateName = (String) request.getAttribute("jsp"); ((WebContext) MgnlContext.getInstance()).include(jspTemplateName, out); } public void destroy() { } }
  16. 16. 16 createActionURL Creates a link to the active portlet on the current page with specified action § Use the original URI of the current request as target address § Set “action” and “portletId” parameters § Add all (other) parameters of the current request
  17. 17. 17 API extensions ActionResponse { HttpServletResponse handleResponseMyself(); } § Portlet must (and can!) do any further request handling itself § “Generalization” of the redirect concept
  18. 18. 18 Reply caching § Not every page load has an “action” and “render” phase! Example: Page with a shopping cart and a weather forecast § Remove one item of the shopping cart § Change the displayed location in the weather gadget à the last shopping cart action is “invalid” Caching the RenderRequests for every portlet on the page allows independent portlet behaviour! A basic principle in the portlet context
  19. 19. 19 Implementation details ActionRequestImpl: § Special handling for action and uuid § Needs access to HttpServletRequest ActionResponseImpl: § Needs access to HttpServletResponse § Store redirect location if called RenderRequestImpl: § Needs ActionResponse in constructor RenderResponseImpl: § Needs HttpServletRequest and Writer in constructor § createActionURL(…)
  20. 20. 20 Implementation details (2) PortletURLImpl: § “Merge” parameters and action/portletId and create parameter string PortletConfig: § Bean to provide the configuration (content2bean) § classname § portletId § Description § Map<String, String> parameters
  21. 21. 21 Keeping the RenderRequest § Put portlet id, portlet object and RenderRequest in a container § Store container in session § G container is page-specific On a request: § Check for action command à do it! § store in new container in session § Check for stored container entry § move to new container and keep in session § render it later during rendering § Call default action for missing entries and store them § Remove old container
  22. 22. 22 Default action Provide a default action per portlet and page § Place the same portlet on different pages with different functionality (i.e. login, logout, display data, edit data, …) § Simple and intuitive menu integration § Configure the default action on the page § Allows one portlet per application (in principle, different portlets could share the same data / state) § Transparent for the portlet!
  23. 23. 23 Integration into Magnolia Action phase: § Add a portlet filter § Alternative: action phase in template’s model (Mgnl 4.x) (in the paragraph’s model it’s already too late) Render phase: § Called while rendering the paragraph containing the portlet
  24. 24. 24 PortletFilter Get all portlets Call Get action of current page processAction yes Get default action Redirect? yes Portlets Have yes no found? action? no no Have Store in new no yes container yes container entry? Remove old More no container portlets?
  25. 25. 25 Render a portlet § JSP or Freemarker-template with only one tag: <mgnlportlet:portlet/> (integrated in Magnolia as paragraph) § Tag implementation: § get portletId out of current content node § get portlet object and render request out of container § call portlet.render(…)
  26. 26. 26 Configuration (backend) § configure portlet classname and portletId § content2bean à pass any configuration value(s)
  27. 27. 27 Configuration (frontend) Portlet-Paragraph to add Portlets à choose portlet and default action Alternativ: “PortletApps” with preconfigured values Portlet-specific configuration values: § add subparagraph(s) inside your portlet § access values by iterating through JCR nodes
  28. 28. 28 Advanced configuration (portlet config dialog) g g dialo et c onfi l port
  29. 29. 29 Advanced configuration (subparagraphs) g dialog le t confi port
  30. 30. 30 Interaction overview (repetition)
  31. 31. 31 Putting all together: seamless Magnolia integration applicational pages h r a g ra p te xt pa para graph portlet CMS (only) pages
  32. 32. 32 Unaddressed issues § Caching § Deployment § Several applications on same page may conflict (due to redirects) à how should the applications behave? § Integration of 3rd party frameworks
  33. 33. 33 Real world experiences § Used in production § Several applications integrated and live: § virtual portfolio system § serving personalized content (account information) § CSV download of table content (render into a CSV file instead of a HTML table) § form editor (for Magnolia 3.5 / 3.6) § wizards
  34. 34. 34 Real world experiences (2) § Well-suited for small applications § Multi-page setup is fragile § Additional configuration inside the paragraph possible § Use “normal” CMS page for additional content (help, …) § Mixing of portlet-paragraphs and normal paragraphs on same page possible
  35. 35. 35 Findings Intuitive and flexible Simple API (no specific framework to use) Proper model phase support Fusing with Magnolia (menu, mix paragraphs, …) Few programmer support Configuration dependencies (links to other pages) Complexity of bigger applications
  36. 36. 36 Any Questions?

×