67

1 app 2 developers 3 servers

Embed Size (px)

Citation preview

Page 1: 1 app 2 developers 3 servers
Page 2: 1 app 2 developers 3 servers

1 App, 2 Developers, 3 Servers: Getting the Same Application to run on different servers

Mark Myers, LDC

René Winkelmeyer, midpoints GmbH (honorary)

Page 3: 1 app 2 developers 3 servers

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

Page 4: 1 app 2 developers 3 servers

Honorary second presenter : René Winkelmeyer

Head of Development at midpoints GmbH

– IBM Advanced Business Partner from Germany http://www.midpoints.de

– Specialized in RCP development

– XPages development and building mobile infrastructures

– IBM Design Partner for Notes/Domino Next and Mobile

OpenNTF Contributor

– File Navigator (http://filenavigator.openntf.org)

– Generic NSF View Widget for IBM Connections2 © 2013 IBM Corporation

He is not always this grumpy looking

Page 5: 1 app 2 developers 3 servers

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

Page 6: 1 app 2 developers 3 servers

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)

Page 7: 1 app 2 developers 3 servers

BASIC APPLICATION

Page 8: 1 app 2 developers 3 servers

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

Page 9: 1 app 2 developers 3 servers

Basic Vaadin Application

Once you have added the Vaadin Plugin

Select “File” “New” and select “Vaadin7 Project”

Page 10: 1 app 2 developers 3 servers

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

Page 11: 1 app 2 developers 3 servers

Basic Vaadin Application

Select “Generate web.xml deployment descriptor”

Accept the other defaults.

Page 12: 1 app 2 developers 3 servers

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.

Page 13: 1 app 2 developers 3 servers

APACHE SETUP

Page 14: 1 app 2 developers 3 servers

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

Page 15: 1 app 2 developers 3 servers

Apache: Setup

Download Tomcat from http://tomcat.apache.org/download-80.cgi

Upzip the Download and place it somewhere sensible.

Page 16: 1 app 2 developers 3 servers

Apache: Setup

Go Back To Eclipse, Select the “Servers” tab

Click to the Link to Create a New Server Config

Page 17: 1 app 2 developers 3 servers

Apache: Setup

Select Apache / Tomcat v8.0 from the list

Browse to the directory you unzipped Tomcat to and select it.

Page 18: 1 app 2 developers 3 servers

Apache: Setup

To deploy an app in eclipse, right click on the application root

Select “Run As” “Run on Server”

Page 19: 1 app 2 developers 3 servers

Apache: Setup

The “3ServerDemo” will be listed in the Available column, add it to the “Configured” column.

Page 20: 1 app 2 developers 3 servers

Apache: Setup

Right click on the server in the “Server” tab and select “Start”

Page 21: 1 app 2 developers 3 servers

Apache: Setup

The Application in now running on Apache

Be still my beating heart part 1

Page 22: 1 app 2 developers 3 servers

WEBSPHERE SETUP

Page 23: 1 app 2 developers 3 servers

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.

Page 24: 1 app 2 developers 3 servers

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”

Page 25: 1 app 2 developers 3 servers

Websphere: Setup

Search for IBM and select “install” on “IBM WebSphere Application Server V8.5x Developer Tools”

Page 26: 1 app 2 developers 3 servers

WebSphere: Setup

You only need the “WebSphere Application Server V8.5 Tools” but the other tools are useful.

Select “Confirm”.

Page 27: 1 app 2 developers 3 servers

Websphere: Setup

Once the tools have installed and Eclipse restarted.

On the “Servers” tab right click, and select “New” Server

Page 28: 1 app 2 developers 3 servers

WebSphere: Setup

Select “WebSphere Application Server V8.5”

Accept All defaults

Select “Finish”

Page 29: 1 app 2 developers 3 servers

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

Page 30: 1 app 2 developers 3 servers

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

Page 31: 1 app 2 developers 3 servers

WebSphere: Setup

Select “File” “New”

Pick “Java EE” “Enterprise Application Project”

Page 32: 1 app 2 developers 3 servers

WebSphere: Setup

Give the EAR project a suitable name, and select the “Target runtime”

Click “Next”

Page 33: 1 app 2 developers 3 servers

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”

Page 34: 1 app 2 developers 3 servers

WebSphere: Setup

Now you will find, that when you try to run the application on WebSphere you have a available Application.

Page 35: 1 app 2 developers 3 servers

WebSphere: Setup

The Application in now running on WebSphere

Be still my beating heart part 2

Page 36: 1 app 2 developers 3 servers

WEBSPHERE SETUPAPPENDIX: CONNECTIONS

Page 37: 1 app 2 developers 3 servers

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

Page 38: 1 app 2 developers 3 servers

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","")

Page 39: 1 app 2 developers 3 servers

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“ [email protected] height=“500“ width=“100%">

<Require feature="dynamic-height" />

</ModulePrefs>

<Content href="/3ServerDemo" type="url" view="canvas" /></Module>

Page 40: 1 app 2 developers 3 servers

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>

Page 41: 1 app 2 developers 3 servers

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

Page 42: 1 app 2 developers 3 servers

DOMINO SETUP

Page 43: 1 app 2 developers 3 servers

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

