bug 324927 moved configItemFactories to ConfigSource
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigLoaderJob.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigLoaderJob.java
index 5d0120f..e9758a7 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigLoaderJob.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigLoaderJob.java
@@ -69,9 +69,9 @@
 			final String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
 			monitor.subTask(Messages.getString("ConfigLoaderJob.loading") + name); //$NON-NLS-1$
 
-			final ConfigSource source = ConfigPlugin.load(namespace);
-			if (source != null)
-				result.add(source);
+			final ConfigPlugin configPlugin = new ConfigPlugin(namespace);
+			if (!configPlugin.isEmpty())
+				result.add(configPlugin);
 			monitor.worked(1);
 		}
 		return result;
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigPlugin.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigPlugin.java
index 1ac6581..4d759c0 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigPlugin.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigPlugin.java
@@ -25,40 +25,35 @@
  */
 public class ConfigPlugin extends ConfigSource {
 
-	protected ConfigPlugin(String namespace) {
-		this.namespace = namespace;
+	private String bundleSymbolicName;
+	
+	protected ConfigPlugin(String bundleSymbolicName) {
+		this.bundleSymbolicName = bundleSymbolicName;
+		setUniqueIdentifer(bundleSymbolicName);
+		load();
 	}
 
-	public static ConfigPlugin load(String namespace) {
-
-		ConfigPlugin configPlugin = new ConfigPlugin(namespace);
-		configPlugin.setUniqueIdentifer(namespace);
-
-		for (IExtension ext : Platform.getExtensionRegistry().getExtensions(namespace)) {
+	private void load() {
+		removeAllItems();
+		for (IExtension extension : Platform.getExtensionRegistry().getExtensions(bundleSymbolicName)) {
 			try {
-				configPlugin.addItem(ext.getExtensionPointUniqueIdentifier(),
-						ext.getSimpleIdentifier(), ext.getLabel(),
-						ConfigurationElementWrapper.convertArray(ext
+				addItem(extension.getExtensionPointUniqueIdentifier(),
+						extension.getSimpleIdentifier(), extension.getLabel(),
+						ConfigurationElementWrapper.convertArray(extension
 								.getConfigurationElements()));
 			} catch (IOException e) {
 				String message = MessageFormat.format(Messages
 						.getString("ConfigPlugin.loadError"), //$NON-NLS-1$
-						new Object[] { ext.getSimpleIdentifier(), namespace });
+						new Object[] { extension.getSimpleIdentifier(), bundleSymbolicName });
 				VexPlugin.getInstance().log(IStatus.ERROR, message, e);
-				return null;
+				return;
 			}
 		}
-
-		configPlugin.parseResources(null);
-
-		return configPlugin.isEmpty() ? null : configPlugin;
+		parseResources(null);
 	}
-
+	
 	public URL getBaseUrl() {
-		return Platform.getBundle(namespace).getEntry("plugin.xml"); //$NON-NLS-1$
+		return Platform.getBundle(bundleSymbolicName).getEntry("plugin.xml"); //$NON-NLS-1$
 	}
 
-	// ======================================================= PRIVATE
-
-	private String namespace;
 }
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigSource.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigSource.java
index 87f9ab5..8879180 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigSource.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigSource.java
@@ -34,14 +34,33 @@
 
 	private static final long serialVersionUID = -3438659781471827569L;
 
+	private static final IConfigItemFactory[] CONFIG_ITEM_FACTORIES = new IConfigItemFactory[] { new DoctypeFactory(), new StyleFactory() };
+
+	// Globally-unique identifier of this configuration
+	// == the plugin id.
+	private String id;
+
+	// all config items in this configuration
+	private final List<ConfigItem> items = new ArrayList<ConfigItem>();
+
+	// map String URI => parsed resource
+	private final Map<String, Object> parsedResources = new HashMap<String, Object>();
+
+	protected static IConfigItemFactory getConfigItemFactory(final String extensionPointId) {
+		for (final IConfigItemFactory factory : CONFIG_ITEM_FACTORIES)
+			if (factory.getExtensionPointId().equals(extensionPointId))
+				return factory;
+		return null;
+	}
+
 	/**
 	 * Adds the given item to the configuration.
 	 * 
 	 * @param item
 	 *            ConfigItem to be added.
 	 */
-	public void addItem(ConfigItem item) {
-		this.items.add(item);
+	public void addItem(final ConfigItem item) {
+		items.add(item);
 	}
 
 	/**
@@ -62,20 +81,16 @@
 	 *         recognized.
 	 * @throws IOException
 	 */
-	public ConfigItem addItem(String extensionPoint, String simpleIdentifier,
-			String name, IConfigElement[] configElements) throws IOException {
-
-		IConfigItemFactory factory = ConfigurationRegistry.INSTANCE
-				.getConfigItemFactory(extensionPoint);
-		if (factory != null) {
-			ConfigItem item = factory.createItem(this, configElements);
-			item.setSimpleId(simpleIdentifier);
-			item.setName(name);
-			this.addItem(item);
-			return item;
-		} else {
+	protected ConfigItem addItem(final String extensionPoint, final String simpleIdentifier, final String name, final IConfigElement[] configElements)
+			throws IOException {
+		final IConfigItemFactory factory = getConfigItemFactory(extensionPoint);
+		if (factory == null)
 			return null;
-		}
+		final ConfigItem item = factory.createItem(this, configElements);
+		item.setSimpleId(simpleIdentifier);
+		item.setName(name);
+		this.addItem(item);
+		return item;
 
 	}
 
@@ -85,7 +100,7 @@
 	 * @param item
 	 *            ConfigItem to be removed.
 	 */
-	public void remove(ConfigItem item) {
+	public void remove(final ConfigItem item) {
 		items.remove(item);
 	}
 
@@ -93,14 +108,14 @@
 	 * Remove all items from this configuration.
 	 */
 	public void removeAllItems() {
-		this.items.clear();
+		items.clear();
 	}
 
 	/**
 	 * Remove all parsed resources from this configuration.
 	 */
 	public void removeAllResources() {
-		this.parsedResources.clear();
+		parsedResources.clear();
 	}
 
 	/**
@@ -122,8 +137,8 @@
 	 * @param uri
 	 *            Relative URI of the resource to remove.
 	 */
-	public void removeResource(String uri) {
-		this.parsedResources.remove(uri); // TODO Respect secondary resources
+	public void removeResource(final String uri) {
+		parsedResources.remove(uri); // TODO Respect secondary resources
 	}
 
 	/**
@@ -134,23 +149,6 @@
 	}
 
 	/**
-	 * Returns all ConfigItems of the given type registered with this
-	 * configuration.
-	 * 
-	 * @param type
-	 *            The type of ConfigItem to return.
-	 */
-	public Collection<ConfigItem> getAllItems(String type) {
-		List<ConfigItem> selectedItems = new ArrayList<ConfigItem>();
-		for (ConfigItem item : this.items) {
-			if (item.getExtensionPointId().equals(type)) {
-				selectedItems.add(item);
-			}
-		}
-		return selectedItems;
-	}
-
-	/**
 	 * Returns the base URL of this factory. This is used to resolve relative
 	 * URLs in config items
 	 */
@@ -163,13 +161,10 @@
 	 * @param simpleId
 	 *            Simple ID of the item to return.
 	 */
-	public ConfigItem getItem(String simpleId) {
-		for (ConfigItem item : this.items) {
-			if (item.getSimpleId() != null
-					&& item.getSimpleId().equals(simpleId)) {
+	public ConfigItem getItem(final String simpleId) {
+		for (final ConfigItem item : items)
+			if (item.getSimpleId() != null && item.getSimpleId().equals(simpleId))
 				return item;
-			}
-		}
 		return null;
 	}
 
@@ -180,12 +175,10 @@
 	 * @param resourcePath
 	 *            Path of the resource.
 	 */
-	public ConfigItem getItemForResource(String resourcePath) {
-		for (ConfigItem item : this.items) {
-			if (item.getResourcePath().equals(resourcePath)) {
+	public ConfigItem getItemForResource(final String resourcePath) {
+		for (final ConfigItem item : items)
+			if (item.getResourcePath().equals(resourcePath))
 				return item;
-			}
-		}
 		return null;
 	}
 
@@ -197,8 +190,8 @@
 	 *            URI of the resource, relative to the base URL of this
 	 *            configuration.
 	 */
-	public Object getParsedResource(String uri) {
-		return this.parsedResources.get(uri);
+	public Object getParsedResource(final String uri) {
+		return parsedResources.get(uri);
 	}
 
 	/**
@@ -206,57 +199,7 @@
 	 * the ID of the plugin that defines the configuration.
 	 */
 	public String getUniqueIdentifer() {
-		return this.id;
-	}
-
-	/**
-	 * Returns all ConfigItems of the given type for which isValid returns true.
-	 * 
-	 * @param type
-	 *            The type of ConfigItem to return.
-	 */
-	public Collection<ConfigItem> getValidItems(String type) {
-		List<ConfigItem> validItems = new ArrayList<ConfigItem>();
-		for (ConfigItem item : this.getAllItems(type)) {
-			if (item.isValid()) {
-				validItems.add(item);
-			}
-		}
-		return validItems;
-	}
-
-	/**
-	 * Returns true if there are no items in this configuration.
-	 */
-	public boolean isEmpty() {
-		return this.items.isEmpty();
-	}
-
-	/**
-	 * Parses all resources required by the registered items.
-	 * 
-	 * @param problemHandler
-	 *            Handler for build problems. May be null.
-	 */
-	public void parseResources(IBuildProblemHandler problemHandler) {
-		for (ConfigItem item : this.items) {
-			String uri = item.getResourcePath();
-			if (!this.parsedResources.containsKey(uri)) {
-				IConfigItemFactory factory = ConfigurationRegistry.INSTANCE
-						.getConfigItemFactory(item.getExtensionPointId());
-				Object parsedResource;
-				try {
-					parsedResource = factory.parseResource(this.getBaseUrl(),
-							uri, problemHandler);
-					this.parsedResources.put(uri, parsedResource);
-				} catch (IOException ex) {
-					String message = MessageFormat.format(Messages
-							.getString("ConfigSource.errorParsingUri"),
-							new Object[] { uri });
-					VexPlugin.getInstance().log(IStatus.ERROR, message, ex); //$NON-NLS-1$
-				}
-			}
-		}
+		return id;
 	}
 
 	/**
@@ -265,20 +208,52 @@
 	 * @param id
 	 *            New identifier for this configuration.
 	 */
-	public void setUniqueIdentifer(String id) {
+	protected void setUniqueIdentifer(final String id) {
 		this.id = id;
 	}
+	
+	/**
+	 * Returns all ConfigItems of the given type for which isValid returns true.
+	 * 
+	 * @param extensionPointId
+	 *            The type of ConfigItem to return.
+	 */
+	public Collection<ConfigItem> getValidItems(final String extensionPointId) {
+		final List<ConfigItem> result = new ArrayList<ConfigItem>();
+		for (final ConfigItem item : items)
+			if (item.getExtensionPointId().equals(extensionPointId) && item.isValid())
+				result.add(item);
+		return result;
+	}
 
-	// ==================================================== PRIVATE
+	/**
+	 * Returns true if there are no items in this configuration.
+	 */
+	public boolean isEmpty() {
+		return items.isEmpty();
+	}
 
-	// Globally-unique identifier of this configuration
-	// == the plugin id.
-	private String id;
+	/**
+	 * Parses all resources required by the registered items.
+	 * 
+	 * @param problemHandler
+	 *            Handler for build problems. May be null.
+	 */
+	public void parseResources(final IBuildProblemHandler problemHandler) {
+		parsedResources.clear();
+		for (final ConfigItem item : items) {
+			final String uri = item.getResourcePath();
+			if (!parsedResources.containsKey(uri)) {
+				final IConfigItemFactory factory = getConfigItemFactory(item.getExtensionPointId());
+				try {
+					final Object parsedResource = factory.parseResource(getBaseUrl(), uri, problemHandler);
+					parsedResources.put(uri, parsedResource);
+				} catch (final IOException ex) {
+					final String message = MessageFormat.format(Messages.getString("ConfigSource.errorParsingUri"), new Object[] { uri });
+					VexPlugin.getInstance().log(IStatus.ERROR, message, ex);
+				}
+			}
+		}
+	}
 
-	// all config items in this configuration
-	private List<ConfigItem> items = new ArrayList<ConfigItem>();
-
-	// map String URI => parsed resource
-	private Map<String, Object> parsedResources = new HashMap<String, Object>();
-
-}
+}
\ No newline at end of file
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigurationRegistry.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigurationRegistry.java
index 252a986..9d52f4e 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigurationRegistry.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigurationRegistry.java
@@ -19,8 +19,6 @@
 

 	ConfigurationRegistry INSTANCE = new ConfigurationRegistryImpl();

 	

-	IConfigItemFactory getConfigItemFactory(String extensionPointId);

-

 	void fireConfigChanged(final ConfigEvent e);

 	

 	void fireConfigLoaded(final ConfigEvent e);

diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigurationRegistryImpl.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigurationRegistryImpl.java
index e8dcb3d..81e947f 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigurationRegistryImpl.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/ConfigurationRegistryImpl.java
@@ -60,8 +60,6 @@
 	private volatile boolean loaded = false;
 
 	public ConfigurationRegistryImpl() {
-		configItemFactories.add(new DoctypeFactory());
-		configItemFactories.add(new StyleFactory());
 		ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener);
 	}
 
@@ -78,9 +76,9 @@
 				public void done(final IJobChangeEvent event) {
 					lock();
 					try {
-						configs = new HashMap<String, ConfigSource>();
+						configurationSources = new HashMap<String, ConfigSource>();
 						for (final ConfigSource configSource : loaderJob.getAllConfigSources())
-							configs.put(configSource.getUniqueIdentifer(), configSource);
+							configurationSources.put(configSource.getUniqueIdentifer(), configSource);
 						loaded = true;
 						loaderJob = null;
 					} finally {
@@ -95,56 +93,13 @@
 		}
 	}
 
-	/**
-	 * Add a ConfigSource to the list of configurations.
-	 * 
-	 * @param config
-	 *            ConfigSource to be added.
-	 */
-	public void addConfigSource(final ConfigSource config) {
-		try {
-			lock();
-			configs.put(config.getUniqueIdentifer(), config);
-		} finally {
-			unlock();
-		}
-	}
-
-	/**
-	 * Call the configChanged method on all registered ConfigChangeListeners.
-	 * 
-	 * @param e
-	 *            ConfigEvent to be fired.
-	 */
-	public void fireConfigChanged(final ConfigEvent e) {
-		configListeners.fireEvent("configChanged", e); //$NON-NLS-1$
-	}
-
-	/**
-	 * Call the configLoaded method on all registered ConfigChangeListeners.
-	 * This method is called from the ConfigLoaderJob
-	 * thread.
-	 * 
-	 * @param e
-	 *            ConfigEvent to be fired.
-	 */
-	public void fireConfigLoaded(final ConfigEvent e) {
-		configListeners.fireEvent("configLoaded", e); //$NON-NLS-1$
-	}
-
-	/**
-	 * Returns an array of all registered ConfigItem objects implementing the
-	 * given extension point.
-	 * 
-	 * @param extensionPointId
-	 *            ID of the desired extension point.
-	 */
 	private List<ConfigItem> getAllConfigItems(final String extensionPointId) {
+		waitUntilLoaded();
+		lock();
 		try {
-			lock();
 			final List<ConfigItem> result = new ArrayList<ConfigItem>();
-			for (final ConfigSource config : configs.values())
-				result.addAll(config.getValidItems(extensionPointId));
+			for (final ConfigSource configurationSource : configurationSources.values())
+				result.addAll(configurationSource.getValidItems(extensionPointId));
 			return result;
 		} finally {
 			unlock();
@@ -153,16 +108,40 @@
 
 	private List<ConfigSource> getAllConfigSources() {
 		waitUntilLoaded();
+		lock();
 		try {
-			lock();
 			final List<ConfigSource> result = new ArrayList<ConfigSource>();
-			result.addAll(configs.values());
+			result.addAll(configurationSources.values());
 			return result;
 		} finally {
 			unlock();
 		}
 	}
 
+	private void removeConfigSource(final ConfigSource config) {
+		waitUntilLoaded();
+		lock();
+		try {
+			configurationSources.remove(config);
+		} finally {
+			unlock();
+		}
+	}
+	
+	/**
+	 * Locks the registry for modification or iteration over its config sources.
+	 */
+	public void lock() {
+		lock.acquire();
+	}
+
+	/**
+	 * Unlocks the registry.
+	 */
+	public void unlock() {
+		lock.release();
+	}
+
 	private void waitUntilLoaded() {
 		if (!loaded)
 			if (loaderJob == null)
@@ -176,20 +155,6 @@
 	}
 
 	/**
-	 * Returns the IConfigItemFactory object for the given extension point or
-	 * null if none exists.
-	 * 
-	 * @param extensionPointId
-	 *            Extension point ID for which to search.
-	 */
-	public IConfigItemFactory getConfigItemFactory(final String extensionPointId) {
-		for (final IConfigItemFactory factory : configItemFactories)
-			if (factory.getExtensionPointId().equals(extensionPointId))
-				return factory;
-		return null;
-	}
-
-	/**
 	 * Returns true if the Vex configuration has been loaded.
 	 * 
 	 * @see org.eclipse.wst.xml.vex.ui.internal.config.ConfigLoaderJob
@@ -199,21 +164,6 @@
 	}
 
 	/**
-	 * Remove a VexConfiguration from the list of configs.
-	 * 
-	 * @param config
-	 *            VexConfiguration to remove.
-	 */
-	public void removeConfigSource(final ConfigSource config) {
-		try {
-			lock();
-			configs.remove(config);
-		} finally {
-			unlock();
-		}
-	}
-
-	/**
 	 * Adds a ConfigChangeListener to the notification list.
 	 * 
 	 * @param listener
@@ -234,17 +184,25 @@
 	}
 
 	/**
-	 * Locks the registry for modification or iteration over its config sources.
+	 * Call the configChanged method on all registered ConfigChangeListeners.
+	 * 
+	 * @param e
+	 *            ConfigEvent to be fired.
 	 */
-	public void lock() {
-		lock.acquire();
+	public void fireConfigChanged(final ConfigEvent e) {
+		configListeners.fireEvent("configChanged", e); //$NON-NLS-1$
 	}
 
 	/**
-	 * Unlocks the registry.
+	 * Call the configLoaded method on all registered ConfigChangeListeners.
+	 * This method is called from the ConfigLoaderJob
+	 * thread.
+	 * 
+	 * @param e
+	 *            ConfigEvent to be fired.
 	 */
-	public void unlock() {
-		lock.release();
+	public void fireConfigLoaded(final ConfigEvent e) {
+		configListeners.fireEvent("configLoaded", e); //$NON-NLS-1$
 	}
 
 	// new interface
@@ -346,9 +304,8 @@
 	// ======================================================== PRIVATE
 
 	private final ILock lock = Job.getJobManager().newLock();
-	private Map<String, ConfigSource> configs = new HashMap<String, ConfigSource>();
+	private Map<String, ConfigSource> configurationSources = new HashMap<String, ConfigSource>();
 	private final ListenerList<IConfigListener, ConfigEvent> configListeners = new ListenerList<IConfigListener, ConfigEvent>(IConfigListener.class);
-	private final List<IConfigItemFactory> configItemFactories = new ArrayList<IConfigItemFactory>();
 
 	private final IResourceChangeListener resourceChangeListener = new IResourceChangeListener() {
 		public void resourceChanged(final IResourceChangeEvent event) {
diff --git a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/PluginProject.java b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/PluginProject.java
index 7e92e82..d201795 100644
--- a/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/PluginProject.java
+++ b/sourceediting/plugins/org.eclipse.wst.xml.vex.ui/src/org/eclipse/wst/xml/vex/ui/internal/config/PluginProject.java
@@ -174,9 +174,11 @@
 			extElement.setAttribute("id", item.getSimpleId()); //$NON-NLS-1$
 			extElement.setAttribute("name", item.getName()); //$NON-NLS-1$
 			extElement.setAttribute("point", item.getExtensionPointId()); //$NON-NLS-1$
-			final IConfigItemFactory factory = ConfigurationRegistry.INSTANCE.getConfigItemFactory(item.getExtensionPointId());
-			extElement.setChildren(factory.createConfigurationElements(item));
-			root.addChild(extElement);
+			final IConfigItemFactory factory = getConfigItemFactory(item.getExtensionPointId());
+			if (factory != null) {
+				extElement.setChildren(factory.createConfigurationElements(item));
+				root.addChild(extElement);
+			}
 		}
 		writeElement(root, out, 0);