cziegeler 2004/05/26 01:39:49
Modified:
src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components
PortalManagerImpl.java PortalManager.java
CopletThread.java
src/java/org/apache/cocoon/components ContextHelper.java
src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/generation
PortalGenerator.java
src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/context
SessionContextImpl.java
SessionContextProviderImpl.java
Log:
Remvoe the use of Recomposable, move to Serviceable. Code cleanup
Revision Changes Path
1.8 +55 -66
cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/PortalManagerImpl.java
Index: PortalManagerImpl.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/PortalManagerImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PortalManagerImpl.java 26 May 2004 01:55:30 -0000 1.7
+++ PortalManagerImpl.java 26 May 2004 08:39:49 -0000 1.8
@@ -26,16 +26,15 @@
import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.Component;
-import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.component.Composable;
-import org.apache.avalon.framework.component.Recomposable;
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.logger.AbstractLogEnabled;
+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.ProcessingException;
import org.apache.cocoon.components.ContextHelper;
import org.apache.cocoon.components.sax.XMLDeserializer;
@@ -82,7 +81,7 @@
*/
public final class PortalManagerImpl
extends AbstractLogEnabled
-implements Disposable, Composable, Recomposable, Recyclable,
Contextualizable, Component, PortalManager {
+implements Disposable, Serviceable, Recyclable, Contextualizable, Component,
PortalManager {
/** The cache (store) for the profiles */
private Store profileStore;
@@ -105,8 +104,8 @@
/** The transaction manager */
private TransactionManager transactionManager;
- /** The component manager */
- protected ComponentManager manager;
+ /** The service manager */
+ protected ServiceManager manager;
/** The current source resolver */
protected SourceResolver resolver;
@@ -122,12 +121,12 @@
*/
public void recycle() {
if (this.manager != null) {
- this.manager.release(this.profileStore);
- this.manager.release( (Component)this.authenticationManager);
- this.manager.release( (Component)this.mediaManager);
- this.manager.release( (Component)this.sessionManager);
- this.manager.release( (Component)this.contextManager);
- this.manager.release( (Component)this.transactionManager);
+ this.manager.release( this.profileStore );
+ this.manager.release( this.authenticationManager);
+ this.manager.release( this.mediaManager);
+ this.manager.release( this.sessionManager);
+ this.manager.release( this.contextManager);
+ this.manager.release( this.transactionManager);
this.profileStore = null;
this.authenticationManager = null;
this.mediaManager = null;
@@ -146,37 +145,30 @@
try {
authManager =
(AuthenticationManager)this.manager.lookup(AuthenticationManager.ROLE);
return authManager.getState();
- } catch (ComponentException ce) {
+ } catch (ServiceException ce) {
// ignore this here
return null;
} finally {
- this.manager.release( (Component)authManager );
+ this.manager.release( authManager );
}
}
/* (non-Javadoc)
- * @see
org.apache.avalon.framework.component.Composable#compose(org.apache.avalon.framework.component.ComponentManager)
+ * @see
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
- public void compose(ComponentManager manager)
- throws ComponentException {
+ public void service(ServiceManager manager)
+ throws ServiceException {
this.manager = manager;
this.resolver = (SourceResolver)manager.lookup(SourceResolver.ROLE);
this.xpathProcessor =
(XPathProcessor)this.manager.lookup(XPathProcessor.ROLE);
}
/* (non-Javadoc)
- * @see
org.apache.avalon.framework.component.Recomposable#recompose(org.apache.avalon.framework.component.ComponentManager)
- */
- public void recompose(ComponentManager manager) throws
ComponentException {
- this.manager = manager;
- }
-
- /* (non-Javadoc)
* @see org.apache.avalon.framework.activity.Disposable#dispose()
*/
public void dispose() {
if ( this.manager != null ) {
- this.manager.release( (Component)this.xpathProcessor );
+ this.manager.release( this.xpathProcessor );
this.xpathProcessor = null;
this.manager.release( this.resolver );
this.resolver = null;
@@ -198,7 +190,7 @@
if (this.profileStore == null) {
try {
this.profileStore = (Store)this.manager.lookup(Store.ROLE);
- } catch (ComponentException ce) {
+ } catch (ServiceException ce) {
throw new ProcessingException("Error during lookup of store
component.", ce);
}
}
@@ -213,7 +205,7 @@
if (this.authenticationManager == null) {
try {
this.authenticationManager =
(AuthenticationManager)this.manager.lookup(AuthenticationManager.ROLE);
- } catch (ComponentException ce) {
+ } catch (ServiceException ce) {
throw new ProcessingException("Error during lookup of
AuthenticationManager.", ce);
}
}
@@ -228,7 +220,7 @@
if (this.mediaManager == null) {
try {
this.mediaManager =
(MediaManager)this.manager.lookup(MediaManager.ROLE);
- } catch (ComponentException ce) {
+ } catch (ServiceException ce) {
throw new ProcessingException("Error during lookup of
MediaManager.", ce);
}
}
@@ -255,8 +247,6 @@
this.changeProfile();
} catch (SAXException se) {
throw new ProcessingException(se);
- } catch (IOException ioe) {
- throw new ProcessingException(ioe);
}
}
@@ -268,7 +258,7 @@
* @see
org.apache.cocoon.webapps.portal.components.PortalManager#configurationTest()
*/
public void configurationTest()
- throws ProcessingException, IOException, SAXException {
+ throws ProcessingException {
// no sync required
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("BEGIN configurationTest");
@@ -288,7 +278,7 @@
* @see
org.apache.cocoon.webapps.portal.components.PortalManager#getContext(boolean)
*/
public SessionContext getContext(boolean create)
- throws ProcessingException, IOException, SAXException {
+ throws ProcessingException {
// synchronized
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("BEGIN getContext create="+create);
@@ -329,7 +319,7 @@
String profileID,
String media,
String contextID)
- throws IOException, SAXException, ProcessingException {
+ throws SAXException, ProcessingException {
// synchronized not req.
this.setup();
Response response = ContextHelper.getResponse(this.componentContext);
@@ -547,18 +537,17 @@
if (saveResource == null) {
throw new ProcessingException("portal: No save
resource defined for type coplet-base.");
- } else {
+ }
- SourceUtil.writeDOM(saveResource,
- null,
- pars,
- copletsFragment,
- this.resolver,
- "xml");
+ SourceUtil.writeDOM(saveResource,
+ null,
+ pars,
+ copletsFragment,
+ this.resolver,
+ "xml");
- // now the hardest part, clean up the whole cache
- this.cleanUpCache(null, null, configuration);
- }
+ // now the hardest part, clean up the whole cache
+ this.cleanUpCache(null, null, configuration);
}
} finally {
this.getTransactionManager().stopWritingTransaction(context);
@@ -725,7 +714,7 @@
* @see
org.apache.cocoon.webapps.portal.components.PortalManager#getStatusProfile()
*/
public Element getStatusProfile()
- throws SAXException, IOException, ProcessingException {
+ throws ProcessingException {
// synchronized
if (this.getLogger().isDebugEnabled() ) {
this.getLogger().debug("BEGIN getStatusProfile");
@@ -748,6 +737,7 @@
try {
statusProfile = (Element)DOMUtil.getSingleNode(profile,
"profile/status-profile", this.xpathProcessor);
} catch (javax.xml.transform.TransformerException ignore) {
+ // ignore
}
}
@@ -763,7 +753,7 @@
public void showPortal(XMLConsumer consumer,
boolean configMode,
boolean adminProfile)
- throws SAXException, ProcessingException, IOException {
+ throws SAXException, ProcessingException {
// synchronized
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("BEGIN showPortal consumer=" +
consumer+", configMode="+
@@ -879,7 +869,7 @@
SessionContext context,
Map storedProfile,
String profileID)
- throws SAXException, ProcessingException, IOException {
+ throws SAXException, ProcessingException {
// synchronized
if (this.getLogger().isDebugEnabled() ) {
this.getLogger().debug("BEGIN showPortal consumer=" +
consumer+", configMode="+configMode+", context="+context+
@@ -1174,7 +1164,7 @@
String role,
String id,
boolean adminProfile)
- throws ProcessingException, IOException, SAXException {
+ throws ProcessingException {
// synchronized
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("BEGIN buildProfile type=" + type + ",
role=" + role + ", id=" +id+", adminProfile="+adminProfile);
@@ -1359,7 +1349,7 @@
String role,
String id,
boolean adminProfile)
- throws SAXException, ProcessingException, IOException,
javax.xml.transform.TransformerException {
+ throws SAXException, ProcessingException,
javax.xml.transform.TransformerException {
// calling method must be synchronized
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("END buildProfileDeltaN type="+type+",
role="+role+", id="+id);
@@ -1649,14 +1639,13 @@
int pos = profileID.indexOf('_');
if (pos == -1) {
return null;
- } else {
- String lastPart = profileID.substring(pos+1);
- pos = lastPart.indexOf('_');
- if (pos == -1) return null;
- int len = new Integer(lastPart.substring(0, pos)).intValue();
- lastPart = lastPart.substring(pos+1, pos+1+len);
- return lastPart;
- }
+ }
+ String lastPart = profileID.substring(pos+1);
+ pos = lastPart.indexOf('_');
+ if (pos == -1) return null;
+ int len = new Integer(lastPart.substring(0, pos)).intValue();
+ lastPart = lastPart.substring(pos+1, pos+1+len);
+ return lastPart;
}
/**
@@ -2790,7 +2779,7 @@
ContextHelper.getObjectModel(this.componentContext),
this.getLogger(),
loadedCoplet,
- this.manager,
+
ContextHelper.getSitemapServiceManager(this.componentContext),
this.resolver,
this.xpathProcessor);
theThread.start();
@@ -2908,7 +2897,7 @@
interpreter =
(XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE);
interpreter.setConsumer(new
IncludeXMLConsumer(consumer, consumer));
interpreter.deserialize(content);
- } catch (ComponentException e) {
+ } catch (ServiceException e) {
throw new ProcessingException("Component for
XMLDeserializer not found." + e, e);
} finally {
if (interpreter != null)
this.manager.release(interpreter);
@@ -3235,7 +3224,7 @@
* @see
org.apache.cocoon.webapps.portal.components.PortalManager#checkAuthentication(org.apache.cocoon.environment.Redirector,
java.lang.String)
*/
public boolean checkAuthentication(Redirector redirector, String
copletID)
- throws SAXException, IOException, ProcessingException {
+ throws IOException, ProcessingException {
// synchronized
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("BEGIN checkAuthentication
coplet="+copletID);
@@ -3469,7 +3458,7 @@
String role,
String id,
boolean adminProfile)
- throws SAXException, IOException, ProcessingException {
+ throws ProcessingException {
// no sync required
if (this.getLogger().isDebugEnabled() ) {
this.getLogger().debug("BEGIN createProfile context="+context+
@@ -3891,7 +3880,7 @@
* Change the profile according to the request parameter
*/
private void changeProfile()
- throws ProcessingException, SAXException, IOException {
+ throws ProcessingException, SAXException {
// synchronized
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("BEGIN changeProfile");
@@ -4300,7 +4289,7 @@
if (this.sessionManager == null) {
try {
this.sessionManager =
(SessionManager)this.manager.lookup(SessionManager.ROLE);
- } catch (ComponentException ce) {
+ } catch (ServiceException ce) {
throw new ProcessingException("Error during lookup of
SessionManager component.", ce);
}
}
@@ -4315,7 +4304,7 @@
if (this.contextManager == null) {
try {
this.contextManager =
(ContextManager)this.manager.lookup(ContextManager.ROLE);
- } catch (ComponentException ce) {
+ } catch (ServiceException ce) {
throw new ProcessingException("Error during lookup of
ContextManager component.", ce);
}
}
@@ -4330,7 +4319,7 @@
if (this.transactionManager == null) {
try {
this.transactionManager =
(TransactionManager)this.manager.lookup(TransactionManager.ROLE);
- } catch (ComponentException ce) {
+ } catch (ServiceException ce) {
throw new ProcessingException("Error during lookup of
TransactionManager component.", ce);
}
}
1.14 +7 -7
cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/PortalManager.java
Index: PortalManager.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/PortalManager.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- PortalManager.java 5 Mar 2004 13:02:18 -0000 1.13
+++ PortalManager.java 26 May 2004 08:39:49 -0000 1.14
@@ -92,7 +92,7 @@
* This is only a public wrapper for the getConfiguration method.
*/
void configurationTest()
- throws ProcessingException, IOException, SAXException;
+ throws ProcessingException;
/**
* Include Portal URI into stream
@@ -102,7 +102,7 @@
String profileID,
String media,
String contextID)
- throws IOException, SAXException, ProcessingException;
+ throws SAXException, ProcessingException;
/**
* Show the admin configuration page.
@@ -114,7 +114,7 @@
* Get the status profile
*/
Element getStatusProfile()
- throws SAXException, IOException, ProcessingException;
+ throws ProcessingException;
/**
* Show the portal.
@@ -123,13 +123,13 @@
void showPortal(XMLConsumer consumer,
boolean configMode,
boolean adminProfile)
- throws SAXException, ProcessingException, IOException;
+ throws SAXException, ProcessingException;
/**
* Check the authentication for the coplet. If it is not available do a
redirect
*/
boolean checkAuthentication(Redirector redirector, String copletID)
- throws SAXException, IOException, ProcessingException;
+ throws IOException, ProcessingException;
/**
* Get the current media type
@@ -141,7 +141,7 @@
* Get the portal context of the current application
*/
SessionContext getContext(boolean create)
- throws ProcessingException, IOException, SAXException;
+ throws ProcessingException;
/**
* Builds the key for caching
1.8 +28 -29
cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/CopletThread.java
Index: CopletThread.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/components/CopletThread.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CopletThread.java 19 Mar 2004 14:16:54 -0000 1.7
+++ CopletThread.java 26 May 2004 08:39:49 -0000 1.8
@@ -22,9 +22,8 @@
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.sax.TransformerHandler;
-import org.apache.avalon.framework.component.Component;
-import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.components.sax.XMLSerializer;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.environment.ObjectModelHelper;
@@ -54,13 +53,13 @@
*/
public final class CopletThread implements Runnable {
- private Logger logger;
- private String copletID;
- private Map objectModel;
- private Object[] loadedCoplet;
- private ComponentManager manager;
- private SourceResolver resolver;
- private XPathProcessor processor;
+ private Logger logger;
+ private String copletID;
+ private Map objectModel;
+ private Object[] loadedCoplet;
+ private ServiceManager manager;
+ private SourceResolver resolver;
+ private XPathProcessor processor;
/**
* Initialise all instance variables.
@@ -79,7 +78,7 @@
Map objectModel,
Logger logger,
Object[] loadedCoplet,
- ComponentManager manager,
+ ServiceManager manager,
SourceResolver resolver,
XPathProcessor processor) {
this.copletID = copletID;
@@ -97,7 +96,7 @@
public void run() {
XMLSerializer compiler = null;
Element copletConf = (Element)this.loadedCoplet[1];
- SourceParameters p = (SourceParameters)loadedCoplet[2];
+ SourceParameters p = (SourceParameters)this.loadedCoplet[2];
try {
// Determine the resource to load
@@ -119,7 +118,7 @@
if (!handlesSizable && !p.getParameter("size",
"max").equals("max")) {
// do nothing here
- loadedCoplet[0] = new byte[0];
+ this.loadedCoplet[0] = new byte[0];
} else {
compiler =
(XMLSerializer)this.manager.lookup(XMLSerializer.ROLE);
@@ -161,33 +160,33 @@
includeFragment = size.equals("max");
if (!includeFragment) {
if (this.logger.isWarnEnabled()) {
- this.logger.warn("Minimized coplet
'"+copletID+"' not handled correctly.");
+ this.logger.warn("Minimized coplet
'"+this.copletID+"' not handled correctly.");
}
}
if ( includeFragment ) {
if (this.logger.isDebugEnabled() ) {
- this.logger.debug("portal: Loading coplet " +
copletID);
+ this.logger.debug("portal: Loading coplet " +
this.copletID);
}
// add the parameters to the request attributes
Map info = new HashMap(3);
SessionContextImpl.copletInfo.set(info);
info.put(PortalConstants.COPLETINFO_PARAMETERS, p);
info.put(PortalConstants.COPLETINFO_PORTALURI,
request.getRequestURI());
- info.put(PortalConstants.COPLETINFO_STATUSPROFILE,
loadedCoplet[7]);
+ info.put(PortalConstants.COPLETINFO_STATUSPROFILE,
this.loadedCoplet[7]);
XMLConsumer xc = new
IncludeXMLConsumer(nextConsumer);
Source source = null;
try {
source = SourceUtil.getSource(resource,
null,
(handlesParameters
? p : null),
- resolver);
+ this.resolver);
SourceUtil.toSAX(source, xc);
} finally {
- resolver.release(source);
+ this.resolver.release(source);
}
if (this.logger.isDebugEnabled()) {
- this.logger.debug("portal: Loaded coplet " +
copletID);
+ this.logger.debug("portal: Loaded coplet " +
this.copletID);
}
}
if ( stylesheet != null ) {
@@ -197,36 +196,36 @@
SessionContextImpl.copletInfo.set(null);
if ( transformers != null ) {
for(int i=0; i < transformers.size(); i++) {
- this.manager.release(
(Component)transformers.get(i));
+ this.manager.release( transformers.get(i));
this.resolver.release( (Source)sources.get(i));
}
}
}
nextConsumer = null;
compiler.endDocument();
- loadedCoplet[0] = compiler.getSAXFragment();
+ this.loadedCoplet[0] = compiler.getSAXFragment();
}
} catch (Exception local) {
// this exception is ignored and an error message is included
// later on when the coplet is processed
- this.logger.error("Exception during processing of coplet: " +
copletID, local);
+ this.logger.error("Exception during processing of coplet: " +
this.copletID, local);
} catch (Throwable local) {
// this exception is ignored and an error message is included
// later on when the coplet is processed
- this.logger.error("Exception during processing of coplet: " +
copletID, local);
+ this.logger.error("Exception during processing of coplet: " +
this.copletID, local);
} finally {
if (compiler != null) {
this.manager.release(compiler);
}
}
- loadedCoplet[6] = null;
- copletID = null;
+ this.loadedCoplet[6] = null;
+ this.copletID = null;
copletConf = null;
this.logger = null;
- objectModel = null;
+ this.objectModel = null;
p = null;
- loadedCoplet = null;
- manager = null;
- resolver = null;
+ this.loadedCoplet = null;
+ this.manager = null;
+ this.resolver = null;
} // END run
} // END CLASS
1.8 +32 -1
cocoon-2.1/src/java/org/apache/cocoon/components/ContextHelper.java
Index: ContextHelper.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/ContextHelper.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ContextHelper.java 25 May 2004 07:28:25 -0000 1.7
+++ ContextHelper.java 26 May 2004 08:39:49 -0000 1.8
@@ -20,6 +20,7 @@
import org.apache.avalon.framework.CascadingRuntimeException;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Response;
@@ -53,6 +54,11 @@
// Forbid instantiation
}
+ /**
+ * Return the current request
+ * @param context The component context
+ * @return The request object
+ */
public static final Request getRequest(Context context) {
// the request object is always present
try {
@@ -62,6 +68,11 @@
}
}
+ /**
+ * Return the current response
+ * @param context The component context
+ * @return The response
+ */
public static final Response getResponse(Context context) {
// the response object is always present
try {
@@ -71,6 +82,11 @@
}
}
+ /**
+ * Return the current object model
+ * @param context The component context
+ * @return The object model
+ */
public static final Map getObjectModel(Context context) {
// the object model is always present
try {
@@ -78,5 +94,20 @@
} catch (ContextException ce) {
throw new CascadingRuntimeException("Unable to get the object
model from the context.", ce);
}
+ }
+
+ /**
+ * Return the current sitemap service manager
+ * @param context The component context
+ * @return The sitemap manager if currently a request is processed
+ * @since 2.2
+ */
+ public static final ServiceManager getSitemapServiceManager(Context
context) {
+ // the service manager is always present
+ try {
+ return
(ServiceManager)context.get(CONTEXT_SITEMAP_SERVICE_MANAGER);
+ } catch (ContextException ce) {
+ throw new CascadingRuntimeException("Unable to get the service
manager from the context.", ce);
+ }
}
}
1.7 +4 -1
cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/generation/PortalGenerator.java
Index: PortalGenerator.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/generation/PortalGenerator.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PortalGenerator.java 5 Mar 2004 13:02:18 -0000 1.6
+++ PortalGenerator.java 26 May 2004 08:39:49 -0000 1.7
@@ -35,6 +35,9 @@
public final class PortalGenerator
extends ServiceableGenerator {
+ /* (non-Javadoc)
+ * @see org.apache.cocoon.generation.Generator#generate()
+ */
public void generate()
throws IOException, SAXException, ProcessingException {
1.10 +50 -53
cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/context/SessionContextImpl.java
Index: SessionContextImpl.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/context/SessionContextImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- SessionContextImpl.java 19 Mar 2004 14:16:55 -0000 1.9
+++ SessionContextImpl.java 26 May 2004 08:39:49 -0000 1.10
@@ -42,6 +42,12 @@
import java.util.Map;
/**
+ * @author CZiegeler
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+/**
* The portal context
*
* This context allows access to various parts of a portal profile.
@@ -115,7 +121,7 @@
Map objectModel,
PortalManager portal,
XPathProcessor xpathProcessor)
- throws IOException, SAXException, ProcessingException {
+ throws ProcessingException {
this.xpathProcessor = xpathProcessor;
this.setup(name, null, null);
@@ -135,7 +141,7 @@
}
this.statusProfile =
(Element)info.get(PortalConstants.COPLETINFO_STATUSPROFILE);
}
- this.mediaType = (this.copletPars != null ?
(String)copletPars.getParameter(PortalConstants.PARAMETER_MEDIA)
+ this.mediaType = (this.copletPars != null ?
(String)this.copletPars.getParameter(PortalConstants.PARAMETER_MEDIA)
: portal.getMediaType());
// get the profile
@@ -187,12 +193,12 @@
* Get the configuration DOM
*/
private void getConfigurationDOM(PortalManager portal)
- throws ProcessingException, IOException {
+ throws ProcessingException {
if (this.configurationDOM == null && portal != null) {
try {
String contextID = null;
if (this.copletID != null && this.copletNumber != null) {
- contextID = "coplet_"+copletID+"_"+copletNumber;
+ contextID =
"coplet_"+this.copletID+"_"+this.copletNumber;
}
DOMBuilder builder = new DOMBuilder();
builder.startDocument();
@@ -209,13 +215,15 @@
}
}
- /* Set the context name */
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#setup(java.lang.String,
java.lang.String, java.lang.String)
+ */
public void setup(String value, String load, String save) {
- name = value;
+ this.name = value;
}
- /**
- * Get the xml fragment
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#getXML(java.lang.String)
*/
public synchronized DocumentFragment getXML(String path)
throws ProcessingException {
@@ -237,7 +245,7 @@
if (this.statusProfile != null) {
if (this.copletID != null && this.copletNumber != null) {
- String statusPath = "customization/[EMAIL
PROTECTED]'"+copletID+"' and @number='"+copletNumber+"']";
+ String statusPath = "customization/[EMAIL
PROTECTED]'"+this.copletID+"' and @number='"+this.copletNumber+"']";
try {
Node node =
DOMUtil.getSingleNode(this.statusProfile, statusPath, this.xpathProcessor);
if (node != null) {
@@ -278,7 +286,7 @@
if (this.statusProfile != null) {
if (this.copletID != null && this.copletNumber != null) {
- String statusPath = "customization/[EMAIL
PROTECTED]'"+copletID+"' and @number='"+copletNumber+"']";
+ String statusPath = "customization/[EMAIL
PROTECTED]'"+this.copletID+"' and @number='"+this.copletNumber+"']";
if (path.startsWith("coplet-data/")) {
statusPath = statusPath + path.substring(11);
}
@@ -329,7 +337,7 @@
if (this.statusProfile != null) {
if (this.copletID != null && this.copletNumber != null) {
- String statusPath = "customization/[EMAIL
PROTECTED]'"+copletID+"' and @number='"+copletNumber+"']";
+ String statusPath = "customization/[EMAIL
PROTECTED]'"+this.copletID+"' and @number='"+this.copletNumber+"']";
if (path.startsWith("coplet-data/")) {
statusPath = statusPath + path.substring(11);
}
@@ -366,28 +374,24 @@
}
- /**
- * Append a document fragment at the given path. The implementation of
this
- * method is context specific.
- * Usually the children of the fragment are appended as new children of
the
- * node specified by the path.
- * If the path is not existent it is created.
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#appendXML(java.lang.String,
org.w3c.dom.DocumentFragment)
*/
public synchronized void appendXML(String path, DocumentFragment
fragment)
throws ProcessingException {
throw new ProcessingException("appendXML() not implemented.");
}
- /**
- * Remove nodes
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#removeXML(java.lang.String)
*/
public synchronized void removeXML(String path)
throws ProcessingException {
throw new ProcessingException("removeXML() not implemented.");
}
- /**
- * Get a copy the first node specified by the path.
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#getSingleNode(java.lang.String)
*/
public synchronized Node getSingleNode(String path)
throws ProcessingException {
@@ -396,8 +400,8 @@
// return result;
}
- /**
- * Get a copy all the nodes specified by the path.
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#getNodeList(java.lang.String)
*/
public synchronized NodeList getNodeList(String path)
throws ProcessingException {
@@ -406,8 +410,8 @@
// return result;
}
- /**
- * Set the value of a node. The node is copied before insertion.
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#setNode(java.lang.String,
org.w3c.dom.Node)
*/
public synchronized void setNode(String path, Node node)
throws ProcessingException {
@@ -415,36 +419,35 @@
}
- /**
- * Set a context attribute. If value is null the attribute is removed.
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#setAttribute(java.lang.String,
java.lang.Object)
*/
public synchronized void setAttribute(String key, Object value) {
if (value == null) {
- attributes.remove(key);
+ this.attributes.remove(key);
} else {
- attributes.put(key, value);
+ this.attributes.put(key, value);
}
}
- /**
- * Get a context attribute. If the attribute is not available return null
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#getAttribute(java.lang.String)
*/
public synchronized Object getAttribute(String key) {
- return attributes.get(key);
+ return this.attributes.get(key);
}
- /**
- * Get a context attribute. If the attribute is not available the
defaultObject is returned
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#getAttribute(java.lang.String,
java.lang.Object)
*/
public synchronized Object getAttribute(String key, Object
defaultObject) {
- Object value = attributes.get(key);
+ Object value = this.attributes.get(key);
if (value == null) value = defaultObject;
return value;
}
- /**
- * Get the value of this node. This is similiar to the xsl:value-of
- * function. If the node does not exist, <code>null</code> is returned.
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#getValueOfNode(java.lang.String)
*/
public synchronized String getValueOfNode(String path)
throws ProcessingException {
@@ -453,18 +456,16 @@
// return value;
}
- /**
- * Set the value of a node.
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#setValueOfNode(java.lang.String,
java.lang.String)
*/
public synchronized void setValueOfNode(String path, String value)
throws ProcessingException {
throw new ProcessingException("setValueOfNode() not implemented.");
}
- /**
- * Stream the XML directly to the handler. This streams the contents of
getXML()
- * to the given handler without creating a DocumentFragment containing a
copy
- * of the data
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#streamXML(java.lang.String,
org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler)
*/
public synchronized boolean streamXML(String path,
ContentHandler contentHandler,
@@ -479,10 +480,8 @@
return streamed;
}
- /**
- * Try to load XML into the context.
- * If the context does not provide the ability of loading,
- * an exception is thrown.
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#loadXML(java.lang.String,
org.apache.excalibur.source.SourceParameters)
*/
public void loadXML(String path,
SourceParameters parameters)
@@ -490,10 +489,8 @@
throw new ProcessingException("The context " + this.name + " does
not support loading.");
}
- /**
- * Try to save XML from the context.
- * If the context does not provide the ability of saving,
- * an exception is thrown.
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContext#saveXML(java.lang.String,
org.apache.excalibur.source.SourceParameters)
*/
public void saveXML(String path,
SourceParameters parameters)
1.9 +5 -11
cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/context/SessionContextProviderImpl.java
Index: SessionContextProviderImpl.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal-fw/java/org/apache/cocoon/webapps/portal/context/SessionContextProviderImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SessionContextProviderImpl.java 5 Mar 2004 13:02:18 -0000 1.8
+++ SessionContextProviderImpl.java 26 May 2004 08:39:49 -0000 1.9
@@ -15,7 +15,6 @@
*/
package org.apache.cocoon.webapps.portal.context;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -40,7 +39,6 @@
import org.apache.cocoon.webapps.session.context.SessionContextProvider;
import org.apache.excalibur.source.SourceParameters;
import org.apache.excalibur.xml.xpath.XPathProcessor;
-import org.xml.sax.SAXException;
/**
* Context provider for the portal context
@@ -75,7 +73,7 @@
PortalManager portal = null;
try {
- portal =
(PortalManager)manager.lookup(PortalManager.ROLE);
+ portal =
(PortalManager)this.manager.lookup(PortalManager.ROLE);
// is this an external resource which wants access to a
coplet?
String value = req.getParameter("portalcontext");
if (value != null) {
@@ -110,22 +108,18 @@
}
context = new SessionContextImpl(name, objectModel,
portal, this.xpathProcessor);
objectModel.put(this.getClass().getName()+name, context);
- } catch (SAXException se) {
- throw new ProcessingException("SAXException", se);
- } catch (IOException ioe) {
- throw new ProcessingException("IOException", ioe);
} catch (ServiceException se) {
throw new ProcessingException("Unable to lookup
portal.", se);
} finally {
- manager.release(portal);
+ this.manager.release(portal);
}
}
}
return context;
}
- /**
- * Does the context exist?
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.webapps.session.context.SessionContextProvider#existsSessionContext(java.lang.String)
*/
public boolean existsSessionContext(String name)
throws ProcessingException {