Page 44: 1 app 2 developers 3 servers

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

Page 45: 1 app 2 developers 3 servers

Domino: Setup

Lets do Method 1

In Eclipse click “New” “Plug-in Project”

Page 46: 1 app 2 developers 3 servers

Domino: Setup In Eclipse click “New” “Plug-in Project”

Select “Equinox” as your framework

Generate an Activator

Page 47: 1 app 2 developers 3 servers

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

Page 48: 1 app 2 developers 3 servers

Domino: Setup - Update

Now Import the Notes.jar

– File Import

– Select the file system and get the Notes.jar file from the extdirectory

Page 49: 1 app 2 developers 3 servers

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

Page 50: 1 app 2 developers 3 servers

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

Page 51: 1 app 2 developers 3 servers

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

Page 52: 1 app 2 developers 3 servers

MULTI AUTHENTICATION

Page 53: 1 app 2 developers 3 servers

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.

Page 54: 1 app 2 developers 3 servers

Multi Authentication

Enterprise applications now often compare poorly against consumer websites which take multiple forms of authentication.

Page 55: 1 app 2 developers 3 servers

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)

}

Page 56: 1 app 2 developers 3 servers

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.

Page 57: 1 app 2 developers 3 servers

DATA ABSTRACTION

Page 58: 1 app 2 developers 3 servers

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.

Page 59: 1 app 2 developers 3 servers

Data Abstraction

Create OrderInternal Order

Object

Reference No

Status

Address

Items

Etc..

DB2 Order Table

MongoDbCollection

NSFDatabase

Create DB2 Order

Create MongoDb

Order

Create NSF Order

Page 60: 1 app 2 developers 3 servers

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

Page 61: 1 app 2 developers 3 servers

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)

Page 62: 1 app 2 developers 3 servers

SUMMARY

Page 63: 1 app 2 developers 3 servers

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.

Page 64: 1 app 2 developers 3 servers

QUESTIONS?

Page 65: 1 app 2 developers 3 servers

René Winkelmeyer Online

Company http://www.midpoints.de

– IBM Advanced Business Partner

Blog http://blog.winkelmeyer.com

Twitter @muenzpraeger

Skype muenzpraeger

LinkedIn https://www.linkedin.com/in/muenzpraeger

Mail [email protected] [email protected]

Slide Share http://www.slideshare.net/muenzpraeger

Page 66: 1 app 2 developers 3 servers

Mark Myers Online

Company http://www.londc.com

– Our Latest product http://www.LDCVia.com

Blog http://www.stickfight.co.uk

Twitter @stickfight

Skype stickfight

LinkedIn https://uk.linkedin.com/in/stickfight/

Mail [email protected] [email protected]

Page 67: 1 app 2 developers 3 servers

Notices and Disclaimers

Copyright © 2015 by International Business Machines Corporation (IBM). No part of this document may be reproduced or transmitted in any form without written permission from IBM.

U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM.

Information in these presentations (including information relating to products that have not yet been announced by IBM) has been reviewed for accuracy as of the date of initial publication and could include

unintentional technical or typographical errors. IBM shall have no responsibility to update this information. THIS DOCUMENT IS DISTRIBUTED "AS IS" WITHOUT ANY WARRANTY, EITHER EXPRESS OR IMPLIED.

IN NO EVENT SHALL IBM BE LIABLE FOR ANY DAMAGE ARISING FROM THE USE OF THIS INFORMATION, INCLUDING BUT NOT LIMITED TO, LOSS OF DATA, BUSINESS INTERRUPTION, LOSS OF

PROFIT OR LOSS OF OPPORTUNITY. IBM products and services are warranted according to the terms and conditions of the agreements under which they are provided.

Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without notice.

Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are presented as illustrations of how those customers have used IBM products and the results

they may have achieved. Actual performance, cost, savings or other results in other operating environments may vary.

References in this document to IBM products, programs, or services does not imply that IBM intends to make such products, programs or services available in all countries in which IBM operates or does business.

Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not necessarily reflect the views of IBM. All materials and discussions are provided for informational

purposes only, and are neither intended to, nor shall constitute legal or other guidance or advice to any individual participant or their specific situation.

It is the customer’s responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal counsel as to the identification and interpretation of any relevant laws and regulatory

requirements that may affect the customer’s business and any actions the customer may need to take to comply with such laws. IBM does not provide legal advice or represent or warrant that its services or products

will ensure that the customer is in compliance with any law.

Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products in connection with

this publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers

of those products. IBM does not warrant the quality of any third-party products, or the ability of any such third-party products to interoperate with IBM’s products. IBM EXPRESSLY DISCLAIMS ALL WARRANTIES,

EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

The provision of the information contained herein is not intended to, and does not, grant any right or license under any IBM patents, copyrights, trademarks or other intellectual property right.

IBM, the IBM logo, ibm.com, BrassRing®, Connections™, Domino®, Global Business Services®, Global Technology Services®, SmartCloud®, Social Business®, Kenexa®, Notes®, PartnerWorld®, Prove It!®,

PureSystems®, Sametime®, Verse™, Watson™, WebSphere®, Worklight®, are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide. Other product and service

names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.