Summary? In the second part of the portlet family of Stefan? Hepper and Stephan? Hesmer, the author transfers the pen point from the Basic summary of the portlet? API to the portlet? API reference implementation (Ri? Reference? Implementation is Pluto) Detail description. The author also provides a series of portlet instances to explain how to expand the standard function of the portlet? API.
Enterprise Portal Providers uses pluggable user interface components (portlets) to provide a representation layer. Unfortunately, the previous providers only defined their own portlet? API, which is incompatible throughout the industry. In order to standardize the entire industry process, Java group released Java specification requirements (JSR) 168: Portlet specification.
The first part of this series introduces the details of JSP? 168. The second part focuses on the reference implementation (RI) of the portlet? API, that is, PLUTO. Also provided an instance of a portlet, the reader can learn from this instance.
Article Section 1 describes the architecture of RI, including the detachable concept of portlet containers and how to reuse portlet containers in other projects. The second section describes the installation and use of RI, and how to quickly configure the portlet. The article also includes a gradual in-depth example.
Note: You can download the original code through the resource link after the article.
PLUTO architecture
???? Let's take a look at the architecture of PLUTO and some basic concepts. Let's briefly explain the PORTAL's reference implementation and the location of the portlet container in the entire Portal architecture. Next we study the architecture of Pluto in terms of detail. Finally, let's take a look at the portlet container: portlet? Expand.
About Portal
??????? Pluto is generally used to demonstrate how to work and provide developers with an instance platform that test portlets. However, if there is no driver to run and test the portlet container a bit troublesome. Pluto's simple Portal component is only schema in the portlet container, which only meets the basic requirements of JSR? 168. (In contrast, Apache's open source project JetSpeed is more professional. Jetspeed will focus on Portal itself instead of portlet containers, and more considering the needs of other groups.)
Figure 1 depicts the basic architecture of Portal. Portal's network application handles client requests, gets the portlets from the user's current page, then call the portlet container to get the content of each portlet. Portal uses a portlet? container? Invoker? API to access? Portlet container If the container user wants to get the relevant information of Portal, you must implement the Callback interface of the PROVIDER® SPI? (Service? Provider® Interface) of the PortLet container. Finally, the portlet container calls all portlets via the portlet? API.
Screen.width-430) this.width = Screen.width-430 "align = center border = 0>
?
Figure 1: Structure of a simple portal in Pluto
Portlet container
????
????? Portlet container is the operating environment of the portlet, and is also the core of each portal. It requires information about Portal itself, and it must reuse itself. Therefore, Portlet containers and other portal components are completely separated. That is to say, you can embed the independent portlet container in any portal, as long as you meet the conditions of the portlet container, all SPIs are implemented. Portlet container? Invoker? API, or entry point, played the role of the main call interface of the portlet container. The invoker? API of the portlet container combines the living cycle of the portlet container and the request (INTPAGE (), PerformTitle (), portletService (), etc.). Because the portlet container finally calls the portlet's master portlet interface similar to the portlet? API, the difference is that the portlet definition must be passed. It is because this additional portlet definition, the portlet container can call the portlet correctly.
In addition to accessing the portlet container with an API, Portal must extend the SPI defined by the portlet container. Therefore, Ri introduces a container service: the detachable component registered in the container provides an underlying function and can be expanded. Ri contains self-built services in some containers (the first four must be implemented when running the portlet container, the last one is optional):
?? Information provider: Provide portal and portal framework for portal and portal frameworks. Get information and store Portal information through this interface. This information includes the URL, Portlet context, portlet mode, and window status control in the navigation bar.
Plant Manager: Defining how to get a specific implementation through the factory method. (A standard portal should already have an implementation.)
?? Log Service: Define a log tool (a standard portal should already have an implementation).
?? Configuration Service: Define how to get the configuration parameters (a standard portal should already have an implementation).
?? Property Manager (optional): The implementation of the property manager interface allows processing of the properties defined in the JSR168 specification.
Strictly speaking, the portlet object model is also part of the SPI, but it has a special position in SPI. The portlet object model processes all Potlet objects, which consists of a set of interfaces that are intertwined. Therefore, he cannot be considered by separating him and the container service.
?
Screen.width-430) this.width = Screen.width-430 "align = center border = 0>
Figure 2: Portlet container structure
?
Portlet deployment
??? portlet? Container? Architecture over the servlet container and enhances its functionality. In order to implement it, the portlet? Container will be original servlet? Join the WAR file of each portlet application, which we have described in Figure 3 3. When deploying the portlet component, first get the original WAR file, then join a new or modified the original Web.xml, and join a servlet as a call point to package each portlet. After that, the portlet deployment (? This is the THE? THE? PORTLET? DEPLOYMENT? PASS? TO? Modified? War? File? TO? THE? Application? Server? Deployment) will pass a modified WAR file to the app Server, deploy them to the application server system. During the calling process of the portlet, the portlet container calls the Added servlet as the entry point for the WAR file deploying the portlet. ?
Screen.width-430) this.width = Screen.width-430 "align = center border = 0>
Figure 3: Deployment of portlet in ri
PLUTO and WSRP standard
??? JSR? 168 is closely integrated with the remote portlet network service (the "web? (WSRP)) standard in JSR? 168. These two standards formed almost simultaneously released an open source implementation, realizing the necessary functions in their respective specifications. As a common goal, two standard efforts can cooperate together. Now, the portlet container can run a WSRP? Portlet.
PLUTO can run multiple portlet containers in a portal. Thus, Pluto's portlet container can be initialized multiple times. More importantly, it can be initialized in different ways. Each portlet container can use the SPI different implementation.
Ri installation
?
??? You will find that the PLUTO installation process is very simple. Perform install commands, install.bat or install.sh under the build directory / build. Next, the installer will prompt you to specify the Tomcat installation directory. (Note: The file separator is not a backslash in MS? Windows.)
After this, the installation process creates ri and all portlets, install portlets to the specified Tomcat directory. After the installation is complete, check the document to determine all the necessary manual settings.
Now you can start Tomcat, pass
Http: // localhost: 8080 / pluto / portal to access RI.
It is so simple!
?
How to deploy portlet
?
?????? Deploy portlets in PLUTO and its simplicity. Just remember that you must first install PLUTO, it sets the preorderun.properties correctly. This is necessary for the deployment process. Go to the build directory at the command prompt, enter the command deployportlet.bat?, Use the portlet? WAR file to do parameters, such as:
DeployPortlet.bat? C: /pluto/portlets/bookmark_04/driver/bookmark_04.war
Portlet instance
????? Let's take a picture of a portlet, Bookmark. It fully utilizes the portlet? API and clarifies the concept we have learned. We started with a simple example, we extend this Bookmark? Portlet in every step, and finally we will almost all the portlet? API, make it a senior portlet.
Bookmark? Portlet: Version One first Bookmark? Portlet uses some of the features in the portlet? API:
?? portlet? API? Interface THE? Portlet? API? Interface
?? Java server page (JSP) JavaServer? Pages? (JSP)?
?? portlet? API tag library The? Portlet? API? Tag? Libraries
?? Deployment Descriptor Deployment? Descriptors
The first Bookmark? Portlet is displayed and edited separately, respectively. Each JSP page is just a simple display of the current portlet mode of the portlet and the WindWOS state. In order to display this information, we use the portlet? API tag library (just part of the program code, please download all the code, it is difficult to understand: Translator Note):
PUBLIC? VOID? DoVIEW? (RENDERREQUEST? REQUEST,
RENDERRESPONSE? RESPONSE? THROWS? PortletException,? IoException? {
???????? response.setContentType ("text / html"); ????????
???????? String? Jspname? =? GetPortletConfig (). GetInitParameter ("jspview");
PortletRequestDispatcher? Rd? =?
GetPortletContext (). getRequestDispatcher (jspname);
???????? rd.include (request, response);
????}
The next code is a simple JSP page in the example (ie View.jsp: Translator Note):
<% @? Page? session = "false"?%>
<% @? Page? Import = "javax.port. *"%>
<% @? Page? Import = "java.util. *"%>
<% @? taglib? URI = '/ web-inf / TLD / portlet.tld'? prefix = 'portlet'%>
Hello,
I? Am? The? Bookmark? Portlet.
Current? Portlet? Mode:? <% = PortletRequest.getPortletMode ()%>
Current? Window? State:? <% = PortletRequest.getWindowState ()%>
Bookmark? Portlet: Version 2
? The second Bookmark? Portlet further deep into the portlet? API? In addition to the portlet? API? Feature used by the first example, it increases:
?? Action processing action? Handling
?? portlet? Parameter? Portlet? Preferences
?? Verification parameter? A? Preferences? Validator
?? Predefined? Preferences? In?, DEPLOYMENT? DESCRIPTOR in the deployment descriptor?
In the second Bookmark example, two new JSP pages replace version one. First, edit.jsp allows you to add and delete bookmarks via portlet action. The bookmarks entered in this JSP page will be stored as portlet parameters. Second, view.jsp? Displays a bookmark stored as a portlet parameter with a hyperlink. Bookmark? Portlet: version
• Added features:
?? Regional deployment descriptor? Localizable? Deployment? Descriptor
?? Resource package ResourceBundles
The deployment descriptor and JSP page are now available from the resource package (ResourceBundles) to get the displayed character set, they can support English and German.
Bookmark? Portlet: version four
• The final portlet example passed the portlet? Parameters demonstrated the concept of the navigation (The? Navigational? State? Concept?). There are seven bookmarks in the version, but the default page only shows four, as shown in Figure 4. By clicking on Next and Back hyperlinks, users can navigate to five bookmarks forward or backward. The initial point will be initialized to submit parameters such that the user can use the browser's refresh, backward and forward buttons.
Screen.width-430) this.width = Screen.width-430 "align = center border = 0>
?
? Bookmark? Portlet version of the interface
Portlet review
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??? As you can see, the reference implementation of the Portlet specification includes two parts: Portal and Portlet containers. Portal is a test drive for a simple running portlet container. The portlet container acts as a regular component that can quickly use other portals.
???? This portlet instance uses a lot of important concepts in many portlet? API. You can extend this instance with all portlet? API and servlet? API. For example, you can use a servlet to output other useful information in a new window, such as a print preview. You can also interact with the portlet via the HTTP session. In fact, because portlets are a powerful technology, the function that can be implemented is endless.