From c8d05b4db1f23b9d1e32dabe6b9eb548edb49687 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Wed, 27 Feb 2013 10:55:02 -0500 Subject: [PATCH] moving in some osgi bundles so as not to lose track of them. the example just provides a service bundle with some functionality, and a hello world example of using that bundle. it depends on eclipse to know about the services project currently, but could be made separate at some point with an ant build script, but then again, this is just a nice example. --- .../.classpath | 7 ++++ osgi/org.feistymeow.bundle.helloOSGi/.project | 34 +++++++++++++++++ .../.settings/org.eclipse.jdt.core.prefs | 7 ++++ .../.settings/org.eclipse.pde.core.prefs | 4 ++ .../META-INF/MANIFEST.MF | 10 +++++ .../build.properties | 4 ++ .../bundle/helloosgi/Activator.java | 35 ++++++++++++++++++ .../.classpath | 7 ++++ .../.project | 34 +++++++++++++++++ .../.settings/org.eclipse.jdt.core.prefs | 7 ++++ .../.settings/org.eclipse.pde.core.prefs | 4 ++ .../META-INF/MANIFEST.MF | 10 +++++ .../build.properties | 4 ++ .../bundle/serviceosgi/HelloService.java | 6 +++ .../serviceosgi/HelloServiceActivator.java | 37 +++++++++++++++++++ .../bundle/serviceosgi/HelloServiceImpl.java | 13 +++++++ readme.txt | 5 +++ 17 files changed, 228 insertions(+) create mode 100644 osgi/org.feistymeow.bundle.helloOSGi/.classpath create mode 100644 osgi/org.feistymeow.bundle.helloOSGi/.project create mode 100644 osgi/org.feistymeow.bundle.helloOSGi/.settings/org.eclipse.jdt.core.prefs create mode 100644 osgi/org.feistymeow.bundle.helloOSGi/.settings/org.eclipse.pde.core.prefs create mode 100644 osgi/org.feistymeow.bundle.helloOSGi/META-INF/MANIFEST.MF create mode 100644 osgi/org.feistymeow.bundle.helloOSGi/build.properties create mode 100644 osgi/org.feistymeow.bundle.helloOSGi/src/org/feistymeow/bundle/helloosgi/Activator.java create mode 100644 osgi/org.feistymeow.bundle.servicesOSGi/.classpath create mode 100644 osgi/org.feistymeow.bundle.servicesOSGi/.project create mode 100644 osgi/org.feistymeow.bundle.servicesOSGi/.settings/org.eclipse.jdt.core.prefs create mode 100644 osgi/org.feistymeow.bundle.servicesOSGi/.settings/org.eclipse.pde.core.prefs create mode 100644 osgi/org.feistymeow.bundle.servicesOSGi/META-INF/MANIFEST.MF create mode 100644 osgi/org.feistymeow.bundle.servicesOSGi/build.properties create mode 100644 osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloService.java create mode 100644 osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloServiceActivator.java create mode 100644 osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloServiceImpl.java diff --git a/osgi/org.feistymeow.bundle.helloOSGi/.classpath b/osgi/org.feistymeow.bundle.helloOSGi/.classpath new file mode 100644 index 00000000..098194ca --- /dev/null +++ b/osgi/org.feistymeow.bundle.helloOSGi/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/osgi/org.feistymeow.bundle.helloOSGi/.project b/osgi/org.feistymeow.bundle.helloOSGi/.project new file mode 100644 index 00000000..af56a198 --- /dev/null +++ b/osgi/org.feistymeow.bundle.helloOSGi/.project @@ -0,0 +1,34 @@ + + + org.feistymeow.bundle.helloOSGi + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature + + diff --git a/osgi/org.feistymeow.bundle.helloOSGi/.settings/org.eclipse.jdt.core.prefs b/osgi/org.feistymeow.bundle.helloOSGi/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..f42de363 --- /dev/null +++ b/osgi/org.feistymeow.bundle.helloOSGi/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/osgi/org.feistymeow.bundle.helloOSGi/.settings/org.eclipse.pde.core.prefs b/osgi/org.feistymeow.bundle.helloOSGi/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 00000000..e8ff8be0 --- /dev/null +++ b/osgi/org.feistymeow.bundle.helloOSGi/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +pluginProject.equinox=false +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/osgi/org.feistymeow.bundle.helloOSGi/META-INF/MANIFEST.MF b/osgi/org.feistymeow.bundle.helloOSGi/META-INF/MANIFEST.MF new file mode 100644 index 00000000..0f036d6a --- /dev/null +++ b/osgi/org.feistymeow.bundle.helloOSGi/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: HelloOSGi +Bundle-SymbolicName: org.feistymeow.bundle.helloOSGi +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.feistymeow.bundle.helloosgi.Activator +Bundle-Vendor: feistymeow.org +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Import-Package: org.feistymeow.bundle.serviceosgi, + org.osgi.framework;version="1.3.0" diff --git a/osgi/org.feistymeow.bundle.helloOSGi/build.properties b/osgi/org.feistymeow.bundle.helloOSGi/build.properties new file mode 100644 index 00000000..34d2e4d2 --- /dev/null +++ b/osgi/org.feistymeow.bundle.helloOSGi/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/osgi/org.feistymeow.bundle.helloOSGi/src/org/feistymeow/bundle/helloosgi/Activator.java b/osgi/org.feistymeow.bundle.helloOSGi/src/org/feistymeow/bundle/helloosgi/Activator.java new file mode 100644 index 00000000..faa68fbc --- /dev/null +++ b/osgi/org.feistymeow.bundle.helloOSGi/src/org/feistymeow/bundle/helloosgi/Activator.java @@ -0,0 +1,35 @@ +package org.feistymeow.bundle.helloosgi; + +import org.feistymeow.bundle.serviceosgi.HelloService; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; + +@SuppressWarnings("rawtypes") +public class Activator implements BundleActivator { + + ServiceReference helloServiceReference; + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + + System.out.println("into Hello OSGi!"); + + helloServiceReference = context.getServiceReference(HelloService.class.getName()); + @SuppressWarnings("unchecked") + HelloService helloService = (HelloService)context.getService(helloServiceReference); + System.out.println(helloService.sayHello()); + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + System.out.println("out of Hello OSGi!"); + } + +} diff --git a/osgi/org.feistymeow.bundle.servicesOSGi/.classpath b/osgi/org.feistymeow.bundle.servicesOSGi/.classpath new file mode 100644 index 00000000..098194ca --- /dev/null +++ b/osgi/org.feistymeow.bundle.servicesOSGi/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/osgi/org.feistymeow.bundle.servicesOSGi/.project b/osgi/org.feistymeow.bundle.servicesOSGi/.project new file mode 100644 index 00000000..a831b04d --- /dev/null +++ b/osgi/org.feistymeow.bundle.servicesOSGi/.project @@ -0,0 +1,34 @@ + + + org.feistymeow.bundle.servicesOSGi + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature + + diff --git a/osgi/org.feistymeow.bundle.servicesOSGi/.settings/org.eclipse.jdt.core.prefs b/osgi/org.feistymeow.bundle.servicesOSGi/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..f42de363 --- /dev/null +++ b/osgi/org.feistymeow.bundle.servicesOSGi/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/osgi/org.feistymeow.bundle.servicesOSGi/.settings/org.eclipse.pde.core.prefs b/osgi/org.feistymeow.bundle.servicesOSGi/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 00000000..e8ff8be0 --- /dev/null +++ b/osgi/org.feistymeow.bundle.servicesOSGi/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +pluginProject.equinox=false +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/osgi/org.feistymeow.bundle.servicesOSGi/META-INF/MANIFEST.MF b/osgi/org.feistymeow.bundle.servicesOSGi/META-INF/MANIFEST.MF new file mode 100644 index 00000000..47c20581 --- /dev/null +++ b/osgi/org.feistymeow.bundle.servicesOSGi/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: HelloService Plugin +Bundle-SymbolicName: org.feistymeow.bundle.servicesosgi +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.feistymeow.bundle.serviceosgi.HelloServiceActivator +Bundle-Vendor: feistymeow.org +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Import-Package: org.osgi.framework;version="1.3.0" +Export-Package: org.feistymeow.bundle.serviceosgi;uses:="org.osgi.framework" diff --git a/osgi/org.feistymeow.bundle.servicesOSGi/build.properties b/osgi/org.feistymeow.bundle.servicesOSGi/build.properties new file mode 100644 index 00000000..34d2e4d2 --- /dev/null +++ b/osgi/org.feistymeow.bundle.servicesOSGi/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloService.java b/osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloService.java new file mode 100644 index 00000000..c93c8cc8 --- /dev/null +++ b/osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloService.java @@ -0,0 +1,6 @@ +package org.feistymeow.bundle.serviceosgi; + +public interface HelloService +{ + public String sayHello(); +} diff --git a/osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloServiceActivator.java b/osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloServiceActivator.java new file mode 100644 index 00000000..6d49301a --- /dev/null +++ b/osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloServiceActivator.java @@ -0,0 +1,37 @@ +package org.feistymeow.bundle.serviceosgi; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +public class HelloServiceActivator implements BundleActivator +{ + + @SuppressWarnings("rawtypes") + ServiceRegistration helloServiceRegistration; + + /* + * (non-Javadoc) + * + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception + { + System.out.println("hello-service start"); + + HelloService helloService = new HelloServiceImpl(); + helloServiceRegistration = context.registerService(HelloService.class.getName(), helloService, null); + } + + /* + * (non-Javadoc) + * + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception + { + helloServiceRegistration.unregister(); + System.out.println("hello-service stop"); + } + +} diff --git a/osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloServiceImpl.java b/osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloServiceImpl.java new file mode 100644 index 00000000..c007d48e --- /dev/null +++ b/osgi/org.feistymeow.bundle.servicesOSGi/src/org/feistymeow/bundle/serviceosgi/HelloServiceImpl.java @@ -0,0 +1,13 @@ +package org.feistymeow.bundle.serviceosgi; + +public class HelloServiceImpl implements HelloService +{ + + @Override + public String sayHello() + { + System.out.println("Inside HelloServiceImpl.sayHello()"); + return "Say Hello"; + } + +} diff --git a/readme.txt b/readme.txt index 34a15a49..7c349639 100644 --- a/readme.txt +++ b/readme.txt @@ -44,6 +44,11 @@ kona/ Our burgeoning Java libraries. Not much to see here yet, but there is some code piling up for these that we will try to release soon. +osgi/ + Some example bundles for Java OSGi. These may eventually fill out with real material, + but currently they are just tracking the investigation we did into creating bundles and + running using them. + production/ Machinery for getting releases out the door, including the generated files such as binaries and build system tools. -- 2.34.1