vgritsenko 02/02/01 06:44:34
Modified: src/java/org/apache/cocoon/components/profiler
ProfilerGenerator.java
src/java/org/apache/cocoon/components/xscript
XScriptManagerImpl.java XScriptObject.java
Log:
XScriptManager supposed to be ThreadSafe - otherwise all this GLOBAL_SCOPE does not
make any sence
Revision Changes Path
1.2 +2 -1
xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilerGenerator.java
Index: ProfilerGenerator.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/profiler/ProfilerGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfilerGenerator.java 3 Jan 2002 12:31:12 -0000 1.1
+++ ProfilerGenerator.java 1 Feb 2002 14:44:34 -0000 1.2
@@ -26,7 +26,7 @@
* Generates an XML representation of the current status of Profiler.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a>
- * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:12 $
+ * @version CVS $Revision: 1.2 $ $Date: 2002/02/01 14:44:34 $
*/
public class ProfilerGenerator extends ComposerGenerator
implements Recyclable, Composable, Disposable {
@@ -56,6 +56,7 @@
super.manager.release(this.profiler);
this.profiler = null;
}
+ super.dispose();
}
/**
1.3 +31 -45
xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptManagerImpl.java
Index: XScriptManagerImpl.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptManagerImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XScriptManagerImpl.java 22 Jan 2002 00:17:12 -0000 1.2
+++ XScriptManagerImpl.java 1 Feb 2002 14:44:34 -0000 1.3
@@ -13,6 +13,7 @@
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.component.Component;
@@ -20,11 +21,6 @@
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.avalon.excalibur.pool.Poolable;
-
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.cocoon.components.xscript.XScriptObjectFromURL;
@@ -36,7 +32,7 @@
*/
public class XScriptManagerImpl
extends AbstractLoggable
- implements XScriptManager, Composable, Component, Configurable, Poolable
+ implements XScriptManager, Composable, Component, Parameterizable, ThreadSafe
{
/**
* The global scope. All the global variables are indexed in this
@@ -65,8 +61,7 @@
*/
protected ComponentManager manager = null;
- public void compose(ComponentManager manager)
- throws ComponentException
+ public void compose(ComponentManager manager) throws ComponentException
{
this.manager = manager;
getLogger().debug("XScriptManager component initialized.");
@@ -76,26 +71,17 @@
{
try {
object.compose(manager);
- }
- catch (ComponentException ex) {
+ } catch (ComponentException ex) {
}
}
- public void configure(Configuration conf)
- throws ConfigurationException
+ public void parameterize(Parameters params) throws ParameterException
{
- try {
- Parameters params = Parameters.fromConfiguration(conf);
- String[] names = params.getNames();
- for (int i = 0; i < names.length; i++) {
- String resourceString = params.getParameter(names[i]);
- XScriptObject resource = new XScriptObjectFromURL(this, resourceString);
- globalScope.put(names[i], resource);
- }
- }
- catch (ParameterException ex) {
- throw new ConfigurationException("Error configuring XScriptManager: ",
- ex);
+ String[] names = params.getNames();
+ for (int i = 0; i < names.length; i++) {
+ String resourceString = params.getParameter(names[i]);
+ XScriptObject resource = new XScriptObjectFromURL(this, resourceString);
+ globalScope.put(names[i], resource);
}
}
@@ -122,14 +108,13 @@
public XScriptObject get(String name, int scope, String context)
throws IllegalArgumentException
{
- if (scope == XScriptManager.GLOBAL_SCOPE)
+ if (scope == XScriptManager.GLOBAL_SCOPE) {
return globalScope.get(name);
- else if (scope == XScriptManager.SESSION_SCOPE) {
+ } else if (scope == XScriptManager.SESSION_SCOPE) {
XScriptVariableScope s = (XScriptVariableScope)sessionScope.get(context);
if (s != null)
return s.get(name);
- }
- else if (scope == XScriptManager.PAGE_SCOPE) {
+ } else if (scope == XScriptManager.PAGE_SCOPE) {
XScriptVariableScope s = (XScriptVariableScope)pageScope.get(context);
if (s != null)
return s.get(name);
@@ -149,8 +134,9 @@
scope = (XScriptVariableScope)sessionScope.get(sessionContext);
if (scope != null) {
synchronized(scope) {
- if (scope.defines(name))
+ if (scope.defines(name)) {
return scope.get(name);
+ }
}
}
@@ -158,15 +144,17 @@
scope = (XScriptVariableScope)pageScope.get(pageContext);
if (scope != null) {
synchronized(scope) {
- if (scope.defines(name))
+ if (scope.defines(name)) {
return scope.get(name);
+ }
}
}
// No luck finding `name' in the page scope, try the global scope.
synchronized(globalScope) {
- if (globalScope.defines(name))
+ if (globalScope.defines(name)) {
return globalScope.get(name);
+ }
}
// No variable `name' found, throw an exception.
@@ -178,25 +166,23 @@
{
if (scope == XScriptManager.GLOBAL_SCOPE) {
globalScope.put(name, value);
- }
- else if (scope == XScriptManager.SESSION_SCOPE) {
+ } else if (scope == XScriptManager.SESSION_SCOPE) {
XScriptVariableScope s = (XScriptVariableScope)sessionScope.get(context);
if (s == null) {
s = new XScriptVariableScope();
sessionScope.put(context, s);
}
s.put(name, value);
- }
- else if (scope == XScriptManager.PAGE_SCOPE) {
+ } else if (scope == XScriptManager.PAGE_SCOPE) {
XScriptVariableScope s = (XScriptVariableScope)pageScope.get(context);
if (s == null) {
s = new XScriptVariableScope();
pageScope.put(context, s);
}
s.put(name, value);
- }
- else
+ } else {
throw createAccessException("create", name, scope, context);
+ }
}
public void remove(String name, int scope, String context)
@@ -204,19 +190,19 @@
{
if (scope == XScriptManager.GLOBAL_SCOPE) {
globalScope.remove(name);
- }
- else if (scope == XScriptManager.SESSION_SCOPE) {
+ } else if (scope == XScriptManager.SESSION_SCOPE) {
XScriptVariableScope s = (XScriptVariableScope)sessionScope.get(context);
- if (s != null)
+ if (s != null) {
s.remove(name);
- }
- else if (scope == XScriptManager.PAGE_SCOPE) {
+ }
+ } else if (scope == XScriptManager.PAGE_SCOPE) {
XScriptVariableScope s = (XScriptVariableScope)pageScope.get(context);
- if (s != null)
+ if (s != null) {
s.remove(name);
- }
- else
+ }
+ } else {
throw createAccessException("remove", name, scope, context);
+ }
}
public void removeFirst(String name,
1.3 +1 -1
xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptObject.java
Index: XScriptObject.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/xscript/XScriptObject.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XScriptObject.java 25 Jan 2002 03:41:13 -0000 1.2
+++ XScriptObject.java 1 Feb 2002 14:44:34 -0000 1.3
@@ -92,7 +92,7 @@
transformer.transform(this, stylesheet, params, result);
- componentManager.release((Component)transformer);
+ componentManager.release(transformer);
return new XScriptObjectResult(xscriptManager, writer.toString());
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]