示例#1
0
 public boolean check(AssociationDescriptor descriptor, ServiceElement element) {
   return (ServiceElementUtil.matchesServiceElement(
       element,
       descriptor.getName(),
       descriptor.getInterfaceNames(),
       descriptor.getOperationalStringName()));
 }
示例#2
0
  /**
   * An AssociationDescriptor is equal to another AssociationDescriptor if their name, opStringName
   * and {@link AssociationType} attributes are equal
   */
  public boolean equals(final Object obj) {
    if (this == obj) return true;
    if (!(obj instanceof AssociationDescriptor)) return false;
    AssociationDescriptor that = (AssociationDescriptor) obj;
    if (this.type.equals(that.type) && this.getName().equals(that.getName())) {
      boolean matched = false;
      /* Check propertyName attributes */
      if (this.opStringName != null
          && that.opStringName != null
          && this.opStringName.equals(that.opStringName)) {
        matched = true;
      }
      if (this.opStringName == null && that.opStringName == null) matched = true;

      if (!matched) return matched;

      if (!Arrays.equals(this.interfaceNames, that.interfaceNames)) return false;

      /* Check propertyName attributes */
      if (this.propertyName != null
          && that.propertyName != null
          && this.propertyName.equals(that.propertyName)) {
        return true;
      }
      if (this.propertyName == null && that.propertyName == null) return true;
    }
    return (false);
  }
示例#3
0
 /**
  * Creates an AssociationDescriptor for a service, matching on the service name
  *
  * @param name The service name
  * @param setter The setter property to use when injecting
  * @param serviceClass The service's exported proxy class
  * @param type The type of Association to create
  * @param groups Discovery groups to use
  * @return An AssociationDescriptor
  */
 public static AssociationDescriptor create(
     final String name,
     final String setter,
     final Class serviceClass,
     final AssociationType type,
     final String... groups) {
   AssociationDescriptor ad = new AssociationDescriptor(type, name);
   ad.setInterfaceNames(serviceClass.getName());
   if (setter != null) ad.setPropertyName(setter);
   ad.setGroups(groups);
   ad.setMatchOnName(true);
   return ad;
 }
示例#4
0
 /**
  * This method verifies whether the InstantiatorResource can support any declared service
  * colocation requirements
  *
  * @param sElem The ServiceElement
  * @param ir The InstantiatorResource
  * @return Return true if the provided InstantiatorResource meets service colocation requirements
  */
 static boolean meetsColocationRequirements(ServiceElement sElem, InstantiatorResource ir) {
   boolean provisionable = true;
   AssociationDescriptor[] aDescs = sElem.getAssociationDescriptors();
   for (AssociationDescriptor aDesc : aDescs) {
     boolean ok = false;
     if (aDesc.getAssociationType() == AssociationType.COLOCATED) {
       if (matches(aDesc, ir.getServiceElements())) {
         break;
       }
     } else {
       ok = true;
     }
     if (!ok) {
       provisionable = false;
       break;
     }
   }
   return (provisionable);
 }
示例#5
0
 public boolean check(AssociationDescriptor descriptor, ServiceItem serviceItem) {
   if (descriptor.getVersion() == null) return true;
   boolean matches = false;
   String configuredVersion = descriptor.getVersion();
   for (Entry entry : serviceItem.attributeSets) {
     if (entry instanceof VersionEntry) {
       matches =
           versionMatcher.versionSupported(configuredVersion, ((VersionEntry) entry).version);
       if (logger.isDebugEnabled()) {
         logger.debug(
             "requiredVersion: {}, publishedVersion: {}, matched? {}",
             configuredVersion,
             entry,
             matches);
       }
       if (matches) break;
     }
   }
   return matches;
 }
示例#6
0
 /*
  * Get the AssociationMatchFilter for an AssociationDescriptor
  */
 private static AssociationMatchFilter getAssociationMatchFilter(
     AssociationDescriptor descriptor) {
   AssociationMatchFilter defaultFilter = new DefaultAssociationMatchFilter();
   AssociationMatchFilter filter;
   try {
     String matchFilter = descriptor.getAssociationMatchFilter();
     if (matchFilter != null) {
       ClassLoader cl = Thread.currentThread().getContextClassLoader();
       filter = (AssociationMatchFilter) cl.loadClass(matchFilter).newInstance();
     } else {
       filter = defaultFilter;
     }
   } catch (Exception e) {
     filter = defaultFilter;
     logger.log(
         Level.WARNING,
         "Getting AssociationMatchFilter for association " + "[" + descriptor.toString() + "]",
         e);
   }
   return (filter);
 }