Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
eXo platform
Benjamin MestralletSoftware ArchitecteXo platform SARL
Portlet API in Action
BeJug Workshop 2004
Overall Presentation Goal
Let's implement and deploy your first HelloWorld portlet in a JSR 168 certified portlet container
Speaker’s Qualifications
● Benjamin Mestrallet is a software architect● He co-leads the eXo platform project● He created the eXo platform SARL which is a
service company that focuses on training and support for the eXo platform
● We published two articles about the eXo platform on TheServerSide.com
Ease of use
• We make your life easier• Code faster• Deploy faster• Go home earlier
Presentation Agenda
● Part I : the Hello World portlet• The code• The eclipse plugin
● Part II : a portlet framework?
● Part III : Architecture of the eXo platform• Integrated application suite• IoC / dependancy injection• The services stack• The standards
MVC design
● Controller : Portlet● Model : JavaBeans● View JSP
Redirection
● Redirection to the JSP : PortletRequestDispatcher
private static final String HELLO_TEMPLATE = "/WEB-INF/templates/html/HelloWorld.jsp"; public void doView(RenderRequest pRequest, RenderResponse pResponse) throws PortletException, IOException { pResponse.setContentType("text/html"); PortletContext context = getPortletContext(); PortletRequestDispatcher rd = context. getRequestDispatcher(HELLO_TEMPLATE); rd.include(pRequest, pResponse); }
The JSP
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %><portlet:defineObjects/><center> <img src='/HelloWorld/images/hello-world.png'/></center><center>HelloWorld Portlet in <b><%= renderRequest.getPortletMode().toString()%></b> Mode</center><center>The current window state is <b><%= renderRequest.getWindowState().toString()%> </b></center>
The portlet.xml <portlet> [...] <portlet-name> HelloWorld </portlet-name> [...] <portlet-class> HelloWorldPortlet </portlet-class> [...] <supports> <mime-type>text/html</mime-type> <portlet-mode> edit </portlet-mode> <portlet-mode> help </portlet-mode> </supports> [...] </portlet>
2 phase requests
Specs 1.0
PortletURL
● 2 types : ActionURL and RenderURL
PortletURL actionURL = pResponse.createActionURL(); actionURL.setWindowState(WindowState.MAXIMIZED); actionURL.setParameter("param", "ActionURL"); PortletURL renderURL = pResponse.createRenderURL(); renderURL.setPortletMode(PortletMode.HELP); renderURL.setParameter("param", "RenderURL"); [...] writer.write(actionURL.toString()); writer.write(renderURL.toString());
Portlet Preferences
● Persit the user preferences
<portlet-preferences> <preference> <name>pref</name> <value>defaultPref</value> <read-only>false</read-only> </preference></portlet-preferences>
PortletPreferences portletPreferences = actionRequest.getPreferences();portletPreferences.setValue("pref", "modifiedPref");portletPreferences.store();
Part II
Framework bridges
Bridges concepts
Portal
Portlet bridge
Framework servlet
JSF Bridge
● JSF : 6 phases● Portlet API : 2 phases
render() method
processAction() method
Redirect to the first jsp
<init-param> <name>default-view</name> <value>exo.component.UIUserProfile.class</value> </init-param> or<init-param> <name>default-view</name> <value>/jsf/profile.jsp</value> </init-param>
Part III
eXo platform architecture
Integrated Application Suite
● Integrated services but loosely coupled● Several layers
– Low level: Log, base de données, cache...– Midle level:
- Portlet container - Workflow- JCR
– Higher level: e-commerce, publishing
● 2 types of clients :• Portal channel• WSRP consumers
● Skeleton for higher level applications like CRM, ERP modules builds
IoC / Dependancy injection
● Hollywood principle : “don't call me, I will call you”● Clear distinction between the service/component
API and their implementation● Use of lightweight containers : Pico container
● Depandancy injection (Martin Fowler)
IoC 2
● How to inject the correct implementation into the objects :• Constructor injection public ServiceA(ServiceB serviceB) {...}• Setter injection public void setServiceB(ServiceB serviceB) {...}• Service locator pattern ServicesManager.getInstance().getService(ServiceB.class)
● Side effects :• Unit tests (maintainability, refactor)• Components : POJOs ( != EJBs )
The services
● LogService● CacheService● ThreadPoolService● DatabaseService/HibernateService● OrganizationService● WorkflowService● JCRService (JSR 170)● PublishingService● PortletContainerService (JSR 168)● WSRPService● ChartService● OfficeService● EcommerceService● CommunicationService● ...
The standards
● Portlet API • JSR 168 (JCP), certification, december 2003
● Web Service for Remote Portals (WSRP)• OASIS, interoperability discussions
● Java Content Repository• JSR 170, public draft in “february”
● JSR 207: Process Definition for Java
Portlet container architecture
WSRP
If You Only Remember One Thing…
Next big step : makes J2EE easier
Q&A
BeJug Workshop 2004