Using Legacy Applications via Bridges Mark Baker and Rahim Lakhoo

advertisement
Using Legacy Applications via
Bridges
Mark Baker and Rahim Lakhoo
Outline
• Introduction.
• Motivation.
• Technologies:
– JSR-223,
– PHP-JavaBridge,
– PortletBridge-Portlet,
– Other Bridging Technologies.
• System Architecture.
• Demonstration Applications.
• Issue.
• Conclusions.
31 May 2016
2
Introduction
• Portsmouth and Reading’s role in the Sakai VRE
project is to develop and deploy a number of
portlet-based tools and services.
• In particular we are looking at:
– Collaborative tools based on NaradaBrokering,
– Semantic Web tools based on RDF,
– Bridging technologies to enable legacy applications,
– Peer-to-Peer technologies.
• We will make these tools available, either via a
native JSR-168 capability, or via the WSRP
consumer developed within the Sakai project.
• In this talk we will recount our experiences
investigating, deploying and testing a range of
emerging bridging technologies.
31 May 2016
3
Legacy Applications
• Motivation:
– Investigate whether script-based Web
applications, such as PHP can be reused in
Java-based environment,
– Investigate if PHP applications can be reused
as a portlets,
– Test by deploying a number of PHP
applications as portlets,
– Add useful tools/utilities to the Sakai
Demonstrator.
31 May 2016
4
Bridging Technologies
• JSR-223:
– Reference implementation available,
– Allows Java to communicate objects with script-based
languages and vice versa,
– To be included with the next release of Sun JDK
“Mustang” (JDK 1.6).
• PHP-JavaBridge:
– Described as an XML-based network protocol,
– Allows communications between Java and PHP,
– Provides a suitable environment to execute PHP scripts
under Apache Tomcat.
• PortletBridge-Portlet:
31 May 2016
– Renders Web pages into a JSR-168 portlet,
– Proxies links and other external resources contained in a
Web page,
– Can load multiple instances, with different configurations.
5
Bridges - JSR-223 (1)
• JSR-223 specification is lead by Zend
Technologies and Sun, amongst others.
• Allows script-based languages to be used
in Java server-side applications and vice
versa.
• Defines a new API, javax.script.*.
• New API includes scripting-engines for
different languages.
• Reference implementation includes
support for Rhino, PHP and Groovy.
31 May 2016
6
Bridges - JSR-223 (2)
• Reference Implementation:
Hosting Server
Apache Tomcat
JSR223 Reference Implementation
Compiled
PHP 5.01
PHP.INI
31 May 2016
Libs
Javax.script
API
CLI
Scripting
Engines
PHP
Engine
Groovy
Engine
Samples
PHP
Rhino
Engine
PHP
CLI
Groovy
PHP
Web
Groovy
Web
Groovy
CLI
7
Bridges - JSR-223 (3)
• Reference implementation of JSR-223
includes a pre-compiled skeleton
installation of PHP5.
• JSR-223 API includes some scripting
engines for PHP, Groovy and Rhino.
• Also includes a script to invoke Java
classes, which contain script-based calls,
from the command-line.
• Samples scripts/programs are available
for PHP, Groovy amongst others:
– Command-line and Web capabilities.
31 May 2016
8
Bridges - PHP-JavaBridge (1)
• Described as an XML-based network protocol.
• Designed to communicate with native scripting
engines, which have a Java or ECMA 335 virtual
machine.
• Provides a suitable environment for PHP applications
to run under Apache Tomcat.
• Allows Java and PHP to share sessions, in a J2EE
environment.
• Has a number of configurations for installation and
connections to existing Web servers.
31 May 2016
9
Bridges - PHP-JavaBridge (2)
Hosting Server
Apache Tomcat
Apache Web Server
PHP-JavaBridge
Socket Connection
Java Libs
Hosts CGI
Binary
31 May 2016
PHP CGI
Optional Binaries
10
Bridges - PHP-JavaBridge (3)
• Includes PHP5-CGI binaries and configurations files.
• Although the PHP-JavaBridge is not limited to the included
CGI environment, it can use the PHP environment of the
hosting server.
• The PHP-JavaBridge can connect to an existing Apache Web
Server, executing PHP applications.
• Has a number of different modes:
–
–
–
–
Request - Created/destroyed on every request/response,
Dynamic - Starts/stops synchronously with a HTTP server,
System - Installed from a RPM as a system service,
J2EE - Installed into a J2EE server, such as Apache Tomcat.
• If the PHP instance crashes with the PHP-JavaBridge the
backend Java server/servlet is unaffected.
31 May 2016
11
Bridges - PortletBridge-Portlet (1)
• Generic method of rendering Web sites into a JSR168 portlet, developed by Jamie McCrindle.
• Tested in various portlet containers, including
GridSphere, JetSpeed and JBoss.
• Proxies a Web sites content, so that a user may use
the application from within a portlet.
• Uses XSLT to rewrite downstream content from Web
sites.
• Includes remote proxy server settings for complex
network set-ups.
• Allows for multiple instances with different
configurations.
31 May 2016
12
Bridges - PortletBridge-Portlet (2)
Hosting Server
Web Page/
Site
Apache Tomcat
Portal
PortletBridge-Portlet
Portlet
Web
Page/Site
Rendered
as a
Portlet
31 May 2016
PortletBridge Servlet
XSLT
Proxy
Scope
Memento
13
Bridges - PortletBridge-Portlet (3)
• PorltetBridge-portlet, uses Apache’s httpclient to
GET/POST from/to Web pages.
• Web pages are transformed using XSLT, which
rewrites links and other content, such as:
– CSS,
– JavaScript,
– Images,
– Forms,
– Headers,
– etc…
• Uses Regex for defining the proxy scope.
• PortletBridge defines a Memento for storing users
state, such as cookies.
31 May 2016
14
Bridges - Others
• Apache Portals Bridges project aims to
use common Web frameworks via
portlets.
• Currently support is being developed for:
– Struts,
– JSF,
– Perl CGI Scripts,
– PHP,
– Velocity Templates.
• GridSphere 2.1.x portal includes the
Struts Portals Bridge.
31 May 2016
15
System Architecture (1)
• The PHP-JavaBridge provides the runtime
environment for the PHP application.
• A PHP application is packaged and configured as
a Web archive (WAR).
• Included in the WAR is a configured CGI
environment, complete with PHP configuration
files and extensions, per application.
• The PHP application can communicate with Java
if extra functionality or a hybrid application is
desired.
31 May 2016
16
System Architecture (2)
Hosting Server
GridSphere Portal
Apache Tomcat
PortletBridgePortlet
Exsiting Application
PHP Application
MySQL
Database
PHP-JavaBridge
CGI/FastCGI
31 May 2016
17
System Architecture (3)
• The PortletBridge-Portlet is installed as a JSR168 portlet under GridSphere.
• PortletBridge-Portlet instances are created and
configured for each PHP application installed
under the PHP-JavaBridge.
• If desired, XSL Style Sheets can be configured
per PHP application.
• Once configured, the PHP applications are
presented as individual portlets, which can be
subscribed to by users.
31 May 2016
18
Demonstration Applications
• Using a combination of the PHP-JavaBridge and
the PortletBridge-Portlet, we configured some
PHP applications as portlets.
• These are the applications configured:
– BibAdmin - Bibtex database,
– YW Guest Book - PHP guest book application,
– FhImage - A simple image gallery.
• Deployment procedure:
– Applications are first deployed as WARs under Tomcat.
– Then an instance of the PortletBridge-Portlet is
created and configured for each PHP application.
31 May 2016
19
BibAdmin Portlet
31 May 2016
20
Guest Book Portlet
31 May 2016
21
Guest Book Admin Portlet
31 May 2016
22
Image Gallery Portlet
31 May 2016
23
Demonstrated Applications
• The PHP applications tested with this
technique have no real difference in terms
of functionality when compared to native
installations.
• Some PHP applications are easier to port to
a portlet than others.
• Other PHP applications have a poor
implementation/design, which can lead to
issues within a portal environment.
31 May 2016
24
Issues
• Login mechanisms can cause problems; simple PHP and PHP
with JS logins were tested successfully:
– However, it is also feasible to disable logins of PHP applications
in favor of utilising the portals security framework.
• Some applications need to have pre-defined PHP variables
changed to reflect the J2EE environment, i.e. port number.
• PHP applications which load new windows have issues with the
constraints imposed by a portal.
• Frames are not supported by the PortletBridge-Portlet.
• XHTML or mixed XHTML/HTML documents currently cause
the proxy facility of the PortletBridge-Portlet to fail:
– The developers are working on this.
• There are some CSS leaks into the portal, currently this
issue has been seen with GridSphere:
– Also, background colours cannot always be seen in the portlet
versions.
31 May 2016
25
Conclusions
• Although this technique is not without issues, it
does present a viable solution for reusing existing
PHP applications.
• The PortletBridge-Portlet is still a young project,
which is being actively developed.
• Other bridging technologies, such as the Apache
Portals Bridges project will be of interest, as they
are starting to be included in portals, such as
GridSphere.
• JSR-223 should see an increase in developers
using the new API, as the release of Sun JDK 1.6
approaches.
• Bridging technologies should be an interesting
alternative/addition for developing portlets and
could be useful when combined with WSRP.
31 May 2016
26
References
• http://portals.dsg.port.ac.uk
• http://www.jcp.org/aboutJava/communit
yprocess/edr/jsr223/index.html
• http://PHP-Java-Bridge.sourceforge.net
• http://www.portletbridge.org
• http://www.gridpshere.org
• http://portals.apache.org/bridges/
31 May 2016
27
Questions?
http://dsg.port.ac.uk
http://acet.rdg.ac.uk
Quic kTi me™ and a
Download