public TcpClient getTcpClient() throws Exception {
   TcpClient client = pool.borrowObject();
   if (!client.isConnected()) {
     client.connect();
   }
   return client;
 }
  @Override
  public GMLUnmarshaller acquireUnmarshaller() throws Exception {
    DefaultGMLUnmarshaller unmarshaller = gmlUnmarshallerPool.borrowObject();
    gmlUnmarshallerPool.returnObject(unmarshaller);

    return unmarshaller;
  }
 public Redisson getResource() {
   try {
     return internalPool.borrowObject();
   } catch (Exception e) {
     throw new RedisConnectionException("Could not get a resource from the pool", e);
   }
 }
Beispiel #4
0
 public Response call(Request request) throws Exception {
   if (request == null || request.getServiceName() == null) {
     throw new RuntimeException("request or request servciename cannot be null");
   }
   if (status != 1) {
     throw new RuntimeException("client is not init or aready destory");
   }
   Connection connection = null;
   try {
     connection = pool.borrowObject();
     return connection.call(request);
   } catch (SocketException e) {
     connection.close();
     throw e;
   } finally {
     if (connection != null) {
       pool.returnObject(connection);
     }
   }
 }