Skip to content

Commit

Permalink
Use settings
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/cocoon/trunk@429305 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cziegeler committed Aug 7, 2006
1 parent e1341b8 commit 701cfc4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@
package org.apache.cocoon.generation;

import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;

import org.apache.cocoon.Constants;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.search.LuceneCocoonHelper;
import org.apache.cocoon.components.search.LuceneCocoonPager;
import org.apache.cocoon.components.search.LuceneCocoonSearcher;
import org.apache.cocoon.components.search.LuceneXMLIndexer;
import org.apache.cocoon.configuration.Settings;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
Expand Down Expand Up @@ -92,7 +89,7 @@
* @version $Id$
*/
public class SearchGenerator extends ServiceableGenerator
implements Contextualizable, Disposable
implements Disposable
{

/**
Expand Down Expand Up @@ -411,6 +408,11 @@ public class SearchGenerator extends ServiceableGenerator
*/
public void service(ServiceManager manager) throws ServiceException {
super.service(manager);
// If the index directory is specified relativly, the working directory is
// used as home directory of the index directory.
final Settings settings = (Settings)this.manager.lookup(Settings.ROLE);
this.workDir = new File(settings.getWorkDirectory());
this.manager.release(settings);
}

/**
Expand Down Expand Up @@ -481,25 +483,6 @@ public void setup(SourceResolver resolver, Map objectModel, String src, Paramete
}
}


/**
* Contextualize this class.
*
* <p>
* Especially retrieve the work directory.
* If the index directory is specified relativly, the working directory is
* used as home directory of the index directory.
* </p>
*
* @param context Context to use
* @exception ContextException If contextualizing fails.
* @since
*/
public void contextualize(Context context) throws ContextException {
// retrieve the working directory, assuming that the index may reside there
workDir = (File) context.get(Constants.CONTEXT_WORK_DIR);
}

/**
* Generate xml content describing search results.
* Entry point of the ComposerGenerator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@
import java.net.MalformedURLException;
import java.net.URL;

import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.Constants;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.search.LuceneCocoonHelper;
import org.apache.cocoon.components.search.LuceneCocoonIndexer;
import org.apache.cocoon.configuration.Settings;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.store.Directory;

Expand All @@ -39,23 +36,19 @@
* @version $Id$
*/
public class LuceneUtil
implements Contextualizable, Serviceable {
implements Serviceable {

private File workDir;
private ServiceManager manager;

/* (non-Javadoc)
* @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
*/
public void contextualize(Context context) throws ContextException {
this.workDir = (File) context.get(Constants.CONTEXT_WORK_DIR);
}

/* (non-Javadoc)
/**
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void service(ServiceManager manager) throws ServiceException {
this.manager = manager;
final Settings settings = (Settings)this.manager.lookup(Settings.ROLE);
this.workDir = new File(settings.getWorkDirectory());
this.manager.release(settings);
}

public void createIndex(String baseURL, boolean create)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;

import org.apache.cocoon.Constants;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.components.search.LuceneCocoonHelper;
import org.apache.cocoon.components.search.LuceneXMLIndexer;
import org.apache.cocoon.configuration.Settings;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.commons.lang.BooleanUtils;
import org.apache.excalibur.source.SourceValidity;
Expand Down Expand Up @@ -109,7 +109,7 @@
* @version $Id$
*/
public class LuceneIndexTransformer extends AbstractTransformer
implements CacheableProcessingComponent, Configurable, Contextualizable {
implements CacheableProcessingComponent, Configurable, Serviceable {

public static final String ANALYZER_CLASSNAME_CONFIG = "analyzer-classname";
public static final String ANALYZER_CLASSNAME_PARAMETER = "analyzer-classname";
Expand Down Expand Up @@ -210,12 +210,17 @@ public void setup(SourceResolver resolver, Map objectModel, String src, Paramete
}

/**
* Contextualize this class
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void contextualize(Context context) throws ContextException {
this.workDir = (File) context.get(Constants.CONTEXT_WORK_DIR);
public void service(ServiceManager manager) throws ServiceException {
final Settings settings = (Settings)manager.lookup(Settings.ROLE);
this.workDir = new File(settings.getWorkDirectory());
manager.release(settings);
}

/**
* @see org.apache.cocoon.xml.AbstractXMLProducer#recycle()
*/
public void recycle() {
this.processing = STATE_GROUND;
if (this.writer != null) {
Expand Down

0 comments on commit 701cfc4

Please sign in to comment.