`
pwosboy
  • 浏览: 84192 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

了解Portlet

阅读更多
The base building blocks of a Portal are the portlets. Portlets are complete applications following the Model-View-Controller design pattern. Portlets are developed, deployed, managed and displayed independent of all other portlets.
Based on the J2EE container model, portlets run inside the Portlet Container of WebSphere Portal analogous to the way servlets run inside the Servlet Container of WebSphere Application Server.
 
Portlets are a special subclass of HTTPServlet that includes properties and functionality that allows them to run inside the Portlet Container.
 
我认为这段话更清楚的说明了portlets的作用,就像struts中的ActionServlet一样,servlet的作用已经只是作为请求的转发器,具体的请求处理已经根据请求做的事务处理都是有别的类来处理的。在没有深入的学习之前,我猜想Portlet的模式,是message-driven的模式,对于浏览的每次请求,这些请求会被放在一个消息队列里,由servlet根据消息的注册信息来发送给事务处理的类。
Though portlets actually run as servlets under the WebSphere Application Server, they cannot send redirects or errors to the browser directly, forward requests or write arbitrary markup to the output stream. All communication back to the end user from a portlet is done via the aggregation modules.
 

WebSphere Portal runtime: the portlet container

WebSphere Portal is a J2EE application based on the servlet technology. In fact, portlets inherit from HTTP Servlet in the Java hierarchy, providing the servlet functionality. The WebSphere Portal portlet container is not, however, a standalone container as is the servlet container. The portlet container is a thin layer implemented on top of the servlet container designed to reuse the functionality provided by the servlet container.

Life circle

 init()
 The portlet is constructed after portal initialization and initialized with the init() method. The portal always instantiates only a single instance of the portlet, and this instance is shared among all users, exactly the same way a servlet is shared among all users of an application server.
 initConcrete()
After constructing the portlet and before the portlet is accessed for the first time, the portlet is initialized with the PortletSettings. This is known as the concrete portlet.
 service()
The portal calls the service() method when the portlet is required to render its content. During the life cycle of the portlet, the service() method is typically called many times. For each portlet on the page, the service() method is not called in a guaranteed order and may even be called in a different order for each request.
 destroyConcrete()
The concrete portlet is taken out of service with the destroyConcrete() method. This can happen when an administrator deletes a concrete portlet during runtime on the portal server.  destroy() When the portal is terminating, portlets are taken out of service, then destroyed with the destroy() method. Finally, the portlet is garbage collected

Portlet events and messaging

Action events: generated when an HTTP request is received by the portlet container that is associated with an action, such as when the user clicks a link.
Message events: generated when another portlet within the portlet application sends a message.
Window events: generated when the user changes the state of the portlet window.
 
1. Processing all action events
The user makes a request of the portal, the portal receives the request and decodes the action URI sent by the client and propagates an action event to the appropriate portlet. The receiving portlet’s action listener is called to process an action event. An appropriate time to send messages to other portlets is during the processing of the action event.
2. Processing all message events
If a message is sent to a portlet, the portlet’s message listener is called to process the message. Since portlets can send multiple messages and send messages as a result of receiving a message, this process continues until there are no more messaging events pending. Cyclical messaging is prevented by the WebSphere Portal architecture.
3. Processing all window events
Sizing operations such as maximize, minimize and restore, along with the portlet’s ability to request a specific size, causes multiple window events to be sent to all portlets affected by the sizing activity. This processing of window events continues until there are no more window events pending.
4. Portlet rendering process
Upon completing the event processing in the order specified above, the portal aggregator begins calling each container on the page being displayed, causing its contents to be rendered. The rendering process is explored in detail in 1.3.9, “Page aggregation” on page 32. When aggregation is complete, the page is returned to the user.
 

Page aggregation processing

The rendering process is a domino process starting with the root container. The root container triggers the rendering of all the child components in the page hierarchy as seen in Figure 1-11 on page 37. Rendering the screen triggers the aggregation of a page and its portlets. The pageRender tag in the screen starts the rendering process. If no portlet is maximized, then the pageRender tag calls the RootContainer.
The Root Container holds all the containers and controls for this page. The pageRender tag tells the Root Container to invoke the rendering of all its children. Since the Root Container is used only as a starting point for the aggregation, it does not render itself and therefore is not visible on the screen.
Each child of the Root Container invokes its template which is responsible for rendering all the content of its child. If the child contains further child components the componentLoop and componentRender tags execute the rendering of all these components one at a time. Each component invokes its own template which in turn invokes more components until the leaf of each branch is reached. Thus, control moves between component classes and their respective JSPs. Each component writes its content to the servlet output stream. When a control is reached, it invokes the rendering of the portlet, which adds its output to the output stream via its rendering. When the entire tree has been traversed, the output stream is closed and the output is sent back to the requesting client.
分享到:
评论

相关推荐

    IBM portlet api 和 中文教程

    首先,我们需要了解portlet的基本概念。portlet有三种主要的生命周期阶段:初始化、渲染和服务。初始化阶段是portlet加载时执行的,用于设置portlet的全局属性;渲染阶段是portlet根据请求生成响应内容;服务阶段则...

    使用spring mvc portlet 3.0开发IBM WebSphere Portlet应用

    首先,让我们了解Portlet 3.0标准,它是JSR 362的一部分。这个版本引入了更多的RESTful特性,支持异步处理,以及增强了portlet与浏览器之间的交互能力。Spring MVC Portlet 3.0利用这些新特性,简化了portlet开发...

    Portlet 简单例子demo pluto

    Portlet技术是Web应用程序开发中的一个重要概念,尤其在企业级应用中广泛使用,它...通过这个“Portlet简单例子demo pluto”,你可以动手实践,深入了解Portlet的开发过程,从而更好地掌握这一重要的Web应用开发技术。

    portlet资料

    通过这份资料,开发者可以全面了解portlet的开发流程,提高在JeeCMS或其他Java Portal平台上的工作效率。对于希望在企业级Web应用中实现模块化、可复用用户界面的开发者来说,这将是一份非常有价值的学习资源。

    struts2_portlet_pluto_demo

    通过这个示例项目,开发者可以学习如何在portlet环境中集成Struts2,了解portlet生命周期、portlet配置、以及如何将Struts2的MVC模式应用到portlet开发中。这对于那些希望在企业级门户应用中使用Struts2的开发者来说...

    文件上载Portlet源代码

    首先,我们需要了解Portlet的工作原理。Portlet容器(如 Pluto)负责管理portlet生命周期,包括初始化、渲染、动作处理和事件处理等阶段。Portlet通过与容器交互来提供其服务,比如文件上传功能。文件上载通常涉及...

    Portlet 案例项目

    首先,了解Portlet的基本概念至关重要。Portlet是一种Java Web组件,遵循portlet规范(如JSR 286或JSR 168),它定义了portlet与门户服务器之间的接口。Portlet可以处理请求、呈现内容,并与其他portlet进行通信。...

    IBM portlet开发指南

    了解Portlet应用的目录结构、类加载器、存档文件和部署描述符,有助于开发者更好地组织和打包Portlet应用。 #### 高级特性 包括资源服务、Portlet协作、过滤器等,这些都是提高Portlet开发效率和Portlet应用质量的...

    Portlet - Apache Pluto - Hello World Portlet

    首先,我们需要了解portlet的基本概念。Portlet是一种可以在门户(Portal)页面上运行的小应用程序,它可以与门户中的其他portlet协同工作,并且能够响应用户的交互。Java Portlet API定义了portlet的生命周期、渲染...

    liferay-spring-portlet

    通过深入学习和理解这个项目,开发者可以掌握如何在Liferay中创建和部署Spring Portlet,了解portlet的生命周期和交互方式,以及Spring框架在portlet开发中的应用。同时,如果进一步集成Hibernate,还可以学习到如何...

    jetspeed的portlet开发

    了解Portlet生命周期,包括初始化、渲染、事件处理和资源请求,对于开发者来说是基础。 2. **Jetspeed Portlet开发**:Jetspeed提供了丰富的API和工具来简化portlet的开发。开发者可以使用JavaServer Pages (JSP)、...

    pluto部署到tomcat的步骤 同时包含portlet-api-2.0.jar资源

    首先,让我们详细了解portlet-api-2.0.jar。这个JAR文件包含了portlet API的版本2.0,这是开发portlet应用所需的核心库。Portlet是一种可重用的Web组件,可以在portlet容器(如Pluto)中运行,它能够与portlet门户...

    portlet 源码+api

    总之,通过研究这个"portlet1_0"源码和API,初学者可以深入了解portlet的基本原理和实现方式,为进一步学习更高级的portlet技术打下坚实基础。同时,这也有助于理解门户服务器的工作机制,提升Web应用程序的开发能力...

    liferay-portlet-development-guide-4.3

    1. **Portlet基础知识**:了解portlet的基本概念,它是如何在Liferay Portal中运行的,以及portlet与传统Web应用的区别。 2. **Portlet生命周期**:学习portlet的创建、初始化、渲染和销毁等不同阶段,以及在这些...

    Java Portlet Specification 1.0

    * 有经验的 Portlet 开发者:他们想了解 Portlet 技术的内部机制。 1.3 API 参考 本规范还提供了一个附带的 Javadoc,包括类、接口和方法声明的全部规范。 1.4 其他 Java 平台规范 本规范还引用了以下 Java API ...

    liferay一个简单的portlet

    首先,让我们了解Portlet的基本概念。Portlet是一种Web组件,它可以嵌入到门户页面中,提供交互式的用户体验。在Liferay中,Portlet可以通过Java API和XML配置文件来定义其行为和外观。Portlets可以是任何类型的Web...

    在Dockbar中增加语言Portlet方法

    在IT行业中,Portlet是一种可重用的Web组件,常用于构建portlet应用,例如企业级的门户系统。Dockbar是Liferay Portal...通过这个过程,开发者可以深入了解portlet的工作原理,以及如何在实际项目中灵活定制用户界面。

    基于Oracle AS Portal下的Java Portlet开发.pdf

    【Oracle AS Portal】 Oracle AS Portal是Oracle应用服务器的一个组件,专门用于构建和部署企业级门户...开发者需要了解Portlet生命周期、PDK - Java API以及可能用到的Web框架,以便充分利用Oracle AS Portal的特性。

    Portlet HelloWorld Pluto2+myeclips6+tomcat6詳細開發指南

    【标题】"Portlet HelloWorld Pluto2+myeclips6+tomcat6详细开发指南"提供了在使用Pluto2portlet容器、myEclipse6集成...通过遵循这份指南,开发者能够了解Portlet开发的基础,并获得在实际项目中应用这些知识的经验。

    基于 Struts 2 构建 WebSphere Portal 上的 Portlet 应用

    在 WebSphere Portal 中开发 Portlet,首先需要了解 Portlet API,包括 Portlet、ActionRequest、ActionResponse、RenderRequest 和 RenderResponse 等接口。Portlet 生命周期包括初始化、渲染、动作处理和销毁四个...

Global site tag (gtag.js) - Google Analytics