Presentation is loading. Please wait.

Presentation is loading. Please wait.

NBCR Summer Institute 2006 GridSphere:Hands-on Installation and Development Jason Novotny

Similar presentations


Presentation on theme: "NBCR Summer Institute 2006 GridSphere:Hands-on Installation and Development Jason Novotny"— Presentation transcript:

1 NBCR Summer Institute 2006 GridSphere:Hands-on Installation and Development Jason Novotny Jnovotny@ncmir.ucsd.edu

2 Requirements You will need the following software packages on you local machine Java > 1.4.x (java.sun.com) Apache Ant > 1.6 (ant.apache.org) Apache Tomcat > 5.0.x (tomcat.apache.org) Knowledge in Java programming Knowledge in Servlet programming It helps to have a look at the JSR 168 specification (http://jcp.org/en/jsr/detail?id=168) or read articles on javaworld.com (http://www.javaworld.com/javaworld/jw-08- 2003/jw-0801-portlet.html) or sun.com (http://developers.sun.com/prodtech/portalserver/reference/t echart/jsr168/)http://jcp.org/en/jsr/detail?id=168http://www.javaworld.com/javaworld/jw-08- 2003/jw-0801-portlet.htmlhttp://developers.sun.com/prodtech/portalserver/reference/t echart/jsr168/

3 Requirements (II) For programming part a good Java IDE (please don’t use vi for real programming) NetBeans (www.netbeans.org)www.netbeans.org Eclipse (www.eclipse.org)www.eclipse.org IntelliJ Idea (www.jetbrains.org) commercialwww.jetbrains.org

4 Getting the required software Tomcat: http://www.gridsphere.org/gridsphere/NBCR/tomcat.tar.gz http://www.gridsphere.org/gridsphere/NBCR/ Ant: http://www.gridsphere.org/gridsphere/NBCR/ant.tar. gz http://www.gridsphere.org/gridsphere/NBCR/

5 Getting GridSphere GridSphere is available from http://www.gridsphere.org/gridsphere/gridsphere?ci d=download Download GridSphere 2.2 (we will refer to that directory from now on as GRIDSPHERE_HOME) Unzip/Untar it $CATALINA_HOME needs to be set to the root directory of tomcat ANT_HOME needs to be set to the root directory of ant export ANT_HOME=

6 Installing cd gridsphere $ANT_HOME/bin/ant install To enable deploying portlets in a running GridSphere please modify the $CATALINA_HOME/conf/tomcat- users.xml file $CATALINA_HOME/bin/startup.sh http://localhost:8080/gridsphere/gridsph ere

7 Setup GridSphere Fill out the GridSphere setup screen

8 Running GridSphere

9 Programming Stop tomcat ($CATALINA_HOME/bin/shutdown.sh) We will create a ‘Hello World’ Example Steps involved: Create the templates Create the jsp, the portlet code Modify the descriptor files Deploy to GridSphere Change the Code Redeploy to GridSphere We going to write a classic HelloWorld example All files can be found at http://www.gridsphere.org/NBCR/workshop/ http://www.gridsphere.org/NBCR/workshop/

10 Creating template files GridSphere provides a mechanism to create template files for your project It is not required to use but it provides some help In GRIDSPHERE_HOME run ‘ant new-project’ You will be asked for a project title, enter Hello World You will be asked for a project name, this will be used for the webapplication name, enter gsexamples (this will be used as directory name for your project) You will be asked whether you want this to be a GS or JSR portletwebapp, enter jsr All templatefiles are now created in GRIDSPHERE_HOME/project/gsexamples If you made a mistake simply erase the GRIDSPHERE_HOME/project/gsexamples directory and start over again

11 Simple Hello World create a file in the subdirectory src/org/gridsphere/gsexamples/portlets named HelloWorld.java package org.gridsphere.gsexamples; import javax.portlet.GenericPortlet; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import javax.portlet.PortletException; import java.io.PrintWriter; import java.io.IOException; 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(" Hello World "); }

12 Deployment descriptors All files are located in webapp/WEB-INF We need to edit a couple of deployment descriptor files portlet.xml - JSR 168 standard, describing the portlet layout.xml - GridSphere file, describing the layout of the portlet within a page group.xml - GridSphere file, Describing a collection of portlets More files are needed but are autogenerated and need not to be modified for this example web.xmlweb.xml - Standard web.xml descriptorweb.xml gridsphere-portlet.xml - GridSphere specific PortletServices.xml - For use with GridSphere Portlet Services

