600 likes | 629 Views
Learn about portal history, how portals work, portlet development, choosing a portal server, and more. Explore different types of portals like corporate intranet, hosted services, extranet, and e-commerce, and their challenges and solutions. Discover how portals streamline user interaction and drive productivity.
E N D
Portals & Portlets Building Portals Quickly with the Portlet API Erin Mulder – Harbor Java User Group – May 11, 2004
On the plate tonight… • Portal History • Who Needs Portals • How Portals Work • Portlet Development • Step-by-Step Example • Choosing a Portal Server • Where to go from here…
Enterprise Portals • Users and user profiles • Different user groups or roles with customized views • Information and functionality available in individual portlets • Non-technical users can define roles and arrange portlets into pages, layouts • Streamline each person’s interaction so they only see what they care about
Corporate Intranet • Challenges: • Lots of internal applications • Users have to: • Remember lots of usernames/passwords • Get training on a dozen different application interfaces • Remember how to launch, access and use each of them (“hello, help desk?”) • Constantly switch between applications (disrupts flow) • Administrators have to manage dozens or hundreds of desktop applications
Corporate Intranet • Portal Solution: • Centralizes administration • Users just need to know how to use a web browser – application interfaces build on surfing skills • Single sign-on • Integrated to-do lists and single interface streamline the workday • Easy to manage access, customize views, monitor activity, etc. (to drive productivity)
ASP / Hosted Services • Challenges: • Different customers want different views • Lots of time and energy spent on customization • Need to maintain dozens or hundreds of slightly different versions of the application • Changes require intervention by developers and technical administrators • Support staff is constantly switching between versions to help users
ASP / Hosted Services • Portal Solution: • Allows reuse of core functionality • Layout, look & feel, etc. can be customized without development or admin support • Customers can manage their own views and users • Built-in security keeps users from breaking out of their roles • Individual portlets can still be upgraded or customized on a per-customer basis
Corporate Extranet • Challenges: • Customers, suppliers, partners, employees • Each group needs its own view and functionality • System needs to be both accessible and secure • Hundreds of customized interfaces and databases make reporting, integration, maintenance a nightmare • A lot of functionality is duplicated
Corporate Extranet • Portal Solution: • Portal allows reuse of shared portlets while still restricting what each user can do • Accommodates many different roles (partner, wholesaler, retail customer, employee, etc.) • Easily accessible through firewalls • Solid security architecture • Reduced training costs • Really just a bigger example of the corporate intranet
E-Commerce • Challenges: • Developers and administrators can’t respond quickly enough to business needs/whims • Customers are fickle • Business wants to target marketing campaigns by demographics • Need to integrate with partners • Hasn’t this all been done before??
E-Commerce • Portal Solution: • Many portal servers ship with full e-commerce functionality • Many support heavy personalization and targeted marketing campaigns • Easy to pull in and format partner/supplier content with built-in web service portlets • Business folks can work directly with content, with much less tech support
Software Vendor • Challenges: • Customer’s IT staff doesn’t want to support yet another proprietary application • Portal Solution: • Customer already has a portal server in house • Much more amenable to something they can drop right into their existing portal • Right now, that means writing portlet versions of the product that work with 6-8 portal servers • With JSR-168, it’s much closer to write-once
General Process • Choose a portal server based on features, performance and existing portlet catalog • Install it (standalone or inside a J2EE server) • Use web-based administrative tools to: • configure security and user management • tweak colors, layouts, logos, etc. • create pages (usually represented as tabs) • configure which portlets go on which pages and are accessible to which users • Develop new skins, layouts, portlets as needed
Common Features • User administration • Navigation and layout • Skins • Out-of-the-box portlets • Portlet catalog (vendor community) • Proprietary and standard portlet APIs
User Administration • Define users and groups: • Can use built-in user management features • Or, can integrate with authentication service (e.g. LDAP, SSO product) • Configure which users and groups can access which portlets • Configure default pages, portlet layouts, skins, etc. for each group • Optionally, allow users to personalize
Navigation & Layout • Portlets are arranged into pages • Pages are tabs (or are grouped into tabs) • Each page is assigned a predefined layout • Portlets are assigned to each spot in the layout • Users are often allowed to minimize, maximize, add and remove portlets • Behind the scenes, layouts are implemented by very simple, generic JSPs
Skins • Skin = look and feel • Includes logo, header, footer, colors, CSS styles, icons, etc. • Changing the skin has no effect on functionality • Behind the scenes, skins are implemented with JSPs, stylesheets and images • Skins (and layouts) can be reused in many different applications • Only somewhat portable between servers
Out-of-the-Box Portlets • The more you pay, the more you get… • Common freebies include news feed aggregators, weather, generic web service stubs, groupware (CMS, calendar, etc.) • Many expensive specialized packages available: • For industries (publishing, life sciences, education, manufacturing, etc.) • For business areas (collaboration, supply-chain, CRM, corporate governance, financials, etc.)
Portlet Catalog • Find a new application and just drop it in • Find portlet front-ends for your existing applications • Very easy to deploy new apps and features • Software vendors like Documentum, Compoze and Citrix list their portlets in portlet catalogs on the portal server’s site • Standards increase the options, but it’s still nice to buy portlets that are already pre-configured
Portlet APIs • Small intranets may never need custom portlets • Large enterprise portals almost certainly will • Becomes the platform for new app development • Need to integrate legacy applications so users can get away from green screens and desktop apps • Almost every portal server has proprietary API • Almost all support or plan to support the standard JSR-168 Portlet API • Many support or plan to support WSRP as well
Developing a Portlet • Write portlet code using JSR-168 Portlet API • Package portlets in a WAR with a portlet.xml DD • Can be mixed in with application’s existing WAR • Can be deployed inside EAR with EJBs, etc. • Deploy this archive to the portal server • Use the portal server admin tools to set permissions for each portlet and add them to individual pages in the portal
Why not Servlets? • Many portlets are involved in each HTTP request • Shouldn’t be allowed to work with request and response objects directly • Need to be able to re-render themselves without changing state • Need to store individual preferences, state • Tiles frameworks work fine for layout of one application, but don’t substitute for a real portal
The JSR-168 Portlet API • Different modes for viewing, configuring and getting help with a portlet • Minimized, normal and maximized portlet “window states” • Both action and render requests • Multiple content types from one portlet • Storage of preferences on per-user basis • Access to user profile
Example Portlet import javax.portlet.*; public class HelloWorldPortlet extends GenericPortlet { public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException { response.setContentType(“text/html”); response.getWriter().print("Hello World!"); } publicvoid processAction(ActionRequest request, ActionResponse response) throws IOException, PortletException { // do nothing for now } }
Example portlet.xml <portlet> <portlet-name>hello</portlet-name> <display-name>Hello World</display-name> <portlet-class>HelloWorldPortlet</portlet-class> <expiration-cache>0</expiration-cache> <supports><mime-type>text/html</mime-type></supports> <portlet-info> <title>Hello World</title> <short-title>Hello World</short-title> <keywords>Hello World</keywords> </portlet-info> <security-role-ref> <role-name>Administrator</role-name> </security-role-ref> </portlet>
Package and deploy… • Create a WAR (or add to existing one): WEB-INF/ classes/ HelloWorldPortlet.class web.xml portlet.xml • Deploy this WAR to the server • Use administrative tools to place your new HelloWorldPortlet on some page and try it out
Liferay Portal Server • Simple, open source portal server • JSR-168 compliant • Very easy to download and install • Available as a bundle with JBoss/Tomcat/Jetty • Free • Nice Struts integration • (Not the speediest server out there)
Downloading Liferay • Go to http://www.liferay.com/ • Click on “Downloads” • Choose one of the bundles • For these examples, we’ll be using: Liferay Enterprise Portal 2.1.0 (Bundled with JBoss+Tomcat) • If you have trouble downloading it there (the links don’t work in all browsers), download it directly from: http://sourceforge.net/project/showfiles.php?group_id=49260
Installing Liferay • Unzip the bundle you downloaded into some dir • Assuming you’re not running as root : • Customize the port in: server/default/deploy/jbossweb-tomcat50.sar/server.xml • Customize directories in : server/default/deploy/ext.ear/portal-ejb.jar/portal.properties • Fix the permissions (chmod u+x bin/*.sh) • Run the server (bin/run.sh) • Browse to: http://localhost:PORT/
Take it for a spin • Change the color scheme • Maximize, minimize and interact with portlets • Rearrange the portlets on the page • Visit various pages • As an admin: • Manage pages • Manage users • Manage user access to portlets/pages/etc.
Hot-deploy our Portlet <targetname=“deploy”> <propertyenvironment=“env”/> <propertyname=“server.type” value=“jboss-tomcat”/> <propertyname=“server.dir” value=“/server/jboss-tomcat”/> <propertyname=“server.deploy” value=“${server.dir}/server/default/deploy”/> <javaclassname=“com.liferay.portal.tools.PortletDeployer”> <classpath> <pathelementlocation=“${server.deploy}/ext.ear/portal-ejb.jar”/> <pathelementlocation=“${env.ANT_HOME}/lib/ant.jar”/> <filesetdir=“${server.dir}/server/default/lib/ext”/> </classpath> <argvalue=“${server.type}”/> <argvalue=“${server.deploy}”/> <argvalue=“${server.deploy}/ext.ear/portal-web-complete.war/WEB-INF/tld/liferay-portlet.tld”/> <argvalue=“${server.deploy}/ext.ear/portal-web-complete.war/WEB-INF/lib/util-taglib.jar”/> </java> </target>