| Method from org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor Detail: |
public ProcessingPipeline buildPipeline(Environment environment) throws Exception {
InvokeContext context = new InvokeContext(true);
context.enableLogging(getLogger());
try {
if (process(environment, context)) {
return context.getProcessingPipeline();
} else {
return null;
}
} finally {
context.dispose();
}
}
Process the given Environment to assemble
a ProcessingPipeline. |
public void dispose() {
if (this.disposableNodes != null) {
// we must dispose the nodes in reverse order
// otherwise selector nodes are freed before the components node
for(int i=this.disposableNodes.size()-1; i >-1; i--) {
((Disposable)disposableNodes.get(i)).dispose();
}
this.disposableNodes = null;
}
// Ensure it won't be used anymore
this.rootNode = null;
}
|
public Map getComponentConfigurations() {
// do we have the sitemap configurations prepared for this processor?
if ( null == this.sitemapComponentConfigurations ) {
synchronized (this) {
if ( this.sitemapComponentConfigurations == null ) {
// do we have configurations?
final Configuration[] childs = (this.componentConfigurations == null
? null
: this.componentConfigurations.getChildren());
if ( null != childs ) {
if ( null == this.wrappingProcessor.parent ) {
this.sitemapComponentConfigurations = new HashMap(12);
} else {
// copy all configurations from parent
this.sitemapComponentConfigurations = new HashMap(
this.wrappingProcessor.parent.getComponentConfigurations());
}
// and now check for new configurations
for(int m = 0; m < childs.length; m++) {
final String r = this.wrappingProcessor.roleManager.getRoleForName(childs[m].getName());
this.sitemapComponentConfigurations.put(r, new ChainedConfiguration(childs[m],
(ChainedConfiguration)this.sitemapComponentConfigurations.get(r)));
}
} else {
// we don't have configurations
if ( null == this.wrappingProcessor.parent ) {
this.sitemapComponentConfigurations = Collections.EMPTY_MAP;
} else {
// use configuration from parent
this.sitemapComponentConfigurations = this.wrappingProcessor.parent.getComponentConfigurations();
}
}
}
}
}
return this.sitemapComponentConfigurations;
}
Get the sitemap component configurations |
public Processor getRootProcessor() {
return this.wrappingProcessor.getRootProcessor();
}
|
public TreeProcessor getWrappingProcessor() {
return this.wrappingProcessor;
}
|
public void markForDisposal() {
// Decrement the request count (negative number means dispose)
synchronized(this) {
this.requestCount--;
}
if (this.requestCount < 0) {
// No more users : dispose right now
dispose();
}
}
Mark this processor as needing to be disposed. Actual call to #dispose() will occur when
all request processings on this processor will be terminated. |
public boolean process(Environment environment) throws Exception {
InvokeContext context = new InvokeContext();
context.enableLogging(getLogger());
try {
return process(environment, context);
} finally {
context.dispose();
}
}
Process the given Environment producing the output. |
protected boolean process(Environment environment,
InvokeContext context) throws Exception {
// Increment the concurrent requests count
synchronized(this) {
requestCount++;
}
try {
// and now process
CocoonComponentManager.enterEnvironment(environment, this.sitemapComponentManager, this);
Map objectModel = environment.getObjectModel();
Object oldResolver = objectModel.get(ProcessingNode.OBJECT_SOURCE_RESOLVER);
final Redirector oldRedirector = context.getRedirector();
// Build a redirector
TreeProcessorRedirector redirector = new TreeProcessorRedirector(environment, context);
setupLogger(redirector);
context.setRedirector(redirector);
objectModel.put(ProcessingNode.OBJECT_SOURCE_RESOLVER, environment);
boolean success = false;
try {
success = this.rootNode.invoke(environment, context);
return success;
} finally {
CocoonComponentManager.leaveEnvironment(success);
// Restore old redirector and resolver
context.setRedirector(oldRedirector);
objectModel.put(ProcessingNode.OBJECT_SOURCE_RESOLVER, oldResolver);
}
} finally {
// Decrement the concurrent request count
synchronized(this) {
requestCount--;
}
if(requestCount < 0) {
// Marked for disposal and no more concurrent requests.
dispose();
}
}
}
Do the actual processing, be it producing the response or just building the pipeline |
public void setComponentConfigurations(Configuration componentConfigurations) {
this.componentConfigurations = componentConfigurations;
this.sitemapComponentConfigurations = null;
}
Set the sitemap component configurations (called as part of the tree building process) |
public void setProcessorData(ComponentManager manager,
ProcessingNode rootNode,
List disposableNodes) {
if (this.sitemapComponentManager != null) {
throw new IllegalStateException("setProcessorData() can only be called once");
}
this.sitemapComponentManager = manager;
this.rootNode = rootNode;
this.disposableNodes = disposableNodes;
}
Set the processor data, result of the treebuilder job |
public String toString() {
return "ConcreteTreeProcessor - " + wrappingProcessor.source.getURI();
}
|