Package org.apache.cocoon.bean

Examples of org.apache.cocoon.bean.CocoonBean


        for (Iterator i = line.getArgList().iterator(); i.hasNext();) {
            targets.add(NetUtils.normalize((String) i.next()));
        }

        CocoonBean cocoon = new CocoonBean(workDir, contextDir, configFile);
        cocoon.setLogKit(logKit);
        cocoon.setLogger(logger);
        cocoon.setLogLevel(logLevel);
       
        if (loadedClasses.size()!=0) {
            cocoon.setLoadedClasses(loadedClasses);
        }

        if (agentOptions != null) {
            cocoon.setAgentOptions(agentOptions);
        }
        if (acceptOptions != null) {
            cocoon.setAcceptOptions(acceptOptions);
        }
        if (defaultFilename != null) {
            cocoon.setDefaultFilename(defaultFilename);
        }       
        cocoon.setBrokenLinkFile(brokenLinkFile);
        cocoon.setPrecompileOnly(precompileOnly);
        cocoon.setFollowLinks(followLinks);
        cocoon.setConfirmExtensions(confirmExtensions);
        cocoon.setVerbose(verbose);

        if (destDir.equals("")) {
            String error = "Careful, you must specify a destination dir when using the -d/--destDir argument";
            cocoon.getLogger().fatalError(error);
            System.out.println(error);
            System.exit(1);
        }

        if (cocoon.getContextDir().equals("")) {
            String error = "Careful, you must specify a configuration file when using the -c/--contextDir argument";
            cocoon.getLogger().fatalError(error);
            System.out.println(error);
            System.exit(1);
        }

        if (cocoon.getWorkDir().equals("")) {
            String error = "Careful, you must specify a destination dir when using the -w/--workDir argument";
            cocoon.getLogger().fatalError(error);
            System.out.println(error);
            System.exit(1);
        }

        if (targets.size() == 0 && !cocoon.isPrecompileOnly()) {
            String error = "Please, specify at least one starting URI.";
            cocoon.getLogger().fatalError(error);
            System.out.println(error);
            System.exit(1);
        }

        System.out.println(getProlog());
       
        cocoon.initialize();
        cocoon.warmup();
        cocoon.process(targets, new FileDestination(destDir));
        cocoon.dispose();

        long duration = System.currentTimeMillis() - startTimeMillis;
        System.out.println("Total time: " + (duration / 60000) + " minutes " + (duration % 60000)/1000 + " seconds");
        System.exit(0);
    }
View Full Code Here


* @version CVS $Id: AntDelegate.java,v 1.3 2004/04/30 12:55:55 upayavira Exp $
*/
public class AntDelegate {

    public static int process(Document xconf, String uriGroup) throws Exception {
        CocoonBean cocoon = new CocoonBean();
        OutputStreamListener listener = new OutputStreamListener(System.out);
        cocoon.addListener(listener);
        BeanConfigurator.configure(xconf, cocoon, "", uriGroup, listener);

        System.out.println(CocoonBean.getProlog());

        if (cocoon.getTargetCount() ==0 && cocoon.isPrecompileOnly()) {
            listener.messageGenerated("Please, specify at least one starting URI.");
            System.exit(1);
        }

        cocoon.initialize();
        cocoon.process();
        cocoon.dispose();

        listener.complete();
        return listener.isSuccessful() ? 0 : 1;
    }
View Full Code Here

