/** * 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); }
/** * 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); }
/** * 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); }