Revision 23178

View differences:

branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataManager.java
12 12

  
13 13
import com.iver.utiles.NotExistInXMLEntity;
14 14
import com.iver.utiles.XMLEntity;
15
import com.iver.utiles.XMLException;
15 16

  
16 17

  
17 18
public class DataManager {
......
137 138

  
138 139
		try {
139 140
			DataStore dataStore = (DataStore) registerInfo.clazz.newInstance();
140
			dataStore.init(xmlEntity);
141
			dataStore.setXMLEntity(xmlEntity);
141 142
			return dataStore;
142 143
		} catch (InstantiationException e) {
143 144
			throw new InitializeException(name, e);
144 145
		} catch (IllegalAccessException e) {
145 146
			throw new InitializeException(name, e);
147
		} catch (XMLException e) {
148
			throw new InitializeException(name, e);
146 149
		}
147 150
	}
148 151

  
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/XMLInitializeException.java
1
package org.gvsig.fmap.data.feature;
2

  
3
import java.util.Map;
4

  
5
import com.iver.utiles.XMLException;
6

  
7
public class XMLInitializeException extends XMLException {
8

  
9
	public XMLInitializeException(String name,Throwable exception) {
10
		init();
11
	}
12

  
13
	public XMLInitializeException(String description,String name,Throwable exception) {
14
		init();
15
	}
16

  
17
	public XMLInitializeException(String description,String name) {
18
		init();
19
	}
20
	/**
21
	 *
22
	 */
23
	protected void init() {
24
		messageKey = "error_initialize";
25
		formatString = "Can?t initialize %(name): %(description) ";
26
	}
27

  
28
	protected Map values() {
29
		// TODO Auto-generated method stub
30
		return null;
31
	}
32
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/AbstractFeatureStore.java
38 38
import org.gvsig.tools.observer.Observer;
39 39

  
40 40
import com.iver.utiles.XMLEntity;
41
import com.iver.utiles.XMLException;
41 42

  
42 43

  
43 44
public abstract class AbstractFeatureStore implements FeatureStore {
......
74 75
		this.observeResource(resource);
75 76
	}
76 77

  
77
	public void init(XMLEntity xmlEntity) throws InitializeException {
78
	public void setXMLEntity(XMLEntity xmlEntity) throws XMLException {
78 79
		DataManager manager = DataManager.getManager();
79 80

  
80 81
		XMLEntity paramsXML = xmlEntity.firstChild("type", "parameters");
81 82

  
82 83
		if (paramsXML == null) {
83
			throw new InitializeException("parameters not found", this
84
			throw new XMLInitializeException("parameters not found", this
84 85
					.getName());
85 86
		}
86

  
87
		try {
87 88
		DataStoreParameters params = manager
88
				.createDataStoreParameters(paramsXML);
89
					.createDataStoreParameters(paramsXML);
89 90
		this.init(params);
90

  
91
		} catch (InitializeException e) {
92
			throw new XMLInitializeException("inititalize", e);
93
		}
91 94
		//TODO Selection and Lock persistence
92 95

  
93 96
	}
......
104 107

  
105 108
		return xml;
106 109
	}
107

  
108

  
109

  
110

  
111 110
	protected final void observeResource(Resource resource){
112 111
		ResourceChangedObserver observer=new ResourceChangedObserver(this);
113 112
		resource.addObserver(observer);
......
709 708
		}
710 709

  
711 710
		/* (non-Javadoc)
712
		 * @see org.gvsig.util.observer.Observer#update(org.gvsig.util.observer.Observable, java.lang.Object)
711
		 * @see org.gvsig.tools.observer.Observer#update(org.gvsig.util.observer.Observable, java.lang.Object)
713 712
		 */
714 713
		public void update(Observable observable, Object notification) {
715 714
			if (!(notification instanceof ResourceNotification)){
......
846 845
		return indexStore.contains(fType, colName);
847 846
	}
848 847

  
849

  
848
	public String getClassName() {
849
		return this.getClass().getName();
850
	}
850 851
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/ResourceManager.java
35 35
			res = resource;
36 36
			this.resources.put(res.getKey(), res);
37 37
			res.addObservers(this.observers);
38
			res.preapare();
38
			res.prepare();
39 39
		}
40 40
		res.incref();
41 41

  
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataStore.java
10 10
import org.gvsig.metadata.IMetadatable;
11 11
import org.gvsig.tools.observer.Observable;
12 12

  
13
import com.iver.utiles.IPersistence;
13 14
import com.iver.utiles.XMLEntity;
15
import com.iver.utiles.XMLException;
14 16

  
15
public interface DataStore extends Observable, IMetadatable{
17
public interface DataStore extends Observable, IMetadatable, IPersistence{
16 18

  
17 19
	public String getName();
18 20

  
19 21
	public void init(DataStoreParameters parameters) throws InitializeException;
20
	public void init(XMLEntity xmlEntity) throws InitializeException;
22
	public void setXMLEntity(XMLEntity xmlEntity) throws XMLException;
21 23

  
22
	public XMLEntity getXMLEntity();
23 24
	/*
24 25
	 * FIXME: Comprobar el valor de retorno de las funciones ?Deber?an de ser booleanas?
25 26
	 */
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/Resource.java
84 84
		if (!this.isOpen()) {
85 85
			return;
86 86
		}
87
		observable.notifyObservers(
88
				this,
89
				new DefaultResourceNotification(this,ResourceNotification.BEGIN_CLOSE));
87 90
		doClose();
88 91
		observable.notifyObservers(
89 92
				this,
......
122 125
		if (this.isOpen()){
123 126
			return;
124 127
		}
128
		observable.notifyObservers(
129
				this,
130
				new DefaultResourceNotification(this,ResourceNotification.BEGIN_OPEN));
131

  
125 132
		if (doOpen()) {
126 133
			this.updateLastTimeOpen();
127 134
		}
......
168 175

  
169 176

  
170 177
	/* (non-Javadoc)
171
	 * @see org.gvsig.util.observer.Observable#addObserver(org.gvsig.util.observer.Observer)
178
	 * @see org.gvsig.util.observer.Observable#addObserver(org.gvsig.tools.observer.Observer)
172 179
	 */
173 180
	public void addObserver(Observer o) {
174 181
		this.observable.addObserver(o);
......
176 183
	}
177 184

  
178 185
	/* (non-Javadoc)
179
	 * @see org.gvsig.util.observer.Observable#deleteObserver(org.gvsig.util.observer.Observer)
186
	 * @see org.gvsig.util.observer.Observable#deleteObserver(org.gvsig.tools.observer.Observer)
180 187
	 */
181 188
	public void deleteObserver(Observer o) {
182 189
		this.observable.deleteObserver(o);
......
197 204
	/**
198 205
	 *
199 206
	 */
200
	void preapare() throws DataException{
207
	void prepare() throws DataException{
201 208
		try{
202 209
			observable.notifyObservers(
203 210
					this,
......
209 216
	}
210 217

  
211 218
	protected synchronized void checkOpen() throws OpenException{
219
		try {
220
			prepare();
221
		} catch (DataException e) {
222
			throw new OpenException(getName(),e);
223
		}
212 224
		this.updateLastTimeUsed();
213 225
		if (!this.isOpen()){
214 226
			this.open();
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/ResourceNotification.java
40 40
	public static final String PREPARE = "Prepare_Resource";
41 41
	public static final String CHANGED = "Changed_Resource";
42 42
	public static final String BEGIN_DISPOSE = "Begin_Dispose_Resource";
43
	public static final String BEGIN_OPEN = "Begin_Open_Resource";
44
	public static final String BEGIN_CLOSE = "Begin_Close_Resource";
43 45

  
44 46
	public Resource getResource();
45 47
	public String getType();

Also available in: Unified diff