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.

OSGi and Eclipse RCP

1,421 views

Published on

Slides for a talk at the Seattle Java User Group about building a workflow management application for a biomedical lab on top of the OSGi module system and the Eclipse Rich Client Platform.

Published in: Technology, News & Politics
  • Be the first to comment

OSGi and Eclipse RCP

  1. 1. OSGi & Eclipse RCPEric JainSeattle Java User Group, November 15, 2011
  2. 2. 1 acctggat...2 acctgaat...3 acctggag...
  3. 3. 1 A*24:36N2 A*02:01:213 A*03:20/A*11:86
  4. 4. Samples 1 A*24:36N 2 A*02:01:21 3 A*03:20/A*11:86 Resolution Quantification SequencingExtraction Normalization Amplification SNP-Calling Genotyping QC Failure / Repeat Other Workflows
  5. 5. standalone client uih2 fs-proxy logging fs core pg exec fs-http server
  6. 6. Workflow A (v2) SNP Sequencing Workflow A Calling (v1) 1.0.0Amplification Sequencing 2.0.0 SNP Discovery Workflow B
  7. 7. META-INF/MANIFEST.MFManifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-Name: Demo BundleBundle-SymbolicName: org.seajug.demoBundle-Version: 1.0.0Import-Package: com.google.common.base;version="[10.0.0,11.0.0)", com.google.common.collect;version="[10.0.0,11.0.0)", com.google.common.io;version="[10.0.0,11.0.0)"Export-Package: org.seajug.demo;version="1.0.0", org.seajug.demo.ui;version="1.0.0"Bundle-ClassPath: lib/jxl.jar, conf/, .Bundle-Activator: org.seajug.demo.ActivatorBundle-RequiredExecutionEnvironment: JavaSE-1.6
  8. 8. Bootstrap CL Extensions CL System Classpath CLContext 1 Context 2 Context 3
  9. 9. Bootstrap CL Extensions CL System Classpath CL Bundle 2Bundle 1 Bundle 3 Fragment A Bundle 4
  10. 10. osgi> ssFramework is launched.id State Bundle0 ACTIVE org.eclipse.osgi_3.7.1.R37x_v20110808-1106 Fragments=11 RESOLVED org.eclipse.equinox.weaving.hook_1.0.0.v20100108 Master=02 ACTIVE org.eclipse.equinox.simpleconfigurator_1.0.200.v201105023 RESOLVED ch.qos.logback.classic_0.9.29 Fragments=984 RESOLVED ch.qos.logback.core_0.9.295 RESOLVED com.google.guava_10.0.0...53 <<LAZY>> org.eclipse.emf.ecore_2.7.0.v20110912-0920...78 RESOLVED org.eclipse.swt_3.7.1.v3738a Fragments=7979 RESOLVED org.eclipse.swt.win32.win32.x86_64_3.7.1.v3738a Master=78...
  11. 11. From: Creating Modular Applications in Java. Manning, 2011.
  12. 12. Activator.javapackage org.seajug.demo;import org.osgi.framework.BundleActivator;import org.osgi.framework.BundleContext;import org.osgi.framework.ServiceReference;public class Activator implements BundleActivator { @Override public void start(BundleContext context) { context.registerService(Foo.class, new Foo(), null); ServiceReference<Bar> ref = context.getServiceReference(Bar.class); Bar bar = (Bar) context.getService(ref); ... } @Override public void stop(BundleContext context) { }}
  13. 13. META-INF/spring-context.xml<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="..."> <osgi:reference id="foo" interface="org.seajug.demo.Foo"/> <bean id="bar" class="org.seajug.demo.internal.BarImpl"/> <osgi:service ref="bar" interface="org.seajug.demo.Bar"/> <context:annotation-config/></beans>
  14. 14. pom.xml<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>2.1.0</version> <configuration> <instructions> <module>com.google.inject</module> <Bundle-Copyright>Copyright (C) 2006 Google Inc.</Bundle-Copyright> <Bundle-DocURL>http://code.google.com/p/google-guice/</Bundle-DocURL> <Bundle-Name>${project.artifactId}</Bundle-Name> <Bundle-SymbolicName>$(module)</Bundle-SymbolicName> <Bundle-RequiredExecutionEnvironment> J2SE-1.5,JavaSE-1.6 </Bundle-RequiredExecutionEnvironment> <Import-Package>!com.google.inject.*,*</Import-Package> <_versionpolicy> [$(version;==;$(@)),$(version;+;$(@))) </_versionpolicy> </instructions> </configuration> <executions> <execution> <phase>prepare-package</phase> <goals> <goal>manifest</goal> </goals> </execution> </executions></plugin>
  15. 15. module-info.javamodule com.greetings @ 0.1 { requires jdk.base; // default to the highest available version requires org.astro @ 1.[1.1.1]+; class com.greetings.Hello;}} http://openjdk.java.net/projects/jigsaw/
  16. 16. TableDemo.javapackage org.seajug.demo;import org.eclipse.swt.SWT;import org.eclipse.swt.widgets.Composite;import org.eclipse.swt.widgets.Table;import org.eclipse.swt.widgets.TableItem;public class TableDemo { public void show(String[] values, Composite parent) { Table table = new Table(parent, SWT.BORDER | SWT.V_SCROLL); for (String value : values) { TableItem item = new TableItem(table, SWT.NONE); item.setText(value); } }}
  17. 17. TableViewerDemo.javapackage org.seajug.demo;import org.eclipse.jface.viewers.ArrayContentProvider;import org.eclipse.jface.viewers.LabelProvider;import org.eclipse.jface.viewers.TableViewer;import org.eclipse.swt.SWT;import org.eclipse.swt.widgets.Composite;public class TableViewerDemo { public void show(String[] values, Composite parent) { TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.V_SCROLL); viewer.setLabelProvider(new LabelProvider()); viewer.setContentProvider(new ArrayContentProvider()); viewer.setInput(values); }}
  18. 18. TableViewPartDemo.javapackage org.seajug.demo;import org.eclipse.jface.viewers.TableViewer;import org.eclipse.swt.widgets.Composite;import org.eclipse.ui.IViewSite;import org.eclipse.ui.PartInitException;import org.eclipse.ui.part.ViewPart;public class DemoViewPart extends ViewPart { private TableViewer viewer; @Override public void init(IViewSite site) throws PartInitException { super.init(site); } @Override public void createPartControl(Composite parent) { viewer = new TableViewer(parent, SWT.BORDER | SWT.V_SCROLL); ... } @Override public void setFocus() { viewer.getControl().setFocus(); } @Override public void dispose() { super.dispose(); }}
  19. 19. plugin.xml<extension point="org.eclipse.ui.views"> <view id="demoView" name="Demo" class="org.seajug.demo.DemoViewPart" /></extension>
  20. 20. plugin.xml<extension point="org.eclipse.ui.commands"> <command id="openItem" name="Open Item"/></extension><extension point="org.eclipse.ui.handlers"> <handler class="org.seajug.demo.OpenItemHandler" commandId="openItem"> <activeWhen> <with variable="activePartId"> <equals value="demoView"/> </with> </activeWhen> <enabledWhen> <with variable="selection"> <and> <count value="1"/> <iterate> <instanceof value="org.seajug.demo.Item"/> </iterate> </and> </with> </enabledWhen> </handler></extension><extension point="org.eclipse.ui.menus"> <menuContribution locationURI="toolbar:demoView"> <command commandId="openItem" icon="icons/open.png" style="push"/> </menuContribution></extension>
  21. 21. package org.fhcrc.gems.ui;import org.eclipse.core.runtime.IProgressMonitor;import org.eclipse.core.runtime.IStatus;import org.eclipse.core.runtime.Status;import org.eclipse.core.runtime.jobs.Job;public class JobDemo { public void run() { new Job("Genotyping") { @Override protected IStatus run(IProgressMonitor monitor) { monitor.beginTask("Reticulating splines", 100); for (int i = 0; i < 100; ++i) { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } ... } monitor.done(); return Status.OK_STATUS; } }.schedule(); }}
  22. 22. pom.xml<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>4.0.0</modelVersion> <groupId>org.seajug.demo</groupId> <artifactId>parent</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>pom</packaging> <properties> <tycho-version>0.13.0</tycho-version> </properties> <modules> <module>product</module> <module>org.seajug.demo.core</module> <module>org.seajug.demo.feature</module> <module>org.seajug.demo.test</module> <module>target-definition</module> </modules> <build> <plugins> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-maven-plugin</artifactId> <version>${tycho-version}</version> <extensions>true</extensions> </plugin> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>target-platform-configuration</artifactId> <version>${tycho-version}</version> <configuration> <resolver>p2</resolver> <target> <artifact> <groupId>org.seajug.demo</groupId> <artifactId>target-definition</artifactId> <version>1.0.0-SNAPSHOT</version> <classifier>build</classifier> </artifact> </target> </configuration> </plugin> </plugins> </build>
  23. 23. org.seajug.demo.core/pom.xml<project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>4.0.0</modelVersion> <groupId>org.seajug.demo</groupId> <artifactId>org.seajug.demo.core</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <parent> <groupId>org.seajug.demo</groupId> <artifactId>parent</artifactId> <version>1.0.0-SNAPSHOT</version> </parent></project>

×