org.apache.cocoon
Class Main

java.lang.Object
  |
  +--org.apache.cocoon.Main

public class Main
extends java.lang.Object

Command line entry point.

Version:
CVS $Id: Main.java,v 1.17.2.1 2002/06/07 09:34:22 cziegeler Exp $
Author:
Stefano Mazzocchi

Field Summary
protected static int ACCEPT_OPT
           
protected static int AGENT_OPT
           
protected static int BROKEN_LINK_FILE
           
protected static int CONFIG_FILE
           
protected static int CONTEXT_DIR_OPT
           
protected static java.lang.String DEFAULT_ACCEPT
           
protected static java.lang.String DEFAULT_USER_AGENT
           
protected static int DEST_DIR_OPT
           
protected static int FOLLOW_LINKS_OPT
           
protected static int HELP_OPT
           
protected static int LOG_KIT_OPT
           
protected static int LOG_LEVEL_OPT
           
protected static int LOGGER_OPT
           
protected static org.apache.avalon.excalibur.cli.CLOptionDescriptor[] OPTIONS
           
protected static int PRECOMPILE_OPT
           
protected static int URI_FILE
           
protected static int VERSION_OPT
           
protected static int WORK_DIR_OPT
           
 
Constructor Summary
Main(Cocoon cocoon, java.io.File context, java.io.File destDir, java.io.File brokenLinks)
          Creates the Main class
 
Method Summary
protected static java.lang.String getClassPath(java.lang.String context)
          This builds the important ClassPath used by this class.
protected  java.util.Collection getLinks(java.lang.String deparameterizedURI, java.util.Map parameters)
          Samples an URI for its links.
protected  java.lang.String getPage(java.lang.String deparameterizedURI, java.util.Map parameters, java.util.Map links, java.io.OutputStream stream)
          Processes an URI for its content.
protected  java.lang.String getType(java.lang.String deparameterizedURI, java.util.Map parameters)
          Analyze the type of content for an URI.
static void main(java.lang.String[] args)
          The main method.
 int process(java.util.Collection uris, boolean precompileOnly)
          Process the URI list and process them all independently.
static void processFile(java.lang.String filename, java.util.List uris)
          processFile method.
 java.util.Collection processURI(java.lang.String uri)
          Processes the given URI and return all links.
 void processXMAP(java.lang.String uri)
          Process a single XMAP file
 void processXSP(java.lang.String uri)
          Process a single XSP file
 void recursivelyPrecompile(java.io.File contextDir, java.io.File file)
          Recurse the directory hierarchy and process the XSP's.
 java.lang.String translateURI(java.lang.String uri)
          Translate an URI into a file name.
protected  java.lang.String tree(int level)
          Generate the string for a tree in ascii art for a tree view log output.
 void warmup()
          Warms up the engine by accessing the root.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HELP_OPT

protected static final int HELP_OPT

VERSION_OPT

protected static final int VERSION_OPT

LOG_KIT_OPT

protected static final int LOG_KIT_OPT

LOGGER_OPT

protected static final int LOGGER_OPT

LOG_LEVEL_OPT

protected static final int LOG_LEVEL_OPT

CONTEXT_DIR_OPT

protected static final int CONTEXT_DIR_OPT

DEST_DIR_OPT

protected static final int DEST_DIR_OPT

WORK_DIR_OPT

protected static final int WORK_DIR_OPT

AGENT_OPT

protected static final int AGENT_OPT

ACCEPT_OPT

protected static final int ACCEPT_OPT

URI_FILE

protected static final int URI_FILE

FOLLOW_LINKS_OPT

protected static final int FOLLOW_LINKS_OPT

CONFIG_FILE

protected static final int CONFIG_FILE

BROKEN_LINK_FILE

protected static final int BROKEN_LINK_FILE

PRECOMPILE_OPT

protected static final int PRECOMPILE_OPT

DEFAULT_USER_AGENT

protected static final java.lang.String DEFAULT_USER_AGENT

DEFAULT_ACCEPT

protected static final java.lang.String DEFAULT_ACCEPT

OPTIONS

protected static final org.apache.avalon.excalibur.cli.CLOptionDescriptor[] OPTIONS
Constructor Detail

