QCon London: Mastering long-running processes in modern architectures
1 app 2 developers 3 servers
1.
2. 1 App, 2 Developers, 3 Servers:
Getting the Same
Application to run on
different servers
Mark Myers, LDC
René Winkelmeyer, midpoints GmbH (honorary)
3. Who Am I ? : Mark Myers
Member of the London Developer Co-op http://www.londc.com
– A group of freelance developers that band together to build more
complex projects.
– IBM Connections, Domino, Mobile and Web development
– Hire me!
Developer from a support background
13+ years on Domino, 16+ years in IT
Speaker at 5x Lotuspheres/Connects, 5 x UKLUGs, 1 x ILUG,
2 x BLUG/Engage
5. What is this Session about?
Its about being able to write a core app and deploy it on any server with a Java core
– It does not even need to be a Java app, this works just as well for pure client side websites using
popular client side JavaScript frameworks eg, AngluarJS, backbone.
– This also means you can use your preferred IDE, ie sublime text for AngularJS
As IBM develops new apps and brings out new platforms, you want to be able to develop
for them without putting all your eggs in one basket (this is good for IBM as it lowers the
investment cost for partners to developer for their platforms)
We used to take each new standard and framework and try and glue it to Domino, now we
can speed up that process and glue it to any part of the IBM stack. <cough> BlueMix
<cough> or even expand our apps to other providers
6. What Software are we using?
IDE: Eclipse™ Luna for EE https://www.eclipse.org/downloads/packages/eclipse-ide-java-
ee-developers/lunasr1a
– Vaadin Plugin https://vaadin.com/eclipse
– Apache® Tomcat® V8 http://tomcat.apache.org/download-80.cgi
IBM® Domino® 9.0.1
IBM® WebSphere® 8.5.5 (Not the Liberty Profile, the full server as used by Connections)
8. Basic Vaadin Application
Why Use Vaadin for this demo?
– It is one of the best frameworks in terms of features ( both client side and server side logic)
– Easy for Domino People to pick up, as of all the current frameworks it seems to work the nearest
of Domino and Xpages.
– Uses a single servlet and deploys as a standard WAR application (Web application ARchive)
– Complex in terms of infrastructure (not a hello world platform)
– Its not a client end framework e.g AngularJS
9. Basic Vaadin Application
Once you have added the Vaadin Plugin
Select “File” “New” and select “Vaadin
7 Project”
10. Basic Vaadin Application
Give the Project a name and leave the Target runtime as
“<None>” and accept defaults on the rest of the options
Accept the default build Directory
12. Basic Vaadin Application
If this is your first time building a Vaadin App it will
download a load of backend framework stuff, don’t worry
just let it run. (we will come back to why that is important
later)
You now have a clean
new WAR app, lets
deploy it.
14. Apache: Setup
Globally considered the baseline for Java Application Servers
The Most popular Java Application Server on the Internet
– https://plumbr.eu/blog/most-popular-application-servers-in-2014
Very easy going and light weight
15. Apache: Setup
Download Tomcat from
http://tomcat.apache.org/download-
80.cgi
Upzip the Download and place it
somewhere sensible.
16. Apache: Setup
Go Back To Eclipse, Select the “Servers”
tab
Click to the Link to Create a New Server
Config
17. Apache: Setup
Select Apache / Tomcat v8.0 from the list
Browse to the directory you unzipped
Tomcat to and select it.
18. Apache: Setup
To deploy an app in eclipse, right click
on the application root
Select “Run As” “Run on Server”
19. Apache: Setup
The “3ServerDemo” will be listed in
the Available column, add it to the
“Configured” column.
23. WebSphere: Setup
The core of the IBM stack
The Liberty profile is a very light weight version of the full WebSphere server.
– Perfect for local development.
– From the point of view of the type of applications we are discussing here WebSphere and the
liberty profile are interchangeable.
– We are not using it here just to prove a point as Connections development is one of our primary
use cases and Connections uses the full WebSphere server.
24. WebSphere: Setup
We are assuming you have installed
WebSphere 8.5.5 locally
– A typical install accepting all defaults
After that we will want to install the IBM
WebSphere plugin for Eclipse
This is in the “Eclipse Marketplace” rather
than under the “Install New Software”
25. Websphere: Setup
Search for IBM and select “install” on
“IBM WebSphere Application Server
V8.5x Developer Tools”
26. WebSphere: Setup
You only need the “WebSphere
Application Server V8.5 Tools” but the
other tools are useful.
Select “Confirm”.
27. Websphere: Setup
Once the tools have installed and Eclipse
restarted.
On the “Servers” tab right click, and
select “New” Server
28. WebSphere: Setup
Select “WebSphere Application Server V8.5”
Accept All defaults
Select “Finish”
29. WebSphere: Setup
Browse to the servers AppServer directory (it
will auto fill the JRE Setting)
– Note: This JRE has to be a version equal or
higher than the Compile version of the
application
30. WebSphere: Setup
You will find that when you try to
run the WAR app on WebSphere in
the same way as you did for
Tomcat that no applications will be
Listed
You need to create a EAR wrapper
32. WebSphere: Setup
Give the EAR project a suitable name,
and select the “Target runtime”
Click “Next”
33. WebSphere: Setup
Now select the actual app that will be
inserted into the EAR application
If you want to keep all the Application
settings within the core application then
do not select “Generate application.xml
deployment descriptor”
34. WebSphere: Setup
Now you will find, that when you try to
run the application on WebSphere you
have a available Application.
35. WebSphere: Setup
The Application in now running on
WebSphere
Be still my beating heart part 2
37. Connections: Setup
The connections box can take any of the apps you build (Its just a WebSphere box after
all)
– Don’t forget that connections is a heavy duty application adding additional apps to the same box
has to be done carefully, make sure you work out the maximum load your app is going to add and
keep Admins informed.
– You should use the Connections API’s for most things but you DO gain access to the
Connections DB2 databases (by their well known JDBC names), and they grant you a great deal
of power and speed
• Do not do this without telling your admin.
M
38. Connections: Setup
If you are adding a new app to connections with a new context i.e. the “directory” the site
runs in (in this case “3ServerDemo”)
You will find the URL will not work when you first try and open the website.
You will have to use wsadmin to re-sync the application servers
LCConfigService.checkInConfig("d:",AdminControl.getCell())
LCConfigService.updateConfig("versionStamp","")
39. Connections: Setup
Integration at the users end is done with widgets, either the “Open Social” widget
standard or iwidgets
– See the slides for MAS202 to tell the difference.
An Example of a BASIC “Open Social” wrapper, that you can use to point to your own
content within your own app
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title=“ServerDemo“ author_email=support@3ServerDemo.com height=“500“ width=“100%">
<Require feature="dynamic-height" />
</ModulePrefs>
<Content href="/3ServerDemo" type="url" view="canvas" /></Module>
40. Connections: Setup
And a BASIC iwidget wrapper, that you can use to point to your own content within
your own app
<?xml version="1.0" encoding="UTF-8" ?>
<iw:iwidget name=“3ServerDemo" xmlns:iw="http://www.ibm.com/xmlns/prod/iWidget" iScope="htmlWidget" supportedModes="view" mode="view">
<iw:content mode="view">
<![CDATA[
<iframe src="/3ServerDemo/" scrolling="auto" width="100%" height="3000px" frameborder="0" scrolling="no"></iframe>
]]>
</iw:content>
</iw:iwidget>
41. Connections: Setup
Put the iwidget xml file in the WEB-INF directory
You can use this to add a widget to Connections with the URL
http://servername/3ServerDemo/iwidgetlink.xml
43. Domino: Setup
Take advance of the latest frameworks while still being able to leverage all your existing
domino data and features with easy NSF data and security access.
This has been done multiple times before 2 excellent reference presentations are:
– https://speakerdeck.com/sbasegmez/bp207-meet-the-java-application-server-you-already-own-
ibm-domin
– http://www.slideshare.net/fiorep/domino-osgi-development
44. Domino: Getting Existing Web Applications Running on Domino via OSGI
Method 1 – Copy existing App components over then glue the app back into a new Plug in
Project
– Pros:
• Easy to work out what's going out (mixing project dependency's + OSGI is horrible)
• If you have resource conflicts caused by dependency injection tools, you might have to do an
export as WAR to get the jars matching entries in MANIFEST.MF
– Cons
• Not very elegant
Method 2 - Migrate your Existing Application to a plug-in project
– Pros:
• Impressive and fast when it works.
– Cons:
• Horribly confusing to get right if you don’t know what your OSGI config should look like
46. Domino: Setup
In Eclipse click “New”
“Plug-in Project”
Select “Equinox” as
your framework
Generate an Activator
47. Domino: Setup - Update
Next copy your “src” and “WebContent” from your
original project to
This is only because we are using a Java backend
framework (worst Case scenario)
– If we were using only front end frameworks, you
would only have to copy the “WebContent”
Directory
48. Domino: Setup - Update
Now Import the Notes.jar
– File Import
– Select the file system and get
the Notes.jar file from the ext
directory
49. Domino: Setup - Update
Your MANIFEST.MF will tend to take a lot of
work until you get used to it,
Once you are happy with it, It is
recommended you just manually edit it
rather than using the GUI
The Jar files you copied over from your original project
50. Domino: Setup - Update
Next to ensure you have all
required system libs, check the
facets view for both projects to
ensure they are the same
– Right click on the project root
Properties and select Project
Facets
51. Domino: Setup - Update
That will give you a valid project that can be used in conjunction with
– 1- A eclipse feature site
– 2- Then an eclipse update site
– 3- Then the Domino update site
Be Still my beating heart part 3
I’m not going to go though it as
its been done in a presentation
every year for the last 3 years at
this conference. Zzzzzz
53. Multi Authentication
With the increased emphasis on security due to recent breaches, your application often
has to deal with multiple forms of security.
Despite common standards if you are going to support different servers you have to cater
to different authentication mediums.
Once you have made the initial effort to handle different forms of authentication as dictated
by the server platforms, then adding multiple ones becomes progressively easier.
54. Multi Authentication
Enterprise applications now often
compare poorly against
consumer websites which take
multiple forms of authentication.
55. Multi Authentication: Example
if (isDomino) {
Session userSession = DominoResource.INSTANCE.getUserSession(username.getValue(), password.getValue());
if (null == userSession || !userSession.isValid()) {
//Report system Error
} else {
AppSession appSession = SessionUtils.populateFromDominoSession(userSession)
}
} else {
LDAPLogon lDAPLogon = new LDAPLogon();
LdapContext userCTX = lDAPLogon.getUserCtx(username.getValue(), password.getValue());
if (null == userCTX) {
//Report system Error
} else {
LDAPUtils ldap = new LDAPUtils(username.getValue(), LDAPResource.INSTANCE.getCtx());
AppSession appSession = SessionUtils.populateFromLDAP(ldap)
}
56. Multi Authentication
Pros
– Allows greater integration into a clients system.
– If a client is migrating from one system to another your systems will not be a bottleneck in the
process.
– Can allow you to log on to multiple systems simultaneously.
Cons
– Can slow down the login process
– A systems wide unique identifier is sometimes hard to achieve
• You would not believe how many times email address is not suitable.
58. Data Abstraction
Just about all data storage is actually an abstraction layer (such as http://hibernate.org/ )
If you are considering support for multiple platforms, then providing your own functional
abstraction layer can be very useful.
– You design how you want the data to be handled in your app and deal with the actual nuts and
bold of storage latter, which makes your storage more agnostic.
When doing a data abstraction, it is best to sit down and work out exactly how and what
you are wanting to store and read
If you have created an API then its easy to use the same functions as a data abstraction
and vs versa, so you may have done all the hard work.
59. Data Abstraction
Create Order
Internal Order
Object
Reference No
Status
Address
Items
Etc..
DB2 Order
Table
MongoDb
Collection
NSF
Database
Create DB2
Order
Create
MongoDb
Order
Create NSF
Order
60. Data Abstraction: Example
public OrderStatus createOrder(Order currentOrder, String requestingUser) {
try {
if (isDomino) {
return dominoStore.createOrder( currentOrder, requestingUser) ;
} else(isWebSphere) {
return db2Store.createOrder( currentOrder, requestingUser);
} else {
return mongoStore.createOrder( currentOrder, requestingUser);
}
} catch (Exception e) {
e.printStackTrace();
return OrderStatus.ORDER_CREATE_FAIL;
}
}
There is no mention of
database connections or
tables or SQL or sessions
or anything specific to a
single storage medium
61. Data Abstraction
Pros
– Grants flexibility to changing backend storage
– Makes you think about storage rather than just stuffing data into a database
– Once you have done it once, its easy to reuse.
– Allows soft rollouts of new platforms.
– Easier to work on large teams as it separates workflow and storage.
Cons
– Adding an extra field etc takes much longer.
– It can get complex and cause performance issues if done badly
• Think about the difference between real workflow and storage workflow eg search
– Different platforms can have features that another does not have (eg. Blob storage)
63. Summary
Given the speed that both frameworks and platforms change, you need to provide the most
flexibility you can without sacrificing functionality, all the while ensuring you can pivot if
needed.
– This can be seen in the mobile market where companies tying them selves to a single platform
limit their long term growth, the same rule applies to any application market.
Gluing frameworks onto frameworks is both slow and clunky, taking a few steps back and
building your apps on as clean a system as possible means change is easier, and you can
get for more return on investment.