    public static void main(String[] args) throws Exception {

        Main.setOptions();
        CommandLine line = new PosixParser().parse( options, args );
        listener = new OutputStreamListener(System.out);
        CocoonBean cocoon = new CocoonBean();
        cocoon.addListener(listener);

        if (line.hasOption(HELP_OPT)) {
             printUsage();
        } else if (line.hasOption(VERSION_OPT)) {
             printVersion();
        }

        String uriGroup = null;
        if (line.hasOption(URI_GROUP_NAME_OPT)) {
            uriGroup = line.getOptionValue(URI_GROUP_NAME_OPT);
        }
           
        String destDir = null;
        if (line.hasOption(XCONF_OPT)) {
            // destDir from command line overrides one in xconf file
            destDir = Main.processXConf(cocoon, line.getOptionValue(XCONF_OPT), destDir, uriGroup);
        }
        if (line.hasOption(DEST_DIR_OPT)) {
            destDir = line.getOptionValue(DEST_DIR_OPT);
        }

        if (line.hasOption(VERBOSE_OPT)) {
            cocoon.setVerbose(true);
        }
        if (line.hasOption(PRECOMPILE_ONLY_OPT)) {
            cocoon.setPrecompileOnly(true);
        }

        if (line.hasOption(WORK_DIR_OPT)) {
            String workDir = line.getOptionValue(WORK_DIR_OPT);
            if (workDir.equals("")) {
                listener.messageGenerated(
                    "Careful, you must specify a work dir when using the -w/--workDir argument");
                System.exit(1);
            } else {
                cocoon.setWorkDir(line.getOptionValue(WORK_DIR_OPT));
            }
        }
        if (line.hasOption(CONTEXT_DIR_OPT)) {
            String contextDir = line.getOptionValue(CONTEXT_DIR_OPT);
            if (contextDir.equals("")) {
                listener.messageGenerated(
                    "Careful, you must specify a configuration file when using the -c/--contextDir argument");
                System.exit(1);
            } else
                cocoon.setContextDir(contextDir);
            }
        }
        if (line.hasOption(CONFIG_FILE_OPT)) {
            cocoon.setConfigFile(line.getOptionValue(CONFIG_FILE_OPT));
        }
        if (line.hasOption(LOG_KIT_OPT)) {
            cocoon.setLogKit(line.getOptionValue(LOG_KIT_OPT));
        }
        if (line.hasOption(LOGGER_OPT)) {
            cocoon.setLogger(line.getOptionValue(LOGGER_OPT));
        }
        if (line.hasOption(LOG_LEVEL_OPT)) {
            cocoon.setLogLevel(line.getOptionValue(LOG_LEVEL_OPT));
        }
        if (line.hasOption(AGENT_OPT)) {
            cocoon.setAgentOptions(line.getOptionValue(AGENT_OPT));
        }
        if (line.hasOption(ACCEPT_OPT)) {
            cocoon.setAcceptOptions(line.getOptionValue(ACCEPT_OPT));
        }
        if (line.hasOption(DEFAULT_FILENAME_OPT)) {
            cocoon.setDefaultFilename(line.getOptionValue(DEFAULT_FILENAME_OPT));
        }
        if (line.hasOption(BROKEN_LINK_FILE_OPT)) {
            listener.setReportFile(line.getOptionValue(BROKEN_LINK_FILE_OPT));
        }
        if (line.hasOption(FOLLOW_LINKS_OPT)) {
            cocoon.setFollowLinks(BooleanUtils.toBoolean(line.getOptionValue(FOLLOW_LINKS_OPT)));
        }
        if (line.hasOption(CONFIRM_EXTENSIONS_OPT)) {
            cocoon.setConfirmExtensions(BooleanUtils.toBoolean(line.getOptionValue(CONFIRM_EXTENSIONS_OPT, "yes")));
        }
        if (line.hasOption(LOAD_CLASS_OPT)){
            cocoon.addLoadedClasses(Arrays.asList(line.getOptionValues(LOAD_CLASS_OPT)));
        }
        if (line.hasOption(URI_FILE_OPT)) {
            cocoon.addTargets(BeanConfigurator.processURIFile(line.getOptionValue(URI_FILE_OPT)), destDir);
        }

        cocoon.addTargets(line.getArgList(), destDir);

        listener.messageGenerated(CocoonBean.getProlog());

        if (cocoon.getTargetCount() ==0 && cocoon.isPrecompileOnly()) {
            listener.messageGenerated("Please, specify at least one starting URI.");
            System.exit(1);
        }

