01
/**//* Copyright (C) 2008 db4objects Inc. http://www.db4o.com */
02
03
package com.db4odoc.tp.rollback;
04
05
import com.db4o.activation.ActivationPurpose;
06
import com.db4o.activation.Activator;
07
import com.db4o.ta.Activatable;
08
09
public class Pilot implements Activatable ...{
10
11
private String name;
12
private Id id;
13
14
transient Activator _activator;
15
// Bind the class to an object container
16
public void bind(Activator activator) ...{
17
if (_activator == activator) ...{
18
return;
19
}
20
if (activator != null && _activator != null) ...{
21
throw new IllegalStateException();
22
}
23
_activator = activator;
24
}
25
26
// activate the object fields
27
public void activate(ActivationPurpose purpose) ...{
28
if (_activator == null)
29
return;
30
_activator.activate(purpose);
31
}
32
33
34
public Pilot(String name, int id) ...{
35
this.name = name;
36
this.id = new Id(id);
37
}
38
39
public String getName() ...{
40
activate(ActivationPurpose.READ);
41
return name;
42
}
43
44
public void setName(String name) ...{
45
activate(ActivationPurpose.WRITE);
46
this.name = name;
47
}
48
49
public String toString() ...{
50
activate(ActivationPurpose.READ);
51
return getName() + "[" + id + "]";
52
}
53
54
public void setId(int i) ...{
55
activate(ActivationPurpose.WRITE);
56
this.id.change(i);
57
}
58
}