33
1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

Embed Size (px)

Citation preview

Page 1: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

1

Developing Applications in Protégé:

The Protégé Plugin Architecture

Timothy Redmond

Ontolog Forum29-Jun-2006

Page 2: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

2

Overview

• What is a Plugin?• How Plugins Work• Plugin Types and Capabilities• Plugin Packaging• Plugin Bundling• Plugin Licensing• Other Development Models

Page 3: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

3

Out of Scope

• Standard Java Development • Coding• Packaging (jars)• Utilities

• Implementation mechanisms• Development environments• Non-plugin Protégé extensions

Page 4: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

4

What is a Plugin?

• Extension to Protégé • Requires no source code modifications• Loaded and managed by system• Changes way Protégé works

• Implementation of a Java interface • Packaged as jars• Installed in subdirectory of Protégé plugins

Page 5: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

5

How Plugins Work

• Protégé, at startup, loads jars directly below plugins subdirectory

• Jars contain manifest of contained plugins• System creates instances of plugin• System calls plugin methods when needed

“Don’t call us, we’ll call you.”

Page 6: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

6

Plugin Source

• Extremely Simple Demo Plugins• Available with the source for this talk

Page 7: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

7

Types of Plugins

• TabWidget• SlotWidget• KnowledgeBaseFactory (“Backend”)• ProjectPlugin• ExportPlugin• CreateProjectPlugin

Page 8: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

8

Plugin: TabWidget

• What is it?• Large piece of screen real-estate• Can interact with domain KB

browse, change, delete, corrupt• What are its limitations?

• Difficult to supplement or even interact with other tabs

• How hard is it to create?• Easy (1 day)• Just implement the initialize() method

Page 9: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

9

Tab Plugin Configuration

Protégé is built from plugins

The Frame Counter Tab which we have added.

Not enabled.

Page 10: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

10

Simple Tab Plugin

Page 11: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

11

Plugin: SlotWidget

• What is it?• UI Control which allows the user to display and

modify a slot value• Follows a protocol for hiding interaction KB

• What are its limitations?• Works best with a single slot

• How hard is it to create?• Easy (1 day)

Page 12: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

12

Forms and the Slot Widget

Page 13: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

13

Forms and the Slot Widget

Page 14: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

14

Plugin: SlotWidget - Protocol

• Initialize()• Describe how large a widget would like to be

• getValues()• Protégé wants the value being displayed.

• setValues()• Protégé wants to update the value displayed in the

widget

• valueChanged() • tells Protégé of an update

• isSuitable()• setEditable()

Page 15: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

15

Plugin Type: KnowledgeBaseFactory

• What is it?• Replacement for standard storage mechanisms

• Database• External server• …

• Allows for parsing of different file formats• What are its limitations?

• Difficult to manipulate UI• Implementations tend to be buggy

• How hard is it to create?• Hard (>= 1 month)• Consider Import/Export plugin instead

Page 16: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

16

Plugin Type: ProjectPlugin

• What is it?• Code that executes when “things happen” to a

project (create, load, display, close, etc)• Get access to project, view, menu bar, tool bar and

can modify them as you like

• How hard is it to create?• Easy (1 day)• Seven Possible Interfaces to implement

Page 17: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

17

Project Plugin Example

Page 18: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

18

Plugin Type: ExportPlugin

• What is it?• Code that saves (part of) a knowledge-base in any

format to somewhere else• files, servers, web, …

• No change of the current backend• No guarantee of “lossless round trip” • No “live” connection

• How hard is it to create?• Medium (1 week)• Implement handleExportRequest()

Page 19: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

19

Export Plugin Example

Page 20: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

20

Plugin Type: CreateProjectPlugin

• What is it?• Code that creates a knowledge-base from

information from somewhere else • files, servers, web, …

• No change of the current backend• No guarantee of “lossless round trip”• No “live” connection

• How hard is it to create?• Medium (1 week)

Page 21: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

21

