Search in sources :

Example 1 with MiniXmlParser

use of com.sun.enterprise.universal.xml.MiniXmlParser in project Payara by payara.

the class GFEmbeddedLauncher method setup.

@Override
public void setup() throws GFLauncherException, MiniXmlParserException {
    if (setup)
        return;
    else
        setup = true;
    try {
        setupFromEnv();
    } catch (GFLauncherException gfle) {
        String msg = "";
        throw new GFLauncherException(GENERAL_MESSAGE + gfle.getMessage());
    }
    setCommandLine();
    /* it is NOT an error for there to be no domain.xml (yet).
         * so eat exceptions.  Also just set the default to 4848 if we don't find
         * the port...
         */
    GFLauncherInfo info = getInfo();
    try {
        File parent = info.getDomainParentDir();
        String domainName = info.getDomainName();
        String instanceName = info.getInstanceName();
        if (instanceName == null)
            instanceName = "server";
        File dom = new File(parent, domainName);
        File theConfigDir = new File(dom, "config");
        File dx = new File(theConfigDir, "domain.xml");
        info.setConfigDir(theConfigDir);
        info.setDomainRootDir(new File(System.getenv(INSTALL_HOME)));
        MiniXmlParser parser = new MiniXmlParser(dx, instanceName);
        info.setAdminAddresses(parser.getAdminAddresses());
        File logFile = new File(dom, "logs");
        logFile = new File(logFile, "server.log");
        logFilename = logFile.getAbsolutePath();
    } catch (Exception e) {
        // temp todo
        e.printStackTrace();
    }
    List<HostAndPort> adminAddresses = info.getAdminAddresses();
    if (adminAddresses == null || adminAddresses.isEmpty()) {
        adminAddresses = new ArrayList<HostAndPort>();
        adminAddresses.add(new HostAndPort("localhost", 4848, false));
        info.setAdminAddresses(adminAddresses);
    }
    GFLauncherLogger.addLogFileHandler(getLogFilename(), info);
// super.fixLogFilename();
/*
    String domainName = parser.getDomainName();
    if(GFLauncherUtils.ok(domainName)) {
    info.setDomainName(domainName);
    }
     */
}
Also used : HostAndPort(com.sun.enterprise.util.HostAndPort) SmartFile(com.sun.enterprise.universal.io.SmartFile) File(java.io.File) MiniXmlParser(com.sun.enterprise.universal.xml.MiniXmlParser) MiniXmlParserException(com.sun.enterprise.universal.xml.MiniXmlParserException)

Example 2 with MiniXmlParser

use of com.sun.enterprise.universal.xml.MiniXmlParser in project Payara by payara.

the class ChangeNodeMasterPasswordCommand method isRunning.

private boolean isRunning(File nodeDirChild, String serverName) throws CommandException {
    try {
        File serverDir = new File(nodeDirChild, serverName);
        File configDir = new File(serverDir, "config");
        File domainXml = new File(configDir, "domain.xml");
        if (!domainXml.exists())
            return false;
        MiniXmlParser parser = new MiniXmlParser(domainXml, serverName);
        List<HostAndPort> addrSet = parser.getAdminAddresses();
        if (addrSet.size() <= 0)
            throw new CommandException(strings.get("NoAdminPort"));
        HostAndPort addr = addrSet.get(0);
        return isRunning(addr.getHost(), addr.getPort());
    } catch (MiniXmlParserException ex) {
        throw new CommandException(strings.get("NoAdminPortEx", ex), ex);
    }
}
Also used : HostAndPort(com.sun.enterprise.util.HostAndPort) MiniXmlParserException(com.sun.enterprise.universal.xml.MiniXmlParserException) CommandException(org.glassfish.api.admin.CommandException) File(java.io.File) MiniXmlParser(com.sun.enterprise.universal.xml.MiniXmlParser)

Example 3 with MiniXmlParser

use of com.sun.enterprise.universal.xml.MiniXmlParser in project Payara by payara.

the class LocalServerCommand method getAdminAddress.

/**
 * Returns the admin address of a particular server. Note that this method
 * should be called only when you own the server that is available on
 * an accessible file system.
 *
 * @return HostAndPort object with admin server address
 * @throws CommandException in case of parsing errors
 */
