Search in sources :

Example 6 with DomainException

use of com.sun.enterprise.admin.servermgmt.DomainException in project Payara by payara.

the class DomainPortValidator method validateAndSetPorts.

/**
 * Validate's the port. If custom port value is not given then it retrieves
 * its default value. If the port is already been occupied then it picks
 * randomly available port value.
 *
 * @throws DomainException If any exception occurs in validation.
 */
public void validateAndSetPorts() throws DomainException {
    Properties domainProperties = _domainConfig.getDomainProperties();
    try {
        // Validate and gets the port values.
        final Integer adminPortInt = getPort(domainProperties, DomainConfig.K_ADMIN_PORT, (String) _domainConfig.get(DomainConfig.K_ADMIN_PORT), _defaultProps.getProperty(SubstitutableTokens.ADMIN_PORT_TOKEN_NAME), "Admin");
        _domainConfig.add(DomainConfig.K_ADMIN_PORT, adminPortInt);
        final Integer instancePortInt = getPort(domainProperties, DomainConfig.K_INSTANCE_PORT, (String) _domainConfig.get(DomainConfig.K_INSTANCE_PORT), _defaultProps.getProperty(SubstitutableTokens.HTTP_PORT_TOKEN_NAME), "HTTP Instance");
        _domainConfig.add(DomainConfig.K_INSTANCE_PORT, instancePortInt);
        final Integer jmsPort = getPort(domainProperties, DomainConfig.K_JMS_PORT, null, _defaultProps.getProperty(SubstitutableTokens.JMS_PROVIDER_PORT_TOKEN_NAME), "JMS");
        _domainConfig.add(DomainConfig.K_JMS_PORT, jmsPort);
        domainProperties.setProperty(PortConstants.JMS, jmsPort.toString());
        final Integer orbPort = getPort(domainProperties, DomainConfig.K_ORB_LISTENER_PORT, null, _defaultProps.getProperty(SubstitutableTokens.ORB_LISTENER_PORT_TOKEN_NAME), "IIOP");
        _domainConfig.add(DomainConfig.K_ORB_LISTENER_PORT, orbPort);
        final Integer httpSSLPort = getPort(domainProperties, DomainConfig.K_HTTP_SSL_PORT, null, _defaultProps.getProperty(SubstitutableTokens.HTTP_SSL_PORT_TOKEN_NAME), "HTTP_SSL");
        _domainConfig.add(DomainConfig.K_HTTP_SSL_PORT, httpSSLPort);
        final Integer iiopSSLPort = getPort(domainProperties, DomainConfig.K_IIOP_SSL_PORT, null, _defaultProps.getProperty(SubstitutableTokens.ORB_SSL_PORT_TOKEN_NAME), "IIOP_SSL");
        _domainConfig.add(DomainConfig.K_IIOP_SSL_PORT, iiopSSLPort);
        final Integer iiopMutualAuthPort = getPort(domainProperties, DomainConfig.K_IIOP_MUTUALAUTH_PORT, null, _defaultProps.getProperty(SubstitutableTokens.ORB_MUTUALAUTH_PORT_TOKEN_NAME), "IIOP_MUTUALAUTH");
        _domainConfig.add(DomainConfig.K_IIOP_MUTUALAUTH_PORT, iiopMutualAuthPort);
        final Integer jmxPort = getPort(domainProperties, DomainConfig.K_JMX_PORT, null, _defaultProps.getProperty(SubstitutableTokens.JMX_SYSTEM_CONNECTOR_PORT_TOKEN_NAME), "JMX_ADMIN");
        _domainConfig.add(DomainConfig.K_JMX_PORT, jmxPort);
        final Integer osgiShellTelnetPort = getPort(domainProperties, DomainConfig.K_OSGI_SHELL_TELNET_PORT, null, _defaultProps.getProperty(SubstitutableTokens.OSGI_SHELL_TELNET_PORT_TOKEN_NAME), "OSGI_SHELL");
        _domainConfig.add(DomainConfig.K_OSGI_SHELL_TELNET_PORT, osgiShellTelnetPort);
        final Integer javaDebuggerPort = getPort(domainProperties, DomainConfig.K_JAVA_DEBUGGER_PORT, null, _defaultProps.getProperty(SubstitutableTokens.JAVA_DEBUGGER_PORT_TOKEN_NAME), "JAVA_DEBUGGER");
        _domainConfig.add(DomainConfig.K_JAVA_DEBUGGER_PORT, javaDebuggerPort);
        checkPortPrivilege(new Integer[] { adminPortInt, instancePortInt, jmsPort, orbPort, httpSSLPort, jmsPort, orbPort, httpSSLPort, iiopSSLPort, iiopMutualAuthPort, jmxPort, osgiShellTelnetPort, javaDebuggerPort });
    } catch (Exception ex) {
        throw new DomainException(ex);
    }
}
Also used : DomainException(com.sun.enterprise.admin.servermgmt.DomainException) Properties(java.util.Properties) DomainException(com.sun.enterprise.admin.servermgmt.DomainException)

Aggregations

DomainException (com.sun.enterprise.admin.servermgmt.DomainException)6 RepositoryException (com.sun.enterprise.admin.servermgmt.RepositoryException)3 File (java.io.File)3 StringSubstitutor (com.sun.enterprise.admin.servermgmt.stringsubs.StringSubstitutor)2 InputStream (java.io.InputStream)2 Properties (java.util.Properties)2 JarEntry (java.util.jar.JarEntry)2 JarFile (java.util.jar.JarFile)2 RepositoryManager (com.sun.enterprise.admin.servermgmt.RepositoryManager)1 PEDomainConfigValidator (com.sun.enterprise.admin.servermgmt.pe.PEDomainConfigValidator)1 AttributePreprocessorImpl (com.sun.enterprise.admin.servermgmt.stringsubs.impl.AttributePreprocessorImpl)1 TemplateInfoHolder (com.sun.enterprise.admin.servermgmt.template.TemplateInfoHolder)1 Property (com.sun.enterprise.admin.servermgmt.xml.stringsubs.Property)1 ConfigCustomizationToken (com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken)1 CustomizationTokensProvider (com.sun.enterprise.config.modularity.customization.CustomizationTokensProvider)1 FileTypeDetails (com.sun.enterprise.config.modularity.customization.FileTypeDetails)1 PortTypeDetails (com.sun.enterprise.config.modularity.customization.PortTypeDetails)1 ASenvPropertyReader (com.sun.enterprise.universal.glassfish.ASenvPropertyReader)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1