author | never |
Mon, 12 Jul 2010 22:27:18 -0700 | |
changeset 5926 | a36f90d986b6 |
parent 5506 | 202f599c92aa |
child 5597 | ab490f66d2cf |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
package java.beans; |
|
26 |
||
27 |
import java.util.*; |
|
28 |
import java.lang.reflect.*; |
|
29 |
import sun.reflect.misc.*; |
|
30 |
||
31 |
||
32 |
/** |
|
33 |
* The <code>DefaultPersistenceDelegate</code> is a concrete implementation of |
|
34 |
* the abstract <code>PersistenceDelegate</code> class and |
|
35 |
* is the delegate used by default for classes about |
|
36 |
* which no information is available. The <code>DefaultPersistenceDelegate</code> |
|
37 |
* provides, version resilient, public API-based persistence for |
|
38 |
* classes that follow the JavaBeans conventions without any class specific |
|
39 |
* configuration. |
|
40 |
* <p> |
|
41 |
* The key assumptions are that the class has a nullary constructor |
|
42 |
* and that its state is accurately represented by matching pairs |
|
43 |
* of "setter" and "getter" methods in the order they are returned |
|
44 |
* by the Introspector. |
|
45 |
* In addition to providing code-free persistence for JavaBeans, |
|
46 |
* the <code>DefaultPersistenceDelegate</code> provides a convenient means |
|
47 |
* to effect persistent storage for classes that have a constructor |
|
48 |
* that, while not nullary, simply requires some property values |
|
49 |
* as arguments. |
|
50 |
* |
|
51 |
* @see #DefaultPersistenceDelegate(String[]) |
|
52 |
* @see java.beans.Introspector |
|
53 |
* |
|
54 |
* @since 1.4 |
|
55 |
* |
|
56 |
* @author Philip Milne |
|
57 |
*/ |
|
58 |
||
59 |
public class DefaultPersistenceDelegate extends PersistenceDelegate { |
|
60 |
private String[] constructor; |
|
61 |
private Boolean definesEquals; |
|
62 |
||
63 |
/** |
|
64 |
* Creates a persistence delegate for a class with a nullary constructor. |
|
65 |
* |
|
66 |
* @see #DefaultPersistenceDelegate(java.lang.String[]) |
|
67 |
*/ |
|
68 |
public DefaultPersistenceDelegate() { |
|
69 |
this(new String[0]); |
|
70 |
} |
|
71 |
||
72 |
/** |
|
73 |
* Creates a default persistence delegate for a class with a |
|
74 |
* constructor whose arguments are the values of the property |
|
75 |
* names as specified by <code>constructorPropertyNames</code>. |
|
76 |
* The constructor arguments are created by |
|
77 |
* evaluating the property names in the order they are supplied. |
|
78 |
* To use this class to specify a single preferred constructor for use |
|
79 |
* in the serialization of a particular type, we state the |
|
80 |
* names of the properties that make up the constructor's |
|
81 |
* arguments. For example, the <code>Font</code> class which |
|
82 |
* does not define a nullary constructor can be handled |
|
83 |
* with the following persistence delegate: |
|
84 |
* |
|
85 |
* <pre> |
|
86 |
* new DefaultPersistenceDelegate(new String[]{"name", "style", "size"}); |
|
87 |
* </pre> |
|
88 |
* |
|
89 |
* @param constructorPropertyNames The property names for the arguments of this constructor. |
|
90 |
* |
|
91 |
* @see #instantiate |
|
92 |
*/ |
|
93 |
public DefaultPersistenceDelegate(String[] constructorPropertyNames) { |
|
94 |
this.constructor = constructorPropertyNames; |
|
95 |
} |
|
96 |
||
97 |
private static boolean definesEquals(Class type) { |
|
98 |
try { |
|
99 |
return type == type.getMethod("equals", Object.class).getDeclaringClass(); |
|
100 |
} |
|
101 |
catch(NoSuchMethodException e) { |
|
102 |
return false; |
|
103 |
} |
|
104 |
} |
|
105 |
||
106 |
private boolean definesEquals(Object instance) { |
|
107 |
if (definesEquals != null) { |
|
108 |
return (definesEquals == Boolean.TRUE); |
|
109 |
} |
|
110 |
else { |
|
111 |
boolean result = definesEquals(instance.getClass()); |
|
112 |
definesEquals = result ? Boolean.TRUE : Boolean.FALSE; |
|
113 |
return result; |
|
114 |
} |
|
115 |
} |
|
116 |
||
117 |
/** |
|
118 |
* If the number of arguments in the specified constructor is non-zero and |
|
119 |
* the class of <code>oldInstance</code> explicitly declares an "equals" method |
|
120 |
* this method returns the value of <code>oldInstance.equals(newInstance)</code>. |
|
121 |
* Otherwise, this method uses the superclass's definition which returns true if the |
|
122 |
* classes of the two instances are equal. |
|
123 |
* |
|
124 |
* @param oldInstance The instance to be copied. |
|
125 |
* @param newInstance The instance that is to be modified. |
|
126 |
* @return True if an equivalent copy of <code>newInstance</code> may be |
|
127 |
* created by applying a series of mutations to <code>oldInstance</code>. |
|
128 |
* |
|
129 |
* @see #DefaultPersistenceDelegate(String[]) |
|
130 |
*/ |
|
131 |
protected boolean mutatesTo(Object oldInstance, Object newInstance) { |
|
132 |
// Assume the instance is either mutable or a singleton |
|
133 |
// if it has a nullary constructor. |
|
134 |
return (constructor.length == 0) || !definesEquals(oldInstance) ? |
|
135 |
super.mutatesTo(oldInstance, newInstance) : |
|
136 |
oldInstance.equals(newInstance); |
|
137 |
} |
|
138 |
||
139 |
/** |
|
140 |
* This default implementation of the <code>instantiate</code> method returns |
|
141 |
* an expression containing the predefined method name "new" which denotes a |
|
142 |
* call to a constructor with the arguments as specified in |
|
143 |
* the <code>DefaultPersistenceDelegate</code>'s constructor. |
|
144 |
* |
|
145 |
* @param oldInstance The instance to be instantiated. |
|
146 |
* @param out The code output stream. |
|
147 |
* @return An expression whose value is <code>oldInstance</code>. |
|
148 |
* |
|
4849
c83eca4dbb8f
6412286: DOC: LTP: Unspecified NPE in java.beans.DefaultPersistenceDelegate.instantiate method
malenkov
parents:
1280
diff
changeset
|
149 |
* @throws NullPointerException if {@code out} is {@code null} |
c83eca4dbb8f
6412286: DOC: LTP: Unspecified NPE in java.beans.DefaultPersistenceDelegate.instantiate method
malenkov
parents:
1280
diff
changeset
|
150 |
* |
2 | 151 |
* @see #DefaultPersistenceDelegate(String[]) |
152 |
*/ |
|
153 |
protected Expression instantiate(Object oldInstance, Encoder out) { |
|
154 |
int nArgs = constructor.length; |
|
155 |
Class type = oldInstance.getClass(); |
|
156 |
Object[] constructorArgs = new Object[nArgs]; |
|
157 |
for(int i = 0; i < nArgs; i++) { |
|
158 |
try { |
|
159 |
Method method = findMethod(type, this.constructor[i]); |
|
160 |
constructorArgs[i] = MethodUtil.invoke(method, oldInstance, new Object[0]); |
|
161 |
} |
|
162 |
catch (Exception e) { |
|
163 |
out.getExceptionListener().exceptionThrown(e); |
|
164 |
} |
|
165 |
} |
|
166 |
return new Expression(oldInstance, oldInstance.getClass(), "new", constructorArgs); |
|
167 |
} |
|
168 |
||
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
169 |
private Method findMethod(Class type, String property) { |
2 | 170 |
if (property == null) { |
171 |
throw new IllegalArgumentException("Property name is null"); |
|
172 |
} |
|
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
173 |
PropertyDescriptor pd = getPropertyDescriptor(type, property); |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
174 |
if (pd == null) { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
175 |
throw new IllegalStateException("Could not find property by the name " + property); |
2 | 176 |
} |
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
177 |
Method method = pd.getReadMethod(); |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
178 |
if (method == null) { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
179 |
throw new IllegalStateException("Could not find getter for the property " + property); |
2 | 180 |
} |
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
181 |
return method; |
2 | 182 |
} |
183 |
||
184 |
private static boolean equals(Object o1, Object o2) { |
|
185 |
return (o1 == null) ? (o2 == null) : o1.equals(o2); |
|
186 |
} |
|
187 |
||
188 |
private void doProperty(Class type, PropertyDescriptor pd, Object oldInstance, Object newInstance, Encoder out) throws Exception { |
|
189 |
Method getter = pd.getReadMethod(); |
|
190 |
Method setter = pd.getWriteMethod(); |
|
191 |
||
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
192 |
if (getter != null && setter != null) { |
2 | 193 |
Expression oldGetExp = new Expression(oldInstance, getter.getName(), new Object[]{}); |
194 |
Expression newGetExp = new Expression(newInstance, getter.getName(), new Object[]{}); |
|
195 |
Object oldValue = oldGetExp.getValue(); |
|
196 |
Object newValue = newGetExp.getValue(); |
|
197 |
out.writeExpression(oldGetExp); |
|
198 |
if (!equals(newValue, out.get(oldValue))) { |
|
199 |
// Search for a static constant with this value; |
|
200 |
Object e = (Object[])pd.getValue("enumerationValues"); |
|
201 |
if (e instanceof Object[] && Array.getLength(e) % 3 == 0) { |
|
202 |
Object[] a = (Object[])e; |
|
203 |
for(int i = 0; i < a.length; i = i + 3) { |
|
204 |
try { |
|
205 |
Field f = type.getField((String)a[i]); |
|
206 |
if (f.get(null).equals(oldValue)) { |
|
207 |
out.remove(oldValue); |
|
208 |
out.writeExpression(new Expression(oldValue, f, "get", new Object[]{null})); |
|
209 |
} |
|
210 |
} |
|
211 |
catch (Exception ex) {} |
|
212 |
} |
|
213 |
} |
|
214 |
invokeStatement(oldInstance, setter.getName(), new Object[]{oldValue}, out); |
|
215 |
} |
|
216 |
} |
|
217 |
} |
|
218 |
||
219 |
static void invokeStatement(Object instance, String methodName, Object[] args, Encoder out) { |
|
220 |
out.writeStatement(new Statement(instance, methodName, args)); |
|
221 |
} |
|
222 |
||
223 |
// Write out the properties of this instance. |
|
224 |
private void initBean(Class type, Object oldInstance, Object newInstance, Encoder out) { |
|
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
225 |
BeanInfo info; |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
226 |
try { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
227 |
info = Introspector.getBeanInfo(type); |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
228 |
} catch (IntrospectionException exception) { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
229 |
return; |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
230 |
} |
2 | 231 |
// Properties |
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
232 |
for (PropertyDescriptor d : info.getPropertyDescriptors()) { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
233 |
if (d.isTransient()) { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
234 |
continue; |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
235 |
} |
2 | 236 |
try { |
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
237 |
doProperty(type, d, oldInstance, newInstance, out); |
2 | 238 |
} |
239 |
catch (Exception e) { |
|
240 |
out.getExceptionListener().exceptionThrown(e); |
|
241 |
} |
|
242 |
} |
|
243 |
||
244 |
// Listeners |
|
245 |
/* |
|
246 |
Pending(milne). There is a general problem with the archival of |
|
247 |
listeners which is unresolved as of 1.4. Many of the methods |
|
248 |
which install one object inside another (typically "add" methods |
|
249 |
or setters) automatically install a listener on the "child" object |
|
250 |
so that its "parent" may respond to changes that are made to it. |
|
251 |
For example the JTable:setModel() method automatically adds a |
|
252 |
TableModelListener (the JTable itself in this case) to the supplied |
|
253 |
table model. |
|
254 |
||
255 |
We do not need to explictly add these listeners to the model in an |
|
256 |
archive as they will be added automatically by, in the above case, |
|
257 |
the JTable's "setModel" method. In some cases, we must specifically |
|
258 |
avoid trying to do this since the listener may be an inner class |
|
259 |
that cannot be instantiated using public API. |
|
260 |
||
261 |
No general mechanism currently |
|
262 |
exists for differentiating between these kind of listeners and |
|
263 |
those which were added explicitly by the user. A mechanism must |
|
264 |
be created to provide a general means to differentiate these |
|
265 |
special cases so as to provide reliable persistence of listeners |
|
266 |
for the general case. |
|
267 |
*/ |
|
268 |
if (!java.awt.Component.class.isAssignableFrom(type)) { |
|
269 |
return; // Just handle the listeners of Components for now. |
|
270 |
} |
|
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
271 |
for (EventSetDescriptor d : info.getEventSetDescriptors()) { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
272 |
if (d.isTransient()) { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
273 |
continue; |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
274 |
} |
2 | 275 |
Class listenerType = d.getListenerType(); |
276 |
||
277 |
||
278 |
// The ComponentListener is added automatically, when |
|
279 |
// Contatiner:add is called on the parent. |
|
280 |
if (listenerType == java.awt.event.ComponentListener.class) { |
|
281 |
continue; |
|
282 |
} |
|
283 |
||
284 |
// JMenuItems have a change listener added to them in |
|
285 |
// their "add" methods to enable accessibility support - |
|
286 |
// see the add method in JMenuItem for details. We cannot |
|
287 |
// instantiate this instance as it is a private inner class |
|
288 |
// and do not need to do this anyway since it will be created |
|
289 |
// and installed by the "add" method. Special case this for now, |
|
290 |
// ignoring all change listeners on JMenuItems. |
|
291 |
if (listenerType == javax.swing.event.ChangeListener.class && |
|
292 |
type == javax.swing.JMenuItem.class) { |
|
293 |
continue; |
|
294 |
} |
|
295 |
||
296 |
EventListener[] oldL = new EventListener[0]; |
|
297 |
EventListener[] newL = new EventListener[0]; |
|
298 |
try { |
|
299 |
Method m = d.getGetListenerMethod(); |
|
300 |
oldL = (EventListener[])MethodUtil.invoke(m, oldInstance, new Object[]{}); |
|
301 |
newL = (EventListener[])MethodUtil.invoke(m, newInstance, new Object[]{}); |
|
302 |
} |
|
1280
f58fc9f575e3
6351692: catch(Throwable) in java.beans.MetaData preventing thread shutdown
malenkov
parents:
466
diff
changeset
|
303 |
catch (Exception e2) { |
2 | 304 |
try { |
305 |
Method m = type.getMethod("getListeners", new Class[]{Class.class}); |
|
306 |
oldL = (EventListener[])MethodUtil.invoke(m, oldInstance, new Object[]{listenerType}); |
|
307 |
newL = (EventListener[])MethodUtil.invoke(m, newInstance, new Object[]{listenerType}); |
|
308 |
} |
|
309 |
catch (Exception e3) { |
|
310 |
return; |
|
311 |
} |
|
312 |
} |
|
313 |
||
314 |
// Asssume the listeners are in the same order and that there are no gaps. |
|
315 |
// Eventually, this may need to do true differencing. |
|
316 |
String addListenerMethodName = d.getAddListenerMethod().getName(); |
|
317 |
for (int i = newL.length; i < oldL.length; i++) { |
|
318 |
// System.out.println("Adding listener: " + addListenerMethodName + oldL[i]); |
|
319 |
invokeStatement(oldInstance, addListenerMethodName, new Object[]{oldL[i]}, out); |
|
320 |
} |
|
321 |
||
322 |
String removeListenerMethodName = d.getRemoveListenerMethod().getName(); |
|
323 |
for (int i = oldL.length; i < newL.length; i++) { |
|
324 |
invokeStatement(oldInstance, removeListenerMethodName, new Object[]{newL[i]}, out); |
|
325 |
} |
|
326 |
} |
|
327 |
} |
|
328 |
||
329 |
/** |
|
330 |
* This default implementation of the <code>initialize</code> method assumes |
|
331 |
* all state held in objects of this type is exposed via the |
|
332 |
* matching pairs of "setter" and "getter" methods in the order |
|
333 |
* they are returned by the Introspector. If a property descriptor |
|
334 |
* defines a "transient" attribute with a value equal to |
|
335 |
* <code>Boolean.TRUE</code> the property is ignored by this |
|
336 |
* default implementation. Note that this use of the word |
|
337 |
* "transient" is quite independent of the field modifier |
|
338 |
* that is used by the <code>ObjectOutputStream</code>. |
|
339 |
* <p> |
|
340 |
* For each non-transient property, an expression is created |
|
341 |
* in which the nullary "getter" method is applied |
|
342 |
* to the <code>oldInstance</code>. The value of this |
|
343 |
* expression is the value of the property in the instance that is |
|
344 |
* being serialized. If the value of this expression |
|
345 |
* in the cloned environment <code>mutatesTo</code> the |
|
346 |
* target value, the new value is initialized to make it |
|
347 |
* equivalent to the old value. In this case, because |
|
348 |
* the property value has not changed there is no need to |
|
349 |
* call the corresponding "setter" method and no statement |
|
350 |
* is emitted. If not however, the expression for this value |
|
351 |
* is replaced with another expression (normally a constructor) |
|
352 |
* and the corresponding "setter" method is called to install |
|
353 |
* the new property value in the object. This scheme removes |
|
354 |
* default information from the output produced by streams |
|
355 |
* using this delegate. |
|
356 |
* <p> |
|
357 |
* In passing these statements to the output stream, where they |
|
358 |
* will be executed, side effects are made to the <code>newInstance</code>. |
|
359 |
* In most cases this allows the problem of properties |
|
360 |
* whose values depend on each other to actually help the |
|
361 |
* serialization process by making the number of statements |
|
362 |
* that need to be written to the output smaller. In general, |
|
363 |
* the problem of handling interdependent properties is reduced to |
|
364 |
* that of finding an order for the properties in |
|
365 |
* a class such that no property value depends on the value of |
|
366 |
* a subsequent property. |
|
367 |
* |
|
368 |
* @param oldInstance The instance to be copied. |
|
369 |
* @param newInstance The instance that is to be modified. |
|
370 |
* @param out The stream to which any initialization statements should be written. |
|
371 |
* |
|
4849
c83eca4dbb8f
6412286: DOC: LTP: Unspecified NPE in java.beans.DefaultPersistenceDelegate.instantiate method
malenkov
parents:
1280
diff
changeset
|
372 |
* @throws NullPointerException if {@code out} is {@code null} |
c83eca4dbb8f
6412286: DOC: LTP: Unspecified NPE in java.beans.DefaultPersistenceDelegate.instantiate method
malenkov
parents:
1280
diff
changeset
|
373 |
* |
2 | 374 |
* @see java.beans.Introspector#getBeanInfo |
375 |
* @see java.beans.PropertyDescriptor |
|
376 |
*/ |
|
377 |
protected void initialize(Class<?> type, |
|
378 |
Object oldInstance, Object newInstance, |
|
379 |
Encoder out) |
|
380 |
{ |
|
381 |
// System.out.println("DefulatPD:initialize" + type); |
|
382 |
super.initialize(type, oldInstance, newInstance, out); |
|
383 |
if (oldInstance.getClass() == type) { // !type.isInterface()) { |
|
384 |
initBean(type, oldInstance, newInstance, out); |
|
385 |
} |
|
386 |
} |
|
466
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
387 |
|
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
388 |
private static PropertyDescriptor getPropertyDescriptor(Class type, String property) { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
389 |
try { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
390 |
for (PropertyDescriptor pd : Introspector.getBeanInfo(type).getPropertyDescriptors()) { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
391 |
if (property.equals(pd.getName())) |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
392 |
return pd; |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
393 |
} |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
394 |
} catch (IntrospectionException exception) { |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
395 |
} |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
396 |
return null; |
6acd5ec503a8
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents:
2
diff
changeset
|
397 |
} |
2 | 398 |
} |