Revision 35988

View differences:

tags/dal_time_support_Build_0/libraries/libFMap_dal/resources-test/log4j.xml
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
5

  
6
    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
7
        <layout class="org.apache.log4j.PatternLayout">
8
            <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n"/>
9
        </layout>
10
    </appender>
11

  
12
  <category name="org.gvsig.fmap.dal">
13
    <priority value="WARN"/>
14
  </category>
15

  
16
    <root>
17
        <priority value="INFO" />
18
        <appender-ref ref="CONSOLE" />
19
    </root>
20
</log4j:configuration>
0 21

  
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/DataParameters.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.dal;
29

  
30
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
31
import org.gvsig.tools.dynobject.DynObject;
32
import org.gvsig.tools.persistence.Persistent;
33

  
34
/**
35
 * This interface is a generic persistent parameter container. It is used in a
36
 * variety of contexts in which a set of arbitrary parameters is needed.
37
 */
38
public interface DataParameters extends Persistent, DynObject {
39

  
40
	/**
41
	 * clears the parameter container.
42
	 */
43
	public void clear();
44

  
45
	/**
46
	 * Creates and returns a new copy of this DataParameters.
47
	 *
48
	 * @return a new copy of this
49
	 */
50
	public DataParameters getCopy();
51

  
52
	/**
53
	 * Checks its valid
54
	 *
55
	 * @throws ValidateDataParametersException
56
	 *             if any problem was detected
57
	 */
58
	public void validate() throws ValidateDataParametersException;
59
}
0 60

  
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/DataStoreNotification.java
1
package org.gvsig.fmap.dal;
2

  
3
/**
4
 * This interface represents a notification produced by a DataStore.
5
 * 
6
 * Notifications can be of several types. This interface also defines a set 
7
 * of constants that represent the types of notifications that a DataStore 
8
 * can produce.
9
 */
10
public interface DataStoreNotification {
11

  
12
	/** Complex notification for special situations */
13
	public static final String COMPLEX_NOTIFICATION = "complex_notification";
14

  
15
	/** Fired before opening the store */
16
	public static final String BEFORE_OPEN = "before_Open_DataStore";
17
	
18
	/** Fired after opening the store */
19
	public static final String AFTER_OPEN = "after_Open_DataStore";
20

  
21
	/** Fired before closing the store */
22
	public static final String BEFORE_CLOSE = "before_Close_DataStore";
23
	
24
	/** Fired after closing the store */
25
	public static final String AFTER_CLOSE = "after_Close_DataStore";
26

  
27
	/** Fired before disposing the store */
28
	public static final String BEFORE_DISPOSE = "before_Dispose_DataStore";
29
	
30
	/** Fired after disposing the store */
31
	public static final String AFTER_DISPOSE = "after_Dispose_DataStore";
32

  
33
	/** Fired after the store selection has changed */
34
	public static final String SELECTION_CHANGE = "after_SelectionChange_DataStore";
35

  
36
	/** Fired when a resource of the store has changed */
37
	public static final String RESOURCE_CHANGED = "resourceChange_DataStore";
38

  
39
	/**
40
	 * Returns the DataStore that produced this notification
41
	 * @return DataStore source of this
42
	 */
43
	public DataStore getSource();
44
	
45
	/**
46
	 * Returns the type of this notification, represented by one of the constants defined in this interface.
47
	 * @return a String containing this notification's type
48
	 */
49
	public String getType();
50

  
51
}
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/DataTypes.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.dal;
23

  
24
/**
25
 * This interface defines a set of constants for all data types supported by the
26
 * DAL.
27
 * 
28
 * @author gvSIG Team
29
 * @version $Id$
30
 * 
31
 */
32
public interface DataTypes extends org.cresques.DataTypes,
33
    org.gvsig.fmap.geom.DataTypes, org.gvsig.timesupport.DataTypes {
34

  
35
	
36
}
0 37

  
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/DataQuery.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {DiSiD Technologies}  {Create Parameter object to define queries}
26
 */
27
package org.gvsig.fmap.dal;
28

  
29
import org.gvsig.tools.persistence.Persistent;
30

  
31
/**
32
 * Defines the properties of a collection of data, as a result of a query
33
 * through a DataStore.
34
 * <p>
35
 * The scale parameter can be used by the DataStore as a hint about the quality
36
 * or resolution of the data needed to view or operate with the data returned.
37
 * As an example, it may use the scale to return only a representative subset of
38
 * the data, or maybe to return Data with less detail, like a point or a line
39
 * instead of a polygon.
40
 * </p>
41
 * 
42
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
43
 */
