MCPcopy Index your code
hub / github.com/OpenSC/OpenSC-Java / DestroyableHolder

Class DestroyableHolder

java/src/org/opensc/util/DestroyableHolder.java:41–106  ·  view source on GitHub ↗

This class holds a map of destroyables, which will be destroyed recursively. @author wglas

Source from the content-addressed store, hash-verified

39 * @author wglas
40 */
41public class DestroyableHolder extends DestroyableChild implements DestroyableParent
42{
43 private Set<Destroyable> children;
44
45 /**
46 * Constructs a holder without a parent.
47 */
48 public DestroyableHolder()
49 {
50 super();
51 this.children = null;
52 }
53
54 /* (non-Javadoc)
55 * @see org.opensc.pkcs11.util.DestroyableParent#register(javax.security.auth.Destroyable)
56 */
57 public void register(Destroyable destroyable)
58 {
59 if (this.children == null)
60 this.children = new HashSet<Destroyable>();
61
62 this.children.add(destroyable);
63 }
64
65 /* (non-Javadoc)
66 * @see org.opensc.pkcs11.util.DestroyableParent#deregister(javax.security.auth.Destroyable)
67 */
68 public void deregister(Destroyable destroyable)
69 {
70 if (this.children == null) return;
71
72 this.children.remove(destroyable);
73 }
74
75 /**
76 * Constructs a holder with a parent.
77 */
78 public DestroyableHolder(DestroyableParent parent)
79 {
80 super(parent);
81 this.children = null;
82 }
83
84 /* (non-Javadoc)
85 * @see javax.security.auth.Destroyable#destroy()
86 */
87 public void destroy() throws DestroyFailedException
88 {
89 if (this.children != null)
90 {
91 for (Destroyable destroyable : this.children)
92 {
93 if (destroyable.isDestroyed()) continue;
94
95 if (destroyable instanceof DestroyableChild)
96 ((DestroyableChild)destroyable).unlink();
97
98 destroyable.destroy();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected