예제 #1
0
  public BaseMethodBinding<?> getMethod(RequestDetails theRequest) {
    if (null == methods) {
      ourLog.warn("No methods exist for resource: {}", resourceName);
      return null;
    }

    ourLog.debug("Looking for a handler for {}", theRequest);
    for (BaseMethodBinding<?> rm : methods) {
      if (rm.incomingServerRequestMatchesMethod(theRequest)) {
        ourLog.debug("Handler {} matches", rm);
        return rm;
      } else {
        ourLog.trace("Handler {} does not match", rm);
      }
    }
    return null;
  }
  /**
   * Instantiates a new client instance
   *
   * @param theClientType The client type, which is an interface type to be instantiated
   * @param theServerBase The URL of the base for the restful FHIR server to connect to
   * @return A newly created client
   * @throws ConfigurationException If the interface type is not an interface
   */
  @Override
  public synchronized <T extends IRestfulClient> T newClient(
      Class<T> theClientType, String theServerBase) {
    if (!theClientType.isInterface()) {
      throw new ConfigurationException(theClientType.getCanonicalName() + " is not an interface");
    }

    ClientInvocationHandlerFactory invocationHandler = myInvocationHandlers.get(theClientType);
    if (invocationHandler == null) {
      HttpClient httpClient = getHttpClient();
      invocationHandler =
          new ClientInvocationHandlerFactory(httpClient, myContext, theServerBase, theClientType);
      for (Method nextMethod : theClientType.getMethods()) {
        BaseMethodBinding<?> binding = BaseMethodBinding.bindMethod(nextMethod, myContext, null);
        invocationHandler.addBinding(nextMethod, binding);
      }
      myInvocationHandlers.put(theClientType, invocationHandler);
    }

    T proxy = instantiateProxy(theClientType, invocationHandler.newInvocationHandler(this));

    return proxy;
  }