コード例 #1
0
ファイル: SGAxisServlet.java プロジェクト: haruo31/langrid
  private void loadServicesFromServicesPath(WSDDDeployment deployment, ServiceLoader loader)
      throws IOException {
    for (String name : loader.listServiceNames()) {
      if (deployment.getWSDDService(new QName(name)) != null) continue;

      ServiceFactory factory = null;
      try {
        factory = loader.loadServiceFactory(Thread.currentThread().getContextClassLoader(), name);
      } catch (RuntimeException e) {
        if (e.getClass().getName().equals("BeanCreationException")) {
          logger.log(
              Level.WARNING,
              "ignore service \"" + name + "\" because interface class not determined.",
              e);
          continue;
        }
        throw e;
      }
      Set<Class<?>> interfaceClasses = factory.getInterfaces();
      if (interfaceClasses.isEmpty()) {
        logger.warning("ignore service \"" + name + "\" because interface class not determined.");
        continue;
      }

      WSDDService s = new WSDDService();
      s.setName(name);
      s.getServiceDesc().setName(name);
      s.setProviderQName(new QName("http://xml.apache.org/axis/wsdd/providers/java", "SGRPC"));
      s.setParameter("className", interfaceClasses.iterator().next().getName());
      s.setParameter(
          "x_sg_interfaces",
          StringUtil.join(
              interfaceClasses.toArray(new Class<?>[] {}), new ClassToClassNameTransformer(), ","));
      s.setParameter("x_sg_managed", "true");
      for (Class<?> c : interfaceClasses) {
        addBeanMapping(s, c.getName());
      }
      deployment.deployService(s);
    }
  }
コード例 #2
0
ファイル: SDK44EncodingUtils.java プロジェクト: NCIP/cagrid
  protected static Mapping getMapping(MessageContext context, String mappingProperty) {
    long startTime = System.currentTimeMillis();

    // determine the mapping location, starting with a default based on the property
    String mappingLocation =
        mappingProperty.equals(CASTOR_MARSHALLER_PROPERTY)
            ? DEFAULT_MARSHALLER_MAPPING
            : DEFAULT_UNMARSHALLER_MAPPING;
    if (context != null) {
      String prop = (String) context.getProperty(mappingProperty);
      if (prop != null && !prop.trim().equals("")) {
        // the property exists in the message context, use the property value
        mappingLocation = prop;
        LOG.debug("Loading castor mapping from message context property[" + mappingProperty + "]");
      } else {
        try {
          // attempt to find the property in the wsdd global configuration
          prop =
              (String) context.getAxisEngine().getConfig().getGlobalOptions().get(mappingProperty);
        } catch (Exception e) {
          LOG.warn("Error reading global configuration:" + e.getMessage(), e);
        }
        if (prop != null && !prop.trim().equals("")) {
          mappingLocation = prop;
          LOG.debug(
              "Loading castor mapping from globalConfiguration property[" + mappingProperty + "]");
        } else {
          // walk through the WSDD config and find the property in service config options
          EngineConfiguration config = context.getAxisEngine().getConfig();
          if (config instanceof WSDDEngineConfiguration) {
            WSDDDeployment wsdd = ((WSDDEngineConfiguration) config).getDeployment();
            WSDDService[] services = wsdd.getServices();
            for (WSDDService service : services) {
              prop = service.getParameter(mappingProperty);
              if (prop != null && !prop.trim().equals("")) {
                // found it!
                mappingLocation = prop;
                LOG.debug(
                    "Loading castor mapping from service "
                        + service.getQName()
                        + " property ["
                        + prop
                        + "]");
                break;
              }
            }
          }
          if (!(prop != null && !prop.trim().equals(""))) {
            LOG.warn(
                "Unable to locate castor mapping property["
                    + mappingProperty
                    + "], using default mapping location:"
                    + mappingLocation);
          }
        }
      }
    } else {
      LOG.debug(
          "Unable to determine message context, using default mapping location:" + mappingLocation);
    }

    // locate the bytes of the mapping file
    String mappingDocument = null;
    try {
      mappingDocument = loadResource(mappingLocation);
    } catch (IOException ex) {
      LOG.error("Error loading mapping file [" + mappingLocation + "] : " + ex.getMessage(), ex);
    }

    Mapping mapping = loadMappingFromString(mappingLocation, mappingDocument, getDtdResolver());

    long duration = System.currentTimeMillis() - startTime;
    LOG.debug("Time to load mapping file:" + duration + " ms.");

    return mapping;
  }