SlideShare une entreprise Scribd logo
1  sur  22
A General Review of JSR 168 with Examples

Vinay Kumar
de.linkedin.com/in/vinaykumar2/
www.techartifact.com
What is JSR 168?
 From the portlet development point of view, it
is really very simple:
 You write a java class that extends GenericPortlet.
 You override/implement several methods inherited

from GenericPortlet.
 You use some supporting classes/interfaces



Many are analogous to their servlet equivalents
Some (portletsession) actually seem to be trivial wrappers
around servlet equivalents in Pluto.
Some Terminology
Term
Portlet

Portlet
Container
Portal

Portlet
Application

Definition
Java code that manages a piece of
web content and which may invoke
services.
Manages the lifecycle of the portlets
(inits, invokes,destroys).
Displays the portal content provided
by the container. The portal is
responsible for the actual layout.
A webapp containing a group of
related portlets, content, supporting
jars, etc.
The Big Picture

 As a portlet developer, the previous set of classes are all you

normally touch.
 The portlet container (Pluto) is responsible for running your
portlets.
 Init, invoke methods, destroy.

 Portlets have a very limited way of interacting with the container.
 It is a black box->black hole.
 The API is basically one-way.
Some Generic Portlet Methods
Method

Description

Init

Called when the portlet is created.
Override if you need to set initial params.

doView

Controls what happens immediately
before the portlet is displayed in view
mode. Normally you override this.

doHelp, doEdit

Other portlet display modes

processAction

Place for handling any <form> actions
before turning over to the display mode
method (like doView). You should
override this for web forms.
Some Supporting Classes/Interfaces
Class

Description

PortletContext

Similar to servlet context; get context info and the
RequestDispatcher from here.

PortletSession

Stores attribute information for a single portlet
application across multiple requests.

RenderRequest,
RenderResponse

The request and response objects available to the
doView() method. Similar to the normal servlet
request

ActionRequest,Actio The request and response objects available to the
nResponse
processAction() method. Similar to the servlet
request and response objects.
PortletURL

Use this to create URLs that reference the portal.

PortletRequestDispat Use this to include/forward to a JSP or servlet in
cher
the same portlet app.

WindowState

See if you are in minimized, maximized, normal
state.
In Action: Get started.
public class JunkPortlet extends GenericPortlet {
public void init(){
//Do any initialization.
}
//Rest of the methods on following slides go here.
…
}
Override doView()
protected void doView( RenderRequest
req, RenderResponse res)
throws PortletException, IOException {
//Include the desired JSP or HTML page.
//We could also use out to write directly to the
response.
WindowState state=req.getWindowState();
if(!state.equals(WindowState.MINIMIZED)) {
res.setContentType("text/html");
PortletRequestDispatcher rd=
getPortletContext().getRequestDispatcher(“MyJSP.
jsp”);
rd.include(req,res);
}
}
The JSP Page
<portlet:defineObjects/>
<%
PortletSession
portletSession=renderRequest.getPortletSession();
portletSession.setAttribute("localattname","localattval");
PortletURL url=renderResponse.createActionURL();
String theActionString=url.toString();
%>
HTML Content is here.
A form is below.
<form method=post action="<%=theActionString%>">
<input type=…>
</form>
Some Notes
 Include the <%portlet:definedObjects/%> tag, which

will instantiate renderRequest, renderResponse, and
portletConfig objects.
 You can then just use them, as with request, response, and

other JSP implicit objects.

 The renderRequest gives you access to the

PortletSession, if you want to store session variables.
 One of the trouble points.

 The renderResponse gives you access to the PortletURL

object.
 Use the PortletURL to generate a URL for the <form
action>

 So that it points to portlet container and gets handled by the

processAction() method, rather than going of into space.
 Handle href URLs similarly.
 This is one of the sticking points.
Lastly, Override processAction()
 When you invoke the form on the
previous JSP, the portlet container will
pass the action handling to the
processAction method.
 The ActionRequest can be used to get
any of the <input> parameters in a way
similar to the usual HttpServletRequest.
 When the processAction method
returns, the container then invokes the
appropriate do method (usually
doView).
 If you need to pass <form> parameters
on to doView, add them to the
ActionResponse.



This will give them to the RenderRequest.
The example shows how to add ALL
parameters.

