Download presentation
Presentation is loading. Please wait.
1
Kurt Mueller Steve Mock 8/24/04
GridSphere Tutorial Kurt Mueller Steve Mock 8/24/04
2
Intro
3
GridSphere is… a framework for portlet development a portlet container
modeled on IBM’s WebSphere an open source project developed by the EU GridLab project
4
Huh? Portlets? modular groupings of presentation and server-side logic
login portlet file manager portlet job submission portlet managed by a portlet container, such as GridSphere or Jetspeed. Demo various portlets Explain portlet container Portlets extend servlets; portlet container lives in Tomcat servlet container…
5
Portlets are nice because…
modularity should allow easy sharing and deployment JSR-168 will be trivial to move between GridSphere, WebSphere, JetSpeed, etc. GridSphere is JSR-168-compliant
6
Portlets are nice because…
separation of presentation and logic perl cgi script with embedded HTML: Show_jobs.cgi: … #Get the keys from one job hash foreach $label (keys %job_keys){ $htmlstr .= "<td Class=heading bgcolor=white>$label</td>\n"; } $htmlstr .= "</tr>\n"; return $htmlstr;
7
Portlets are nice because…
separation of presentation and logic JSP for presentation: Jobs.jsp: … <h1>Job listing:</h1> Name: <c:out value=“${job.name}” /><br> Owner: <c:out value=“${job.owner}” /><br> …and Java for logic: JobList.java: … String jobID = request.getParameter(jobID); Jobs jobs = dataBase.getJobs(); Job myJob = jobs.getJob(jobID); Request.setParameter(“job”, myJob); RequestDispatcher rd = request.getRequestDispatcher("/contacts.jsp"); rd.forward(request, response);
8
GridSphere portlet container provides:
Security Authentication and session management Role-based access control User/group management (admin only) Interface customization Layout Themes Localization Webapp deployment (admin only)
9
Portlet container provides:
Various helper portlets File Manager Notepad Banner display Text messaging
10
Authentication Pluggable architecture
Default is simple username/password database Can login with Grid credentials from Myproxy server Can write your own module Prioritize login mechanisms, so can fall back to default if more complex mechanisms fail.
11
Role-Based Access Control
Users are one of: USER ADMIN SUPER
12
User / Group management
13
User / Group management
Also, can restrict or provide access to webapps on a per-user basis
14
Layout customization
15
Localization Portlet.properties: Portlet_de.properties:
LOGIN_NAME=User Name LOGIN_PASS=Password LOGIN_SUCCESS=Welcome LOGIN_FAILED=Your username and/or password is incorrect. Please try again. LOGIN_ACTION=Login LOGIN_CONFIGURE=Configure Login LOGIN_CONFIG_MSG=Login configuration options LOGIN_CONFIG_ALLOW=Allow users to create new accounts on the portal? LOGIN_SIGNUP=Create new account Portlet_de.properties: LOGIN_NAME=Nutzername LOGIN_PASS=Passwort LOGIN_SUCCESS=Willkommen LOGIN_FAILED=Der Nutzername und/oder das Passwort war nicht korrekt. Bitte versu chen Sie es nocheinmal. LOGIN_ACTION=Anmelden LOGIN_CONFIGURE=Login konfigurieren LOGIN_CONFIG_MSG=Konfigurations Optionen f\u00FCr Login LOGIN_CONFIG_ALLOW=Sollen Nutzer eine neues Konto anlegene k\u00F6nnen? LOGIN_SIGNUP=Neues Konto erstellen
16
Webapp deployment
17
Installing GridSphere
18
Installing GridSphere
Software requirements: JDK Apache Ant Jakarta Tomcat , Tomcat
19
Installing GridSphere
Environment requirements: ANT_HOME set to ant install directory JAVA_HOME set to jdk install directory CATALINA_HOME set to tomcat install directory ant and java executables in your PATH
20
Installing GridSphere
Install tomcat: Download tomcat from , then % tar xvfz jakarta-tomcat tar.gz Set CATALINA_HOME to ${HOME}/jakarta-tomcat
21
Installing GridSphere
Get GridSphere from GridSphere CVS: % cvs -d login % <no password; press enter> % cvs -d co gridsphere
22
Installing GridSphere
Or, get snapshot prepared for this class: Download gridsphere.tar.gz % tar xvfz gridsphere.tar.gz
23
Installing GridSphere
Install GridSphere to tomcat: % cd gridsphere % ant install Startup tomcat and test your GridSphere installation: % cd $CATALINA_HOME % bin/startup.sh Try it out in your web browser!
25
Creating a portlet
26
Development considerations
ALWAYS develop in ${HOME}/gridsphere (or wherever you downloaded from cvs) and deploy to tomcat. DO NOT modify files directly in tomcat after deploying. Edits will be lost next time you deploy from ${HOME}/gridsphere.
27
‘ant install’ vs. ‘ant deploy’
First time you deploy gridsphere or your project to tomcat, use ‘ant install’. Removes previous content Initializes database and persistence management Creates all docs; takes a long time for gridsphere Subsequently, use ‘ant deploy’ Quicker, doesn’t wipe out database Might have to do ‘ant install’ for troubleshooting later
28
Our first portlet Eight steps: Create a new gridsphere project
Write our Java code Edit gridsphere-portlet.xml Edit layout.xml Edit web.xml Deploy project to tomcat
29
Create a new gridsphere project
% cd ${HOME}/gridsphere % mkdir projects % ant new-project Name your project and give it a title: Demo Portlets, demo. Choose “jsr” for JSR-168 compliance. % cd projects/demo/src % mkdir -p demo/portlets/ % vi demo/portlets/HelloWorld.java
30
Create HelloWorld.java
package demo.portlets.helloworld; import javax.portlet.*; import java.io.*; public class HelloWorld extends GenericPortlet { public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<h1>Hello World</h1>"); //* } * no separation of logic and presentation!
31
Edit layout.xml In projects/demo/webapp/WEB-INF, edit layout.xml
<portlet-tabbed-pane> <portlet-tab label="Demo Portlets"> <title lang="en">Demo Portlets</title> <portlet-tabbed-pane style="sub-menu"> <portlet-tab label="helloworldtab"> <title lang="en">Hello World</title> <table-layout> <row-layout> <column-layout> <portlet-frame label="helloworld"> <portlet-class>demo.portlets.HelloWorld</portlet-class> </portlet-frame> </column-layout> </row-layout> </table-layout> </portlet-tab> </portlet-tabbed-pane>
32
Edit group.xml <?xml version="1.0" encoding="UTF-8"?>
<portlet-group> <group-name>demo</group-name> <group-description>The demo group</group-description> <group-visibility>PUBLIC</group-visibility> <portlet-role-info> <portlet-class>demo.portlets.HelloWorld</portlet-class> <required-role>USER</required-role> </portlet-role-info> </portlet-group>
33
Edit portlet.xml <?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns=" version="1.0" xmlns:xsi=" xsi:schemaLocation=" <portlet> <description xml:lang="en">The classic Hello World example</description> <portlet-name>HelloPortlet</portlet-name> <display-name xml:lang="en">Hello World</display-name> <portlet-class>demo.portlets.HelloWorld</portlet-class> <expiration-cache>60</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>edit</portlet-mode> <portlet-mode>help</portlet-mode> </supports> <supported-locale>en</supported-locale> <portlet-info> <title>Hello World</title> <short-title>Hello World</short-title> <keywords>hello</keywords> </portlet-info> </portlet> </portlet-app>
34
Deploy to tomcat Once we’ve put HelloWorld.java into place and modified layout.xml, portlet.xml, and group.xml appropriately, we must deploy our demo webapp to tomcat: % cd ${HOME}/gridsphere/projects/demo % ant install This compiles, packages, and deploys our webapp
35
Finally, restart tomcat
% cd ${HOME}/jakarta-tomcat % bin/shutdown.sh % rm logs/catalina.out % bin/startup.sh
36
Enable Demo Portlets
37
And here it is
38
Portlet modes View - default mode
Edit - change user-configurable options Configure - administrator configuration Help
39
Portlet modes Stock quote portlet example:
View - see your chosen stock prices Edit - change the stocks you want to see Configure - change the back-end stock quote server from which you get data Help - describe how to use the portlet
40
Portlet modes Implementing portlet modes in HelloWorld.java: …
public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<h1>This is the edit mode!</h1>"); }
41
Portlet modes
42
Layout customization
43
Customizing the look
44
Look defined in xml files
In gridsphere/webapps/gridsphere/WEB-INF/layouts: GuestUserLayout.xml: Describes default layout of portal for non-authenticated (guest) users TemplateLayout.xml: Describes default layout of portal for authenticated users. ErrorLayout.xml: Describes error layout
45
Default GuestUserLayout.xml
<?xml version="1.0" encoding="UTF-8"?> <page-layout theme="xp" title="GridSphere Portal"> <!-- Header components --> <portlet-header> <table-layout style="header"> <row-layout> <column-layout width="70%"> <portlet-content include="/html/pagehead.html"/> </column-layout> <column-layout width="30%"> <portlet-frame transparent="true" outer-padding="0" label="locale"> <portlet-class> org.gridlab.gridsphere.portlets.core.locale.LocalePortlet.1 </portlet-class> </portlet-frame> </row-layout> </table-layout> </portlet-header> <!-- Tabbed Panes --> …
46
Custom GuestUserLayout.xml
<?xml version="1.0" encoding="UTF-8"?> <page-layout theme="sdsc" SDSC"> <!-- Header components --> <portlet-header> <portlet-content include="/html/pagehead.html"/> </portlet-header> …
47
Default pagehead.html gridsphere/webapps/gridsphere/html/pagehead.html: <div id="page-logo"><img width="40" height="48" src="/gridsphere/html/gridlablogo.jpg"> GridSphere Portal</div>
48
Custom pagehead.html <table border="0" cellpadding="0" cellspacing="0" width="800"> <tr> <td><img src=" width="553" height="1" border="0" name="undefined_2"></td> <td><img src=" width="247" height="1" border="0" name="undefined_2"></td> <td><img src=" width="1" height="1" border="0" name="undefined_2"></td> </tr> <td colspan="2"><img name="sdsc_top_nav8_r1_c1" src=" width="800" height="58" border="0" usemap="#m_sdsc_top_nav8_r1_c1"></td> <td><img src=" width="1" height="58" border="0" name="undefined_2"></td> <td align="left" valign="top" bgcolor="#0063DE"><img name="sdsc_top_nav8_r2_c1" src="/gridsphere/html/sdsc_top_nav8_r2_c1.gif" width="553" height="37" border="0" usemap="#m_sdsc_top_nav8_r2_c1"></td> <th bgcolor="#0063DE" nowrap align="center" background=" valign="middle" > <table width="100%" cellpadding="0" cellspacing="0" border="0" height="25"> …
49
Custom GuestUserLayout.xml
<!-- Tabbed Panes --> <portlet-tabbed-pane selected="0" style="menu"> <portlet-tab label="home"> <title lang="en">Home</title> <portlet-tabbed-pane selected="0" style="sub-menu"> <portlet-tab label="intro"> <title lang="en">Intro</title> <portlet-content include="/html/home-intro.html"/> </portlet-tab> <portlet-tab label="calendar"> <title lang="en">Calendar</title> <portlet-content include="/html/home-calendar.html"/> </portlet-tabbed-pane>
50
GridSphere vs webapp layout
GuestUserLayout.xml, TemplateLayout.xml, etc. define overall GridSphere look and layout Webapp layout.xml (webapps/demo/WEB-INF/layout.xml) defines tab and portlet structure for individual webapps.
51
GridSphere themes Defined in gridsphere/themes/<theme-name>
Collection of graphic images used to construct tabs and portlet mode icons, etc, and Cascading Style Sheets (CSS) that describe text formatting, spacing, colors, etc.
52
More Portlets
53
PortletUI tag library GridSphere provides a JSP tag library that ‘wraps’ many HTML elements Tags are rendered using gridsphere CSS for consistent look and feel Simplifies coding Enables sharing of objects between JSP and portlet classes through ActionPortlet model.
54
PortletUI tag library Example portlet:
55
PortletUI tag library Html to render it:
<table cellspacing="1" cellpadding="1" border="0" width="100%" > <tr> <td class="portlet-section-body”> Welcome!<br><br> <span class="portlet-msg-info" >Provide your information:</span> </td> </tr> <form action=" method="POST" name="form1"> <td class="portlet-section-body" > <span class="portlet-msg-info" >Name</span> <input class="portlet-form-input-field" type="text" name="" /> <span class="portlet-msg-info" >Description</span> <textarea class="portlet-msg-info" name="" cols="40" rows="5" ></textarea> <input class="portlet-form-button" type="submit" name="action=doSetupSubmit" value="Submit"/> </form> </table>
56
PortletUI tag library Instead of HTML, use PortletUI JSP tags:
<ui:panel> <ui:tablerow> <ui:tablecell > Welcome!<br><br> <ui:text value="Provide your information:" /> </ui:tablecell> </ui:tablerow> <ui:form> <ui:tablecell> <ui:text value="Name" /> <ui:textfield beanId=“name”/> <ui:text value="Description" /> <ui:textarea beanId=“desc” rows="5" cols="40" /> <ui:actionsubmit action="doSubmit" value="Submit"/> </ui:form> </ui:panel>
57
ActionPortlet model public class SimpleActionPortlet extends ActionPortlet { public void init(PortletConfig config) throws UnavailableException { super.init(config); DEFAULT_VIEW_PAGE = "simple/view.jsp"; DEFAULT_CONFIGURE_PAGE = "simple/config.jsp"; DEFAULT_EDIT_PAGE = “simple/edit.jsp”; DEFAULT_HELP_PAGE = “simple/help.jsp”; } public void doSubmit(FormEvent event) { log.debug("in doSubmit"); TextBean name = event.getTextBean(“name”); // output name to Description field of JSP page: TextBean desc = event.getTextAreaBean(“desc”); desc.setValue(“got a name: “ + name.getValue()); setNextState(event.getPortletRequest(), DEFAULT_VIEW_PAGE);
58
gridportlets webapp
59
gridportlets Provided as a stand-alone web application by the GridSphere team Provides Grid-aware portlets and services Available via cvs: % cd gridsphere/projects % cvs -d co gridportlets
60
gridportlets Once downloaded, do ‘ant docs’ in gridportlets root directory. Then read documentation in build/docs for complete installation instructions. Basic steps: Install ogsa bin to tomcat as a separate webapp. Copy ogsa libs to gridportlets/lib/ext ‘ant install’ in gridportlets In gridsphere, Configure Group Membership to enable gridportlets
61
gridportlets Certificate management tools Credential retrieval
Job submission and monitoring <demo>
62
Resources http://www.gridsphere.org
Built-in docs:
63
Resources Authors: Jason Novotny (novotny@aei.mpg.de)
GridSphere mailing lists: Authors: Jason Novotny Michael Russell Oliver Wehrens
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.