protected final HostAndPort getAdminAddress(String serverName) throws CommandException {
    try {
        MiniXmlParser parser = new MiniXmlParser(getDomainXml(), serverName);
        List<HostAndPort> addrSet = parser.getAdminAddresses();
        if (addrSet.size() > 0)
            return addrSet.get(0);
        else
            throw new CommandException(strings.get("NoAdminPort"));
    } catch (MiniXmlParserException ex) {
        throw new CommandException(strings.get("NoAdminPortEx", ex), ex);
    }
}
Also used : HostAndPort(com.sun.enterprise.util.HostAndPort) MiniXmlParserException(com.sun.enterprise.universal.xml.MiniXmlParserException) CommandException(org.glassfish.api.admin.CommandException) MiniXmlParser(com.sun.enterprise.universal.xml.MiniXmlParser)

Example 4 with MiniXmlParser

use of com.sun.enterprise.universal.xml.MiniXmlParser in project Payara by payara.

the class GFLauncher method setup.

public void setup() throws GFLauncherException, MiniXmlParserException {
    ASenvPropertyReader pr;
    if (isFakeLaunch()) {
        pr = new ASenvPropertyReader(info.getInstallDir());
    } else {
        pr = new ASenvPropertyReader();
    }
    asenvProps = pr.getProps();
    info.setup();
    setupLogLevels();
    MiniXmlParser parser = new MiniXmlParser(getInfo().getConfigFile(), getInfo().getInstanceName());
    String domainName = parser.getDomainName();
    if (GFLauncherUtils.ok(domainName)) {
        info.setDomainName(domainName);
    }
    info.setAdminAddresses(parser.getAdminAddresses());
    javaConfig = new JavaConfig(parser.getJavaConfig());
    setupProfilerAndJvmOptions(parser);
    setupUpgradeSecurity();
    Map<String, String> realmprops = parser.getAdminRealmProperties();
    if (realmprops != null) {
        String classname = realmprops.get("classname");
        String keyfile = realmprops.get("file");
        if ("com.sun.enterprise.security.auth.realm.file.FileRealm".equals(classname) && keyfile != null) {
            adminFileRealmKeyFile = keyfile;
        }
    }
    secureAdminEnabled = parser.getSecureAdminEnabled();
    renameOsgiCache();
    setupMonitoring(parser);
    sysPropsFromXml = parser.getSystemProperties();
    asenvProps.put(INSTANCE_ROOT_PROPERTY, getInfo().getInstanceRootDir().getPath());
    // Set the config java-home value as the Java home for the environment,
    // unless it is empty or it is already refering to a substitution of
    // the environment variable.
    String jhome = javaConfig.getJavaHome();
    if (GFLauncherUtils.ok(jhome) && !jhome.trim().equals("${" + JAVA_ROOT_PROPERTY + "}")) {
        asenvProps.put(JAVA_ROOT_PROPERTY, jhome);
    }
    debugOptions = getDebug();
    parseDebug();
    parser.setupConfigDir(getInfo().getConfigDir(), getInfo().getInstallDir());
    setLogFilename(parser);
    resolveAllTokens();
    fixLogFilename();
    GFLauncherLogger.addLogFileHandler(logFilename, info);
    setJavaExecutable();
    setClasspath();
    setCommandLine();
    setJvmOptions();
    logCommandLine();
    // if no <network-config> element, we need to upgrade this domain
    needsAutoUpgrade = !parser.hasNetworkConfig();
    needsManualUpgrade = !parser.hasDefaultConfig();
    setupCalledByClients = true;
}
Also used : ASenvPropertyReader(com.sun.enterprise.universal.glassfish.ASenvPropertyReader) MiniXmlParser(com.sun.enterprise.universal.xml.MiniXmlParser)

Aggregations

MiniXmlParser (com.sun.enterprise.universal.xml.MiniXmlParser)4 MiniXmlParserException (com.sun.enterprise.universal.xml.MiniXmlParserException)3 HostAndPort (com.sun.enterprise.util.HostAndPort)3 File (java.io.File)2 CommandException (org.glassfish.api.admin.CommandException)2 ASenvPropertyReader (com.sun.enterprise.universal.glassfish.ASenvPropertyReader)1 SmartFile (com.sun.enterprise.universal.io.SmartFile)1