Ar*@!+$es to this. getting IBM connections to do what you want
1. ICON UK 2013
"Ar*@!+$es to this"
getting connections to do what you want
Presenter: Mark Myers
Company: London Devloper Co-op
UKLUG 2012 – Cardiff, Wales
September 2012
2. Who am I? – Mark Myers
•
A Member of the London Developer Co-op
(londc.com) A group of UK based developers
•
•
•
•
•
•
•
•
Ben Poole
Julian Woodward
Mark Myers (me)
Robin Willis
Matt White
Developer from a support background
12+ years on Domino, 15+ years in IT
Speaker at 3x Lotuspheres, 4x UKLUGs, 1x ILUG,
1x BLUG
UKLUG 2012 – Cardiff, Wales
3. Why this presentation and why that
title?
• IBM have given us a new platform. And
with it a new framework.
• It still has a Beta feel about it,
• Due to its constructions is very much a
patchwork with some areas working
inconsistently and varying wildly
between versions
UKLUG 2012 – Cardiff, Wales
4. Fair Enough but Still, why that title?
• Support are using a “hot brick” tactic on
areas when you a forced to use
undocumented features e.g.
dojo.i18n.getLocalization
• Connections is designed for a certain
use case and just like Domino before it
clients are not sticking to it but you still
need to deliver on their needs.
We can hack domino to do what ever we want. Time
to do the same with connections
UKLUG 2012 – Cardiff, Wales
5. So what are we dealing with?
What is IBM Connections from a Developers point of view?
UKLUG 2012 – Cardiff, Wales
6. So what are we dealing with?
• An IBM Websphere server
• With N number of ‘normal’ apps on it
• Glued to a DB2 server (normally)
No need to get excited
UKLUG 2012 – Cardiff, Wales
8. You can find out which URL’s match to
which applications
You would of course never use a Java Decompiler such as the one found
at http://jd.benow.ca/ to workout how these apps actually work
UKLUG 2012 – Cardiff, Wales
9. Loads of JDBC connections
UKLUG 2012 – Cardiff, Wales
10. I break customisation into 3 levels
• By GUI
• By XML (not done in this presentation)
• By Native app
Lets do this one
UKLUG 2012 – Cardiff, Wales
11. Tools (Your IDE)
• Rational Application Developer for
WebSphere Software (NEVER EVER!!)
• http://www03.ibm.com/software/products/us/en/
application/
• Myeclipse Blue
• http://www.myeclipseide.com/blue/
UKLUG 2012 – Cardiff, Wales
12. Native Websphere App time!!
• When all else fails this option will let you do
ANYTHING you want.
• A Necessity for Connections environments with no
Domino servers
• Other than a few IBM quirks, the following is all
standard java apps stuff, good to know and very very
reusable
UKLUG 2012 – Cardiff, Wales
13. What are WAR and EAR files
• A .War file (Web application ARchive) is a file used to
distribute a collection of JavaServer Pages, Java
Servlets, Java classes, XML files, tag libraries, static
Web pages (HTML and related files) and other
resources that together constitute a Web application.
• An .Ear (Enterprise ARchive) is Basically a normal
War file wrapped in a configuration wrapper.
• On the Ear file features remember you are on a
shared server and you can not make any
assumptions as to what is happening
UKLUG 2012 – Cardiff, Wales
14. Making a Native Connections App
In MyEclipse/RAD do “File”
“New” Web Project
Easiest way of ensuring
compatibility is to select a
matching Runtime
Just Accept defaults
UKLUG 2012 – Cardiff, Wales
15. Making a Native Connections App
In MyEclipse/RAD do “File”
“New” Enterprise
Application Project
UKLUG 2012 – Cardiff, Wales
16. Making a Native Connections App
Select the App(s) you
want to be packaged in
this Ear
Selecting this means that
unless you wish to
customize the deployment
you are done
UKLUG 2012 – Cardiff, Wales
17. Making a Native Connections App
This gives you the
following 2 project
structures
UKLUG 2012 – Cardiff, Wales
18. Making a Native Connections App
Select your EAR file project and do “File” “Export”
UKLUG 2012 – Cardiff, Wales
19. The Questions Domino Developers ask
when starting Native Java Apps
• How do I connect to a database?
• Where is my “when Opened in a browser”?
• Agents!, I need them! Where are they?
UKLUG 2012 – Cardiff, Wales
20. The Great Database Chase
• When we moved from Domino to Connections we
went from the easy going world of NOSQL and
constantly being in a database context to Relational
databases and defining our own contexts (most likely
DB2)
• There are lots of different ways of linking your
applications to databases (in Java)
• Hibernate
• JPA
• EJB3
• I'm going to Use JPA (Java Persistence API) as I find
it the best and most easy-going
• http://en.wikipedia.org/wiki/Java_Persistence_API
UKLUG 2012 – Cardiff, Wales
21. Why Use all this? Why not read/write direct
using SQL?
• Eliminates all of the 'hand' mapping in Java from a
SQL ResultSet to a Java Object greatly reducing the
amount of mapping work.
• Avoids low level JDBC and SQL code. You just deal
with Java Classes
• Provides high end performance features such as
caching and sophisticated database and query
optimizations.
There are lots of fighting over if you should use a ORM
(Object-relational mapping) framework such as JPA,
but frankly, its quick, reliable and does not give you
grief
UKLUG 2012 – Cardiff, Wales
22. The Great Database Chase
JDBC Mapped
to
Persistence unit
In
Persistence.xml
JDBC config
on Server
Entity
Manager used
code to do
stuff
Entity
Manager
Calls Entity
Manaager
Persistence
Unit used by
Entity
Manager
helper
UKLUG 2012 – Cardiff, Wales
23. JDBC connections are setup on the WAS
server
This actually provides the
link to the database and
you don’t need to deal
with Authentication
UKLUG 2012 – Cardiff, Wales
24. Setting up a WAS db2 connection
Open up the
WAS admin
console, and
select “JDBS
Providers”
UKLUG 2012 – Cardiff, Wales
25. Setting up a WAS db2 connection
Make sure
“db2jcc.jar”
“db2jcc_license
_cu.jar”
Are on the
server, they
should be if
Connections is
on there
UKLUG 2012 – Cardiff, Wales
26. Setting up a WAS db2 connection
You can Check
the location in
“Websphere
Variables”
UKLUG 2012 – Cardiff, Wales
27. Setting up a WAS db2 connection
Create a Data source and link to the JDBC Provider
UKLUG 2012 – Cardiff, Wales
28. Setting up a WAS db2 connection
Create a Data
source and link to
the JDBC Provider
You will also want to
select a
authentication alias
UKLUG 2012 – Cardiff, Wales
29. Setting up a WAS db2 connection
This will mean
that the
application does
not have to
contain any
authentication
details
(meaning the
same app can
be deployed to
dev and live)
UKLUG 2012 – Cardiff, Wales
30. Persistence.xml
When dealing with websphere
the transaction-type will
always be
“RESOURCE_LOCAL”
Now we can link our application to the database
definition on the server
UKLUG 2012 – Cardiff, Wales
34. Don’t worry this is all done with wizards
UKLUG 2012 – Cardiff, Wales
35. Lets have a Look at the Datbase
UKLUG 2012 – Cardiff, Wales
36. Where is my “when Opened in a browser”?
The Web.xml is the core of your application configuration, just
about everything is started from here
UKLUG 2012 – Cardiff, Wales
37. Agents!, I need them! Where are they?
• There are lots of different ways of providing this
feature, and lots of pro and cons for each way.
• I am going to show you Quartz from
http://quartz-scheduler.org/
UKLUG 2012 – Cardiff, Wales
38. Setting up a Scheduled Job
Down load the Quartz package from the website un zip it and
copy the Jar files in the /webroot/WEB-INF/lib
UKLUG 2012 – Cardiff, Wales
39. Setting up a Scheduled Job
In the Properties of the Project, in the Java Build Path, add
the /webRoot/Web-INF/lib as a “class folder”
UKLUG 2012 – Cardiff, Wales
40. Setting up a Scheduled Job
In your Web.xml add a new servlet, with the value
<load-on-startup> = 1
UKLUG 2012 – Cardiff, Wales
41. Setting up a Scheduled Job
Setup a new Class that the servlet will call
UKLUG 2012 – Cardiff, Wales
42. Setting up a Scheduled Job
In the “init” method for the new servlet you have made, add one
of the many varieties of Quartz Scheduler see http://quartzscheduler.org/documentation
UKLUG 2012 – Cardiff, Wales
43. Further Reading on Native Apps
As you are now just writing Native Java Apps + IBM
quirks the number of available libraries and tools you
can use is mind blowing
Some Recommended areas to read up on:
•Jersey: The easiest way to do REST services in pure
java. http://jersey.java.net/
•Annotations
http://javapapers.com/core-java/java-annotations/
•Abdera: Best Atom Service reader and generator http
://abdera.apache.org/
UKLUG 2012 – Cardiff, Wales
46. Tools
• DEV HTTP CLIENT
• https://plus.google.com/1040257982
50320128549/posts
• FireBug
• https://getfirebug.com/
UKLUG 2012 – Cardiff, Wales
47. Example: Java Agent Atom Feed
A few different Java feed parsing
libraries to choose from:
• ROME – http://rometools.org
• Apache Abdera –
http://abdera.apache.org
• Apache Wink –
http://incubator.apache.org/wink
All require several additional libraries
• Apache Commons libraries
• Java StAX support
• Etc.
Handles HTTP connections as well as
parsing
Authentication too
UKLUG 2012 – Cardiff, Wales
78. And to just round up:
the Activity Stream
Its Just another Atom feed:
https://xxx.com/connections/opensocial/ba
sic/rest/activitystreams/@me/@all
Excellent example:
http://www.lbenitez.com/2012/05/how-topost-events-into-opensocial.html
UKLUG 2012 – Cardiff, Wales
79. The Activity Stream
{
"generator": {
"image": { "url": "/homepage/nav/common/images/iconProfiles16.png"},
"id": "demoapp",
"displayName": "Demo Application",
"url": "http://www.ibm.com/"
},
"actor": { "id": "@me" },
"verb": "post",
"title": “Example Title",
"content": " You have created a new Activity Stream.",
"updated": "2013-05-08T12:00:00.000Z",
"object": {
"summary": “rhubarb rhubarb",
"objectType": "note",
"id": “rr13",
"displayName": " rhubarb rhubarb ",
"url": "http:// rhubarb.com/rhubarb.xml",
},
}
UKLUG 2012 – Cardiff, Wales