        cocoon.initialize();
        cocoon.process();
        cocoon.dispose();

        listener.complete();


        int exitCode = (listener.isSuccessful() ? 0 : 1);
View Full Code Here

    public static void main(String[] args) throws Exception {

        Main.setOptions();
        CommandLine line = new PosixParser().parse( options, args );
        listener = new OutputStreamListener(System.out);
        CocoonBean cocoon = new CocoonBean();
        cocoon.addListener(listener);

        if (line.hasOption(HELP_OPT)) {
             printUsage();
        } else if (line.hasOption(VERSION_OPT)) {
             printVersion();
        }

        String uriGroup = null;
        if (line.hasOption(URI_GROUP_NAME_OPT)) {
            uriGroup = line.getOptionValue(URI_GROUP_NAME_OPT);
        }
           
        String destDir = null;
        if (line.hasOption(XCONF_OPT)) {
            // destDir from command line overrides one in xconf file
            destDir = Main.processXConf(cocoon, line.getOptionValue(XCONF_OPT), destDir, uriGroup);
        }
        if (line.hasOption(DEST_DIR_OPT)) {
            destDir = line.getOptionValue(DEST_DIR_OPT);
        }

        if (line.hasOption(VERBOSE_OPT)) {
            cocoon.setVerbose(true);
        }
        if (line.hasOption(PRECOMPILE_ONLY_OPT)) {
            cocoon.setPrecompileOnly(true);
        }

        if (line.hasOption(WORK_DIR_OPT)) {
            String workDir = line.getOptionValue(WORK_DIR_OPT);
            if (workDir.equals("")) {
                listener.messageGenerated(
                    "Careful, you must specify a work dir when using the -w/--workDir argument");
                System.exit(1);
            } else {
                cocoon.setWorkDir(line.getOptionValue(WORK_DIR_OPT));
            }
        }
        if (line.hasOption(CONTEXT_DIR_OPT)) {
            String contextDir = line.getOptionValue(CONTEXT_DIR_OPT);
            if (contextDir.equals("")) {
                listener.messageGenerated(
                    "Careful, you must specify a configuration file when using the -c/--contextDir argument");
                System.exit(1);
            } else
                cocoon.setContextDir(contextDir);
            }
        }
        if (line.hasOption(CONFIG_FILE_OPT)) {
            cocoon.setConfigFile(line.getOptionValue(CONFIG_FILE_OPT));
        }
        if (line.hasOption(LOG_KIT_OPT)) {
            cocoon.setLogKit(line.getOptionValue(LOG_KIT_OPT));
        }
        if (line.hasOption(LOGGER_OPT)) {
            cocoon.setLogger(line.getOptionValue(LOGGER_OPT));
        }
        if (line.hasOption(LOG_LEVEL_OPT)) {
            cocoon.setLogLevel(line.getOptionValue(LOG_LEVEL_OPT));
        }
        if (line.hasOption(AGENT_OPT)) {
            cocoon.setAgentOptions(line.getOptionValue(AGENT_OPT));
        }
        if (line.hasOption(ACCEPT_OPT)) {
            cocoon.setAcceptOptions(line.getOptionValue(ACCEPT_OPT));
        }
        if (line.hasOption(DEFAULT_FILENAME_OPT)) {
            cocoon.setDefaultFilename(line.getOptionValue(DEFAULT_FILENAME_OPT));
        }
        if (line.hasOption(BROKEN_LINK_FILE_OPT)) {
            listener.setReportFile(line.getOptionValue(BROKEN_LINK_FILE_OPT));
        }
        if (line.hasOption(FOLLOW_LINKS_OPT)) {
            cocoon.setFollowLinks(yesno(line.getOptionValue(FOLLOW_LINKS_OPT)));
        }
        if (line.hasOption(CONFIRM_EXTENSIONS_OPT)) {
            cocoon.setConfirmExtensions(yesno(line.getOptionValue(CONFIRM_EXTENSIONS_OPT, "yes")));
        }
        if (line.hasOption(LOAD_CLASS_OPT)){
            cocoon.addLoadedClasses(Arrays.asList(line.getOptionValues(LOAD_CLASS_OPT)));
        }
        if (line.hasOption(URI_FILE_OPT)) {
            cocoon.addTargets(BeanConfigurator.processURIFile(line.getOptionValue(URI_FILE_OPT)), destDir);
        }

