public SchemaFactory run() { ClassLoader cl = ClassLoaderContext.setContextClassLoader(getClass().getClassLoader(), registry.getServiceDiscovery(), SchemaFactory.class, TransformerFactory.class, SAXParserFactory.class, DocumentBuilderFactory.class ); try { // Create an aggregated validation schemas from all the XSDs return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); } finally { if (cl != null) { Thread.currentThread().setContextClassLoader(cl); } } } });
public JAXBContext run() throws JAXBException { // Try to set up TCCL so that JAXBContext service discovery works in OSGi ClassLoader tccl = ClassLoaderContext.setContextClassLoader(JAXBContextCache.class.getClassLoader(), registry.getServiceDiscovery(), // The service provider of JAXBContext doesn't extend JAXBContext // We should use the service name instead of the class JAXBContext.class.getName(), DatatypeFactory.class.getName()); try { JAXBContext context = JAXBContext.newInstance(classesToBeBound); return context; } finally { if (tccl != null) { Thread.currentThread().setContextClassLoader(tccl); } } } });
public SchemaFactory run() { ClassLoader cl = ClassLoaderContext.setContextClassLoader(getClass().getClassLoader(), registry.getServiceDiscovery(), SchemaFactory.class, TransformerFactory.class, SAXParserFactory.class, DocumentBuilderFactory.class ); try { // Create an aggregated validation schemas from all the XSDs return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); } finally { if (cl != null) { Thread.currentThread().setContextClassLoader(cl); } } } });
public JAXBContext run() throws JAXBException { // Try to set up TCCL so that JAXBContext service discovery works in OSGi ClassLoader tccl = ClassLoaderContext.setContextClassLoader(JAXBContextCache.class.getClassLoader(), registry.getServiceDiscovery(), // The service provider of JAXBContext doesn't extend JAXBContext // We should use the service name instead of the class JAXBContext.class.getName(), DatatypeFactory.class.getName()); try { JAXBContext context = JAXBContext.newInstance(classesToBeBound); return context; } finally { if (tccl != null) { Thread.currentThread().setContextClassLoader(tccl); } } } });
public void init() throws ServletException { ClassLoader cl = ClassLoaderContext.setContextClassLoader(Thread.currentThread().getContextClassLoader(), registry.getServiceDiscovery(), "/META-INF/server/wink-providers", "javax.ws.rs.ext.RuntimeDelegate"); try { super.init(); } finally { if (cl != null) { // return previous classLoader Thread.currentThread().setContextClassLoader(cl); } } }
@Override public void configure(Map<String, Map<String, String>> attributes) { ServiceDiscovery discovery = getExtensionPointRegistry().getServiceDiscovery(); for (Map.Entry<String, Map<String, String>> e : attributes.entrySet()) { discovery.setAttribute(e.getKey(), e.getValue()); } for (Object o : properties.keySet()) { String p = (String) o; if (p.indexOf('.') > -1) { String serviceType = p.substring(0, p.lastIndexOf('.')); String attribute = p.substring(p.lastIndexOf('.')+1); discovery.setAttribute(serviceType, attribute, properties.getProperty(p)); } } quietLogging = Boolean.parseBoolean(properties.getProperty(RuntimeProperties.QUIET_LOGGING)); super.configure(attributes); }
@Override public void configure(Map<String, Map<String, String>> attributes) { ServiceDiscovery discovery = getExtensionPointRegistry().getServiceDiscovery(); for (Map.Entry<String, Map<String, String>> e : attributes.entrySet()) { discovery.setAttribute(e.getKey(), e.getValue()); } for (Object o : properties.keySet()) { String p = (String) o; if (p.indexOf('.') > -1) { String serviceType = p.substring(0, p.lastIndexOf('.')); String attribute = p.substring(p.lastIndexOf('.')+1); discovery.setAttribute(serviceType, attribute, properties.getProperty(p)); } } quietLogging = Boolean.parseBoolean(properties.getProperty(RuntimeProperties.QUIET_LOGGING)); super.configure(attributes); }
ServiceDeclaration factoryDeclaration = registry.getServiceDiscovery().getServiceDeclaration(factoryInterface.getName()); if (factoryDeclaration != null) { Class<?> factoryClass = factoryDeclaration.loadClass();
private synchronized void loadScanners() { if (loaded) return; // Get the scanner service declarations Collection<ServiceDeclaration> scannerDeclarations; try { scannerDeclarations = registry.getServiceDiscovery().getServiceDeclarations(ContributionScanner.class.getName()); } catch (IOException e) { throw new IllegalStateException(e); } for (ServiceDeclaration scannerDeclaration: scannerDeclarations) { Map<String, String> attributes = scannerDeclaration.getAttributes(); // Load a URL artifact scanner String contributionType = attributes.get("type"); // Create a scanner wrapper and register it ContributionScanner scanner = new LazyContributionScanner(registry, contributionType, scannerDeclaration); addContributionScanner(scanner); } loaded = true; }
private synchronized void loadScanners() { if (loaded) return; // Get the scanner service declarations Collection<ServiceDeclaration> scannerDeclarations; try { scannerDeclarations = registry.getServiceDiscovery().getServiceDeclarations(ContributionScanner.class.getName()); } catch (IOException e) { throw new IllegalStateException(e); } for (ServiceDeclaration scannerDeclaration: scannerDeclarations) { Map<String, String> attributes = scannerDeclaration.getAttributes(); // Load a URL artifact scanner String contributionType = attributes.get("type"); // Create a scanner wrapper and register it ContributionScanner scanner = new LazyContributionScanner(registry, contributionType, scannerDeclaration); addContributionScanner(scanner); } loaded = true; }
private synchronized void loadServletHosts() { if (loaded) return; // Get the databinding service declarations Collection<ServiceDeclaration> sds; try { sds = registry.getServiceDiscovery().getServiceDeclarations(ServletHost.class, true); } catch (IOException e) { throw new IllegalStateException(e); } // Load data bindings for (ServiceDeclaration sd : sds) { // Create a data binding wrapper and register it ServletHost servletHost = new LazyServletHost(sd); addServletHost(servletHost); } loaded = true; }
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); } }
/** * Lazily load artifact processors registered in the extension point. */ private synchronized void loadProcessors() { if (loaded) return; // Get the processor service declarations Collection<ServiceDeclaration> processorDeclarations; try { processorDeclarations = registry.getServiceDiscovery().getServiceDeclarations(URLArtifactProcessor.class.getName()); } catch (IOException e) { IllegalStateException ie = new IllegalStateException(e); throw ie; } for (ServiceDeclaration processorDeclaration : processorDeclarations) { Map<String, String> attributes = processorDeclaration.getAttributes(); // Load a URL artifact processor String artifactType = attributes.get("type"); String modelTypeName = attributes.get("model"); // Create a processor wrapper and register it URLArtifactProcessor<?> processor = new LazyURLArtifactProcessor(artifactType, modelTypeName, processorDeclaration, registry, staxProcessor); addArtifactProcessor(processor); } loaded = true; }
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); } }
/** * Dynamically load data bindings declared under META-INF/services */ private synchronized void loadDataBindings() { if (loadedDataBindings) return; // Get the databinding service declarations Collection<ServiceDeclaration> dataBindingDeclarations; try { dataBindingDeclarations = registry.getServiceDiscovery().getServiceDeclarations(DataBinding.class.getName()); } catch (IOException e) { throw new IllegalStateException(e); } // Load data bindings for (ServiceDeclaration dataBindingDeclaration : dataBindingDeclarations) { Map<String, String> attributes = dataBindingDeclaration.getAttributes(); String name = attributes.get("name"); // Create a data binding wrapper and register it DataBinding dataBinding = new LazyDataBinding(name, dataBindingDeclaration); addDataBinding(dataBinding); } loadedDataBindings = true; }
/** * Lazily load artifact processors registered in the extension point. */ private synchronized void loadProcessors() { if (loaded) return; // Get the processor service declarations Collection<ServiceDeclaration> processorDeclarations; try { processorDeclarations = registry.getServiceDiscovery().getServiceDeclarations(URLArtifactProcessor.class.getName()); } catch (IOException e) { IllegalStateException ie = new IllegalStateException(e); throw ie; } for (ServiceDeclaration processorDeclaration : processorDeclarations) { Map<String, String> attributes = processorDeclaration.getAttributes(); // Load a URL artifact processor String artifactType = attributes.get("type"); String modelTypeName = attributes.get("model"); // Create a processor wrapper and register it URLArtifactProcessor<?> processor = new LazyURLArtifactProcessor(artifactType, modelTypeName, processorDeclaration, registry, staxProcessor); addArtifactProcessor(processor); } loaded = true; }
/** * Dynamically load data bindings declared under META-INF/services */ private synchronized void loadDataBindings() { if (loadedDataBindings) return; // Get the databinding service declarations Collection<ServiceDeclaration> dataBindingDeclarations; try { dataBindingDeclarations = registry.getServiceDiscovery().getServiceDeclarations(DataBinding.class.getName()); } catch (IOException e) { throw new IllegalStateException(e); } // Load data bindings for (ServiceDeclaration dataBindingDeclaration : dataBindingDeclarations) { Map<String, String> attributes = dataBindingDeclaration.getAttributes(); String name = attributes.get("name"); // Create a data binding wrapper and register it DataBinding dataBinding = new LazyDataBinding(name, dataBindingDeclaration); addDataBinding(dataBinding); } loadedDataBindings = true; }
private static Object instantiate(ClassLoader cl, String className, JMSBinding binding, ExtensionPointRegistry registry) { try { for (ServiceDeclaration sd : registry.getServiceDiscovery().getServiceDeclarations(JMSMessageProcessor.class)) { if (className.equals(sd.getClassName())) { final Class<?> clazz = sd.loadClass(); Constructor<?> constructor; try { constructor = AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>() { public Constructor<?> run() throws NoSuchMethodException{ return clazz.getDeclaredConstructor(new Class[] {JMSBinding.class, ExtensionPointRegistry.class}); } }); } catch (PrivilegedActionException ex) { throw (NoSuchMethodException) ex.getException(); } return constructor.newInstance(binding, registry); } } throw new JMSBindingException("Class not found: " + className); } catch (Throwable e) { throw new JMSBindingException("Exception instantiating OperationAndDataBinding class", e); } }
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; } }