44
public interface DataQuery extends Persistent {
45

  
46
    /**
47
     * Sets the scale.
48
     *
49
     * @param scale
50
     *            the scale to set
51
     */
52
	void setScale(double scale);
53

  
54
	/**
55
	 * Returns the scale of the data to load.
56
	 * 
57
	 * @return the scale of the data to load
58
	 */
59
	double getScale();
60

  
61
	/**
62
	 * Returns the value of an query parameter.
63
	 *
64
	 * @param name
65
	 *            of the parameter
66
	 * @return the parameter value
67
	 */
68
	Object getQueryParameter(String name);
69

  
70
	/**
71
	 * Sets the value of an query parameter.
72
	 *
73
	 * @param name
74
	 *            of the query parameter
75
	 * @param value
76
	 *            for the query parameter
77
	 */
78
	void setQueryParameter(String name, Object value);
79

  
80
}
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/DataManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 IVER T.I. S.A.   {{Task}}
26
 */
27
package org.gvsig.fmap.dal;
28

  
29
import java.util.List;
30

  
31
import org.gvsig.fmap.dal.exception.InitializeException;
32
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
33
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
34
import org.gvsig.fmap.dal.feature.Feature;
35
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
36
import org.gvsig.fmap.dal.feature.FeatureAttributeGetter;
37
import org.gvsig.fmap.dal.feature.FeatureIndex;
38
import org.gvsig.fmap.dal.feature.FeatureQuery;
39
import org.gvsig.fmap.dal.feature.FeatureStore;
40
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
41
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProvider;
42
import org.gvsig.fmap.dal.resource.ResourceManager;
43
import org.gvsig.fmap.dal.store.memory.MemoryStoreProvider;
44
import org.gvsig.tools.dynobject.DynObject;
45
import org.gvsig.tools.evaluator.Evaluator;
46
import org.gvsig.tools.exception.BaseException;
47

  
48
/**
49
 * There are two top level management roles within DAL: data access and resource management.
50
 *
51
 * This class is responsible of the data access management role. It provides ways
52
 * for registering and instantiating {@link DataServerExplorer}(s), {@link DataStore}(s),
53
 * {@link Evaluator}(s) and {@link FeatureIndex}(es).
54
 *
55
 * @see ResourceManager
56
 *
57
 */
