from xpages hero to osgi guru: taking the scary out of building extension libraries (icon uk 2014)

50
Presenter: Paul Withers Company: Intec Systems Ltd Presenter: John Cooper Company: JCB ICON UK 2014 From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries

Upload: paul-withers

Post on 26-May-2015

540 views

Category:

Technology


7 download

DESCRIPTION

Session delivered at ICON UK September 2014 with John Cooper. Links to the resources are at the end of the slides.

TRANSCRIPT

Page 1: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

Presenter: Paul Withers Company: Intec Systems Ltd

Presenter: John Cooper

Company: JCB

ICON UK 2014 From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries

Page 2: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

2

Paul Withers

• XPages Developer since 2009

• IBM Champion

• Author of XPages Extension Library

• Developer XPages OpenLog Logger

• Co-Developer of OpenNTF Domino API

Page 3: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

3

John Cooper

Began developing XPages from 8.5.0

Developed many XPage applications using java beans and custom components so decide to create OSGI Plugin to be able to deploy once

New to blogging, contributed 1 project to Open NTF so far.

Page 4: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

4

Agenda

• Why

• Development and Debugging Environment

• XPages Starter Kit

• Structure and Deployment

Page 5: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

5

XPages Developer Roadmap

• 11 types of developer – Stephan Wissel

• Three types of developer – Niklas Heidloff

• Five tiers of developers – Greg Reeder

Extension Library development should be the goal of XPages developers

Page 6: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

6

Why?

• Build Once, Use Anywhere (virtually!)

• Easier to deploy new versions

• Deploy for junior developers

• Deploy third-party libraries

• Apache POI etc

• JDBC Drivers

• More easily avoid Java security exceptions

• Required for DOTS

Page 7: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

7

Examples

• XPages Extension Library

• IBM SBT

• XPages OpenLog Logger

• OpenNTF Domino API

• Bootstrap4Xpages

• XPage Debug Toolbar

• XPages Scaffolding

• XPages Toolkit

Page 8: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

8

JDBC Driver Plugin Wizard

• Enhancement to RDBMS part of Ext Lib

• Requires latest version of ExtLib

• Allows a plugin to be created from one dialog for a JDBC driver

• See 3:15 on video http://www.openntf.org/main.nsf/blog.xsp?permaLink=NHEF-9N7CKD

Page 9: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

9

Agenda

• Why

• Development and Debugging Environment

• XPages Starter Kit

• Structure and Deployment

Page 10: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

10

Development and Debugging Environment

• Eclipse

• XPages SDK

• Debug Plugin

• IBM Java Runtime

• Local Domino Server recommended

Page 11: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

11

Eclipse for RCP and RAP Developers

• Latest release is Luna

• Debug plugin does not support this?

• Can have multiple versions installed

Page 13: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

13

XPages SDK

• Gives XPages JREs and Target Platforms

• From 4:40 in video

• Point Preferences to Domino and Notes installs

• Ensure “Automatically create JRE” ticked

• Tick relevant entry in Java > Installed JREs

• Create and select entry under Plug-in Development > Target Platform

Page 14: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

14

Debug Plugin

• Allows you to point Domino server direct to projects in relevant workspace

• From 7:44 in video

• Point Preferences to Domino install

• Configure Domino server for Java debugging, as for Java development

• Run > Debug Configurations

• Create Debug Configuration

Page 15: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

15

OSGi Configuration

• Create new OSGi Framework configuration – tells Domino to use Eclipse workspace

• Set as Domino OSGi Framework

• Set auto-start to false

• Click Debug – creates pde.launch.ini

• Issue “res task http” command

• Obviously will cause problems on

networked server!

Page 16: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

16

New Plugins

• For new plugins

• Go to OSGi Framework configuration

• Select the new plugin

• Click Debug to update config

• Issue “res task http” command

• If plugin is changed

• Issue “res task http” command

Page 17: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

17

Java Runtime

• Not necessary for most development

• Needed to debug Extension Library

• See blog post by Paul Withers

• Point eclipse.ini to Domino javaw.exe

• Ensures it uses IBM version of Java

• Add before Xms

• No spaces

Page 18: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

18

Agenda

• Why

• Development and Debugging Environment

• XSP Starter Kit

• Structure and Deployment

Page 20: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

20

XSP Starter Kit

• Sample Plugin

• Includes examples for all main classes

• Components

• Beans

• SSJS – not straightforward

• Listeners

• and more

Page 21: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

21

Agenda

• Why

• Development and Debugging Environment

• XPages Starter Kit

• Structure and Deployment

Page 22: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

22

Structure

• Plugin project

• This is all that’s needed for OSGi

framework configuration

• Feature project loads one or more plugin

• Update Site project points to one or more feature

• Creates plugins and features jars

• Export as General > File System

Page 23: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

23

Update Site Project

Page 24: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

24

Deployment to Server / DDE

• Run from Eclipse using Domino Debug Plugin

• Install to remote server as other Ext Libs

• See Chapter 2 of XPages Extension

Library pp28+

• Install to DDE as other Ext Libs

Page 25: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

25

Deploy to DDE

