public interface Activatable
public class Item {
private Item _next;
public Item(Item next) {
_next = next;
}
public Item next() {
return _next;
}
}
The basic sequence of actions to get the above scheme to work is the
following:
public class Item implements Activatable {
transient Activator _activator;
public void bind(Activator activator) {
if (null != _activator) {
throw new IllegalStateException();
}
_activator = activator;
}
// ...
}
- The first action in every method body of an activatable object should be a
call to the corresponding Activator's activate() method. (Note that this is
not enforced by any interface, it is rather a convention, and other
implementations are possible.)
public class Item implements Activatable {
public void activate() {
if (_activator == null) return;
_activator.activate();
}
public Item next() {
activate();
return _next;
}
}
- The activate() method will check whether the object is already activated.
If this is not the case, it will request the container to activate the object
to level 1 and set the activated flag accordingly.
Configuration config = ...
config.add(new TransparentActivationSupport());
Java: If you implement this interface manually and intend to pass this class through
the db4o bytecode instrumentation process, make sure you also implement the
ActivatableInstrumented marker interface.| Modifier and Type | Method and Description |
|---|---|
void |
activate(ActivationPurpose purpose)
should be called by every reading field access of an object.
|
void |
bind(Activator activator)
called by db4o upon instantiation.
|
void bind(Activator activator)
Activator in a transient field of the object.activator - the Activatorvoid activate(ActivationPurpose purpose)
Activator.activate(ActivationPurpose) on the Activator
that was previously passed to bind(Activator).purpose - TODO