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 {
30 public abstract void addNotificationListener(NotificationListener listener);
31
38 public abstract void removeNotificationListener(NotificationListener listener);
39
40 private static final class CppProxy extends NotificationManager
41 {
42 private final long nativeRef;
43 private final AtomicBoolean destroyed = new AtomicBoolean(false);
44
45 private CppProxy(long nativeRef)
46 {
47 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
48 this.nativeRef = nativeRef;
49 }
50
51 private native void nativeDestroy(long nativeRef);
52 public void _djinni_private_destroy()
53 {
54 boolean destroyed = this.destroyed.getAndSet(true);
55 if (!destroyed) nativeDestroy(this.nativeRef);
56 }
57 protected void finalize() throws java.lang.Throwable
58 {
59 _djinni_private_destroy();
60 super.finalize();
61 }
62
63 // NotificationManager methods
64
65 @Override
66 public void addNotificationListener(NotificationListener listener)
67 {
68 assert !this.destroyed.get() : "trying to use a destroyed object";
69 native_addNotificationListener(this.nativeRef, listener);
70 }
71 private native void native_addNotificationListener(long _nativeRef, NotificationListener listener);
72
73 @Override
74 public void removeNotificationListener(NotificationListener listener)
75 {
76 assert !this.destroyed.get() : "trying to use a destroyed object";
77 native_removeNotificationListener(this.nativeRef, listener);
78 }
79 private native void native_removeNotificationListener(long _nativeRef, NotificationListener listener);
80 }
81}