cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.2/src/java/org/apache/cocoon/bean BeanListener.java CocoonBean.java BatchProcessorBean.java ProcessorBean.java
Date Fri, 23 Jan 2004 11:07:28 GMT
cziegeler    2004/01/23 03:07:28

  Modified:    src/java/org/apache/cocoon/bean BeanListener.java
                        CocoonBean.java BatchProcessorBean.java
                        ProcessorBean.java
  Log:
  Just some code formatting and optimization
  
  Revision  Changes    Path
  1.5       +14 -14    cocoon-2.2/src/java/org/apache/cocoon/bean/BeanListener.java
  
  Index: BeanListener.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/BeanListener.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BeanListener.java	17 Oct 2003 17:49:23 -0000	1.4
  +++ BeanListener.java	23 Jan 2004 11:07:28 -0000	1.5
  @@ -69,14 +69,14 @@
        * @param pagesComplete  Number of pages already generated
        * @param timeTaken      Length of time for processing in millis
        */
  -    public void pageGenerated(String sourceURI,
  -                              String destinationURI,
  -                              int pageSize,
  -                              int linksInPage,
  -                              int newLinksinPage,
  -                              int pagesRemaining,
  -                              int pagesComplete,
  -                              long timeTaken);
  +    void pageGenerated(String sourceURI,
  +                       String destinationURI,
  +                       int pageSize,
  +                       int linksInPage,
  +                       int newLinksinPage,
  +                       int pagesRemaining,
  +                       int pagesComplete,
  +                       long timeTaken);
   
       /**
        * Report a that was skipped because its URI matched an
  @@ -84,13 +84,13 @@
        * @param uri      The uri for the report
        * @param message  The message for skipping
        */
  -    public void pageSkipped(String uri, String message);
  +    void pageSkipped(String uri, String message);
   
       /**
        * Report a general message about operation of the bean
        * @param msg            The message to be reported
        */
  -    public void messageGenerated(String msg);
  +    void messageGenerated(String msg);
   
       /**
        * Report a warning about something non-fatal that happened within
  @@ -98,19 +98,19 @@
        * @param uri            The page being generated when warning was triggered
        * @param warning        The warning to be reported
        */
  -    public void warningGenerated(String uri, String warning);
  +    void warningGenerated(String uri, String warning);
   
       /**
        * Report a broken link
        * @param uri            The URI that failed to be generated
        * @param message        A reason why the link was not generated
        */
  -    public void brokenLinkFound(String uri, String parentURI, String message, Throwable t);
  +    void brokenLinkFound(String uri, String parentURI, String message, Throwable t);
   
       /**
        * Signals completion of the generation process. This method can
        * be used to write out reports, display time generation duration,
        * etc.
        */
  -    public void complete();
  +    void complete();
   }
  
  
  
  1.48      +45 -93    cocoon-2.2/src/java/org/apache/cocoon/bean/CocoonBean.java
  
  Index: CocoonBean.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/CocoonBean.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- CocoonBean.java	9 Jan 2004 08:03:39 -0000	1.47
  +++ CocoonBean.java	23 Jan 2004 11:07:28 -0000	1.48
  @@ -99,27 +99,22 @@
       private boolean m_alreadyLoaded;
       private Map m_properties;
   
  -    public CocoonBean()
  -    {
  +    public CocoonBean() {
           m_confBuilder = new FortressConfig();
           m_parentClassLoader = Thread.currentThread().getContextClassLoader();
           m_initializationLogger = new NullLogger();
  -        m_contManager = null;
           m_alreadyLoaded = false;
           m_properties = new HashMap();
       }
   
  -    public CompilingProcessor getRootProcessor()
  -    {
  +    public CompilingProcessor getRootProcessor() {
  +        // TODO - the rootProcessor is never released
           ServiceManager manager = getServiceManager();
   
           CompilingProcessor rootProcessor = null;
  -        try
  -        {
  +        try {
               rootProcessor = (CompilingProcessor)manager.lookup( CompilingProcessor.ROLE);
  -        }
  -        catch ( ServiceException e )
  -        {
  +        } catch ( ServiceException e ) {
               throw new CascadingRuntimeException("Error retrieving root processor", e);
           }
   
  @@ -127,14 +122,10 @@
       }
   
       protected ServiceManager getServiceManager(){
  -        if (null == m_contManager)
  -        {
  -            try
  -            {
  +        if (null == m_contManager) {
  +            try {
                   initialize();
  -            }
  -            catch ( Exception e )
  -            {
  +            } catch ( Exception e ) {
                   throw new CascadingRuntimeException("Error starting up container", e);
               }
           }
  @@ -145,145 +136,115 @@
       }
   
   
  -    public Logger getInitializationLogger()
  -    {
  +    public Logger getInitializationLogger() {
           return m_initializationLogger;
       }
   
  -    public void setInitializationLogger( Logger initializationLogger )
  -    {
  +    public void setInitializationLogger( Logger initializationLogger ) {
           m_initializationLogger = initializationLogger;
       }
   
  -    public File getWorkDirectory()
  -    {
  +    public File getWorkDirectory() {
           return m_workDirectory;
       }
   
  -    public void setWorkDirectory( File workDirectory )
  -    {
  +    public void setWorkDirectory( File workDirectory ) {
           m_workDirectory = workDirectory;
       }
   
  -    public int getThreadsPerCPU()
  -    {
  +    public int getThreadsPerCPU() {
           return m_threadsPerCPU;
       }
   
  -    public void setThreadsPerCPU( int threadsPerCPU )
  -    {
  +    public void setThreadsPerCPU( int threadsPerCPU ) {
           m_threadsPerCPU = threadsPerCPU;
       }
   
  -    public ClassLoader getParentClassLoader()
  -    {
  +    public ClassLoader getParentClassLoader() {
           return m_parentClassLoader;
       }
   
  -    public void setParentClassLoader( ClassLoader parentClassLoader )
  -    {
  +    public void setParentClassLoader( ClassLoader parentClassLoader ) {
           m_parentClassLoader = parentClassLoader;
       }
   
  -    public long getThreadTimeOut()
  -    {
  +    public long getThreadTimeOut() {
           return m_threadTimeOut;
       }
   
  -    public void setThreadTimeOut( long threadTimeOut )
  -    {
  +    public void setThreadTimeOut( long threadTimeOut ) {
           m_threadTimeOut = threadTimeOut;
       }
   
  -    public String getContextURI()
  -    {
  +    public String getContextURI() {
           return m_contextURI;
       }
   
  -    public void setContextURI( String contextURI )
  -    {
  +    public void setContextURI( String contextURI ) {
           m_contextURI = contextURI;
       }
   
  -    public String getInstrumentConfigURI()
  -    {
  +    public String getInstrumentConfigURI() {
           return m_instrumentConfigURI;
       }
   
  -    public void setInstrumentConfigURI( String instrumentConfigURI )
  -    {
  +    public void setInstrumentConfigURI( String instrumentConfigURI ) {
           m_instrumentConfigURI = instrumentConfigURI;
       }
   
  -    public String getLogConfigURI()
  -    {
  +    public String getLogConfigURI() {
           return m_logConfigURI;
       }
   
  -    public void setLogConfigURI( String logConfigURI )
  -    {
  +    public void setLogConfigURI( String logConfigURI ) {
           m_logConfigURI = logConfigURI;
       }
   
  -    public String getLogCategory()
  -    {
  +    public String getLogCategory() {
           return m_logCategory;
       }
   
  -    public void setLogCategory( String logCategory )
  -    {
  +    public void setLogCategory( String logCategory ) {
           m_logCategory = logCategory;
       }
   
  -    public String getConfigURI()
  -    {
  +    public String getConfigURI() {
           return m_configURI;
       }
   
  -    public void setConfigURI( String configURI )
  -    {
  +    public void setConfigURI( String configURI ) {
           m_configURI = configURI;
       }
   
  -    public List getClassForceLoadList()
  -    {
  +    public List getClassForceLoadList() {
           return m_classForceLoadList;
       }
   
  -    public void setClassForceLoadList( List classForceLoadList )
  -    {
  +    public void setClassForceLoadList( List classForceLoadList ) {
           m_classForceLoadList = classForceLoadList;
       }
   
  -    public String getClassPath()
  -    {
  +    public String getClassPath() {
           return m_classPath;
       }
   
  -    public void setClassPath( String classPath )
  -    {
  +    public void setClassPath( String classPath ) {
           m_classPath = classPath;
       }
   
  -    public void setProperty( String key, Object value )
  -    {
  -        if ( null == value )
  -        {
  +    public void setProperty( String key, Object value ) {
  +        if ( null == value ) {
               m_properties.remove( key );
  -        }
  -        else
  -        {
  +        } else {
               m_properties.put( key, value );
           }
       }
   
  -    public Object getProperty( String key )
  -    {
  +    public Object getProperty( String key ) {
           return m_properties.get( key );
       }
   
  -    public void clearAllProperties()
  -    {
  +    public void clearAllProperties() {
           m_properties.clear();
       }
   
  @@ -312,8 +273,7 @@
   
           DefaultContext initContext = new ComponentContext( m_confBuilder.getContext() );
           Iterator it = m_properties.entrySet().iterator();
  -        while (it.hasNext())
  -        {
  +        while (it.hasNext()) {
               Map.Entry entry = (Map.Entry)it.next();
               initContext.put(entry.getKey(), entry.getValue());
           }
  @@ -322,32 +282,26 @@
           ContainerUtil.initialize( m_contManager );
       }
   
  -    private LifecycleExtensionManager getLifecycleExtensionManager()
  -    {
  +    private LifecycleExtensionManager getLifecycleExtensionManager() {
           LifecycleExtensionManager manager = new LifecycleExtensionManager();
           manager.addCreatorExtension(new SitemapConfigurableCreator());
   
           return manager;
       }
   
  -    private void forceLoadClasses()
  -    {
  +    private void forceLoadClasses() {
           if ( m_alreadyLoaded ) return;
   
           m_initializationLogger.debug("Loading classes");
   
           Iterator it = m_classForceLoadList.iterator();
  -        while (it.hasNext())
  -        {
  +        while (it.hasNext()) {
               String className = (String) it.next();
               m_initializationLogger.debug("Loading class: " + className);
   
  -            try
  -            {
  +            try {
                   m_parentClassLoader.loadClass(className);
  -            }
  -            catch (Exception e)
  -            {
  +            } catch (Exception e) {
                   m_initializationLogger.warn("Could not load class: " + className, e);
               }
           }
  @@ -355,15 +309,13 @@
           m_alreadyLoaded = true;
       }
   
  -    public void dispose()
  -    {
  +    public void dispose() {
           m_initializationLogger.debug("Shutting down Cocoon");
           ContainerUtil.dispose( m_contManager );
           m_contManager = null;
       }
   
  -    protected void finalize() throws Throwable
  -    {
  +    protected void finalize() throws Throwable {
           dispose();
           super.finalize();
       }
  
  
  
  1.2       +423 -510  cocoon-2.2/src/java/org/apache/cocoon/bean/BatchProcessorBean.java
  
  Index: BatchProcessorBean.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/BatchProcessorBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BatchProcessorBean.java	17 Oct 2003 22:05:14 -0000	1.1
  +++ BatchProcessorBean.java	23 Jan 2004 11:07:28 -0000	1.2
  @@ -1,52 +1,47 @@
   /*
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  -
  - Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  -
  - Redistribution and use in source and binary forms, with or without modifica-
  - tion, are permitted provided that the following conditions are met:
  -
  - 1. Redistributions of  source code must  retain the above copyright  notice,
  -    this list of conditions and the following disclaimer.
  -
  - 2. Redistributions in binary form must reproduce the above copyright notice,
  -    this list of conditions and the following disclaimer in the documentation
  -    and/or other materials provided with the distribution.
  -
  - 3. The end-user documentation included with the redistribution, if any, must
  -    include  the following  acknowledgment:  "This product includes  software
  -    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  -    Alternately, this  acknowledgment may  appear in the software itself,  if
  -    and wherever such third-party acknowledgments normally appear.
  -
  - 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
  -    must not be used to endorse or promote products derived from this  software
  -    without  prior written permission. For written permission, please contact
  -    apache@apache.org.
  -
  - 5. Products  derived from this software may not  be called "Apache", nor may
  -    "Apache" appear  in their name,  without prior written permission  of the
  -    Apache Software Foundation.
  -
  - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  - FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  -
  - This software  consists of voluntary contributions made  by many individuals
  - on  behalf of the Apache Software  Foundation. For more  information on the
  - Apache Software Foundation, please see <http://www.apache.org/>.
  -
  -*/
  + * 
  + * ============================================================================
  + * The Apache Software License, Version 1.1
  + * ============================================================================
  + * 
  + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  + * 
  + * Redistribution and use in source and binary forms, with or without modifica-
  + * tion, are permitted provided that the following conditions are met:
  + *  1. Redistributions of source code must retain the above copyright notice,
  + * this list of conditions and the following disclaimer.
  + *  2. Redistributions in binary form must reproduce the above copyright
  + * notice, this list of conditions and the following disclaimer in the
  + * documentation and/or other materials provided with the distribution.
  + *  3. The end-user documentation included with the redistribution, if any,
  + * must include the following acknowledgment: "This product includes software
  + * developed by the Apache Software Foundation (http://www.apache.org/)."
  + * Alternately, this acknowledgment may appear in the software itself, if and
  + * wherever such third-party acknowledgments normally appear.
  + *  4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software
  + * Foundation" must not be used to endorse or promote products derived from
  + * this software without prior written permission. For written permission,
  + * please contact apache@apache.org.
  + *  5. Products derived from this software may not be called "Apache", nor may
  + * "Apache" appear in their name, without prior written permission of the
  + * Apache Software Foundation.
  + * 
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  + * 
  + * This software consists of voluntary contributions made by many individuals
  + * on behalf of the Apache Software Foundation. For more information on the
  + * Apache Software Foundation, please see <http://www.apache.org/> .
  + *  
  + */
   package org.apache.cocoon.bean;
   
   import org.apache.cocoon.Constants;
  @@ -67,13 +62,11 @@
   
   /**
    * BatchProcessorBean does XYZ
  - *
  + * 
    * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
    * @version CVS $ Revision: 1.1 $
    */
  -public class BatchProcessorBean
  -        extends ProcessorBean
  -{
  +public class BatchProcessorBean extends ProcessorBean {
   
       private boolean m_linkFollowed = true;
       private boolean m_precompileOnly = false;
  @@ -95,389 +88,337 @@
   
       private String m_logPriority;
   
  -    public BatchProcessorBean()
  -    {
  +    public BatchProcessorBean() {
           m_crawler = new Crawler();
       }
   
  -    public boolean isLinkFollowed()
  -    {
  +    public boolean isLinkFollowed() {
           return m_linkFollowed;
       }
   
  -    public void setLinkFollowed( boolean linkFollowed )
  -    {
  +    public void setLinkFollowed(boolean linkFollowed) {
           m_linkFollowed = linkFollowed;
       }
   
  -    public String getLogPriority()
  -    {
  +    public String getLogPriority() {
           return m_logPriority;
       }
   
  -    public void setLogPriority( String logPriority )
  -    {
  +    public void setLogPriority(String logPriority) {
           m_logPriority = logPriority;
       }
   
  -    public boolean isPrecompileOnly()
  -    {
  +    public boolean isPrecompileOnly() {
           return m_precompileOnly;
       }
   
  -    public void setPrecompileOnly( boolean precompileOnly )
  -    {
  +    public void setPrecompileOnly(boolean precompileOnly) {
           m_precompileOnly = precompileOnly;
       }
   
  -    public boolean isExtensionConfirmed()
  -    {
  +    public boolean isExtensionConfirmed() {
           return m_extensionConfirmed;
       }
   
  -    public void setExtensionConfirmed( boolean extensionConfirmed )
  -    {
  +    public void setExtensionConfirmed(boolean extensionConfirmed) {
           m_extensionConfirmed = extensionConfirmed;
       }
   
  -    public String getDefaultFilename()
  -    {
  +    public String getDefaultFilename() {
           return m_defaultFilename;
       }
   
  -    public void setDefaultFilename( String defaultFilename )
  -    {
  +    public void setDefaultFilename(String defaultFilename) {
           m_defaultFilename = defaultFilename;
       }
   
  -    public boolean isBrokenLinkGenerated()
  -    {
  +    public boolean isBrokenLinkGenerated() {
           return m_brokenLinkGenerated;
       }
   
  -    public void setBrokenLinkGenerated( boolean brokenLinkGenerated )
  -    {
  +    public void setBrokenLinkGenerated(boolean brokenLinkGenerated) {
           m_brokenLinkGenerated = brokenLinkGenerated;
       }
   
  -    public String getBrokenLinkExtension()
  -    {
  +    public String getBrokenLinkExtension() {
           return m_brokenLinkExtension;
       }
   
  -    public void setBrokenLinkExtension( String brokenLinkExtension )
  -    {
  +    public void setBrokenLinkExtension(String brokenLinkExtension) {
           m_brokenLinkExtension = brokenLinkExtension;
       }
   
  -    public List getIncludeLinkExtensions()
  -    {
  +    public List getIncludeLinkExtensions() {
           return m_includeLinkExtensions;
       }
   
  -    public void setIncludeLinkExtensions( List includeLinkExtensions )
  -    {
  +    public void setIncludeLinkExtensions(List includeLinkExtensions) {
           m_includeLinkExtensions = includeLinkExtensions;
       }
   
  -    public String getChecksumsURI()
  -    {
  +    public String getChecksumsURI() {
           return m_checksumsURI;
       }
   
  -    public void setChecksumsURI( String checksumsURI )
  -    {
  +    public void setChecksumsURI(String checksumsURI) {
           m_checksumsURI = checksumsURI;
       }
   
  -    public void initialize() throws Exception
  -    {
  +    public void initialize() throws Exception {
           super.initialize();
  -        if ( m_crawler.getRemainingCount() == 0 && !isPrecompileOnly() )
  -        {
  +        if (m_crawler.getRemainingCount() == 0 && !isPrecompileOnly()) {
               String error = "Please, specify at least one starting URI.";
  -            getInitializationLogger().fatalError( error );
  -            throw new ProcessingException( error );
  +            getInitializationLogger().fatalError(error);
  +            throw new ProcessingException(error);
           }
   
           m_sourceResolver =
  -        (SourceResolver) getServiceManager().lookup(
  -                SourceResolver.ROLE );
  -    }
  -
  -    protected void finalize() throws Throwable
  -    {
  -        dispose();
  -        super.finalize();
  +            (SourceResolver) getServiceManager().lookup(SourceResolver.ROLE);
       }
   
       /**
        * Adds a target for processing
  -     *
  -     * @param type Type of target - append, replace, insert.
  +     * 
  +     * @param type
  +     *            Type of target - append, replace, insert.
        * @param root
  -     * @param sourceURI URI of the starting page
  -     * @param destURI URI specifying destination for the generated pages.
  -     * @throws IllegalArgumentException if destURI is missing
  +     * @param sourceURI
  +     *            URI of the starting page
  +     * @param destURI
  +     *            URI specifying destination for the generated pages.
  +     * @throws IllegalArgumentException
  +     *             if destURI is missing
        */
       public void addTarget(
  -            String type,
  -            String root,
  -            String sourceURI,
  -            String destURI )
  -            throws IllegalArgumentException
  -    {
  -        Target target = new Target( type, root, sourceURI, destURI );
  -        addTargetToCrawler( target );
  -    }
  -
  -    private void addTargetToCrawler( Target target ){
  -        target.setDefaultFilename( m_defaultFilename );
  -        target.setFollowLinks( m_linkFollowed );
  -        target.setConfirmExtension( m_extensionConfirmed );
  -        target.setLogger( m_logPriority );
  -        m_crawler.addTarget( target );
  -    }
  -
  -    public void addTarget( String type, String sourceURI, String destURI )
  -            throws IllegalArgumentException
  -    {
  -        Target target = new Target( type, sourceURI, destURI );
  +        String type,
  +        String root,
  +        String sourceURI,
  +        String destURI)
  +    throws IllegalArgumentException {
  +        Target target = new Target(type, root, sourceURI, destURI);
           addTargetToCrawler(target);
       }
   
  -    public void addTarget( String sourceURI, String destURI )
  -            throws IllegalArgumentException
  -    {
  -        Target target = new Target( sourceURI, destURI );
  -        addTargetToCrawler( target );
  +    private void addTargetToCrawler(Target target) {
  +        target.setDefaultFilename(m_defaultFilename);
  +        target.setFollowLinks(m_linkFollowed);
  +        target.setConfirmExtension(m_extensionConfirmed);
  +        target.setLogger(m_logPriority);
  +        m_crawler.addTarget(target);
       }
   
  -    public void addTargets( List uris, String destURI )
  -            throws IllegalArgumentException
  -    {
  +    public void addTarget(String type, String sourceURI, String destURI)
  +    throws IllegalArgumentException {
  +        Target target = new Target(type, sourceURI, destURI);
  +        addTargetToCrawler(target);
  +    }
  +
  +    public void addTarget(String sourceURI, String destURI)
  +    throws IllegalArgumentException {
  +        Target target = new Target(sourceURI, destURI);
  +        addTargetToCrawler(target);
  +    }
  +
  +    public void addTargets(List uris, String destURI)
  +    throws IllegalArgumentException {
           Iterator i = uris.iterator();
  -        while ( i.hasNext() )
  -        {
  -            Target target = new Target( (String) i.next(), destURI );
  -            addTargetToCrawler( target );
  +        while (i.hasNext()) {
  +            Target target = new Target((String) i.next(), destURI);
  +            addTargetToCrawler(target);
           }
       }
   
       public void addTarget(
  -            String type,
  -            String root,
  -            String sourceURI,
  -            String destURI,
  -            boolean followLinks,
  -            boolean confirmExtension,
  -            String logger )
  -            throws IllegalArgumentException
  -    {
  +        String type,
  +        String root,
  +        String sourceURI,
  +        String destURI,
  +        boolean followLinks,
  +        boolean confirmExtension,
  +        String logger)
  +    throws IllegalArgumentException {
   
           Target target;
  -        if ( root == null && type == null )
  -        {
  -            target = new Target( sourceURI, destURI );
  -        }
  -        else if ( root == null )
  -        {
  -            target = new Target( type, sourceURI, destURI );
  -        }
  -        else
  -        {
  -            target = new Target( type, root, sourceURI, destURI );
  +        if (root == null && type == null) {
  +            target = new Target(sourceURI, destURI);
  +        } else if (root == null) {
  +            target = new Target(type, sourceURI, destURI);
  +        } else {
  +            target = new Target(type, root, sourceURI, destURI);
           }
  -        target.setDefaultFilename( m_defaultFilename );
  -        target.setFollowLinks( followLinks );
  -        target.setConfirmExtension( confirmExtension );
  -        target.setLogger( logger );
  -        m_crawler.addTarget( target );
  +        target.setDefaultFilename(m_defaultFilename);
  +        target.setFollowLinks(followLinks);
  +        target.setConfirmExtension(confirmExtension);
  +        target.setLogger(logger);
  +        m_crawler.addTarget(target);
       }
   
  -    public void addExcludePattern( String pattern )
  -    {
  -        int preparedPattern[] = WildcardHelper.compilePattern( pattern );
  -        m_excludePatterns.add( preparedPattern );
  +    public void addExcludePattern(String pattern) {
  +        int preparedPattern[] = WildcardHelper.compilePattern(pattern);
  +        m_excludePatterns.add(preparedPattern);
       }
   
  -    public void addIncludePattern( String pattern )
  -    {
  -        int preparedPattern[] = WildcardHelper.compilePattern( pattern );
  -        m_includePatterns.add( preparedPattern );
  +    public void addIncludePattern(String pattern) {
  +        int preparedPattern[] = WildcardHelper.compilePattern(pattern);
  +        m_includePatterns.add(preparedPattern);
       }
   
  -    public void addIncludeLinkExtension( String extension )
  -    {
  -        if ( m_includeLinkExtensions == null )
  -        {
  +    public void addIncludeLinkExtension(String extension) {
  +        if (m_includeLinkExtensions == null) {
               m_includeLinkExtensions = new ArrayList();
           }
  -        m_includeLinkExtensions.add( extension );
  +        m_includeLinkExtensions.add(extension);
  +    }
  +
  +    public void addListener(BeanListener listener) {
  +        m_listeners.add(listener);
       }
   
  -    public void addListener( BeanListener listener )
  -    {
  -        m_listeners.add( listener );
  -    }
  -
  -    public void pageGenerated( String sourceURI,
  -                               String destURI,
  -                               int pageSize,
  -                               int linksInPage,
  -                               int newLinksInPage,
  -                               int pagesRemaining,
  -                               int pagesComplete,
  -                               long timeTaken )
  -    {
  +    public void pageGenerated(
  +        String sourceURI,
  +        String destURI,
  +        int pageSize,
  +        int linksInPage,
  +        int newLinksInPage,
  +        int pagesRemaining,
  +        int pagesComplete,
  +        long timeTaken) {
           Iterator i = m_listeners.iterator();
  -        while ( i.hasNext() )
  -        {
  +        while (i.hasNext()) {
               BeanListener l = (BeanListener) i.next();
  -            l.pageGenerated( sourceURI,
  -                    destURI,
  -                    pageSize,
  -                    linksInPage,
  -                    newLinksInPage,
  -                    pagesRemaining,
  -                    pagesComplete,
  -                    timeTaken );
  +            l.pageGenerated(
  +                sourceURI,
  +                destURI,
  +                pageSize,
  +                linksInPage,
  +                newLinksInPage,
  +                pagesRemaining,
  +                pagesComplete,
  +                timeTaken);
           }
       }
   
  -    public void sendMessage( String msg )
  -    {
  +    public void sendMessage(String msg) {
           Iterator i = m_listeners.iterator();
  -        while ( i.hasNext() )
  -        {
  +        while (i.hasNext()) {
               BeanListener l = (BeanListener) i.next();
  -            l.messageGenerated( msg );
  +            l.messageGenerated(msg);
           }
       }
   
  -    public void sendWarning( String uri, String warning )
  -    {
  +    public void sendWarning(String uri, String warning) {
           Iterator i = m_listeners.iterator();
  -        while ( i.hasNext() )
  -        {
  +        while (i.hasNext()) {
               BeanListener l = (BeanListener) i.next();
  -            l.warningGenerated( uri, warning );
  +            l.warningGenerated(uri, warning);
           }
       }
   
  -    public void sendBrokenLinkWarning( String uri, String warning )
  -    {
  +    public void sendBrokenLinkWarning(String uri, String warning) {
           Iterator i = m_listeners.iterator();
  -        while ( i.hasNext() )
  -        {
  +        while (i.hasNext()) {
               BeanListener l = (BeanListener) i.next();
  -            l.brokenLinkFound( uri, "", warning, null );
  +            l.brokenLinkFound(uri, "", warning, null);
           }
       }
   
  -    public void pageSkipped( String uri, String message )
  -    {
  +    public void pageSkipped(String uri, String message) {
           Iterator i = m_listeners.iterator();
  -        while ( i.hasNext() )
  -        {
  +        while (i.hasNext()) {
               BeanListener l = (BeanListener) i.next();
  -            l.pageSkipped( uri, message );
  +            l.pageSkipped(uri, message);
           }
       }
   
  -    public void dispose()
  -    {
  -        getServiceManager().release(m_sourceResolver);
  -        m_sourceResolver = null;
  +    public void dispose() {
  +        if ( m_sourceResolver != null ) {
  +            getServiceManager().release(m_sourceResolver);
  +            m_sourceResolver = null;
  +        }
  +        super.dispose();
       }
   
       /**
        * Process the URI list and process them all independently.
  -     * @exception Exception if an error occurs
  +     * 
  +     * @exception Exception
  +     *                if an error occurs
        */
  -    public void process() throws Exception
  -    {
  +    public void process() throws Exception {
   
  -        if ( m_sourceResolver == null )
  -        {
  +        if (m_sourceResolver == null) {
               this.initialize();
           }
   
           readChecksumFile();
   
  -        if ( m_crawler.getRemainingCount() == 0 )
  -        {
  +        if (m_crawler.getRemainingCount() == 0) {
               precompile();
  -        }
  -        else
  -        {
  +        } else {
               Iterator iterator = m_crawler.iterator();
  -            while ( iterator.hasNext() )
  -            {
  +            while (iterator.hasNext()) {
                   Target target = (Target) iterator.next();
  -                if ( isPrecompileOnly() )
  -                {
  -                    processXSP( target.getSourceURI() );
  -                }
  -                else
  -                {
  -                    processTarget( m_crawler, target );
  +                if (isPrecompileOnly()) {
  +                    processXSP(target.getSourceURI());
  +                } else {
  +                    processTarget(m_crawler, target);
                   }
               }
           }
   
           writeChecksumFile();
   
  -        if ( getInitializationLogger().isInfoEnabled() )
  -        {
  +        if (getInitializationLogger().isInfoEnabled()) {
               getInitializationLogger().info(
  -                    "  Memory used: "
  -                    + ( Runtime.getRuntime().totalMemory()
  -                        - Runtime.getRuntime().freeMemory() ) );
  +                "  Memory used: "
  +                    + (Runtime.getRuntime().totalMemory()
  +                        - Runtime.getRuntime().freeMemory()));
               getInitializationLogger().info(
  -                    "  Processed, Translated & Left: "
  +                "  Processed, Translated & Left: "
                       + m_crawler.getProcessedCount()
                       + ", "
                       + m_crawler.getTranslatedCount()
                       + ", "
  -                    + m_crawler.getRemainingCount() );
  +                    + m_crawler.getRemainingCount());
           }
       }
   
       /**
        * Processes the given Target and return all links.
  -     *
  -     * If links are to be followed, and extensions checked then the algorithm is as
  -     * follows:
  +     * 
  +     * If links are to be followed, and extensions checked then the algorithm
  +     * is as follows:
        * <ul>
  -     *  <li>file name for the URI is generated. URI MIME type is checked for
  -     *      consistency with the URI and, if the extension is inconsistent
  -     *      or absent, the file name is changed</li>
  -     *  <li>the link view of the given URI is called and the file names for linked
  -     *      resources are generated and stored.</li>
  -     *  <li>for each link, absolute file name is translated to relative path.</li>
  -     *  <li>after the complete list of links is translated, the link-translating
  -     *      view of the resource is called to obtain a link-translated version
  -     *      of the resource with the given link map</li>
  -     *  <li>list of absolute URI is returned, for every URI which is not yet
  -     *      present in list of all translated URIs</li>
  +     * <li>file name for the URI is generated. URI MIME type is checked for
  +     * consistency with the URI and, if the extension is inconsistent or
  +     * absent, the file name is changed</li>
  +     * <li>the link view of the given URI is called and the file names for
  +     * linked resources are generated and stored.</li>
  +     * <li>for each link, absolute file name is translated to relative path.
  +     * </li>
  +     * <li>after the complete list of links is translated, the
  +     * link-translating view of the resource is called to obtain a
  +     * link-translated version of the resource with the given link map</li>
  +     * <li>list of absolute URI is returned, for every URI which is not yet
  +     * present in list of all translated URIs</li>
        * </ul>
  -     *
  +     * 
        * If links are to be followed, but extensions are not checked, then the
        * algorithm will be:
        * <ul>
  -     *   <li>The content for the page is generated</li>
  -     *   <li>Whilst generating, all links are gathered by the LinkGatherer</li>
  -     *   <li>Gathered links are added to the unprocessed links list, and
  -     *       processing continues until all processing is complete
  -     *   </li>
  +     * <li>The content for the page is generated</li>
  +     * <li>Whilst generating, all links are gathered by the LinkGatherer</li>
  +     * <li>Gathered links are added to the unprocessed links list, and
  +     * processing continues until all processing is complete</li>
        * </ul>
  -     *
  -     * @param target a <code>Target</code> target to process
  -     * @exception Exception if an error occurs
  +     * 
  +     * @param target
  +     *            a <code>Target</code> target to process
  +     * @exception Exception
  +     *                if an error occurs
        */
  -    private void processTarget( Crawler crawler, Target target ) throws Exception
  -    {
  +    private void processTarget(Crawler crawler, Target target)
  +    throws Exception {
   
           int status = 0;
   
  @@ -486,13 +427,14 @@
           int pageSize = 0;
           long startTimeMillis = System.currentTimeMillis();
   
  -        if ( target.confirmExtensions() )
  -        {
  -            if ( !crawler.hasTranslatedLink( target ) )
  -            {
  -                final String mimeType = getType( target.getDeparameterizedSourceURI(), target.getParameters() );
  -                target.setMimeType( mimeType );
  -                crawler.addTranslatedLink( target );
  +        if (target.confirmExtensions()) {
  +            if (!crawler.hasTranslatedLink(target)) {
  +                final String mimeType =
  +                    getType(
  +                        target.getDeparameterizedSourceURI(),
  +                        target.getParameters());
  +                target.setMimeType(mimeType);
  +                crawler.addTranslatedLink(target);
               }
           }
   
  @@ -503,281 +445,261 @@
   
           // Process links
           final HashMap translatedLinks = new HashMap();
  -        if ( target.followLinks() && target.confirmExtensions() && isCrawlablePage( target ) )
  -        {
  +        if (target.followLinks()
  +            && target.confirmExtensions()
  +            && isCrawlablePage(target)) {
               final Iterator i =
  -                    getLinks( target.getDeparameterizedSourceURI(), target.getParameters() ).iterator();
  +                getLinks(
  +                    target.getDeparameterizedSourceURI(),
  +                    target.getParameters())
  +                    .iterator();
   
  -            while ( i.hasNext() )
  -            {
  +            while (i.hasNext()) {
                   String linkURI = (String) i.next();
  -                Target linkTarget = target.getDerivedTarget( linkURI );
  +                Target linkTarget = target.getDerivedTarget(linkURI);
   
  -                if ( linkTarget == null )
  -                {
  -                    pageSkipped( linkURI, "link does not share same root as parent" );
  +                if (linkTarget == null) {
  +                    pageSkipped(
  +                        linkURI,
  +                        "link does not share same root as parent");
                       continue;
                   }
   
  -                if ( !isIncluded( linkTarget.getSourceURI() ) )
  -                {
  -                    pageSkipped( linkTarget.getSourceURI(), "matched include/exclude rules" );
  +                if (!isIncluded(linkTarget.getSourceURI())) {
  +                    pageSkipped(
  +                        linkTarget.getSourceURI(),
  +                        "matched include/exclude rules");
                       continue;
                   }
   
  -                if ( !crawler.hasTranslatedLink( linkTarget ) )
  -                {
  -                    try
  -                    {
  +                if (!crawler.hasTranslatedLink(linkTarget)) {
  +                    try {
                           final String mimeType =
  -                                getType( linkTarget.getDeparameterizedSourceURI(), linkTarget.getParameters() );
  -                        linkTarget.setMimeType( mimeType );
  -                        crawler.addTranslatedLink( linkTarget );
  -                        getInitializationLogger().info( "  Link translated: " + linkTarget.getSourceURI() );
  -                        if ( crawler.addTarget( linkTarget ) )
  -                        {
  +                            getType(
  +                                linkTarget.getDeparameterizedSourceURI(),
  +                                linkTarget.getParameters());
  +                        linkTarget.setMimeType(mimeType);
  +                        crawler.addTranslatedLink(linkTarget);
  +                        getInitializationLogger().info(
  +                            "  Link translated: " + linkTarget.getSourceURI());
  +                        if (crawler.addTarget(linkTarget)) {
                               newLinkCount++;
                           }
  -                    }
  -                    catch ( ProcessingException pe )
  -                    {
  -                        this.sendBrokenLinkWarning( linkTarget.getSourceURI(), pe.getMessage() );
  -                        if ( isBrokenLinkGenerated() )
  -                        {
  -                            if ( crawler.addTarget( linkTarget ) )
  -                            {
  +                    } catch (ProcessingException pe) {
  +                        this.sendBrokenLinkWarning(
  +                            linkTarget.getSourceURI(),
  +                            pe.getMessage());
  +                        if (isBrokenLinkGenerated()) {
  +                            if (crawler.addTarget(linkTarget)) {
                                   newLinkCount++;
                               }
                           }
                       }
                   }
   
  -                translatedLinks.put( linkTarget.getOriginalSourceURI(),
  -                        linkTarget.getTranslatedURI( target.getPath() ) );
  +                translatedLinks.put(
  +                    linkTarget.getOriginalSourceURI(),
  +                    linkTarget.getTranslatedURI(target.getPath()));
               }
   
               linkCount = translatedLinks.size();
           }
   
  -        try
  -        {
  +        try {
               // Process URI
               DelayedOutputStream output = new DelayedOutputStream();
  -            try
  -            {
  +            try {
                   List gatheredLinks;
  -                if ( !target.confirmExtensions() && target.followLinks() && isCrawlablePage( target ) )
  -                {
  +                if (!target.confirmExtensions()
  +                    && target.followLinks()
  +                    && isCrawlablePage(target)) {
                       gatheredLinks = new ArrayList();
  -                }
  -                else
  -                {
  +                } else {
                       gatheredLinks = null;
                   }
   
                   status =
  -                getPage(
  +                    getPage(
                           target.getDeparameterizedSourceURI(),
  -                        getLastModified( target ),
  +                        getLastModified(target),
                           target.getParameters(),
                           target.confirmExtensions() ? translatedLinks : null,
                           gatheredLinks,
  -                        output );
  +                        output);
   
  -                if ( status >= 400 )
  -                {
  +                if (status >= 400) {
                       throw new ProcessingException(
  -                            "Resource not found: " + status );
  +                        "Resource not found: " + status);
                   }
   
  -                if ( gatheredLinks != null )
  -                {
  -                    for ( Iterator it = gatheredLinks.iterator(); it.hasNext(); )
  -                    {
  +                if (gatheredLinks != null) {
  +                    for (Iterator it = gatheredLinks.iterator();
  +                        it.hasNext();
  +                        ) {
                           String linkURI = (String) it.next();
  -                        Target linkTarget = target.getDerivedTarget( linkURI );
  +                        Target linkTarget = target.getDerivedTarget(linkURI);
   
  -                        if ( linkTarget == null )
  -                        {
  -                            pageSkipped( linkURI, "link does not share same root as parent" );
  +                        if (linkTarget == null) {
  +                            pageSkipped(
  +                                linkURI,
  +                                "link does not share same root as parent");
                               continue;
                           }
   
  -                        if ( !isIncluded( linkTarget.getSourceURI() ) )
  -                        {
  -                            pageSkipped( linkTarget.getSourceURI(), "matched include/exclude rules" );
  +                        if (!isIncluded(linkTarget.getSourceURI())) {
  +                            pageSkipped(
  +                                linkTarget.getSourceURI(),
  +                                "matched include/exclude rules");
                               continue;
                           }
  -                        if ( crawler.addTarget( linkTarget ) )
  -                        {
  +                        if (crawler.addTarget(linkTarget)) {
                               newLinkCount++;
                           }
                       }
                       linkCount = gatheredLinks.size();
                   }
   
  -            }
  -            catch ( ProcessingException pe )
  -            {
  +            } catch (ProcessingException pe) {
                   output.close();
                   output = null;
  -                this.resourceUnavailable( target );
  -                this.sendBrokenLinkWarning( target.getSourceURI(),
  -                        DefaultNotifyingBuilder.getRootCause( pe ).getMessage() );
  -            }
  -            finally
  -            {
  -                if ( output != null && status != -1 )
  -                {
  -
  -                    ModifiableSource source = getSource( target );
  -                    try
  -                    {
  +                this.resourceUnavailable(target);
  +                this.sendBrokenLinkWarning(
  +                    target.getSourceURI(),
  +                    DefaultNotifyingBuilder.getRootCause(pe).getMessage());
  +            } finally {
  +                if (output != null && status != -1) {
  +
  +                    ModifiableSource source = getSource(target);
  +                    try {
                           pageSize = output.size();
   
  -                        if ( m_checksumsURI == null || !isSameContent( output, target ) )
  -                        {
  +                        if (m_checksumsURI == null
  +                            || !isSameContent(output, target)) {
                               OutputStream stream = source.getOutputStream();
  -                            output.setFileOutputStream( stream );
  +                            output.setFileOutputStream(stream);
                               output.flush();
                               output.close();
  -                            pageGenerated( target.getSourceURI(),
  -                                    target.getAuthlessDestURI(),
  -                                    pageSize,
  -                                    linkCount,
  -                                    newLinkCount,
  -                                    crawler.getRemainingCount(),
  -                                    crawler.getProcessedCount(),
  -                                    System.currentTimeMillis() - startTimeMillis );
  -                        }
  -                        else
  -                        {
  +                            pageGenerated(
  +                                target.getSourceURI(),
  +                                target.getAuthlessDestURI(),
  +                                pageSize,
  +                                linkCount,
  +                                newLinkCount,
  +                                crawler.getRemainingCount(),
  +                                crawler.getProcessedCount(),
  +                                System.currentTimeMillis() - startTimeMillis);
  +                        } else {
                               output.close();
  -                            pageSkipped( target.getSourceURI(), "Page not changed" );
  +                            pageSkipped(
  +                                target.getSourceURI(),
  +                                "Page not changed");
                           }
  -                    }
  -                    catch ( IOException ioex )
  -                    {
  -                        getInitializationLogger().warn( ioex.toString() );
  -                    }
  -                    finally
  -                    {
  -                        releaseSource( source );
  +                    } catch (IOException ioex) {
  +                        getInitializationLogger().warn(ioex.toString());
  +                    } finally {
  +                        releaseSource(source);
                       }
                   }
               }
  -        }
  -        catch ( Exception rnfe )
  -        {
  -            getInitializationLogger().warn( "Could not process URI: " + target.getSourceURI() );
  +        } catch (Exception rnfe) {
  +            getInitializationLogger().warn(
  +                "Could not process URI: " + target.getSourceURI());
               rnfe.printStackTrace();
  -            this.sendBrokenLinkWarning( target.getSourceURI(), "URI not found: " + rnfe.getMessage() );
  +            this.sendBrokenLinkWarning(
  +                target.getSourceURI(),
  +                "URI not found: " + rnfe.getMessage());
           }
       }
   
       /**
        * Generate a <code>resourceUnavailable</code> message.
  -     *
  -     * @param target being unavailable
  -     * @exception IOException if an error occurs
  +     * 
  +     * @param target
  +     *            being unavailable
  +     * @exception IOException
  +     *                if an error occurs
        */
  -    private void resourceUnavailable( Target target )
  -            throws IOException, ProcessingException
  -    {
  -        if ( isBrokenLinkGenerated() )
  -        {
  +    private void resourceUnavailable(Target target)
  +    throws IOException, ProcessingException {
  +        if (isBrokenLinkGenerated()) {
               //Why decode this URI now?
               //String brokenFile = NetUtils.decodePath(destinationURI);
   
  -            if ( m_brokenLinkExtension != null )
  -            {
  -                target.setExtraExtension( m_brokenLinkExtension );
  +            if (m_brokenLinkExtension != null) {
  +                target.setExtraExtension(m_brokenLinkExtension);
               }
  -            SimpleNotifyingBean n = new SimpleNotifyingBean( this );
  -            n.setType( "resource-not-found" );
  -            n.setTitle( "Resource not Found" );
  -            n.setSource( "Cocoon commandline (Main.java)" );
  -            n.setMessage( "Page Not Available." );
  -            n.setDescription( "The requested resource couldn't be found." );
  -            n.addExtraDescription( Notifying.EXTRA_REQUESTURI, target.getSourceURI() );
  -            n.addExtraDescription( "missing-file", target.getSourceURI() );
  -
  -            ModifiableSource source = getSource( target );
  -            try
  -            {
  +            SimpleNotifyingBean n = new SimpleNotifyingBean(this);
  +            n.setType("resource-not-found");
  +            n.setTitle("Resource not Found");
  +            n.setSource("Cocoon commandline (Main.java)");
  +            n.setMessage("Page Not Available.");
  +            n.setDescription("The requested resource couldn't be found.");
  +            n.addExtraDescription(
  +                Notifying.EXTRA_REQUESTURI,
  +                target.getSourceURI());
  +            n.addExtraDescription("missing-file", target.getSourceURI());
  +
  +            ModifiableSource source = getSource(target);
  +            try {
                   OutputStream stream = source.getOutputStream();
   
  -                PrintStream out = new PrintStream( stream );
  -                Notifier.notify( n, out, "text/html" );
  +                PrintStream out = new PrintStream(stream);
  +                Notifier.notify(n, out, "text/html");
                   out.flush();
                   out.close();
  -            }
  -            finally
  -            {
  -                releaseSource( source );
  +            } finally {
  +                releaseSource(source);
               }
           }
       }
   
  -    public ModifiableSource getSource( Target target )
  -            throws IOException, ProcessingException
  -    {
  +    public ModifiableSource getSource(Target target)
  +    throws IOException, ProcessingException {
           final String finalDestinationURI = target.getDestinationURI();
  -        Source src = m_sourceResolver.resolveURI( finalDestinationURI );
  -        if ( !( src instanceof ModifiableSource ) )
  -        {
  -            m_sourceResolver.release( src );
  +        Source src = m_sourceResolver.resolveURI(finalDestinationURI);
  +        if (!(src instanceof ModifiableSource)) {
  +            m_sourceResolver.release(src);
               throw new ProcessingException(
  -                    "Source is not Modifiable: " + finalDestinationURI );
  +                "Source is not Modifiable: " + finalDestinationURI);
           }
           return (ModifiableSource) src;
       }
   
  -    public long getLastModified( Target target ) throws IOException, ProcessingException
  -    {
  -        Source src = getSource( target );
  +    public long getLastModified(Target target)
  +    throws IOException, ProcessingException {
  +        Source src = getSource(target);
           long lastModified = src.getLastModified();
  -        this.releaseSource( src );
  +        this.releaseSource(src);
           return lastModified;
       }
   
  -    public void releaseSource( Source source )
  -    {
  -        m_sourceResolver.release( source );
  +    public void releaseSource(Source source) {
  +        m_sourceResolver.release(source);
       }
   
  -    private boolean isIncluded( String uri )
  -    {
  +    private boolean isIncluded(String uri) {
           boolean included;
           Iterator i;
           HashMap map = new HashMap();
   
  -        if ( m_includePatterns.size() == 0 )
  -        {
  +        if (m_includePatterns.size() == 0) {
               included = true;
  -        }
  -        else
  -        {
  +        } else {
               included = false;
               i = m_includePatterns.iterator();
  -            while ( i.hasNext() )
  -            {
  +            while (i.hasNext()) {
                   int pattern[] = (int[]) i.next();
  -                if ( WildcardHelper.match( map, uri, pattern ) )
  -                {
  +                if (WildcardHelper.match(map, uri, pattern)) {
                       included = true;
                       break;
                   }
               }
           }
  -        if ( m_excludePatterns.size() != 0 )
  -        {
  +        if (m_excludePatterns.size() != 0) {
               i = m_excludePatterns.iterator();
  -            while ( i.hasNext() )
  -            {
  +            while (i.hasNext()) {
                   int pattern[] = (int[]) i.next();
  -                if ( WildcardHelper.match( map, uri, pattern ) )
  -                {
  +                if (WildcardHelper.match(map, uri, pattern)) {
                       included = false;
                       break;
                   }
  @@ -786,94 +708,85 @@
           return included;
       }
   
  -    private boolean isCrawlablePage( Target target )
  -    {
  -        if ( m_includeLinkExtensions == null )
  -        {
  +    private boolean isCrawlablePage(Target target) {
  +        if (m_includeLinkExtensions == null) {
               return true;
  -        }
  -        else
  -        {
  -            return m_includeLinkExtensions.contains( target.getExtension() );
  +        } else {
  +            return m_includeLinkExtensions.contains(target.getExtension());
           }
       }
   
  -    /* NB. This is a temporary solution - it may well be replaced by storing the checksum info
  -    *     in the XML 'report' file, along with details of what pages were created, etc.
  -    */
  -    private void readChecksumFile() throws Exception
  -    {
  +    /*
  +     * NB. This is a temporary solution - it may well be replaced by storing
  +     * the checksum info in the XML 'report' file, along with details of what
  +     * pages were created, etc.
  +     */
  +    private void readChecksumFile() throws Exception {
           m_checksums = new HashMap();
   
  -        try
  -        {
  -            Source checksumSource = m_sourceResolver.resolveURI( m_checksumsURI );
  -            BufferedReader reader = new BufferedReader( new InputStreamReader( checksumSource.getInputStream() ) );
  +        try {
  +            Source checksumSource = m_sourceResolver.resolveURI(m_checksumsURI);
  +            BufferedReader reader =
  +                new BufferedReader(
  +                    new InputStreamReader(checksumSource.getInputStream()));
               String line;
               int lineNo = 0;
  -            while ( ( line = reader.readLine() ) != null )
  -            {
  +            while ((line = reader.readLine()) != null) {
                   lineNo++;
  -                if ( line.trim().startsWith( "#" ) || line.trim().length() == 0 )
  -                {
  +                if (line.trim().startsWith("#") || line.trim().length() == 0) {
                       continue;
                   }
  -                if ( line.indexOf( "\t" ) == -1 )
  -                {
  -                    throw new ProcessingException( "Missing tab at line " + lineNo + " of " + m_checksumsURI );
  -                }
  -                String filename = line.substring( 0, line.indexOf( "\t" ) );
  -                String checksum = line.substring( line.indexOf( "\t" ) + 1 );
  -                m_checksums.put( filename, checksum );
  +                if (line.indexOf("\t") == -1) {
  +                    throw new ProcessingException(
  +                        "Missing tab at line "
  +                            + lineNo
  +                            + " of "
  +                            + m_checksumsURI);
  +                }
  +                String filename = line.substring(0, line.indexOf("\t"));
  +                String checksum = line.substring(line.indexOf("\t") + 1);
  +                m_checksums.put(filename, checksum);
               }
               reader.close();
  -        }
  -        catch ( SourceNotFoundException e )
  -        {
  +        } catch (SourceNotFoundException e) {
               // return leaving checksums map m_empty
           }
       }
   
  -    private void writeChecksumFile() throws Exception
  -    {
  -        Source checksumSource = m_sourceResolver.resolveURI( m_checksumsURI );
  -        if ( !( checksumSource instanceof ModifiableSource ) )
  -        {
  -            throw new ProcessingException( "Checksum file is not Modifiable:" + checksumSource );
  +    private void writeChecksumFile() throws Exception {
  +        Source checksumSource = m_sourceResolver.resolveURI(m_checksumsURI);
  +        if (!(checksumSource instanceof ModifiableSource)) {
  +            throw new ProcessingException(
  +                "Checksum file is not Modifiable:" + checksumSource);
           }
           ModifiableSource source = (ModifiableSource) checksumSource;
  -        PrintWriter writer = new PrintWriter( new OutputStreamWriter( source.getOutputStream() ) );
  +        PrintWriter writer =
  +            new PrintWriter(new OutputStreamWriter(source.getOutputStream()));
           Iterator i = m_checksums.keySet().iterator();
  -        while ( i.hasNext() )
  -        {
  +        while (i.hasNext()) {
               String key = (String) i.next();
  -            String checksum = (String) m_checksums.get( key );
  -            writer.println( key + "\t" + checksum );
  +            String checksum = (String) m_checksums.get(key);
  +            writer.println(key + "\t" + checksum);
           }
           writer.close();
       }
   
  -    private boolean isSameContent( DelayedOutputStream stream, Target target )
  -    {
  -        try
  -        {
  -            MessageDigest md5 = MessageDigest.getInstance( "MD5" );
  -            md5.update( stream.getContent() );
  -            String streamDigest = SourceUtil.encodeBASE64( new String( md5.digest() ) );
  -            String targetDigest = (String) m_checksums.get( target.getSourceURI() );
  +    private boolean isSameContent(DelayedOutputStream stream, Target target) {
  +        try {
  +            MessageDigest md5 = MessageDigest.getInstance("MD5");
  +            md5.update(stream.getContent());
  +            String streamDigest =
  +                SourceUtil.encodeBASE64(new String(md5.digest()));
  +            String targetDigest =
  +                (String) m_checksums.get(target.getSourceURI());
   
  -            if ( streamDigest.equals( targetDigest ) )
  -            {
  +            if (streamDigest.equals(targetDigest)) {
                   return true;
  -            }
  -            else
  -            {
  -                m_checksums.put( target.getSourceURI(), streamDigest );
  +            } else {
  +                m_checksums.put(target.getSourceURI(), streamDigest);
                   return false;
               }
  -        }
  -        catch ( NoSuchAlgorithmException e )
  -        {
  +        } catch (NoSuchAlgorithmException e) {
               // or do something:
               return false;
           }
  
  
  
  1.2       +26 -59    cocoon-2.2/src/java/org/apache/cocoon/bean/ProcessorBean.java
  
  Index: ProcessorBean.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/bean/ProcessorBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProcessorBean.java	17 Oct 2003 22:05:14 -0000	1.1
  +++ ProcessorBean.java	23 Jan 2004 11:07:28 -0000	1.2
  @@ -71,8 +71,8 @@
    * @author <a href="bloritsch.at.apache.org">Berin Loritsch</a>
    * @version CVS $ Revision: 1.1 $
    */
  -public class ProcessorBean extends CocoonBean
  -{
  +public class ProcessorBean extends CocoonBean {
  +    
       protected static final String DEFAULT_USER_AGENT = Constants.COMPLETE_NAME;
       protected static final String DEFAULT_ACCEPT = "text/html, */*";
       private String m_userAgent = DEFAULT_USER_AGENT;
  @@ -81,8 +81,7 @@
       private HashMap m_empty = new HashMap();
       private CommandLineContext m_cliContext;
   
  -    public void initialize() throws Exception
  -    {
  +    public void initialize() throws Exception {
           super.initialize();
   
           m_cliContext = new CommandLineContext( getContextURI() );
  @@ -92,8 +91,7 @@
       /**
        * Allow subclasses to recursively precompile XSPs.
        */
  -    protected void precompile()
  -    {
  +    protected void precompile() {
           recursivelyPrecompile( new File(getContextURI()), new File(getContextURI()) );
       }
   
  @@ -102,35 +100,22 @@
        * @param contextDir a <code>File</code> value for the context directory
        * @param file a <code>File</code> value for a single XSP file or a directory to scan recursively
        */
  -    private void recursivelyPrecompile( File contextDir, File file )
  -    {
  -        if ( file.isDirectory() )
  -        {
  +    private void recursivelyPrecompile( File contextDir, File file ) {
  +        if ( file.isDirectory() ) {
               String entries[] = file.list();
  -            for ( int i = 0; i < entries.length; i++ )
  -            {
  +            for ( int i = 0; i < entries.length; i++ ) {
                   recursivelyPrecompile( contextDir, new File( file, entries[i] ) );
               }
  -        }
  -        else if ( file.getName().toLowerCase().endsWith( ".xmap" ) )
  -        {
  -            try
  -            {
  +        } else if ( file.getName().toLowerCase().endsWith( ".xmap" ) ) {
  +            try {
                   this.processXMAP( IOUtils.getContextFilePath( contextDir.getCanonicalPath(), file.getCanonicalPath() ) );
  -            }
  -            catch ( Exception e )
  -            {
  +            } catch ( Exception e ) {
                   //Ignore for now.
               }
  -        }
  -        else if ( file.getName().toLowerCase().endsWith( ".xsp" ) )
  -        {
  -            try
  -            {
  +        } else if ( file.getName().toLowerCase().endsWith( ".xsp" ) ) {
  +            try {
                   this.processXSP( IOUtils.getContextFilePath( contextDir.getCanonicalPath(), file.getCanonicalPath() ) );
  -            }
  -            catch ( Exception e )
  -            {
  +            } catch ( Exception e ) {
                   //Ignore for now.
               }
           }
  @@ -142,8 +127,7 @@
        * @param uri a <code>String</code> pointing to an xsp URI
        * @exception Exception if an error occurs
        */
  -    protected void processXSP( String uri ) throws Exception
  -    {
  +    protected void processXSP( String uri ) throws Exception {
           String markupLanguage = "xsp";
           String programmingLanguage = "java";
           Environment env = new LinkSamplingEnvironment( "/", new File( getContextURI() ), m_attributes,
  @@ -157,8 +141,7 @@
        * @param uri a <code>String</code> pointing to an xmap URI
        * @exception Exception if an error occurs
        */
  -    protected void processXMAP( String uri ) throws Exception
  -    {
  +    protected void processXMAP( String uri ) throws Exception {
           String markupLanguage = "sitemap";
           String programmingLanguage = "java";
           Environment env = new LinkSamplingEnvironment( "/", new File(getContextURI()), m_attributes,
  @@ -176,8 +159,7 @@
        * @exception Exception if an error occurs
        */
       protected Collection getLinks( String deparameterizedURI, Map parameters )
  -            throws Exception
  -    {
  +            throws Exception {
   
           parameters.put( "user-agent", m_userAgent );
           parameters.put( "accept", m_accept );
  @@ -206,8 +188,7 @@
               Map links,
               List gatheredLinks,
               OutputStream stream )
  -            throws Exception
  -    {
  +            throws Exception {
   
           parameters.put( "user-agent", m_userAgent );
           parameters.put( "accept", m_accept );
  @@ -222,28 +203,19 @@
   
           // if we get here, the page was created :-)
           int status = env.getStatus();
  -        if ( !env.isModified() )
  -        {
  +        if ( !env.isModified() ) {
               status = -1;
           }
           return status;
       }
   
       /** Class <code>NullOutputStream</code> here. */
  -    static class NullOutputStream
  -            extends OutputStream
  -    {
  -        public void write( int b ) throws IOException
  -        {
  -        }
  +    static class NullOutputStream extends OutputStream {
  +        public void write( int b ) throws IOException {}
   
  -        public void write( byte b[] ) throws IOException
  -        {
  -        }
  +        public void write( byte b[] ) throws IOException {}
   
  -        public void write( byte b[], int off, int len ) throws IOException
  -        {
  -        }
  +        public void write( byte b[], int off, int len ) throws IOException {}
       }
   
       /**
  @@ -255,8 +227,7 @@
        * @exception Exception if an error occurs
        */
       protected String getType( String deparameterizedURI, Map parameters )
  -            throws Exception
  -    {
  +    throws Exception {
   
           parameters.put( "user-agent", m_userAgent );
           parameters.put( "accept", m_accept );
  @@ -276,14 +247,10 @@
        * @return boolean true if no error were cast, false otherwise
        * @exception Exception if an error occurs, except RNFE
        */
  -    private boolean processLenient( Environment env ) throws Exception
  -    {
  -        try
  -        {
  +    private boolean processLenient( Environment env ) throws Exception {
  +        try {
               getRootProcessor().process( env );
  -        }
  -        catch ( ProcessingException pe )
  -        {
  +        } catch ( ProcessingException pe ) {
               return false;
           }
           return true;
  
  
  

Mime
View raw message