Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 139813 Details for
Bug 281148
Get rid of org.eclipse.e4.services extension point
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix
patch.txt (text/plain), 13.27 KB, created by
John Arthorne
on 2009-06-22 17:28:48 EDT
(
hide
)
Description:
Fix
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2009-06-22 17:28:48 EDT
Size:
13.27 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.e4.core.services >Index: schema/org.eclipse.e4.services.exsd >=================================================================== >RCS file: schema/org.eclipse.e4.services.exsd >diff -N schema/org.eclipse.e4.services.exsd >--- schema/org.eclipse.e4.services.exsd 14 Jan 2009 19:53:11 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,120 +0,0 @@ >-<?xml version='1.0' encoding='UTF-8'?> >-<!-- Schema file written by PDE --> >-<schema targetNamespace="org.eclipse.e4.workbench.core" xmlns="http://www.w3.org/2001/XMLSchema"> >-<annotation> >- <appinfo> >- <meta.schema plugin="org.eclipse.e4.workbench.core" id="org.eclipse.e4.services" name="E4 Services"/> >- </appinfo> >- <documentation> >- [Enter description of this extension point.] >- </documentation> >- </annotation> >- >- <element name="extension"> >- <annotation> >- <appinfo> >- <meta.element /> >- </appinfo> >- </annotation> >- <complexType> >- <sequence> >- <element ref="servicefactory"/> >- </sequence> >- <attribute name="point" type="string" use="required"> >- <annotation> >- <documentation> >- >- </documentation> >- </annotation> >- </attribute> >- <attribute name="id" type="string"> >- <annotation> >- <documentation> >- >- </documentation> >- </annotation> >- </attribute> >- <attribute name="name" type="string"> >- <annotation> >- <documentation> >- >- </documentation> >- <appinfo> >- <meta.attribute translatable="true"/> >- </appinfo> >- </annotation> >- </attribute> >- </complexType> >- </element> >- >- <element name="servicefactory"> >- <complexType> >- <sequence minOccurs="1" maxOccurs="unbounded"> >- <element ref="service"/> >- </sequence> >- <attribute name="class" type="string" use="required"> >- <annotation> >- <documentation> >- >- </documentation> >- <appinfo> >- <meta.attribute kind="java" basedOn="org.eclipse.e4.core.services.ComputedValue:"/> >- </appinfo> >- </annotation> >- </attribute> >- </complexType> >- </element> >- >- <element name="service"> >- <complexType> >- <attribute name="api" type="string" use="required"> >- <annotation> >- <documentation> >- >- </documentation> >- <appinfo> >- <meta.attribute kind="java"/> >- </appinfo> >- </annotation> >- </attribute> >- </complexType> >- </element> >- >- <annotation> >- <appinfo> >- <meta.section type="since"/> >- </appinfo> >- <documentation> >- [Enter the first release in which this extension point appears.] >- </documentation> >- </annotation> >- >- <annotation> >- <appinfo> >- <meta.section type="examples"/> >- </appinfo> >- <documentation> >- [Enter extension point usage example here.] >- </documentation> >- </annotation> >- >- <annotation> >- <appinfo> >- <meta.section type="apiinfo"/> >- </appinfo> >- <documentation> >- [Enter API information here.] >- </documentation> >- </annotation> >- >- <annotation> >- <appinfo> >- <meta.section type="implementation"/> >- </appinfo> >- <documentation> >- [Enter information about supplied implementation of this extension point.] >- </documentation> >- </annotation> >- >- >-</schema> >Index: src/org/eclipse/e4/internal/core/services/osgi/OSGiContextStrategy.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/internal/core/services/osgi/OSGiContextStrategy.java,v >retrieving revision 1.1 >diff -u -r1.1 OSGiContextStrategy.java >--- src/org/eclipse/e4/internal/core/services/osgi/OSGiContextStrategy.java 2 Apr 2009 15:50:13 -0000 1.1 >+++ src/org/eclipse/e4/internal/core/services/osgi/OSGiContextStrategy.java 22 Jun 2009 21:26:43 -0000 >@@ -10,11 +10,19 @@ > *******************************************************************************/ > package org.eclipse.e4.internal.core.services.osgi; > >-import java.util.*; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+import java.util.WeakHashMap; > import org.eclipse.e4.core.services.IDisposable; >+import org.eclipse.e4.core.services.context.IContextFunction; > import org.eclipse.e4.core.services.context.IEclipseContext; > import org.eclipse.e4.core.services.context.spi.ILookupStrategy; >-import org.osgi.framework.*; >+import org.osgi.framework.BundleContext; >+import org.osgi.framework.Constants; >+import org.osgi.framework.InvalidSyntaxException; >+import org.osgi.framework.ServiceReference; > import org.osgi.util.tracker.ServiceTracker; > import org.osgi.util.tracker.ServiceTrackerCustomizer; > >@@ -25,11 +33,11 @@ > */ > public class OSGiContextStrategy implements ILookupStrategy, IDisposable, ServiceTrackerCustomizer { > class ServiceData { >- //the service name >+ // the service name > String name; > > ServiceTracker tracker; >- //the contexts using this service (IEclipseContext -> null) >+ // the contexts using this service (IEclipseContext -> null) > final Map users = new WeakHashMap(); > > ServiceData(String name) { >@@ -57,7 +65,8 @@ > Object newValue = bundleContext.getService(reference); > if (newValue == null) > return null; >- //for performance we store the concrete service object with each context that requested it >+ // for performance we store the concrete service object with each >+ // context that requested it > ServiceData data = (ServiceData) services.get(name); > for (Iterator it = data.users.keySet().iterator(); it.hasNext();) > ((IEclipseContext) it.next()).set(name, newValue); >@@ -65,14 +74,14 @@ > } > > /** >- * Discards any services that are no longer used by any strongly >- * reachable contexts. >+ * Discards any services that are no longer used by any strongly reachable >+ * contexts. > */ > private void cleanReferences() { > synchronized (services) { > for (Iterator it = services.values().iterator(); it.hasNext();) { > ServiceData data = (ServiceData) it.next(); >- //if there are no more references, discard the service >+ // if there are no more references, discard the service > if (data.users.isEmpty()) { > data.tracker.close(); > it.remove(); >@@ -98,10 +107,23 @@ > cleanReferences(); > ServiceData data = (ServiceData) services.get(name); > if (data == null) { >+ // see if there is an IContextFunction registered for this name >+ try { >+ ServiceReference[] refs = bundleContext.getServiceReferences( >+ IContextFunction.SERVICE_NAME, "(" //$NON-NLS-1$ >+ + IContextFunction.SERVICE_CONTEXT_KEY + '=' + name + ')'); >+ if (refs != null && refs.length > 0) >+ return bundleContext.getService(refs[0]); >+ } catch (InvalidSyntaxException e) { >+ // the name is not a valid service name, so just carry on >+ } >+ >+ // create a tracker to retrieve the service with the given name > data = new ServiceData(name); > data.tracker = new ServiceTracker(bundleContext, name, this); > services.put(name, data); >- //just opening a tracker will cause values to be set by the tracker callback methods >+ // just opening a tracker will cause values to be set by the tracker >+ // callback methods > data.tracker.open(); > } > data.addContext(originatingContext); >@@ -117,7 +139,7 @@ > > public void removedService(ServiceReference reference, Object service) { > String name = serviceName(reference); >- //must set to null rather than removing so injection continues to work >+ // must set to null rather than removing so injection continues to work > ServiceData data = (ServiceData) services.get(name); > for (Iterator it = data.users.keySet().iterator(); it.hasNext();) > ((IEclipseContext) it.next()).set(name, null); >Index: src/org/eclipse/e4/core/services/context/IContextFunction.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/context/IContextFunction.java,v >retrieving revision 1.1 >diff -u -r1.1 IContextFunction.java >--- src/org/eclipse/e4/core/services/context/IContextFunction.java 2 Apr 2009 15:50:13 -0000 1.1 >+++ src/org/eclipse/e4/core/services/context/IContextFunction.java 22 Jun 2009 21:26:43 -0000 >@@ -12,31 +12,61 @@ > package org.eclipse.e4.core.services.context; > > import org.eclipse.e4.core.services.context.spi.ContextFunction; >+import org.osgi.framework.BundleContext; > > /** >- * A context function encapsulates evaluation of some code within an {@link IEclipseContext}. >- * The result of the function must be derived purely from the provided arguments and >- * context objects, and must be free from side-effects other than the function's return value. >- * In particular, the function must be idempotent - subsequent invocations of the same function >+ * A context function encapsulates evaluation of some code within an >+ * {@link IEclipseContext}. The result of the function must be derived purely >+ * from the provided arguments and context objects, and must be free from >+ * side-effects other than the function's return value. In particular, the >+ * function must be idempotent - subsequent invocations of the same function > * with the same inputs must produce the same result. > * <p> >- * A common use for context functions is as a place holder for an object that has not yet >- * been created. These place holders can be stored as values in an {@link IEclipseContext}, >- * allowing the concrete value they represent to be computed lazily only when requested. >+ * A common use for context functions is as a place holder for an object that >+ * has not yet been created. These place holders can be stored as values in an >+ * {@link IEclipseContext}, allowing the concrete value they represent to be >+ * computed lazily only when requested. >+ * </p> >+ * <p> >+ * Context functions can optionally be registered as OSGi services. Context >+ * implementations may use such registered services to seed context instances >+ * with initial values. Registering your context function as a service is a >+ * signal that contexts are free to add an instance of your function to their >+ * context automatically, using the key specified by the >+ * {@link #SERVICE_CONTEXT_KEY} service property. > * </p> > * > * @see IEclipseContext#set(String, Object) >- * @noimplement This interface is not intended to be implemented by clients. Function >- * implementations must subclass {@link ContextFunction} instead. >+ * @noimplement This interface is not intended to be implemented by clients. >+ * Function implementations must subclass {@link ContextFunction} >+ * instead. > */ > public interface IContextFunction { > /** >- * Evaluates the function based on the provided arguments and context to produce >- * a consistent result. >+ * The OSGi service name for a context function service. This name can be >+ * used to obtain instances of the service. >+ * >+ * @see BundleContext#getServiceReference(String) >+ */ >+ public static final String SERVICE_NAME = IContextFunction.class.getName(); >+ >+ /** >+ * An OSGi service property used to indicate the context key this function >+ * should be registered in. >+ * >+ * @see BundleContext#getServiceReference(String) >+ */ >+ public static final String SERVICE_CONTEXT_KEY = "service.context.key"; //$NON-NLS-1$ >+ >+ /** >+ * Evaluates the function based on the provided arguments and context to >+ * produce a consistent result. > * >- * @param context The context in which to perform the value computation. >- * @param arguments The arguments required to compute the value, or >- * <code>null</code> if no arguments are applicable >+ * @param context >+ * The context in which to perform the value computation. >+ * @param arguments >+ * The arguments required to compute the value, or >+ * <code>null</code> if no arguments are applicable > * @return The concrete value. > */ > public Object compute(IEclipseContext context, Object[] arguments); >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.core.services/plugin.xml,v >retrieving revision 1.1 >diff -u -r1.1 plugin.xml >--- plugin.xml 11 Nov 2008 18:15:27 -0000 1.1 >+++ plugin.xml 22 Jun 2009 21:26:43 -0000 >@@ -1,7 +1,5 @@ > <?xml version="1.0" encoding="UTF-8"?> > <?eclipse version="3.2"?> > <plugin> >- <extension-point id="org.eclipse.e4.services" name="E4 Services" schema="schema/org.eclipse.e4.services.exsd"/> > <extension-point id="org.eclipse.e4.languages" name="E4 Languages" schema="schema/org.eclipse.e4.languages.exsd"/> >- > </plugin>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 281148
: 139813 |
139814