Revision 30569 branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/raster/spi/AbstractCoverageStoreProvider.java

View differences:

AbstractCoverageStoreProvider.java
32 32

  
33 33
import org.gvsig.fmap.dal.DALLocator;
34 34
import org.gvsig.fmap.dal.DataServerExplorer;
35
import org.gvsig.fmap.dal.DataStoreParameters;
35 36
import org.gvsig.fmap.dal.exception.CloseException;
36 37
import org.gvsig.fmap.dal.exception.DataException;
37 38
import org.gvsig.fmap.dal.exception.InitializeException;
......
41 42
import org.gvsig.fmap.dal.raster.CoverageSelection;
42 43
import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices;
43 44
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
45
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
44 46
import org.gvsig.fmap.geom.primitive.Envelope;
45 47
import org.gvsig.tools.dynobject.DelegatedDynObject;
46 48
import org.gvsig.tools.dynobject.DynClass;
47 49
import org.gvsig.tools.dynobject.DynObject;
48 50
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
49 51
import org.gvsig.tools.dynobject.exception.DynMethodException;
50
import org.slf4j.Logger;
51
import org.slf4j.LoggerFactory;
52 52

  
53 53

  
54 54
/**
......
58 58
public abstract class AbstractCoverageStoreProvider implements
59 59
		CoverageStoreProvider {
60 60
	protected CoverageStoreProviderServices store;
61
	protected Logger logger;
62
	protected DelegatedDynObject dynObject;
61
	private DelegatedDynObject metadata;
62
	private DataStoreParameters parameters;
63 63

  
64
	public AbstractCoverageStoreProvider() {
65
		this.store = null;
66
		this.logger = null;
67
		this.dynObject = null;
64

  
65
	protected AbstractCoverageStoreProvider(DataStoreParameters params,
66
			DataStoreProviderServices storeServices, DynObject metadata) {
67
		this.store = (CoverageStoreProviderServices) storeServices;
68
		this.metadata = (DelegatedDynObject) metadata;
69
		this.parameters = params;
68 70
	}
69 71

  
70
	public CoverageStoreProvider initialize(CoverageStoreProviderServices store)
71
			throws InitializeException {
72
		this.store = store;
73
		return this;
72
	protected AbstractCoverageStoreProvider(DataStoreParameters params,
73
			DataStoreProviderServices storeServices) {
74
		this.store = (CoverageStoreProviderServices) storeServices;
75
		this.metadata = null;
76
		this.parameters = params;
74 77
	}
75 78

  
79
	/**
80
	 * Set metada container if this not set at construction time and only in one
81
	 * time. In other case an Exception will be throw
82
	 *
83
	 * @param metadata
84
	 */
85
	protected void setMetadata(DynObject metadata) {
86
		if (this.metadata != null) {
87
			// FIXME Exception
88
			throw new IllegalStateException();
89
		}
90
		this.metadata = (DelegatedDynObject) metadata;
91
	}
92

  
76 93
	protected ResourceProvider createResource(String type, Object[] params)
77 94
			throws InitializeException {
78 95
		ResourceManagerProviderServices manager = (ResourceManagerProviderServices) DALLocator
......
89 106
		return this.getClass().getName();
90 107
	}
91 108

  
92
	public Logger getLogger() {
93
		if (this.logger == null) {
94
			this.logger = LoggerFactory.getLogger(this.getClass());
95
		}
96
		return this.logger;
97
	}
98

  
99 109
	public boolean allowWrite() {
100 110
		return false;
101 111
	}
......
113 123
	}
114 124

  
115 125
	public void dispose() throws CloseException {
116
		this.dynObject = null;
126
		this.metadata = null;
117 127
		this.store = null;
118
		this.logger = null;
128
		this.parameters = null;
119 129
	}
120 130

  
121 131
	public Envelope getEnvelope() throws DataException {
......
126 136
			ValidateDataParametersException;
127 137

  
128 138
	public void delegate(DynObject dynObject) {
129
		if (this.dynObject == null) {
139
		if (this.metadata == null) {
130 140
			return;
131 141
		}
132
		this.dynObject.delegate(dynObject);
142
		this.metadata.delegate(dynObject);
133 143
	}
134 144

  
135 145
	public DynClass getDynClass() {
136
		if (this.dynObject == null) {
146
		if (this.metadata == null) {
137 147
			return null;
138 148
		}
139
		return this.dynObject.getDynClass();
149
		return this.metadata.getDynClass();
140 150
	}
141 151

  
142 152
	public Object getDynValue(String name) throws DynFieldNotFoundException {
143
		if (this.dynObject == null) {
153
		if (this.metadata == null) {
144 154
			return null;
145 155
		}
146 156
		// TODO this.open??
147
		return this.dynObject.getDynValue(name);
157
		return this.metadata.getDynValue(name);
148 158
	}
149 159

  
150 160
	public boolean hasDynValue(String name) {
151
		if (this.dynObject == null) {
161
		if (this.metadata == null) {
152 162
			return false;
153 163
		}
154 164
		// TODO this.open??
155
		return this.dynObject.hasDynValue(name);
165
		return this.metadata.hasDynValue(name);
156 166
	}
157 167

  
158 168
	public void implement(DynClass dynClass) {
159
		if (this.dynObject == null) {
169
		if (this.metadata == null) {
160 170
			return;
161 171
		}
162
		this.dynObject.implement(dynClass);
172
		this.metadata.implement(dynClass);
163 173

  
164 174
	}
165 175

  
166 176
	public Object invokeDynMethod(int code, DynObject context)
167 177
			throws DynMethodException {
168
		if (this.dynObject == null) {
178
		if (this.metadata == null) {
169 179
			return null;
170 180
		}
171 181
		// TODO this.open??
172
		return this.dynObject.invokeDynMethod(this, code, context);
182
		return this.metadata.invokeDynMethod(this, code, context);
173 183
	}
174 184

  
175 185
	public Object invokeDynMethod(String name, DynObject context)
176 186
			throws DynMethodException {
177
		if (this.dynObject == null) {
187
		if (this.metadata == null) {
178 188
			return null;
179 189
		}
180 190
		// TODO this.open??
181
		return this.dynObject.invokeDynMethod(this, name, context);
191
		return this.metadata.invokeDynMethod(this, name, context);
182 192
	}
183 193

  
184 194
	public void setDynValue(String name, Object value)
185 195
			throws DynFieldNotFoundException {
186
		if (this.dynObject == null) {
196
		if (this.metadata == null) {
187 197
			return;
188 198
		}
189 199
		// TODO this.open??
190
		this.dynObject.setDynValue(name, value);
200
		this.metadata.setDynValue(name, value);
191 201
	}
192 202

  
193 203
}

Also available in: Unified diff