public DefaultJavaImplementationFactory() { super(new DefaultExtensionPointRegistry()); } }
@Override protected void unregisterExtensionPoint(Class<?> i) { ServiceRegistration registration = registrations.remove(i); if (registration != null) { try { registration.unregister(); } catch (IllegalStateException e) { // The service has been unregistered, ignore it } } super.unregisterExtensionPoint(i); }
/** * Add an extension point to the registry. This default implementation * stores extensions against the interfaces that they implement. * * @param extensionPoint The instance of the extension point * * @throws IllegalArgumentException if extensionPoint is null */ public synchronized void addExtensionPoint(Object extensionPoint) { addExtensionPoint(extensionPoint, null); }
/** * Get the extension point by the interface that it implements * * @param extensionPointType The lookup key (extension point interface) * @return The instance of the extension point * * @throws IllegalArgumentException if extensionPointType is null */ public synchronized <T> T getExtensionPoint(Class<T> extensionPointType) { if (extensionPointType == null) { throw new IllegalArgumentException("Cannot lookup ExtensionPoint of type null"); } Object extensionPoint = findExtensionPoint(extensionPointType); if (extensionPoint == null) { // Dynamically load an extension point class declared under META-INF/services try { ServiceDeclaration extensionPointDeclaration = getServiceDiscovery().getServiceDeclaration(extensionPointType); if (extensionPointDeclaration != null) { extensionPoint = newInstance(this, extensionPointDeclaration); // Cache the loaded extension point addExtensionPoint(extensionPoint, extensionPointDeclaration); } } catch (Throwable e) { throw new IllegalArgumentException(e); } } return extensionPointType.cast(extensionPoint); }
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); } }
/** * 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; }
@Override protected void registerExtensionPoint(Class<?> extensionPointType, Object extensionPoint, ServiceDeclaration declaration) { BundleContext context = bundleContext; if (declaration instanceof EquinoxServiceDiscoverer.ServiceDeclarationImpl) { EquinoxServiceDiscoverer.ServiceDeclarationImpl declarationImpl = (EquinoxServiceDiscoverer.ServiceDeclarationImpl)declaration; Bundle bundle = declarationImpl.getBundle(); /** * If this bundle is not in the STARTING, ACTIVE, or STOPPING states or this bundle * is a fragment bundle, then this bundle has no valid BundleContext. This method will * return null if this bundle has no valid BundleContext */ if ((bundle.getState() & (Bundle.ACTIVE | Bundle.STARTING)) == 0) { try { bundle.start(); } catch (BundleException e) { throw new IllegalStateException(e); } } context = bundle.getBundleContext(); } Dictionary<Object, Object> props = new Hashtable<Object, Object>(); ServiceRegistration registration = context.registerService(extensionPointType.getName(), extensionPoint, props); registrations.put(extensionPointType, registration); super.registerExtensionPoint(extensionPointType, extensionPoint, declaration); }
/** * Get the extension point by the interface that it implements * * @param extensionPointType The lookup key (extension point interface) * @return The instance of the extension point * * @throws IllegalArgumentException if extensionPointType is null */ public synchronized <T> T getExtensionPoint(Class<T> extensionPointType) { if (extensionPointType == null) { throw new IllegalArgumentException("Cannot lookup ExtensionPoint of type null"); } Object extensionPoint = findExtensionPoint(extensionPointType); if (extensionPoint == null) { // Dynamically load an extension point class declared under META-INF/services try { ServiceDeclaration extensionPointDeclaration = getServiceDiscovery().getServiceDeclaration(extensionPointType); if (extensionPointDeclaration != null) { extensionPoint = newInstance(this, extensionPointDeclaration); // Cache the loaded extension point addExtensionPoint(extensionPoint, extensionPointDeclaration); } } catch (Throwable e) { throw new IllegalArgumentException(e); } } return extensionPointType.cast(extensionPoint); }
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); } }
/** * 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; }
/** * Constructs a new XMLInputFactory. * * @param inputFactory * @param schemas */ // FOR Test only public DefaultValidatingXMLInputFactory(XMLInputFactory inputFactory, ValidationSchemaExtensionPoint schemas) { this.inputFactory = inputFactory; this.schemas = schemas; this.registry = new DefaultExtensionPointRegistry(); }
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); } }
/** * Add an extension point to the registry. This default implementation * stores extensions against the interfaces that they implement. * * @param extensionPoint The instance of the extension point * * @throws IllegalArgumentException if extensionPoint is null */ public synchronized void addExtensionPoint(Object extensionPoint) { addExtensionPoint(extensionPoint, null); }
PhaseManager(String pattern) { super(); this.pattern = pattern; this.registry = new DefaultExtensionPointRegistry(); }
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); } }
/** * Constructs a new XMLInputFactory. * * @param inputFactory * @param schemas */ // FOR Test only public DefaultValidatingXMLInputFactory(XMLInputFactory inputFactory, ValidationSchemaExtensionPoint schemas) { this.inputFactory = inputFactory; this.schemas = schemas; this.registry = new DefaultExtensionPointRegistry(); }
protected ExtensionPointRegistry createExtensionPointRegistry() { return new DefaultExtensionPointRegistry(); }
public DefaultAssemblyFactory() { super(new DefaultExtensionPointRegistry()); }