You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2005/01/10 14:32:30 UTC
svn commit: r124799 - in cocoon/branches/BRANCH_2_1_X/src: blocks/cron/java/org/apache/cocoon/components/cron blocks/eventcache/java/org/apache/cocoon/caching/impl blocks/forms/java/org/apache/cocoon/forms/datatype blocks/forms/java/org/apache/cocoon/forms/datatype/convertor blocks/forms/java/org/apache/cocoon/forms/samples blocks/forms/java/org/apache/cocoon/forms/samples/dreamteam blocks/naming/java/org/apache/cocoon/components/naming blocks/portal/java/org/apache/cocoon/portal/acting/helpers blocks/portal/java/org/apache/cocoon/portal/event/aspect/impl blocks/portal/java/org/apache/cocoon/portal/event/impl blocks/portal/java/org/apache/cocoon/portal/generation blocks/portal/java/org/apache/cocoon/portal/impl blocks/portal/java/org/apache/cocoon/portal/profile/impl blocks/scratchpad/java/org/apache/cocoon/components/flow/ws blocks/scratchpad/java/org/apache/cocoon/generation blocks/tour/java/org/apache/cocoon/samples/tour/shapes java/org/apache/cocoon/components/store/impl java/org/apache/cocoon/components/thread java/org/apache/cocoon/components/treeprocessor java/org/apache/cocoon/selection
Author: vgritsenko
Date: Mon Jan 10 05:32:27 2005
New Revision: 124799
URL: http://svn.apache.org/viewcvs?view=rev&rev=124799
Log:
svn:eol-style native
Modified:
cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzDriverDelegate.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreCMT.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/cron/java/org/apache/cocoon/components/cron/QuartzJobStoreTX.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/JMSEventMessageListener.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/AbstractJavaSelectionList.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/JavaSelectionList.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/JavaSelectionListBuilder.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/samples/DateTestJavaSelectionList.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/samples/dreamteam/Manager.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/naming/java/org/apache/cocoon/components/naming/EntryManager.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/naming/java/org/apache/cocoon/components/naming/LDAPEntryManager.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/FullScreenMapping.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/aspect/impl/PageLabelEventAspect.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/PageLabelEventConverter.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PageLabelLinkService.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PageLabelManager.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/ws/ClientBindingGenerator.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/ws/EndpointDefinition.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/ws/InvalidServiceException.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/ws/LoadException.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/ws/WebServiceLoader.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/generation/CSVGenerator.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Circle.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Rectangular.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Shape.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Square.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/store/impl/CocoonStoreJanitor.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/store/impl/StoreJanitorImpl.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/BoundedQueue.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/ChannelWrapper.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/DefaultThreadFactory.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/DefaultThreadPool.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/LinkedQueue.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/Queue.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/RunnableManager.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/SynchronousChannel.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/ThreadFactory.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/ThreadPool.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/selection/AbstractRegexpSelector.java (props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/selection/RegexpHeaderSelector.java (contents, props changed)
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/selection/RegexpRequestParameterSelector.java (props changed)
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/JMSEventMessageListener.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/JMSEventMessageListener.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/JMSEventMessageListener.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/JMSEventMessageListener.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/JMSEventMessageListener.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/JMSEventMessageListener.java Mon Jan 10 05:32:27 2005
@@ -1,117 +1,117 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */package org.apache.cocoon.caching.impl;
-
-import javax.jms.Message;
-
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.caching.Cache;
-import org.apache.cocoon.caching.EventAware;
-import org.apache.cocoon.caching.validity.Event;
-import org.apache.cocoon.caching.validity.NamedEvent;
-import org.apache.cocoon.components.jms.AbstractMessageListener;
-
-/**
- * JMS listener will notify an {@link org.apache.cocoon.caching.EventAware} component
- * of external events. This could be used for example to do external cache invalidation.
- *
- * <p>
- * Besides those inherited from
- * {@link org.apache.cocoon.components.jms.AbstractMessageListener}
- * parameters are:
- * </p>
- * <table border="1">
- * <tbody>
- * <tr>
- * <th align="left">parameter</th>
- * <th align="left">required</th>
- * <th align="left">default</th>
- * <th align="left">description</th>
- * </tr>
- * <tr>
- * <td valign="top">eventcache-role</td>
- * <td valign="top">no</td>
- * <td valign="top">org.apache.cocoon.caching.Cache/EventAware</td>
- * <td valign="top">The role name to lookup the event cache from the service manager.</td>
- * </tr>
- * </tbody>
- * </table>
- */
-public class JMSEventMessageListener extends AbstractMessageListener implements ThreadSafe {
-
- // ---------------------------------------------------- Constants
-
- private static final String DEFAULT_EVENTCACHE_ROLE = Cache.ROLE + "/EventAware";
- private static final String EVENTCACHE_ROLE_PARAM = "eventcache-role";
-
- // ---------------------------------------------------- Instance variables
-
- private String m_eventAwareRole;
- private EventAware m_eventCache;
-
- // ---------------------------------------------------- Lifecycle
-
- public JMSEventMessageListener() {
- }
-
- public void parameterize(Parameters parameters) throws ParameterException {
- super.parameterize(parameters);
- m_eventAwareRole = parameters.getParameter(EVENTCACHE_ROLE_PARAM, DEFAULT_EVENTCACHE_ROLE);
- }
-
- public void initialize() throws Exception {
- super.initialize();
- m_eventCache = (EventAware) m_manager.lookup(m_eventAwareRole);
- }
-
- public void dispose() {
- super.dispose();
- this.m_manager.release(m_eventCache);
- }
-
- /**
- * Notifies the event cache of events occurred.
- */
- public synchronized void onMessage(Message message) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Receiving message: " + message);
- }
- final Event[] events = eventsFromMessage(message);
- for (int i = 0; i < events.length; i++) {
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Notifying " + m_eventAwareRole + " of " + events[i]);
- }
- m_eventCache.processEvent(events[i]);
- }
- }
-
- /**
- * Convert the message contents to (a series of) cache event. The default implementation
- * assumes that the message contains the trigger name, a '|', and a table name.
- * It extracts the tablename and creates a NamedEvent with it.
- * Override this method to provide a custom message to event mapping.
- *
- * @param message the JMS message.
- * @return the cache event.
- */
- protected Event[] eventsFromMessage(Message message) {
- String name = message.toString();
- int pos = name.indexOf('|');
- return new Event[] { new NamedEvent(name.substring(pos + 1)) };
- }
-
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */package org.apache.cocoon.caching.impl;
+
+import javax.jms.Message;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.caching.Cache;
+import org.apache.cocoon.caching.EventAware;
+import org.apache.cocoon.caching.validity.Event;
+import org.apache.cocoon.caching.validity.NamedEvent;
+import org.apache.cocoon.components.jms.AbstractMessageListener;
+
+/**
+ * JMS listener will notify an {@link org.apache.cocoon.caching.EventAware} component
+ * of external events. This could be used for example to do external cache invalidation.
+ *
+ * <p>
+ * Besides those inherited from
+ * {@link org.apache.cocoon.components.jms.AbstractMessageListener}
+ * parameters are:
+ * </p>
+ * <table border="1">
+ * <tbody>
+ * <tr>
+ * <th align="left">parameter</th>
+ * <th align="left">required</th>
+ * <th align="left">default</th>
+ * <th align="left">description</th>
+ * </tr>
+ * <tr>
+ * <td valign="top">eventcache-role</td>
+ * <td valign="top">no</td>
+ * <td valign="top">org.apache.cocoon.caching.Cache/EventAware</td>
+ * <td valign="top">The role name to lookup the event cache from the service manager.</td>
+ * </tr>
+ * </tbody>
+ * </table>
+ */
+public class JMSEventMessageListener extends AbstractMessageListener implements ThreadSafe {
+
+ // ---------------------------------------------------- Constants
+
+ private static final String DEFAULT_EVENTCACHE_ROLE = Cache.ROLE + "/EventAware";
+ private static final String EVENTCACHE_ROLE_PARAM = "eventcache-role";
+
+ // ---------------------------------------------------- Instance variables
+
+ private String m_eventAwareRole;
+ private EventAware m_eventCache;
+
+ // ---------------------------------------------------- Lifecycle
+
+ public JMSEventMessageListener() {
+ }
+
+ public void parameterize(Parameters parameters) throws ParameterException {
+ super.parameterize(parameters);
+ m_eventAwareRole = parameters.getParameter(EVENTCACHE_ROLE_PARAM, DEFAULT_EVENTCACHE_ROLE);
+ }
+
+ public void initialize() throws Exception {
+ super.initialize();
+ m_eventCache = (EventAware) m_manager.lookup(m_eventAwareRole);
+ }
+
+ public void dispose() {
+ super.dispose();
+ this.m_manager.release(m_eventCache);
+ }
+
+ /**
+ * Notifies the event cache of events occurred.
+ */
+ public synchronized void onMessage(Message message) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Receiving message: " + message);
+ }
+ final Event[] events = eventsFromMessage(message);
+ for (int i = 0; i < events.length; i++) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Notifying " + m_eventAwareRole + " of " + events[i]);
+ }
+ m_eventCache.processEvent(events[i]);
+ }
+ }
+
+ /**
+ * Convert the message contents to (a series of) cache event. The default implementation
+ * assumes that the message contains the trigger name, a '|', and a table name.
+ * It extracts the tablename and creates a NamedEvent with it.
+ * Override this method to provide a custom message to event mapping.
+ *
+ * @param message the JMS message.
+ * @return the cache event.
+ */
+ protected Event[] eventsFromMessage(Message message) {
+ String name = message.toString();
+ int pos = name.indexOf('|');
+ return new Event[] { new NamedEvent(name.substring(pos + 1)) };
+ }
+
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertor.java Mon Jan 10 05:32:27 2005
@@ -1,68 +1,68 @@
-/*
- * Copyright 2004 Outerthought bvba and Schaubroeck nv
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.forms.datatype.convertor;
-
-import org.apache.cocoon.forms.datatype.convertor.Convertor;
-import org.apache.cocoon.forms.datatype.convertor.ConversionResult;
-import org.apache.cocoon.forms.validation.ValidationError;
-import org.apache.commons.lang.exception.ExceptionUtils;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.outerj.daisy.htmlcleaner.HtmlCleanerTemplate;
-import org.outerj.daisy.htmlcleaner.HtmlCleaner;
-
-import java.util.Locale;
-
-/**
- * A CForms convertor doing string-to-string conversion by utilizing
- * the Daisy HtmlCleaner component.
- */
-public class HtmlCleaningConvertor implements Convertor {
- HtmlCleanerTemplate template;
-
- public HtmlCleaningConvertor(HtmlCleanerTemplate template) {
- this.template = template;
- }
-
- public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
- HtmlCleaner cleaner = template.newHtmlCleaner();
- try {
- String result = cleaner.cleanToString(value);
- return new ConversionResult(result);
- } catch (Exception e) {
- Throwable t = ExceptionUtils.getRootCause(e);
- if (t == null)
- t = e;
- String message = t.getMessage();
- if (message == null)
- message = t.toString();
- ValidationError validationError = new ValidationError(message, false);
- return new ConversionResult(validationError);
- }
- }
-
- public String convertToString(Object object, Locale locale, Convertor.FormatCache formatCache) {
- return (String)object;
- }
-
- public Class getTypeClass() {
- return java.lang.String.class;
- }
-
- public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
- // nothing to say about me
- }
-}
+/*
+ * Copyright 2004 Outerthought bvba and Schaubroeck nv
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.apache.cocoon.forms.datatype.convertor.Convertor;
+import org.apache.cocoon.forms.datatype.convertor.ConversionResult;
+import org.apache.cocoon.forms.validation.ValidationError;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.outerj.daisy.htmlcleaner.HtmlCleanerTemplate;
+import org.outerj.daisy.htmlcleaner.HtmlCleaner;
+
+import java.util.Locale;
+
+/**
+ * A CForms convertor doing string-to-string conversion by utilizing
+ * the Daisy HtmlCleaner component.
+ */
+public class HtmlCleaningConvertor implements Convertor {
+ HtmlCleanerTemplate template;
+
+ public HtmlCleaningConvertor(HtmlCleanerTemplate template) {
+ this.template = template;
+ }
+
+ public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
+ HtmlCleaner cleaner = template.newHtmlCleaner();
+ try {
+ String result = cleaner.cleanToString(value);
+ return new ConversionResult(result);
+ } catch (Exception e) {
+ Throwable t = ExceptionUtils.getRootCause(e);
+ if (t == null)
+ t = e;
+ String message = t.getMessage();
+ if (message == null)
+ message = t.toString();
+ ValidationError validationError = new ValidationError(message, false);
+ return new ConversionResult(validationError);
+ }
+ }
+
+ public String convertToString(Object object, Locale locale, Convertor.FormatCache formatCache) {
+ return (String)object;
+ }
+
+ public Class getTypeClass() {
+ return java.lang.String.class;
+ }
+
+ public void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException {
+ // nothing to say about me
+ }
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/HtmlCleaningConvertorBuilder.java Mon Jan 10 05:32:27 2005
@@ -1,73 +1,73 @@
-/*
- * Copyright 2004 Outerthought bvba and Schaubroeck nv
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.forms.datatype.convertor;
-
-import org.apache.cocoon.forms.datatype.convertor.ConvertorBuilder;
-import org.apache.cocoon.forms.datatype.convertor.Convertor;
-import org.apache.cocoon.forms.util.DomHelper;
-import org.apache.cocoon.forms.CacheManager;
-import org.apache.cocoon.components.source.SourceUtil;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.excalibur.source.Source;
-import org.w3c.dom.Element;
-import org.outerj.daisy.htmlcleaner.HtmlCleanerTemplate;
-import org.outerj.daisy.htmlcleaner.HtmlCleanerFactory;
-import org.xml.sax.InputSource;
-
-/**
- * Builds {@link HtmlCleaningConvertor}s.
- */
-public class HtmlCleaningConvertorBuilder implements ConvertorBuilder, Serviceable {
- private ServiceManager serviceManager;
-
- public void service(ServiceManager serviceManager) throws ServiceException {
- this.serviceManager = serviceManager;
- }
-
- public Convertor build(Element element) throws Exception {
- String config = DomHelper.getAttribute(element, "config");
-
- Source source = null;
- SourceResolver sourceResolver = null;
- CacheManager cacheManager = null;
- try {
- cacheManager = (CacheManager)serviceManager.lookup(CacheManager.ROLE);
- sourceResolver = (SourceResolver)serviceManager.lookup(SourceResolver.ROLE);
- source = sourceResolver.resolveURI(config);
-
- String prefix = HtmlCleanerTemplate.class.getName();
- HtmlCleanerTemplate template = (HtmlCleanerTemplate)cacheManager.get(source, prefix);
- if (template == null) {
- HtmlCleanerFactory factory = new HtmlCleanerFactory();
- InputSource is = SourceUtil.getInputSource(source);
- template = factory.buildTemplate(is);
- cacheManager.set(template, source, prefix);
- }
-
- return new HtmlCleaningConvertor(template);
- } finally {
- if (source != null)
- sourceResolver.release(source);
- if (sourceResolver != null)
- serviceManager.release(sourceResolver);
- if (cacheManager != null)
- serviceManager.release(cacheManager);
- }
- }
-}
+/*
+ * Copyright 2004 Outerthought bvba and Schaubroeck nv
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.datatype.convertor;
+
+import org.apache.cocoon.forms.datatype.convertor.ConvertorBuilder;
+import org.apache.cocoon.forms.datatype.convertor.Convertor;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.apache.cocoon.forms.CacheManager;
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.Source;
+import org.w3c.dom.Element;
+import org.outerj.daisy.htmlcleaner.HtmlCleanerTemplate;
+import org.outerj.daisy.htmlcleaner.HtmlCleanerFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Builds {@link HtmlCleaningConvertor}s.
+ */
+public class HtmlCleaningConvertorBuilder implements ConvertorBuilder, Serviceable {
+ private ServiceManager serviceManager;
+
+ public void service(ServiceManager serviceManager) throws ServiceException {
+ this.serviceManager = serviceManager;
+ }
+
+ public Convertor build(Element element) throws Exception {
+ String config = DomHelper.getAttribute(element, "config");
+
+ Source source = null;
+ SourceResolver sourceResolver = null;
+ CacheManager cacheManager = null;
+ try {
+ cacheManager = (CacheManager)serviceManager.lookup(CacheManager.ROLE);
+ sourceResolver = (SourceResolver)serviceManager.lookup(SourceResolver.ROLE);
+ source = sourceResolver.resolveURI(config);
+
+ String prefix = HtmlCleanerTemplate.class.getName();
+ HtmlCleanerTemplate template = (HtmlCleanerTemplate)cacheManager.get(source, prefix);
+ if (template == null) {
+ HtmlCleanerFactory factory = new HtmlCleanerFactory();
+ InputSource is = SourceUtil.getInputSource(source);
+ template = factory.buildTemplate(is);
+ cacheManager.set(template, source, prefix);
+ }
+
+ return new HtmlCleaningConvertor(template);
+ } finally {
+ if (source != null)
+ sourceResolver.release(source);
+ if (sourceResolver != null)
+ serviceManager.release(sourceResolver);
+ if (cacheManager != null)
+ serviceManager.release(cacheManager);
+ }
+ }
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/samples/dreamteam/Manager.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/samples/dreamteam/Manager.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/samples/dreamteam/Manager.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/samples/dreamteam/Manager.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/samples/dreamteam/Manager.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/samples/dreamteam/Manager.java Mon Jan 10 05:32:27 2005
@@ -1,136 +1,136 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.forms.samples.dreamteam;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-/**
- * Manager
- */
-public class Manager {
- private static Manager manager = new Manager();
- private List allPersons = null;
- private Team dreamTeam = null;
-
- private Manager() {
- super();
- }
-
- public static Manager getManager() {
- if (manager == null) {
- manager = new Manager();
- }
- return manager;
- }
- public Hashtable getAllPersonsByPosition() {
- Hashtable list = new Hashtable();
- Team team = null;
- TeamMember teamMember = null;
- String position = null;
- for (int i = 0; i < allPersons.size(); i++) {
- teamMember = (TeamMember)allPersons.get(i);
- position = teamMember.getPosition();
- if (list.containsKey(position)) {
- team = (Team)list.get(position);
- }
- else {
- team = new Team();
- list.put(position, team);
- }
- team.addMember(teamMember);
- }
- return list;
-
- }
- public TeamMember getPerson(String memberID) {
- TeamMember member = null;
- if (allPersons == null) {
- return null;
- }
- for (Iterator iter = allPersons.iterator(); iter.hasNext();) {
- member = (TeamMember) iter.next();
- if (member.getMemberId().equals(memberID)) {
- return member;
- }
- }
- return null;
- }
-
- public void buildDreamTeam(Team dreamlist) {
- if (dreamTeam != null) {
- dreamTeam.getTeam().clear();
- }
- dreamTeam = new Team();
- TeamMember listMember = null;
- TeamMember dreamMember = null;
- for (Iterator iter = dreamlist.getTeam().iterator(); iter.hasNext();) {
- listMember = (TeamMember) iter.next();
- dreamMember = getPerson(listMember.getMemberId());
- dreamTeam.addMember(dreamMember);
- }
- }
-
- public Team getDreamTeam() {
- if (dreamTeam == null) {
- dreamTeam = new Team();
- dreamTeam.setTeam(allPersons);
- }
- return dreamTeam;
- }
-
- public void readPlayers(Document doc) {
- NodeList players = doc.getElementsByTagName("player");
- Node player = null;
- int size = players.getLength();
- for (int i = 0; i < size; i++) {
- player = players.item(i);
- addPlayer((Element)player);
- }
- }
-
- private void addPlayer(Element player) {
- // convert the XML node to a TeamMember
- if (allPersons == null) {
- allPersons = new ArrayList();
- }
- TeamMember member = null;
- member = new TeamMember();
- member.setMemberId("" + (allPersons.size() + 1));
- member.setName(getElementValue(player, "name"));
- member.setPosition(getElementValue(player, "position"));
- member.setCountry(getElementValue(player, "country"));
-// System.out.println(member.toString());
- allPersons.add(member);
- }
-
- private String getElementValue(Element element, String tag) {
- String result = null;
- NodeList nodes = element.getElementsByTagName(tag);
- result = nodes.item(0).getFirstChild().getNodeValue();
-// System.out.println("element: " + tag + "=" + result);
- return result;
- }
-
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.samples.dreamteam;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+/**
+ * Manager
+ */
+public class Manager {
+ private static Manager manager = new Manager();
+ private List allPersons = null;
+ private Team dreamTeam = null;
+
+ private Manager() {
+ super();
+ }
+
+ public static Manager getManager() {
+ if (manager == null) {
+ manager = new Manager();
+ }
+ return manager;
+ }
+ public Hashtable getAllPersonsByPosition() {
+ Hashtable list = new Hashtable();
+ Team team = null;
+ TeamMember teamMember = null;
+ String position = null;
+ for (int i = 0; i < allPersons.size(); i++) {
+ teamMember = (TeamMember)allPersons.get(i);
+ position = teamMember.getPosition();
+ if (list.containsKey(position)) {
+ team = (Team)list.get(position);
+ }
+ else {
+ team = new Team();
+ list.put(position, team);
+ }
+ team.addMember(teamMember);
+ }
+ return list;
+
+ }
+ public TeamMember getPerson(String memberID) {
+ TeamMember member = null;
+ if (allPersons == null) {
+ return null;
+ }
+ for (Iterator iter = allPersons.iterator(); iter.hasNext();) {
+ member = (TeamMember) iter.next();
+ if (member.getMemberId().equals(memberID)) {
+ return member;
+ }
+ }
+ return null;
+ }
+
+ public void buildDreamTeam(Team dreamlist) {
+ if (dreamTeam != null) {
+ dreamTeam.getTeam().clear();
+ }
+ dreamTeam = new Team();
+ TeamMember listMember = null;
+ TeamMember dreamMember = null;
+ for (Iterator iter = dreamlist.getTeam().iterator(); iter.hasNext();) {
+ listMember = (TeamMember) iter.next();
+ dreamMember = getPerson(listMember.getMemberId());
+ dreamTeam.addMember(dreamMember);
+ }
+ }
+
+ public Team getDreamTeam() {
+ if (dreamTeam == null) {
+ dreamTeam = new Team();
+ dreamTeam.setTeam(allPersons);
+ }
+ return dreamTeam;
+ }
+
+ public void readPlayers(Document doc) {
+ NodeList players = doc.getElementsByTagName("player");
+ Node player = null;
+ int size = players.getLength();
+ for (int i = 0; i < size; i++) {
+ player = players.item(i);
+ addPlayer((Element)player);
+ }
+ }
+
+ private void addPlayer(Element player) {
+ // convert the XML node to a TeamMember
+ if (allPersons == null) {
+ allPersons = new ArrayList();
+ }
+ TeamMember member = null;
+ member = new TeamMember();
+ member.setMemberId("" + (allPersons.size() + 1));
+ member.setName(getElementValue(player, "name"));
+ member.setPosition(getElementValue(player, "position"));
+ member.setCountry(getElementValue(player, "country"));
+// System.out.println(member.toString());
+ allPersons.add(member);
+ }
+
+ private String getElementValue(Element element, String tag) {
+ String result = null;
+ NodeList nodes = element.getElementsByTagName(tag);
+ result = nodes.item(0).getFirstChild().getNodeValue();
+// System.out.println("element: " + tag + "=" + result);
+ return result;
+ }
+
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/FullScreenMapping.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/FullScreenMapping.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/FullScreenMapping.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/FullScreenMapping.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/FullScreenMapping.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/FullScreenMapping.java Mon Jan 10 05:32:27 2005
@@ -1,44 +1,44 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.portal.acting.helpers;
-
-import org.apache.cocoon.portal.PortalService;
-import org.apache.cocoon.portal.coplet.CopletInstanceData;
-import org.apache.cocoon.portal.event.Event;
-import org.apache.cocoon.portal.event.impl.FullScreenCopletEvent;
-import org.apache.cocoon.portal.layout.Layout;
-import org.apache.cocoon.portal.profile.ProfileManager;
-
-/**
- * Helper class for a full screen event
- *
- * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: CopletMapping.java 30941 2004-07-29 19:56:58Z vgritsenko $
-*/
-public class FullScreenMapping extends Mapping {
- public String copletId;
- public String layoutId;
-
- public Event getEvent(PortalService service, Object data) {
- final ProfileManager manager = service.getComponentManager().getProfileManager();
- final CopletInstanceData cid = manager.getCopletInstanceData(this.copletId);
- final Layout layout = manager.getPortalLayout(null, layoutId) ;
-
- Event e = new FullScreenCopletEvent(cid, layout);
- return e;
- }
-
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.acting.helpers;
+
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.event.Event;
+import org.apache.cocoon.portal.event.impl.FullScreenCopletEvent;
+import org.apache.cocoon.portal.layout.Layout;
+import org.apache.cocoon.portal.profile.ProfileManager;
+
+/**
+ * Helper class for a full screen event
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: CopletMapping.java 30941 2004-07-29 19:56:58Z vgritsenko $
+*/
+public class FullScreenMapping extends Mapping {
+ public String copletId;
+ public String layoutId;
+
+ public Event getEvent(PortalService service, Object data) {
+ final ProfileManager manager = service.getComponentManager().getProfileManager();
+ final CopletInstanceData cid = manager.getCopletInstanceData(this.copletId);
+ final Layout layout = manager.getPortalLayout(null, layoutId) ;
+
+ Event e = new FullScreenCopletEvent(cid, layout);
+ return e;
+ }
+
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java Mon Jan 10 05:32:27 2005
@@ -1,139 +1,139 @@
-/*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.portal.generation;
-
-import java.util.Map;
-
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.cocoon.environment.ObjectModelHelper;
-import org.apache.cocoon.generation.ServiceableGenerator;
-import org.apache.cocoon.portal.Constants;
-import org.apache.cocoon.portal.PortalService;
-import org.apache.cocoon.portal.coplet.CopletInstanceData;
-import org.xml.sax.SAXException;
-
-/**
- * Abstract generator implementation that provides a method getCopletInstanceData().
- * There are two possibilities how the generator obtains the information required for
- * getting the coplet instance data:<br><br>
- * 1) If it is used within a coplet pipeline and this pipeline is called using the "cocoon:" protocol,
- * all required information are passed automatically.<br>
- * 2) Otherwise the portal name and the coplet id must be passed to the generator
- * as paremeters in the following way:
- *
- * <pre><map:generator type="coplet">
- * <map:parameter name="portalName" type="exampleportal"/>
- * <map:parameter name="copletId" type="examplecoplet"/>
- * </map:generator></pre>
- *
- * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
- * @version CVS $Id: AbstractCopletTransformer.java 30941 2004-07-29 19:56:58Z vgritsenko $
- */
-public abstract class AbstractCopletGenerator
-extends ServiceableGenerator {
-
- /**
- * Parameter name.
- */
- public static final String COPLET_ID_PARAM = "copletId";
-
- /**
- * Parameter name.
- */
- public static final String PORTAL_NAME_PARAM = "portalName";
-
- /** The portal service */
- private PortalService _portalService;
-
- /**
- * Try to get the coplet instance data belonging to the current request
- * @return The coplet instance data
- * @throws SAXException If an errors occurs or the instance data is not available
- */
- protected CopletInstanceData getCopletInstanceData()
- throws SAXException {
- CopletInstanceData cid = this.getCopletInstanceData(null);
- if ( cid == null ) {
- throw new SAXException("Could not find coplet instance data for the current pipeline.");
- }
- return cid;
- }
-
-
- /**
- * Get the portal service
- */
- protected PortalService getPortalService()
- throws SAXException {
- if ( this._portalService == null ) {
- try {
- this._portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
- } catch (ServiceException se) {
- throw new SAXException("Unable to get portal service.", se);
- }
- }
- return this._portalService;
- }
-
-
- /**
- * Try to get the coplet instance data with the given id
- * @param copletId The id of the coplet instance or null if this transformer
- * is used inside a coplet pipeline
- * @return The coplet instance data or null
- * @throws SAXException If an error occurs
- */
- protected CopletInstanceData getCopletInstanceData(String copletId)
- throws SAXException {
- final Map context = (Map)objectModel.get(ObjectModelHelper.PARENT_CONTEXT);
-
- if ( copletId == null ) {
- // determine coplet id
- if (context != null) {
- copletId = (String)context.get(Constants.COPLET_ID_KEY);
- } else {
- copletId = (String)objectModel.get(Constants.COPLET_ID_KEY);
- if ( copletId == null ) {
- try {
- copletId = this.parameters.getParameter(COPLET_ID_PARAM);
-
- } catch (ParameterException e) {
- throw new SAXException("copletId must be passed as parameter or in the object model within the parent context.");
- }
- }
- }
- }
- if (copletId == null) {
- throw new SAXException("copletId must be passed as parameter or in the object model within the parent context.");
- }
-
- CopletInstanceData object = this.getPortalService().getComponentManager().getProfileManager().getCopletInstanceData( copletId );
-
- return object;
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
- */
- public void recycle() {
- if ( this._portalService != null ) {
- this.manager.release( this._portalService );
- this._portalService = null;
- }
- super.recycle();
- }
-}
+/*
+ * Copyright 1999-2002,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.generation;
+
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.generation.ServiceableGenerator;
+import org.apache.cocoon.portal.Constants;
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.xml.sax.SAXException;
+
+/**
+ * Abstract generator implementation that provides a method getCopletInstanceData().
+ * There are two possibilities how the generator obtains the information required for
+ * getting the coplet instance data:<br><br>
+ * 1) If it is used within a coplet pipeline and this pipeline is called using the "cocoon:" protocol,
+ * all required information are passed automatically.<br>
+ * 2) Otherwise the portal name and the coplet id must be passed to the generator
+ * as paremeters in the following way:
+ *
+ * <pre><map:generator type="coplet">
+ * <map:parameter name="portalName" type="exampleportal"/>
+ * <map:parameter name="copletId" type="examplecoplet"/>
+ * </map:generator></pre>
+ *
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @version CVS $Id: AbstractCopletTransformer.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public abstract class AbstractCopletGenerator
+extends ServiceableGenerator {
+
+ /**
+ * Parameter name.
+ */
+ public static final String COPLET_ID_PARAM = "copletId";
+
+ /**
+ * Parameter name.
+ */
+ public static final String PORTAL_NAME_PARAM = "portalName";
+
+ /** The portal service */
+ private PortalService _portalService;
+
+ /**
+ * Try to get the coplet instance data belonging to the current request
+ * @return The coplet instance data
+ * @throws SAXException If an errors occurs or the instance data is not available
+ */
+ protected CopletInstanceData getCopletInstanceData()
+ throws SAXException {
+ CopletInstanceData cid = this.getCopletInstanceData(null);
+ if ( cid == null ) {
+ throw new SAXException("Could not find coplet instance data for the current pipeline.");
+ }
+ return cid;
+ }
+
+
+ /**
+ * Get the portal service
+ */
+ protected PortalService getPortalService()
+ throws SAXException {
+ if ( this._portalService == null ) {
+ try {
+ this._portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
+ } catch (ServiceException se) {
+ throw new SAXException("Unable to get portal service.", se);
+ }
+ }
+ return this._portalService;
+ }
+
+
+ /**
+ * Try to get the coplet instance data with the given id
+ * @param copletId The id of the coplet instance or null if this transformer
+ * is used inside a coplet pipeline
+ * @return The coplet instance data or null
+ * @throws SAXException If an error occurs
+ */
+ protected CopletInstanceData getCopletInstanceData(String copletId)
+ throws SAXException {
+ final Map context = (Map)objectModel.get(ObjectModelHelper.PARENT_CONTEXT);
+
+ if ( copletId == null ) {
+ // determine coplet id
+ if (context != null) {
+ copletId = (String)context.get(Constants.COPLET_ID_KEY);
+ } else {
+ copletId = (String)objectModel.get(Constants.COPLET_ID_KEY);
+ if ( copletId == null ) {
+ try {
+ copletId = this.parameters.getParameter(COPLET_ID_PARAM);
+
+ } catch (ParameterException e) {
+ throw new SAXException("copletId must be passed as parameter or in the object model within the parent context.");
+ }
+ }
+ }
+ }
+ if (copletId == null) {
+ throw new SAXException("copletId must be passed as parameter or in the object model within the parent context.");
+ }
+
+ CopletInstanceData object = this.getPortalService().getComponentManager().getProfileManager().getCopletInstanceData( copletId );
+
+ return object;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
+ */
+ public void recycle() {
+ if ( this._portalService != null ) {
+ this.manager.release( this._portalService );
+ this._portalService = null;
+ }
+ super.recycle();
+ }
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java Mon Jan 10 05:32:27 2005
@@ -1,93 +1,93 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.portal.profile.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.avalon.framework.configuration.Configuration;
-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.webapps.authentication.AuthenticationManager;
-import org.apache.cocoon.webapps.authentication.configuration.ApplicationConfiguration;
-import org.apache.cocoon.webapps.authentication.user.RequestState;
-import org.apache.cocoon.webapps.authentication.user.UserHandler;
-
-/**
- * Get the information about the current user.
- * This implementation uses the authentication-fw block
- *
- * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
- */
-public class AuthenticationFWUserInfoProvider
-implements UserInfoProvider, Serviceable {
-
- protected ServiceManager manager;
-
-
- /* (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;
- }
-
- /* (non-Javadoc)
- * @see org.apache.cocoon.portal.profile.impl.UserInfoProvider#getUserInfo(java.lang.String, java.lang.String)
- */
- public UserInfo getUserInfo(String portalName, String layoutKey)
- throws Exception {
- AuthenticationManager authManager = null;
- try {
- authManager = (AuthenticationManager)this.manager.lookup(AuthenticationManager.ROLE);
- final UserInfo info = new UserInfo(portalName, layoutKey);
-
- final RequestState state = authManager.getState();
- final UserHandler handler = state.getHandler();
-
- info.setUserName(handler.getUserId());
- try {
- info.setGroup((String)handler.getContext().getContextInfo().get("group"));
- } catch (ProcessingException pe) {
- // ignore this
- }
-
- final ApplicationConfiguration ac = state.getApplicationConfiguration();
- if ( ac == null ) {
- throw new ProcessingException("Configuration for portal not found in application configuration.");
- }
- final Configuration appConf = ac.getConfiguration("portal");
- if ( appConf == null ) {
- throw new ProcessingException("Configuration for portal not found in application configuration.");
- }
- final Configuration config = appConf.getChild("profiles");
- final Configuration[] children = config.getChildren();
- final Map configs = new HashMap();
- if ( children != null ) {
- for(int i=0; i < children.length; i++) {
- configs.put(children[i].getName(), children[i].getAttribute("uri"));
- }
- }
- info.setConfigurations(configs);
- return info;
- } finally {
- this.manager.release( authManager );
- }
- }
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.profile.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configuration;
+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.webapps.authentication.AuthenticationManager;
+import org.apache.cocoon.webapps.authentication.configuration.ApplicationConfiguration;
+import org.apache.cocoon.webapps.authentication.user.RequestState;
+import org.apache.cocoon.webapps.authentication.user.UserHandler;
+
+/**
+ * Get the information about the current user.
+ * This implementation uses the authentication-fw block
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class AuthenticationFWUserInfoProvider
+implements UserInfoProvider, Serviceable {
+
+ protected ServiceManager manager;
+
+
+ /* (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;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.cocoon.portal.profile.impl.UserInfoProvider#getUserInfo(java.lang.String, java.lang.String)
+ */
+ public UserInfo getUserInfo(String portalName, String layoutKey)
+ throws Exception {
+ AuthenticationManager authManager = null;
+ try {
+ authManager = (AuthenticationManager)this.manager.lookup(AuthenticationManager.ROLE);
+ final UserInfo info = new UserInfo(portalName, layoutKey);
+
+ final RequestState state = authManager.getState();
+ final UserHandler handler = state.getHandler();
+
+ info.setUserName(handler.getUserId());
+ try {
+ info.setGroup((String)handler.getContext().getContextInfo().get("group"));
+ } catch (ProcessingException pe) {
+ // ignore this
+ }
+
+ final ApplicationConfiguration ac = state.getApplicationConfiguration();
+ if ( ac == null ) {
+ throw new ProcessingException("Configuration for portal not found in application configuration.");
+ }
+ final Configuration appConf = ac.getConfiguration("portal");
+ if ( appConf == null ) {
+ throw new ProcessingException("Configuration for portal not found in application configuration.");
+ }
+ final Configuration config = appConf.getChild("profiles");
+ final Configuration[] children = config.getChildren();
+ final Map configs = new HashMap();
+ if ( children != null ) {
+ for(int i=0; i < children.length; i++) {
+ configs.put(children[i].getName(), children[i].getAttribute("uri"));
+ }
+ }
+ info.setConfigurations(configs);
+ return info;
+ } finally {
+ this.manager.release( authManager );
+ }
+ }
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java Mon Jan 10 05:32:27 2005
@@ -1,33 +1,33 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.portal.profile.impl;
-
-/**
- * Get the information about the current user.
- * This data object is used for loading the profile. It decouples the
- * portal from the used authentication method.
- *
- * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
- */
-public interface UserInfoProvider {
-
- /**
- * Return the user info about the current user.
- */
- UserInfo getUserInfo(String portalName, String layoutKey)
- throws Exception;
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.profile.impl;
+
+/**
+ * Get the information about the current user.
+ * This data object is used for loading the profile. It decouples the
+ * portal from the used authentication method.
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public interface UserInfoProvider {
+
+ /**
+ * Return the user info about the current user.
+ */
+ UserInfo getUserInfo(String portalName, String layoutKey)
+ throws Exception;
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/ws/EndpointDefinition.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/ws/EndpointDefinition.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/ws/EndpointDefinition.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/ws/EndpointDefinition.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/ws/EndpointDefinition.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/scratchpad/java/org/apache/cocoon/components/flow/ws/EndpointDefinition.java Mon Jan 10 05:32:27 2005
@@ -1,227 +1,227 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.flow.ws;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.wsdl.Binding;
-import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.Service;
-import javax.wsdl.WSDLException;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.namespace.QName;
-
-/**
- * Represents a service endpoint in a WSDL document.
- */
-public class EndpointDefinition {
-
- private Definition wsdlDef;
- private String namespaceURI;
- private Service service;
- private Port port;
-
- /**
- * Creates a new EndpointDefinition. If a particular service is not
- * identified the endpoint is created using the first service definition
- * occurring in the WSDL with a port with a SOAP binding.
- *
- * @param wsdlURL
- * @param serviceName
- * @param portName
- * @throws WSDLException
- * @throws InvalidServiceException
- */
- public EndpointDefinition(String wsdlURL, String serviceName,
- String portName) throws WSDLException, InvalidServiceException {
- wsdlDef = loadWSDLDefinition(wsdlURL);
- namespaceURI = wsdlDef.getTargetNamespace();
- initialize(serviceName, portName);
- }
-
- /**
- * Returns the target namespace of the WSDL document in which this endpoint
- * is defined.
- *
- * @return String
- */
- public String getNamespaceURI() {
- return namespaceURI;
- }
-
- /**
- * Returns the name of the service that this endpoint belongs to.
- *
- * @return String
- */
- public String getServiceName() {
- return service.getQName().getLocalPart();
- }
-
- /**
- * Returns the name of the port that concretely defines the endpoint.
- *
- * @return String
- */
- public String getPortName() {
- return port.getName();
- }
-
- /**
- * Sets the service and port for this endpoint using the named entities if
- * provided.
- *
- * @param serviceName
- * @param portName
- * @throws InvalidServiceException
- */
- private void initialize(String serviceName, String portName)
- throws InvalidServiceException {
- if (serviceName != null) {
- service = getServiceNamed(serviceName);
- } else {
- service = getDefaultService();
- }
- // if using default service a port was already created in validating the
- // service.
- if (port == null) {
- if (portName != null) {
- port = getPortNamed(portName);
- } else {
- // returns 1st port with a soap binding for the given service or
- // throws an exception if none found
- port = getDefaultPort(service);
- }
- }
- }
-
- /**
- * Loads the WSDL document containing the definition of this endpoint.
- *
- * @param wsdlURL
- * @return @throws
- * WSDLException
- */
- private Definition loadWSDLDefinition(String wsdlURL) throws WSDLException {
- WSDLFactory factory = WSDLFactory.newInstance();
- WSDLReader reader = factory.newWSDLReader();
- reader.setFeature("javax.wsdl.verbose", false);
- reader.setFeature("javax.wsdl.importDocuments", true);
- Definition wsdlDef = reader.readWSDL(wsdlURL);
- return wsdlDef;
- }
-
- /**
- * Returns an object representation of the named service.
- *
- * @param serviceName
- * @return
- */
- private Service getServiceNamed(String serviceName) {
- return wsdlDef.getService(new QName(namespaceURI, serviceName));
- }
-
- /**
- * Returns an object representing the default service if none is specified
- * when this endpoint is created. The default service is determined by
- * selecting the 1st service that has a port with a SOAP binding.
- *
- * @return @throws
- * InvalidServiceException
- */
- private Service getDefaultService() throws InvalidServiceException {
- Map services = wsdlDef.getServices();
- Iterator it = services.values().iterator();
- while (it.hasNext()) {
- Service service = (Service) it.next();
- Port port = getDefaultPort(service);
- if (port != null) {
- this.port = port;
- return service;
- }
- }
- String msg = "No services defined in WSDL document named: "
- + wsdlDef.getQName().getLocalPart();
- throw new InvalidServiceException(msg);
- }
-
- /**
- * Returns an object representation of the named port.
- *
- * @param portName
- * @return
- */
- private Port getPortNamed(String portName) {
- Map serviceMap = wsdlDef.getServices();
- Iterator services = serviceMap.values().iterator();
- while (services.hasNext()) {
- Service service = (Service) services.next();
- Map portMap = service.getPorts();
- Iterator ports = portMap.values().iterator();
- while (ports.hasNext()) {
- Port port = (Port) ports.next();
- if (port.getName().equals(portName)) {
- return port;
- }
- }
- }
- return null;
- }
-
- /**
- * Returns an object representing the default port if none is specified at
- * the time this endpoint is created. The default port is determined by
- * selecting the 1st port, for the given service, that has a SOAP binding.
- *
- * @param service
- * @throws InvalidServiceException
- */
- private Port getDefaultPort(Service service) throws InvalidServiceException {
- Map ports = service.getPorts();
- Iterator it = ports.values().iterator();
- while (it.hasNext()) {
- Port port = (Port) it.next();
- if (hasSoapBinding(port)) {
- return port;
- }
- }
- String msg = "No ports with SOAP binding for service named: "
- + service.getQName().getLocalPart();
- throw new InvalidServiceException(msg);
- }
-
- /**
- * Tests if a port has a SOAP binding.
- *
- * @param port
- * @return
- */
- private boolean hasSoapBinding(Port port) {
- Binding binding = port.getBinding();
- Iterator it = port.getExtensibilityElements().iterator();
- while (it.hasNext()) {
- Object element = it.next();
- if (element instanceof SOAPAddress) {
- return true;
- }
- }
- return false;
- }
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.flow.ws;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a service endpoint in a WSDL document.
+ */
+public class EndpointDefinition {
+
+ private Definition wsdlDef;
+ private String namespaceURI;
+ private Service service;
+ private Port port;
+
+ /**
+ * Creates a new EndpointDefinition. If a particular service is not
+ * identified the endpoint is created using the first service definition
+ * occurring in the WSDL with a port with a SOAP binding.
+ *
+ * @param wsdlURL
+ * @param serviceName
+ * @param portName
+ * @throws WSDLException
+ * @throws InvalidServiceException
+ */
+ public EndpointDefinition(String wsdlURL, String serviceName,
+ String portName) throws WSDLException, InvalidServiceException {
+ wsdlDef = loadWSDLDefinition(wsdlURL);
+ namespaceURI = wsdlDef.getTargetNamespace();
+ initialize(serviceName, portName);
+ }
+
+ /**
+ * Returns the target namespace of the WSDL document in which this endpoint
+ * is defined.
+ *
+ * @return String
+ */
+ public String getNamespaceURI() {
+ return namespaceURI;
+ }
+
+ /**
+ * Returns the name of the service that this endpoint belongs to.
+ *
+ * @return String
+ */
+ public String getServiceName() {
+ return service.getQName().getLocalPart();
+ }
+
+ /**
+ * Returns the name of the port that concretely defines the endpoint.
+ *
+ * @return String
+ */
+ public String getPortName() {
+ return port.getName();
+ }
+
+ /**
+ * Sets the service and port for this endpoint using the named entities if
+ * provided.
+ *
+ * @param serviceName
+ * @param portName
+ * @throws InvalidServiceException
+ */
+ private void initialize(String serviceName, String portName)
+ throws InvalidServiceException {
+ if (serviceName != null) {
+ service = getServiceNamed(serviceName);
+ } else {
+ service = getDefaultService();
+ }
+ // if using default service a port was already created in validating the
+ // service.
+ if (port == null) {
+ if (portName != null) {
+ port = getPortNamed(portName);
+ } else {
+ // returns 1st port with a soap binding for the given service or
+ // throws an exception if none found
+ port = getDefaultPort(service);
+ }
+ }
+ }
+
+ /**
+ * Loads the WSDL document containing the definition of this endpoint.
+ *
+ * @param wsdlURL
+ * @return @throws
+ * WSDLException
+ */
+ private Definition loadWSDLDefinition(String wsdlURL) throws WSDLException {
+ WSDLFactory factory = WSDLFactory.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+ reader.setFeature("javax.wsdl.verbose", false);
+ reader.setFeature("javax.wsdl.importDocuments", true);
+ Definition wsdlDef = reader.readWSDL(wsdlURL);
+ return wsdlDef;
+ }
+
+ /**
+ * Returns an object representation of the named service.
+ *
+ * @param serviceName
+ * @return
+ */
+ private Service getServiceNamed(String serviceName) {
+ return wsdlDef.getService(new QName(namespaceURI, serviceName));
+ }
+
+ /**
+ * Returns an object representing the default service if none is specified
+ * when this endpoint is created. The default service is determined by
+ * selecting the 1st service that has a port with a SOAP binding.
+ *
+ * @return @throws
+ * InvalidServiceException
+ */
+ private Service getDefaultService() throws InvalidServiceException {
+ Map services = wsdlDef.getServices();
+ Iterator it = services.values().iterator();
+ while (it.hasNext()) {
+ Service service = (Service) it.next();
+ Port port = getDefaultPort(service);
+ if (port != null) {
+ this.port = port;
+ return service;
+ }
+ }
+ String msg = "No services defined in WSDL document named: "
+ + wsdlDef.getQName().getLocalPart();
+ throw new InvalidServiceException(msg);
+ }
+
+ /**
+ * Returns an object representation of the named port.
+ *
+ * @param portName
+ * @return
+ */
+ private Port getPortNamed(String portName) {
+ Map serviceMap = wsdlDef.getServices();
+ Iterator services = serviceMap.values().iterator();
+ while (services.hasNext()) {
+ Service service = (Service) services.next();
+ Map portMap = service.getPorts();
+ Iterator ports = portMap.values().iterator();
+ while (ports.hasNext()) {
+ Port port = (Port) ports.next();
+ if (port.getName().equals(portName)) {
+ return port;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns an object representing the default port if none is specified at
+ * the time this endpoint is created. The default port is determined by
+ * selecting the 1st port, for the given service, that has a SOAP binding.
+ *
+ * @param service
+ * @throws InvalidServiceException
+ */
+ private Port getDefaultPort(Service service) throws InvalidServiceException {
+ Map ports = service.getPorts();
+ Iterator it = ports.values().iterator();
+ while (it.hasNext()) {
+ Port port = (Port) it.next();
+ if (hasSoapBinding(port)) {
+ return port;
+ }
+ }
+ String msg = "No ports with SOAP binding for service named: "
+ + service.getQName().getLocalPart();
+ throw new InvalidServiceException(msg);
+ }
+
+ /**
+ * Tests if a port has a SOAP binding.
+ *
+ * @param port
+ * @return
+ */
+ private boolean hasSoapBinding(Port port) {
+ Binding binding = port.getBinding();
+ Iterator it = port.getExtensibilityElements().iterator();
+ while (it.hasNext()) {
+ Object element = it.next();
+ if (element instanceof SOAPAddress) {
+ return true;
+ }
+ }
+ return false;
+ }
}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Circle.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Circle.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Circle.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Circle.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Circle.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Circle.java Mon Jan 10 05:32:27 2005
@@ -1,42 +1,42 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.cocoon.samples.tour.shapes;
-
-/**
- * Circle Shape for tour block java-shapes sample
- */
-public class Circle implements Shape{
- double _r;
-
- public String getName() {
- return "Circle";
- }
-
- /** Creates a new instance of Circle */
- public Circle(double r) {
- _r = r;
- }
-
- public double area() {
- return 3.14 * _r * _r;
- }
-
- public double perimeter() {
- return 2 * 3.14 * _r;
- }
-
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cocoon.samples.tour.shapes;
+
+/**
+ * Circle Shape for tour block java-shapes sample
+ */
+public class Circle implements Shape{
+ double _r;
+
+ public String getName() {
+ return "Circle";
+ }
+
+ /** Creates a new instance of Circle */
+ public Circle(double r) {
+ _r = r;
+ }
+
+ public double area() {
+ return 3.14 * _r * _r;
+ }
+
+ public double perimeter() {
+ return 2 * 3.14 * _r;
+ }
+
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Rectangular.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Rectangular.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Rectangular.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Rectangular.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Rectangular.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Rectangular.java Mon Jan 10 05:32:27 2005
@@ -1,43 +1,43 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.cocoon.samples.tour.shapes;
-
-/**
- * Rectangular Shape for tour block java-shapes sample
- */
-public class Rectangular implements Shape{
- double _h;
- double _b;
- /** Creates a new instance of StrCount */
- public Rectangular(double h, double b) {
- _h = h;
- _b = b;
- }
-
- public String getName() {
- return "Rectangular";
- }
-
- public double area(){
- return _h * _b;
- }
-
- public double perimeter(){
- return (_h + _b) * 2;
- }
-
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cocoon.samples.tour.shapes;
+
+/**
+ * Rectangular Shape for tour block java-shapes sample
+ */
+public class Rectangular implements Shape{
+ double _h;
+ double _b;
+ /** Creates a new instance of StrCount */
+ public Rectangular(double h, double b) {
+ _h = h;
+ _b = b;
+ }
+
+ public String getName() {
+ return "Rectangular";
+ }
+
+ public double area(){
+ return _h * _b;
+ }
+
+ public double perimeter(){
+ return (_h + _b) * 2;
+ }
+
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Shape.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Shape.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Shape.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Shape.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Shape.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Shape.java Mon Jan 10 05:32:27 2005
@@ -1,26 +1,26 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.cocoon.samples.tour.shapes;
-
-/**
- * Shape interface for tour block java-shapes sample
- */
-public interface Shape {
- String getName();
- abstract double area();
- abstract double perimeter();
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cocoon.samples.tour.shapes;
+
+/**
+ * Shape interface for tour block java-shapes sample
+ */
+public interface Shape {
+ String getName();
+ abstract double area();
+ abstract double perimeter();
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Square.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Square.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Square.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Square.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Square.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/tour/java/org/apache/cocoon/samples/tour/shapes/Square.java Mon Jan 10 05:32:27 2005
@@ -1,41 +1,41 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.cocoon.samples.tour.shapes;
-
-/**
- * Square Shape for tour block java-shapes sample
- */
-public class Square implements Shape {
- float _b;
- /** Creates a new instance of Square */
- public Square(float b) {
- _b = b;
- }
-
- public String getName() {
- return "Square";
- }
-
- public double area() {
- return _b*_b;
- }
-
- public double perimeter() {
- return 4*_b;
- }
-
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cocoon.samples.tour.shapes;
+
+/**
+ * Square Shape for tour block java-shapes sample
+ */
+public class Square implements Shape {
+ float _b;
+ /** Creates a new instance of Square */
+ public Square(float b) {
+ _b = b;
+ }
+
+ public String getName() {
+ return "Square";
+ }
+
+ public double area() {
+ return _b*_b;
+ }
+
+ public double perimeter() {
+ return 4*_b;
+ }
+
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java Mon Jan 10 05:32:27 2005
@@ -1,391 +1,391 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.treeprocessor;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.Processor;
-import org.apache.cocoon.components.ChainedConfiguration;
-import org.apache.cocoon.components.CocoonComponentManager;
-import org.apache.cocoon.components.pipeline.ProcessingPipeline;
-import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.ForwardRedirector;
-import org.apache.cocoon.environment.Redirector;
-import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
-import org.apache.cocoon.environment.wrapper.MutableEnvironmentFacade;
-
-
-/**
- * The concrete implementation of {@link Processor}, containing the evaluation tree and associated
- * data such as component manager.
- *
- * @version CVS $Id: ConcreteTreeProcessor.java,v 1.1 2004/06/05 08:18:50 sylvain Exp $
- */
-public class ConcreteTreeProcessor
-extends AbstractLogEnabled
-implements Processor, Disposable {
-
- /** The processor that wraps us */
- private TreeProcessor wrappingProcessor;
-
- /** Component manager defined by the <map:components> of this sitemap */
- ComponentManager sitemapComponentManager;
-
- /** Processing nodes that need to be disposed with this processor */
- private List disposableNodes;
-
- /** Root node of the processing tree */
- private ProcessingNode rootNode;
-
- private Map sitemapComponentConfigurations;
-
- private Configuration componentConfigurations;
-
- /** Number of simultaneous uses of this processor (either by concurrent request or by internal requests) */
- private int requestCount;
-
- /** Builds a concrete processig, given the wrapping processor */
- public ConcreteTreeProcessor(TreeProcessor wrappingProcessor) {
- this.wrappingProcessor = wrappingProcessor;
- }
-
- /** Set the processor data, result of the treebuilder job */
- 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 sitemap component configurations (called as part of the tree building process) */
- public void setComponentConfigurations(Configuration componentConfigurations) {
- this.componentConfigurations = componentConfigurations;
- this.sitemapComponentConfigurations = null;
- }
-
- /**
- * Get the sitemap component configurations
- * @since 2.1
- */
- 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; }
-
- /**
- * Mark this processor as needing to be disposed. Actual call to {@link #dispose()} will occur when
- * all request processings on this processor will be terminated.
- */
- 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();
- }
- }
-
- public TreeProcessor getWrappingProcessor() {
- return this.wrappingProcessor;
- }
-
- public Processor getRootProcessor() {
- return this.wrappingProcessor.getRootProcessor();
- }
-
- /**
- * Process the given <code>Environment</code> producing the output.
- * @return If the processing is successfull <code>true</code> is returned.
- * If not match is found in the sitemap <code>false</code>
- * is returned.
- * @throws org.apache.cocoon.ResourceNotFoundException If a sitemap component tries
- * to access a resource which can not
- * be found, e.g. the generator
- * ConnectionResetException If the connection was reset
- */
- 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 <code>Environment</code> to assemble
- * a <code>ProcessingPipeline</code>.
- * @since 2.1
- */
- 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();
- }
- }
-
- /**
- * Do the actual processing, be it producing the response or just building the pipeline
- * @param environment
- * @param context
- * @return true if the pipeline was successfully built, false otherwise.
- * @throws Exception
- */
- 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);
- try {
- boolean success = this.rootNode.invoke(environment, context);
-
- return success;
-
- } finally {
- CocoonComponentManager.leaveEnvironment();
- // 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();
- }
- }
- }
-
- private boolean handleCocoonRedirect(String uri, Environment environment, InvokeContext context) throws Exception {
-
- // Build an environment wrapper
- // If the current env is a facade, change the delegate and continue processing the facade, since
- // we may have other redirects that will in turn also change the facade delegate
-
- MutableEnvironmentFacade facade = environment instanceof MutableEnvironmentFacade ?
- ((MutableEnvironmentFacade)environment) : null;
-
- if (facade != null) {
- // Consider the facade delegate (the real environment)
- environment = facade.getDelegate();
- }
-
- // test if this is a call from flow
- boolean isRedirect = (environment.getObjectModel().remove("cocoon:forward") == null);
- Environment newEnv = new ForwardEnvironmentWrapper(environment, this.sitemapComponentManager, uri, getLogger());
- if ( isRedirect ) {
- ((ForwardEnvironmentWrapper)newEnv).setInternalRedirect(true);
- }
-
- if (facade != null) {
- // Change the facade delegate
- facade.setDelegate((EnvironmentWrapper)newEnv);
- newEnv = facade;
- }
-
- // Get the processor that should process this request
- ConcreteTreeProcessor processor;
- if (newEnv.getRootContext().equals(newEnv.getContext())) {
- processor = ((TreeProcessor)getRootProcessor()).concreteProcessor;
- } else {
- processor = this;
- }
-
- // Process the redirect
- // No more reset since with TreeProcessorRedirector, we need to pop values from the redirect location
- // context.reset();
- // The following is a fix for bug #26854 and #26571
- final boolean result = processor.process(newEnv, context);
- if ( facade != null ) {
- newEnv = facade.getDelegate();
- }
- if ( ((ForwardEnvironmentWrapper)newEnv).getRedirectURL() != null ) {
- environment.redirect( false, ((ForwardEnvironmentWrapper)newEnv).getRedirectURL() );
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.apache.avalon.framework.activity.Disposable#dispose()
- */
- 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;
- }
-
- private class TreeProcessorRedirector extends ForwardRedirector {
-
- private InvokeContext context;
- public TreeProcessorRedirector(Environment env, InvokeContext context) {
- super(env);
- this.context = context;
- }
-
- protected void cocoonRedirect(String uri) throws IOException, ProcessingException {
- try {
- ConcreteTreeProcessor.this.handleCocoonRedirect(uri, this.env, this.context);
- } catch(IOException ioe) {
- throw ioe;
- } catch(ProcessingException pe) {
- throw pe;
- } catch(RuntimeException re) {
- throw re;
- } catch(Exception ex) {
- throw new ProcessingException(ex);
- }
- }
- }
-
- /**
- * Local extension of EnvironmentWrapper to propagate otherwise blocked
- * methods to the actual environment.
- */
- private static final class ForwardEnvironmentWrapper extends EnvironmentWrapper {
-
- public ForwardEnvironmentWrapper(Environment env,
- ComponentManager manager, String uri, Logger logger)
- throws MalformedURLException {
- super(env, manager, uri, logger, false);
- }
-
- public void setStatus(int statusCode) {
- environment.setStatus(statusCode);
- }
-
- public void setContentLength(int length) {
- environment.setContentLength(length);
- }
-
- public void setContentType(String contentType) {
- environment.setContentType(contentType);
- }
-
- public String getContentType() {
- return environment.getContentType();
- }
-
- public boolean isResponseModified(long lastModified) {
- return environment.isResponseModified(lastModified);
- }
-
- public void setResponseIsNotModified() {
- environment.setResponseIsNotModified();
- }
- }
-
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.components.ChainedConfiguration;
+import org.apache.cocoon.components.CocoonComponentManager;
+import org.apache.cocoon.components.pipeline.ProcessingPipeline;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.ForwardRedirector;
+import org.apache.cocoon.environment.Redirector;
+import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
+import org.apache.cocoon.environment.wrapper.MutableEnvironmentFacade;
+
+
+/**
+ * The concrete implementation of {@link Processor}, containing the evaluation tree and associated
+ * data such as component manager.
+ *
+ * @version CVS $Id: ConcreteTreeProcessor.java,v 1.1 2004/06/05 08:18:50 sylvain Exp $
+ */
+public class ConcreteTreeProcessor
+extends AbstractLogEnabled
+implements Processor, Disposable {
+
+ /** The processor that wraps us */
+ private TreeProcessor wrappingProcessor;
+
+ /** Component manager defined by the <map:components> of this sitemap */
+ ComponentManager sitemapComponentManager;
+
+ /** Processing nodes that need to be disposed with this processor */
+ private List disposableNodes;
+
+ /** Root node of the processing tree */
+ private ProcessingNode rootNode;
+
+ private Map sitemapComponentConfigurations;
+
+ private Configuration componentConfigurations;
+
+ /** Number of simultaneous uses of this processor (either by concurrent request or by internal requests) */
+ private int requestCount;
+
+ /** Builds a concrete processig, given the wrapping processor */
+ public ConcreteTreeProcessor(TreeProcessor wrappingProcessor) {
+ this.wrappingProcessor = wrappingProcessor;
+ }
+
+ /** Set the processor data, result of the treebuilder job */
+ 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 sitemap component configurations (called as part of the tree building process) */
+ public void setComponentConfigurations(Configuration componentConfigurations) {
+ this.componentConfigurations = componentConfigurations;
+ this.sitemapComponentConfigurations = null;
+ }
+
+ /**
+ * Get the sitemap component configurations
+ * @since 2.1
+ */
+ 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; }
+
+ /**
+ * Mark this processor as needing to be disposed. Actual call to {@link #dispose()} will occur when
+ * all request processings on this processor will be terminated.
+ */
+ 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();
+ }
+ }
+
+ public TreeProcessor getWrappingProcessor() {
+ return this.wrappingProcessor;
+ }
+
+ public Processor getRootProcessor() {
+ return this.wrappingProcessor.getRootProcessor();
+ }
+
+ /**
+ * Process the given <code>Environment</code> producing the output.
+ * @return If the processing is successfull <code>true</code> is returned.
+ * If not match is found in the sitemap <code>false</code>
+ * is returned.
+ * @throws org.apache.cocoon.ResourceNotFoundException If a sitemap component tries
+ * to access a resource which can not
+ * be found, e.g. the generator
+ * ConnectionResetException If the connection was reset
+ */
+ 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 <code>Environment</code> to assemble
+ * a <code>ProcessingPipeline</code>.
+ * @since 2.1
+ */
+ 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();
+ }
+ }
+
+ /**
+ * Do the actual processing, be it producing the response or just building the pipeline
+ * @param environment
+ * @param context
+ * @return true if the pipeline was successfully built, false otherwise.
+ * @throws Exception
+ */
+ 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);
+ try {
+ boolean success = this.rootNode.invoke(environment, context);
+
+ return success;
+
+ } finally {
+ CocoonComponentManager.leaveEnvironment();
+ // 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();
+ }
+ }
+ }
+
+ private boolean handleCocoonRedirect(String uri, Environment environment, InvokeContext context) throws Exception {
+
+ // Build an environment wrapper
+ // If the current env is a facade, change the delegate and continue processing the facade, since
+ // we may have other redirects that will in turn also change the facade delegate
+
+ MutableEnvironmentFacade facade = environment instanceof MutableEnvironmentFacade ?
+ ((MutableEnvironmentFacade)environment) : null;
+
+ if (facade != null) {
+ // Consider the facade delegate (the real environment)
+ environment = facade.getDelegate();
+ }
+
+ // test if this is a call from flow
+ boolean isRedirect = (environment.getObjectModel().remove("cocoon:forward") == null);
+ Environment newEnv = new ForwardEnvironmentWrapper(environment, this.sitemapComponentManager, uri, getLogger());
+ if ( isRedirect ) {
+ ((ForwardEnvironmentWrapper)newEnv).setInternalRedirect(true);
+ }
+
+ if (facade != null) {
+ // Change the facade delegate
+ facade.setDelegate((EnvironmentWrapper)newEnv);
+ newEnv = facade;
+ }
+
+ // Get the processor that should process this request
+ ConcreteTreeProcessor processor;
+ if (newEnv.getRootContext().equals(newEnv.getContext())) {
+ processor = ((TreeProcessor)getRootProcessor()).concreteProcessor;
+ } else {
+ processor = this;
+ }
+
+ // Process the redirect
+ // No more reset since with TreeProcessorRedirector, we need to pop values from the redirect location
+ // context.reset();
+ // The following is a fix for bug #26854 and #26571
+ final boolean result = processor.process(newEnv, context);
+ if ( facade != null ) {
+ newEnv = facade.getDelegate();
+ }
+ if ( ((ForwardEnvironmentWrapper)newEnv).getRedirectURL() != null ) {
+ environment.redirect( false, ((ForwardEnvironmentWrapper)newEnv).getRedirectURL() );
+ }
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.activity.Disposable#dispose()
+ */
+ 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;
+ }
+
+ private class TreeProcessorRedirector extends ForwardRedirector {
+
+ private InvokeContext context;
+ public TreeProcessorRedirector(Environment env, InvokeContext context) {
+ super(env);
+ this.context = context;
+ }
+
+ protected void cocoonRedirect(String uri) throws IOException, ProcessingException {
+ try {
+ ConcreteTreeProcessor.this.handleCocoonRedirect(uri, this.env, this.context);
+ } catch(IOException ioe) {
+ throw ioe;
+ } catch(ProcessingException pe) {
+ throw pe;
+ } catch(RuntimeException re) {
+ throw re;
+ } catch(Exception ex) {
+ throw new ProcessingException(ex);
+ }
+ }
+ }
+
+ /**
+ * Local extension of EnvironmentWrapper to propagate otherwise blocked
+ * methods to the actual environment.
+ */
+ private static final class ForwardEnvironmentWrapper extends EnvironmentWrapper {
+
+ public ForwardEnvironmentWrapper(Environment env,
+ ComponentManager manager, String uri, Logger logger)
+ throws MalformedURLException {
+ super(env, manager, uri, logger, false);
+ }
+
+ public void setStatus(int statusCode) {
+ environment.setStatus(statusCode);
+ }
+
+ public void setContentLength(int length) {
+ environment.setContentLength(length);
+ }
+
+ public void setContentType(String contentType) {
+ environment.setContentType(contentType);
+ }
+
+ public String getContentType() {
+ return environment.getContentType();
+ }
+
+ public boolean isResponseModified(long lastModified) {
+ return environment.isResponseModified(lastModified);
+ }
+
+ public void setResponseIsNotModified() {
+ environment.setResponseIsNotModified();
+ }
+ }
+
+}
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/selection/RegexpHeaderSelector.java
Url: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/selection/RegexpHeaderSelector.java?view=diff&rev=124799&p1=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/selection/RegexpHeaderSelector.java&r1=124798&p2=cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/selection/RegexpHeaderSelector.java&r2=124799
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/selection/RegexpHeaderSelector.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/selection/RegexpHeaderSelector.java Mon Jan 10 05:32:27 2005
@@ -49,7 +49,7 @@
* also be specified as a <code><map:parameter .../></code> inside the
* pipeline itself.</p>
*
- * @version CVS $Id: RegexpHeaderSelector.java 36086 2004-08-08 14:27:52Z ugo $
+ * @version CVS $Id$
*/
public class RegexpHeaderSelector extends AbstractRegexpSelector {