Index: org/exolab/castor/builder/BuilderConfiguration.java =================================================================== RCS file: /home/projects/castor/scm/castor/src/main/org/exolab/castor/builder/BuilderConfiguration.java,v retrieving revision 1.6 diff -u -r1.6 BuilderConfiguration.java --- org/exolab/castor/builder/BuilderConfiguration.java 5 Mar 2005 13:41:42 -0000 1.6 +++ org/exolab/castor/builder/BuilderConfiguration.java 4 Aug 2005 16:19:56 -0000 @@ -85,11 +85,28 @@ *
* org.exolab.castor.builder.boundproperties
*
+ *
+ * @see #BOUND_PROPERTIES_TRANSIENT_LISTENERS
*/
public static final String BOUND_PROPERTIES =
"org.exolab.castor.builder.boundproperties";
-
-
+ /**
+ * Property specifying whether or not to generate
+ * bound property listener lists as transient when
+ * generating source code for bound properties. Enabling this
+ * feature prevents listeners from being serialized during the
+ * serialization process.
+ *
+ * A value of 'true' enables transient listeners.
+ * + * org.exolab.castor.builder.boundproperties.transientlisteners + *+ * + * @see #BOUND_PROPERTIES + */ + public static final String BOUND_PROPERTIES_TRANSIENT_LISTENERS = + "org.exolab.castor.builder.boundproperties.transientlisteners"; + /** * Property specifying whether to implement EnumeratedTypeAccess interface for * all generated enumerated type classes @@ -280,6 +297,25 @@ return TRUE.equalsIgnoreCase(_localProps.getProperty(Property.BOUND_PROPERTIES)); } //-- boundPropertiesEnabled + /** + * Returns true if bound property listeners are transient. + * Enabling this feature prevents listeners from being + * serialized during the serialization process. + * Only applicable if {@link #boundPropertiesEnabled()} is true. + * + * Enabling transient listeners is controlled via + * the
org.exolab.castor.builder.boundproperty.transientlisteners item
+ * in the castorbuilder.properties file. The value is
+ * either 'true' or 'false'.
+ *
+ * @return true if bound properties are enabled.
+ *
+ * @see #boundPropertiesEnabled()
+ */
+ public boolean boundListenersTransient() {
+ return TRUE.equalsIgnoreCase(_localProps.getProperty(Property.BOUND_PROPERTIES_TRANSIENT_LISTENERS));
+ } //-- boundListenersTransient
+
/**
* Returns true if we generate an 'equals' method for
* each generated class.
Index: org/exolab/castor/builder/SourceFactory.java
===================================================================
RCS file: /home/projects/castor/scm/castor/src/main/org/exolab/castor/builder/SourceFactory.java,v
retrieving revision 1.21
diff -u -r1.21 SourceFactory.java
--- org/exolab/castor/builder/SourceFactory.java 23 Jun 2005 04:14:49 -0000 1.21
+++ org/exolab/castor/builder/SourceFactory.java 4 Aug 2005 16:19:58 -0000
@@ -797,12 +797,11 @@
String vName = "propertyChangeListeners";
JField field = new JField(SGTypes.Vector, vName);
field.getModifiers().makePrivate();
+ if (_config.boundListenersTransient()) {
+ field.getModifiers().setTransient(true);
+ }
parent.addField(field);
-
- JSourceCode jsc = parent.getConstructor(0).getSourceCode();
- jsc.add("propertyChangeListeners = new Vector();");
-
//---------------------------------/
//- notifyPropertyChangeListeners -/
//---------------------------------/
@@ -832,7 +831,7 @@
jdDesc.setDescription("the new value of the property.");
parent.addMethod(jMethod);
- jsc = jMethod.getSourceCode();
+ JSourceCode jsc = jMethod.getSourceCode();
//--fix for bug 1026
jsc.add("if (");
jsc.append(vName);
@@ -873,6 +872,13 @@
parent.addMethod(jMethod);
jsc = jMethod.getSourceCode();
+
+
+ jsc.add("if (");
+ jsc.append(vName);
+ jsc.append(" == null) {");
+ jsc.addIndented(vName+" = new Vector();");
+ jsc.add("}");
jsc.add(vName);
jsc.append(".addElement(pcl);");
@@ -899,6 +905,9 @@
parent.addMethod(jMethod);
jsc = jMethod.getSourceCode();
+ jsc.add("if (");
+ jsc.append(vName);
+ jsc.append(" == null) return false;");
jsc.add("return ");
jsc.append(vName);
jsc.append(".removeElement(pcl);");
Index: org/exolab/castor/builder/castorbuilder.properties
===================================================================
RCS file: /home/projects/castor/scm/castor/src/main/org/exolab/castor/builder/castorbuilder.properties,v
retrieving revision 1.3
diff -u -r1.3 castorbuilder.properties
--- org/exolab/castor/builder/castorbuilder.properties 6 May 2004 08:20:51 -0000 1.3
+++ org/exolab/castor/builder/castorbuilder.properties 4 Aug 2005 16:19:58 -0000
@@ -10,6 +10,12 @@
#
#org.exolab.castor.builder.boundproperties=true
+# To cause bound property listeners to be transient uncomment the
+# following line. Bound properties must be enabled for this property
+# to take effect.
+#
+#org.exolab.castor.builder.boundproperties.transientlisteners=true
+
# Java class mapping of