Ar*@!+$es to this. getting IBM connections to do what you want

1,961 views
1,861 views

Published on

Presentation at UKICON 2013 on how to really get IBM connections to do what you want

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,961
On SlideShare
0
From Embeds
0
Number of Embeds
237
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Ar*@!+$es to this. getting IBM connections to do what you want

  1. 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. 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. 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. 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. 5. So what are we dealing with? What is IBM Connections from a Developers point of view? UKLUG 2012 – Cardiff, Wales
  6. 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
  7. 7. A Websphere server with Connections 4.0 installed (amongst other things) UKLUG 2012 – Cardiff, Wales
  8. 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. 9. Loads of JDBC connections UKLUG 2012 – Cardiff, Wales
  10. 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. 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. 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. 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. 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. 15. Making a Native Connections App In MyEclipse/RAD do “File”  “New”  Enterprise Application Project UKLUG 2012 – Cardiff, Wales
  16. 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. 17. Making a Native Connections App This gives you the following 2 project structures UKLUG 2012 – Cardiff, Wales
  18. 18. Making a Native Connections App Select your EAR file project and do “File”  “Export” UKLUG 2012 – Cardiff, Wales
  19. 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. 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. 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. 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. 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. 24. Setting up a WAS db2 connection Open up the WAS admin console, and select “JDBS Providers” UKLUG 2012 – Cardiff, Wales
  25. 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. 26. Setting up a WAS db2 connection You can Check the location in “Websphere Variables” UKLUG 2012 – Cardiff, Wales
  27. 27. Setting up a WAS db2 connection Create a Data source and link to the JDBC Provider UKLUG 2012 – Cardiff, Wales
  28. 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. 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. 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
  31. 31. EntityManagerHelper.java UKLUG 2012 – Cardiff, Wales
  32. 32. Table/Class Data Access Object UKLUG 2012 – Cardiff, Wales
  33. 33. Finally use the data in code UKLUG 2012 – Cardiff, Wales
  34. 34. Don’t worry this is all done with wizards UKLUG 2012 – Cardiff, Wales
  35. 35. Lets have a Look at the Datbase UKLUG 2012 – Cardiff, Wales
  36. 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. 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. 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. 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. 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. 41. Setting up a Scheduled Job Setup a new Class that the servlet will call UKLUG 2012 – Cardiff, Wales
  42. 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. 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
  44. 44. Questions? ? If we have time then we can keep going! UKLUG 2012 – Cardiff, Wales
  45. 45. None Native integration (Domino) UKLUG 2012 – Cardiff, Wales
  46. 46. Tools • DEV HTTP CLIENT • https://plus.google.com/1040257982 50320128549/posts • FireBug • https://getfirebug.com/ UKLUG 2012 – Cardiff, Wales
  47. 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
  48. 48. Example: Java Agent Get Atom Feed © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  49. 49. Example: Java Agent Submit Back to Atom Feed  Most Atom services (particularly IBM) give examples of what XML they want rather than examples of the code you should use, so we will do the same  This is a IBM Connections Blog entry in raw XML: <?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <author><name>I Am Funny</name></author> <title type="text">Great Duck Joke</title> <content type="text">Q: What has webbed feet and fangs? A: Count Duckula</content> </entry> © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  50. 50. Example: Java Agent Submit Back to Atom Feed An amazingly useful line when you are debugging or testing as it outputs the XML so you can check it against what you should be sending © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  51. 51. Example: Java Agent Submit Back to Atom Feed Getting this URL is often the hardest part of dealing with Atom © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  52. 52. Example: Useful Extra Lines Add “registerTrustManager” and you can connect to SSL Ports Nice simple login, you just need the user name, password and the root domain you are logging on to © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  53. 53. Domino Integrating with IBM Connections Before we start we need to get a database ready to call Java from XPages Move to Package Explorer © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  54. 54. Domino Integrating with IBM Connections In The WEB-INF directory Right click and create a new folder © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  55. 55. Domino Integrating with IBM Connections Call it “src” in lower case © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  56. 56. Domino Integrating with IBM Connections Next add this folder to the projects build path Right click on the root of the project and select “Properties” © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  57. 57. Domino Integrating with IBM Connections On the “Source” tab click “Add folder” and add the folder you have created © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  58. 58. Domino Integrating with IBM Connections You will see the Folder has moved Right click and select “New” → “Other” Then Select “Java” → “Class” © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  59. 59. Domino Integrating with IBM Connections Create the new Java Class © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  60. 60. Domino Integrating with IBM Connections OK, Java class created, lets get it some libraries © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  61. 61. Domino Integrating with IBM Connections If you are not allowed to use the EXT directory on the server, the you will need to create a new “lib” folder © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  62. 62. Domino Integrating with IBM Connections © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  63. 63. Domino Integrating with IBM Connections Update (or ask your administrator to) the java.policy file on your server to contain the following grant { permission java.lang.RuntimePermission "getClassLoader"; }; © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  64. 64. Domino Integrating with IBM Connections Now we will add the Atom client code function You need to pass the session into this function as it can’t get its own If you need to you can login here (as described previously) © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  65. 65. Domino Integrating with IBM Connections Create a New Script Library © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  66. 66. Domino Integrating with IBM Connections Set it as a Normal “Server JavaScript” Library © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  67. 67. Domino Integrating with IBM Connections Create a SSJS function to call your Java and pass the results back Pass the “sessionAsSigner” here to give yourself administrator rights © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  68. 68. Domino Integrating with IBM Connections – Pulling it together Create a Custom Control © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  69. 69. Domino Integrating with IBM Connections Give it a Name © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  70. 70. Domino Integrating with IBM Connections Now you can add a repeat control that calls the SSJS function, which in turn calls the Java The Rest of the surrounding boring code is in the demonstration db © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  71. 71. Domino Integrating with IBM Connections – Pulling it together Create a New Xpage Library © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  72. 72. Domino Integrating with IBM Connections – Pulling it together Add the duckstates_cc custom control © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  73. 73. Domino Integrating with IBM Connections – Pulling it together © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  74. 74. Domino Integrating with IBM Connections Now that you have an XPage, you need to present it to Connections as a Open Social widget the easiest way of doing this is with a simple domino page. © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  75. 75. Domino Integrating with IBM Connections Features like “dynamicheight” are harder to get working using this method (rather than a embedding the widget in connections) but if you have a static sized widget it is the simplest and quickest © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  76. 76. Integrating with IBM Connections And add it to your Connections installation © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  77. 77. Integrating with IBM Connections © 2013 IBM Corporation UKLUG 2012 – Cardiff, Wales
  78. 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. 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
  80. 80. Working Post Example (for you to copy) The Activity Stream UKLUG 2012 – Cardiff, Wales
  81. 81. Questions? ? How To Contact Me: Mark Myers Email: Mark@londc.com | Twitter: @stickfight | Skype: Stickfight | Blog: stickfight.co.uk UKLUG 2012 – Cardiff, Wales

×