Index: DefaultDataManager.java
===================================================================
--- DefaultDataManager.java	(revision 42890)
+++ DefaultDataManager.java	(revision 42891)
@@ -23,11 +23,11 @@
  */
 package org.gvsig.fmap.dal.impl;
 
+import org.gvsig.fmap.dal.ExternalStoreProviderFactory;
 import java.io.File;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -47,7 +47,6 @@
 import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
 import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
 import org.gvsig.fmap.dal.feature.EditableFeatureType;
-import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureAttributeGetter;
 import org.gvsig.fmap.dal.feature.FeatureQuery;
@@ -57,16 +56,15 @@
 import org.gvsig.fmap.dal.feature.impl.DefaultEditableFeatureType;
 import org.gvsig.fmap.dal.feature.impl.DefaultFeatureIndex;
 import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore;
-import org.gvsig.fmap.dal.feature.impl.dynobjectutils.DynObjectFeatureFacade;
 import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
 import org.gvsig.fmap.dal.feature.paging.impl.FeaturePagingHelperImpl;
-import org.gvsig.fmap.dal.feature.spi.DataStoreProviderToFeatureStoreProviderFactoryWrapper;
 import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider;
 import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
 import org.gvsig.fmap.dal.feature.spi.cache.FeatureCacheProvider;
 import org.gvsig.fmap.dal.feature.spi.cache.FeatureCacheProviderFactory;
 import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProvider;
 import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProviderServices;
+import org.gvsig.fmap.dal.raster.RasterStoreProviderFactory;
 import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider;
 import org.gvsig.fmap.dal.resource.ResourceManager;
 import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
@@ -228,30 +226,22 @@
      * 
      * Store related services
      */
