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

io.inugami.commons.connectors.ConnectorConstants Maven / Gradle / Ivy

There is a newer version: 3.3.5
Show newest version
/* --------------------------------------------------------------------
 *  Inugami
 * --------------------------------------------------------------------
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3.
 *
 * This program 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
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see .
 */
package io.inugami.commons.connectors;

import io.inugami.api.constants.JvmKeyValues;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ConnectorConstants {

    public static final String HTTP_GET  = "GET";
    public static final String HTTP_POST = "POST";
    public static final String PUT       = "PUT";
    public static final String PATCH     = "PATCH";
    public static final String DELETE    = "DELETE";
    public static final String OPTION    = "OPTION";

    /**
     * -Dhttp.connector.timeout=20000
     */
    public static final String TIME_OUT_CONFIG = "http.connector.timeout";

    /**
     * -Dhttp.connector.timeToLive=30000
     */
    public static final String TIME_TO_LIVE_CONFIG = "http.connector.timeToLive";

    /**
     * -Dhttp.connector.maxConnections=300
     */
    public static final String MAX_CONNEXIONS = "http.connector.maxConnections";

    /**
     * -Dhttp.connector.maxPerRoute=50
     */
    public static final String MAX_PER_ROUTE = "http.connector.maxPerRoute";

    /**
     * -Dapplication.name=inugami
     */
    public static final String APPLICATION_NAME = "application.name";

    /**
     * -Dapplication.name.header=APPLICATION-NAME
     */
    public static final String APPLICATION_NAME_HEADER = "application.name.header";

    /**
     * -Dapplication.hostname=
     */
    public static final String APPLICATION_HOSTNAME = "application.hostname";

    public static final String APPLICATION_HOSTNAME_HEADER_KEY = "application.hostname.header";

    /**
     * -Dhttp.connector.socket.timeout=60000
     */
    public static final String SOCKET_TIMEOUT = "http.connector.socket.timeout";

    public static final String APPLICATION_JSON = "application/json";

    public static final String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded";

    public static final String CONTENT_TYPE = "content-type";

    public static final String CURRENT_APPLICATION_NAME     = initValue(APPLICATION_NAME,
                                                                        JvmKeyValues.APPLICATION_NAME.or(
                                                                                JvmKeyValues.DEFAULT_APPLICATION_NAME));
    public static final String HEADER_APPLICATION_NAME      = initValue(APPLICATION_NAME_HEADER, "application-name");
    public static final String CURRENT_APPLICATION_HOSTNAME = initValue(APPLICATION_HOSTNAME, "");
    public static final String APPLICATION_HOSTNAME_HEADER  = initValue(APPLICATION_HOSTNAME_HEADER_KEY,
                                                                        "application-host");

    private static String initValue(final String key, final String defaultValue) {
        String       result = defaultValue;
        final String value  = System.getProperty(key);
        if (value != null) {
            result = value;
        }
        return result;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy