com.aoindustries.aoserv.daemon.client.AOServDaemonConnectionPool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aoserv-daemon-client Show documentation
Show all versions of aoserv-daemon-client Show documentation
Java client for the AOServ Daemon.
/*
* aoserv-daemon-client - Java client for the AOServ Daemon.
* Copyright (C) 2001-2009, 2016, 2017, 2020 AO Industries, Inc.
* [email protected]
* 7262 Bull Pen Cir
* Mobile, AL 36695
*
* This file is part of aoserv-daemon-client.
*
* aoserv-daemon-client is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* aoserv-daemon-client is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with aoserv-daemon-client. If not, see .
*/
package com.aoindustries.aoserv.daemon.client;
import com.aoindustries.io.AOPool;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.logging.Logger;
/**
* Connections made by TCPConnector
or any
* of its derivatives are pooled and reused.
*
* @author AO Industries, Inc.
*/
final class AOServDaemonConnectionPool extends AOPool {
private final AOServDaemonConnector connector;
AOServDaemonConnectionPool(AOServDaemonConnector connector, Logger logger) {
super(
AOServDaemonConnectionPool.class.getName()+"?hostname=" + connector.hostname+"&local_ip="+connector.local_ip+"&port="+connector.port+"&protocol="+connector.protocol,
connector.poolSize,
connector.maxConnectionAge,
logger
);
this.connector=connector;
}
@Override
protected void close(AOServDaemonConnection conn) {
conn.close();
}
@Override
protected AOServDaemonConnection getConnectionObject() throws InterruptedIOException, IOException {
return new AOServDaemonConnection(connector);
}
@Override
protected boolean isClosed(AOServDaemonConnection conn) {
return conn.isClosed();
}
@Override
@SuppressWarnings("deprecation")
protected void printConnectionStats(Appendable out, boolean isXhtml) throws IOException {
out.append(" \n"
+ " AOServ Daemon Connection Pool \n"
+ " \n");
super.printConnectionStats(out, isXhtml);
out.append(" Local IP: ");
com.aoindustries.util.EncodingUtils.encodeHtml(connector.local_ip.toString(), out, isXhtml);
out.append(" \n"
+ " Host: ");
com.aoindustries.util.EncodingUtils.encodeHtml(connector.hostname.toString(), out, isXhtml);
out.append(" \n"
+ " Port: ").append(Integer.toString(connector.port.getPort())).append(" \n"
+ " Protocol: ");
com.aoindustries.util.EncodingUtils.encodeHtml(connector.protocol, out, isXhtml);
out.append(" \n"
+ " Key: ");
String key=connector.key;
int len=key.length();
for(int c=0;c \n");
}
@Override
protected void resetConnection(AOServDaemonConnection conn) {
}
@Override
protected IOException newException(String message, Throwable cause) {
IOException err=new IOException(message);
if(cause!=null) err.initCause(cause);
return err;
}
@Override
protected InterruptedIOException newInterruptedException(String message, Throwable cause) {
InterruptedIOException err=new InterruptedIOException(message);
if(cause!=null) err.initCause(cause);
return err;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy