/** * Discover all service providers that are compatible with the service type * @param serviceType * @return * @throws IOException */ public Collection<ServiceDeclaration> getServiceDeclarations(Class<?> serviceType) throws IOException { return getServiceDeclarations(serviceType, false); }
/** * Discover all service providers that are compatible with the service type * @param serviceType * @return * @throws IOException */ public Collection<ServiceDeclaration> getServiceDeclarations(Class<?> serviceType) throws IOException { return getServiceDeclarations(serviceType, false); }
public Collection<ServiceDeclaration> getServiceDeclarations(String name) throws IOException { return getServiceDeclarations(name, false); }
public Collection<ServiceDeclaration> getServiceDeclarations(String name) throws IOException { return getServiceDeclarations(name, false); }
public ServiceDeclaration getServiceDeclaration(Class<?> serviceType) throws IOException { Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceType, true); if (sds.isEmpty()) { return null; } else { return sds.iterator().next(); } }
public ServiceDeclaration getServiceDeclaration(Class<?> serviceType) throws IOException { Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceType, true); if (sds.isEmpty()) { return null; } else { return sds.iterator().next(); } }
/** * Get the service declaration. If there are more than one services, the one with highest ranking will * be returned. */ public ServiceDeclaration getServiceDeclaration(final String name) throws IOException { Collection<ServiceDeclaration> declarations = getServiceDeclarations(name, true); if (!declarations.isEmpty()) { // List<ServiceDeclaration> declarationList = new ArrayList<ServiceDeclaration>(declarations); // Collections.sort(declarationList, ServiceComparator.DESCENDING_ORDER); return declarations.iterator().next(); } else { return null; } }
/** * Get the service declaration. If there are more than one services, the one with highest ranking will * be returned. */ public ServiceDeclaration getServiceDeclaration(final String name) throws IOException { Collection<ServiceDeclaration> declarations = getServiceDeclarations(name, true); if (!declarations.isEmpty()) { // List<ServiceDeclaration> declarationList = new ArrayList<ServiceDeclaration>(declarations); // Collections.sort(declarationList, ServiceComparator.DESCENDING_ORDER); return declarations.iterator().next(); } else { return null; } }
/** * Get service declarations that are filtered by the service type. In an OSGi runtime, there * might be different versions of the services * @param serviceType * @return * @throws IOException */ public Collection<ServiceDeclaration> getServiceDeclarations(Class<?> serviceType, boolean byRanking) throws IOException { Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceType.getName(), byRanking); for (Iterator<ServiceDeclaration> i = sds.iterator(); i.hasNext();) { ServiceDeclaration sd = i.next(); if (!sd.isAssignableTo(serviceType)) { logger.log(Level.WARNING, "Service provider {0} is not a type of {1}", new Object[] {sd,serviceType.getName()}); i.remove(); } } return sds; }
void initCommands() throws IOException { for (ServiceDeclaration sd : ServiceDiscovery.getInstance().getServiceDeclarations(Command.class)) { try { Class<?> c = Class.forName(sd.getClassName()); try { Command command = (Command)c.getConstructor(Shell.class).newInstance(this); commands.put(command.getName(), command); } catch (NoSuchMethodException e) { Command command = (Command)c.newInstance(); commands.put(command.getName(), command); } } catch (Exception e) { e.printStackTrace(); } } }
void initCommands() throws IOException { for (ServiceDeclaration sd : ServiceDiscovery.getInstance().getServiceDeclarations(Command.class)) { try { Class<?> c = Class.forName(sd.getClassName()); try { Command command = (Command)c.getConstructor(Shell.class).newInstance(this); commands.put(command.getName(), command); } catch (NoSuchMethodException e) { Command command = (Command)c.newInstance(); commands.put(command.getName(), command); } } catch (Exception e) { e.printStackTrace(); } } }
/** * @param serviceName * @param filter * @return * @throws IOException */ public Collection<ServiceDeclaration> getServiceDeclarations(String serviceName, String filter) throws IOException { Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceName, false); Collection<ServiceDeclaration> filtered = new ArrayList<ServiceDeclaration>(); LDAPFilter filterImpl = LDAPFilter.newInstance(filter); for(ServiceDeclaration sd: sds) { if(filterImpl.match(sd.getAttributes())) { filtered.add(sd); } } return filtered; }
/** * @param serviceName * @param filter * @return * @throws IOException */ public Collection<ServiceDeclaration> getServiceDeclarations(String serviceName, String filter) throws IOException { Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceName, false); Collection<ServiceDeclaration> filtered = new ArrayList<ServiceDeclaration>(); LDAPFilter filterImpl = LDAPFilter.newInstance(filter); for(ServiceDeclaration sd: sds) { if(filterImpl.match(sd.getAttributes())) { filtered.add(sd); } } return filtered; }
/** * Discover all service providers that are compatible with the service type and match the filter * @param serviceType * @param filter * @return * @throws IOException */ public Collection<ServiceDeclaration> getServiceDeclarations(Class<?> serviceType, String filter) throws IOException { Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceType, false); Collection<ServiceDeclaration> filtered = new ArrayList<ServiceDeclaration>(); LDAPFilter filterImpl = LDAPFilter.newInstance(filter); for(ServiceDeclaration sd: sds) { if(filterImpl.match(sd.getAttributes())) { filtered.add(sd); } } return filtered; }
/** * Discover all service providers that are compatible with the service type and match the filter * @param serviceType * @param filter * @return * @throws IOException */ public Collection<ServiceDeclaration> getServiceDeclarations(Class<?> serviceType, String filter) throws IOException { Collection<ServiceDeclaration> sds = getServiceDeclarations(serviceType, false); Collection<ServiceDeclaration> filtered = new ArrayList<ServiceDeclaration>(); LDAPFilter filterImpl = LDAPFilter.newInstance(filter); for(ServiceDeclaration sd: sds) { if(filterImpl.match(sd.getAttributes())) { filtered.add(sd); } } return filtered; }
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 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; } }