Package org.mom4j.messaging

Source Code of org.mom4j.messaging.Launcher

package org.mom4j.messaging;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Properties;

import org.mom4j.api.Mom4jConfig;
import org.mom4j.api.Mom4jConsole;
import org.mom4j.config.ConfigImpl;

import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;


public final class Launcher
{

    /** logger */
    private static Log log = LogFactory.getLog(Launcher.class);


    public static Mom4jConsole start(Mom4jConfig config, boolean verbose)
    {
        // TODO: Remove verbose flag!
        if (config == null) {
            throw new IllegalArgumentException("config is null!");
        }
        if(log.isDebugEnabled()) {
            Properties sysprops = System.getProperties();
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            sysprops.list(pw);
            pw.flush();
            log.debug(sw.getBuffer().toString());
        }
        MessagingServer server = new MessagingServer(config);
        if (verbose)
            log.info("Launching messaging server ...");
        Mom4jConsole console = server.start(verbose);
        if (verbose)
            log.info("Launching messaging server ... done.");
        return console;
    }


    public static void main(String[] args)
    {
        if (args.length != 1) {
            log.error("USAGE: Launcher <config-file>");
            return;
        }
        ConfigImpl cfg = null;
        try {
            cfg = new ConfigImpl(args[0]);
        }
        catch (Exception ex) {
            log.error("Failed to create config", ex);
            return;
        }
        Launcher.start(cfg, true);
    }

}
TOP

Related Classes of org.mom4j.messaging.Launcher

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.