        cocoon.addTargets(line.getArgList(), destDir);

        listener.messageGenerated(CocoonBean.getProlog());

        cocoon.initialize();
        cocoon.process();
        cocoon.dispose();

        listener.complete();


        int exitCode = (listener.isSuccessful() ? 0 : 1);
View Full Code Here

* @version CVS $Id: AntDelegate.java,v 1.1 2003/10/13 12:08:10 upayavira Exp $
*/
public class AntDelegate {

    public static int process(Document xconf, String uriGroup) throws Exception {
        CocoonBean cocoon = new CocoonBean();
        OutputStreamListener listener = new OutputStreamListener(System.out);
        cocoon.addListener(listener);
        BeanConfigurator.configure(xconf, cocoon, "", uriGroup, listener);

        System.out.println(CocoonBean.getProlog());

        cocoon.initialize();
        cocoon.process();
        cocoon.dispose();

        listener.complete();
        return listener.isSuccessful() ? 0 : 1;
    }
View Full Code Here

        long startTimeMillis = System.currentTimeMillis();

        Main.setOptions();
        CommandLine line = new PosixParser().parse( options, args );
        CLIListener listener = new Main.CLIListener();
        CocoonBean cocoon = new CocoonBean();
        cocoon.addListener(listener);

        if (line.hasOption(HELP_OPT)) {
             printUsage();
        } else if (line.hasOption(VERSION_OPT)) {
             printVersion();
        }

        String destDir = null;
        if (line.hasOption(DEST_DIR_OPT)) {
            destDir = line.getOptionValue(DEST_DIR_OPT);
        }

        if (line.hasOption(XCONF_OPT)) {
            // destDir from command line overrides one in xconf file
            destDir = Main.processXConf(cocoon, line.getOptionValue(XCONF_OPT), destDir);
        }
        if (line.hasOption(VERBOSE_OPT)) {
            cocoon.setVerbose(true);
        }
        if (line.hasOption(PRECOMPILE_ONLY_OPT)) {
            cocoon.setPrecompileOnly(true);
        }

        if (line.hasOption(WORK_DIR_OPT)) {
            cocoon.setWorkDir(line.getOptionValue(WORK_DIR_OPT));
        }
        if (line.hasOption(CONTEXT_DIR_OPT)) {
            cocoon.setContextDir(line.getOptionValue(CONTEXT_DIR_OPT));
        }
        if (line.hasOption(CONFIG_FILE_OPT)) {
            cocoon.setConfigFile(line.getOptionValue(CONFIG_FILE_OPT));
        }
        if (line.hasOption(LOG_KIT_OPT)) {
            cocoon.setLogKit(line.getOptionValue(LOG_KIT_OPT));
        }
        if (line.hasOption(LOGGER_OPT)) {
            cocoon.setLogger(line.getOptionValue(LOGGER_OPT));
        }
        if (line.hasOption(LOG_LEVEL_OPT)) {
            cocoon.setLogLevel(line.getOptionValue(LOG_LEVEL_OPT));
        }
        if (line.hasOption(AGENT_OPT)) {
            cocoon.setAgentOptions(line.getOptionValue(AGENT_OPT));
        }
        if (line.hasOption(ACCEPT_OPT)) {
            cocoon.setAcceptOptions(line.getOptionValue(ACCEPT_OPT));
        }
        if (line.hasOption(DEFAULT_FILENAME_OPT)) {
            cocoon.setDefaultFilename(line.getOptionValue(DEFAULT_FILENAME_OPT));
        }
        if (line.hasOption(BROKEN_LINK_FILE_OPT)) {
            brokenLinkReportFile = line.getOptionValue(BROKEN_LINK_FILE_OPT);
        }
        if (line.hasOption(URI_FILE_OPT)) {
            cocoon.addTargets(processURIFile(line.getOptionValue(URI_FILE_OPT)), destDir);
        }
        if (line.hasOption(FOLLOW_LINKS_OPT)) {
            cocoon.setFollowLinks(yesno(line.getOptionValue(FOLLOW_LINKS_OPT)));
        }
        if (line.hasOption(CONFIRM_EXTENSIONS_OPT)) {
            cocoon.setConfirmExtensions(yesno(line.getOptionValue(CONFIRM_EXTENSIONS_OPT, "yes")));
        }
        if (line.hasOption(LOAD_CLASS_OPT)){
            cocoon.addLoadedClasses(Arrays.asList(line.getOptionValues(LOAD_CLASS_OPT)));
        }

