summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2009-02-19 04:01:11 (EST)
committerCarsten Drossel2009-02-19 04:01:11 (EST)
commitf2413595fa1cc30d3399e31bab3abbd1780a7ff8 (patch)
tree7e55d7a5b3abd6c5fad118310aa2c086a095073f
parentef326d503e4fa965788dd4c5f64d9a4200923d1f (diff)
downloadorg.eclipse.riena-f2413595fa1cc30d3399e31bab3abbd1780a7ff8.zip
org.eclipse.riena-f2413595fa1cc30d3399e31bab3abbd1780a7ff8.tar.gz
org.eclipse.riena-f2413595fa1cc30d3399e31bab3abbd1780a7ff8.tar.bz2
overriding node provider via extension point instead of service registration in Activator (caused sequencing problems)
-rw-r--r--org.eclipse.riena.navigation/plugin.xml15
-rw-r--r--org.eclipse.riena.navigation/schema/org.eclipse.riena.navigation.navigationNodeProvider.exsd75
-rw-r--r--org.eclipse.riena.navigation/src/org/eclipse/riena/internal/navigation/Activator.java13
-rw-r--r--org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNodeProviderAccessor.java63
-rw-r--r--org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNodeProviderAccessorWiring.java10
5 files changed, 148 insertions, 28 deletions
diff --git a/org.eclipse.riena.navigation/plugin.xml b/org.eclipse.riena.navigation/plugin.xml
index 6da7369..f0ed489 100644
--- a/org.eclipse.riena.navigation/plugin.xml
+++ b/org.eclipse.riena.navigation/plugin.xml
@@ -6,7 +6,11 @@
id="org.eclipse.riena.navigation.assemblies"
name="navigation assemblies"
schema="schema/org.eclipse.riena.navigation.assembly.exsd"/>
-
+ <extension-point
+ id="org.eclipse.riena.navigation.navigationNodeProvider"
+ name="navigation node provider"
+ schema="schema/org.eclipse.riena.navigation.navigationNodeProvider.exsd"/>
+
<extension point="org.eclipse.core.variables.dynamicVariables">
<variable
description="Navigation node id. Argument MUST be one of 'typeId' or 'instanceId'."
@@ -24,5 +28,14 @@
resolver="org.eclipse.riena.navigation.model.ThreadLocalMapResolver"
supportsArgument="true"/>
</extension>
+
+ <extension
+ point="org.eclipse.riena.navigation.navigationNodeProvider">
+ <navigationNodeProvider
+ id="defaultNavigationNodeProvider"
+ class="org.eclipse.riena.navigation.model.NavigationNodeProvider"
+ priority="-100">
+ </navigationNodeProvider>
+ </extension>
</plugin>
diff --git a/org.eclipse.riena.navigation/schema/org.eclipse.riena.navigation.navigationNodeProvider.exsd b/org.eclipse.riena.navigation/schema/org.eclipse.riena.navigation.navigationNodeProvider.exsd
new file mode 100644
index 0000000..972489b
--- /dev/null
+++ b/org.eclipse.riena.navigation/schema/org.eclipse.riena.navigation.navigationNodeProvider.exsd
@@ -0,0 +1,75 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.riena.navigation" xmlns="http://www.w3.org/2001/XMLSchema">
+ <annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.riena.navigation" id="org.eclipse.riena.navigation.navigationNodeProvider" name="navigationNodeProvider"/>
+ </appInfo>
+ <documentation>
+ Configures which class will be used to create nodes for the application model tree.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="navigationNodeProvider"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ A fully qualified identifier of the target extension point.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ An optional identifier for the extension.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ An optional name for the extension.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="navigationNodeProvider">
+ <complexType>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ An optional identifier for the implementation.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The implementation of INavigationNodeProvider to be used.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.riena.navigation.INavigationNodeProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="priority" type="string" use="default" value="0">
+ <annotation>
+ <documentation>
+ The priority of this implenentation among others. Integer.MIN_VALUE has the least chance to be selected, Integer.MAX_VALUE would most probably be used. Default is 0.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+</schema>
diff --git a/org.eclipse.riena.navigation/src/org/eclipse/riena/internal/navigation/Activator.java b/org.eclipse.riena.navigation/src/org/eclipse/riena/internal/navigation/Activator.java
index 433b7b4..1d5abc8 100644
--- a/org.eclipse.riena.navigation/src/org/eclipse/riena/internal/navigation/Activator.java
+++ b/org.eclipse.riena.navigation/src/org/eclipse/riena/internal/navigation/Activator.java
@@ -10,10 +10,7 @@
*******************************************************************************/
package org.eclipse.riena.internal.navigation;
-import org.eclipse.riena.core.RienaConstants;
import org.eclipse.riena.core.RienaPlugin;
-import org.eclipse.riena.navigation.INavigationNodeProvider;
-import org.eclipse.riena.navigation.model.NavigationNodeProvider;
import org.osgi.framework.BundleContext;
/**
@@ -26,7 +23,6 @@ public class Activator extends RienaPlugin {
// The shared instance
private static Activator plugin;
- private INavigationNodeProvider service1 = null;
/**
* The constructor
@@ -44,11 +40,6 @@ public class Activator extends RienaPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
Activator.plugin = this;
-
- service1 = new NavigationNodeProvider();
-
- context.registerService(INavigationNodeProvider.class.getName(), service1, RienaConstants
- .newDefaultServiceProperties());
}
/*
@@ -60,10 +51,6 @@ public class Activator extends RienaPlugin {
@Override
public void stop(BundleContext context) throws Exception {
Activator.plugin = null;
- if (service1 != null) {
- service1.cleanUp();
- service1 = null;
- }
super.stop(context);
}
diff --git a/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNodeProviderAccessor.java b/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNodeProviderAccessor.java
index 1ca9d86..d7c9837 100644
--- a/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNodeProviderAccessor.java
+++ b/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNodeProviderAccessor.java
@@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.riena.navigation.model;
+import org.eclipse.riena.core.injector.extension.ExtensionInterface;
import org.eclipse.riena.core.util.ServiceAccessor;
import org.eclipse.riena.core.wire.WireWith;
-import org.eclipse.riena.internal.core.ignore.Nop;
import org.eclipse.riena.internal.navigation.Activator;
import org.eclipse.riena.navigation.INavigationNodeProvider;
@@ -24,26 +24,67 @@ public final class NavigationNodeProviderAccessor extends ServiceAccessor<INavig
private final static NavigationNodeProviderAccessor NNPA = new NavigationNodeProviderAccessor();
+ private INavigationNodeProvider provider;
+
/**
* Default Constructor
*/
private NavigationNodeProviderAccessor() {
- super(Activator.getDefault().getContext(), new ServiceAccessor.IBindHook<INavigationNodeProvider>() {
+ super(Activator.getDefault().getContext());
+ }
- public void onBind(INavigationNodeProvider service) {
- Nop.reason("No interest!"); //$NON-NLS-1$
- }
+ /**
+ * Return the INavigationNodeProvider configured via extensions.
+ *
+ * @return An INavigationNodeProvider.
+ */
+ INavigationNodeProvider getConfiguredNavigationNodeProvider() {
+ return provider;
+ }
+
+ public static INavigationNodeProvider getNavigationNodeProvider() {
+ return NNPA.getService();
+ }
- public void onUnbind(INavigationNodeProvider service) {
- // TODO Is this a good idea to let the clean-up be done here! Shouldn´t the service cleaned-up when it is going done?
- service.cleanUp();
+ /**
+ * Configure the navigation node provider to be used. If there is more than
+ * one implementation we take the one having the highest priority according
+ * to attribute 'priority'. If the priority is not specified it is assumed
+ * to be zero (the default value). All implementations sharing the same
+ * priority are considered equivalent and an arbitrary one is chosen.
+ *
+ * @param availableExtensions
+ * Array containing all currently available navigation node
+ * provider implementations. This may change over time as plugins
+ * are activated or deactivated
+ */
+ public void update(INavigationNodeProviderExtension[] availableExtensions) {
+
+ INavigationNodeProviderExtension found = null;
+ int maxPriority = Integer.MIN_VALUE;
+
+ provider = null;
+ for (INavigationNodeProviderExtension probe : availableExtensions) {
+ int p = probe.getPriority();
+ if (found == null || p > maxPriority) {
+ found = probe;
+ maxPriority = p;
}
- });
+ }
+ if (found != null) {
+ provider = found.createClass();
+ }
}
- public static INavigationNodeProvider getNavigationNodeProvider() {
- return NNPA.getService();
+ @ExtensionInterface
+ public interface INavigationNodeProviderExtension {
+
+ String getId();
+
+ int getPriority();
+
+ INavigationNodeProvider createClass();
}
}
diff --git a/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNodeProviderAccessorWiring.java b/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNodeProviderAccessorWiring.java
index 9ceb664..e48f5ac 100644
--- a/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNodeProviderAccessorWiring.java
+++ b/org.eclipse.riena.navigation/src/org/eclipse/riena/navigation/model/NavigationNodeProviderAccessorWiring.java
@@ -12,7 +12,7 @@ package org.eclipse.riena.navigation.model;
import org.eclipse.riena.core.injector.Inject;
import org.eclipse.riena.core.wire.AbstractWiring;
-import org.eclipse.riena.navigation.INavigationNodeProvider;
+import org.eclipse.riena.navigation.model.NavigationNodeProviderAccessor.INavigationNodeProviderExtension;
import org.osgi.framework.BundleContext;
/**
@@ -20,8 +20,12 @@ import org.osgi.framework.BundleContext;
*/
public class NavigationNodeProviderAccessorWiring extends AbstractWiring {
+ private static final String EXTENSION_POINT_ID = "org.eclipse.riena.navigation.navigationNodeProvider"; //$NON-NLS-1$
+
public void wire(Object bean, BundleContext context) {
- Inject.service(INavigationNodeProvider.class).useRanking().into(bean).andStart(context);
+ Inject.extension(EXTENSION_POINT_ID).useType(INavigationNodeProviderExtension.class).into(bean).andStart(
+ context);
+ NavigationNodeProviderAccessor accessor = (NavigationNodeProviderAccessor) bean;
+ accessor.bind(accessor.getConfiguredNavigationNodeProvider());
}
-
}