Loading...
Searching...
No Matches
NotificationManager.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
21public abstract class NotificationManager {
38 public abstract void addNotificationListener(NotificationListener listener);
39
54 public abstract void removeNotificationListener(NotificationListener listener);
55
56 private static final class CppProxy extends NotificationManager
57 {
58 private final long nativeRef;
59 private final AtomicBoolean destroyed = new AtomicBoolean(false);
60
61 private CppProxy(long nativeRef)
62 {
63 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
64 this.nativeRef = nativeRef;
65 }
66
67 private native void nativeDestroy(long nativeRef);
68 public void _djinni_private_destroy()
69 {
70 boolean destroyed = this.destroyed.getAndSet(true);
71 if (!destroyed) nativeDestroy(this.nativeRef);
72 }
73 protected void finalize() throws java.lang.Throwable
74 {
75 _djinni_private_destroy();
76 super.finalize();
77 }
78
79 // NotificationManager methods
80
81 @Override
82 public void addNotificationListener(NotificationListener listener)
83 {
84 assert !this.destroyed.get() : "trying to use a destroyed object";
85 native_addNotificationListener(this.nativeRef, listener);
86 }
87 private native void native_addNotificationListener(long _nativeRef, NotificationListener listener);
88
89 @Override
90 public void removeNotificationListener(NotificationListener listener)
91 {
92 assert !this.destroyed.get() : "trying to use a destroyed object";
93 native_removeNotificationListener(this.nativeRef, listener);
94 }
95 private native void native_removeNotificationListener(long _nativeRef, NotificationListener listener);
96 }
97}