You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2007/05/17 03:12:16 UTC
svn commit: r538782 [1/2] - in /tapestry/tapestry5/trunk:
tapestry-core/src/main/java/org/apache/tapestry/
tapestry-core/src/main/java/org/apache/tapestry/annotations/
tapestry-core/src/main/java/org/apache/tapestry/corelib/base/
tapestry-core/src/main...
Author: hlship
Date: Wed May 16 18:12:11 2007
New Revision: 538782
URL: http://svn.apache.org/viewvc?view=rev&rev=538782
Log:
Rework PageTester: move to a proper package (org.apache.tapestry.test). Move the supporting code and interfaces to an internal package. Get rid of the "splinter interfaces"
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ActionLinkInvoker.java
- copied, changed from r538679, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ComponentInvoker.java
- copied, changed from r538679, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ComponentInvoker.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageLinkInvoker.java
- copied, changed from r538679, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageLinkInvoker.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterComponentInvocationMap.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterContext.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterModule.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterSession.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableCookieSinkSource.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequest.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequestImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableResponseImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/PageTester.java
- copied, changed from r538679, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/test/pagelevel/PageTesterContextTest.java
- copied, changed from r538679, tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/test/pagelevel/ContextForPageTesterTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/test/pagelevel/PageTesterSessionTest.java
- copied, changed from r538679, tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/test/pagelevel/SessionForPageTesterTest.java
Removed:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextPathSource.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FormParameterLookup.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionHolder.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/URLEncoder.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ComponentInvocationMapForPageTester.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ComponentInvoker.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ContextForPageTester.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/CookiesForPageTester.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/FooContextPathSource.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/FormParameterLookupForPageTester.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/NoOpURLEncoder.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageLinkInvoker.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageTester.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/SessionForPageTester.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTester.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/test/pagelevel/ContextForPageTesterTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/test/pagelevel/SessionForPageTesterTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/test/pagelevel/SessionHolderForPageTesterTest.java
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/RegistryBuilderOverrideTest.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/MarkupWriter.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryFilter.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/Parameter.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Form.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/FormSupportImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Submit.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryAppInitializer.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AbstractSessionPersistentFieldStrategy.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ClasspathAssetAliasManagerImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInvocation.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInvocationMap.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextAssetFactory.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CookiesImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FlashPersistentFieldStrategy.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/NoOpComponentInvocationMap.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageLinkTarget.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionApplicationStatePersistenceStrategy.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionPersistentFieldStrategy.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/FormSupport.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Request.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Response.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/FormSupportImplTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/corelib/components/SubmitTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/pagelevel/ASOTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/pagelevel/ActionLinkTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/pagelevel/AssetTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/pagelevel/DTDTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/pagelevel/FormTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/pagelevel/HeadTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/pagelevel/IfTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/pagelevel/LocaleTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/pagelevel/LoopTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/pagelevel/SubmitTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/pagelevel/TemplateInWEBINFTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/CookiesImplTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/SessionApplicationStatePersistenceStrategyTest.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/ObjectLocator.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/RegistryBuilder.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/InternalRegistry.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ObjectLocatorImpl.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/MarkupWriter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/MarkupWriter.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/MarkupWriter.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/MarkupWriter.java Wed May 16 18:12:11 2007
@@ -38,7 +38,7 @@
* date). Optionally, attributes for the new element can be specified directly.
* <p>
* If the element is intended to be clickable or submittable in the
- * {@link org.apache.tapestry.test.pagelevel.PageTester}, you should call
+ * {@link org.apache.tapestry.test.PageTester}, you should call
* {@link #linkElement(String, Link, Object[])} instead.
*
* @param name
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryFilter.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryFilter.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/TapestryFilter.java Wed May 16 18:12:11 2007
@@ -70,7 +70,9 @@
SymbolProvider provider = new ServletContextSymbolProvider(context);
TapestryAppInitializer appInitializer = new TapestryAppInitializer(provider, filterName,
- "servlet", provideExtraModuleDefs(context));
+ "servlet");
+
+ appInitializer.addModules(provideExtraModuleDefs(context));
_registry = appInitializer.getRegistry();
@@ -122,7 +124,7 @@
/** Shuts down and discards the registry. */
public final void destroy()
-
+
{
_registry.shutdown();
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/Parameter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/Parameter.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/Parameter.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/Parameter.java Wed May 16 18:12:11 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -21,6 +21,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+import org.apache.tapestry.TapestryConstants;
import org.apache.tapestry.services.BindingFactory;
/**
@@ -30,7 +31,8 @@
@Target(FIELD)
@Documented
@Retention(RUNTIME)
-public @interface Parameter {
+public @interface Parameter
+{
/**
* The name of the parameter. If not specified, the name of the parameter is derived from the
@@ -65,7 +67,7 @@
* default binding prefixes are paired with specific {@link BindingFactory} implementations, and
* used with parameters whose name reflects the binding prefix.
*/
- String defaultPrefix() default "prop";
+ String defaultPrefix() default TapestryConstants.PROP_BINDING_PREFIX;
/**
* Used to mark a parameter as requiring earlier initialization than other parameters. This is
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java Wed May 16 18:12:11 2007
@@ -31,6 +31,7 @@
import org.apache.tapestry.ioc.Messages;
import org.apache.tapestry.services.FieldValidatorDefaultSource;
import org.apache.tapestry.services.FormSupport;
+import org.apache.tapestry.services.Request;
import org.apache.tapestry.services.TranslatorDefaultSource;
import org.apache.tapestry.services.ValidationMessagesSource;
@@ -84,6 +85,9 @@
@Inject
private Locale _locale;
+ @Inject
+ private Request _request;
+
/**
* Computes a default value for the "translate" parameter using {@link TranslatorDefaultSource}.
*/
@@ -162,7 +166,7 @@
@Override
protected final void processSubmission(FormSupport formSupport, String elementName)
{
- String rawValue = formSupport.getParameterValue(elementName);
+ String rawValue = _request.getParameter(elementName);
_tracker.recordInput(this, rawValue);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Checkbox.java Wed May 16 18:12:11 2007
@@ -18,13 +18,17 @@
import org.apache.tapestry.MarkupWriter;
import org.apache.tapestry.annotations.AfterRender;
import org.apache.tapestry.annotations.BeginRender;
+import org.apache.tapestry.annotations.Inject;
import org.apache.tapestry.annotations.Parameter;
import org.apache.tapestry.corelib.base.AbstractField;
import org.apache.tapestry.services.FormSupport;
+import org.apache.tapestry.services.Request;
/** A Checkbox component is simply a <input type="checkbox">. */
public class Checkbox extends AbstractField
{
+ @Inject
+ private Request _request;
/**
* The value to be read or updated. If not bound, the Checkbox will attempt to edit a property
@@ -64,7 +68,7 @@
@Override
protected void processSubmission(FormSupport formSupport, String elementName)
{
- String postedValue = formSupport.getParameterValue(elementName);
+ String postedValue = _request.getParameter(elementName);
_value = postedValue != null;
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Form.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Form.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Form.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Form.java Wed May 16 18:12:11 2007
@@ -42,7 +42,6 @@
import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.corelib.mixins.RenderInformals;
import org.apache.tapestry.dom.Element;
-import org.apache.tapestry.internal.services.FormParameterLookup;
import org.apache.tapestry.internal.services.HeartbeatImpl;
import org.apache.tapestry.internal.util.Base64ObjectInputStream;
import org.apache.tapestry.internal.util.Base64ObjectOutputStream;
@@ -54,6 +53,7 @@
import org.apache.tapestry.services.Environment;
import org.apache.tapestry.services.FormSupport;
import org.apache.tapestry.services.Heartbeat;
+import org.apache.tapestry.services.Request;
/**
* An HTML form, which will enclose other components to render out the various types of fields.
@@ -150,7 +150,7 @@
private PageRenderSupport _pageRenderSupport;
@Inject
- private FormParameterLookup _paramLookup;
+ private Request _request;
@Inject
private ComponentSource _source;
@@ -294,7 +294,7 @@
{
_tracker.clear();
- _formSupport = new FormSupportImpl(_paramLookup);
+ _formSupport = new FormSupportImpl();
_environment.push(ValidationTracker.class, _tracker);
_environment.push(FormSupport.class, _formSupport);
@@ -332,7 +332,7 @@
// TODO: Ajax stuff will eventually mean there are multiple values for this parameter
// name
- String actionsBase64 = _paramLookup.getParameter(FORM_DATA);
+ String actionsBase64 = _request.getParameter(FORM_DATA);
try
{
@@ -401,7 +401,9 @@
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tapestry.corelib.components.FormValidationControl#recordError(java.lang.String)
*/
public void recordError(String errorMessage)
@@ -413,8 +415,11 @@
_tracker = tracker;
}
- /* (non-Javadoc)
- * @see org.apache.tapestry.corelib.components.FormValidationControl#recordError(org.apache.tapestry.Field, java.lang.String)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tapestry.corelib.components.FormValidationControl#recordError(org.apache.tapestry.Field,
+ * java.lang.String)
*/
public void recordError(Field field, String errorMessage)
{
@@ -425,7 +430,9 @@
_tracker = tracker;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tapestry.corelib.components.FormValidationControl#getHasErrors()
*/
public boolean getHasErrors()
@@ -433,7 +440,9 @@
return _tracker.getHasErrors();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tapestry.corelib.components.FormValidationControl#isValid()
*/
public boolean isValid()
@@ -448,7 +457,9 @@
_tracker = tracker;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.tapestry.corelib.components.FormValidationControl#clearErrors()
*/
public void clearErrors()
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/FormSupportImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/FormSupportImpl.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/FormSupportImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/FormSupportImpl.java Wed May 16 18:12:11 2007
@@ -23,7 +23,6 @@
import java.util.List;
import org.apache.tapestry.ComponentAction;
-import org.apache.tapestry.internal.services.FormParameterLookup;
import org.apache.tapestry.ioc.internal.util.IdAllocator;
import org.apache.tapestry.runtime.Component;
import org.apache.tapestry.services.FormSupport;
@@ -43,33 +42,19 @@
private final ObjectOutputStream _actions;
- private final FormParameterLookup _parameterLookup;
-
private List<Runnable> _commands;
/** Constructor used when processing a form submission. */
- public FormSupportImpl(FormParameterLookup parameterLookup)
+ public FormSupportImpl()
{
- this(null, null, parameterLookup);
+ this(null, null);
}
/** Constructor used when rendering. */
public FormSupportImpl(String clientId, ObjectOutputStream actions)
{
- this(clientId, actions, null);
- }
-
- /** For testing only. */
- FormSupportImpl()
- {
- this(null, null, null);
- }
-
- FormSupportImpl(String clientId, ObjectOutputStream actions, FormParameterLookup parameterLookup)
- {
_clientId = clientId;
_actions = actions;
- _parameterLookup = parameterLookup;
}
public String allocateElementName(String id)
@@ -108,26 +93,19 @@
public void defer(Runnable command)
{
- if (_commands == null)
- _commands = newList();
+ if (_commands == null) _commands = newList();
_commands.add(notNull(command, "command"));
}
void executeDeferred()
{
- if (_commands == null)
- return;
+ if (_commands == null) return;
for (Runnable r : _commands)
r.run();
_commands.clear();
- }
-
- public String getParameterValue(String name)
- {
- return _parameterLookup.getParameter(name);
}
public String getClientId()
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Select.java Wed May 16 18:12:11 2007
@@ -35,6 +35,7 @@
import org.apache.tapestry.corelib.base.AbstractField;
import org.apache.tapestry.services.FieldValidatorDefaultSource;
import org.apache.tapestry.services.FormSupport;
+import org.apache.tapestry.services.Request;
import org.apache.tapestry.util.EnumSelectModel;
import org.apache.tapestry.util.EnumValueEncoder;
@@ -95,6 +96,9 @@
@Inject
private Locale _locale;
+ @Inject
+ private Request _request;
+
Binding defaultValue()
{
return createDefaultParameterBinding("value");
@@ -227,7 +231,7 @@
@Override
protected void processSubmission(FormSupport formSupport, String elementName)
{
- String primaryKey = formSupport.getParameterValue(elementName);
+ String primaryKey = _request.getParameter(elementName);
Object selectedValue = _encoder.toValue(primaryKey);
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Submit.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Submit.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Submit.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/Submit.java Wed May 16 18:12:11 2007
@@ -22,6 +22,7 @@
import org.apache.tapestry.corelib.base.AbstractField;
import org.apache.tapestry.services.FormSupport;
import org.apache.tapestry.services.Heartbeat;
+import org.apache.tapestry.services.Request;
/**
* Corresponds to <input type="submit">, a client-side element that can force the enclosing
@@ -49,6 +50,18 @@
@Inject
private ComponentResources _resources;
+ @Inject
+ private Request _request;
+
+ public Submit()
+ {
+ }
+
+ Submit(Request request)
+ {
+ _request = request;
+ }
+
void beginRender(MarkupWriter writer)
{
writer.element("input", "type", "submit", "name", getElementName(), "id", getClientId());
@@ -62,7 +75,7 @@
@Override
protected void processSubmission(FormSupport formSupport, String elementName)
{
- String value = formSupport.getParameterValue(elementName);
+ String value = _request.getParameter(elementName);
if (value == null) return;
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryAppInitializer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryAppInitializer.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryAppInitializer.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryAppInitializer.java Wed May 16 18:12:11 2007
@@ -14,9 +14,6 @@
package org.apache.tapestry.internal;
-import java.util.Map;
-import java.util.Map.Entry;
-
import org.apache.tapestry.ioc.IOCUtilities;
import org.apache.tapestry.ioc.Registry;
import org.apache.tapestry.ioc.RegistryBuilder;
@@ -26,7 +23,7 @@
import org.apache.tapestry.ioc.services.SymbolProvider;
import org.apache.tapestry.services.Alias;
import org.apache.tapestry.services.TapestryModule;
-import org.apache.tapestry.test.pagelevel.PageTester;
+import org.apache.tapestry.test.PageTester;
/**
* This class is used to build the {@link Registry}. The Registry contains
@@ -48,13 +45,11 @@
private final String _aliasMode;
- private final Registry _registry;
-
private final long _startTime;
- private final long _registryCreatedTime;
+ private long _registryCreatedTime;
- private final Map<String, Object> _serviceOverrides;
+ private final RegistryBuilder _builder = new RegistryBuilder();
public TapestryAppInitializer(String appPackage, String appName, String aliasMode)
{
@@ -62,12 +57,6 @@
appName, aliasMode);
}
- public TapestryAppInitializer(SymbolProvider appProvider, String appName, String aliasMode,
- ModuleDef... moduleDefs)
- {
- this(appProvider, appName, aliasMode, null, moduleDefs);
- }
-
/**
* @param appProvider
* provides symbols for the application (normally, from the ServletContext init
@@ -81,8 +70,7 @@
* @param moduleDefs
* additional module definitions to be mixed in to those automatically located
*/
- public TapestryAppInitializer(SymbolProvider appProvider, String appName, String aliasMode,
- Map<String, Object> serviceOverrides, ModuleDef... moduleDefs)
+ public TapestryAppInitializer(SymbolProvider appProvider, String appName, String aliasMode)
{
_appProvider = appProvider;
@@ -90,20 +78,14 @@
_appName = appName;
_aliasMode = aliasMode;
- _serviceOverrides = serviceOverrides;
_startTime = System.currentTimeMillis();
- _registry = createRegistry(moduleDefs);
+ IOCUtilities.addDefaultModules(_builder);
- _registryCreatedTime = System.currentTimeMillis();
- }
-
- private Registry createRegistry(ModuleDef... moduleDefs)
- {
- RegistryBuilder builder = new RegistryBuilder();
+ // This gets added automatically.
- builder.add(TapestryModule.class);
+ addModules(TapestryModule.class);
String className = _appPackage + ".services." + InternalUtils.capitalize(_appName)
+ "Module";
@@ -115,7 +97,8 @@
// if any.
Class moduleClass = Thread.currentThread().getContextClassLoader().loadClass(className);
- builder.add(moduleClass);
+
+ _builder.add(moduleClass);
}
catch (ClassNotFoundException ex)
{
@@ -123,23 +106,28 @@
// non-trivial application will.
}
- addModules(builder);
-
- // Add any explicitly provided module defs
-
- for (ModuleDef def : moduleDefs)
- builder.add(def);
-
// Add a synthetic module that contributes symbol sources.
- addSyntheticSymbolSourceModule(builder);
+ addSyntheticSymbolSourceModule();
+ }
- overrideServices(builder);
+ /**
+ * Adds additional modules.
+ *
+ * @param moduleDefs
+ */
+ public void addModules(ModuleDef... moduleDefs)
+ {
+ for (ModuleDef def : moduleDefs)
+ _builder.add(def);
+ }
- return builder.build();
+ public void addModules(Class... moduleBuilderClasses)
+ {
+ _builder.add(moduleBuilderClasses);
}
- private void addSyntheticSymbolSourceModule(RegistryBuilder builder)
+ private void addSyntheticSymbolSourceModule()
{
ContributionDef symbolSourceContribution = new SyntheticSymbolSourceContributionDef(
"ServletContext", _appProvider, "before:ApplicationDefaults");
@@ -153,38 +141,15 @@
new SingleKeySymbolProvider(InternalConstants.TAPESTRY_APP_NAME_SYMBOL, _appName),
"before:ServletContext");
- builder.add(new SyntheticModuleDef(symbolSourceContribution, aliasModeContribution,
+ _builder.add(new SyntheticModuleDef(symbolSourceContribution, aliasModeContribution,
appNameContribution));
}
- private void overrideServices(RegistryBuilder builder)
- {
- if (_serviceOverrides != null)
- {
- for (Entry<String, Object> e : _serviceOverrides.entrySet())
- {
- builder.addServiceOverride(e.getKey(), e.getValue());
- }
- }
- }
-
- /**
- * Adds additional modules to the builder. This implementation adds any modules identified by
- * {@link IOCUtilities#addDefaultModules(RegistryBuilder)}. Most subclasses will invoke this
- * implementation, and add additional modules to the RegistryBuilder besides.
- * {@link org.apache.tapestry.ioc.services.TapestryIOCModule} and {@link TapestryModule} will
- * already have been added, as will an application module if present.
- *
- * @param builder
- */
- protected void addModules(RegistryBuilder builder)
- {
- IOCUtilities.addDefaultModules(builder);
- }
-
public Registry getRegistry()
{
- return _registry;
+ _registryCreatedTime = System.currentTimeMillis();
+
+ return _builder.build();
}
/**
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AbstractSessionPersistentFieldStrategy.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AbstractSessionPersistentFieldStrategy.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AbstractSessionPersistentFieldStrategy.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/AbstractSessionPersistentFieldStrategy.java Wed May 16 18:12:11 2007
@@ -23,6 +23,7 @@
import org.apache.tapestry.services.PersistentFieldChange;
import org.apache.tapestry.services.PersistentFieldStrategy;
+import org.apache.tapestry.services.Request;
import org.apache.tapestry.services.Session;
/**
@@ -33,20 +34,19 @@
{
private final String _prefix;
- private final SessionHolder _sessionHolder;
+ private final Request _request;
- protected AbstractSessionPersistentFieldStrategy(String prefix, SessionHolder sessionHolder)
+ protected AbstractSessionPersistentFieldStrategy(String prefix, Request request)
{
_prefix = prefix;
- _sessionHolder = sessionHolder;
+ _request = request;
}
public final Collection<PersistentFieldChange> gatherFieldChanges(String pageName)
{
- Session session = _sessionHolder.getSession(false);
+ Session session = _request.getSession(false);
- if (session == null)
- return Collections.emptyList();
+ if (session == null) return Collections.emptyList();
List<PersistentFieldChange> result = newList();
@@ -101,13 +101,12 @@
builder.append(pageName);
builder.append(':');
- if (componentId != null)
- builder.append(componentId);
+ if (componentId != null) builder.append(componentId);
builder.append(':');
builder.append(fieldName);
- Session session = _sessionHolder.getSession(true);
+ Session session = _request.getSession(true);
session.setAttribute(builder.toString(), newValue);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ClasspathAssetAliasManagerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ClasspathAssetAliasManagerImpl.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ClasspathAssetAliasManagerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ClasspathAssetAliasManagerImpl.java Wed May 16 18:12:11 2007
@@ -23,12 +23,12 @@
import java.util.Map;
import org.apache.tapestry.TapestryConstants;
-import org.apache.tapestry.ioc.annotations.InjectService;
import org.apache.tapestry.services.ClasspathAssetAliasManager;
+import org.apache.tapestry.services.Request;
public class ClasspathAssetAliasManagerImpl implements ClasspathAssetAliasManager
{
- private final ContextPathSource _contextPathSource;
+ private final Request _request;
/** Map from alias to path. */
private final Map<String, String> _aliasToPathPrefix;
@@ -44,12 +44,11 @@
* Configuration is a map of aliases (short names) to complete names. Keys and values should not
* start with a slash, but should end with one. Example: "tapestry/" --> "org/apache/tapestry/".
*/
- public ClasspathAssetAliasManagerImpl(@InjectService("ContextPathSource")
- ContextPathSource contextPathSource,
+ public ClasspathAssetAliasManagerImpl(Request request,
final Map<String, String> configuration)
{
- _contextPathSource = contextPathSource;
+ _request = request;
_aliasToPathPrefix = configuration;
@@ -75,7 +74,7 @@
public String toClientURL(String resourcePath)
{
- StringBuilder builder = new StringBuilder(_contextPathSource.getContextPath());
+ StringBuilder builder = new StringBuilder(_request.getContextPath());
builder.append(TapestryConstants.ASSET_PATH_PREFIX);
for (String pathPrefix : _sortedPathPrefixes)
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInvocation.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInvocation.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInvocation.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInvocation.java Wed May 16 18:12:11 2007
@@ -21,7 +21,7 @@
import org.apache.tapestry.internal.TapestryInternalUtils;
import org.apache.tapestry.ioc.internal.util.InternalUtils;
-import org.apache.tapestry.test.pagelevel.PageTester;
+import org.apache.tapestry.test.PageTester;
/**
* Represents an invocation for a page or a component in the current application. This information
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInvocationMap.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInvocationMap.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInvocationMap.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInvocationMap.java Wed May 16 18:12:11 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -18,7 +18,7 @@
import org.apache.tapestry.MarkupWriter;
import org.apache.tapestry.dom.Document;
import org.apache.tapestry.dom.Element;
-import org.apache.tapestry.test.pagelevel.PageTester;
+import org.apache.tapestry.test.PageTester;
/**
* Used by the {@link PageTester} to map {@link Element}s (pulled from the rendered
@@ -36,7 +36,7 @@
/** Stores a connection between a particular link and an invocation of a component. */
void store(Link link, ComponentInvocation invocation);
- /* Stores a connection between an element and the link associated with that element. */
+ /** Stores a connection between an element and the link associated with that element. */
void store(Element element, Link link);
/**
@@ -47,4 +47,15 @@
* @return associcated component invocation, or null
*/
ComponentInvocation get(Link link);
+
+ /**
+ * Returns the invocation associated with a rendered element.
+ *
+ * @param element
+ * extracted from the rendered {@link Document}
+ * @return the corresponding invocation
+ */
+ ComponentInvocation get(Element element);
+
+ void clear();
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextAssetFactory.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextAssetFactory.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextAssetFactory.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextAssetFactory.java Wed May 16 18:12:11 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -18,6 +18,7 @@
import org.apache.tapestry.ioc.Resource;
import org.apache.tapestry.services.AssetFactory;
import org.apache.tapestry.services.Context;
+import org.apache.tapestry.services.Request;
/**
* Implementation of {@link AssetFactory} for assets that are part of the web application context.
@@ -26,19 +27,19 @@
*/
public class ContextAssetFactory implements AssetFactory
{
- private final ContextPathSource _contextPathSource;
+ private final Request _request;
private final Context _context;
- public ContextAssetFactory(ContextPathSource contextPathSource, Context context)
+ public ContextAssetFactory(Request request, Context context)
{
- _contextPathSource = contextPathSource;
+ _request = request;
_context = context;
}
public Asset createAsset(final Resource resource)
{
- final String contextPath = _contextPathSource.getContextPath() + "/" + resource.getPath();
+ final String contextPath = _request.getContextPath() + "/" + resource.getPath();
return new Asset()
{
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CookiesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CookiesImpl.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CookiesImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CookiesImpl.java Wed May 16 18:12:11 2007
@@ -16,16 +16,16 @@
import javax.servlet.http.Cookie;
-import org.apache.tapestry.ioc.annotations.InjectService;
import org.apache.tapestry.ioc.annotations.Symbol;
import org.apache.tapestry.services.Cookies;
+import org.apache.tapestry.services.Request;
/**
* Implementation of the {@link org.apache.tapestry.services.Cookies} service interface.
*/
public class CookiesImpl implements Cookies
{
- private ContextPathSource _contextPathSource;
+ private Request _request;
private CookieSource _cookieSource;
@@ -33,19 +33,16 @@
private int _defaultMaxAge;
- public CookiesImpl(@InjectService("ContextPathSource")
- ContextPathSource contextPathSource,
+ public CookiesImpl(Request request,
- @InjectService("CookieSource")
CookieSource cookieSource,
- @InjectService("CookieSink")
CookieSink cookieSink,
@Symbol("tapestry.default-cookie-max-age")
int defaultMaxAge)
{
- _contextPathSource = contextPathSource;
+ _request = request;
_cookieSource = cookieSource;
_cookieSink = cookieSink;
_defaultMaxAge = defaultMaxAge;
@@ -73,7 +70,7 @@
public void writeCookieValue(String name, String value, int maxAge)
{
Cookie cookie = new Cookie(name, value);
- cookie.setPath(_contextPathSource.getContextPath() + "/");
+ cookie.setPath(_request.getContextPath() + "/");
cookie.setMaxAge(maxAge);
_cookieSink.addCookie(cookie);
@@ -83,23 +80,26 @@
{
Cookie cookie = new Cookie(name, value);
cookie.setPath(path);
+
_cookieSink.addCookie(cookie);
}
public void writeDomainCookieValue(String name, String value, String domain)
{
Cookie cookie = new Cookie(name, value);
- cookie.setPath(_contextPathSource.getContextPath() + "/");
+ cookie.setPath(_request.getContextPath() + "/");
cookie.setDomain(domain);
+
_cookieSink.addCookie(cookie);
}
public void writeDomainCookieValue(String name, String value, String domain, int maxAge)
{
Cookie cookie = new Cookie(name, value);
- cookie.setPath(_contextPathSource.getContextPath() + "/");
+ cookie.setPath(_request.getContextPath() + "/");
cookie.setDomain(domain);
cookie.setMaxAge(maxAge);
+
_cookieSink.addCookie(cookie);
}
@@ -108,14 +108,16 @@
Cookie cookie = new Cookie(name, value);
cookie.setPath(path);
cookie.setDomain(domain);
+
_cookieSink.addCookie(cookie);
}
public void removeCookieValue(String name)
{
Cookie cookie = new Cookie(name, null);
- cookie.setPath(_contextPathSource.getContextPath() + "/");
+ cookie.setPath(_request.getContextPath() + "/");
cookie.setMaxAge(0);
+
_cookieSink.addCookie(cookie);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FlashPersistentFieldStrategy.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FlashPersistentFieldStrategy.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FlashPersistentFieldStrategy.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FlashPersistentFieldStrategy.java Wed May 16 18:12:11 2007
@@ -14,6 +14,7 @@
package org.apache.tapestry.internal.services;
+import org.apache.tapestry.services.Request;
import org.apache.tapestry.services.Session;
/**
@@ -29,9 +30,9 @@
*/
static final String PREFIX = "flash:";
- public FlashPersistentFieldStrategy(SessionHolder sessionHolder)
+ public FlashPersistentFieldStrategy(Request request)
{
- super(PREFIX, sessionHolder);
+ super(PREFIX, request);
}
@Override
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalModule.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalModule.java Wed May 16 18:12:11 2007
@@ -90,17 +90,6 @@
binder.bind(ResourceStreamer.class, ResourceStreamerImpl.class);
}
- public static void contributeAlias(Configuration<AliasContribution> configuration,
- ObjectLocator locator)
- {
- add(
- configuration,
- locator,
- FormParameterLookup.class,
- ContextPathSource.class,
- URLEncoder.class);
- }
-
@SuppressWarnings("unchecked")
private static void add(Configuration<AliasContribution> configuration, ObjectLocator locator,
Class... serviceInterfaces)
@@ -177,8 +166,6 @@
private final RequestGlobals _requestGlobals;
- private final ContextPathSource _contextPathSource;
-
public InternalModule(@InjectService("ComponentInstantiatorSource")
ComponentInstantiatorSource componentInstantiatorSource,
@@ -201,9 +188,6 @@
Response response,
- @InjectService("ContextPathSource")
- ContextPathSource contextPathSource,
-
@InjectService("ThreadLocale")
ThreadLocale threadLocale,
@@ -219,7 +203,6 @@
_response = response;
_threadLocale = threadLocale;
_requestGlobals = requestGlobals;
- _contextPathSource = contextPathSource;
}
public PageTemplateLocator build(@InjectService("ContextAssetFactory")
@@ -332,12 +315,7 @@
public AssetFactory buildContextAssetFactory(ApplicationGlobals globals)
{
- return new ContextAssetFactory(_contextPathSource, globals.getContext());
- }
-
- public ContextPathSource buildContextPathSource()
- {
- return _request;
+ return new ContextAssetFactory(_request, globals.getContext());
}
public CookieSink buildCookieSink()
@@ -366,11 +344,6 @@
};
}
- public FormParameterLookup buildFormParameterLookup()
- {
- return _request;
- }
-
/**
* Builds the PropBindingFactory as a chain of command. The terminator of the chain is
* responsible for ordinary property names (and property paths). Contributions to the service
@@ -397,16 +370,6 @@
{
configuration.add("css", "text/css");
configuration.add("js", "text/javascript");
- }
-
- public SessionHolder buildSessionHolder()
- {
- return _request;
- }
-
- public URLEncoder buildURLEncoder()
- {
- return _response;
}
/**
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java Wed May 16 18:12:11 2007
@@ -35,12 +35,14 @@
import org.apache.tapestry.ioc.util.StrategyRegistry;
import org.apache.tapestry.runtime.Component;
import org.apache.tapestry.services.ComponentClassResolver;
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.services.Response;
public class LinkFactoryImpl implements LinkFactory
{
- private final ContextPathSource _contextPathSource;
+ private final Request _request;
- private final URLEncoder _encoder;
+ private final Response _response;
private final ComponentClassResolver _componentClassResolver;
@@ -59,13 +61,13 @@
void handle(T result, List context);
}
- public LinkFactoryImpl(ContextPathSource contextPathSource, URLEncoder encoder,
+ public LinkFactoryImpl(Request request, Response encoder,
ComponentClassResolver componentClassResolver,
ComponentInvocationMap componentInvocationMap, RequestPageCache pageCache,
TypeCoercer typeCoercer)
{
- _contextPathSource = contextPathSource;
- _encoder = encoder;
+ _request = request;
+ _response = encoder;
_componentClassResolver = componentClassResolver;
_componentInvocationMap = componentInvocationMap;
_pageCache = pageCache;
@@ -130,7 +132,7 @@
ComponentInvocation invocation = new ComponentInvocation(target, contextStrings,
activationContext);
- Link link = new LinkImpl(_encoder, _contextPathSource.getContextPath(), invocation, forForm);
+ Link link = new LinkImpl(_response, _request.getContextPath(), invocation, forForm);
// Now see if the page has an activation context.
@@ -148,15 +150,13 @@
private void addActivationContextToLink(Link link, String[] activationContext)
{
- if (activationContext.length == 0)
- return;
+ if (activationContext.length == 0) return;
StringBuilder builder = new StringBuilder();
for (int i = 0; i < activationContext.length; i++)
{
- if (i > 0)
- builder.append("/");
+ if (i > 0) builder.append("/");
builder.append(TapestryInternalUtils.urlEncode(activationContext[i]));
}
@@ -178,7 +178,7 @@
PageLinkTarget target = new PageLinkTarget(logicalPageName);
ComponentInvocation invocation = new ComponentInvocation(target, context, null);
- Link link = new LinkImpl(_encoder, _contextPathSource.getContextPath(), invocation, false);
+ Link link = new LinkImpl(_response, _request.getContextPath(), invocation, false);
_componentInvocationMap.store(link, invocation);
@@ -218,8 +218,7 @@
private String[] toContextStrings(Object[] context)
{
- if (context == null)
- return new String[0];
+ if (context == null) return new String[0];
String[] result = new String[context.length];
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkImpl.java Wed May 16 18:12:11 2007
@@ -17,13 +17,14 @@
import java.util.List;
import org.apache.tapestry.Link;
+import org.apache.tapestry.services.Response;
/**
* Starting implementation of {@link Link}. Currently does not support query parameters.
*/
public class LinkImpl implements Link
{
- private final URLEncoder _encoder;
+ private final Response _response;
private final String _contextPath;
@@ -31,22 +32,22 @@
private final boolean _forForm;
- public LinkImpl(URLEncoder encoder, String contextPath, String targetPath)
+ public LinkImpl(Response encoder, String contextPath, String targetPath)
{
this(encoder, contextPath, targetPath, false);
}
- public LinkImpl(URLEncoder encoder, String contextPath, String targetPath, boolean forForm)
+ public LinkImpl(Response encoder, String contextPath, String targetPath, boolean forForm)
{
this(encoder, contextPath, new ComponentInvocation(new OpaqueConstantTarget(targetPath),
new String[0], null), forForm);
}
- public LinkImpl(URLEncoder encoder, String contextPath, ComponentInvocation invocation,
+ public LinkImpl(Response encoder, String contextPath, ComponentInvocation invocation,
boolean forForm)
{
_contextPath = contextPath;
- _encoder = encoder;
+ _response = encoder;
_invocation = invocation;
_forForm = forForm;
}
@@ -68,7 +69,7 @@
public String toURI()
{
- return _encoder.encodeURL(buildURI());
+ return _response.encodeURL(buildURI());
}
private String buildURI()
@@ -82,7 +83,7 @@
public String toRedirectURI()
{
- return _encoder.encodeRedirectURL(buildURI());
+ return _response.encodeRedirectURL(buildURI());
}
public ComponentInvocation getInvocation()
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/NoOpComponentInvocationMap.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/NoOpComponentInvocationMap.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/NoOpComponentInvocationMap.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/NoOpComponentInvocationMap.java Wed May 16 18:12:11 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -33,6 +33,15 @@
}
public ComponentInvocation get(Link link)
+ {
+ return null;
+ }
+
+ public void clear()
+ {
+ }
+
+ public ComponentInvocation get(Element element)
{
return null;
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageLinkTarget.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageLinkTarget.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageLinkTarget.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PageLinkTarget.java Wed May 16 18:12:11 2007
@@ -17,7 +17,7 @@
/**
* It represents a component invocation target for a page link. It is passed to an
* {@link org.apache.tapestry.internal.services.ActionLinkHandler} by both the
- * {@link org.apache.tapestry.test.pagelevel.PageTester} and the real Tapestry code
+ * {@link org.apache.tapestry.test.PageTester} and the real Tapestry code
* {@link org.apache.tapestry.internal.services.PageRenderDispatcher} in order to invoke a page
* link.
*/
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionApplicationStatePersistenceStrategy.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionApplicationStatePersistenceStrategy.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionApplicationStatePersistenceStrategy.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionApplicationStatePersistenceStrategy.java Wed May 16 18:12:11 2007
@@ -16,6 +16,7 @@
import org.apache.tapestry.services.ApplicationStateCreator;
import org.apache.tapestry.services.ApplicationStatePersistenceStrategy;
+import org.apache.tapestry.services.Request;
import org.apache.tapestry.services.Session;
/**
@@ -29,16 +30,16 @@
{
static final String PREFIX = "aso:";
- private final SessionHolder _sessionHolder;
+ private final Request _request;
- public SessionApplicationStatePersistenceStrategy(SessionHolder sessionHolder)
+ public SessionApplicationStatePersistenceStrategy(Request request)
{
- _sessionHolder = sessionHolder;
+ _request = request;
}
private Session getSession()
{
- return _sessionHolder.getSession(true);
+ return _request.getSession(true);
}
@SuppressWarnings("unchecked")
@@ -75,7 +76,7 @@
{
String key = buildKey(asoClass);
- Session session = _sessionHolder.getSession(false);
+ Session session = _request.getSession(false);
return session != null && session.getAttribute(key) != null;
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionPersistentFieldStrategy.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionPersistentFieldStrategy.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionPersistentFieldStrategy.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/SessionPersistentFieldStrategy.java Wed May 16 18:12:11 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -14,6 +14,7 @@
package org.apache.tapestry.internal.services;
+import org.apache.tapestry.services.Request;
import org.apache.tapestry.services.Session;
/**
@@ -31,8 +32,8 @@
*/
static final String PREFIX = "state:";
- public SessionPersistentFieldStrategy(SessionHolder sessionHolder)
+ public SessionPersistentFieldStrategy(Request request)
{
- super(PREFIX, sessionHolder);
+ super(PREFIX, request);
}
}
Copied: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ActionLinkInvoker.java (from r538679, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ActionLinkInvoker.java?view=diff&rev=538782&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java&r1=538679&p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ActionLinkInvoker.java&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ActionLinkInvoker.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ActionLinkInvoker.java Wed May 16 18:12:11 2007
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.test.pagelevel;
+package org.apache.tapestry.internal.test;
import org.apache.tapestry.Link;
import org.apache.tapestry.dom.Document;
Copied: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ComponentInvoker.java (from r538679, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ComponentInvoker.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ComponentInvoker.java?view=diff&rev=538782&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ComponentInvoker.java&r1=538679&p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ComponentInvoker.java&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/ComponentInvoker.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/ComponentInvoker.java Wed May 16 18:12:11 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.test.pagelevel;
+package org.apache.tapestry.internal.test;
import org.apache.tapestry.dom.Document;
import org.apache.tapestry.internal.services.ComponentInvocation;
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java?view=diff&rev=538782&r1=538781&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/InternalBaseTestCase.java Wed May 16 18:12:11 2007
@@ -44,7 +44,6 @@
import org.apache.tapestry.internal.services.ComponentInvocationMap;
import org.apache.tapestry.internal.services.ComponentTemplateSource;
import org.apache.tapestry.internal.services.DocumentScriptBuilder;
-import org.apache.tapestry.internal.services.FormParameterLookup;
import org.apache.tapestry.internal.services.Instantiator;
import org.apache.tapestry.internal.services.LinkFactory;
import org.apache.tapestry.internal.services.LinkFactoryListener;
@@ -490,15 +489,9 @@
expect(factory.createPageLink(page)).andReturn(link);
}
- protected final FormParameterLookup mockFormParameterLookup()
+ protected final void train_getParameter(Request request, String elementName, String value)
{
- return newMock(FormParameterLookup.class);
- }
-
- protected final void train_getParameter(FormParameterLookup lookup, String elementName,
- String value)
- {
- expect(lookup.getParameter(elementName)).andReturn(value).atLeastOnce();
+ expect(request.getParameter(elementName)).andReturn(value).atLeastOnce();
}
protected final void train_isLoaded(InternalComponentResources resources, boolean isLoaded)
Copied: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageLinkInvoker.java (from r538679, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageLinkInvoker.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageLinkInvoker.java?view=diff&rev=538782&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageLinkInvoker.java&r1=538679&p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageLinkInvoker.java&r2=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/test/pagelevel/PageLinkInvoker.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageLinkInvoker.java Wed May 16 18:12:11 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 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.
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package org.apache.tapestry.test.pagelevel;
+package org.apache.tapestry.internal.test;
import org.apache.tapestry.MarkupWriter;
import org.apache.tapestry.dom.Document;
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterComponentInvocationMap.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterComponentInvocationMap.java?view=auto&rev=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterComponentInvocationMap.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterComponentInvocationMap.java Wed May 16 18:12:11 2007
@@ -0,0 +1,66 @@
+// Copyright 2006, 2007 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.tapestry.internal.test;
+
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
+
+import java.util.Map;
+
+import org.apache.tapestry.Link;
+import org.apache.tapestry.dom.Element;
+import org.apache.tapestry.internal.services.ComponentInvocation;
+import org.apache.tapestry.internal.services.ComponentInvocationMap;
+import org.apache.tapestry.internal.services.NoOpComponentInvocationMap;
+import org.apache.tapestry.test.PageTester;
+
+/**
+ * This is the real implementation, used by {@link PageTester}. The typical implementation,
+ * {@link NoOpComponentInvocationMap}, is used in production as a place holder.
+ */
+public class PageTesterComponentInvocationMap implements ComponentInvocationMap
+{
+ private final Map<Element, Link> _elementToLink = newMap();
+
+ private final Map<Link, ComponentInvocation> _linkToInvocation = newMap();
+
+ public void store(Element element, Link link)
+ {
+ _elementToLink.put(element, link);
+ }
+
+ public void store(Link link, ComponentInvocation invocation)
+ {
+ _linkToInvocation.put(link, invocation);
+ }
+
+ public void clear()
+ {
+ _elementToLink.clear();
+ _linkToInvocation.clear();
+ }
+
+ public ComponentInvocation get(Element element)
+ {
+ Link link = _elementToLink.get(element);
+
+ return get(link);
+ }
+
+ public ComponentInvocation get(Link link)
+ {
+ return _linkToInvocation.get(link);
+ }
+
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterContext.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterContext.java?view=auto&rev=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterContext.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterContext.java Wed May 16 18:12:11 2007
@@ -0,0 +1,65 @@
+// Copyright 2007 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.tapestry.internal.test;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tapestry.services.Context;
+
+public class PageTesterContext implements Context
+{
+ private final String _contextRoot;
+
+ public PageTesterContext(String contextRoot)
+ {
+ _contextRoot = contextRoot;
+ }
+
+ public String getInitParameter(String name)
+ {
+ return null;
+ }
+
+ public URL getResource(String path)
+ {
+ File f = new File(_contextRoot + path);
+
+ if (!f.exists() || !f.isFile()) { return null; }
+ try
+ {
+ return f.toURL();
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public List<String> getResourcePaths(String path)
+ {
+ throw new UnsupportedOperationException(
+ "getResourcePaths() is not supported for ContextForPageTester.");
+ }
+
+ public Object getAttribute(String name)
+ {
+ throw new UnsupportedOperationException(
+ "getAttribute() is not supported for ContextForPageTester.");
+ }
+
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterModule.java?view=auto&rev=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterModule.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterModule.java Wed May 16 18:12:11 2007
@@ -0,0 +1,73 @@
+// Copyright 2007 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.tapestry.internal.test;
+
+import org.apache.tapestry.internal.services.ComponentInvocationMap;
+import org.apache.tapestry.internal.services.CookieSink;
+import org.apache.tapestry.internal.services.CookieSource;
+import org.apache.tapestry.ioc.Configuration;
+import org.apache.tapestry.ioc.ObjectLocator;
+import org.apache.tapestry.ioc.ServiceBinder;
+import org.apache.tapestry.services.AliasContribution;
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.services.Response;
+import org.apache.tapestry.test.PageTester;
+
+/**
+ * Used in conjuction with {@link PageTester} to mock up and/or stub out portions of Tapestry that
+ * need to be handled differently when testing.
+ */
+public class PageTesterModule
+{
+ public static final String TEST_MODE = "test";
+
+ public static void bind(ServiceBinder binder)
+ {
+ binder.bind(TestableRequest.class, TestableRequestImpl.class);
+ }
+
+ public static void contributeAlias(Configuration<AliasContribution> configuration,
+ ObjectLocator locator)
+ {
+ add(configuration, ComponentInvocationMap.class, new PageTesterComponentInvocationMap());
+ add(configuration, Response.class, new TestableResponseImpl());
+
+ add(configuration, locator, Request.class, "TestableRequest");
+
+ TestableCookieSinkSource cookies = new TestableCookieSinkSource();
+
+ add(configuration, CookieSink.class, cookies);
+ add(configuration, CookieSource.class, cookies);
+ }
+
+ private static <T> void add(Configuration<AliasContribution> configuration,
+ ObjectLocator locator, Class<T> serviceClass, String serviceId)
+ {
+ T service = locator.getService(serviceId, serviceClass);
+
+ add(configuration, serviceClass, service);
+ }
+
+ private static <T> void add(Configuration<AliasContribution> configuration,
+ Class<T> serviceClass, T service)
+ {
+ AliasContribution<T> contribution = AliasContribution.create(
+ serviceClass,
+ TEST_MODE,
+ service);
+
+ configuration.add(contribution);
+ }
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterSession.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterSession.java?view=auto&rev=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterSession.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/PageTesterSession.java Wed May 16 18:12:11 2007
@@ -0,0 +1,63 @@
+// Copyright 2006, 2007 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.tapestry.internal.test;
+
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tapestry.ioc.internal.util.InternalUtils;
+import org.apache.tapestry.services.Session;
+
+public class PageTesterSession implements Session
+{
+ private final Map<String, Object> _attributes = newMap();
+
+ public List<String> getAttributeNames()
+ {
+ return InternalUtils.sortedKeys(_attributes);
+ }
+
+ public List<String> getAttributeNames(String prefix)
+ {
+ List<String> result = newList();
+
+ for (String name : getAttributeNames())
+ if (name.startsWith(prefix)) result.add(name);
+
+ return result;
+ }
+
+ public Object getAttribute(String name)
+ {
+ return _attributes.get(name);
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ if (value == null)
+ {
+ _attributes.remove(name);
+ }
+ else
+ {
+ _attributes.put(name, value);
+ }
+
+ }
+
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableCookieSinkSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableCookieSinkSource.java?view=auto&rev=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableCookieSinkSource.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableCookieSinkSource.java Wed May 16 18:12:11 2007
@@ -0,0 +1,44 @@
+// Copyright 2007 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.tapestry.internal.test;
+
+import java.util.Map;
+
+import javax.servlet.http.Cookie;
+
+import org.apache.tapestry.internal.services.CookieSink;
+import org.apache.tapestry.internal.services.CookieSource;
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+
+public class TestableCookieSinkSource implements CookieSource, CookieSink
+{
+ private Map<String, Cookie> _cookies;
+
+ public TestableCookieSinkSource()
+ {
+ _cookies = CollectionFactory.newMap();
+ }
+
+ public Cookie[] getCookies()
+ {
+ return _cookies.values().toArray(new Cookie[_cookies.size()]);
+ }
+
+ public void addCookie(Cookie cookie)
+ {
+ _cookies.put(cookie.getName(), cookie);
+ }
+
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequest.java?view=auto&rev=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequest.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequest.java Wed May 16 18:12:11 2007
@@ -0,0 +1,37 @@
+// Copyright 2007 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.tapestry.internal.test;
+
+import java.util.Map;
+
+import org.apache.tapestry.services.Request;
+import org.apache.tapestry.test.PageTester;
+
+/**
+ * An extended version of {@link Request} that allows the {@link PageTester} to control and override
+ * behavior, effectively simulating the portions of {@link Request} that are provided normally by a
+ * servlet container.
+ */
+public interface TestableRequest extends Request
+{
+ /** Clears the internal parameters map. */
+ void clear();
+
+ /** Loads new parameter/value pairs into the map. */
+ void loadParameters(Map<String, String> parameterValues);
+
+ /** Loads a single parameter/value pair. */
+ void loadParameter(String parameterName, String parameterValue);
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequestImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequestImpl.java?view=auto&rev=538782
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequestImpl.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequestImpl.java Wed May 16 18:12:11 2007
@@ -0,0 +1,132 @@
+// Copyright 2007 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.tapestry.internal.test;
+
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.tapestry.ioc.internal.util.InternalUtils;
+import org.apache.tapestry.services.Session;
+
+public class TestableRequestImpl implements TestableRequest
+{
+ private final String _contextPath;
+
+ private final Map<String, String> _parameters = newMap();
+
+ private Session _session;
+
+ public TestableRequestImpl()
+ {
+ this("/foo");
+ }
+
+ public TestableRequestImpl(String contextPath)
+ {
+ _contextPath = contextPath;
+ }
+
+ private void nyi(String methodName)
+ {
+ throw new RuntimeException(String.format(
+ "Request: method %s() not yet implemented by TestableRequestImpl.",
+ methodName));
+ }
+
+ public void clear()
+ {
+ _parameters.clear();
+ }
+
+ public void loadParameter(String parameterName, String parameterValue)
+ {
+ _parameters.put(parameterName, parameterValue);
+ }
+
+ public void loadParameters(Map<String, String> parameterValues)
+ {
+ _parameters.putAll(parameterValues);
+ }
+
+ public long getDateHeader(String name)
+ {
+ nyi("getDateHeader");
+
+ return 0;
+ }
+
+ public String getHeader(String name)
+ {
+ nyi("getHeader");
+
+ return null;
+ }
+
+ public List<String> getHeaderNames()
+ {
+ nyi("getHeaderNames");
+
+ return null;
+ }
+
+ public Locale getLocale()
+ {
+ nyi("getLocale");
+
+ return null;
+ }
+
+ public List<String> getParameterNames()
+ {
+ return InternalUtils.sortedKeys(_parameters);
+ }
+
+ public String[] getParameters(String name)
+ {
+ nyi("getParameters");
+
+ return null;
+ }
+
+ public String getPath()
+ {
+ nyi("getPath");
+
+ return null;
+ }
+
+ public String getContextPath()
+ {
+ return _contextPath;
+ }
+
+ public String getParameter(String name)
+ {
+ return _parameters.get(name);
+ }
+
+ public Session getSession(boolean create)
+ {
+ if (!create) return _session;
+
+ if (_session == null) _session = new PageTesterSession();
+
+ return _session;
+ }
+
+}