All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aoindustries.aoserv.client.HttpdTomcatSharedSite Maven / Gradle / Ivy

There is a newer version: 1.92.0
Show newest version
/*
 * aoserv-client - Java client for the AOServ platform.
 * Copyright (C) 2001-2009, 2016  AO Industries, Inc.
 *     [email protected]
 *     7262 Bull Pen Cir
 *     Mobile, AL 36695
 *
 * This file is part of aoserv-client.
 *
 * aoserv-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-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-client.  If not, see .
 */
package com.aoindustries.aoserv.client;

import com.aoindustries.io.CompressedDataInputStream;
import com.aoindustries.io.CompressedDataOutputStream;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * An HttpdTomcatSharedSite is an HttpdTomcatSite
 * running under an HttpdSharedTomcat.
 *
 * @see  HttpdSharedTomcat
 * @see  HttpdTomcatSite
 *
 * @author  AO Industries, Inc.
 */
final public class HttpdTomcatSharedSite extends CachedObjectIntegerKey {

	static final int
		COLUMN_TOMCAT_SITE=0,
		COLUMN_HTTPD_SHARED_TOMCAT=1
	;
	static final String COLUMN_TOMCAT_SITE_name = "tomcat_site";

	int httpd_shared_tomcat;

	public static final String DEFAULT_TOMCAT_VERSION_PREFIX = HttpdTomcatVersion.VERSION_8_0_PREFIX;

	/**
	 * Determines if the API user is allowed to stop the Java virtual machine associated
	 * with this site.
	 */
	public boolean canStop() throws SQLException, IOException {
		HttpdSharedTomcat hst=getHttpdSharedTomcat();
		return getHttpdSharedTomcat()!=null && !hst.isDisabled();
	}

	/**
	 * Determines if the API user is allowed to start the Java virtual machine associated
	 * with this site.
	 */
	public boolean canStart() throws SQLException, IOException {
		HttpdSharedTomcat hst=getHttpdSharedTomcat();
		return getHttpdSharedTomcat()==null || !hst.isDisabled();
	}

	@Override
	Object getColumnImpl(int i) {
		switch(i) {
			case COLUMN_TOMCAT_SITE: return pkey;
			case COLUMN_HTTPD_SHARED_TOMCAT: return httpd_shared_tomcat;
			default: throw new IllegalArgumentException("Invalid index: "+i);
		}
	}

	public HttpdSharedTomcat getHttpdSharedTomcat() throws SQLException, IOException {
		// May be null when filtered
		return table.connector.getHttpdSharedTomcats().get(httpd_shared_tomcat);
	}

	public HttpdTomcatSite getHttpdTomcatSite() throws SQLException, IOException {
		HttpdTomcatSite obj=table.connector.getHttpdTomcatSites().get(pkey);
		if(obj==null) throw new SQLException("Unable to find HttpdTomcatSite: "+pkey);
		return obj;
	}

	@Override
	public SchemaTable.TableID getTableID() {
		return SchemaTable.TableID.HTTPD_TOMCAT_SHARED_SITES;
	}

	@Override
	public void init(ResultSet result) throws SQLException {
		pkey=result.getInt(1);
		httpd_shared_tomcat=result.getInt(2);
	}

	@Override
	public void read(CompressedDataInputStream in) throws IOException {
		pkey=in.readCompressedInt();
		httpd_shared_tomcat=in.readCompressedInt();
	}

	@Override
	String toStringImpl() throws SQLException, IOException {
		return getHttpdTomcatSite().toStringImpl();
	}

	@Override
	public void write(CompressedDataOutputStream out, AOServProtocol.Version version) throws IOException {
		out.writeCompressedInt(pkey);
		out.writeCompressedInt(httpd_shared_tomcat);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy