diff options
Diffstat (limited to 'examples/bundles')
36 files changed, 545 insertions, 0 deletions
diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.classpath b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.classpath new file mode 100644 index 000000000..64c5e31b7 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.gitignore b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.gitignore new file mode 100644 index 000000000..5e56e040e --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.project b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.project new file mode 100644 index 000000000..5a2105516 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.project @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>com.mycorp.examples.timeservice.consumer.filediscovery</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> + </natures> +</projectDescription> diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.settings/org.eclipse.jdt.core.prefs b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..af0f20f97 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.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.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.settings/org.eclipse.pde.core.prefs b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000..f29e940a0 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/META-INF/MANIFEST.MF b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/META-INF/MANIFEST.MF new file mode 100644 index 000000000..bf5a41a95 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: TimeService Consumer Filediscovery +Bundle-SymbolicName: com.mycorp.examples.timeservice.consumer.filediscovery +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: MyCorp, Inc. +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Remote-Service: timeserviceendpointdescription.xml + diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/build.properties b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/launch/TimeServiceConsumer(discovery=file).launch b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/launch/TimeServiceConsumer(discovery=file).launch new file mode 100644 index 000000000..b14dae44c --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/launch/TimeServiceConsumer(discovery=file).launch @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.pde.ui.EquinoxLauncher"> +<booleanAttribute key="append.args" value="true"/> +<booleanAttribute key="automaticAdd" value="false"/> +<booleanAttribute key="automaticValidate" value="false"/> +<stringAttribute key="bootstrap" value=""/> +<stringAttribute key="checked" value="[NONE]"/> +<booleanAttribute key="clearConfig" value="false"/> +<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/TimeServiceConsumer(discovery=file)"/> +<booleanAttribute key="default" value="true"/> +<booleanAttribute key="default_auto_start" value="true"/> +<intAttribute key="default_start_level" value="4"/> +<booleanAttribute key="includeOptional" value="false"/> +<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/> +<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Declipse.ignoreApp=true -Dosgi.noShutdown=true -DverboseRemoteServiceAdmin=true"/> +<stringAttribute key="pde.version" value="3.3"/> +<booleanAttribute key="show_selected_only" value="false"/> +<stringAttribute key="target_bundles" value="javax.xml@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.eclipse.core.jobs@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.console@default:default,org.eclipse.equinox.event@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true"/> +<booleanAttribute key="tracing" value="false"/> +<booleanAttribute key="useCustomFeatures" value="false"/> +<booleanAttribute key="useDefaultConfigArea" value="true"/> +<stringAttribute key="workspace_bundles" value="com.mycorp.examples.timeservice.consumer.filediscovery@default:false,com.mycorp.examples.timeservice.consumer@default:default,com.mycorp.examples.timeservice@default:default,org.eclipse.ecf.discovery@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.ecf.osgi.services.distribution@default:default,org.eclipse.ecf.osgi.services.remoteserviceadmin.proxy@default:default,org.eclipse.ecf.osgi.services.remoteserviceadmin@default:default,org.eclipse.ecf.provider.remoteservice@default:default,org.eclipse.ecf.provider@default:default,org.eclipse.ecf.remoteservice@default:default,org.eclipse.ecf.sharedobject@default:default,org.eclipse.ecf@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.osgi.services.remoteserviceadmin@default:default"/> +</launchConfiguration> diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/src/foo.txt b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/src/foo.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/src/foo.txt diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/timeserviceendpointdescription.xml b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/timeserviceendpointdescription.xml new file mode 100644 index 000000000..180533dc6 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/timeserviceendpointdescription.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0"> + <endpoint-description> + <property name="ecf.endpoint.id.ns" value-type="String" value="org.eclipse.ecf.core.identity.StringID"/> + <property name="endpoint.framework.uuid" value-type="String" value="20cc5d57-e8f0-0012-192b-c570b422d1f9"/> + <property name="endpoint.id" value-type="String" value="ecftcp://localhost:3288/server"/> + <property name="endpoint.package.version.com.mycorp.examples.timeservice" value-type="String" value="1.0.0"/> + <property name="endpoint.service.id" value-type="Long" value="0"/> + <property name="objectClass" value-type="String"> + <array> + <value>com.mycorp.examples.timeservice.ITimeService</value> + </array> + </property> + <property name="remote.configs.supported" value-type="String"> + <array> + <value>ecf.generic.server</value> + </array> + </property> + <property name="remote.intents.supported" value-type="String"> + <array> + <value>passByValue</value> + <value>exactlyOnce</value> + <value>ordered</value> + </array> + </property> + <property name="service.id" value-type="Long" value="66"/> + <property name="service.imported" value-type="String" value="true"/> + <property name="service.imported.configs" value-type="String"> + <array> + <value>ecf.generic.server</value> + </array> + </property> + </endpoint-description> +</endpoint-descriptions>
\ No newline at end of file diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer/.classpath b/examples/bundles/com.mycorp.examples.timeservice.consumer/.classpath new file mode 100644 index 000000000..64c5e31b7 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer/.gitignore b/examples/bundles/com.mycorp.examples.timeservice.consumer/.gitignore new file mode 100644 index 000000000..5e56e040e --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer/.project b/examples/bundles/com.mycorp.examples.timeservice.consumer/.project new file mode 100644 index 000000000..6e7d35703 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer/.project @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>com.mycorp.examples.timeservice.consumer</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> + </natures> +</projectDescription> diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer/.settings/org.eclipse.jdt.core.prefs b/examples/bundles/com.mycorp.examples.timeservice.consumer/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..af0f20f97 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer/.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.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer/.settings/org.eclipse.pde.core.prefs b/examples/bundles/com.mycorp.examples.timeservice.consumer/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000..f29e940a0 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer/META-INF/MANIFEST.MF b/examples/bundles/com.mycorp.examples.timeservice.consumer/META-INF/MANIFEST.MF new file mode 100644 index 000000000..9f2cb57fc --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Consumer +Bundle-SymbolicName: com.mycorp.examples.timeservice.consumer +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: MyCorp, Inc. +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ActivationPolicy: lazy +Bundle-Activator: com.mycorp.examples.timeservice.consumer.Activator +Import-Package: com.mycorp.examples.timeservice;version="1.0.0", + org.osgi.framework, + org.osgi.service.remoteserviceadmin;version="1.0.0", + org.osgi.util.tracker diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer/build.properties b/examples/bundles/com.mycorp.examples.timeservice.consumer/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/examples/bundles/com.mycorp.examples.timeservice.consumer/src/com/mycorp/examples/timeservice/consumer/Activator.java b/examples/bundles/com.mycorp.examples.timeservice.consumer/src/com/mycorp/examples/timeservice/consumer/Activator.java new file mode 100644 index 000000000..8c7fd795b --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.consumer/src/com/mycorp/examples/timeservice/consumer/Activator.java @@ -0,0 +1,85 @@ +package com.mycorp.examples.timeservice.consumer; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent; +import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener; +import org.osgi.util.tracker.ServiceTracker; +import org.osgi.util.tracker.ServiceTrackerCustomizer; + +import com.mycorp.examples.timeservice.ITimeService; + +public class Activator implements BundleActivator, ServiceTrackerCustomizer<ITimeService,ITimeService> { + + private BundleContext context; + private ServiceTracker<ITimeService,ITimeService> timeServiceTracker; + + public void start(BundleContext context) throws Exception { + this.context = context; + // If the verboseRemoteServiceAdmin system property is set + // then register debug listener + if (Boolean.getBoolean("verboseRemoteServiceAdmin")) + registerDebugListener(context); + + // Create and open ITimeService tracker + this.timeServiceTracker = new ServiceTracker<ITimeService,ITimeService>(this.context,ITimeService.class,this); + this.timeServiceTracker.open(); + } + + public void stop(BundleContext context) throws Exception { + if (timeServiceTracker != null) { + timeServiceTracker.close(); + timeServiceTracker = null; + } + } + + /** + * NOTE: The method will be called when the ITimeService is discovered. + */ + public ITimeService addingService( + ServiceReference<ITimeService> reference) { + System.out.println("ITimeService discovered!"); + System.out.println("Service Reference="+reference); + // Get the time service proxy + ITimeService timeService = this.context.getService(reference); + System.out.println("Calling timeService="+timeService); + // Call the service! + Long time = timeService.getCurrentTime(); + // Print out the result + System.out.println("Call Done. Current time given by ITimeService.getCurrentTime() is: "+time); + return timeService; + } + + public void modifiedService(ServiceReference<ITimeService> reference, + ITimeService service) { + // do nothing + } + + public void removedService(ServiceReference<ITimeService> reference, + ITimeService service) { + // do nothing + } + + // Register a RemoteServiceAdminListener so we can report to sdtout + // when a remote service has actually been successfully exported by + // the RSA implementation + private void registerDebugListener(BundleContext context) { + RemoteServiceAdminListener rsaListener = new RemoteServiceAdminListener() { + public void remoteAdminEvent(RemoteServiceAdminEvent event) { + switch (event.getType()) { + case RemoteServiceAdminEvent.IMPORT_REGISTRATION: + System.out + .println("Service Imported by RemoteServiceAdmin. EndpointDescription Properties=" + + event.getImportReference().getImportedEndpoint().getProperties()); + } + } + + }; + // Register as service, and RemoteServiceAdmin will callback + context.registerService(RemoteServiceAdminListener.class.getName(), + rsaListener, null); + } + + +} diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/.classpath b/examples/bundles/com.mycorp.examples.timeservice.host/.classpath new file mode 100644 index 000000000..64c5e31b7 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.host/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/.gitignore b/examples/bundles/com.mycorp.examples.timeservice.host/.gitignore new file mode 100644 index 000000000..5e56e040e --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.host/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/.project b/examples/bundles/com.mycorp.examples.timeservice.host/.project new file mode 100644 index 000000000..445a254fd --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.host/.project @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>com.mycorp.examples.timeservice.host</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> + </natures> +</projectDescription> diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/.settings/org.eclipse.jdt.core.prefs b/examples/bundles/com.mycorp.examples.timeservice.host/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..af0f20f97 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.host/.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.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/.settings/org.eclipse.pde.core.prefs b/examples/bundles/com.mycorp.examples.timeservice.host/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000..f29e940a0 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.host/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/META-INF/MANIFEST.MF b/examples/bundles/com.mycorp.examples.timeservice.host/META-INF/MANIFEST.MF new file mode 100644 index 000000000..bc892795b --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.host/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Host +Bundle-SymbolicName: com.mycorp.examples.timeservice.host +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: MyCorp, Inc. +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ActivationPolicy: lazy +Import-Package: com.mycorp.examples.timeservice;version="1.0.0", + org.osgi.framework, + org.osgi.service.remoteserviceadmin;version="1.0.0" +Bundle-Activator: com.mycorp.examples.timeservice.host.Activator diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/build.properties b/examples/bundles/com.mycorp.examples.timeservice.host/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.host/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/launch/TimeServiceHost.launch b/examples/bundles/com.mycorp.examples.timeservice.host/launch/TimeServiceHost.launch new file mode 100644 index 000000000..d3f474336 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.host/launch/TimeServiceHost.launch @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.pde.ui.EquinoxLauncher"> +<booleanAttribute key="append.args" value="true"/> +<booleanAttribute key="automaticAdd" value="false"/> +<booleanAttribute key="automaticValidate" value="false"/> +<stringAttribute key="bootstrap" value=""/> +<stringAttribute key="checked" value="[NONE]"/> +<booleanAttribute key="clearConfig" value="false"/> +<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/MyTimeServiceHost"/> +<booleanAttribute key="default" value="true"/> +<booleanAttribute key="default_auto_start" value="true"/> +<intAttribute key="default_start_level" value="4"/> +<booleanAttribute key="includeOptional" value="false"/> +<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/> +<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> +<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Declipse.ignoreApp=true -Dosgi.noShutdown=true -DverboseRemoteServiceAdmin=true"/> +<stringAttribute key="pde.version" value="3.3"/> +<booleanAttribute key="show_selected_only" value="false"/> +<stringAttribute key="target_bundles" value="javax.xml@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.eclipse.core.jobs@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.console@default:default,org.eclipse.equinox.event@2:default,org.eclipse.equinox.registry@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true"/> +<booleanAttribute key="tracing" value="false"/> +<booleanAttribute key="useCustomFeatures" value="false"/> +<booleanAttribute key="useDefaultConfigArea" value="true"/> +<stringAttribute key="workspace_bundles" value="com.mycorp.examples.timeservice.host@default:default,com.mycorp.examples.timeservice@default:default,org.eclipse.ecf.discovery@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.ecf.osgi.services.distribution@default:default,org.eclipse.ecf.osgi.services.remoteserviceadmin.proxy@default:default,org.eclipse.ecf.osgi.services.remoteserviceadmin@default:default,org.eclipse.ecf.provider.remoteservice@default:default,org.eclipse.ecf.provider@default:default,org.eclipse.ecf.remoteservice@default:default,org.eclipse.ecf.sharedobject@default:default,org.eclipse.ecf@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.osgi.services.remoteserviceadmin@default:default"/> +</launchConfiguration> diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/Activator.java b/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/Activator.java new file mode 100644 index 000000000..0e2223870 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/Activator.java @@ -0,0 +1,70 @@ +package com.mycorp.examples.timeservice.host; + +import java.util.Dictionary; +import java.util.Hashtable; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent; +import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener; + +import com.mycorp.examples.timeservice.ITimeService; + +public class Activator implements BundleActivator { + + public void start(BundleContext context) throws Exception { + // If the verboseRemoteServiceAdmin system property is set + // then register debug listener + if (Boolean.getBoolean("verboseRemoteServiceAdmin")) + registerDebugListener(context); + + // Create MyTimeService impl and register as a remote service + Dictionary<String, Object> props = new Hashtable<String, Object>(); + // This is the only required service property to trigger remote services + props.put("service.exported.interfaces", "*"); + // set service.exported.configs + props.put("service.exported.configs",System.getProperty("service.exported.configs","ecf.generic.server")); + // Set the ecf-generic-provider-specific id + props.put("ecf.generic.server.id",System.getProperty("ecf.generic.server.id","ecftcp://localhost:3288/server")); + // register the remote service with the service registry. If ECF remote + // services/RSA impl is installed and started, it will export this + // service via the default distribution provider, which is + // 'ecf.generic.server' + // To change which provider is used (e.g.) r-OSGi: + // props.put("service.exported.configs","ecf.r-osgi.peer"); + ServiceRegistration<ITimeService> timeServiceRegistration = context + .registerService(ITimeService.class, new TimeServiceImpl(), + props); + // Print out that ITimeService remote service registration + System.out.println("MyTimeService host registered with registration=" + + timeServiceRegistration); + } + + public void stop(BundleContext context) throws Exception { + // do nothing + } + + // Register a RemoteServiceAdminListener so we can report to sdtout + // when a remote service has actually been successfully exported by + // the RSA implementation + private void registerDebugListener(BundleContext context) { + RemoteServiceAdminListener rsaListener = new RemoteServiceAdminListener() { + public void remoteAdminEvent(RemoteServiceAdminEvent event) { + switch (event.getType()) { + case RemoteServiceAdminEvent.EXPORT_REGISTRATION: + System.out + .println("Service Exported by RemoteServiceAdmin. EndpointDescription Properties=" + + event.getExportReference() + .getExportedEndpoint() + .getProperties()); + } + } + + }; + // Register as service, and RemoteServiceAdmin will callback + context.registerService(RemoteServiceAdminListener.class.getName(), + rsaListener, null); + } + +} diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/TimeServiceImpl.java b/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/TimeServiceImpl.java new file mode 100644 index 000000000..3225b4700 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/TimeServiceImpl.java @@ -0,0 +1,19 @@ +package com.mycorp.examples.timeservice.host; + +import com.mycorp.examples.timeservice.ITimeService; + +public class TimeServiceImpl implements ITimeService { + + /** + * Implementation of my time service. + */ + public Long getCurrentTime() { + // Print out to host std out that a call to this service was received. + System.out.println("TimeServiceImpl. Received call to getCurrentTime()"); + // Eventually, this should (e.g.) contact NIST time server and return more + // accurate time. For the time being, we will return the System time for + // this host. + return new Long(System.currentTimeMillis()); + } + +} diff --git a/examples/bundles/com.mycorp.examples.timeservice/.classpath b/examples/bundles/com.mycorp.examples.timeservice/.classpath new file mode 100644 index 000000000..64c5e31b7 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/examples/bundles/com.mycorp.examples.timeservice/.gitignore b/examples/bundles/com.mycorp.examples.timeservice/.gitignore new file mode 100644 index 000000000..5e56e040e --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/examples/bundles/com.mycorp.examples.timeservice/.project b/examples/bundles/com.mycorp.examples.timeservice/.project new file mode 100644 index 000000000..bb837c68c --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice/.project @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>com.mycorp.examples.timeservice</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> + </natures> +</projectDescription> diff --git a/examples/bundles/com.mycorp.examples.timeservice/.settings/org.eclipse.jdt.core.prefs b/examples/bundles/com.mycorp.examples.timeservice/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..af0f20f97 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice/.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.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/examples/bundles/com.mycorp.examples.timeservice/.settings/org.eclipse.pde.core.prefs b/examples/bundles/com.mycorp.examples.timeservice/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 000000000..f29e940a0 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/examples/bundles/com.mycorp.examples.timeservice/META-INF/MANIFEST.MF b/examples/bundles/com.mycorp.examples.timeservice/META-INF/MANIFEST.MF new file mode 100644 index 000000000..54763bc07 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Timeservice +Bundle-SymbolicName: com.mycorp.examples.timeservice +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: MyCorp, Inc. +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ActivationPolicy: lazy +Export-Package: com.mycorp.examples.timeservice;version="1.0.0" diff --git a/examples/bundles/com.mycorp.examples.timeservice/build.properties b/examples/bundles/com.mycorp.examples.timeservice/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/examples/bundles/com.mycorp.examples.timeservice/src/com/mycorp/examples/timeservice/ITimeService.java b/examples/bundles/com.mycorp.examples.timeservice/src/com/mycorp/examples/timeservice/ITimeService.java new file mode 100644 index 000000000..ec09274c5 --- /dev/null +++ b/examples/bundles/com.mycorp.examples.timeservice/src/com/mycorp/examples/timeservice/ITimeService.java @@ -0,0 +1,18 @@ +package com.mycorp.examples.timeservice; + +/** + * Example OSGi service for retrieving current time in milliseconds from January + * 1, 1970. + * + */ +public interface ITimeService { + + /** + * Get current time. + * + * @return Long current time in milliseconds since Jan 1, 1970. Will not + * return <code>null</code>. + */ + public Long getCurrentTime(); + +} |