public String getName() { return sd.getAttributes().get("name"); }
public int compare(ServiceDeclaration o1, ServiceDeclaration o2) { int rank1 = 0; String r1 = o1.getAttributes().get("ranking"); if (r1 != null) { rank1 = Integer.parseInt(r1); } int rank2 = 0; String r2 = o2.getAttributes().get("ranking"); if (r2 != null) { rank2 = Integer.parseInt(r2); } return rank2 - rank1; // descending } }
public int compare(ServiceDeclaration o1, ServiceDeclaration o2) { int rank1 = 0; String r1 = o1.getAttributes().get("ranking"); if (r1 != null) { rank1 = Integer.parseInt(r1); } int rank2 = 0; String r2 = o2.getAttributes().get("ranking"); if (r2 != null) { rank2 = Integer.parseInt(r2); } return rank2 - rank1; // descending } }
/** * Remove the duplicate service declarations. The duplication happens when we have the same jar from more than one entries on the classpath * @param declarations * @return */ public static Collection<ServiceDeclaration> removeDuplicateDeclarations(Collection<ServiceDeclaration> declarations) { // Use LinkedHashMap to maintain the insertion order Map<Map<String, String>, ServiceDeclaration> map = new LinkedHashMap<Map<String, String>, ServiceDeclaration>(); for (ServiceDeclaration sd : declarations) { ServiceDeclaration existed = map.put(sd.getAttributes(), sd); if (existed != null) { logger.warning("Duplicate service declaration is detected: " + existed + " <-> " + sd); } } return map.values(); } }
/** * @param sd */ public LazyBindingBuilder(ServiceDeclaration sd) { super(); this.sd = sd; this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname")); }
/** * @param sd */ public LazyImplementationBuilder(ServiceDeclaration sd) { super(); this.sd = sd; this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname")); }
/** * Remove the duplicate service declarations. The duplication happens when we have the same jar from more than one entries on the classpath * @param declarations * @return */ public static Collection<ServiceDeclaration> removeDuplicateDeclarations(Collection<ServiceDeclaration> declarations) { // Use LinkedHashMap to maintain the insertion order Map<Map<String, String>, ServiceDeclaration> map = new LinkedHashMap<Map<String, String>, ServiceDeclaration>(); for (ServiceDeclaration sd : declarations) { ServiceDeclaration existed = map.put(sd.getAttributes(), sd); if (existed != null) { logger.warning("Duplicate service declaration is detected: " + existed + " <-> " + sd); } } return map.values(); } }
/** * @param sd */ public LazyImplementationBuilder(ServiceDeclaration sd) { super(); this.sd = sd; this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname")); }
/** * @param sd */ public LazyPolicyBuilder(ServiceDeclaration sd) { super(); this.sd = sd; this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname")); }
/** * @param sd */ public LazyBindingBuilder(ServiceDeclaration sd) { super(); this.sd = sd; this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname")); }
private Object getAttribute(Method method) throws Exception { if (method.getParameterTypes().length != 0) { return null; } String name = method.getName(); if (name.equals("getModelType") && method.getReturnType() == Class.class) { return sd.loadClass(sd.getAttributes().get("model")); } else if (name.equals("getArtifactType")) { return ServiceDeclarationParser.getQName(sd.getAttributes().get("qname")); } return null; }
/** * @param sd */ public LazyPolicyBuilder(ServiceDeclaration sd) { super(); this.sd = sd; this.qname = ServiceDeclarationParser.getQName(sd.getAttributes().get("qname")); }
private Object getAttribute(Method method) throws Exception { if (method.getParameterTypes().length != 0) { return null; } String name = method.getName(); if (name.equals("getModelType") && method.getReturnType() == Class.class) { return sd.loadClass(sd.getAttributes().get("model")); } else if (name.equals("getArtifactType")) { return ServiceDeclarationParser.getQName(sd.getAttributes().get("qname")); } return null; }
public static boolean matches(ServiceDeclaration declaration, String filter) { if (filter == null) { return true; } LDAPFilter filterImpl = newInstance(filter); return filterImpl.match(declaration.getAttributes()); }
public static boolean matches(ServiceDeclaration declaration, String filter) { if (filter == null) { return true; } LDAPFilter filterImpl = newInstance(filter); return filterImpl.match(declaration.getAttributes()); }
/** * @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; }
/** * @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; }
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; }