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 82209 Details for
Bug 185477
[API] Allow client to add arbitrary headers to a manifest.mf generated by Template Wizard
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]
'Straw man' solution - i.e. let me know this is on the right lines?
patch-185447-strawman-solution.txt (text/plain), 12.62 KB, created by
Les Jones
on 2007-11-06 09:26:47 EST
(
hide
)
Description:
'Straw man' solution - i.e. let me know this is on the right lines?
Filename:
MIME Type:
Creator:
Les Jones
Created:
2007-11-06 09:26:47 EST
Size:
12.62 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.core >Index: src/org/eclipse/pde/internal/core/plugin/AbstractPluginModelBase.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/AbstractPluginModelBase.java,v >retrieving revision 1.57 >diff -u -r1.57 AbstractPluginModelBase.java >--- src/org/eclipse/pde/internal/core/plugin/AbstractPluginModelBase.java 2 Oct 2007 22:16:34 -0000 1.57 >+++ src/org/eclipse/pde/internal/core/plugin/AbstractPluginModelBase.java 6 Nov 2007 14:23:42 -0000 >@@ -27,6 +27,7 @@ > import org.eclipse.pde.core.plugin.IPluginExtensionPoint; > import org.eclipse.pde.core.plugin.IPluginImport; > import org.eclipse.pde.core.plugin.IPluginLibrary; >+import org.eclipse.pde.core.plugin.IPluginManifestInfo; > import org.eclipse.pde.core.plugin.IPluginModelBase; > import org.eclipse.pde.core.plugin.IPluginModelFactory; > import org.eclipse.pde.core.plugin.IPluginObject; >@@ -47,6 +48,17 @@ > super(); > } > >+ /** >+ * Returns information about the plugin manifest. >+ * >+ * @return null - not supported >+ */ >+ public IPluginManifestInfo getPluginManifestInfo() { >+ >+ // TODO See if we can get hold of this information via the id? >+ return null; >+ } >+ > public abstract String getInstallLocation(); > > public abstract IPluginBase createPluginBase(); >Index: text/org/eclipse/pde/internal/core/text/plugin/PluginModelBase.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/plugin/PluginModelBase.java,v >retrieving revision 1.8 >diff -u -r1.8 PluginModelBase.java >--- text/org/eclipse/pde/internal/core/text/plugin/PluginModelBase.java 13 Aug 2007 19:14:15 -0000 1.8 >+++ text/org/eclipse/pde/internal/core/text/plugin/PluginModelBase.java 6 Nov 2007 14:23:42 -0000 >@@ -21,6 +21,7 @@ > import org.eclipse.pde.core.plugin.IExtensions; > import org.eclipse.pde.core.plugin.IExtensionsModelFactory; > import org.eclipse.pde.core.plugin.IPluginBase; >+import org.eclipse.pde.core.plugin.IPluginManifestInfo; > import org.eclipse.pde.core.plugin.IPluginModelBase; > import org.eclipse.pde.core.plugin.IPluginModelFactory; > import org.eclipse.pde.internal.core.NLResourceHelper; >@@ -57,6 +58,17 @@ > return fPluginBase; > } > >+ /** >+ * Returns information about the plugin manifest. >+ * >+ * @return null - not supported >+ */ >+ public IPluginManifestInfo getPluginManifestInfo() { >+ >+ // TODO See if we can get hold of this information via the id? >+ return null; >+ } >+ > protected IWritable getRoot() { > return getPluginBase(); > } >Index: src/org/eclipse/pde/internal/core/bundle/WorkspaceBundlePluginModelBase.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bundle/WorkspaceBundlePluginModelBase.java,v >retrieving revision 1.3 >diff -u -r1.3 WorkspaceBundlePluginModelBase.java >--- src/org/eclipse/pde/internal/core/bundle/WorkspaceBundlePluginModelBase.java 29 Aug 2007 19:04:00 -0000 1.3 >+++ src/org/eclipse/pde/internal/core/bundle/WorkspaceBundlePluginModelBase.java 6 Nov 2007 14:23:42 -0000 >@@ -16,6 +16,7 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.pde.core.IEditableModel; > import org.eclipse.pde.core.plugin.IPluginBase; >+import org.eclipse.pde.core.plugin.IPluginManifestInfo; > import org.eclipse.pde.core.plugin.ISharedExtensionsModel; > import org.eclipse.pde.internal.core.ibundle.IBundle; > import org.eclipse.pde.internal.core.ibundle.IBundleModel; >@@ -37,6 +38,23 @@ > > abstract public IPluginBase createPluginBase(); > >+ /** >+ * Returns information about the plugin manifest. >+ * >+ * @return Plugin manifest information. >+ */ >+ public IPluginManifestInfo getPluginManifestInfo() { >+ >+ IBundle bundle = null; >+ bundle = getBundleModel().getBundle(); >+ >+ IPluginManifestInfo manifestInfo = null; >+ if( bundle != null ) { >+ manifestInfo = new BundleManifestInfo(bundle, this); >+ } >+ return manifestInfo; >+ } >+ > public void load(InputStream stream, boolean outOfSync) throws CoreException { > if (fPluginBase == null) > fPluginBase = createPluginBase(); >Index: src/org/eclipse/pde/internal/core/bundle/BundlePluginModelBase.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/bundle/BundlePluginModelBase.java,v >retrieving revision 1.23 >diff -u -r1.23 BundlePluginModelBase.java >--- src/org/eclipse/pde/internal/core/bundle/BundlePluginModelBase.java 2 Oct 2007 22:16:35 -0000 1.23 >+++ src/org/eclipse/pde/internal/core/bundle/BundlePluginModelBase.java 6 Nov 2007 14:23:42 -0000 >@@ -30,6 +30,7 @@ > import org.eclipse.pde.core.plugin.IPluginExtensionPoint; > import org.eclipse.pde.core.plugin.IPluginImport; > import org.eclipse.pde.core.plugin.IPluginLibrary; >+import org.eclipse.pde.core.plugin.IPluginManifestInfo; > import org.eclipse.pde.core.plugin.IPluginModelFactory; > import org.eclipse.pde.core.plugin.IPluginObject; > import org.eclipse.pde.core.plugin.ISharedExtensionsModel; >@@ -67,6 +68,24 @@ > public IResource getUnderlyingResource() { > return fBundleModel.getUnderlyingResource(); > } >+ >+ /** >+ * Returns information about the plugin manifest. >+ * >+ * @return manifest information, or null if not an OSGi based bundle. >+ */ >+ public IPluginManifestInfo getPluginManifestInfo() { >+ >+ IBundle bundle = null; >+ bundle = getBundleModel().getBundle(); >+ >+ IPluginManifestInfo manifestInfo = null; >+ if( bundle != null ) { >+ manifestInfo = new BundleManifestInfo(bundle, this); >+ } >+ return manifestInfo; >+ } >+ > /* > * (non-Javadoc) > * >Index: src/org/eclipse/pde/core/plugin/IPluginModelBase.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/core/plugin/IPluginModelBase.java,v >retrieving revision 1.20 >diff -u -r1.20 IPluginModelBase.java >--- src/org/eclipse/pde/core/plugin/IPluginModelBase.java 3 Apr 2006 19:48:17 -0000 1.20 >+++ src/org/eclipse/pde/core/plugin/IPluginModelBase.java 6 Nov 2007 14:23:42 -0000 >@@ -67,6 +67,14 @@ > * @return a top-level model object > */ > IPluginBase getPluginBase(boolean createIfMissing); >+ >+ /** >+ * Returns information about the plugin manifest. >+ * >+ * @return manifest information, or null if not an OSGi based bundle. >+ */ >+ IPluginManifestInfo getPluginManifestInfo(); >+ > /** > * Returns </samp>true</samp> if this model is currently enabled. > * >Index: src/org/eclipse/pde/core/plugin/IPluginManifestInfo.java >=================================================================== >RCS file: src/org/eclipse/pde/core/plugin/IPluginManifestInfo.java >diff -N src/org/eclipse/pde/core/plugin/IPluginManifestInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/core/plugin/IPluginManifestInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+package org.eclipse.pde.core.plugin; >+ >+/** >+ * Model representing information held within the manifest. >+ * >+ * @author Les Jones >+ */ >+public interface IPluginManifestInfo { >+ >+ /** >+ * Get the value of a generic manifest header. >+ * @param name The name of the header >+ * @return The value of the header >+ * @see org.eclipse.pde.internal.core.ibundle.IBundle#getHeader(String) >+ */ >+ String getHeader(String name); >+ >+ /** >+ * Set the value of a generic manifest header. >+ * @param name The name of the header >+ * @param value The value of the header >+ * @see org.eclipse.pde.internal.core.ibundle.IBundle#getHeader(String) >+ */ >+ void setHeader(String name, String value); >+ >+} >Index: src/org/eclipse/pde/internal/core/bundle/BundleManifestInfo.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/core/bundle/BundleManifestInfo.java >diff -N src/org/eclipse/pde/internal/core/bundle/BundleManifestInfo.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/core/bundle/BundleManifestInfo.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,153 @@ >+package org.eclipse.pde.internal.core.bundle; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.pde.core.plugin.IFragment; >+import org.eclipse.pde.core.plugin.IPlugin; >+import org.eclipse.pde.core.plugin.IPluginBase; >+import org.eclipse.pde.core.plugin.IPluginManifestInfo; >+import org.eclipse.pde.core.plugin.IPluginObject; >+import org.eclipse.pde.internal.core.ibundle.IBundle; >+import org.eclipse.pde.core.IIdentifiable; >+import org.eclipse.pde.core.IModelChangeProvider; >+import org.osgi.framework.Constants; >+ >+/** >+ * Implementation of Manifest information for the plug-in model. >+ * >+ * TODO: Consider refactoring existing models to utilise this class as the point >+ * that changes the manifest. >+ * >+ * @author Les Jones >+ */ >+public class BundleManifestInfo implements IPluginManifestInfo { >+ >+ /** Underlying bundle representation */ >+ private IBundle fBundle = null; >+ >+ /** Object interested in change events */ >+ private IModelChangeProvider fModelChangeProvider = null; >+ >+ /** >+ * The header event type map links a header with the event that needs to be >+ * fired to indicate that the value has been updated. >+ */ >+ private Map headerEventTypeMap = null; >+ >+ /** >+ * Create a new manifest info instance using the specified bundle. >+ * >+ * @param bundle >+ * Bundle to refer to. >+ */ >+ public BundleManifestInfo(IBundle bundle) { >+ >+ this(bundle, null); >+ } >+ >+ >+ /** >+ * Create a new manifest info instance using the specified bundle, providing model >+ * update information to the specified model change provider. >+ * >+ * @param bundle >+ * Bundle to refer to. >+ * @param modelChangeProvider >+ * object where model changes should be fired >+ */ >+ public BundleManifestInfo(IBundle bundle, >+ IModelChangeProvider modelChangeProvider) { >+ >+ fBundle = bundle; >+ >+ initializeManagedHeaders(); >+ } >+ >+ /** >+ * Initialize the bundle headers that are known to be managed. >+ * i.e. those that require a model update. >+ */ >+ private void initializeManagedHeaders() { >+ >+ headerEventTypeMap = new HashMap(); >+ >+ headerEventTypeMap.put(Constants.BUNDLE_ACTIVATOR, IPlugin.P_CLASS_NAME); >+ headerEventTypeMap.put(Constants.BUNDLE_VERSION, IPluginBase.P_VERSION); >+ headerEventTypeMap.put(Constants.BUNDLE_NAME, IPluginObject.P_NAME); >+ headerEventTypeMap.put(Constants.BUNDLE_VENDOR, IPluginBase.P_PROVIDER); >+ headerEventTypeMap.put(Constants.FRAGMENT_HOST, IFragment.P_PLUGIN_ID); >+ headerEventTypeMap.put(Constants.BUNDLE_SYMBOLICNAME, IIdentifiable.P_ID); >+ } >+ >+ /** >+ * Get the value of a generic manifest header. >+ * @param name The name of the header >+ * @return The value of the header >+ * @see org.eclipse.pde.internal.core.ibundle.IBundle#getHeader(String) >+ */ >+ public String getHeader(String name) { >+ >+ if (fBundle == null) { >+ return null; >+ } >+ >+ return fBundle.getHeader(name); >+ } >+ >+ /** >+ * Set the value of a generic manifest header. >+ * @param name The name of the header >+ * @param value The value of the header >+ * @see org.eclipse.pde.internal.core.ibundle.IBundle#getHeader(String) >+ */ >+ public void setHeader(String name, String value) { >+ >+ if (fBundle == null) { >+ return; >+ } >+ >+ String oldValue = fBundle.getHeader(name); >+ >+ fBundle.setHeader(name, value); >+ >+ fireHeaderUpdated(name, oldValue, value); >+ } >+ >+ /** >+ * Fire an event to indicate to a model that a header has been updated. Two >+ * types of event can be fired, one where the property name is the name of >+ * the header, and another where the name is mapped from the header, e.g. >+ * mapping Bundle-Name (Constants.BUNDLE_NAME) to name >+ * (IPluginObject.P_NAME) >+ * >+ * If no model change provider is associated with this manifest model, this >+ * method does nothing. >+ * >+ * TODO: Check whether this is actually required - the Bundle >+ * implementations appear to fire their own events. >+ * >+ * @param header The name of the header to be updated >+ * @param oldValue The old value of the header >+ * @param newValue The new value of the header >+ */ >+ private void fireHeaderUpdated(String header, String oldValue, String newValue) { >+ >+ if (fModelChangeProvider == null) { >+ // early exit if no change provider >+ return; >+ } >+ >+ // Fire an event mapped from the header name >+ if (headerEventTypeMap.containsKey(header)) { >+ String eventType = (String) headerEventTypeMap.get(header); >+ >+ fModelChangeProvider.fireModelObjectChanged(this, eventType, >+ oldValue, newValue); >+ } >+ >+ // Fire the actual event for the header >+ fModelChangeProvider.fireModelObjectChanged(this, header, oldValue, >+ newValue); >+ } >+}
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 185477
:
82209
|
82210
|
82311