Download presentation
Presentation is loading. Please wait.
Published byOlivia Carroll Modified over 11 years ago
1
aQute Eclipse Environment By Peter Kriens CEO aQute OSGi Director of Technology and OSGi Fellow
2
©1999-2004 aQute, All Rights Reserved slide #2 Contents What you will learn Eclipse Overview OSGi in Eclipse Creating a bundle Running a bundle Debugging a bundle Publishing a bundle Recap
3
©1999-2004 aQute, All Rights Reserved slide #3 What you will learn What Eclipse is all about Why Eclipse is important in relation to the OSGi Alliance How to run, debug, and publish a simple hello world bundle
4
©1999-2004 aQute, All Rights Reserved slide #4 Eclipse Overview Eclipse is an open source project that is developing a highly advanced Integrated Development Environment Though open source, it is driven foremost by IBM It is written in Java, but can be used for Java and other developments IBMs rich client architecture is based on Eclipse –Lotus clients!
5
©1999-2004 aQute, All Rights Reserved slide #5 Eclipse Goals Extremely open architecture that allows components from different origins to provide contributions –Menus, Views, Editors, etc. Decoupled so parts can be upgraded or replaced dynamically without disturbing other parts Providing an integration environment for UI based applications Today also looking at embedded applications
6
©1999-2004 aQute, All Rights Reserved slide #6 Eclipse and OSGi Eclipse developed a plugin model for release 1 and 2 The Equinox project developed a prototype that was based on the OSGi specifications The project was successful so the OSGi runtime replaced the Eclipse 1+2 runtime Eclipse R3 is a full blown OSGi environment
7
©1999-2004 aQute, All Rights Reserved slide #7 Setting up Eclipse to make bundles Install Eclipse from the CD or network. –Network: \\Ziggy\Course In not installed, install the Java SDK –Installers can be found in the download directory If not installed, install Eclipse Start Eclipse Starts up with a purple screen if for the first time.
8
©1999-2004 aQute, All Rights Reserved slide #8 Starting Eclipse
9
©1999-2004 aQute, All Rights Reserved slide #9 Setting up Eclipse Bravo! You are now running OSGi on your desktop! Click in the right hand corner to start Eclipse We now have to get a Framework running Copy the workspace directory to a directory on your hard disk, e.g. c:\workspace Create new project (File:Project) Then Next
10
©1999-2004 aQute, All Rights Reserved slide #10 Setting up a Framework Name the project Framework Select Create project at external location Select the Framework project in the workspace Click Finish This project can be run as an application (and debugged) It also provides the necessary libraries for our exercises
11
©1999-2004 aQute, All Rights Reserved slide #11 Creating a bundle A bundle is an OSGi executable It is a JAR file with classes and manifest The Bundle-Activator Manifest header points to the class that should be started This class must implement the BundleActivator interface
12
©1999-2004 aQute, All Rights Reserved slide #12 Back to Basics: Hello World Activator The Activator class will print Hello World when the bundle is started and Goodbye World when it stops. > BundleActivator
13
©1999-2004 aQute, All Rights Reserved slide #13 Getting Started Create new Java Project –File:New:Project –Java Project, Next
14
©1999-2004 aQute, All Rights Reserved slide #14 Create New Project –Project Name is hello world –Next
15
©1999-2004 aQute, All Rights Reserved slide #15 Create New Project Click Projects
16
©1999-2004 aQute, All Rights Reserved slide #16 Create New Project Select Framework –This will give us access to the OSGi specification class files and source code Click Libraries
17
©1999-2004 aQute, All Rights Reserved slide #17 Create New Project We need to add osgi.jar and servlet.jar from the Framework directory Click Add JARs Select Framework Select osgi.jar and servlet.jar Click OK Click Finish
18
©1999-2004 aQute, All Rights Reserved slide #18 Create Package Add Package –File:New:Package –Name, aQute.workshop.hello –Finish
19
©1999-2004 aQute, All Rights Reserved slide #19 Create Bundle Activator class File:New:Class –Package, aQute.workshop.hello –Name, Activator –Interfaces Add BundleActivator Finish Eclipse will open a generated source file
20
©1999-2004 aQute, All Rights Reserved slide #20 Activator class setup
21
©1999-2004 aQute, All Rights Reserved slide #21 1.1 Write Hello/Goodbye World Fill in the System.out.println(...) in the appropriate places Save the file (File:Save or control-S) –This automatically compiles, so correct any errors
22
©1999-2004 aQute, All Rights Reserved slide #22 Eclipse Tips and Tricks Renaming a class is in the Content menu, on Refactor –Handles all dependencies Control-N gives a list of completions Control-Shift-O cleans up your import clauses and find missing ones
23
©1999-2004 aQute, All Rights Reserved slide #23 Create The Manifest We only have to define what class to start: HelloWorld File:New:File, name it Manifest.mf –Store in root of the project
24
©1999-2004 aQute, All Rights Reserved slide #24 Create the Manifest Only fill in the Class field. This is the Bundle Activator Click on the Manifest.mf button at the bottom
25
©1999-2004 aQute, All Rights Reserved slide #25 Create the Manifest Add Manifest- Version: 1.0 at the top Then Bundle- Activator And 2 empty lines!!!
26
©1999-2004 aQute, All Rights Reserved slide #26 Create the Bundle JAR file Select the Hello World project in the left pane Press right mouse button (This is the context menu) Select Export Select JAR File Next
27
©1999-2004 aQute, All Rights Reserved slide #27 Create JAR File Export Destination –JAR file: Framework/load/HelloWorld.jar This screen defines the source and destination files Next
28
©1999-2004 aQute, All Rights Reserved slide #28 Create JAR file Save the description file in /hello world/bundle.jardesc The description can be reused many times Next
29
©1999-2004 aQute, All Rights Reserved slide #29 Create the JAR file Use existing manifest from workspace Finish
30
©1999-2004 aQute, All Rights Reserved slide #30 Starting A Framework The Framework project contains the OSGi Alliance Reference implementation –This Framework is not optimized, nor industrialized –It expires in 60 days –Contact a vendor for a real framework To start it –Select Framework project –Select aQute.crippled.jar (this contains a framework with some utitility bundles) –In context menu, select Run:Java Application
31
©1999-2004 aQute, All Rights Reserved slide #31 Select Main and then OK –This will start the frame It will start all bundles in the load directory –This is not standard but implemented in an aQute application bundle
32
©1999-2004 aQute, All Rights Reserved slide #32 Starting the Framework
33
©1999-2004 aQute, All Rights Reserved slide #33 Monitor When the Framework is started an OSGi monitor is also started This monitor shows some key information from the Framework It also watches the load folder and installs any new JAR files from this folder
34
©1999-2004 aQute, All Rights Reserved slide #34 Monitor A list of installed bundles, active or not active Detailed information about the bundle Exported packages Imported Packages Registered Services Used Services Operations Status
35
©1999-2004 aQute, All Rights Reserved slide #35 Monitor The monitor uses the OSGi event model to update the display in real time Check this by removing the hello world bundle from the load directory The monitor will show the uninstallation of the bundle
36
©1999-2004 aQute, All Rights Reserved slide #36 Restarting You can restart the bundle by –In the Hello World project –select the bundle.jardesc –Right mouse: Create Jar This works because the fileinstall bundle on the Framework will detect that the JAR file is modified in the load directory This will automatically update the bundle in the Framework (look at the console)
37
©1999-2004 aQute, All Rights Reserved slide #37 Updating the bundle
38
©1999-2004 aQute, All Rights Reserved slide #38 Debugging a Bundle Bundles can be easily debugged Instead of Run the framework, the framework must be started in the debugger First create a breakpoint in the HelloWorld start method (click in the left margin)
39
©1999-2004 aQute, All Rights Reserved slide #39 Select the Framework project and call up the context menu Select Debug:Java Application Select Main Click OK
40
©1999-2004 aQute, All Rights Reserved slide #40 Eclipse does not have the sources, so you must help it! So click on Edit Source Lookup Path.
41
©1999-2004 aQute, All Rights Reserved slide #41 Add the sources Click on Add Click on Java Project Select hello world Click Ok, Ok,Ok This information can also be set in Run:Debug:source
42
©1999-2004 aQute, All Rights Reserved slide #42 Debug Hello World The debugger is started You can now edit the source (within reason) and continue the session. E.g. change the text from Hello World to Bonjour and continue The red circled area contains the buttons to single step or continue
43
©1999-2004 aQute, All Rights Reserved slide #43 What Did We Learn? We learned how to create a real bundle This bundle needed –An Activator class –A Manifest These components were packed in a JAR file This JAR file was installed and started on an OSGi Framework with the fileinstaller bundle The console was used to see the effect of the start and stop methods We debugged the bundle
44
©1999-2004 aQute, All Rights Reserved slide #44 aQute www.aQute.biz +15123514821, Peter.Kriens@aQute.biz
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.