コード例 #1
0
  public void connect(TokenHolder tokenHolder) {
    for (Class<? extends PublicInterface> interface1 : interfaces) {
      JaxWsProxyFactoryBean cpfb = new JaxWsProxyFactoryBean();
      cpfb.setServiceClass(interface1);
      cpfb.setAddress(address + "/" + interface1.getSimpleName());
      Map<String, Object> properties = new HashMap<String, Object>();
      properties.put("mtom-enabled", Boolean.TRUE);
      cpfb.setProperties(properties);

      PublicInterface serviceInterface = (PublicInterface) cpfb.create();

      client = ClientProxy.getClient(serviceInterface);
      HTTPConduit http = (HTTPConduit) client.getConduit();
      http.getClient().setConnectionTimeout(360000);
      http.getClient().setAllowChunking(false);
      http.getClient().setReceiveTimeout(320000);

      if (!useSoapHeaderSessions) {
        ((BindingProvider) serviceInterface)
            .getRequestContext()
            .put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
      }
      add(interface1.getName(), serviceInterface);
    }
    tokenHolder.registerTokenChangeListener(this);
    notifyOfConnect();
  }
コード例 #2
0
ファイル: StudyDAOImpl.java プロジェクト: jdr0887/MaPSeq-API
 @PostConstruct
 public void init() {
   studyService = getService().getPort(StudyService.class);
   Client cl = ClientProxy.getClient(studyService);
   HTTPConduit httpConduit = (HTTPConduit) cl.getConduit();
   httpConduit.getClient().setReceiveTimeout(getConfigurationService().getWebServiceTimeout());
   httpConduit.getClient().setConnectionTimeout(0);
   httpConduit.getClient().setConnection(ConnectionType.CLOSE);
 }
コード例 #3
0
  private void setupGreeter(String cfgResource, boolean useDecoupledEndpoint)
      throws NumberFormatException, MalformedURLException {

    SpringBusFactory bf = new SpringBusFactory();

    controlBus = bf.createBus();
    BusFactory.setDefaultBus(controlBus);

    ControlService cs = new ControlService();
    control = cs.getControlPort();
    updateAddressPort(control, PORT);

    assertTrue("Failed to start greeter", control.startGreeter(cfgResource));

    greeterBus = bf.createBus(cfgResource);
    BusFactory.setDefaultBus(greeterBus);
    LOG.fine("Initialised greeter bus with configuration: " + cfgResource);

    if (null == comparator) {
      comparator = new PhaseComparator();
    }
    if (null == inPhases) {
      inPhases = new ArrayList<Phase>();
      inPhases.addAll(greeterBus.getExtension(PhaseManager.class).getInPhases());
      Collections.sort(inPhases, comparator);
    }
    if (null == preLogicalPhase) {
      preLogicalPhase = getPhase(Phase.PRE_LOGICAL);
    }

    GreeterService gs = new GreeterService();

    greeter = gs.getGreeterPort();
    updateAddressPort(greeter, PORT);
    LOG.fine("Created greeter client.");

    if (!useDecoupledEndpoint) {
      return;
    }

    // programatically configure decoupled endpoint that is guaranteed to
    // be unique across all test cases
    decoupledEndpointPort++;
    decoupledEndpoint =
        "http://localhost:"
            + allocatePort("decoupled-" + decoupledEndpointPort)
            + "/decoupled_endpoint";

    Client c = ClientProxy.getClient(greeter);
    HTTPConduit hc = (HTTPConduit) (c.getConduit());
    HTTPClientPolicy cp = hc.getClient();
    cp.setDecoupledEndpoint(decoupledEndpoint);

    LOG.fine("Using decoupled endpoint: " + cp.getDecoupledEndpoint());
  }
コード例 #4
0
  /**
   * Build a client proxy, for a specific proxy type.
   *
   * @param proxyType proxy type class
   * @return client proxy stub
   */
  protected <T> T build(Class<T> proxyType) {
    String address = generateAddress();
    T rootResource;
    // Synchronized on the class to correlate with the scope of clientStaticResources
    // We want to ensure that the shared bean isn't set concurrently in multiple callers
    synchronized (ClouderaManagerClientBuilder.class) {
      JAXRSClientFactoryBean bean = cleanFactory(clientStaticResources.getUnchecked(proxyType));
      bean.setAddress(address);
      if (username != null) {
        bean.setUsername(username);
        bean.setPassword(password);
      }

      if (enableLogging) {
        bean.setFeatures(Arrays.<AbstractFeature>asList(new LoggingFeature()));
      }
      rootResource = bean.create(proxyType);
    }

    boolean isTlsEnabled = address.startsWith("https://");
    ClientConfiguration config = WebClient.getConfig(rootResource);
    HTTPConduit conduit = (HTTPConduit) config.getConduit();
    if (isTlsEnabled) {
      TLSClientParameters tlsParams = new TLSClientParameters();
      if (!validateCerts) {
        tlsParams.setTrustManagers(new TrustManager[] {new AcceptAllTrustManager()});
      } else if (trustManagers != null) {
        tlsParams.setTrustManagers(trustManagers);
      }
      tlsParams.setDisableCNCheck(!validateCn);
      conduit.setTlsClientParameters(tlsParams);
    }

    HTTPClientPolicy policy = conduit.getClient();
    policy.setConnectionTimeout(connectionTimeoutUnits.toMillis(connectionTimeout));
    policy.setReceiveTimeout(receiveTimeoutUnits.toMillis(receiveTimeout));
    return rootResource;
  }