58

  
59
public interface DataManager {
60

  
61
	/**
62
	 * Returns the default DAL's temporary directory
63
	 *
64
	 * @return Temporary directory name
65
	 */
66
	public String getTemporaryDirectory();
67

  
68
	/*
69
	 * ====================================================================
70
	 *
71
	 * Store related services
72
	 */
73

  
74
	/**
75
	 * Creates, initializes and returns an instance of DataStoreParameters given
76
	 * the name with which their provider is registered.
77
	 * 
78
	 * @param name
79
	 *            provider name
80
	 * 
81
	 * @throws ProviderNotRegisteredException
82
	 *             if the memory provider is not registered
83
	 * @throws InitializeException
84
	 *             if there is an error initializing the parameters for the
85
	 *             memory provider
86
	 **/
87
	public DataStoreParameters createStoreParameters(String name)
88
			throws InitializeException, ProviderNotRegisteredException;
89

  
90
	/**
91
	 * 
92
	 * Creates, initializes and returns an instance of NewDataStoreParameters
93
	 * given the name with which their provider is registered.
94
	 * 
95
	 * @param name
96
	 * 
97
	 * @throws InitializeException
98
	 * @throws ProviderNotRegisteredException
99
	 */
100
	public NewDataStoreParameters createNewStoreParameters(String explorer, String provider)
101
			throws InitializeException, ProviderNotRegisteredException;
102

  
103
	/**
104
	 * 
105
	 * Creates, initializes and returns an instance of DataStore given the
106
	 * DataStoreParameters.
107
	 * 
108
	 * @param parameters
109
	 *            parameters used to instantiate and initialize the DataStore
110
	 * 
111
	 * @throws ProviderNotRegisteredException
112
	 *             if the memory provider is not registered
113
	 * @throws InitializeException
114
	 *             if there is an error initializing the parameters for the
115
	 *             memory provider
116
	 * @throws ValidateDataParametersException
117
	 *             if the parameters to open the memory based store are not
118
	 *             valid
119
	 */
120
	public DataStore openStore(String provider, DataStoreParameters parameters)
121
			throws InitializeException, ProviderNotRegisteredException,
122
			ValidateDataParametersException;
123

  
124
	/**
125
	 * @deprecated see openStore
126
	 */
127
	public DataStore createStore(DataStoreParameters parameters)
128
			throws InitializeException, ProviderNotRegisteredException,
129
			ValidateDataParametersException;
130

  
131
	/**
132
	 * Create a new physical store 
133
	 *  
134
	 * @param parameters
135
	 *
136
	 * @throws InitializeException
137
	 * @throws ProviderNotRegisteredException
138
	 * @throws ValidateDataParametersException
139
	 */
140
	public void newStore(String explorer, String provider, NewDataStoreParameters parameters, boolean overwrite)
141
			throws InitializeException, ProviderNotRegisteredException,
142
			ValidateDataParametersException;
143

  
144
	/**
145
	 * Returns a list of Strings containing the names of all available DataStore
146
	 * providers.
147
	 *
148
	 * @return list of String containing available DataStore provider names
149
	 */
150
	public List getStoreProviders();
151

  
152
	/**
153
	 * Returns a list of Strings containing the names of all available DataStore
154
	 * providers for an explorer.
155
	 * 
156
	 * @param explorer
157
	 *            name
158
	 */
159
	public List getStoreProviders(String name);
160

  
161
	/*
162
	 * ====================================================================
163
	 *
164
	 * Explorer related services
165
	 */
166
	/**
167
	 * Returns an instance of {@link DataServerExplorerParameters} corresponding to
168
	 * the given name.
169
	 *
170
	 * @param name
171
	 *            name of a registered server explorer provider
172
	 *
173
	 * @throws InitializeException
174
	 * 			if parameter initialization causes an error.
175
	 *
176
	 * @throws ProviderNotRegisteredException
177
	 * 			if could not find a provider by the given name.
178
	 *
179
	 **/
180
	public DataServerExplorerParameters createServerExplorerParameters(
181
			String name)
182
			throws InitializeException, ProviderNotRegisteredException;
183

  
184
	/**
185
	 * Returns an instance of {@link DataServerExplorer} given its parameters.
186
	 *
187
	 * @param parameters
188
	 *            parameters used to instantiate and initialize the
189
	 *            {@link DataServerExplorer}.
190
	 *
191
	 * @return an instance of {@link DataServerExplorer}.
192
	 *
193
	 * @throws InitializeException
194
	 *
195
	 * @throws ProviderNotRegisteredException
196
	 * @throws ValidateDataParametersException
197
	 */
198
	public DataServerExplorer openServerExplorer(
199
			String name,
200
			DataServerExplorerParameters parameters)
201
			throws InitializeException, ProviderNotRegisteredException,
202
			ValidateDataParametersException;
203

  
204
	/**
205
	 * @deprecated see openServerExplorer
206
	 */
207
	public DataServerExplorer createServerExplorer(
208
			DataServerExplorerParameters parameters)
209
			throws InitializeException, ProviderNotRegisteredException,
210
			ValidateDataParametersException;
211

  
212
	/**
213
	 * Returns a list of String containing the names of the available
214
	 * DataServerExplorer providers.
215
	 *
216
	 * @return list of String containing the names of the available
217
	 *         DataServerExplorer providers.
218
	 */
219
	public List getExplorerProviders();
220

  
221
	/*
222
	 * ====================================================================
223
	 *
224
	 * Expression evaluation related services
225
	 */
226

  
227
	/**
228
	 * Registers the default expression evaluator. It is used by DAL to evaluate
229
	 * and resolve query filters and expressions.
230
	 *
231
	 * @param evaluator
232
	 *            Class that will be called to evaluate the expression. It must
233
	 *            implement {@link Evaluator}.
234
	 */
235
	public void registerDefaultEvaluator(Class evaluator);
236

  
237
	/**
238
	 * Creates an instance of Evaluator that represents the given expression.
239
	 *
240
	 * @param expression
241
	 *            String containing a CQL expression.
242
	 * @return instance of Evaluator representing the given expression.
243
	 * @throws InitializeException
244
	 */
245
	public Evaluator createExpresion(String expression)
246
			throws InitializeException;
247

  
248
	/*
249
	 * ====================================================================
250
	 *
251
	 * Index related services
252
	 */
253

  
254

  
255
	/**
256
	 * Returns a list of String containing the names of the available index providers.
257
	 *
258
	 * @return
259
	 * 		list of strings with the names of the available index providers
260
	 */
261
	public List getFeatureIndexProviders();
262

  
263
	/**
264
	 * Sets the default DataIndexProvider for the given data type.
265
	 *
266
	 * @param dataType
267
	 * 				one of the data types defined in {@link DataTypes}.
268
	 * @param name
269
	 * 			Provider's name
270
	 */
271
    public void setDefaultFeatureIndexProviderName(int dataType, String name);
272

  
273
	/**
274
	 * Returns the default DataIndexProvider name, given a data type. Data types
275
	 * are defined in {@link DataTypes}.
276
	 *
277
	 * @param dataType
278
	 *            one of the constants in {@link DataTypes}.
279
	 *
280
	 * @return
281
	 * 		the name of the default {@link FeatureIndexProvider} if there is
282
	 * 		anyone available for the given data type.
283
	 */
284
    public String getDefaultFeatureIndexProviderName(int dataType);
285

  
286
    /**
287
	 * Returns a list of String containing the names of the available cache providers.
288
	 *
289
	 * @return
290
	 * 		list of strings with the names of the available cache providers
291
	 */    
292
    public List getFeatureCacheProviders();
293

  
294
	/**
295
	 * Returns an instance of {@link DataServerExplorerParameters} corresponding
296
	 * to the given name used by the cache to create a store to save the
297
	 * retrieved data.
298
	 * 
299
	 * @param name
300
	 *            name of a registered feature cache provider
301
	 * 
302
	 * @throws InitializeException
303
	 *             if parameter initialization causes an error.
304
	 * 
305
	 * @throws ProviderNotRegisteredException
306
	 *             if could not find a cache provider by the given name.
307
	 * 
308
	 */
309
	public DynObject createCacheParameters(String name)
310
			throws InitializeException, ProviderNotRegisteredException;
311

  
312
	/**
313
	 * Utility method to create the {@link DataStoreParameters} to create a
314
	 * {@link FeatureStore} based on the {@link MemoryStoreProvider}.
315
	 * 
316
	 * @param autoOrderAttributeName
317
	 *            the name of the {@link Feature} attribute to be used to order
318
	 *            the store {@link Feature}s by default. Set to null if you
319
	 *            don't want any order by default
320
	 * @return the parameters for the memory based store
321
	 * @throws InitializeException
322
	 *             if there is an error initializing the parameters for the
323
	 *             memory provider
324
	 */
325
	public DataStoreParameters createMemoryStoreParameters(
326
			String autoOrderAttributeName) throws InitializeException;
327

  
328
	/**
329
	 * Utility method to create the a {@link FeatureStore} based on the
330
	 * {@link MemoryStoreProvider}.
331
	 * 
332
	 * @param autoOrderAttributeName
333
	 *            the name of the {@link Feature} attribute to be used to order
334
	 *            the store {@link Feature}s by default. Set to null if you
335
	 *            don't want any order by default
336
	 * @return the the memory based store
337
	 * @throws InitializeException
338
	 *             if there is an error initializing the parameters for the
339
	 *             memory provider
340
	 */
341
	public FeatureStore createMemoryStore(String autoOrderAttributeName)
342
			throws InitializeException;
343

  
344
    /**
345
     * Creates a {@link FeaturePagingHelper} to paginate data from a
346
     * {@link FeatureStore}.
347
     * 
348
     * @param featureStore
349
     *            to get the {@link Feature}s from
350
     * @param pageSize
351
     *            the page size
352
     * @return a {@link FeaturePagingHelper}
353
     * @throws BaseException
354
     *             if there is an error creating the helper
355
     */
356
	public FeaturePagingHelper createFeaturePagingHelper(
357
        FeatureStore featureStore, int pageSize) throws BaseException;
358

  
359
	/**
360
     * Creates a {@link FeaturePagingHelper} to paginate data from a
361
     * {@link FeatureStore}.
362
     * 
363
     * @param featureStore
364
     *            to get the {@link Feature}s from
365
     * @param featureQuery
366
     *            to filter and/or order the data
367
     * @param pageSize
368
     *            the page size
369
     * @return a {@link FeaturePagingHelper}
370
     * @throws BaseException
371
     *             if there is an error creating the helper
372
     */
373
	public FeaturePagingHelper createFeaturePagingHelper(
374
			FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
375
        throws BaseException;
376
	
377
	/**
378
	 * Registers a class that can be used to create a {@link FeatureAttributeGetter}
379
	 * and associate it to a {@link FeatureAttributeDescriptor}.
380
	 * 
381
   	 * @param name
382
   	 *             the name used to register the class.
383
	 * @param clazz
384
	 *             it has to be an instance of {@link FeatureAttributeDescriptor}         
385
	 */
386
	public void registerFeatureAttributeGetter(String name, Class clazz);
387
	
388
	/**
389
	 * Creates a {@link FeatureAttributeGetter} by name. If there is not any class
390
	 * registered with this name or if there is any error an exception is thrown.
391
	 * 
392
	 * @param name
393
	 *             the name that was used to register the class              
394
	 * @return
395
	 *             a {@link FeatureAttributeGetter}
396
	 * @throws InitializeException
397
	 *             if there is any error creating the object
398
	 */
399
	public FeatureAttributeGetter createFeatureAttributeGetter(String name) throws InitializeException;
400
	
401
	public void setOpenErrorHandler(OpenErrorHandler handler);
402

  
403
}
0 404

  
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/DataServerExplorerParameters.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

  
28
package org.gvsig.fmap.dal;
29

  
30
/**
31
 * DataServerExplorer parameter container. Provides a way to obtain the name 
32
 * of the specific data explorer type described by this parameters.
33
 * 
34
 */
35
public interface DataServerExplorerParameters extends DataParameters {
36

  
37
	/**
38
	 * Returns the name of the data explorer type of the DataServerExplorer
39
	 * represented by this DataServerExplorerParameters
40
	 * 
41
	 * @return a String containing the name of the data explorer type
42
	 */
43
	public String getExplorerName();
44

  
45
}
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/resource/ResourceParameters.java
1
package org.gvsig.fmap.dal.resource;
2

  
3
import org.gvsig.fmap.dal.DataParameters;
4

  
5
/**
6
 * Interface that contains any resource parameters.
7
 * Each specific subtype of resource will extend this
8
 * interface with its own relevant parameters.
9
 *
10
 */
11
public interface ResourceParameters extends DataParameters {
12

  
13
	/**
14
	 * Returns the type name of the related resource.
15
	 * 
16
	 * @return
17
	 * 		type name of the resource.
18
	 */
19
	public String getTypeName();
20

  
21
}
22

  
0 23

  
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/resource/spi/AbstractResource.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 IVER T.I   {{Task}}
26
 */
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.fmap.dal.resource.spi;
32

  
33
import java.lang.ref.WeakReference;
34
import java.util.ArrayList;
35
import java.util.Iterator;
36
import java.util.List;
37

  
38
import org.gvsig.fmap.dal.exception.CopyParametersException;
39
import org.gvsig.fmap.dal.exception.InitializeException;
40
import org.gvsig.fmap.dal.resource.Resource;
41
import org.gvsig.fmap.dal.resource.ResourceAction;
42
import org.gvsig.fmap.dal.resource.ResourceNotification;
43
import org.gvsig.fmap.dal.resource.ResourceParameters;
44
import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
45
import org.gvsig.fmap.dal.resource.exception.PrepareResourceException;
46
import org.gvsig.fmap.dal.resource.exception.ResourceException;
47
import org.gvsig.fmap.dal.resource.exception.ResourceExecuteException;
48
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyChangesException;
49
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyCloseException;
50
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyDisposeException;
51
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyOpenException;
52
import org.gvsig.fmap.dal.resource.impl.DefaultResourceNotification;
53
import org.gvsig.tools.observer.Observer;
54
import org.gvsig.tools.observer.WeakReferencingObservable;
55
import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable;
56
import org.gvsig.tools.observer.impl.DelegateWeakReferencingObservable;
57

  
58
/**
59
 * <p>
60
 * Base implementation for Resource
61
 * </p>
62
 * 
63
 * <p>
64
 * This implementation not define the {@link Resource#begin()} and
65
 * {@link Resource#end()}
66
 * </p>
67
 * 
68
 * @author jmvivo
69
 * 
70
 */
71
public abstract class AbstractResource implements ResourceProvider,
72
		WeakReferencingObservable {
73

  
74
	private DelegateWeakReferencingObservable delegateObservable;
75

  
76
	private List consumers;
77

  
78
	private long lastTimeOpen;
79
	private long lastTimeUsed;
80

  
81
	private ResourceParameters parameters;
82
	private ResourceParameters preparedParameters;
83

  
84
	private Object data;
85

  
86
	private int openCount;
87

  
88
	/**
89
	 * Number of times an execute is being simultaneously performed with this
90
	 * resource.
91
	 */
92
	private int executeCount = 0;
93

  
94
	protected final Object lock;
95

  
96
	protected AbstractResource(ResourceParameters parameters)
97
			throws InitializeException {
98
		consumers = new ArrayList();
99
		lastTimeOpen = System.currentTimeMillis();
100
		lastTimeUsed = lastTimeOpen;
101

  
102
		openCount = 0;
103

  
104
		preparedParameters = null;
105
		delegateObservable = new DelegateWeakReferencingObservable(this);
106
		lock = new Object();
107
		try {
108
			this.parameters = (ResourceParameters) parameters.getCopy();
109
		} catch (CopyParametersException e) {
110
			throw new InitializeException(e);
111
		}
112

  
113
	}
114

  
115
	protected final void updateLastTimeUsed() {
116
		lastTimeUsed = System.currentTimeMillis();
117
	}
118

  
119
	protected final void updateLastTimeOpen() {
120
		lastTimeOpen = System.currentTimeMillis();
121
		lastTimeUsed = lastTimeOpen;
122
	}
123

  
124
	public final long getLastTimeOpen() {
125
		return lastTimeOpen;
126
	}
127

  
128
	public final long getLastTimeUsed() {
129
		return lastTimeUsed;
130
	}
131

  
132
	public final ResourceParameters getParameters() {
133
		if (preparedParameters != null) {
134
			return preparedParameters;
135
		}
136
		return this.parameters;
137
	}
138

  
139
	public void prepare(ResourceParameters params)
140
			throws PrepareResourceException {
141
		ResourceNotification notification =
142
				new DefaultResourceNotification(this,
143
						ResourceNotification.PREPARE, params);
144
		this.delegateObservable.notifyObservers(notification);
145
	}
146

  
147
	public void prepare() throws PrepareResourceException {
148
		if (preparedParameters == null) {
149
			try {
150
				ResourceParameters params =
151
						(ResourceParameters) parameters.getCopy();
152
				prepare(params);
153
				preparedParameters = params;
154
			} catch (CopyParametersException e) {
155
				throw new PrepareResourceException(this, e);
156
			}
157
		}
158

  
159
	}
160

  
161
	public void notifyOpen() throws ResourceNotifyOpenException {
162
		this.notifyObserver(ResourceNotification.OPEN);
163
		updateLastTimeOpen();
164
		openCount++;
165
	}
166

  
167
	public void notifyClose() throws ResourceNotifyCloseException {
168
		if (openCount <= 0) {
169
			throw new IllegalStateException();
170
		}
171
		this.notifyObserver(ResourceNotification.CLOSE);
172
		openCount--;
173
	}
174

  
175
	public void notifyChanges() throws ResourceNotifyChangesException {
176
		this.notifyObserver(ResourceNotification.CHANGED);
177

  
178
		Iterator it = consumers.iterator();
179
		while (it.hasNext()) {
180
			ResourceConsumer consumer =
181
					(ResourceConsumer) ((WeakReference) it.next()).get();
182
			if (consumer != null) {
183
				consumer.resourceChanged(this);
184
			} else {
185
				it.remove();
186
			}
187
		}
188
	}
189

  
190
	public boolean isOpen() {
191
		return this.openCount > 0;
192
	}
193

  
194
	public int openCount() {
195
		return this.openCount;
196
	}
197

  
198
	public void addObserver(Observer o) {
199
		this.delegateObservable.addObserver(o);
200
	}
201

  
202
	public void deleteObserver(Observer o) {
203
		this.delegateObservable.deleteObserver(o);
204
	}
205

  
206
	public void deleteObservers() {
207
		this.delegateObservable.deleteObservers();
208

  
209
	}
210

  
211
	public final void addObservers(BaseWeakReferencingObservable observers) {
212
		this.delegateObservable.addObservers(observers);
213
	}
214

  
215
	public final void addConsumer(ResourceConsumer consumer) {
216
		this.updateConsumersList();
217
		consumers.add(new WeakReference(consumer));
218
	}
219

  
220
	public final void removeConsumer(ResourceConsumer consumer) {
221
		ResourceConsumer cur;
222
		Iterator it = consumers.iterator();
223
		while (it.hasNext()) {
224
			cur = (ResourceConsumer) ((WeakReference) it.next()).get();
225
			if (cur == null || (cur == consumer)) {
226
				it.remove();
227
			}
228
		}
229
	}
230

  
231
	public int getConsumersCount() {
232
		this.updateConsumersList();
233
		return consumers.size();
234
	}
235

  
236
	private synchronized void updateConsumersList() {
237
		Iterator it = consumers.iterator();
238
		WeakReference ref;
239
		while (it.hasNext()) {
240
			ref = (WeakReference) it.next();
241
			if (ref.get() == null) {
242
				it.remove();
243
			}
244
		}
245
	}
246

  
247
	public void closeRequest() throws ResourceException {
248
		if (inUse()) {
249
			return;
250
		}
251
		if (consumers != null) {
252
			for (int i = 0; i < consumers.size(); i++) {
253

  
254
			}
255
		}
256
		if (consumers != null) {
257
			Iterator it = consumers.iterator();
258
			while (it.hasNext()) {
259
				ResourceConsumer consumer =
260
						(ResourceConsumer) ((WeakReference) it.next()).get();
261
				if (consumer != null) {
262
					consumer.closeResourceRequested(this);
263
				} else {
264
					it.remove();
265
				}
266
			}
267
		}
268
	}
269

  
270
	public void setData(Object data) {
271
		this.data = data;
272
	}
273

  
274
	public Object getData() {
275
		return this.data;
276
	}
277

  
278
	protected void notifyObserver(String type) {
279
		if (delegateObservable != null) {
280
			this.delegateObservable.notifyObservers(new DefaultResourceNotification(
281
					this, type));
282
		}
283
	}
284

  
285
	public void notifyDispose() throws ResourceNotifyDisposeException {
286
		this.notifyObserver(ResourceNotification.DISPOSE);
287

  
288
		if (consumers != null) {
289
			consumers.clear();
290
		}
291

  
292
		lastTimeOpen = 0l;
293
		lastTimeUsed = 0l;
294

  
295
		data = null;
296

  
297
		if (delegateObservable != null) {
298
			delegateObservable.deleteObservers();
299
		}
300
	}
301

  
302
	public final boolean inUse() {
303
		return executeCount > 0;
304
	}
305

  
306
	public Object execute(ResourceAction action)
307
			throws ResourceExecuteException {
308
		Object value = null;
309
		synchronized (lock) {
310
			executeBegins();
311
			try {
312
				value = performExecution(action);
313
			} catch (Exception e) {
314
				throw new ResourceExecuteException(this, e);
315
			} finally {
316
				executeEnds();
317
			}
318
		}
319
		return value;
320
	}
321

  
322
	protected Object performExecution(ResourceAction action) throws Exception {
323
		return action.run();
324
	}
325

  
326
	protected final void executeBegins() {
327
		executeCount++;
328
	}
329

  
330
	protected final void executeEnds() {
331
		updateLastTimeUsed();
332
		executeCount--;
333
	}
334

  
335
	/**
336
	 * Returns the name of the {@link Resource}.
337
	 * 
338
	 * @throws AccessResourceException
339
	 *             if there is an error while accessing the resource
340
	 */
341
	public abstract String getName() throws AccessResourceException;
342

  
343
	/**
344
	 * Returns the real resource represented by this object.
345
	 * 
346
	 * @throws AccessResourceException
347
	 *             if there is an error while accessing the resource
348
	 */
349
	public abstract Object get() throws AccessResourceException;
350

  
351
}
0 352

  
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/resource/spi/AbstractNonBlockingResource.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 IVER T.I   {{Task}}
26
 */
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.fmap.dal.resource.spi;
32

  
33
import org.gvsig.fmap.dal.exception.InitializeException;
34
import org.gvsig.fmap.dal.resource.ResourceAction;
35
import org.gvsig.fmap.dal.resource.ResourceParameters;
36
import org.gvsig.fmap.dal.resource.exception.ResourceExecuteException;
37

  
38
/**
39
 * <p>
40
 * Abstract Implementation for Resource that allows the concurrent access.
41
 * </p>
42
 * 
43
 * @author jmvivo
44
 * 
45
 */
46
public abstract class AbstractNonBlockingResource extends AbstractResource {
47

  
48
	/**
49
	 * @param parameters
50
	 * @throws InitializeException
51
	 */
52
	public AbstractNonBlockingResource(ResourceParameters parameters)
53
			throws InitializeException {
54
		super(parameters);
55
	}
56

  
57
	public Object execute(ResourceAction action)
58
			throws ResourceExecuteException {
59
		Object value = null;
60
		synchronized (lock) {
61
			executeBegins();
62
		}
63
		try {
64
			value = performExecution(action);
65
		} catch (Exception e) {
66
			throw new ResourceExecuteException(this, e);
67
		} finally {
68
			synchronized (lock) {
69
				executeEnds();
70
			}
71
		}
72
		return value;
73
	}
74
}
0 75

  
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/resource/spi/AbstractResourceParameters.java
1
package org.gvsig.fmap.dal.resource.spi;
2

  
3
import org.gvsig.fmap.dal.resource.ResourceParameters;
4
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
5

  
6
public abstract class AbstractResourceParameters extends AbstractDataParameters
7
		implements ResourceParameters {
8

  
9

  
10
}
0 11

  
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/resource/spi/ResourceManagerProviderServices.java
1
package org.gvsig.fmap.dal.resource.spi;
2

  
3
import java.util.List;
4

  
5
import org.gvsig.fmap.dal.DataParameters;
6
import org.gvsig.fmap.dal.exception.DataException;
7
import org.gvsig.fmap.dal.exception.InitializeException;
8
import org.gvsig.fmap.dal.resource.Resource;
9
import org.gvsig.fmap.dal.resource.ResourceManager;
10
import org.gvsig.fmap.dal.resource.ResourceParameters;
11

  
12
public interface ResourceManagerProviderServices extends ResourceManager {
13

  
14
	public boolean register(String type, String description, Class handler,
15
			Class params);
16

  
17
	public DataParameters createParameters(String type)
18
			throws InitializeException;
19

  
20
	public ResourceProvider createAddResource(ResourceParameters params)
21
			throws InitializeException;
22

  
23
	public ResourceProvider createResource(ResourceParameters params)
24
			throws InitializeException;
25

  
26
	public ResourceProvider createAddResource(String type, Object[] params)
27
			throws InitializeException;
28

  
29
	public ResourceProvider createResource(String type, Object[] params)
30
			throws InitializeException;
31

  
32
	public void remove(Resource resource) throws DataException;
33

  
34
	public void remove(String name) throws DataException;
35
	
36
	public List getResourceProviders();
37

  
38
}
0 39

  
tags/dal_time_support_Build_0/libraries/libFMap_dal/src/org/gvsig/fmap/dal/resource/spi/MultiResource.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {}  {{Task}}
26
 */
27
package org.gvsig.fmap.dal.resource.spi;
28

  
29
import java.util.ArrayList;
30
import java.util.List;
31

  
32
import org.gvsig.fmap.dal.DALLocator;
33
import org.gvsig.fmap.dal.exception.InitializeException;
34
import org.gvsig.fmap.dal.resource.ResourceParameters;
35
import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
36
import org.gvsig.fmap.dal.resource.exception.PrepareResourceException;
37
import org.gvsig.fmap.dal.resource.exception.ResourceException;
38
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyChangesException;
39
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyCloseException;
40
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyDisposeException;
41
import org.gvsig.fmap.dal.resource.exception.ResourceNotifyOpenException;
42
import org.slf4j.Logger;
43
import org.slf4j.LoggerFactory;
44

  
45
/**
46
 * Resource implementation which is able to show an unique interface to a group
47
 * of Resources.
48
 * 
49
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
50
 */
51
public class MultiResource extends AbstractResource {
52

  
53
	public static final String TYPE_NAME = "multi";
54

  
55
	public static final String DESCRIPTION = "Group of multiple resources";
56

  
57
	private static final Logger LOG =
58
			LoggerFactory.getLogger(MultiResource.class);
59

  
60
	private List resources = new ArrayList();
61

  
62
	// Initially, the first one
63
	private int defaultResourcePos = 0;
64

  
65
	/**
66
	 * Creates a new {@link MultiResource} from the given parameters.
67
	 * 
68
	 * @param parameters
69
	 *            to create the resource from
70
	 * @throws InitializeException
71
	 *             if there is an error creating the resource
72
	 */
73
	public MultiResource(MultiResourceParameters parameters)
74
			throws InitializeException {
75
		super(parameters);
76
	}
77

  
78
	private List getResources() {
79
		return resources;
80
	}
81

  
82
	/**
83
	 * Adds a new {@link ResourceProvider} to the list of Resources managed by
84
	 * this group.
85
	 * 
86
	 * @param parameters
87
	 *            to create the resource from
88
	 * @param defaultResource
89
	 *            if the added resource is to be used as the multi resource
90
	 *            default one
91
	 * @throws InitializeException
92
	 *             if there is an error adding the resource
93
	 */
94
	public void addResource(ResourceParameters parameters,
95
			boolean defaultResource) throws InitializeException {
96
		ResourceProvider resourceProvider =
97
				((ResourceManagerProviderServices) DALLocator.getResourceManager()).createResource(parameters);
98
		resources.add(resourceProvider);
99
		if (defaultResource) {
100
			defaultResourcePos = resources.size() - 1;
101
		}
102
	}
103

  
104
	/**
105
	 * Adds a new {@link ResourceProvider} to the list of Resources managed by
106
	 * this group.
107
	 * 
108
	 * @param name
109
	 *            of the resource to add
110
	 * @param params
111
	 *            parameters to create the resource with
112
	 * @param defaultResource
113
	 *            if the added resource is to be used as the multi resource
114
	 *            default one
115
	 * @throws InitializeException
116
	 *             if there is an error adding the resource
117
	 */
118
	public void addResource(String name, Object[] params,
119
			boolean defaultResource) throws InitializeException {
120
		ResourceProvider resourceProvider =
121
				((ResourceManagerProviderServices) DALLocator.getResourceManager()).createResource(
122
						name, params);
123
		resources.add(resourceProvider);
124
		if (defaultResource) {
125
			defaultResourcePos = resources.size() - 1;
126
		}
127
	}
128

  
129
	public boolean isThis(ResourceParameters parameters)
130
			throws ResourceException {
131
		if (parameters instanceof MultiResourceParameters) {
132
			MultiResourceParameters multiParams =
133
					(MultiResourceParameters) parameters;
134
			return multiParams.getName() != null
135
					&& multiParams.getName().equals(
136
							getMultiResourceParameters().getName());
137
		}
138

  
139
		return false;
140
	}
141

  
142
	public void notifyChanges() throws ResourceNotifyChangesException {
143
		List resources = getResources();
144
		for (int i = 0; i < resources.size(); i++) {
145
			((ResourceProvider) getResources().get(i)).notifyChanges();
146
		}
147
	}
148

  
149
	public void notifyClose() throws ResourceNotifyCloseException {
150
		List resources = getResources();
151
		for (int i = 0; i < resources.size(); i++) {
152
			((ResourceProvider) getResources().get(i)).notifyClose();
153
		}
154
	}
155

  
156
	public void notifyDispose() throws ResourceNotifyDisposeException {
157
		List resources = getResources();
158
		for (int i = 0; i < resources.size(); i++) {
159
			((ResourceProvider) getResources().get(i)).notifyDispose();
160
		}
161
	}
162

  
163
	public void notifyOpen() throws ResourceNotifyOpenException {
164
		List resources = getResources();
165
		for (int i = 0; i < resources.size(); i++) {
166
			((ResourceProvider) getResources().get(i)).notifyOpen();
167
		}
168
	}
169

  
170
	public void prepare() throws PrepareResourceException {
171
		List resources = getResources();
172
		for (int i = 0; i < resources.size(); i++) {
173
			((ResourceProvider) getResources().get(i)).prepare();
174
		}
175
	}
176

  
177
	public void closeRequest() throws ResourceException {
178
		List resources = getResources();
179
		for (int i = 0; i < resources.size(); i++) {
180
			((ResourceProvider) getResources().get(i)).closeRequest();
181
		}
182
	}
183

  
184
	public Object get() throws AccessResourceException {
185
		ResourceProvider defaultResource = getDefaultResource();
186
		if (defaultResource == null) {
187
			return null;
188
		} else {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff