/** * Returns the set of interfaces implemented by the given class and its * ancestors or a blank set if none */ private static Set<Class<?>> getAllInterfaces(Class<?> clazz) { Set<Class<?>> implemented = new HashSet<Class<?>>(); getAllInterfaces(clazz, implemented); implemented.remove(LifeCycleListener.class); return implemented; }
/** * Returns the set of interfaces implemented by the given class and its * ancestors or a blank set if none */ private static Set<Class<?>> getAllInterfaces(Class<?> clazz) { Set<Class<?>> implemented = new HashSet<Class<?>>(); getAllInterfaces(clazz, implemented); implemented.remove(LifeCycleListener.class); return implemented; }
private static void getAllInterfaces(Class<?> clazz, Set<Class<?>> implemented) { Class<?>[] interfaces = clazz.getInterfaces(); for (Class<?> interfaze : interfaces) { if (Modifier.isPublic(interfaze.getModifiers())) { implemented.add(interfaze); } } Class<?> superClass = clazz.getSuperclass(); // Object has no superclass so check for null if (superClass != null && !superClass.equals(Object.class)) { getAllInterfaces(superClass, implemented); } }
private static void getAllInterfaces(Class<?> clazz, Set<Class<?>> implemented) { Class<?>[] interfaces = clazz.getInterfaces(); for (Class<?> interfaze : interfaces) { if (Modifier.isPublic(interfaze.getModifiers())) { implemented.add(interfaze); } } Class<?> superClass = clazz.getSuperclass(); // Object has no superclass so check for null if (superClass != null && !superClass.equals(Object.class)) { getAllInterfaces(superClass, implemented); } }
public synchronized void addExtensionPoint(Object extensionPoint, ServiceDeclaration declaration) { if (extensionPoint == null) { throw new IllegalArgumentException("Cannot register null as an ExtensionPoint"); } ServiceHelper.start(extensionPoint); Set<Class<?>> interfaces = getAllInterfaces(extensionPoint.getClass()); for (Class<?> i : interfaces) { registerExtensionPoint(i, extensionPoint, declaration); } }
public synchronized void addExtensionPoint(Object extensionPoint, ServiceDeclaration declaration) { if (extensionPoint == null) { throw new IllegalArgumentException("Cannot register null as an ExtensionPoint"); } ServiceHelper.start(extensionPoint); Set<Class<?>> interfaces = getAllInterfaces(extensionPoint.getClass()); for (Class<?> i : interfaces) { registerExtensionPoint(i, extensionPoint, declaration); } }
/** * Remove an extension point based on the interface that it implements * * @param extensionPoint The extension point to remove * * @throws IllegalArgumentException if extensionPoint is null */ public synchronized void removeExtensionPoint(Object extensionPoint) { if (extensionPoint == null) { throw new IllegalArgumentException("Cannot remove null as an ExtensionPoint"); } ServiceHelper.stop(extensionPoint); Set<Class<?>> interfaces = getAllInterfaces(extensionPoint.getClass()); for (Class<?> i : interfaces) { unregisterExtensionPoint(i); } }
/** * Remove an extension point based on the interface that it implements * * @param extensionPoint The extension point to remove * * @throws IllegalArgumentException if extensionPoint is null */ public synchronized void removeExtensionPoint(Object extensionPoint) { if (extensionPoint == null) { throw new IllegalArgumentException("Cannot remove null as an ExtensionPoint"); } ServiceHelper.stop(extensionPoint); Set<Class<?>> interfaces = getAllInterfaces(extensionPoint.getClass()); for (Class<?> i : interfaces) { unregisterExtensionPoint(i); } }