• Every change you make to the component re-install the update – Quite laborious for development

• Add directly to DDE plugins

• Best to create separate directory

See blog post by John Cooper

Page 26: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

26

Create new Directory

• Navigate to framework directory inside the Notes Data Directory

• Create a new plugin directory

Page 27: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

27

Create a Link file

• Inside your newly created text file add the following:

path=C\:/Program Files (x86)/IBM/Notes/framework/jmc-plugins

Page 28: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

28

Update Platform.XML file

• Change the transient attribute on the config tag to false

• Replace all the instances of policy="MANAGED-ONLY" to policy="USER-EXCLUDE"

Page 29: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

29

Export Plugin

• Export plugin as a “Deployable Plugin and Fragment”

• Put in newly created directory

• Restart designer

Page 30: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

30

Is It Working?

• Check Help > Support > View Log and View Trace for errors / print statements

Page 31: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

31

Is It Working?

Page 32: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

32

Deployment to Developers / XPiNC

• Add to Widget Catalog from Update Site database

• See XPages Extension Library pp40+

• Best practice is using Desktop Policy, ensures updates automatically deployed

Page 33: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

33

Plugin Structure

• See Extensibility API Developers Guide

• Activator is optional

• Allows generic code to be run

• Extend org.eclipse.core.runtime.Plugin

Page 34: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

34

Extensions

• Extensions load other Java classes

• Extend com.ibm.commons.Extension

• Use “tell http osgi pt -v com.ibm. commons.Extension” to see types and classes currently loaded

Page 35: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

35

Library

• Selected in Xsp Properties

• Type=com.ibm.xsp.Library

• Extend AbstractXspLibrary

• Defines

• Dependencies

• Faces-Config files

• Xsp-Config files

Page 36: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

36

Contributor

• Adds factories

• Holds server-level maps

• Load implicit objects (variables)

• Type=com.ibm.xsp.library.Contributor

• Extend XspContributor

Page 37: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

37

ResourceProvider

• Adds browser resources

• JavaScript

• CSS

• Images

• Type=com.ibm.xsp.GlobalResourceProvider

• Extend BundleResourceProvider

Page 38: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

38

Basic Plugin from XSP Starter Kit

Page 39: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

39

Rest Service using DAS

• DAS – Domino Access Services

• Create a plugin project

• Add extension point to plugin.xml

<plugin> <extension point="com.ibm.domino.das.service"> <serviceResources class="org.iconuk.servicesdemo.service.NabDetailsService" name="NabDetails" path="nabdetails" version="9.0.1"> </serviceResources> </extension> </plugin>

Page 40: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

40

Plugin.xml

class="org.iconuk.servicesdemo.service.NabDetailsService“

Points to main service class

name="NabDetails"

Name of service is used in server document to know which service to load

path="nabdetails"

Path is the used to for the URL to access the service. Eg. http://hostname/api/nabdetails

Page 41: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

41

Service Class

• Required for extension point

• Extends com.ibm.domino.das.service.RestService

• getClasses method used to access Classes for each service URL

Page 42: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

42

Resource class

• One class per url

api/nabdetails/me -> class CurrentUserDetailsResource

api/nabdetails/paul -> class UserPaulDetailsResource

• Used to identify which path uses the class

@Path(CURRENTUSER_PATH)

• Used to identify which http method uses class method

@GET

Page 43: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

43

Enable on server

• Load plugin on to server in same way as any other plugin

• Open Server Document Internet Protocols -> Domino Web Engine

• Add service name to Enabled DAS Services

Page 44: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

44

Components

• Take a custom control and make it global

• NotesIn9 64 by Tim Tripcony

• #codefortim

• Or code within Eclipse

• Extensibility API 9.0.1

Page 45: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

45

Components

• Component class DOMINO

• .xsp-config to add properties DDE

• Renderer class, if required DOMINO

• Use getRendererType() to find an

existing renderer

• faces-config.xml to add renderer DOMINO

• Load xsp-config and faces-config.xml in Library class

Page 46: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

46

Including Third Party Jars

• Create a separate plugin

• New > Plug-in from Existing JAR Archives

• For additional jars

• Import the jar

• Add to Build Path

• Ensure included in Binary Build on

build.properties

• Also blog post by John Dalsgaard

Page 47: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

47

Including Third Party Jars

• Add as Required Plug-in to plugin.xml

• Click on Properties and tick “Reexport this dependency”

• Add to feature

• Ensure “Unpack the plug-in archive after the installation” is ticked

Otherwise DDE will not see the jars

Page 48: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

48

Demo Plugin

• Add component for Separator

• Allow properties for:

• separatorType (New Line / Space)

• count (integer, defaulting to 1)

• Deploy org.apache.commons.lang3

• Add utility method to convert any object to string detailing properties

Page 50: From XPages Hero to OSGi Guru: Taking the Scary out of Building Extension Libraries (ICON UK 2014)

50

Thank You

• Paul Withers

[email protected]

• http://www.intec.co.uk/blog

• http://twitter.com/paulswithers

• John Cooper

[email protected]

• http://developmentblog.johnmcooper.co.uk

• http://twitter.com/j_m_cooper