public synchronized ServletHost getServletHost() { if (host == null) { try { host = ServiceHelper.newInstance(registry, sd); ServiceHelper.start(host); } catch (Throwable e) { throw new IllegalStateException(e); } } return host; }
/** * Create a service instance from the service declaration * @param <T> * @param registry The extension point registry * @param sd The service declaration * @return The newly created service instance * @throws Exception */ public static <T> T newInstance(ExtensionPointRegistry registry, ServiceDeclaration sd) throws Exception { Class<T> cls = (Class<T>)sd.loadClass(); T instance = null; try { // Try constructor(ExtensionPointRegistry.class) instance = newInstance(cls, ExtensionPointRegistry.class, registry); } catch (NoSuchMethodException e) { try { // Try Try constructor(ExtensionPointRegistry.class, Map.class) instance = newInstance(cls, ARG_TYPES, registry, sd.getAttributes()); } catch (NoSuchMethodException e1) { // Try constructor() instance = newInstance(cls); } } return instance; }
/** * Create a service instance from the service declaration * @param <T> * @param registry The extension point registry * @param sd The service declaration * @return The newly created service instance * @throws Exception */ public static <T> T newInstance(ExtensionPointRegistry registry, ServiceDeclaration sd) throws Exception { Class<T> cls = (Class<T>)sd.loadClass(); T instance = null; try { // Try constructor(ExtensionPointRegistry.class) instance = newInstance(cls, ExtensionPointRegistry.class, registry); } catch (NoSuchMethodException e) { try { // Try Try constructor(ExtensionPointRegistry.class, Map.class) instance = newInstance(cls, ARG_TYPES, registry, sd.getAttributes()); } catch (NoSuchMethodException e1) { // Try constructor() instance = newInstance(cls); } } return instance; }
instance = newInstance(registry, sd); start(instance);
instance = newInstance(registry, sd); start(instance);
utility = newInstance(registry, utilityDeclaration); } else { try { utility = newInstance(utilityClass, ExtensionPointRegistry.class, registry); } catch (NoSuchMethodException e) { utility = newInstance(utilityClass);
utility = newInstance(registry, utilityDeclaration); } else { try { utility = newInstance(utilityClass, ExtensionPointRegistry.class, registry); } catch (NoSuchMethodException e) { utility = newInstance(utilityClass);
private synchronized void loadHosts() { if (loaded) { return; } try { ServiceDeclaration sd = registry.getServiceDiscovery().getServiceDeclaration(CorbaHost.class); CorbaHost host = ServiceHelper.newInstance(registry, sd); ServiceHelper.start(host); corbaHosts.add(host); } catch (Throwable e) { throw new ServiceRuntimeException(e); } }
Class<NodeActivator> activatorClass = (Class<NodeActivator>)activatorDeclaration.loadClass(); try { activator = ServiceHelper.newInstance(activatorClass, ExtensionPointRegistry.class, registry); } catch (NoSuchMethodException e) { try { activator = ServiceHelper.newInstance(activatorClass, new Class<?>[] {ExtensionPointRegistry.class, Map.class}, registry, activator = ServiceHelper.newInstance(activatorClass);
private synchronized void loadHosts() { if (loaded) { return; } try { ServiceDeclaration sd = registry.getServiceDiscovery().getServiceDeclaration(CorbaHost.class); CorbaHost host = ServiceHelper.newInstance(registry, sd); ServiceHelper.start(host); corbaHosts.add(host); } catch (Throwable e) { throw new ServiceRuntimeException(e); } }
Class<ModuleActivator> activatorClass = (Class<ModuleActivator>)activatorDeclaration.loadClass(); try { activator = newInstance(activatorClass, ExtensionPointRegistry.class, registry); } catch (NoSuchMethodException e) { try { activator = newInstance(activatorClass, new Class<?>[] {ExtensionPointRegistry.class, Map.class}, registry, activator = newInstance(activatorClass);
Class<NodeActivator> activatorClass = (Class<NodeActivator>)activatorDeclaration.loadClass(); try { activator = ServiceHelper.newInstance(activatorClass, ExtensionPointRegistry.class, registry); } catch (NoSuchMethodException e) { try { activator = ServiceHelper.newInstance(activatorClass, new Class<?>[] {ExtensionPointRegistry.class, Map.class}, registry, activator = ServiceHelper.newInstance(activatorClass);
Class<ModuleActivator> activatorClass = (Class<ModuleActivator>)activatorDeclaration.loadClass(); try { activator = newInstance(activatorClass, ExtensionPointRegistry.class, registry); } catch (NoSuchMethodException e) { try { activator = newInstance(activatorClass, new Class<?>[] {ExtensionPointRegistry.class, Map.class}, registry, activator = newInstance(activatorClass);
try { factory = newInstance(registry, factoryDeclaration); } catch (NoSuchMethodException e) { factory = newInstance(factoryDeclaration.loadClass(), FactoryExtensionPoint.class, this);
try { factory = newInstance(registry, factoryDeclaration); } catch (NoSuchMethodException e) { factory = newInstance(factoryDeclaration.loadClass(), FactoryExtensionPoint.class, this);
/** * 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); }
private synchronized void load() { if (loaded) { return; } try { Collection<ServiceDeclaration> declarations = registry.getServiceDiscovery().getServiceDeclarations(DomainRegistryFactory.class, true); for (ServiceDeclaration declaration : declarations) { DomainRegistryFactory factory = ServiceHelper.newInstance(registry, declaration); addDomainRegistryFactory(factory); } } catch (Exception e) { throw new ServiceRuntimeException(e); } finally { loaded = true; } }
private synchronized void load() { if (loaded) { return; } try { Collection<ServiceDeclaration> declarations = registry.getServiceDiscovery().getServiceDeclarations(DomainRegistryFactory.class, true); for (ServiceDeclaration declaration : declarations) { DomainRegistryFactory factory = ServiceHelper.newInstance(registry, declaration); addDomainRegistryFactory(factory); } } catch (Exception e) { throw new ServiceRuntimeException(e); } finally { loaded = true; } }