13 portlet.xml (JSR) Specifiy the portlet in webapp/WEB-INF/portlet.xml The classic Hello World example HelloPortlet Hello World org.gridsphere.gsexamples.portlets.HelloWorld 60 text/html edit help en Hello World hello

14 layout.xml (GS) Specifiy the layout in webapp/WEB-INF/layout.xml GridSphere Examples Hello gsexamples#HelloPortlet

15 group.xml (GS) Specify the layout in webapp/WEB-INF/group.xml to define which portlet belong together Hello An example group PUBLIC gsexamples#HelloPortlet USER

16 Deployment Use ‘ant install’ to deploy this portlet to GridSphere Start GridSphere Subscribe to the Hello World group in the Profile Manager

17 Hello World

18 Using UI Beans... Let’s enhance the example a bit Make use of the GridSphere UI Visual Beans Enter a name, say hello or goodbye

19 Creating the JSP JSP’s are stored in webapp/jsp subdirectory of your just created helloworld project Create a jsp file uihelloworld.jsp there http://java.sun.com/portlet !

20 Creating the portlet Create a directory src/org/gridsphere/gsexamples/portlets/ Create the following portletcode in UiHelloWorld.java: package org.gridsphere.gsexamples.portlets; import org.gridlab.gridsphere.provider.portlet.jsr.ActionPortlet; import org.gridlab.gridsphere.provider.event.jsr.RenderFormEvent; import org.gridlab.gridsphere.provider.event.jsr.ActionFormEvent; import org.gridlab.gridsphere.provider.event.jsr.FormEvent; import org.gridlab.gridsphere.provider.portletui.beans.TextBean; import org.gridlab.gridsphere.provider.portletui.beans.TextFieldBean; import javax.portlet.PortletConfig; import javax.portlet.PortletException;

21 UiHelloWorld.java public class UiHelloWorld extends ActionPortlet { private static final String DISPLAY_PAGE = "uihelloworld.jsp"; public void init(PortletConfig config) throws PortletException { super.init(config); DEFAULT_VIEW_PAGE = "prepare"; } private void greet(FormEvent event) { TextBean hellobye = event.getTextBean("hellobye"); hellobye.setValue("Hello"); TextFieldBean name = event.getTextFieldBean("name"); TextBean greeting = event.getTextBean("greeting"); if (name.getValue()==null) name.setValue("stranger"); greeting.setValue(name.getValue()); } public void prepare(RenderFormEvent event) throws PortletException { greet(event); setNextState(event.getRenderRequest(), DISPLAY_PAGE); } public void sayHello(ActionFormEvent event) throws PortletException { greet(event); setNextState(event.getActionRequest(), DISPLAY_PAGE); } public void sayGoodBye(ActionFormEvent event) throws PortletException { greet(event); TextBean hellobye = event.getTextBean("hellobye"); hellobye.setValue("Good Bye"); setNextState(event.getActionRequest(), DISPLAY_PAGE); }

22 portlet.xml Edit the section of the portlet.xml Download as webapp/WEB-INF/portlet-2.xml...<portlet> An Ui Hello World example An Ui Hello World example UiHelloWorld UiHelloWorld org.gridsphere.gsexamples.portlets.UiHelloWorld org.gridsphere.gsexamples.portlets.UiHelloWorld 0 0 text/html text/html en en Ui Hello World Ui Hello World hello, ui, world hello, ui, world </portlet>...

23 layout.xml Download as webapp/WEB-INF/layout-2.xml <portlet-tabbed-pane> GridSphere Examples GridSphere Examples Hello Hello gsexamples#UiHelloWorld gsexamples#UiHelloWorld </portlet-tabbed-pane>

24 group.xml Download as webapp/WEB-INF/group-2.xml <portlet-group> HelloWorld HelloWorld UI Hello World Example UI Hello World Example PUBLIC PUBLIC gsexamples#UiHelloWorld gsexamples#UiHelloWorld USER USER </portlet-group>

25 Redeploy Portlet If you change code you can easily redploy the portlet ant install In GridSphere reload the Hello World portlet app

26 Deployed portlet! Click on the ‘Hello’ tab Enter your name!

27 Questions ?


Download ppt "NBCR Summer Institute 2006 GridSphere:Hands-on Installation and Development Jason Novotny"

Similar presentations


Ads by Google