public void processAction
(ActionRequest request,
ActionResponse
actionResponse) throws
PortletException,
java.io.IOException {
//Process request parameters
…
//Add any other request params
// to the renderRequest
actionResponse.setRenderPara
meters(request.getParameterMa
p());
}
A Final Comment on Portlet Coding
 The above example makes some important and dubious

assumptions

 Developers would want to write a GenericPortlet extension for

every single portlet they develop.


And write really complicated processAction() and doView()
methods.

 Developers will like the specific JSR 168 portlet-style MVC that

it forces on them.
 Developers will gladly ignore other development
methodologies/frameworks like Velocity, Struts, and JSF.

 Fortunately, we can develop bridges that allow you to

develop with other frameworks and avoid lots of
specialized portlet code.
 We have targeted Velocity for reasons discussed later.
 Java Server Faces may be the way of the future.
Deploying Portlet Applications
 The portlet container (i.e. uPortal) runs as a
distinct web application.
 That is, it has its own directory in tomcat.
 Moreover, it runs as a separate context, with its own

classloader, session management, etc.

 Portlet applications are deployed as distinct war
files/web applications.
 You go through the container webapp to get to the

portlet webapp.
 Portlets in the same application share jars, classes,
and runtime stuff like request and session variables.
 Portlets in different portlet apps do not share
anything.

 JSR 168 containers vary in the specifics of their
deployment procedures.
 We’ll look at uPortal and GridSphere
The Maven Way
 Maven is a very powerful build/deploy tool.
 Compared to Apache Ant, it has many more
built-in functions (“goals”)
 Essentially, you avoid writing a lot of Ant build.xml

boilerplate for common tasks like compiling
code, making javadocs, and creating wars.
 Also helps you manage jar dependencies.
 Just use a common directory structure.

 If you need to do custom things, create Maven
scripts that just call Ant or Jelly.
Using Maven in Portlet Development
 First, create a standard directory

structure.
 See right

 Project.xml is a maven file that

defines your project.
 Put all your application under
src.
 Put all java code under src/java.
 Use package dir structure

 Images, HTML, JSP, etc. go

under the webapp directory.
 Put unit tests under the tests
directory.






MyProject/project.xml
MyProject/src/java/
MyProject/src/webapp/jsp
MyProject/src/webapp/WEBINF/web.xml
 MyProject/src/webapp/WEBINF/portlet.xml
 MyProject/tests
Maven War
 If you use the previous structure, all you need to do to

compile everything and create a war file is type “maven
war” in the MyProject directory.
 This will also run any unit tests that you have placed in
MyProject/tests.
 The resulting war file is placed in MyProject/target/
project.xml and
project.properties
 project.xml allows you to specify jar
dependencies and build characteristics.

 project.properties defines any variables that you
want to set in project.xml.
 It also defines maven properties like the maven

remote repository values.

 You can also script maven using maven.xml.
 You can also beef maven goals up with Ant and/or

Jelly scripts.
 Not used in the example but used extensively in the
OGCE download.
Portlet.xml
 This file is used to configure your portlet

properties.
 The example code includes a minimal portlet.xml
file for inspection.
Web.xml

 Web.xml is the standard place to put webapp
configuration for servlets/jsp.
 JSR 168 containers need a special servlet that
can handle cross-webapp communication.
 This is typically configured in each portlet app’s

web.xml file.
 This is portal vendor-specific.

 For uPortal installation, you don’t have to worry
about these details.
 uPortal has a tool to read the web.xml you give it and

add in the additional required XML tags.
 You can examine the changes in the
OGCESamplePortlets webapp.
Demo -
Questions

?
Thank you

Contenu connexe

Tendances

Java 10 New Features
Java 10 New FeaturesJava 10 New Features
Java 10 New FeaturesAli BAKAN
 
Component Framework Primer for JSF Users
Component Framework Primer for JSF UsersComponent Framework Primer for JSF Users
Component Framework Primer for JSF UsersAndy Schwartz
 
Introduction to java standard portlets
Introduction to java standard portletsIntroduction to java standard portlets
Introduction to java standard portletsRohan Faye
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and DebuggingRich Helton
 
Exploiting Deserialization Vulnerabilities in Java
Exploiting Deserialization Vulnerabilities in JavaExploiting Deserialization Vulnerabilities in Java
Exploiting Deserialization Vulnerabilities in JavaCODE WHITE GmbH
 
