コード例 #1
0
  public BusinessService readServiceAnnotations(String classWithAnnotations, Properties properties)
      throws ClassNotFoundException {

    BusinessService service = new BusinessService();
    Class<?> clazz = ClassUtil.forName(classWithAnnotations, this.getClass());
    UDDIService uddiService = (UDDIService) clazz.getAnnotation(UDDIService.class);
    WebService webServiceAnnotation = (WebService) clazz.getAnnotation(WebService.class);

    if (uddiService != null) {
      // service
      String lang = "en"; // default to english
      if (uddiService.lang() != null) {
        lang = uddiService.lang();
      }
      Name name = new Name();
      name.setLang(lang);
      service.setBusinessKey(TokenResolver.replaceTokens(uddiService.businessKey(), properties));
      service.setServiceKey(TokenResolver.replaceTokens(uddiService.serviceKey(), properties));
      if (!"".equals(uddiService.serviceName())) {
        name.setValue(TokenResolver.replaceTokens(uddiService.serviceName(), properties));
      } else if (webServiceAnnotation != null && !"".equals(webServiceAnnotation.serviceName())) {
        name.setValue(webServiceAnnotation.serviceName());
      } else {
        name.setValue(clazz.getSimpleName());
      }
      service.getName().add(name);
      Description description = new Description();
      description.setLang(lang);
      description.setValue(TokenResolver.replaceTokens(uddiService.description(), properties));
      service.getDescription().add(description);

      // categoryBag on the service
      if (!"".equals(uddiService.categoryBag())) {
        CategoryBag categoryBag = parseCategoryBag(uddiService.categoryBag());
        service.setCategoryBag(categoryBag);
      }

      // bindingTemplate on service
      BindingTemplate bindingTemplate =
          parseServiceBinding(clazz, lang, webServiceAnnotation, properties);
      if (bindingTemplate != null) {
        bindingTemplate.setServiceKey(service.getServiceKey());
        if (service.getBindingTemplates() == null) {
          service.setBindingTemplates(new BindingTemplates());
        }
        service.getBindingTemplates().getBindingTemplate().add(bindingTemplate);
      }

    } else {
      log.error("Missing UDDIService annotation in class " + classWithAnnotations);
    }

    return service;
  }
コード例 #2
0
  /**
   * This method is used to populate the Business Service with the retrieved uniform service
   * information. If there is a single service name, the service passed in will be populated with
   * that name. If there are multiple aliases for a service name, a copy of the service will be
   * created and it will be populated with the alias and then added to the Business Entity
   * structure.
   *
   * @param oUDDIService The information on the service as retrieved from the UDDI registry.
   * @param oEntities The complete list of business entities against which the desired entity is
   *     found. If multiple uniform service names are detected a new service will be added to this
   *     entity.
   * @param oService The business service which is updated with the uniform service name. If
   *     multiples are detected a copy of this service will be made to form a new one.
   */
  public void populateUniformServiceNameAndReplicateService(
      BusinessService oUDDIService, CMBusinessEntities oEntities, CMBusinessService oService) {
    if ((oUDDIService.getCategoryBag() != null)
        && (oUDDIService.getCategoryBag().getKeyedReference() != null)
        && (oUDDIService.getCategoryBag().getKeyedReference().size() > 0)) {

      // Uniform Service Name
      // ---------------------
      List<String> oServiceNames =
          findAndGetValueFromKeyedReference(
              oUDDIService.getCategoryBag().getKeyedReference(), UNIFORM_SERVICE_NAME_KEY);

      if (oServiceNames != null && oServiceNames.size() > 0) {

        // The existance of more than one service name will create multiple services for the entity
        int serviceCount = 0;
        for (String sValue : oServiceNames) {
          if ((sValue != null) && (sValue.length() > 0)) {
            if (serviceCount == 0) {
              oService.setUniformServiceName(sValue);
            } else {
              CMBusinessService oServiceCopy = oService.createCopy();
              oServiceCopy.setUniformServiceName(sValue);
              CMBusinessEntity oEntity =
                  findSpecificBusiness(
                      oEntities.getBusinessEntity(), oUDDIService.getBusinessKey());
              oEntity.getBusinessServices().getBusinessService().add(oServiceCopy);
            }
            serviceCount++;
          }
        }
      } else {
        log.debug(
            "A Normal Service value is NOT detected for UDDI Service "
                + oUDDIService.getBusinessKey()
                + " - "
                + oUDDIService.getServiceKey());
      }
    } // if ((oUDDIService.getCategoryBag() != null) &&  ...
  }
