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 43635 Details for
Bug 143229
[project explorer] Web DD loading issues during web service indexing
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]
Patches several plugins to drive registration through an extension point
bug143229.txt (text/plain), 37.65 KB, created by
Michael D. Elder
on 2006-06-06 15:30:30 EDT
(
hide
)
Description:
Patches several plugins to drive registration through an extension point
Filename:
MIME Type:
Creator:
Michael D. Elder
Created:
2006-06-06 15:30:30 EDT
Size:
37.65 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jst.j2ee.webservice >Index: plugin.xml >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.webservice/plugin.xml,v >retrieving revision 1.18 >diff -u -r1.18 plugin.xml >--- plugin.xml 2 Dec 2005 21:17:23 -0000 1.18 >+++ plugin.xml 6 Jun 2006 19:19:22 -0000 >@@ -102,4 +102,16 @@ > helperClass="org.eclipse.jst.j2ee.internal.webservice.helper.WSDLServiceHelperImpl"> > </wsdlHelper> > </extension> >+ <extension >+ point="org.eclipse.wst.common.modulecore.resourceFactories"> >+ <resourceFactory >+ class="org.eclipse.jst.j2ee.webservice.internal.wsdd.WsddResourceFactory" >+ shortSegment="webservices.xml"/> >+ <resourceFactory >+ class="org.eclipse.jst.j2ee.webservice.internal.wsdd.WsddResourceFactory" >+ shortSegment="webservices-temp.xml"/> >+ <resourceFactory >+ class="org.eclipse.jst.j2ee.webservice.wsclient.internal.impl.WebServicesClientResourceFactory" >+ shortSegment="webservicesclient.xml"/> >+ </extension> > </plugin> >Index: webservice/org/eclipse/jst/j2ee/internal/webservice/plugin/WebServicePlugin.java >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.webservice/webservice/org/eclipse/jst/j2ee/internal/webservice/plugin/WebServicePlugin.java,v >retrieving revision 1.10 >diff -u -r1.10 WebServicePlugin.java >--- webservice/org/eclipse/jst/j2ee/internal/webservice/plugin/WebServicePlugin.java 1 Dec 2005 22:20:54 -0000 1.10 >+++ webservice/org/eclipse/jst/j2ee/internal/webservice/plugin/WebServicePlugin.java 6 Jun 2006 19:19:22 -0000 >@@ -206,8 +206,6 @@ > */ > public void start(BundleContext context) throws Exception { > super.start(context); >- WsddResourceFactory.register(WTPResourceFactoryRegistry.INSTANCE); >- WebServicesClientResourceFactory.register(WTPResourceFactoryRegistry.INSTANCE); > } > > /** >#P org.eclipse.jst.j2ee.ejb >Index: ejb/org/eclipse/jst/j2ee/ejb/internal/plugin/EjbPlugin.java >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.ejb/ejb/org/eclipse/jst/j2ee/ejb/internal/plugin/EjbPlugin.java,v >retrieving revision 1.14 >diff -u -r1.14 EjbPlugin.java >--- ejb/org/eclipse/jst/j2ee/ejb/internal/plugin/EjbPlugin.java 1 Dec 2005 22:24:15 -0000 1.14 >+++ ejb/org/eclipse/jst/j2ee/ejb/internal/plugin/EjbPlugin.java 6 Jun 2006 19:19:22 -0000 >@@ -175,8 +175,7 @@ > } > > public void start(BundleContext context) throws Exception { >- super.start(context); >- EJBJarResourceFactory.register(WTPResourceFactoryRegistry.INSTANCE); >+ super.start(context); > } > > public String getString(String key, boolean translate) { >#P org.eclipse.jst.j2ee >Index: j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPlugin.java >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPlugin.java,v >retrieving revision 1.38 >diff -u -r1.38 J2EEPlugin.java >--- j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPlugin.java 19 Apr 2006 19:17:35 -0000 1.38 >+++ j2eeplugin/org/eclipse/jst/j2ee/internal/plugin/J2EEPlugin.java 6 Jun 2006 19:19:23 -0000 >@@ -492,9 +492,7 @@ > IAdapterManager manager = Platform.getAdapterManager(); > manager.registerAdapters(new EarEditAdapterFactory(), ArtifactEditModel.class); > manager.registerAdapters(new AppClientEditAdapterFactory(), ArtifactEditModel.class); >- ApplicationResourceFactory.register(WTPResourceFactoryRegistry.INSTANCE); >- ApplicationClientResourceFactory.register(WTPResourceFactoryRegistry.INSTANCE); >- WSDLServiceExtensionRegistry.getInstance(); >+ WSDLServiceExtensionRegistry.getInstance(); > > manager.registerAdapters(new VirtualArchiveComponentAdapterFactory(), VirtualArchiveComponent.class ); > >#P org.eclipse.jst.j2ee.core >Index: mofj2ee/org/eclipse/jst/j2ee/application/internal/impl/ApplicationResourceFactory.java >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.core/mofj2ee/org/eclipse/jst/j2ee/application/internal/impl/ApplicationResourceFactory.java,v >retrieving revision 1.3 >diff -u -r1.3 ApplicationResourceFactory.java >--- mofj2ee/org/eclipse/jst/j2ee/application/internal/impl/ApplicationResourceFactory.java 24 May 2006 15:42:10 -0000 1.3 >+++ mofj2ee/org/eclipse/jst/j2ee/application/internal/impl/ApplicationResourceFactory.java 6 Jun 2006 19:19:23 -0000 >@@ -37,6 +37,15 @@ > J2EEXmlDtDEntityResolver.registerDtD(J2EEConstants.J2EE_1_4_XSD_SHORT_NAME, J2EEConstants.J2EE_1_4_XSD_SHORT_NAME); > } > >+ >+ >+ /** >+ * @param aRendererFactory >+ */ >+ public ApplicationResourceFactory() { >+ super(RendererFactory.getDefaultRendererFactory()); >+ } >+ > /** > * @param aRendererFactory > */ >Index: mofj2ee/org/eclipse/jst/j2ee/client/internal/impl/ApplicationClientResourceFactory.java >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.core/mofj2ee/org/eclipse/jst/j2ee/client/internal/impl/ApplicationClientResourceFactory.java,v >retrieving revision 1.3 >diff -u -r1.3 ApplicationClientResourceFactory.java >--- mofj2ee/org/eclipse/jst/j2ee/client/internal/impl/ApplicationClientResourceFactory.java 24 May 2006 15:42:10 -0000 1.3 >+++ mofj2ee/org/eclipse/jst/j2ee/client/internal/impl/ApplicationClientResourceFactory.java 6 Jun 2006 19:19:23 -0000 >@@ -38,6 +38,13 @@ > > /** > * Constructor for ApplicationClientResourceFactory. >+ */ >+ public ApplicationClientResourceFactory() { >+ super(RendererFactory.getDefaultRendererFactory()); >+ } >+ >+ /** >+ * Constructor for ApplicationClientResourceFactory. > * @param aRendererFactory > */ > public ApplicationClientResourceFactory(RendererFactory aRendererFactory) { >Index: mofj2ee/org/eclipse/jst/j2ee/ejb/internal/impl/EJBJarResourceFactory.java >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.core/mofj2ee/org/eclipse/jst/j2ee/ejb/internal/impl/EJBJarResourceFactory.java,v >retrieving revision 1.3 >diff -u -r1.3 EJBJarResourceFactory.java >--- mofj2ee/org/eclipse/jst/j2ee/ejb/internal/impl/EJBJarResourceFactory.java 24 May 2006 15:42:10 -0000 1.3 >+++ mofj2ee/org/eclipse/jst/j2ee/ejb/internal/impl/EJBJarResourceFactory.java 6 Jun 2006 19:19:23 -0000 >@@ -39,6 +39,12 @@ > J2EEXmlDtDEntityResolver.registerDtD(J2EEConstants.EJB_JAR_SCHEMA_LOC_2_1, "ejb-jar_2_1.xsd"); //$NON-NLS-1$ > } > >+ /** >+ */ >+ public EJBJarResourceFactory() { >+ super(RendererFactory.getDefaultRendererFactory()); >+ } >+ > /** > * @param aRendererFactory > */ >Index: mofj2ee/org/eclipse/jst/j2ee/webapplication/internal/impl/WebAppResourceFactory.java >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.core/mofj2ee/org/eclipse/jst/j2ee/webapplication/internal/impl/WebAppResourceFactory.java,v >retrieving revision 1.3 >diff -u -r1.3 WebAppResourceFactory.java >--- mofj2ee/org/eclipse/jst/j2ee/webapplication/internal/impl/WebAppResourceFactory.java 24 May 2006 15:42:10 -0000 1.3 >+++ mofj2ee/org/eclipse/jst/j2ee/webapplication/internal/impl/WebAppResourceFactory.java 6 Jun 2006 19:19:23 -0000 >@@ -48,11 +48,17 @@ > J2EEXmlDtDEntityResolver.registerDtD(J2EEConstants.JSP_SCHEMA_LOC_2_0, "jsp_2_0.xsd"); //$NON-NLS-1$ > } > >+ /** >+ */ >+ public WebAppResourceFactory() { >+ super(RendererFactory.getDefaultRendererFactory()); >+ } >+ > /** > * @param aRendererFactory > */ > public WebAppResourceFactory(RendererFactory aRendererFactory) { >- super(aRendererFactory); >+ super(aRendererFactory); > } > > /* (non-Javadoc) >@@ -65,7 +71,7 @@ > /** > * Register myself with the Resource.Factory.Registry > */ >- public static void registerWith(RendererFactory aRendererFactory) { >+ public static void registerWith(RendererFactory aRendererFactory) { > J2EEResourceFactoryRegistry.INSTANCE.registerLastFileSegment(J2EEConstants.WEBAPP_DD_SHORT_NAME, new WebAppResourceFactory(aRendererFactory)); > } > >@@ -81,11 +87,13 @@ > * register using the default renderer factory. > * @see #registerWith(RendererFactory) > */ >- public static void register(FileNameResourceFactoryRegistry aRegistry) { >+ public static void register(FileNameResourceFactoryRegistry aRegistry) { > aRegistry.registerLastFileSegment(J2EEConstants.WEBAPP_DD_SHORT_NAME, new WebAppResourceFactory(RendererFactory.getDefaultRendererFactory())); > } > > public static Resource.Factory getRegisteredFactory() { >+ >+ System.err.println("fetching registered factory for web app uri"); > return J2EEResourceFactoryRegistry.INSTANCE.getFactory(J2EEConstants.WEBAPP_DD_URI_OBJ); > } > >Index: plugin.xml >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.core/plugin.xml,v >retrieving revision 1.14 >diff -u -r1.14 plugin.xml >--- plugin.xml 11 Apr 2006 19:15:14 -0000 1.14 >+++ plugin.xml 6 Jun 2006 19:19:23 -0000 >@@ -164,5 +164,25 @@ > class="org.eclipse.jst.j2ee.core.internal.validation.xmlerrorcustomization.J2EEErrorMessageCustomizer" > namespace="http://java.sun.com/xml/ns/j2ee"/> > </extension> >+ >+ >+ <extension >+ point="org.eclipse.wst.common.modulecore.resourceFactories"> >+ <resourceFactory >+ class="org.eclipse.jst.j2ee.webapplication.internal.impl.WebAppResourceFactory" >+ shortSegment="web.xml"/> >+ <resourceFactory >+ class="org.eclipse.jst.j2ee.ejb.internal.impl.EJBJarResourceFactory" >+ shortSegment="ejb-jar.xml"/> >+ <resourceFactory >+ class="org.eclipse.jst.j2ee.client.internal.impl.ApplicationClientResourceFactory" >+ shortSegment="application-client.xml"/> >+ <resourceFactory >+ class="org.eclipse.jst.j2ee.application.internal.impl.ApplicationResourceFactory" >+ shortSegment="application.xml"/> >+ <resourceFactory >+ class="org.eclipse.jst.j2ee.jca.internal.impl.ConnectorResourceFactory" >+ shortSegment="ra.xml"/> >+ </extension> > > </plugin> >Index: mofj2ee/org/eclipse/jst/j2ee/jca/internal/impl/ConnectorResourceFactory.java >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.core/mofj2ee/org/eclipse/jst/j2ee/jca/internal/impl/ConnectorResourceFactory.java,v >retrieving revision 1.3 >diff -u -r1.3 ConnectorResourceFactory.java >--- mofj2ee/org/eclipse/jst/j2ee/jca/internal/impl/ConnectorResourceFactory.java 24 May 2006 15:42:10 -0000 1.3 >+++ mofj2ee/org/eclipse/jst/j2ee/jca/internal/impl/ConnectorResourceFactory.java 6 Jun 2006 19:19:23 -0000 >@@ -31,6 +31,16 @@ > J2EEXmlDtDEntityResolver.registerDtD(J2EEConstants.CONNECTOR_ALT_SYSTEMID_1_0, "connector_1.0.dtd"); //$NON-NLS-1$ > J2EEXmlDtDEntityResolver.registerDtD(J2EEConstants.CONNECTOR_SCHEMA_LOC_1_5, "connector_1_5.xsd"); //$NON-NLS-1$ > } >+ >+ >+ >+ /** >+ * Constructor for ConnectorResourceFactory. >+ * @param aRendererFactory >+ */ >+ public ConnectorResourceFactory() { >+ super(RendererFactory.getDefaultRendererFactory()); >+ } > > /** > * Constructor for ConnectorResourceFactory. >Index: mofj2ee/org/eclipse/jst/j2ee/webservice/internal/wsdd/WsddResourceFactory.java >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.core/mofj2ee/org/eclipse/jst/j2ee/webservice/internal/wsdd/WsddResourceFactory.java,v >retrieving revision 1.5 >diff -u -r1.5 WsddResourceFactory.java >--- mofj2ee/org/eclipse/jst/j2ee/webservice/internal/wsdd/WsddResourceFactory.java 1 Dec 2005 22:25:38 -0000 1.5 >+++ mofj2ee/org/eclipse/jst/j2ee/webservice/internal/wsdd/WsddResourceFactory.java 6 Jun 2006 19:19:23 -0000 >@@ -25,6 +25,15 @@ > > public class WsddResourceFactory extends TranslatorResourceFactory > { >+ >+ /** >+ * WsddResourceFactory constructor comment. >+ */ >+ public WsddResourceFactory() >+ { >+ super(RendererFactory.getDefaultRendererFactory()); >+ } >+ > /** > * WsddResourceFactory constructor comment. > */ >Index: mofj2ee/org/eclipse/jst/j2ee/webservice/wsclient/internal/impl/WebServicesClientResourceFactory.java >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.core/mofj2ee/org/eclipse/jst/j2ee/webservice/wsclient/internal/impl/WebServicesClientResourceFactory.java,v >retrieving revision 1.2 >diff -u -r1.2 WebServicesClientResourceFactory.java >--- mofj2ee/org/eclipse/jst/j2ee/webservice/wsclient/internal/impl/WebServicesClientResourceFactory.java 1 Dec 2005 22:25:32 -0000 1.2 >+++ mofj2ee/org/eclipse/jst/j2ee/webservice/wsclient/internal/impl/WebServicesClientResourceFactory.java 6 Jun 2006 19:19:23 -0000 >@@ -30,6 +30,14 @@ > > public class WebServicesClientResourceFactory > extends TranslatorResourceFactory { >+ >+ /** >+ * @param aRendererFactory >+ */ >+ public WebServicesClientResourceFactory() { >+ super(RendererFactory.getDefaultRendererFactory()); >+ } >+ > /** > * Method registerDtds. > */ >#P org.eclipse.wst.common.emf >Index: wtpemf/org/eclipse/wst/common/internal/emf/resource/FileNameResourceFactoryRegistry.java >=================================================================== >RCS file: /home/webtools/wst/components/common/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/FileNameResourceFactoryRegistry.java,v >retrieving revision 1.2 >diff -u -r1.2 FileNameResourceFactoryRegistry.java >--- wtpemf/org/eclipse/wst/common/internal/emf/resource/FileNameResourceFactoryRegistry.java 11 Mar 2005 20:50:36 -0000 1.2 >+++ wtpemf/org/eclipse/wst/common/internal/emf/resource/FileNameResourceFactoryRegistry.java 6 Jun 2006 19:19:24 -0000 >@@ -9,7 +9,9 @@ > package org.eclipse.wst.common.internal.emf.resource; > > import java.util.ArrayList; >+import java.util.HashMap; > import java.util.List; >+import java.util.Map; > > import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.ecore.resource.Resource; >@@ -18,11 +20,10 @@ > > > public abstract class FileNameResourceFactoryRegistry extends DefaultOverridableResourceFactoryRegistry { >- //We are using two lists instead of a Map because we need to iterate >- //the list of simpleFileNames quite a lot. >- protected List simpleFileNames; >- protected List simpleFileNameFactories; > >+ private Map/*<String shortName, ResourceFactoryDescriptor>*/ descriptors = new HashMap(); >+ private Map/*<ResourceFactoryDescriptor, Resource.Factory>*/ factories = new HashMap(); >+ > public FileNameResourceFactoryRegistry() { > super(); > } >@@ -33,58 +34,57 @@ > * @see org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl#getFactory(URI) > */ > protected Object getFileNameFactory(URI uri) { >- if (simpleFileNames != null) { >- String fileName = uri.lastSegment(); >- if (fileName != null) { >- String key; >- for (int i = 0; i < simpleFileNames.size(); i++) { >- key = (String) simpleFileNames.get(i); >- if (fileName.equals(key)) >- return simpleFileNameFactories.get(i); >- } >- } >+ >+ if(uri != null) { >+ ResourceFactoryDescriptor descriptor = getDescriptor(uri); >+ >+ if(descriptor != null) { >+ return getFactory(descriptor); >+ } > } > return null; >+ > } > >- public Resource.Factory getFactory(URI uri) { >- Object resourceFactory = getFileNameFactory(uri); >- if (resourceFactory == null) >+ public synchronized Resource.Factory getFactory(URI uri) { >+ >+ Resource.Factory resourceFactory = null; >+ if(uri != null && uri.lastSegment() != null) { >+ ResourceFactoryDescriptor descriptor = getDescriptor(uri); >+ >+ if(descriptor != null) { >+ resourceFactory = getFactory(descriptor); >+ } >+ } >+ if(resourceFactory == null) > resourceFactory = super.getFactory(uri); >- return (Resource.Factory) resourceFactory; >+ return resourceFactory; > } > > /** > * Register a file name representing the last segment of a URI with the corresponding > * Resource.Factory. > */ >- public void registerLastFileSegment(String aSimpleFileName, Resource.Factory aFactory) { >+ public synchronized void registerLastFileSegment(String aSimpleFileName, Resource.Factory aFactory) { > URI uri = URI.createURI(aSimpleFileName); >- String lastSegment = uri.lastSegment(); >- int index = getFileNameIndexForAdd(lastSegment); >- setFileName(lastSegment, index); >- setFileNameFactory(aFactory, index); >+ String lastSegment = uri.lastSegment(); >+ addDescriptor(new StaticResourceFactoryDescriptor(lastSegment, aFactory)); >+ } >+ >+ protected final synchronized ResourceFactoryDescriptor getDescriptor(URI uri) { >+ return (ResourceFactoryDescriptor) descriptors.get(uri.lastSegment()); > } > >- private int getFileNameIndexForAdd(String aSimpleFileName) { >- if (simpleFileNames != null) { >- int i = simpleFileNames.indexOf(aSimpleFileName); >- if (i > -1) >- return i; >- return simpleFileNames.size(); >+ protected final synchronized Resource.Factory getFactory(ResourceFactoryDescriptor descriptor) { >+ Resource.Factory factory = (Factory) factories.get(descriptor); >+ if(factory == null) { >+ factories.put(descriptor, (factory = descriptor.createFactory())); > } >- return 0; >- } >- >- private void setFileNameFactory(Factory aFactory, int index) { >- if (simpleFileNameFactories == null) >- simpleFileNameFactories = new ArrayList(); >- simpleFileNameFactories.add(index, aFactory); >+ return factory; > } > >- private void setFileName(String aSimpleFileName, int index) { >- if (simpleFileNames == null) >- simpleFileNames = new ArrayList(); >- simpleFileNames.add(index, aSimpleFileName); >+ protected final void addDescriptor(ResourceFactoryDescriptor descriptor) { >+ descriptors.put(descriptor.getShortSegment(), descriptor); > } >+ > } >\ No newline at end of file >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /home/webtools/wst/components/common/plugins/org.eclipse.wst.common.emf/META-INF/MANIFEST.MF,v >retrieving revision 1.11 >diff -u -r1.11 MANIFEST.MF >--- META-INF/MANIFEST.MF 1 Jun 2006 19:25:12 -0000 1.11 >+++ META-INF/MANIFEST.MF 6 Jun 2006 19:19:24 -0000 >@@ -7,7 +7,7 @@ > Bundle-Vendor: %pluginProvider > Bundle-Localization: plugin > Export-Package: org.eclipse.wst.common.internal.emf.plugin;x-internal:=true, >- org.eclipse.wst.common.internal.emf.resource;x-internal:=true, >+ org.eclipse.wst.common.internal.emf.resource;x-friends:="org.eclipse.wst.common.modulecore", > org.eclipse.wst.common.internal.emf.utilities;x-internal:=true > Require-Bundle: org.eclipse.emf.ecore.xmi, > org.eclipse.wst.common.frameworks, >Index: wtpemf/org/eclipse/wst/common/internal/emf/resource/ResourceFactoryDescriptor.java >=================================================================== >RCS file: wtpemf/org/eclipse/wst/common/internal/emf/resource/ResourceFactoryDescriptor.java >diff -N wtpemf/org/eclipse/wst/common/internal/emf/resource/ResourceFactoryDescriptor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ wtpemf/org/eclipse/wst/common/internal/emf/resource/ResourceFactoryDescriptor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,60 @@ >+/******************************************************************************* >+ * Copyright (c) 2003, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.common.internal.emf.resource; >+ >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+ >+public abstract class ResourceFactoryDescriptor { >+ >+ >+ /** >+ * Returns true if the current descriptor is applicable to the given fileURI. >+ * >+ * @param fileURI The URI of the file to be loaded >+ * @return True if the current descriptor declares a resource factory applicable to the given URI. >+ */ >+ public abstract boolean isEnabledFor(URI fileURI); >+ >+ >+ /** >+ * The short segment is one possible way that a ResourceFactory >+ * might apply to a URI. Clients should call {@link isEnabledFor} >+ * instead of comparing the short segments when searching for an >+ * applicable descriptor from a set. >+ * >+ * <p><b>Subclasses may NOT return null.</b></p> >+ * >+ * @return The short segment that this descriptor is applicable to. >+ */ >+ public abstract String getShortSegment(); >+ >+ >+ /** >+ * The correct instance of Resource.Factory. The instance returned >+ * may or may not be unique, so if you require the same instance >+ * for each call, you should cache the value returned the first >+ * time from this method. >+ * >+ * @return An instance of Resource.Factory. >+ */ >+ public abstract Resource.Factory createFactory(); >+ >+ public int hashCode() { >+ return getShortSegment().hashCode(); >+ } >+ >+ public boolean equals(Object o) { >+ if(o instanceof ResourceFactoryDescriptor) >+ return getShortSegment().equals(((ResourceFactoryDescriptor)o).getShortSegment()); >+ return false; >+ } >+} >Index: wtpemf/org/eclipse/wst/common/internal/emf/resource/StaticResourceFactoryDescriptor.java >=================================================================== >RCS file: wtpemf/org/eclipse/wst/common/internal/emf/resource/StaticResourceFactoryDescriptor.java >diff -N wtpemf/org/eclipse/wst/common/internal/emf/resource/StaticResourceFactoryDescriptor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ wtpemf/org/eclipse/wst/common/internal/emf/resource/StaticResourceFactoryDescriptor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+package org.eclipse.wst.common.internal.emf.resource; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+ >+/** >+ * Declares a subclass to create Resource.Factory(ies) from an extension. >+ */ >+class StaticResourceFactoryDescriptor extends ResourceFactoryDescriptor { >+ >+ private final String shortSegment; >+ private final Resource.Factory factory; >+ >+ /** >+ * >+ * @param shortSegment A non-null name of the file associated with the given factory >+ * @param factory A non-null Resource.Factory that can load files of the given name >+ */ >+ public StaticResourceFactoryDescriptor(String shortSegment, Resource.Factory factory) { >+ Assert.isNotNull(shortSegment); >+ Assert.isNotNull(factory); >+ this.shortSegment = shortSegment; >+ this.factory = factory; >+ } >+ >+ public boolean isEnabledFor(URI fileURI) { >+ /* shortSegment must be non-null for the descriptor to be created, >+ * a validation check in init() verifies this requirement */ >+ if(fileURI != null && fileURI.lastSegment() != null) >+ return shortSegment.equals(fileURI.lastSegment()); >+ return false; >+ } >+ >+ public Resource.Factory createFactory() { >+ return factory; >+ } >+ >+ public String getShortSegment() { >+ return shortSegment; >+ } >+} >#P org.eclipse.wst.common.modulecore >Index: modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPResourceFactoryRegistry.java >=================================================================== >RCS file: /home/webtools/wst/components/common/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPResourceFactoryRegistry.java,v >retrieving revision 1.2 >diff -u -r1.2 WTPResourceFactoryRegistry.java >--- modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPResourceFactoryRegistry.java 1 Dec 2005 22:02:53 -0000 1.2 >+++ modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/WTPResourceFactoryRegistry.java 6 Jun 2006 19:19:24 -0000 >@@ -10,9 +10,20 @@ > *******************************************************************************/ > package org.eclipse.wst.common.componentcore.internal.impl; > >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.ISafeRunnable; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.SafeRunner; > import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.jem.util.RegistryReader; >+import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin; > import org.eclipse.wst.common.internal.emf.resource.FileNameResourceFactoryRegistry; >+import org.eclipse.wst.common.internal.emf.resource.ResourceFactoryDescriptor; >+import org.eclipse.wst.common.internal.emf.utilities.DefaultOverridableResourceFactoryRegistry; > > /** > * <p> >@@ -22,10 +33,143 @@ > public class WTPResourceFactoryRegistry extends FileNameResourceFactoryRegistry { > > public static final WTPResourceFactoryRegistry INSTANCE = new WTPResourceFactoryRegistry(); >+ >+ private final static boolean LOG_WARNINGS = false; >+ >+ >+ private WTPResourceFactoryRegistry() { >+ new ResourceFactoryRegistryReader().readRegistry(); >+ } > > public Resource.Factory delegatedGetFactory(URI uri) { > if (WTPResourceFactoryRegistry.INSTANCE == this) > return super.delegatedGetFactory(uri); > return WTPResourceFactoryRegistry.INSTANCE.getFactory(uri); >+ } >+ >+ public synchronized Resource.Factory getFactory(URI uri) { >+ >+ Resource.Factory resourceFactory = null; >+ if(uri != null && uri.lastSegment() != null) { >+ ResourceFactoryDescriptor descriptor = getDescriptor(uri); >+ >+ if(descriptor != null) { >+ resourceFactory = getFactory(descriptor); >+ } >+ } >+ if(resourceFactory == null) >+ resourceFactory = super.getFactory(uri); >+ return resourceFactory; >+ } >+ >+ >+ /** >+ * Register a file name representing the last segment of a URI with the corresponding >+ * Resource.Factory. >+ */ >+ public synchronized void registerLastFileSegment(String aSimpleFileName, Resource.Factory aFactory) { >+ >+ if(LOG_WARNINGS) { >+ /* the third entry in the array is this stack frame, we walk back from there. */ >+ StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); >+ if(stackTrace.length > 4) { >+ StringBuffer warningMessage = new StringBuffer("WTPResourceFactoryRegistry.registerLastFileSegment() was called explicitly from " + stackTrace[3]); >+ warningMessage.append("\nThis happened around: \n"); >+ for (int i = 4; (i < stackTrace.length) && i < 8; i++) { >+ warningMessage.append("\tnear ").append(stackTrace[i]).append('\n'); >+ } >+ warningMessage.append(".\nClients should use the org.eclipse.wst.common.modulecore.resourceFactories extension point instead."); >+ ModulecorePlugin.log(IStatus.INFO, 0, warningMessage.toString(), null); >+ } >+ } >+ >+ super.registerLastFileSegment(aSimpleFileName, aFactory); >+ >+ } >+ >+ /** >+ * Declares a subclass to create Resource.Factory(ies) from an extension. >+ */ >+ private class ConfigurationResourceFactoryDescriptor extends ResourceFactoryDescriptor implements IResourceFactoryExtPtConstants { >+ >+ private String shortSegment; >+ private final IConfigurationElement element; >+ >+ public ConfigurationResourceFactoryDescriptor(IConfigurationElement ext) throws CoreException { >+ Assert.isNotNull(ext); >+ element = ext; >+ init(); >+ } >+ >+ private void init() throws CoreException { >+ shortSegment = element.getAttribute(ATT_SHORT_SEGMENT); >+ if(shortSegment == null || shortSegment.trim().length() == 0) >+ throw new CoreException( >+ ModulecorePlugin.createErrorStatus(0, >+ "The shortSegment attribute of " + TAG_RESOURCE_FACTORY + //$NON-NLS-1$ >+ " must specify a valid, non-null, non-empty value in " + //$NON-NLS-1$ >+ element.getNamespaceIdentifier(), null)); >+ >+ } >+ >+ public boolean isEnabledFor(URI fileURI) { >+ /* shortSegment must be non-null for the descriptor to be created, >+ * a validation check in init() verifies this requirement */ >+ if(fileURI != null && fileURI.lastSegment() != null) >+ return shortSegment.equals(fileURI.lastSegment()); >+ return false; >+ } >+ >+ public Resource.Factory createFactory() { >+ >+ final Resource.Factory[] factory = new Resource.Factory[1]; >+ >+ SafeRunner.run(new ISafeRunnable() { >+ >+ public void run() throws Exception { >+ factory[0] = (Resource.Factory) element.createExecutableExtension(ATT_CLASS); >+ } >+ >+ public void handleException(Throwable exception) { >+ ModulecorePlugin.log(ModulecorePlugin.createErrorStatus(0, exception.getMessage(), exception)); >+ } >+ }); >+ >+ return factory[0] != null ? factory[0] : DefaultOverridableResourceFactoryRegistry.GLOBAL_FACTORY; >+ >+ } >+ >+ public String getShortSegment() { >+ return shortSegment; >+ } >+ } >+ >+ >+ private class ResourceFactoryRegistryReader extends RegistryReader implements IResourceFactoryExtPtConstants { >+ >+ public ResourceFactoryRegistryReader() { >+ super(Platform.getPluginRegistry(), ModulecorePlugin.PLUGIN_ID, EXTPT_RESOURCE_FACTORIES); >+ } >+ >+ public boolean readElement(final IConfigurationElement element) { >+ >+ if(element != null && TAG_RESOURCE_FACTORY.equals(element.getName())) { >+ final boolean[] success = new boolean[] { true }; >+ SafeRunner.run(new ISafeRunnable() { >+ >+ public void run() throws Exception { >+ addDescriptor(new ConfigurationResourceFactoryDescriptor(element)); >+ } >+ >+ public void handleException(Throwable exception) { >+ ModulecorePlugin.log(ModulecorePlugin.createErrorStatus(0, exception.getMessage(), exception)); >+ success[0] = false; >+ } >+ }); >+ return success[0]; >+ } else { >+ return false; >+ } >+ } > } > } >Index: plugin.xml >=================================================================== >RCS file: /home/webtools/wst/components/common/plugins/org.eclipse.wst.common.modulecore/plugin.xml,v >retrieving revision 1.30 >diff -u -r1.30 plugin.xml >--- plugin.xml 27 Apr 2006 04:17:42 -0000 1.30 >+++ plugin.xml 6 Jun 2006 19:19:24 -0000 >@@ -50,6 +50,7 @@ > </extension> > <extension-point id="ComponentProjectMigrator" name="ComponentProjectMigrator" schema="schema/ComponentProjectMigrator.exsd"/> > <extension-point id="artifactedit" name="Component Artifact Edit" schema="schema/artifactedit.exsd"/> >+ <extension-point id="resourceFactories" name="Resource Factory Association (Internal)" schema="schema/resourceFactories.exsd"/> > > <!-- Contribute a URIResolverExtension for flexible projects --> > <extension point="org.eclipse.wst.common.uriresolver.resolverExtensions"> >Index: modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/IResourceFactoryExtPtConstants.java >=================================================================== >RCS file: modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/IResourceFactoryExtPtConstants.java >diff -N modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/IResourceFactoryExtPtConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/IResourceFactoryExtPtConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+/******************************************************************************* >+ * Copyright (c) 2003, 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.common.componentcore.internal.impl; >+ >+public interface IResourceFactoryExtPtConstants { >+ >+ >+ String EXTPT_RESOURCE_FACTORIES = "resourceFactories"; //$NON-NLS-1$ >+ >+ String TAG_RESOURCE_FACTORY = "resourceFactory"; //$NON-NLS-1$ >+ >+ String ATT_CLASS = "class"; //$NON-NLS-1$ >+ >+ String ATT_SHORT_SEGMENT = "shortSegment"; //$NON-NLS-1$ >+ >+ >+} >Index: schema/resourceFactories.exsd >=================================================================== >RCS file: schema/resourceFactories.exsd >diff -N schema/resourceFactories.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/resourceFactories.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,117 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.wst.common.modulecore"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.wst.common.modulecore" id="resourceFactories" name="Resource Factory Association (Internal)"/> >+ </appInfo> >+ <documentation> >+ An *internal* extension point that declares an association between a short-segment filename and a Resource.Factory. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <complexType> >+ <sequence> >+ <element ref="resourceFactory"/> >+ </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="resourceFactory"> >+ <annotation> >+ <documentation> >+ Associates a short name (e.g. "web.xml") with the appropriate Resource.Factory to create the Resource type when loading files of the declared shortname. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Declares an implementation of <code>org.eclipse.emf.ecore.resource.Resource.Factory</code>. >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.emf.ecore.resource.Resource.Factory"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ <attribute name="shortSegment" type="string" use="required"> >+ <annotation> >+ <documentation> >+ Declares the short segment of a filename that the resource factory applies to (e.g. "web.xml"). >+ </documentation> >+ </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> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="copyright"/> >+ </appInfo> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ >+</schema> >#P org.eclipse.jst.j2ee.web >Index: web/org/eclipse/jst/j2ee/internal/web/plugin/WebPlugin.java >=================================================================== >RCS file: /home/webtools/jst/components/j2ee/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/plugin/WebPlugin.java,v >retrieving revision 1.23 >diff -u -r1.23 WebPlugin.java >--- web/org/eclipse/jst/j2ee/internal/web/plugin/WebPlugin.java 1 Dec 2005 22:22:18 -0000 1.23 >+++ web/org/eclipse/jst/j2ee/internal/web/plugin/WebPlugin.java 6 Jun 2006 19:19:25 -0000 >@@ -262,7 +262,7 @@ > > public void start(BundleContext context) throws Exception { > super.start(context); >- WebAppResourceFactory.register(WTPResourceFactoryRegistry.INSTANCE); >+ //WebAppResourceFactory.register(WTPResourceFactoryRegistry.INSTANCE); > IAdapterManager manager = Platform.getAdapterManager(); > manager.registerAdapters(new WebEditAdapterFactory(), ArtifactEditModel.class); > }
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 143229
: 43635 |
43835