Learn react by Etietop Demas
Learn react by Etietop DemasLearn react by Etietop Demas
Learn react by Etietop DemasEtietop Demas
 
Java Portlet 2.0 (JSR 286) Specification
Java Portlet 2.0 (JSR 286) SpecificationJava Portlet 2.0 (JSR 286) Specification
Java Portlet 2.0 (JSR 286) SpecificationJohn Lewis
 
SyScan 2016 - Remote code execution via Java native deserialization
SyScan 2016 - Remote code execution via Java native deserializationSyScan 2016 - Remote code execution via Java native deserialization
SyScan 2016 - Remote code execution via Java native deserializationDavid Jorm
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
 
Java 8 from perm gen to metaspace
Java 8  from perm gen to metaspaceJava 8  from perm gen to metaspace
Java 8 from perm gen to metaspaceMohammad Faizan
 
Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)Stephen Colebourne
 

Tendances (18)

Java 10 New Features
Java 10 New FeaturesJava 10 New Features
Java 10 New Features
 
Component Framework Primer for JSF Users
Component Framework Primer for JSF UsersComponent Framework Primer for JSF Users
Component Framework Primer for JSF Users
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 
Java Enterprise Edition
Java Enterprise EditionJava Enterprise Edition
Java Enterprise Edition
 
Introduction to java standard portlets
Introduction to java standard portletsIntroduction to java standard portlets
Introduction to java standard portlets
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and Debugging
 
Exploiting Deserialization Vulnerabilities in Java
Exploiting Deserialization Vulnerabilities in JavaExploiting Deserialization Vulnerabilities in Java
Exploiting Deserialization Vulnerabilities in Java
 
Learn react by Etietop Demas
Learn react by Etietop DemasLearn react by Etietop Demas
Learn react by Etietop Demas
 
Java Portlet 2.0 (JSR 286) Specification
Java Portlet 2.0 (JSR 286) SpecificationJava Portlet 2.0 (JSR 286) Specification
Java Portlet 2.0 (JSR 286) Specification
 
Core java
Core javaCore java
Core java
 
SyScan 2016 - Remote code execution via Java native deserialization
SyScan 2016 - Remote code execution via Java native deserializationSyScan 2016 - Remote code execution via Java native deserialization
SyScan 2016 - Remote code execution via Java native deserialization
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
WEB TECHNOLOGIES Servlet
WEB TECHNOLOGIES ServletWEB TECHNOLOGIES Servlet
WEB TECHNOLOGIES Servlet
 
J2 Ee Overview
J2 Ee OverviewJ2 Ee Overview
J2 Ee Overview
 
Java 8 from perm gen to metaspace
Java 8  from perm gen to metaspaceJava 8  from perm gen to metaspace
Java 8 from perm gen to metaspace
 
Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)
 
EJB Part-1
EJB Part-1EJB Part-1
EJB Part-1
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 

Similaire à JSR 168 Portal - Overview

Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran TochAdil Jafri
 
Web container and Apache Tomcat
Web container and Apache TomcatWeb container and Apache Tomcat
Web container and Apache TomcatAuwal Amshi
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jspAnkit Minocha
 
Html servlet example
Html   servlet exampleHtml   servlet example
Html servlet examplervpprash
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Appschrisb206 chrisb206
 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and DeploymentBG Java EE Course
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsKaml Sah
 
Web Applications Development
Web Applications DevelopmentWeb Applications Development
Web Applications Developmentriround
 
Servlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpServlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpodilodif
 
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 Minutes
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 MinutesBuild Your First Java Jersey JAX-RS REST Web Service in less than 15 Minutes
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 MinutesRobert Li
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksSunil Patil
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworksSunil Patil
 

Similaire à JSR 168 Portal - Overview (20)

Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
 
Web container and Apache Tomcat
Web container and Apache TomcatWeb container and Apache Tomcat
Web container and Apache Tomcat
 
Tomcat + other things
Tomcat + other thingsTomcat + other things
Tomcat + other things
 
Jsp tutorial
Jsp tutorialJsp tutorial
Jsp tutorial
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Jdbc
JdbcJdbc
Jdbc
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jsp
 
Html servlet example
Html   servlet exampleHtml   servlet example
Html servlet example
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and Deployment
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
Web Applications Development
Web Applications DevelopmentWeb Applications Development
Web Applications Development
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
 
Servlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpServlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtp
 
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 Minutes
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 MinutesBuild Your First Java Jersey JAX-RS REST Web Service in less than 15 Minutes
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 Minutes
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source Frameworks
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworks
 

Plus de Vinay Kumar

Modernizing the monolithic architecture to container based architecture apaco...
Modernizing the monolithic architecture to container based architecture apaco...Modernizing the monolithic architecture to container based architecture apaco...
Modernizing the monolithic architecture to container based architecture apaco...Vinay Kumar
 
Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Vinay Kumar
 
Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Vinay Kumar
 
Extend soa with api management Sangam18
Extend soa with api management Sangam18Extend soa with api management Sangam18
Extend soa with api management Sangam18Vinay Kumar
 
Extend soa with api management Doag18
Extend soa with api management Doag18Extend soa with api management Doag18
Extend soa with api management Doag18Vinay Kumar
 
Roaring with elastic search sangam2018
Roaring with elastic search sangam2018Roaring with elastic search sangam2018
Roaring with elastic search sangam2018Vinay Kumar
 
Extend soa with api management spoug- Madrid
Extend soa with api management   spoug- MadridExtend soa with api management   spoug- Madrid
Extend soa with api management spoug- MadridVinay Kumar
 
Expose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug MadridExpose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug MadridVinay Kumar
 
Modern application development with oracle cloud sangam17
Modern application development with oracle cloud sangam17Modern application development with oracle cloud sangam17
Modern application development with oracle cloud sangam17Vinay Kumar
 
award-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caaward-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caVinay Kumar
 
award-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caaward-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caVinay Kumar
 
Adf spotlight-webcenter task flow-customzation
Adf spotlight-webcenter task flow-customzationAdf spotlight-webcenter task flow-customzation
Adf spotlight-webcenter task flow-customzationVinay Kumar
 
Personalization in webcenter portal
Personalization in webcenter portalPersonalization in webcenter portal
Personalization in webcenter portalVinay Kumar
 
Custom audit rules in Jdeveloper extension
Custom audit rules in Jdeveloper extensionCustom audit rules in Jdeveloper extension
Custom audit rules in Jdeveloper extensionVinay Kumar
 
File upload in oracle adf mobile
File upload in oracle adf mobileFile upload in oracle adf mobile
File upload in oracle adf mobileVinay Kumar
 
Webcenter application performance tuning guide
Webcenter application performance tuning guideWebcenter application performance tuning guide
Webcenter application performance tuning guideVinay Kumar
 
Tuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperTuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperVinay Kumar
 
Oracle adf performance tips
Oracle adf performance tipsOracle adf performance tips
Oracle adf performance tipsVinay Kumar
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depthVinay Kumar
 
Oracle Fusion Architecture
Oracle Fusion ArchitectureOracle Fusion Architecture
Oracle Fusion ArchitectureVinay Kumar
 

Plus de Vinay Kumar (20)

Modernizing the monolithic architecture to container based architecture apaco...
Modernizing the monolithic architecture to container based architecture apaco...Modernizing the monolithic architecture to container based architecture apaco...
Modernizing the monolithic architecture to container based architecture apaco...
 
Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20
 
Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20
 
Extend soa with api management Sangam18
Extend soa with api management Sangam18Extend soa with api management Sangam18
Extend soa with api management Sangam18
 
Extend soa with api management Doag18
Extend soa with api management Doag18Extend soa with api management Doag18
Extend soa with api management Doag18
 
Roaring with elastic search sangam2018
Roaring with elastic search sangam2018Roaring with elastic search sangam2018
Roaring with elastic search sangam2018
 
Extend soa with api management spoug- Madrid
Extend soa with api management   spoug- MadridExtend soa with api management   spoug- Madrid
Extend soa with api management spoug- Madrid
 
Expose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug MadridExpose your data as an api is with oracle rest data services -spoug Madrid
Expose your data as an api is with oracle rest data services -spoug Madrid
 
Modern application development with oracle cloud sangam17
Modern application development with oracle cloud sangam17Modern application development with oracle cloud sangam17
Modern application development with oracle cloud sangam17
 
award-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caaward-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026ca
 
award-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026caaward-3b07c32b-b116-3a75-8974-d814d37026ca
award-3b07c32b-b116-3a75-8974-d814d37026ca
 