コード例 #3
0
  /**
   * This method retrieves the service information from the UDDI server for each of the business
   * entities.
   *
   * @param oEntities The business entities for which services should be retrieved. The information
   *     is placed in the appropriate location in this object.
   * @throws UDDIAccessorException
   */
  private void retrieveDetailedServiceInfoFromUDDI(CMBusinessEntities oEntities)
      throws UDDIAccessorException {
    if ((oEntities == null)
        || (oEntities.getBusinessEntity() == null)
        || (oEntities.getBusinessEntity().size() <= 0)) {
      return; // we are done  there is nothing to retrieve.
    }

    ServiceDetail oResult = null;

    try {
      GetServiceDetail oSearchParams = new GetServiceDetail();

      // Load up the list of service keys to retrieve the details of...
      // --------------------------------------------------------
      for (CMBusinessEntity oEntity : oEntities.getBusinessEntity()) {
        if ((oEntity.getBusinessServices() != null)
            && (oEntity.getBusinessServices().getBusinessService() != null)
            && (oEntity.getBusinessServices().getBusinessService().size() > 0)) {
          for (CMBusinessService oService : oEntity.getBusinessServices().getBusinessService()) {
            if ((oService.getServiceKey() != null) && (oService.getServiceKey().length() > 0)) {
              oSearchParams.getServiceKey().add(oService.getServiceKey());
            }
          } // for (CMBusinessService oService : oEntity.getBusinessServices().getBusinessService())
        } // if ((oEntity.getBusinessServices() != null) && ...
      } // for (CMBusinessEntity oEntity : oEntities.getBusinessEntity())

      UDDIInquiryPortType oPort = getUDDIInquiryWebService();
      oResult = oPort.getServiceDetail(oSearchParams);
    } catch (Exception e) {
      String sErrorMessage =
          "Failed to call UDDI web service get_serviceDetail method.  Error: " + e.getMessage();
      log.error(sErrorMessage, e);
      throw new UDDIAccessorException(sErrorMessage, e);
    }

    // Now let's process the results...
    // ---------------------------------
    if ((oResult != null)
        && (oResult.getBusinessService() != null)
        && (oResult.getBusinessService().size() > 0)) {
      // Now put the returned information back into our structure.
      // -----------------------------------------------------------
      for (BusinessService oUDDIService : oResult.getBusinessService()) {
        if ((oUDDIService.getServiceKey() != null)
            && (oUDDIService.getServiceKey().length() > 0)
            && (oUDDIService.getBusinessKey() != null)
            && (oUDDIService.getBusinessKey().length() > 0)) {
          CMBusinessService oService =
              findSpecificService(
                  oEntities.getBusinessEntity(),
                  oUDDIService.getBusinessKey(),
                  oUDDIService.getServiceKey());

          if (oService != null) {
            // Binding Service Name
            // ----------------------
            if ((oUDDIService.getName() != null) && (oUDDIService.getName().size() > 0)) {
              CMBindingNames oNames = new CMBindingNames();
              oService.setNames(oNames);

              for (Name oUDDIName : oUDDIService.getName()) {
                if ((oUDDIName.getValue() != null) && (oUDDIName.getValue().length() > 0)) {
                  oService.getNames().getName().add(oUDDIName.getValue());
                }
              }
            } // if ((oUDDIService.getName() != null) &&

            // Binding Descriptions
            // ---------------------
            if ((oUDDIService.getDescription() != null)
                && (oUDDIService.getDescription().size() > 0)) {
              CMBindingDescriptions oDescripts = new CMBindingDescriptions();
              oService.setDescriptions(oDescripts);

              for (Description oUDDIDescript : oUDDIService.getDescription()) {
                if ((oUDDIDescript.getValue() != null) && (oUDDIDescript.getValue().length() > 0)) {
                  oService.getDescriptions().getDescription().add(oUDDIDescript.getValue());
                }
              }
            } // if ((oUDDIService.getDescription() != null) && ...

            // Binding Template Information
            // -----------------------------
            if ((oUDDIService.getBindingTemplates() != null)
                && (oUDDIService.getBindingTemplates().getBindingTemplate() != null)
                && (oUDDIService.getBindingTemplates().getBindingTemplate().size() > 0)) {
              CMBindingTemplates oTemplates = new CMBindingTemplates();
              for (BindingTemplate oUDDITemplate :
                  oUDDIService.getBindingTemplates().getBindingTemplate()) {
                CMBindingTemplate oTemplate = new CMBindingTemplate();
                boolean bHaveData = false;

                // Endpoint URL
                // --------------
                if ((oUDDITemplate.getAccessPoint() != null)
                    && (oUDDITemplate.getAccessPoint().getValue() != null)
                    && (oUDDITemplate.getAccessPoint().getValue().length() > 0)) {
                  oTemplate.setEndpointURL(oUDDITemplate.getAccessPoint().getValue());
                  bHaveData = true;
                }

                // Service Version
                // ---------------
                if ((oUDDITemplate.getCategoryBag() != null)
                    && (oUDDITemplate.getCategoryBag().getKeyedReference() != null)
                    && (oUDDITemplate.getCategoryBag().getKeyedReference().size() > 0)) {

                  List<String> oServiceVersions =
                      findAndGetValueFromKeyedReference(
                          oUDDITemplate.getCategoryBag().getKeyedReference(), SERVICE_VERSION_KEY);
                  if (oServiceVersions != null && oServiceVersions.size() == 1) {
                    for (String sValue : oServiceVersions) {
                      if ((sValue != null) && (sValue.length() > 0)) {
                        oTemplate.setServiceVersion(sValue);
                        bHaveData = true;
                      }
                    }
                  } else {
                    log.debug(
                        "A single Service Version is NOT detected for UDDI Service "
                            + oUDDIService.getBusinessKey()
                            + " - "
                            + oUDDIService.getServiceKey());
                  }
                }
                if (bHaveData) {
                  oTemplates.getBindingTemplate().add(oTemplate);
                }
              }

              if ((oTemplates.getBindingTemplate() != null)
                  && (oTemplates.getBindingTemplate().size() > 0)) {
                oService.setBindingTemplates(oTemplates);
              }
            }

            // Uniform Service Name
            //
            // Multiple Uniform Service Names will result in the
            // creation of oService copies so this should be the last
            // population to be performed.
            // ----------------------------------------
            populateUniformServiceNameAndReplicateService(oUDDIService, oEntities, oService);
          } // if (oService != null)
        } // if ((oUDDIService.getServiceKey() != null) &&  ...
      } // for (BusinessService oUDDIService : oResult.getBusinessService())
    } // if ((oResult != null) &&
  }