        cocoon.addTargets(line.getArgList(), destDir);

        System.out.println(getProlog());

        cocoon.initialize();
        cocoon.process();
        cocoon.dispose();

        listener.outputBrokenLinks();

        long duration = System.currentTimeMillis() - startTimeMillis;
        System.out.println("Total time: " + (duration / 60000) + " minutes " + (duration % 60000)/1000 + " seconds");
View Full Code Here

        long startTimeMillis = System.currentTimeMillis();

        Main.setOptions();
        CommandLine line = new PosixParser().parse( options, args );
        CLIListener listener = new Main.CLIListener();
        CocoonBean cocoon = new CocoonBean();
        cocoon.addListener(listener);

        if (line.hasOption(HELP_OPT)) {
             printUsage();
        } else if (line.hasOption(VERSION_OPT)) {
             printVersion();
        }

        String destDir = null;
        if (line.hasOption(DEST_DIR_OPT)) {
            destDir = line.getOptionValue(DEST_DIR_OPT);
        }

        if (line.hasOption(XCONF_OPT)) {
            // destDir from command line overrides one in xconf file
            destDir = Main.processXConf(cocoon, line.getOptionValue(XCONF_OPT), destDir);
        }
        if (line.hasOption(VERBOSE_OPT)) {
            cocoon.setVerbose(true);
        }
        if (line.hasOption(PRECOMPILE_ONLY_OPT)) {
            cocoon.setPrecompileOnly(true);
        }

        if (line.hasOption(WORK_DIR_OPT)) {
            cocoon.setWorkDir(line.getOptionValue(WORK_DIR_OPT));
        }
        if (line.hasOption(CONTEXT_DIR_OPT)) {
            cocoon.setContextDir(line.getOptionValue(CONTEXT_DIR_OPT));
        }
        if (line.hasOption(CONFIG_FILE_OPT)) {
            cocoon.setConfigFile(line.getOptionValue(CONFIG_FILE_OPT));
        }
        if (line.hasOption(LOG_KIT_OPT)) {
            cocoon.setLogKit(line.getOptionValue(LOG_KIT_OPT));
        }
        if (line.hasOption(LOGGER_OPT)) {
            cocoon.setLogger(line.getOptionValue(LOGGER_OPT));
        }
        if (line.hasOption(LOG_LEVEL_OPT)) {
            cocoon.setLogLevel(line.getOptionValue(LOG_LEVEL_OPT));
        }
        if (line.hasOption(AGENT_OPT)) {
            cocoon.setAgentOptions(line.getOptionValue(AGENT_OPT));
        }
        if (line.hasOption(ACCEPT_OPT)) {
            cocoon.setAcceptOptions(line.getOptionValue(ACCEPT_OPT));
        }
        if (line.hasOption(DEFAULT_FILENAME_OPT)) {
            cocoon.setDefaultFilename(line.getOptionValue(DEFAULT_FILENAME_OPT));
        }
        if (line.hasOption(BROKEN_LINK_FILE_OPT)) {
            brokenLinkReportFile = line.getOptionValue(BROKEN_LINK_FILE_OPT);
        }
        if (line.hasOption(URI_FILE_OPT)) {
            cocoon.addTargets(processURIFile(line.getOptionValue(URI_FILE_OPT)), destDir);
        }
        if (line.hasOption(FOLLOW_LINKS_OPT)) {
            cocoon.setFollowLinks(yesno(line.getOptionValue(FOLLOW_LINKS_OPT)));
        }
        if (line.hasOption(CONFIRM_EXTENSIONS_OPT)) {
            cocoon.setConfirmExtensions(yesno(line.getOptionValue(CONFIRM_EXTENSIONS_OPT, "yes")));
        }
        if (line.hasOption(LOAD_CLASS_OPT)){
            cocoon.addLoadedClasses(Arrays.asList(line.getOptionValues(LOAD_CLASS_OPT)));
        }

