* the reflected class instance.
*/
private void testInstanceForIdField() {
- // look for the id field (should be an NCName string)
// TODO: decide if 'id' is an appropriate reserved attribute name for the VorbaId
- try {
- java.lang.reflect.Field fd = this.getClass().getDeclaredField("_id");
- if (String.class.isAssignableFrom(fd.getType())) {
- this.setRegisterable(true);
+ // look for the id field in all castor classes (should be an NCName string)
+
+ Class thisclass=this.getClass();
+ setRegisterable(false);
+ while (!thisclass.equals(Vobject.class)) {
+ try {
+ java.lang.reflect.Field fd = thisclass.getDeclaredField("_id");
+ if (String.class.isAssignableFrom(fd.getType())) {
+ this.setRegisterable(true);
+ break;
+ }
+ } catch (SecurityException e) {
+ log.error("Unexpected Security Exception whilst finding id fields to set!",e);
+ } catch (NoSuchFieldException e) {
+ thisclass=thisclass.getSuperclass();
}
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchFieldException e) {
- this.setRegisterable(false);
}
}
-
+ // boolean __testedInstance=false;
/**
* update the Vobject instance's _id field, based on the contents of the
* VorbaId. Only call this if you mean to do it!
*/
protected void setInstanceIdField() {
+ /*if (!registerable && !__testedInstance) {
+ testInstanceForIdField();
+ __testedInstance=true;
+ }*/
if (registerable) {
if (__vorba != null)
try {
* properly instantiated VorbaIdFactory.
*/
public VorbaId getVorbaId() {
+ /*if (!registerable && !__testedInstance) {
+ testInstanceForIdField();
+ __testedInstance=true;
+ }*/
if (registerable && vorbaId == null) {
// Try to use the associated factory.
if (__vorba != null)