Adf spotlight-webcenter task flow-customzation
Adf spotlight-webcenter task flow-customzationAdf spotlight-webcenter task flow-customzation
Adf spotlight-webcenter task flow-customzation
 
Personalization in webcenter portal
Personalization in webcenter portalPersonalization in webcenter portal
Personalization in webcenter portal
 
Custom audit rules in Jdeveloper extension
Custom audit rules in Jdeveloper extensionCustom audit rules in Jdeveloper extension
Custom audit rules in Jdeveloper extension
 
File upload in oracle adf mobile
File upload in oracle adf mobileFile upload in oracle adf mobile
File upload in oracle adf mobile
 
Webcenter application performance tuning guide
Webcenter application performance tuning guideWebcenter application performance tuning guide
Webcenter application performance tuning guide
 
Tuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperTuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paper
 
Oracle adf performance tips
Oracle adf performance tipsOracle adf performance tips
Oracle adf performance tips
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depth
 
Oracle Fusion Architecture
Oracle Fusion ArchitectureOracle Fusion Architecture
Oracle Fusion Architecture
 

Dernier

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Dernier (20)

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

JSR 168 Portal - Overview

  • 1. A General Review of JSR 168 with Examples Vinay Kumar de.linkedin.com/in/vinaykumar2/ www.techartifact.com
  • 2. What is JSR 168?  From the portlet development point of view, it is really very simple:  You write a java class that extends GenericPortlet.  You override/implement several methods inherited from GenericPortlet.  You use some supporting classes/interfaces   Many are analogous to their servlet equivalents Some (portletsession) actually seem to be trivial wrappers around servlet equivalents in Pluto.
  • 3. Some Terminology Term Portlet Portlet Container Portal Portlet Application Definition Java code that manages a piece of web content and which may invoke services. Manages the lifecycle of the portlets (inits, invokes,destroys). Displays the portal content provided by the container. The portal is responsible for the actual layout. A webapp containing a group of related portlets, content, supporting jars, etc.
  • 4. The Big Picture  As a portlet developer, the previous set of classes are all you normally touch.  The portlet container (Pluto) is responsible for running your portlets.  Init, invoke methods, destroy.  Portlets have a very limited way of interacting with the container.  It is a black box->black hole.  The API is basically one-way.
  • 5. Some Generic Portlet Methods Method Description Init Called when the portlet is created. Override if you need to set initial params. doView Controls what happens immediately before the portlet is displayed in view mode. Normally you override this. doHelp, doEdit Other portlet display modes processAction Place for handling any <form> actions before turning over to the display mode method (like doView). You should override this for web forms.
  • 6. Some Supporting Classes/Interfaces Class Description PortletContext Similar to servlet context; get context info and the RequestDispatcher from here. PortletSession Stores attribute information for a single portlet application across multiple requests. RenderRequest, RenderResponse The request and response objects available to the doView() method. Similar to the normal servlet request ActionRequest,Actio The request and response objects available to the nResponse processAction() method. Similar to the servlet request and response objects. PortletURL Use this to create URLs that reference the portal. PortletRequestDispat Use this to include/forward to a JSP or servlet in cher the same portlet app. WindowState See if you are in minimized, maximized, normal state.
  • 7. In Action: Get started. public class JunkPortlet extends GenericPortlet { public void init(){ //Do any initialization. } //Rest of the methods on following slides go here. … }
  • 8. Override doView() protected void doView( RenderRequest req, RenderResponse res) throws PortletException, IOException { //Include the desired JSP or HTML page. //We could also use out to write directly to the response. WindowState state=req.getWindowState(); if(!state.equals(WindowState.MINIMIZED)) { res.setContentType("text/html"); PortletRequestDispatcher rd= getPortletContext().getRequestDispatcher(“MyJSP. jsp”); rd.include(req,res); } }
  • 9. The JSP Page <portlet:defineObjects/> <% PortletSession portletSession=renderRequest.getPortletSession(); portletSession.setAttribute("localattname","localattval"); PortletURL url=renderResponse.createActionURL(); String theActionString=url.toString(); %> HTML Content is here. A form is below. <form method=post action="<%=theActionString%>"> <input type=…> </form>
  • 10. Some Notes  Include the <%portlet:definedObjects/%> tag, which will instantiate renderRequest, renderResponse, and portletConfig objects.  You can then just use them, as with request, response, and other JSP implicit objects.  The renderRequest gives you access to the PortletSession, if you want to store session variables.  One of the trouble points.  The renderResponse gives you access to the PortletURL object.  Use the PortletURL to generate a URL for the <form action>  So that it points to portlet container and gets handled by the processAction() method, rather than going of into space.  Handle href URLs similarly.  This is one of the sticking points.
  • 11. Lastly, Override processAction()  When you invoke the form on the previous JSP, the portlet container will pass the action handling to the processAction method.  The ActionRequest can be used to get any of the <input> parameters in a way similar to the usual HttpServletRequest.  When the processAction method returns, the container then invokes the appropriate do method (usually doView).  If you need to pass <form> parameters on to doView, add them to the ActionResponse.   This will give them to the RenderRequest. The example shows how to add ALL parameters. public void processAction (ActionRequest request, ActionResponse actionResponse) throws PortletException, java.io.IOException { //Process request parameters … //Add any other request params // to the renderRequest actionResponse.setRenderPara meters(request.getParameterMa p()); }
  • 12. A Final Comment on Portlet Coding  The above example makes some important and dubious assumptions  Developers would want to write a GenericPortlet extension for every single portlet they develop.  And write really complicated processAction() and doView() methods.  Developers will like the specific JSR 168 portlet-style MVC that it forces on them.  Developers will gladly ignore other development methodologies/frameworks like Velocity, Struts, and JSF.  Fortunately, we can develop bridges that allow you to develop with other frameworks and avoid lots of specialized portlet code.  We have targeted Velocity for reasons discussed later.  Java Server Faces may be the way of the future.
  • 13. Deploying Portlet Applications  The portlet container (i.e. uPortal) runs as a distinct web application.  That is, it has its own directory in tomcat.  Moreover, it runs as a separate context, with its own classloader, session management, etc.  Portlet applications are deployed as distinct war files/web applications.  You go through the container webapp to get to the portlet webapp.  Portlets in the same application share jars, classes, and runtime stuff like request and session variables.  Portlets in different portlet apps do not share anything.  JSR 168 containers vary in the specifics of their deployment procedures.  We’ll look at uPortal and GridSphere
  • 14. The Maven Way  Maven is a very powerful build/deploy tool.  Compared to Apache Ant, it has many more built-in functions (“goals”)  Essentially, you avoid writing a lot of Ant build.xml boilerplate for common tasks like compiling code, making javadocs, and creating wars.  Also helps you manage jar dependencies.  Just use a common directory structure.  If you need to do custom things, create Maven scripts that just call Ant or Jelly.
  • 15. Using Maven in Portlet Development  First, create a standard directory structure.  See right  Project.xml is a maven file that defines your project.  Put all your application under src.  Put all java code under src/java.  Use package dir structure  Images, HTML, JSP, etc. go under the webapp directory.  Put unit tests under the tests directory.     MyProject/project.xml MyProject/src/java/ MyProject/src/webapp/jsp MyProject/src/webapp/WEBINF/web.xml  MyProject/src/webapp/WEBINF/portlet.xml  MyProject/tests
  • 16. Maven War  If you use the previous structure, all you need to do to compile everything and create a war file is type “maven war” in the MyProject directory.  This will also run any unit tests that you have placed in MyProject/tests.  The resulting war file is placed in MyProject/target/
  • 17. project.xml and project.properties  project.xml allows you to specify jar dependencies and build characteristics.  project.properties defines any variables that you want to set in project.xml.  It also defines maven properties like the maven remote repository values.  You can also script maven using maven.xml.  You can also beef maven goals up with Ant and/or Jelly scripts.  Not used in the example but used extensively in the OGCE download.
  • 18. Portlet.xml  This file is used to configure your portlet properties.  The example code includes a minimal portlet.xml file for inspection.
  • 19. Web.xml  Web.xml is the standard place to put webapp configuration for servlets/jsp.  JSR 168 containers need a special servlet that can handle cross-webapp communication.  This is typically configured in each portlet app’s web.xml file.  This is portal vendor-specific.  For uPortal installation, you don’t have to worry about these details.  uPortal has a tool to read the web.xml you give it and add in the additional required XML tags.  You can examine the changes in the OGCESamplePortlets webapp.