        cocoon.addTargets(line.getArgList(), destDir);

        System.out.println(getProlog());

        cocoon.initialize();
        cocoon.process();
        cocoon.dispose();

        listener.outputBrokenLinks();

        long duration = System.currentTimeMillis() - startTimeMillis;
        System.out.println("Total time: " + (duration / 60000) + " minutes " + (duration % 60000)/1000 + " seconds");
View Full Code Here

    public static void main(String[] args) throws Exception {

        Main.setOptions();
        CommandLine line = new PosixParser().parse( options, args );
        listener = new OutputStreamListener(System.out);
        CocoonBean cocoon = new CocoonBean();
        cocoon.addListener(listener);

        if (line.hasOption(HELP_OPT)) {
             printUsage();
        } else if (line.hasOption(VERSION_OPT)) {
             printVersion();
        } else {
            String uriGroup = null;
            if (line.hasOption(URI_GROUP_NAME_OPT)) {
                uriGroup = line.getOptionValue(URI_GROUP_NAME_OPT);
            }
               
            String destDir = null;
            if (line.hasOption(XCONF_OPT)) {
                // destDir from command line overrides one in xconf file
                destDir = Main.processXConf(cocoon, line.getOptionValue(XCONF_OPT), destDir, uriGroup);
            }
            if (line.hasOption(DEST_DIR_OPT)) {
                destDir = line.getOptionValue(DEST_DIR_OPT);
            }
   
            if (line.hasOption(VERBOSE_OPT)) {
                cocoon.setVerbose(true);
            }
            if (line.hasOption(PRECOMPILE_ONLY_OPT)) {
                cocoon.setPrecompileOnly(true);
            }
   
            if (line.hasOption(WORK_DIR_OPT)) {
                String workDir = line.getOptionValue(WORK_DIR_OPT);
                if (workDir.length() == 0) {
                    listener.messageGenerated(
                        "Careful, you must specify a work dir when using the -w/--workDir argument");
                    System.exit(1);
                } else {
                    cocoon.setWorkDir(line.getOptionValue(WORK_DIR_OPT));
                }
            }
            if (line.hasOption(CONTEXT_DIR_OPT)) {
                String contextDir = line.getOptionValue(CONTEXT_DIR_OPT);
                if (contextDir.length() == 0) {
                    listener.messageGenerated(
                        "Careful, you must specify a configuration file when using the -c/--contextDir argument");
                    System.exit(1);
                } else
                    cocoon.setContextDir(contextDir);
                }
            }
            if (line.hasOption(CONFIG_FILE_OPT)) {
                cocoon.setConfigFile(line.getOptionValue(CONFIG_FILE_OPT));
            }
            if (line.hasOption(LOG_KIT_OPT)) {
                cocoon.setLogKit(line.getOptionValue(LOG_KIT_OPT));
            }
            if (line.hasOption(LOGGER_OPT)) {
                cocoon.setLogger(line.getOptionValue(LOGGER_OPT));
            }
            if (line.hasOption(LOG_LEVEL_OPT)) {
                cocoon.setLogLevel(line.getOptionValue(LOG_LEVEL_OPT));
            }
            if (line.hasOption(AGENT_OPT)) {
                cocoon.setAgentOptions(line.getOptionValue(AGENT_OPT));
            }
            if (line.hasOption(ACCEPT_OPT)) {
                cocoon.setAcceptOptions(line.getOptionValue(ACCEPT_OPT));
            }
            if (line.hasOption(DEFAULT_FILENAME_OPT)) {
                cocoon.setDefaultFilename(line.getOptionValue(DEFAULT_FILENAME_OPT));
            }
            if (line.hasOption(BROKEN_LINK_FILE_OPT)) {
                listener.setReportFile(line.getOptionValue(BROKEN_LINK_FILE_OPT));
            }
            if (line.hasOption(FOLLOW_LINKS_OPT)) {
                cocoon.setFollowLinks(BooleanUtils.toBoolean(line.getOptionValue(FOLLOW_LINKS_OPT)));
            }
            if (line.hasOption(CONFIRM_EXTENSIONS_OPT)) {
                cocoon.setConfirmExtensions(BooleanUtils.toBoolean(line.getOptionValue(CONFIRM_EXTENSIONS_OPT, "yes")));
            }
            if (line.hasOption(LOAD_CLASS_OPT)){
                cocoon.addLoadedClasses(Arrays.asList(line.getOptionValues(LOAD_CLASS_OPT)));
            }
            if (line.hasOption(URI_FILE_OPT)) {
                cocoon.addTargets(BeanConfigurator.processURIFile(line.getOptionValue(URI_FILE_OPT)), destDir);
            }
   
            cocoon.addTargets(line.getArgList(), destDir);
   
            listener.messageGenerated(CocoonBean.getProlog());
   
            if (cocoon.getTargetCount() == 0 && cocoon.isPrecompileOnly()) {
                listener.messageGenerated("Please, specify at least one starting URI.");
                System.exit(1);
            }
   
            cocoon.initialize();
            cocoon.process();
            cocoon.dispose();
   
            listener.complete();
   
   
            int exitCode = (listener.isSuccessful() ? 0 : 1);
View Full Code Here

    public static void main(String[] args) throws Exception {

        Main.setOptions();
        CommandLine line = new PosixParser().parse( options, args );
        listener = new OutputStreamListener(System.out);
        CocoonBean cocoon = new CocoonBean();
        cocoon.addListener(listener);

        if (line.hasOption(HELP_OPT)) {
             printUsage();
        } else if (line.hasOption(VERSION_OPT)) {
             printVersion();
        }

        String uriGroup = null;
        if (line.hasOption(URI_GROUP_NAME_OPT)) {
            uriGroup = line.getOptionValue(URI_GROUP_NAME_OPT);
        }
           
        String destDir = null;
        if (line.hasOption(XCONF_OPT)) {
            // destDir from command line overrides one in xconf file
            destDir = Main.processXConf(cocoon, line.getOptionValue(XCONF_OPT), destDir, uriGroup);
        }
        if (line.hasOption(DEST_DIR_OPT)) {
            destDir = line.getOptionValue(DEST_DIR_OPT);
        }

        if (line.hasOption(VERBOSE_OPT)) {
            cocoon.setVerbose(true);
        }
        if (line.hasOption(PRECOMPILE_ONLY_OPT)) {
            cocoon.setPrecompileOnly(true);
        }

        if (line.hasOption(WORK_DIR_OPT)) {
            String workDir = line.getOptionValue(WORK_DIR_OPT);
            if (workDir.equals("")) {
                listener.messageGenerated(
                    "Careful, you must specify a work dir when using the -w/--workDir argument");
                System.exit(1);
            } else {
                cocoon.setWorkDir(line.getOptionValue(WORK_DIR_OPT));
            }
        }
        if (line.hasOption(CONTEXT_DIR_OPT)) {
            String contextDir = line.getOptionValue(CONTEXT_DIR_OPT);
            if (contextDir.equals("")) {
                listener.messageGenerated(
                    "Careful, you must specify a configuration file when using the -c/--contextDir argument");
                System.exit(1);
            } else
                cocoon.setContextDir(contextDir);
            }
        }
        if (line.hasOption(CONFIG_FILE_OPT)) {
            cocoon.setConfigFile(line.getOptionValue(CONFIG_FILE_OPT));
        }
        if (line.hasOption(LOG_KIT_OPT)) {
            cocoon.setLogKit(line.getOptionValue(LOG_KIT_OPT));
        }
        if (line.hasOption(LOGGER_OPT)) {
            cocoon.setLogger(line.getOptionValue(LOGGER_OPT));
        }
        if (line.hasOption(LOG_LEVEL_OPT)) {
            cocoon.setLogLevel(line.getOptionValue(LOG_LEVEL_OPT));
        }
        if (line.hasOption(AGENT_OPT)) {
            cocoon.setAgentOptions(line.getOptionValue(AGENT_OPT));
        }
        if (line.hasOption(ACCEPT_OPT)) {
            cocoon.setAcceptOptions(line.getOptionValue(ACCEPT_OPT));
        }
        if (line.hasOption(DEFAULT_FILENAME_OPT)) {
            cocoon.setDefaultFilename(line.getOptionValue(DEFAULT_FILENAME_OPT));
        }
        if (line.hasOption(BROKEN_LINK_FILE_OPT)) {
            listener.setReportFile(line.getOptionValue(BROKEN_LINK_FILE_OPT));
        }
        if (line.hasOption(FOLLOW_LINKS_OPT)) {
            cocoon.setFollowLinks(BooleanUtils.toBoolean(line.getOptionValue(FOLLOW_LINKS_OPT)));
        }
        if (line.hasOption(CONFIRM_EXTENSIONS_OPT)) {
            cocoon.setConfirmExtensions(BooleanUtils.toBoolean(line.getOptionValue(CONFIRM_EXTENSIONS_OPT, "yes")));
        }
        if (line.hasOption(LOAD_CLASS_OPT)){
            cocoon.addLoadedClasses(Arrays.asList(line.getOptionValues(LOAD_CLASS_OPT)));
        }
        if (line.hasOption(URI_FILE_OPT)) {
            cocoon.addTargets(BeanConfigurator.processURIFile(line.getOptionValue(URI_FILE_OPT)), destDir);
        }

        cocoon.addTargets(line.getArgList(), destDir);

        listener.messageGenerated(CocoonBean.getProlog());

        if (cocoon.getTargetCount() ==0 && cocoon.isPrecompileOnly()) {
            listener.messageGenerated("Please, specify at least one starting URI.");
            System.exit(1);
        }

        cocoon.initialize();
        cocoon.process();
        cocoon.dispose();

        listener.complete();


        int exitCode = (listener.isSuccessful() ? 0 : 1);
View Full Code Here

* @version CVS $Id: AntDelegate.java 54552 2004-10-11 10:35:06Z upayavira $
*/
public class AntDelegate {

    public static int process(Document xconf, String uriGroup) throws Exception {
        CocoonBean cocoon = new CocoonBean();
        OutputStreamListener listener = new OutputStreamListener(System.out);
        cocoon.addListener(listener);
        BeanConfigurator.configure(xconf, cocoon, "", uriGroup, listener);

        System.out.println(CocoonBean.getProlog());

        if (!cocoon.isPrecompileOnly() && cocoon.getTargetCount() ==0) {
            listener.messageGenerated("Please, specify at least one starting URI.");
            System.exit(1);
        }

        cocoon.initialize();
        cocoon.process();
        cocoon.dispose();

        listener.complete();
        return listener.isSuccessful() ? 0 : 1;
    }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.bean.CocoonBean

Copyright © 2018 www.massapicom. 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.