Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_data / src / org / gvsig / fmap / data / impl / DefaultDataManager.java @ 23867

History | View | Annotate | Download (21.2 KB)

1
package org.gvsig.fmap.data.impl;
2

    
3
import java.lang.reflect.Constructor;
4
import java.lang.reflect.InvocationTargetException;
5
import java.util.ArrayList;
6
import java.util.HashMap;
7
import java.util.Iterator;
8
import java.util.List;
9
import java.util.Map;
10
import java.util.Set;
11

    
12
import org.gvsig.fmap.data.DALLocator;
13
import org.gvsig.fmap.data.DataExplorer;
14
import org.gvsig.fmap.data.DataExplorerParameters;
15
import org.gvsig.fmap.data.DataManager;
16
import org.gvsig.fmap.data.DataStore;
17
import org.gvsig.fmap.data.DataStoreParameters;
18
import org.gvsig.fmap.data.ResourceManager;
19
import org.gvsig.fmap.data.exceptions.InitializeException;
20
import org.gvsig.fmap.data.exceptions.NotResgisteredStore;
21
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
22
import org.gvsig.fmap.data.feature.FeatureStore;
23
import org.gvsig.fmap.data.feature.FeatureType;
24
import org.gvsig.fmap.data.feature.impl.DefaultFeatureStore;
25
import org.gvsig.fmap.data.feature.spi.DataIndexProvider;
26
import org.gvsig.fmap.data.feature.spi.FeatureStoreProvider;
27
import org.gvsig.tools.evaluator.Evaluator;
28
import org.gvsig.tools.extensionPoint.ExtensionPoint;
29
import org.gvsig.tools.extensionPoint.ExtensionPointsSingleton;
30
import org.gvsig.tools.operations.Operation;
31
import org.gvsig.tools.operations.OperationContext;
32
import org.gvsig.tools.operations.OperationException;
33
import org.gvsig.tools.operations.OperationNotSupportedException;
34

    
35
import com.iver.utiles.NotExistInXMLEntity;
36
import com.iver.utiles.XMLEntity;
37

    
38
public class DefaultDataManager implements DataManager {
39
        private static ArrayList registers = new ArrayList();
40

    
41
        private Class evaluatorClass = null;
42
        private Constructor evaluatorConstructor = null;
43
        
44
        /** This map contains the name of the default provider for each data type */ 
45
        private Map defaultDataIndexProviders = new HashMap();
46

    
47
        /**
48
         * Define extension point names
49
         */
50
        public interface ExtensionPointNames {
51
                public static final String DATAINDEX_PROVIDER = "DataIndexProvider";
52
                public static final String DATASTORE_PROVIDER = "DataStoreProvider";
53
                public static final String DATAEXPLORER_PROVIDER = "DataExplorerProvider";
54
        }
55

    
56
        /*
57
         * Create extension points
58
         */
59
        private static ExtensionPoint dataExplorerProviderEP = new ExtensionPoint(
60
                        ExtensionPointNames.DATAEXPLORER_PROVIDER, "Data Explorer Provider");        
61
        private static ExtensionPoint dataStoreProviderEP = new ExtensionPoint(
62
                        ExtensionPointNames.DATASTORE_PROVIDER, "Data Store Provider");
63
        private static ExtensionPoint dataIndexProviderEP = new ExtensionPoint(
64
                        ExtensionPointNames.DATAINDEX_PROVIDER, "Data Index Provider");
65

    
66
        /*
67
         * Register extension points
68
         */
69
        static {
70
                ExtensionPointsSingleton.getInstance().put(dataExplorerProviderEP);
71
                ExtensionPointsSingleton.getInstance().put(dataStoreProviderEP);
72
                ExtensionPointsSingleton.getInstance().put(dataIndexProviderEP);
73
        }
74
        
75
        /**
76
         *
77
         * @return ResourceManager
78
         */
79

    
80
        public ResourceManager getResourceManager() {
81
                return DALLocator.getResourceManager();
82
        }
83

    
84
        private List dataStoreOperations = new ArrayList();
85

    
86
        public DefaultDataManager() {
87
                //                org.gvsig.fmap.data.feature.driver.shp.Register.selfRegister();
88
                //                org.gvsig.fmap.data.feature.driver.Register.selfRegister();
89

    
90
                //                org.gvsig.fmap.data.gml.Register.selfRegister();
91
        }
92

    
93
        /* (non-Javadoc)
94
         * @see org.gvsig.fmap.data.DataManager#registerDataStore(java.lang.String, java.lang.Class, java.lang.Class)
95
         */
96

    
97
        public void registerDataStoreProvider(String name, Class dataStoreProviderClass, Class parametersClass) {
98
                RegisterInfo register = new RegisterInfo(RegisterInfo.TYPE_STORE, name,
99
                                dataStoreProviderClass, parametersClass);
100
                if (registers.contains(register)){
101
                        return;
102
                }
103
                registers.add(register);
104
        }
105

    
106
        /**
107
         * Levanta una instancia de los parametros solicitados inicializa el nombre
108
         * en la instancia y la devuelve.
109
         *
110
         * @throws InitializeException
111
         * @throws NotResgisteredStore
112
         **/
113
        public DataStoreParameters createDataStoreParameters(String name)
114
                        throws InitializeException, NotResgisteredStore {
115

    
116
                RegisterInfo registerInfo = this.getRegisterByName(name);
117
                if (registerInfo == null){
118
                        throw new NotResgisteredStore(name);
119
                } else if (registerInfo.type != RegisterInfo.TYPE_STORE) {
120
                        throw new NotResgisteredStore(name);
121
                }
122

    
123
                try {
124
                        return (DataStoreParameters)registerInfo.parametersClazz.newInstance();
125
                } catch (InstantiationException e) {
126
                        throw new InitializeException(name,e);
127
                } catch (IllegalAccessException e) {
128
                        throw new InitializeException(name,e);
129
                }
130
        }
131

    
132

    
133

    
134
        /* (non-Javadoc)
135
         * @see org.gvsig.fmap.data.DataManager#createDataStoreParameters(com.iver.utiles.XMLEntity)
136
         */
137
        public DataStoreParameters createDataStoreParameters(XMLEntity xmlEntity)
138
        throws InitializeException, NotResgisteredStore {
139
                String name;
140
                try {
141
                        name = xmlEntity.getStringProperty("dataStoreName");
142
                } catch (NotExistInXMLEntity e) {
143
                        throw new InitializeException(e);
144
                }
145

    
146
                DataStoreParameters params = this.createDataStoreParameters(name);
147

    
148
                params.loadFromXMLEntity(xmlEntity);
149
                return params;
150

    
151
        }
152

    
153
        /**
154
         * Levanta la instancia del datasource, levanta una instancia del driver que
155
         * precisa el datasource y por ultimo invoca al metodo init del datasource.
156
         *
157
         * @throws InitializeException
158
         * @throws NotResgisteredStore
159
         **/
160
        /* (non-Javadoc)
161
         * @see org.gvsig.fmap.data.DataManager#createDataStore(org.gvsig.fmap.data.impl.DataStoreParameters)
162
         */
163
        public DataStore createDataStore(DataStoreParameters parameters)
164
                        throws InitializeException, NotResgisteredStore {
165
                String name = parameters.getDataStoreName();
166

    
167
                RegisterInfo registerInfo = this.getRegisterByName(name);
168
                if (registerInfo == null){
169
                        throw new NotResgisteredStore(name);
170
                }
171

    
172
                if (FeatureStoreProvider.class.isAssignableFrom(registerInfo.clazz)) {
173
                        try {
174
                                FeatureStoreProvider provider = (FeatureStoreProvider) registerInfo.clazz
175
                                                .newInstance();
176

    
177
                                return new DefaultFeatureStore(this, parameters, provider);
178
                        } catch (InstantiationException e) {
179
                                throw new InitializeException(name, e);
180
                        } catch (IllegalAccessException e) {
181
                                throw new InitializeException(name, e);
182
                        }
183

    
184
                }
185
                // FIXME
186
                throw new UnsupportedOperationException();
187

    
188
        }
189

    
190
        /* (non-Javadoc)
191
         * @see org.gvsig.fmap.data.DataManager#createDataStore(com.iver.utiles.XMLEntity)
192
         */
193
        public DataStore createDataStore(XMLEntity xmlEntity)
194
        throws InitializeException, NotResgisteredStore {
195
                try {
196
                        Class storeClass = Class.forName(xmlEntity
197
                                        .getStringProperty("className"));
198
                        Constructor constructor = storeClass.getConstructor(new Class[] {DataManager.class,XMLEntity.class});
199
                        return (DataStore) constructor.newInstance(new Object[]{this,xmlEntity});
200
                } catch (Exception e) {
201
                        throw new InitializeException(e);
202
                }
203

    
204
        }
205

    
206

    
207
        /** Como conjunto de propiedades genericas a un tipo de DataStore
208
         * a las que se puede acceder sin tener que crear un DataStore/Driver.
209
         *
210
         * Por ejemplo para "DriverDataSource.shp" podria tener el
211
         * tamaƱo de identificador de campo.
212
         *
213
         * En "DriverDataSource.postgres" podria aportar informacion sobre
214
         * las tablas disponibles o cosas asi. Hay que ver que precisa
215
         * GeoDB y de donde lo puede obtener.
216
         *
217
         * Hay que pensarlo bien.
218
         *
219
         */
220

    
221
        /**
222
         * Collection of generic properties of a DataStore type which can access
223
         * without create a DataStore/Driver.
224
         *
225
         * For example for "DriverDataSource.shp" could have the size of the data
226
         * identification.
227
         *
228
         * In "DriverDataSource.postgres" could add information about availables
229
         * tables or things like that. We`ll have to see what GeoDB needs and where
230
         * it can get.
231
         *
232
         * We have to think it good.
233
         */
234
        /* (non-Javadoc)
235
         * @see org.gvsig.fmap.data.DataManager#registerDataExplorer(java.lang.String, java.lang.Class, java.lang.Class)
236
         */
237

    
238

    
239
        public void registerDataExplorer(String name, Class dataSourceClass, Class parametersClass) {
240
                RegisterInfo register = new RegisterInfo(RegisterInfo.TYPE_EXPLORER,
241
                                name, dataSourceClass, parametersClass);
242
                if (registers.contains(register)){
243
                        return;
244
                }
245
                registers.add(register);
246
        }
247

    
248
        /**
249
         * Levanta una instancia de los parametros solicitados inicializa el nombre
250
         * en la instancia y la devuelve.
251
         *
252
         * @throws InitializeException
253
         *             TODO
254
         * @throws NotResgisteredStore
255
         **/
256

    
257
        public DataExplorerParameters createDataExplorerParameters(String name)
258
                        throws InitializeException, NotResgisteredStore {
259
                RegisterInfo registerInfo = this.getRegisterByName(name);
260
                if (registerInfo == null){
261
                        throw new NotResgisteredStore(name);
262
                } else if (registerInfo.type != RegisterInfo.TYPE_EXPLORER) {
263
                        throw new NotResgisteredStore(name);
264
                }
265

    
266
                try {
267
                        return (DataExplorerParameters)registerInfo.parametersClazz.newInstance();
268
                } catch (InstantiationException e) {
269
                        throw new InitializeException(name,e);
270
                } catch (IllegalAccessException e) {
271
                        throw new InitializeException(name,e);
272
                } catch (Exception e) {
273
                        // TODO: de momento para los class en el caso de que no exista el explorer.
274
                        throw new InitializeException(name, e);
275
                }
276
        }
277

    
278
        /* (non-Javadoc)
279
         * @see org.gvsig.fmap.data.DataManager#createDataExplorerParameters(com.iver.utiles.XMLEntity)
280
         */
281

    
282
        public DataExplorerParameters createDataExplorerParameters(
283
                        XMLEntity xmlEntity) throws InitializeException,
284
                        NotResgisteredStore {
285
                String name = null;
286
                try {
287
                        name = xmlEntity.getStringProperty("dataExplorerName");
288
                } catch (NotExistInXMLEntity e) {
289
                        throw new InitializeException(e);
290
                }
291
                DataExplorerParameters params = this.createDataExplorerParameters(name);
292

    
293
                params.loadFromXMLEntity(xmlEntity);
294

    
295
                return params;
296
        }
297

    
298
        /* (non-Javadoc)
299
         * @see org.gvsig.fmap.data.DataManager#createDataExplorer(org.gvsig.fmap.data.impl.DataExplorerParameters)
300
         */
301
        public DataExplorer createDataExplorer(DataExplorerParameters parameters)
302
                        throws InitializeException, NotResgisteredStore {
303
                RegisterInfo registerInfo = this.getRegisterByName(parameters.getDataExplorerName());
304
                if (registerInfo == null){
305
                        throw new NotResgisteredStore(parameters.getDataExplorerName());
306
                }
307
                try {
308
                        DataExplorer dataSource= (DataExplorer)registerInfo.clazz.newInstance();
309
                        dataSource.init(parameters);
310
                        return dataSource;
311
                } catch (InstantiationException e) {
312
                        throw new InitializeException(parameters.getDataExplorerName(),e);
313
                } catch (IllegalAccessException e) {
314
                        throw new InitializeException(parameters.getDataExplorerName(),e);
315
                }
316
        }
317

    
318
        /* (non-Javadoc)
319
         * @see org.gvsig.fmap.data.DataManager#createDataExplorer(com.iver.utiles.XMLEntity)
320
         */
321

    
322

    
323
        public DataExplorer createDataExplorer(XMLEntity xmlEntity)
324
        throws InitializeException, NotResgisteredStore {
325

    
326
                String name;
327
                try {
328
                        name = xmlEntity.getStringProperty("dataExplorerName");
329
                } catch (NotExistInXMLEntity e) {
330
                        throw new InitializeException(e);
331
                }
332

    
333
                RegisterInfo registerInfo = this.getRegisterByName(name);
334
                if (registerInfo == null) {
335
                        throw new NotResgisteredStore(name);
336
                }
337
                try {
338
                        DataExplorer dataSource = (DataExplorer) registerInfo.clazz
339
                        .newInstance();
340
                        dataSource.init(xmlEntity);
341
                        return dataSource;
342
                } catch (InstantiationException e) {
343
                        throw new InitializeException(name, e);
344
                } catch (IllegalAccessException e) {
345
                        throw new InitializeException(name, e);
346
                }
347
        }
348

    
349
        private RegisterInfo getRegisterByName(String name){
350
                Iterator iterator=registers.iterator();
351
                while (iterator.hasNext()) {
352
                        RegisterInfo registerInfo = (RegisterInfo) iterator.next();
353
                        if (name.equalsIgnoreCase(registerInfo.name)) {
354
                                return registerInfo;
355
                        }
356
                }
357
                return null;
358
        }
359

    
360
        /* (non-Javadoc)
361
         * @see org.gvsig.fmap.data.DataManager#registerDataStoreOperation(java.lang.String, java.lang.String, org.gvsig.fmap.data.operation.DataStoreOperation)
362
         */
363

    
364

    
365

    
366
        public int registerDataStoreOperation(String storeName, String operationName, Operation operation) {
367
                if (operationName == null){
368
                        throw new IllegalArgumentException("operationName cannot be null.");
369
                }
370
                if (operation == null){
371
                        throw new IllegalArgumentException("operation cannot be null.");
372
                }
373

    
374
                RegisterInfo register = this.getRegisterByName(storeName);
375
                if (register == null){
376
                        throw new IllegalArgumentException(storeName + " not registered");
377
                }
378
                int index = registerGeometryOperationName(operationName);
379

    
380
                register.registerOperation(index, operation);
381

    
382
                return index;
383
        }
384

    
385
        /**
386
         *
387
         * @param String
388
         *            operationName
389
         * @return int index
390
         * @throws IllegalArgumentException
391
         */
392

    
393
        private int registerGeometryOperationName(String operationName) {
394
                if (operationName == null) {
395
                        throw new IllegalArgumentException("operationName cannot be null.");
396
                }
397

    
398

    
399
                int index = this.getOperationIndex(operationName);
400

    
401
                //                int index = dataStoreOperations .indexOf(operationName);
402
                if (index == -1) {
403
                        dataStoreOperations.add(operationName);
404
                        index = dataStoreOperations.indexOf(operationName);
405
                }
406
                return index;
407
        }
408

    
409
        /**
410
         *
411
         * @param String
412
         *            operationName
413
         * @return int index
414
         */
415

    
416
        private int getOperationIndex(String operationName) {
417
                int index = -1;
418
                for (int i = 0; i < dataStoreOperations.size(); i++) {
419
                        if (((String) dataStoreOperations.get(i))
420
                                        .equalsIgnoreCase(operationName)) {
421
                                index = i;
422
                                break;
423
                        }
424
                }
425
                return index;
426
        }
427

    
428
        /**
429
         *
430
         * @param DataStore
431
         *            store
432
         * @param int code
433
         * @param DataStoreOperationContext
434
         *            context
435
         * @return Object
436
         * @throws OperationException
437
         * @throws DataStoreOperationNotSupportedException
438
         */
439

    
440
        public Object invokeDataStoreOperation(DataStore store, int code,
441
                        OperationContext context) throws OperationException,
442
                        OperationNotSupportedException {
443
                if (code < 0 || code >= dataStoreOperations.size()) {
444
                        throw new OperationNotSupportedException(code, "{unknow}");
445
                }
446
                RegisterInfo register = this.getRegisterByName(store.getName());
447
                Operation operation = register.getOperation(code);
448
                if (operation == null){
449
                        throw new OperationNotSupportedException(code,
450
                                        (String) this.dataStoreOperations.get(code));
451
                }
452
                return operation.invoke(store, context);
453

    
454
        }
455

    
456
        /**
457
         *
458
         * @param DataStore
459
         *            store
460
         * @param String
461
         *            operationName
462
         * @param OperationContext
463
         *            context
464
         * @return Object
465
         * @throws OperationException
466
         * @throws OperationNotSupportedException
467
         */
468

    
469
        public Object invokeDataStoreOperation(DataStore store,
470
                        String operationName, OperationContext context)
471
        throws OperationException, OperationNotSupportedException {
472
                return this.invokeDataStoreOperation(store, this.getOperationIndex(operationName), context);
473
        }
474

    
475
        private class RegisterInfo{
476
                public static final String TYPE_STORE = "store";
477
                public static final String TYPE_EXPLORER = "explorer";
478

    
479
                private String name;
480
                private String type;
481
                private Class clazz;
482
                private Class parametersClazz;
483
                private List operations = new ArrayList();
484

    
485
                /**
486
                 *
487
                 * @param String
488
                 *            type
489
                 * @param String
490
                 *            name
491
                 * @param Class
492
                 *            dsc
493
                 * @param Class
494
                 *            pc
495
                 */
496

    
497
                public RegisterInfo(String type, String name, Class dsc, Class pc) {
498
                        this.type = type;
499
                        this.name=name;
500
                        this.clazz=dsc;
501
                        this.parametersClazz=pc;
502
                }
503

    
504
                /*
505
                 * (non-Javadoc)
506
                 * @see java.lang.Object#equals(java.lang.Object)
507
                 */
508

    
509
                public boolean equals(Object obj) {
510
                        if (obj instanceof RegisterInfo){
511
                                RegisterInfo ri = (RegisterInfo)obj;
512
                                return ri.name.equals(this.name) &&
513
                                ri.clazz.equals(this.clazz) &&
514
                                ri.parametersClazz.equals(this.parametersClazz);
515
                        }
516
                        return super.equals(obj);
517
                }
518

    
519
                /**
520
                 *
521
                 * @param int index
522
                 * @param DataStoreOperation
523
                 *            operation
524
                 */
525

    
526
                public void registerOperation(int index, Operation operation) {
527

    
528
                        while (index > operations.size()) {
529
                                operations.add(null);
530
                        }
531

    
532
                        if (index == operations.size()) {
533
                                operations.add(operation);
534
                        } else {
535
                                operations.set(index, operation);
536
                        }
537
                }
538

    
539
                /**
540
                 *
541
                 * @param int index
542
                 * @return DataStoreOperation
543
                 */
544

    
545
                public Operation getOperation(int index) {
546
                        try{
547
                                return (Operation) this.operations.get(index);
548
                        }catch (IndexOutOfBoundsException  e) {
549
                                return null;
550
                        }
551
                }
552

    
553

    
554
        }
555

    
556
        /**
557
         *
558
         * @param String
559
         *            toreName
560
         * @param String
561
         *            operationName
562
         * @return boolean
563
         */
564

    
565
        public boolean implementsDataStoreOperation(
566
                        String storeName, String operationName) {
567
                return this.implementsDataStoreOperation(storeName, this.getOperationIndex(operationName));
568
        }
569

    
570
        /**
571
         *
572
         * @param String
573
         *            storeName
574
         * @param int operationCode
575
         * @return boolean
576
         */
577

    
578
        public boolean implementsDataStoreOperation(
579
                        String storeName, int operationCode) {
580
                RegisterInfo register = this.getRegisterByName(storeName);
581
                Operation operation = register.getOperation(operationCode);
582
                if (operation == null){
583
                        return false;
584
                }
585
                return true;
586
        }
587

    
588
        /**
589
         *
590
         * @return String[] reg
591
         */
592

    
593
        public String[] getRegisters() {
594
                String[] reg=new String[registers.size()];
595
                for (int i = 0; i < registers.size(); i++) {
596
                        reg[i]=((RegisterInfo)registers.get(i)).name;
597
                }
598
                return reg;
599
        }
600

    
601
        /* (non-Javadoc)
602
         * @see org.gvsig.fmap.data.DataManager#getRegistersStores()
603
         */
604

    
605
        public String[] getRegistersStores() {
606
                return this.getRegisterOfType(RegisterInfo.TYPE_STORE);
607
        }
608

    
609
        /* (non-Javadoc)
610
         * @see org.gvsig.fmap.data.DataManager#getRegistersExplorers()
611
         */
612

    
613
        public String[] getRegistersExplorers() {
614
                return this.getRegisterOfType(RegisterInfo.TYPE_EXPLORER);
615
        }
616

    
617
        /**
618
         *
619
         * @param String
620
         *            type
621
         * @return String[]
622
         */
623

    
624
        private String[] getRegisterOfType(String type) {
625
                List reg = new ArrayList();
626
                RegisterInfo info = null;
627
                for (int i = 0; i < registers.size(); i++) {
628
                        info =(RegisterInfo) registers.get(i);
629
                        if (info.type == type) {
630
                                reg.add(info.name);
631
                        }
632
                }
633
                return (String[]) reg.toArray(new String[0]);
634

    
635
        }
636

    
637

    
638
        public Evaluator createExpresion(String expresion) {
639
                try {
640
                        return (Evaluator) this.evaluatorConstructor.newInstance(new Object[] {expresion});
641
                } catch (InstantiationException e) {
642
                        throw new IllegalArgumentException();
643
                } catch (IllegalAccessException e) {
644
                        throw new IllegalArgumentException();
645
                } catch (InvocationTargetException e) {
646
                        throw new IllegalArgumentException();
647
                }
648
        }
649

    
650
        public void registerDefaultEvaluator(Class evaluatorClass) {
651
                if (!evaluatorClass.isInstance(Evaluator.class)) {
652
                        throw new ClassCastException();
653
                }
654
                try {
655
                        this.evaluatorConstructor = evaluatorClass
656
                                        .getConstructor(new Class[] { String.class });
657
                } catch (SecurityException e) {
658
                        throw new ClassCastException();
659
                } catch (NoSuchMethodException e) {
660
                        throw new ClassCastException();
661
                }
662
                this.evaluatorClass = evaluatorClass;
663
        }
664

    
665
        public DataIndexProvider createDataIndexProvider(FeatureStore store,
666
                        FeatureType type, FeatureAttributeDescriptor attr,
667
                        String[] providerNames) throws InitializeException, NotResgisteredStore {
668
                
669
                String name = null;
670
                
671
                // look up the specified preferred providers. The first found is chosen
672
                if (providerNames != null) {
673
                        boolean notFound = true;
674
                        for (int i = 0; i < providerNames.length && notFound; i++) {  
675
                                if (dataIndexProviderEP.containsKey(providerNames[i])) {
676
                                        notFound = false;
677
                                        name = providerNames[i];
678
                                }
679
                        }
680
                }
681
                
682
                // if no preferred providers were specified or none was found, use the default one
683
                if (providerNames == null || name == null) {
684
                        name = getDefaultDataIndexProviderName(attr.getDataType());
685
                }
686
                
687
                // instantiate, initialize and return it
688
                try {                        
689
                        DataIndexProvider dataIndexProvider = (DataIndexProvider) dataIndexProviderEP.create(name);
690
                        dataIndexProvider.initialize();
691
                        return dataIndexProvider;
692
                } catch (IllegalAccessException e) {
693
                        throw new NotResgisteredStore(name);
694
                } catch (InstantiationException e) {
695
                        throw new InitializeException(name, e);
696
                }
697
        }
698

    
699
        public DataIndexProvider createDataIndexProvider(FeatureStore store,
700
                        FeatureType type, FeatureAttributeDescriptor attr) throws InitializeException, NotResgisteredStore {
701
                return createDataIndexProvider(store, type, attr, null);
702
        }
703

    
704
        public String[] getDataIndexProviders(int dataType) {
705
                //FIXME
706
                Set set = dataIndexProviderEP.keySet();
707
                return (String[])set.toArray();
708
        }
709

    
710
        public String getTemporaryDirectory() {
711
                // FIXME Define a better tempdir solution
712
                String tmp = System.getenv("TMP");
713
                if (tmp == null) {
714
                        tmp = System.getenv("TEMP");
715
                }
716
                if (tmp == null) {
717
                        tmp = System.getenv("HOME");
718
                }
719
                return tmp;
720
        }
721

    
722
        public void registerDataIndexProvider(String name, String description, Class clazz) {
723
                dataIndexProviderEP.put(name, description, clazz);
724
        }
725
        
726
        public void setDefaultDataIndexProviderName(int dataType, String name) {
727
                defaultDataIndexProviders.put(new Integer(dataType), name);
728
        }
729
        
730
        public String getDefaultDataIndexProviderName(int dataType) {
731
                return (String) defaultDataIndexProviders.get(new Integer(dataType));                
732
        }
733

    
734
}