Make nmgr volatile, remove setter for wrapped node manager, and check for null nmgr in constructors.

This commit is contained in:
hns 2009-09-08 13:51:39 +00:00
parent 44b4a1fe9c
commit e1354889ec

View file

@ -60,7 +60,7 @@ public final class Node implements INode, Serializable {
private transient String prototype; private transient String prototype;
private transient NodeHandle handle; private transient NodeHandle handle;
private transient INode cacheNode; private transient INode cacheNode;
transient WrappedNodeManager nmgr; transient volatile WrappedNodeManager nmgr;
transient DbMapping dbmap; transient DbMapping dbmap;
transient Key primaryKey = null; transient Key primaryKey = null;
transient String subnodeRelation = null; transient String subnodeRelation = null;
@ -113,6 +113,9 @@ public final class Node implements INode, Serializable {
* Constructor used for virtual nodes. * Constructor used for virtual nodes.
*/ */
public Node(Node home, String propname, WrappedNodeManager nmgr, String prototype) { public Node(Node home, String propname, WrappedNodeManager nmgr, String prototype) {
if (nmgr == null) {
throw new NullPointerException("nmgr");
}
this.nmgr = nmgr; this.nmgr = nmgr;
setParent(home); setParent(home);
// generate a key for the virtual node that can't be mistaken for a Database Key // generate a key for the virtual node that can't be mistaken for a Database Key
@ -134,6 +137,9 @@ public final class Node implements INode, Serializable {
* Creates a new Node with the given name. This is used for ordinary transient nodes. * Creates a new Node with the given name. This is used for ordinary transient nodes.
*/ */
public Node(String name, String prototype, WrappedNodeManager nmgr) { public Node(String name, String prototype, WrappedNodeManager nmgr) {
if (nmgr == null) {
throw new NullPointerException("nmgr");
}
this.nmgr = nmgr; this.nmgr = nmgr;
this.prototype = prototype; this.prototype = prototype;
dbmap = nmgr.getDbMapping(prototype); dbmap = nmgr.getDbMapping(prototype);
@ -158,6 +164,9 @@ public final class Node implements INode, Serializable {
*/ */
public synchronized void init(DbMapping dbm, String id, String name, String prototype, public synchronized void init(DbMapping dbm, String id, String name, String prototype,
Hashtable propMap, WrappedNodeManager nmgr) { Hashtable propMap, WrappedNodeManager nmgr) {
if (nmgr == null) {
throw new NullPointerException("nmgr");
}
this.nmgr = nmgr; this.nmgr = nmgr;
this.dbmap = dbm; this.dbmap = dbm;
this.prototype = prototype; this.prototype = prototype;
@ -585,15 +594,6 @@ public final class Node implements INode, Serializable {
return dbmap; return dbmap;
} }
/**
*
*
* @param nmgr
*/
public void setWrappedNodeManager(WrappedNodeManager nmgr) {
this.nmgr = nmgr;
}
/** /**
* *
* *