예제 #1
0
 private void initialize(ClientProxy clientProxy) throws Exception {
   ClientCreateRequest request =
       new ClientCreateRequest(clientProxy.getName(), clientProxy.getServiceName());
   final ClientContext context = new ClientContext(client, this);
   new ClientInvocation(client, request).invoke().get();
   clientProxy.setContext(context);
   clientProxy.onInitialize();
 }
예제 #2
0
 private void initialize(ClientProxy clientProxy) throws Exception {
   ClientMessage clientMessage =
       CreateProxyParameters.encode(clientProxy.getName(), clientProxy.getServiceName());
   final ClientContext context = new ClientContext(client, this);
   new ClientInvocation(client, clientMessage).invoke().get();
   clientProxy.setContext(context);
   clientProxy.onInitialize();
 }
예제 #3
0
 private void initialize(ClientProxy clientProxy) throws Exception {
   final Address initializationTarget = findNextAddressToSendCreateRequest();
   final Connection connection = getTargetOrOwnerConnection(initializationTarget);
   final ClientMessage clientMessage =
       ClientCreateProxyCodec.encodeRequest(
           clientProxy.getDistributedObjectName(),
           clientProxy.getServiceName(),
           initializationTarget);
   final ClientContext context = new ClientContext(client, this);
   new ClientInvocation(client, clientMessage, connection).invoke().get();
   clientProxy.setContext(context);
   clientProxy.onInitialize();
 }
예제 #4
0
  @SuppressWarnings("unchecked")
  public static <T> T proxy(
      final Class<T> ifaceClient,
      Class<?> ifaceRest,
      ResteasyWebTarget base,
      final ProxyConfig config) {
    if (ifaceRest == null) {
      @SuppressWarnings("rawtypes")
      Class clazz = ifaceClient;
      ifaceRest = clazz;
    }
    if (ifaceRest.isAnnotationPresent(Path.class)) {
      Path path = ifaceRest.getAnnotation(Path.class);
      if (!path.value().equals("") && !path.value().equals("/")) {
        base = (ResteasyWebTarget) base.path(path.value());
      }
    }
    HashMap<Long, MethodInvoker<?>> methodMap = new HashMap<Long, MethodInvoker<?>>();
    for (Method method : ifaceRest.getMethods()) {
      MethodInvoker<?> invoker;
      //         Set<String> httpMethods = IsHttpMethod.getHttpMethods(method);
      //         if ((httpMethods == null || httpMethods.size() == 0) &&
      // method.isAnnotationPresent(Path.class) && method.getReturnType().isInterface())
      //         {
      //            invoker = new SubResourceInvoker(base, method, config);
      //         }
      //         else
      //         {
      invoker = createClientInvoker(ifaceRest, method, base, config);
      //         }
      methodMap.put(MethodHashing.methodHash0(method), invoker);
    }

    Class<?>[] intfs = {ifaceClient};

    ClientProxy clientProxy = new ClientProxy(methodMap);
    // this is done so that equals and hashCode work ok. Adding the proxy to a
    // Collection will cause equals and hashCode to be invoked. The Spring
    // infrastructure had some problems without this.
    clientProxy.setClazz(ifaceClient);

    return (T) Proxy.newProxyInstance(config.getLoader(), intfs, clientProxy);
  }
  private void tryConnect() {
    final String endpointAddress = iUrl.toExternalForm();

    cLogger.info(
        "Creating Service using end point address: '"
            + endpointAddress
            + "', with NS: "
            + nsUri
            + "...");
    final QName serviceName = new QName(nsUri, "PesService");
    Service service = Service.create(serviceName);

    final QName portName = new QName(nsUri, "PesServicePort");
    service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
    cLogger.debug("Getting port handle from service...");
    iPesWsClient = service.getPort(portName, ifcClass);

    Client cl = ClientProxy.getClient(iPesWsClient);
    HTTPConduit http = (HTTPConduit) cl.getConduit();
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    httpClientPolicy.setConnectionTimeout(iConnectTimeout);
    cLogger.debug("Setting connect/receive timeout to {}/{} ms...", connectTimeOut, receiveTimeOut);
    http.setClient(httpClientPolicy);
  }
예제 #6
0
파일: Client.java 프로젝트: kcarta/sdj
  public static void main(String[] args) {

    ClientProxy client;
    client = new ClientProxy();
    client.startSending();
  }