+    @Override
     public void registerStoreProvider(String name, Class storeProviderClass,
         Class parametersClass) {
-        if (name == null || storeProviderClass == null
-            || parametersClass == null) {
-            // FIXME Exception
+        if (name == null || storeProviderClass == null || parametersClass == null) {
             throw new IllegalArgumentException("Any parameters can be null");
         }
 
         if (!DataStoreParameters.class.isAssignableFrom(parametersClass)) {
-            // FIXME Exception
             throw new IllegalArgumentException(parametersClass.getName()
                 + " must implement org.gvsig.fmap.dal.DataStoreParameters");
         }
 
         if (CoverageStoreProvider.class.isAssignableFrom(storeProviderClass)) {
-            ToolsLocator.getExtensionPointManager()
-                .add(DATA_MANAGER_STORE, DATA_MANAGER_STORE_DESCRIPTION)
-                .append(name, null, storeProviderClass);
-
-            ToolsLocator
-                .getExtensionPointManager()
-                .add(DATA_MANAGER_STORE_PARAMS,
-                    DATA_MANAGER_STORE_PARAMS_DESCRIPTION)
-                .append(name, null, parametersClass);
+            // Envuelve al proveedor en una factoria por defecto.
+            this.registerStoreProviderFactory(new DataStoreProviderToCoverageProviderFactoryWrapper(
+                name, "", storeProviderClass, parametersClass));
             return;
         }
 
@@ -351,7 +341,7 @@
             throw new UnauthorizedException(READ_STORE_AUTHORIZATION, parameters, provider);
         }
         
-        // Usa el DynObjectEncoder y no el toString para ver los parametros aunque
+        // Usa el DynObjectEncoder y no el toString para poder ver los parametros aunque
         // el proveedor de datos sobreescriba el metodo toString.
         DynObjectEncoder encoder = ToolsLocator.getDynObjectManager().createSimpleDynObjectEncoder();
         logger.info("openStore('{}','{}')", provider, encoder.encode(parameters));
@@ -360,71 +350,87 @@
 
         parameters.validate();
 
-        DataStore store;
-        try {
-            DataStoreProviderFactory providerFactory;
-            providerFactory =
-                (DataStoreProviderFactory) ToolsLocator
-                    .getExtensionPointManager()
-                    .get(DATA_MANAGER_STORE_PROVIDER_FACTORY).create(name);
-            if (providerFactory != null) {
-                if (FeatureStoreProviderFactory.class
-                    .isAssignableFrom(providerFactory.getClass())) {
-                    store = new DefaultFeatureStore();
-                    this.intializeDataStore(store, parameters);
-                    return store;
-                }
-            }
-        } catch (InstantiationException e1) {
-            // ignore
-        } catch (IllegalAccessException e1) {
-            // ignore
+        DataStoreProviderFactory providerFactory = this.getStoreProviderFactory(name);
+        if( providerFactory == null ) {
+            throw new CantFindTheProviderFactoryException(name);
         }
+        if( providerFactory instanceof FeatureStoreProviderFactory ) {
+            DataStore store = this.createDefaultFeatureStore();
+            this.intializeDataStore(store, parameters);
+            return store;
+            
+        } else if( providerFactory instanceof RasterStoreProviderFactory ) {
+            DataStore store = this.createDefaultRasterStore();
+            this.intializeDataStore(store, parameters);
+            return store;
+            
+        } else if( providerFactory instanceof ExternalStoreProviderFactory ) {
+            DataStoreFactory factory = this.getStoreFactory(name);
+            factory.setParameters(parameters);
+            DataStore store = factory.createStore();
+            this.intializeDataStore(store, parameters);
+            return store;
+            
+        }
+        throw new UnsupportedProviderFactoryException(name,providerFactory);
+    }
 
-        Extension storeProviderExtension =
-            ToolsLocator.getExtensionPointManager().get(DATA_MANAGER_STORE)
-                .get(name);
+    private static class UnsupportedProviderFactoryException extends InitializeException {
+        private static final long serialVersionUID = 2635455949723618046L;
 
-        if (storeProviderExtension == null) {
-            throw new ProviderNotRegisteredException(name);
+        public UnsupportedProviderFactoryException(String resourceName,DataStoreProviderFactory providerFactory) {
+		super("Error intializing resource '%(resource)'. Unsupported provider factory '%(factory).", 
+                    "_UnsupportedProviderFactoryException", 
+                    serialVersionUID
+                );
+		setValue("resource", resourceName);
+		setValue("factory", providerFactory.getClass().getName());
         }
+        
+    }
+    
+    private static class CantFindTheProviderFactoryException extends InitializeException {
+        private static final long serialVersionUID = -2736434434177690011L;
 
-        Class providerClass = storeProviderExtension.getExtension();
-        if (providerClass == null) {
-            throw new ProviderNotRegisteredException(name);
+        public CantFindTheProviderFactoryException(String resourceName) {
+		super("Error intializing resource '%(resource)'. Can't find provider factory for this resource.", 
+                    "_CantFindTheProviderFactoryException", 
+                    serialVersionUID
+                );
+		setValue("resource", resourceName);
         }
-
-        if (CoverageStoreProvider.class.isAssignableFrom(providerClass)) {
-            ExtensionPoint.Extension point =
-                ToolsLocator.getExtensionPointManager()
-                    .get(DATA_MANAGER_STORE_FACTORY).get(name);
-            DataStoreFactory factory = null;
-            try {
-                factory = (DataStoreFactory) point.create();
-            } catch (InstantiationException e) {
-                throw new InitializeException(e);
-            } catch (IllegalAccessException e) {
-                throw new InitializeException(e);
-            }
-            factory.setParameters(parameters);
-            store = factory.createStore();
-        } else
-            if (FeatureStoreProvider.class.isAssignableFrom(providerClass)) {
-
-                store = new DefaultFeatureStore();
-
-            } else {
-                // FIXME Exception
-                throw new InitializeException(name, new RuntimeException(
-                    "Not supported implemtation: name=" + name
-                        + " provider class=" + providerClass.getName()));
-            }
-
-        this.intializeDataStore(store, parameters);
-
-        return store;
+        
     }
-
+    
+    private DataStore createDefaultFeatureStore() {
+        return new DefaultFeatureStore();
+    }
+    
+    private DataStore createDefaultRasterStore() {
+        try {
+            return (DataStore) this.defaultRasterStoreClass.newInstance();
+        } catch (InstantiationException | IllegalAccessException ex) {
+            throw new RuntimeException("Can't create the default RasterStore", ex);
+        }
+    }
+    
+    private Class defaultRasterStoreClass = null;
+    public void registerDefaultRasterStore(Class rasterStoreClass) {
+        this.defaultRasterStoreClass = rasterStoreClass;
+    }
+    
+    private DataStoreFactory getStoreFactory(String name) throws InitializeException {
+        ExtensionPoint.Extension point =
+            ToolsLocator.getExtensionPointManager()
+                .get(DATA_MANAGER_STORE_FACTORY).get(name);
+        try {
+            DataStoreFactory factory = (DataStoreFactory) point.create();
+            return factory;
+        } catch (InstantiationException | IllegalAccessException e) {
+            throw new InitializeException(e);
+        }
+    }
+    
     public DataStore openStore(String provider, DynObject parameters)
         throws InitializeException, ProviderNotRegisteredException,
         ValidateDataParametersException {
@@ -470,15 +476,14 @@
         return names3;
     }
 
+    @Override
     public DataStoreProviderFactory getStoreProviderFactory(String name) {
         try {
             return (DataStoreProviderFactory) ToolsLocator
                 .getExtensionPointManager()
                 .get(DATA_MANAGER_STORE_PROVIDER_FACTORY).create(name);
-        } catch (InstantiationException e) {
+        } catch (InstantiationException | IllegalAccessException e) {
             return null;
-        } catch (IllegalAccessException e) {
-            return null;
         }
     }
 
