Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Plug yourself in and your app will never be the same (2 hour edition)


Published on

Eclipse plugin presentation given at the Norwegian Lotus User Group on 11 May 2011.

Published in: Technology, Business
  • D0WNL0AD FULL ▶ ▶ ▶ ▶ ◀ ◀ ◀ ◀
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Plug yourself in and your app will never be the same (2 hour edition)

  1. 1. LSBG Vårseminar, maj 2011 Larvik, Norge Plug yourself in and your applications will never be the same! (An introduction to plugin development for Lotus Notes, Domino and Sametime)
  2. 2. About me <ul><li>Developer: Notes / Domino / Sametime / Java / DB2 / WebSphere / web / plug-ins
  3. 3. Design Partner for Domino NEXT and Lotus Connections 3.0
  4. 4. Active blogger:
  5. 5. Speaker at Lotusphere
  6. 6. Articles for THE VIEW
  7. 7. E-mail:
  8. 8. .com/lekkim </li></ul>
  9. 9. What I do! <ul><li>Well plugins of course... But ”plugins” are a many-headed beast! </li><ul><li>It's not just ”stuff” for the Notes sidebar
  10. 10. It's about extending the UI in Notes, Sametime and Symphony
  11. 11. It's about delivering a UI capable of doing stuff you cannot do in ”traditional” Notes
  12. 12. It's about developing custom components for the XPages Extensibility Library
  13. 13. It's about DOTS (previously JAVADDIN) and OSGi on the Lotus Domino Server </li></ul></ul>
  14. 14. Why I do it! <ul><li>Plugin development is often about integration </li><ul><li>You often build extensions to existing applications to add functionality
  15. 15. Eclipse and therefore Expeditor, Notes, Symphony, and Sametime, are built to allow for extensibility </li></ul><li>Plugin development has several advantages </li><ul><li>Java </li><ul><li>Mature
  16. 16. Well Adopted
  17. 17. Multi-platform
  18. 18. Libraries </li></ul><li>Eclipse Community </li><ul><li>Web Services
  19. 19. Web Applications
  20. 20. Database Integrations
  21. 21. etc.... </li></ul></ul></ul>
  22. 22. What's possible with plugins Torsdag, sal 1, 11:20-12:00 - Ta samarbeid og planlegging til neste nivå
  23. 23. RedWiki for plugin development <ul><li>Lotus Notes and Domino Application Development wiki / IBM Redbook Publications </li><ul><li>
  24. 24. ...or use the link >> </li></ul></ul>
  25. 25. What I'm going to build (if time permits) <ul><li>Sidebar panel containing </li><ul><li>A list box
  26. 26. Three buttons at the bottom </li><ul><li>One button reads from a web service
  27. 27. One button reads contacts from names.nsf
  28. 28. One button creates a new email </li><ul><li>Reads recipient from list
  29. 29. Create document
  30. 30. Set subject
  31. 31. Add data from web service call to body </li></ul></ul></ul><li>Create a feature for the plugin
  32. 32. Create an update site with the feature
  33. 33. Create a widget for the feature from the update site </li></ul>
  34. 34. Agenda <ul><li>About Eclipse and Lotus Expeditor Toolkit
  35. 35. Installing Lotus Expeditor Toolkit
  36. 36. Plugin Development Basics
  37. 37. Building UI's with SWT and JFace
  38. 38. Jobs, Jobs, Jobs
  39. 39. Logging
  40. 40. APIs
  41. 41. Debugging
  42. 42. Deployment
  43. 43. Resources / Q&A </li></ul>
  44. 44. Eclipse architecture Workbench JFace SWT Core Extension Point Framework Service Framework Rich Client Platform Plug-in Plug-in Extension Pt. Plug-in Extension Point Extension Point Extension Point A software component in Eclipse Extension Point declares contract to extend plug-in functionality Extension code extends this functionality RCP allows you to build GUI apps on multiple OS SWT provides uniform UI API across multiple OS that calls OS UI API for native look and feel JFace provides components to make it easier to write a GUI e.g. wizards, preference pages, actions, dialogs Workbench is desktop UI and customizable Service Framework supports registration and lifecycle management of plug-ins
  45. 45. IBM Lotus Clients – built on Eclipse Sametime Expeditor Apps and Plug-ins (ISV + Customer) Notes Symphony Industry knowledge and experience ecosystem of partners open and extensible collaborative services Integrated applications Portal Browser Desktop Mobile Multiplatform support Scalability Security
  46. 46. Eclipse workbench
  47. 47. Notes workbench s
  48. 48. Lotus Expeditor (XPD) Toolkit <ul><li>An integrated set of tools to develop, test, and deploy applications built on top of Expeditor </li><ul><li>Supports Expeditor, Sametime, Notes and Symphony
  49. 49. FREE! No charge to use the Expeditor toolkit
  50. 50. Supported on Windows and Linux operating systems </li></ul><li>Benefits Of Using The Toolkit </li><ul><li>Easily configure your development environment to develop for the platforms above </li><ul><li>Takes ~ 1 minute to configure your environment </li><ul><li>Set your target environment
  51. 51. Point to the target locations on your machine </li></ul></ul><li>Provides a new launcher to launch products built on top of Expeditor </li><ul><li>Create a new launch configuration to launch the application from Eclipse </li></ul><li>Provides numerous samples to get your started developing for Expeditor based products </li></ul></ul>
  52. 52. Installing XPD Toolkit (1) <ul><li>Download the XPD Toolkit </li><ul><li>
  53. 53. Unzip </li></ul><li>In Eclipse 3.4(.2) </li><ul><li>Help -> Software Updates... </li></ul></ul>
  54. 54. Installing XPD Toolkit (2) <ul><li>Click New Local Site...
  55. 55. Browse to unziped update site
  56. 56. Select OK </li></ul>
  57. 57. Installing XPD Toolkit (3) <ul><li>Select The XPD Toolkit
  58. 58. Click Install... </li></ul>
  59. 59. Installing XPD Toolkit (4) <ul><li>Agree to the license agreement
  60. 60. Install all features
  61. 61. Restart </li></ul>
  62. 62. Installing XPD Toolkit (5) <ul><li>Start IDE
  63. 63. Select Test Environment </li><ul><li>Notes, Sametime, Symphony, XPD </li></ul><li>Specify Target Location </li><ul><li>Point to target runtime
  64. 64. <install>/framework/rcp/eclipse </li></ul><li>Click OK
  65. 65. Run -> Run Configuration
  66. 66. Double Click Client Services
  67. 67. Give The Configuration A Name
  68. 68. Select Run </li></ul>
  69. 69. Installing XPD Toolkit – Demo <ul><li>Start IDE
  70. 70. Select Test Environment </li><ul><li>Symphony, Sametime, Notes , Expeditor </li></ul><li>Specify Target Location </li><ul><li>Point to target runtime
  71. 71. <install>/framework/rcp/eclipse </li></ul><li>Click OK
  72. 72. Run -> Run Configuration
  73. 73. Double Click Client Services
  74. 74. Give The Configuration A Name
  75. 75. Select Run </li></ul>
  76. 76. What are plugins? <ul><li>Plugins are the building blocks of Eclipse based applications </li><ul><li>At their core a plugin is some code plus some declarations (extension points)
  77. 77. By themselves plugins may not do anything, but when you start combining plugins you can build very powerful applications
  78. 78. Examples: Eclipse, Notes, Sametime, Symphony </li></ul></ul>Application Plugin
  79. 79. Anatomy of a plugin <ul><li>Java code (optional)
  80. 80. </li><ul><li>Basic properties of a plugin
  81. 81. Specifies dependencies this plugin has </li></ul><li>Plugin.xml </li><ul><li>Extension points the plugin uses / defines </li></ul><li> </li><ul><li>Manages the build configuration of the plugin </li></ul><li>Resources (optional) </li><ul><li>Jars the plugin may need
  82. 82. Files used for translation
  83. 83. Images
  84. 84. etc.... </li></ul></ul>
  85. 85. Demo: Creating a plugin project <ul><li>File -> New -> Project -> Plugin Development
  86. 86. Select Plug-in Project </li></ul>
  87. 87. Extension Points <ul><li>Extension points make plugins “pluggable” </li><ul><li>Plugins define extension points for other plugins to use </li><ul><li>Examples: sidebar, toolbar buttons, right click menus... </li></ul><li>Extension points allow the platform to be more performant
  88. 88. Eclipse has a nice editor for adding and defining extension points </li></ul><li>How do I know what extension points are available? </li><ul><li> and the Expeditor wiki are your friends </li></ul></ul>Plugin Using Extension Point Extension Point Definition
  89. 89. Key Extension Points <ul><li>org.eclipse.ui.views </li><ul><li>Registers a view part with the platform
  90. 90. View parts can be used inside perspectives or in the sidebar </li></ul><li> </li><ul><li>An Expeditor extension point
  91. 91. Used to add a view part to the sidebar </li></ul><li>org.eclipse.ui.actionSets </li><ul><li>Used to add top level toolbars and menus </li></ul><li>org.eclipse.ui.menus </li><ul><li>Used to add context menus </li></ul><li>org.eclipse.ui.preferencePages </li><ul><li>Used to add preference pages to the preferences </li></ul></ul>
  92. 92. The arcane art of building UI's
  93. 93. UI's are built using code <ul><li>UI's are </li><ul><li>built using Java code adding widgets (controls) to containes (composites)
  94. 94. custom drawn using Java code to listen for paint events </li></ul><li>In either case it isn't WYSIWYG :-( </li></ul>
  95. 95. Standard Widget Toolkit (SWT) <ul><li>Platform native look and feel …
  96. 96. Protection from OS Level Changes
  97. 97. Very responsive
  98. 98. Resulting UI looks like native platform applications </li></ul>
  99. 99. JFace <ul><li>UI toolkit built on top of SWT without hiding it
  100. 100. Provides coarser grained components than SWT </li><ul><li>Dialogs
  101. 101. Image / Font Registries
  102. 102. Wizards
  103. 103. Viewers </li></ul></ul>
  104. 104. Meet WindowBuilder!
  105. 105. Demo: Create a sidebar plugin <ul><li>Add org.eclipse.ui.views extension point
  106. 106. Create view part class
  107. 107. Add extension point
  108. 108. Use WindowBuilder to create UI
  109. 109. Try It Out! </li></ul>
  110. 110. All The APIs You Need <ul><li>Do not reinvent the wheel!
  111. 111. Java and Eclipse contains a rich set of API's that you can use when developing plugins for Lotus clients
  112. 112. Knowing the API's available to you is crucial
  113. 113. We'll cover </li><ul><li>Jobs (threading)
  114. 114. Logging
  115. 115. Notes backend
  116. 116. Notes frontend </li></ul></ul>
  117. 117. Threading lightly <ul><li>A thread is an abstraction in computers to allow programs to perform multiple operations simultaneously </li><ul><li>Avoid tying up the program with background operations </li></ul><li>Two ways to call other code </li><ul><li>Synchronously == blocking </li><ul><li>Blocks current code until call is done and then returns to continue processing
  118. 118. Like you're used to from LotusScript </li></ul><li>Asynchronously == non-blocking </li><ul><li>The calling code continues to run – you now have two pieces of code running
  119. 119. To tell the caller we're done we use callbacks or listeners
  120. 120. Harder to grasp
  121. 121. Used in AJAX – you request data in the background and once the data has been fetched you are told </li></ul></ul></ul>
  122. 122. Jobs, jobs, jobs - lets vote for jobs! <ul><li>Eclipse Job Framework </li><ul><li>java.lang.Thread is way too low-level and error prone
  123. 123. Allows for easy background processing
  124. 124. Very simple to use
  125. 125. Allows scheduling of jobs (“run this code in 2 minutes”)
  126. 126. Allows weaving of jobs
  127. 127. Allows for listening to job status etc.
  128. 128. Standard UI for manipulating jobs </li></ul><li>Two types of Job </li><ul><li>Job – for background processing
  129. 129. UIJob – for user interface updates </li></ul><li>Both are abstract classes and normally used as anonymous inner classes </li></ul>
  130. 130. There can be only one <ul><li>Any Eclipse application only has ONE thread that may update the user interface
  131. 131. It's – surprise, surprise – called the “UI thread”
  132. 132. This means that </li><ul><li>Tying up the UI thread will render the entire client unresponsive
  133. 133. Attempts to access the UI (i.e. set the text of a label) outside the UI thread will fail with an exception
  134. 134. You need a way to “do stuff” in the UI thread </li></ul><li>To do stuff in the UI thread you use an UIJob from the Job API </li></ul>
  135. 135. Using Job in code public void fireOnTheEmpire(int initDelay, final String jediName) { // create recurring job to poll web service new Job(&quot;Poll the Force!&quot;) { protected IStatus run(IProgressMonitor monitor) { // invoke endpoint using input String srvc = “”; WSFacade facade = new WSFacade(srvc); String result =; // do something with the result ... // reschedule this job (in 5 mintues) this.schedule(5 * 60 * 1000); // return return Status.OK_STATUS; } }.schedule(initialDelay * 60 * 1000); } final
  136. 136. Using UIJob in code final List lstJedis = new List(parent, SWT.NONE); ... public void psssst(final String[] jedis) { // since we're called in a background process // use that UIJob we learned about to update the UI new UIJob(&quot;Load Jedis&quot;) { public IStatus runInUIThread(IProgressMonitor monitor) { // update UI for (String jedi : jedis) { lstJedis.add(jedi); } // return status return Status.OK_STATUS; } }.schedule(); }
  137. 137. Avoid Spinning Wheel of Death public void createPartControl(Composite parent) { final Label txt = new Label(parent, SWT.NONE); new UIJob(&quot;Indicate job starting&quot;) { public IStatus runInUIThread(IProgressMonitor monitor) { txt.setText(&quot;Turning star cruiser (&quot; + new Date() + &quot;)...&quot;); // do long running task == BAD!! try { Thread.sleep(5000); } catch (Exception e) {} txt.setText(&quot;Done turning star cruiser (&quot; + new Date() + &quot;)...&quot;); // reschedule and return this.schedule(5000); return Status.OK_STATUS; } }.schedule(5000); }
  138. 138. Weaving Jobs <ul><li>Most operations usually include a UI and a background component so you need to “weave jobs”
  139. 139. A typical operation from the user consists of 3 steps: </li></ul><ul><ul><li>Usually you start of with a UI call (button click i.e. button selection)
  140. 140. You perform some background operation (e.g. load data from a web service or similar)
  141. 141. You need to “call back” into the UI and update or inform </li></ul></ul><ul><li>We call this “to weave job”
  142. 142. We do it by nesting Job instances </li></ul>
  143. 143. Do it right! public void widgetSelected(SelectionEvent event) { list.add(&quot;Starting to run code (&quot; + new Date() + &quot;)...&quot;, 0); new Job(&quot;Long running job&quot;) { protected IStatus run(IProgressMonitor monitor) { downloadEntireGoogleSearchIndex(); // call back into UI to tell user we're done new UIJob(&quot;Update UI&quot;) { public IStatus runInUIThread(IProgressMonitor monitor) { list.add(&quot;Done running code (&quot; + new Date() + &quot;)...&quot;, 0); return Status.OK_STATUS; } }.schedule(); return Status.OK_STATUS; } }.schedule(); }
  144. 144. Demo: Using jobs in your code <ul><li>Adding a button for background operation
  145. 145. Add selection listener
  146. 146. Load data from the web
  147. 147. Once call is done update the UI </li></ul>
  148. 148. Logging <ul><li>System.out.println is NEVER the solution! </li><ul><li>Seems easy at first but 99% of the time it's easier to just use logging from the beginning </li></ul><li>Lotus Expeditor / Notes comes with many supported logging mechanisms </li><ul><li>The one to use is java.util.logging as it's built-in and easy to use and configure </li></ul><li>Logging is done through the Logger class and at a specified Level </li><ul><li>Level (SEVERE, WARNING, INFO, FINE, FINER, FINEST, CONFIG)
  149. 149. Expensive logging may be guarded using isLoggable(Level) </li></ul><li>Loggers are hierarchically named and level is set hierarchically as well </li></ul>
  150. 150. Logging – Example package com.example.demo1; public class MainViewPart extends ViewPart { private static final Logger logger = Logger.getLogger(MainViewPart.class .getPackage().getName()); public MainViewPart() { try {;Main view part instantiated&quot;); String senateCount = this.countSenators(); if (logger.isLoggable(Level.FINEST)) { logger.finest(&quot;Found “ + senateCount + “ senators (&quot; + this + “)”); } } catch (Throwable t) { logger.severe(“There was a disturbance in the Force!”, t); } } }
  151. 151. Logging – getting at it <ul><li>Logging output goes to client log </li><ul><li>Help > Support > View Log/Trace </li></ul><li>Configured using </li><ul><li>OSGi console
  152. 152. Edit <Notes data>/workspace/.config/ and add <logger name>.level=<LEVEL> at the end </li><ul><li>com.lekkimworld.twitnotes2.level=FINEST </li></ul></ul></ul>
  153. 153. Demo: Adding logging to the code <ul><li>Add a logger to our view part
  154. 154. Log the current sunrise and sunset
  155. 155. Enable logging </li></ul>
  156. 156. Notes backend API <ul><li>You have access to the Notes Java API you know and love!
  157. 157. Basic usage is almost the same as you know and love
  158. 158. To get access to the classes you </li><ul><li>DO NOT import notes.jar as you normally do
  159. 159. DO depend on the plugin </li></ul><li>To access Notes data you </li><ul><li>DO NOT use NotesThread.sinitThread
  160. 160. DO use the Job API and the supplied NotesSessionJob </li></ul></ul>
  161. 161. Notes backend API in code new NotesSessionJob(&quot;Access Notes data&quot;) { public IStatus runInNotesThread(Session session, IProgressMonitor monitor) throws NotesException { // print username System.out.println(session.getDatabase(null, “names.nsf”).getTitle()); // return return Status.OK_STATUS; } }.schedule();
  162. 162. Notes frontend API <ul><li>Modeled pretty much like the LotusScript UI API </li><ul><li>NotesUIWorkspace, NotesUIView, NotesUIDocument, … </li></ul><li>Should run in the UI thread
  163. 163. Bridges a MAJOR gap in the Notes product as it gives us access to the Notes UI from Java
  164. 164. Been with us for a while </li><ul><li>Added in Notes 8.5 as beta
  165. 165. Supported from Notes 8.5.1
  166. 166. More functionality added in Notes 8.5.2 </li></ul><li>To use it add a dependency on
  167. 167. Example project available from (“Java UI API Exerciser”) </li></ul>
  168. 168. Notes frontend API (cont.) <ul><li>NotesUIWorkspace </li><ul><li>Entry point
  169. 169. Access to run an agent with context (access to LotusScript!) </li></ul><li>NotesUIView </li><ul><li>Most functionality added in Notes 8.5.2
  170. 170. Listen for selection events and view entries
  171. 171. Works for Java and traditional views </li></ul><li>NotesUIDocument </li><ul><li>You can work in the document on the glass
  172. 172. Access to backend document
  173. 173. Edit / Field / Modify listeners
  174. 174. Access to copy/paste, refresh, reload </li></ul><li>Data classes for easy access (i.e. NotesViewData) </li></ul>
  175. 175. Demo: Use the Notes APIs <ul><li>Use NotesSessionJob to access the user's name.nsf file
  176. 176. Place the email addresses of the user's contacts in the list box
  177. 177. Use the composeDocument API to compose an email to selected contact with data </li></ul>
  178. 178. Final word on APIs <ul><li>Accounts </li><ul><li>Secure storage for credentials, Automatic authentication for HTTP requests </li></ul><li>Lotus Sametime </li><ul><li>Awareness / realtime collaboration </li></ul><li>Search </li><ul><li>Search other applications from the search center </li></ul><li>Domino Designer </li><ul><li>Extend Domino Designer with custom actions </li></ul><li>Composite Applications </li><ul><li>Create components for using Eclipse technology and listen for properties and expose actions </li></ul><li>XPages Extensibility Library </li><ul><li>Add custom widgets for XPages </li></ul><li>LiveText / Toolbox (LiveText / Widgets API's is targeted to be publicly supported from 8.5.3) </li><ul><li>Inject recognizers based on business rules </li></ul></ul>
  179. 179. Final word on APIs – I promise!! <ul><li>Like with Lotus Notes there a multitude of API's available to you for </li><ul><li>Selection, Jobs, Actions / menus, Drag'n'drop, Custom drawing, Charting
  180. 180. … </li></ul><li>Explore and remember to search for “Eclipse” and not “Lotus Notes” as it will yield far more results </li></ul>
  181. 181. Demo: Debugging basics <ul><li>Launching Notes from Eclipse in debug mode
  182. 182. Set breakpoints
  183. 183. Inspecting variables
  184. 184. The console, logging levels </li></ul>
  185. 185. Deploying your fantastic work <ul><li>Deployment is done by </li></ul><ul><ul><li>Packaging your plugin(s) in a feature
  186. 186. Creating an update site to hold the feature
  187. 187. Installing the feature into the clients either manually or using a widget descriptor </li></ul></ul>Feature Plug-in Plug-in . . . Feature Plug-in Plug-in . . . Update Site . . .
  188. 188. Demo: Wrapping it all up <ul><li>Create a feature project
  189. 189. Create an update site
  190. 190. Create an update site NSF
  191. 191. Add our feature to the update site NSF
  192. 192. Create a widget for our feature
  193. 193. Add it to a widget catalog
  194. 194. Watch a video at: </li></ul>
  195. 195. DOTS (used to be JAVADDIN)
  196. 196. XPages Extensibility Library ” A new project has been created which contains a simple sample for how to to develop a 'native' XPages control via the Java extensibility API. This control can be deployed globally as an OSGi bundle/plugin to Lotus Domino and Lotus Notes/Domino Designer and then used in all NSFs without having to put the code in all NSFs redundantely. The new control shows up in the palette in Designer as other out of the box controls.”
  197. 197. Summary and resources <ul><li>RedWiki about plugin development >>
  198. 198. HIGHLY recommended article on the Job API >>
  199. 199. Eclipse articles >>
  200. 200. Eclipse WindowBuilder >> </li></ul>
  201. 201. Q&A <ul><li>But!
  202. 202. How do I?
  203. 203. Doesn't that mean?
  204. 204. Give it to me! :-) </li></ul>