Main

public Main(Cocoon cocoon,
            java.io.File context,
            java.io.File destDir,
            java.io.File brokenLinks)
Creates the Main class
Parameters:
cocoon - a Cocoon instance
context - a File for the context directory
destDir - a File for the destination directory
Method Detail

processFile

public static void processFile(java.lang.String filename,
                               java.util.List uris)
processFile method.
Parameters:
filename - a String value
uris - a List of URIs

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
The main method.
Parameters:
args - a String[] of arguments
Throws:
java.lang.Exception - if an error occurs

warmup

public void warmup()
            throws java.lang.Exception
Warms up the engine by accessing the root.
Throws:
java.lang.Exception - if an error occurs

process

public int process(java.util.Collection uris,
                   boolean precompileOnly)
            throws java.lang.Exception
Process the URI list and process them all independently.
Parameters:
uris - a Collection of URIs
precompileOnly - a boolean denoting to process XSP only
Returns:
an int value with the number of links processed
Throws:
java.lang.Exception - if an error occurs

recursivelyPrecompile

public void recursivelyPrecompile(java.io.File contextDir,
                                  java.io.File file)
Recurse the directory hierarchy and process the XSP's.
Parameters:
contextDir - a File value for the context directory
file - a File value for a single XSP file or a directory to scan recursively

processXSP

public void processXSP(java.lang.String uri)
                throws java.lang.Exception
Process a single XSP file
Parameters:
uri - a String pointing to an xsp URI
Throws:
java.lang.Exception - if an error occurs

processXMAP

public void processXMAP(java.lang.String uri)
                 throws java.lang.Exception
Process a single XMAP file
Parameters:
uri - a String pointing to an xmap URI
Throws:
java.lang.Exception - if an error occurs

processURI

public java.util.Collection processURI(java.lang.String uri)
                                throws java.lang.Exception
Processes the given URI and return all links. The algorithm is the following:
Parameters:
uri - a String URI to process
Returns:
a Collection containing all links found
Throws:
java.lang.Exception - if an error occurs

translateURI

public java.lang.String translateURI(java.lang.String uri)
                              throws java.lang.Exception
Translate an URI into a file name.
Parameters:
uri - a String value to map
Returns:
a String vlaue for the file
Throws:
java.lang.Exception - if an error occurs

tree

protected java.lang.String tree(int level)
Generate the string for a tree in ascii art for a tree view log output.
Parameters:
level - of nesting
Returns:
a String value to print the levels requested

getLinks

protected java.util.Collection getLinks(java.lang.String deparameterizedURI,
                                        java.util.Map parameters)
                                 throws java.lang.Exception
Samples an URI for its links.
Parameters:
deparameterizedURI - a String value of an URI to start sampling from
parameters - a Map value containing request parameters
Returns:
a Collection of links
Throws:
java.lang.Exception - if an error occurs

getPage

protected java.lang.String getPage(java.lang.String deparameterizedURI,
                                   java.util.Map parameters,
                                   java.util.Map links,
                                   java.io.OutputStream stream)
                            throws java.lang.Exception
Processes an URI for its content.
Parameters:
deparameterizedURI - a String value of an URI to start sampling from
parameters - a Map value containing request parameters
links - a Map value
stream - an OutputStream to write the content to
Returns:
a String value for the content
Throws:
java.lang.Exception - if an error occurs

getType

protected java.lang.String getType(java.lang.String deparameterizedURI,
                                   java.util.Map parameters)
                            throws java.lang.Exception
Analyze the type of content for an URI.
Parameters:
deparameterizedURI - a String value to analyze
parameters - a Map value for the request
Returns:
a String value denoting the type of content
Throws:
java.lang.Exception - if an error occurs

getClassPath

protected static java.lang.String getClassPath(java.lang.String context)
This builds the important ClassPath used by this class. It does so in a neutral way. It iterates in alphabetical order through every file in the lib directory and adds it to the classpath. Also, we add the files to the ClassLoader for the Cocoon system. In order to protect ourselves from skitzofrantic classloaders, we need to work with a known one.
Parameters:
context - The context path
Returns:
a String value


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.