GuardedObjectpublic class GuardedObject extends Object implements Serializable{@code GuardedObject} controls access to an object, by checking all requests
for the object with a {@code Guard}. |
Fields Summary |
---|
private static final long | serialVersionUID | private final Object | object | private final Guard | guard |
Constructors Summary |
---|
public GuardedObject(Object object, Guard guard)Constructs a new instance of {@code GuardedObject} which protects access
to the specified {@code Object} using the specified {@code Guard}.
this.object = object;
this.guard = guard;
|
Methods Summary |
---|
public java.lang.Object | getObject()Returns the guarded {@code Object} if the associated {@code Guard}
permits access. If access is not granted, then a {@code
SecurityException} is thrown.
if (guard != null) {
guard.checkGuard(object);
}
return object;
| private void | writeObject(java.io.ObjectOutputStream out)Checks the guard (if there is one) before performing a default
serialization.
if (guard != null) {
guard.checkGuard(object);
}
out.defaultWriteObject();
|
|