Plugin Type: CreateProjectPlugin

• canCreateProject()• Describes when this import plugin can be used

• createCreateProjectWizardPage()• The wizard for finding out where to get the data

• createNewProject()• Creates the project from scratch

• buildNewProject()• Builds the project from existing sources

Page 22: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

22

CreateProjectPlugin Example

Page 23: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

23

Types of Plugins

• TabWidget• SlotWidget• KnowledgeBaseFactory (“Backend”)• ProjectPlugin• ExportPlugin• CreateProjectPlugin

Page 24: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

24

Plugin Packaging

• Plugin can contain doc and “about box” URL’s or pages to integrate into the system

• Create a directory structure like:edu.stanford.smi.protegex.myproject/

myproject.jar otherlibrary.jar

myproject_doc.htmlmyproject_about.htmlplugin.properties

• Zip it up and give it to your friends

Page 25: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

25

Plugin Bundling

• Plugins of general usefulness can be “bundled” with the full release and made available to all users

• Advantage: • You may get a lot of users quickly

• Disadvantage:• You may get a lot of users quickly

• In order to be bundled the plugin must be:• Well Formed• Well Behaved• Well Maintained

Page 26: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

26

Plugin Bundling – Well Formed

• jar file in an appropriate, recognizable directory • approriate: “edu.myorg.mygroup.myproject”, not “foo”• recognizable: last directory element: “mytab” not “foo”

• About Box and Documentation entries• Minimal size

• minimal documentation • links to more extensive documentation on web• no PDF, MS Word, large image files

• no source• at most one small example project• readme.txt file if necessary

• isSuitable implemented if appropriate• Is it requires certain sorts of projects or additional

installation (shared libraries, etc)

Page 27: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

27

Plugin Bundling – Well Behaved

• Must “work” (not crash on startup) with the current release

• Minimal information (just errors) printed to the console window• Single startup line is ok (but certainly not required)• Use Java Logger for debugging

• Must start up and shut down smoothly• No time consuming code executed in static initializer• No long start up delays or modal dialogs that block the

rest of the system• Must free acquired resources in “dispose()”

Page 28: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

28

Plugin Bundling – Well Maintained

• Developer/maintainer “responsive” to problems.

• Does not mean that you offer 24x7x365 free support.

Page 29: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

29

Plugin Licensing

• Plugins are not affected by the Mozilla Public License (MPL)

• You can adopt whatever license you want for your plugin• Open source (GPL, MPL, BSD)• Proprietary

• You can (try to) sell your plugin• See FAQ for more information on plugin and

non-plugin licensing issues• http://protege.stanford.edu/faq.html#08.00

Page 30: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

30

Plugin Summary

• Plugins provide flexible and powerful mechanisms for extending Protege in many ways.

• When you encounter places where the default UI is inadequate or clumsy for your needs (and you will!) think about developing a plugin.

• Think about contributing your plugin it back to the community.

Page 31: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

31

Standalone Application

• Description• Write standalone Java Application• Call into the Protégé API for knowledge base access• Often evolves from a Tab

• Pros• No need to install Protégé• User doesn’t need to know anything about Protégé• Underlying model and data are as secure as you want• Can use some or none of the Protégé UI, as desired

• Forms for classes and instances are available• Some tabs will work

• Cons• Iteration somewhat more difficult than as Tab

Page 32: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

32

OWL Model Interfaces

• Get Standard OWL Vocabulary• E.g. owl:equivalentClass

• Create named classes & properties• Java classes for all parts of the OWL Abstract Syntax• Create OWL expressions (Restrictions)• Listeners for Changes

• E.g. class creation, deletion, new properties

Page 33: 1 Developing Applications in Protégé: The Protégé Plugin Architecture Timothy Redmond Ontolog Forum 29-Jun-2006

33

Summary

• Plugin Development is often a good starting point

• Standalone applications easily built on Protégé• Using only knowledge base• Using also some/all of the Protégé UI