This commit is contained in:
kamhung
2015-11-30 15:22:54 +08:00
parent c8f6a7835f
commit b65ddd5828
5 changed files with 11 additions and 10 deletions

View File

@@ -19,7 +19,7 @@ public final class WatchFactory {
private static final WatchFactory instance = new WatchFactory(null); private static final WatchFactory instance = new WatchFactory(null);
private final List<WeakReference<WatchBean>> beans = new CopyOnWriteArrayList<>(); private final List<WeakReference<WatchNode>> beans = new CopyOnWriteArrayList<>();
private final WatchFactory parent; private final WatchFactory parent;
@@ -27,7 +27,7 @@ public final class WatchFactory {
this.parent = parent; this.parent = parent;
} }
public void register(WatchBean bean) { public void register(WatchNode bean) {
if (bean != null) beans.add(new WeakReference<>(bean)); if (bean != null) beans.add(new WeakReference<>(bean));
} }
@@ -35,9 +35,10 @@ public final class WatchFactory {
return instance; return instance;
} }
// public WatchFactory createChild() { public WatchFactory createChild() {
// return new WatchFactory(this); return new WatchFactory(this);
// } }
public WatchNumber createWatchNumber(String name) { public WatchNumber createWatchNumber(String name) {
return createWatchNumber(name, "", false, 0); return createWatchNumber(name, "", false, 0);
} }
@@ -86,7 +87,7 @@ public final class WatchFactory {
if (Modifier.isFinal(field.getModifiers())) continue; if (Modifier.isFinal(field.getModifiers())) continue;
field.setAccessible(true); field.setAccessible(true);
final Class type = field.getType(); final Class type = field.getType();
WatchOn wo = field.getAnnotation(WatchOn.class); Watchable wo = field.getAnnotation(Watchable.class);
} }
} while ((clazz = clazz.getSuperclass()) != Object.class); } while ((clazz = clazz.getSuperclass()) != Object.class);

View File

@@ -9,7 +9,7 @@ package com.wentch.redkale.watch;
* *
* @author zhangjx * @author zhangjx
*/ */
public interface WatchBean { public interface WatchNode {
public String getName(); public String getName();

View File

@@ -11,7 +11,7 @@ import java.util.concurrent.atomic.*;
* *
* @author zhangjx * @author zhangjx
*/ */
public final class WatchNumber extends AtomicLong implements WatchBean { public final class WatchNumber extends AtomicLong implements WatchNode {
private final boolean interval; private final boolean interval;

View File

@@ -11,7 +11,7 @@ import java.util.function.LongSupplier;
* *
* @author zhangjx * @author zhangjx
*/ */
public final class WatchSupplier implements WatchBean { public final class WatchSupplier implements WatchNode {
private final String name; private final String name;

View File

@@ -18,7 +18,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Documented @Documented
@Target({FIELD}) @Target({FIELD})
@Retention(RUNTIME) @Retention(RUNTIME)
public @interface WatchOn { public @interface Watchable {
String name(); String name();