You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2007/07/17 02:22:20 UTC
svn commit: r556780 [1/2] - in /tapestry/tapestry4/trunk: ./
tapestry-framework/ tapestry-framework/src/java/org/apache/tapestry/engine/
tapestry-framework/src/java/org/apache/tapestry/event/
tapestry-framework/src/java/org/apache/tapestry/resolver/ ta...
Author: jkuhnert
Date: Mon Jul 16 17:22:19 2007
New Revision: 556780
URL: http://svn.apache.org/viewvc?view=rev&rev=556780
Log:
-) Fixes TAPESTRY-1651. Expected parent namespace meta && localized properties to be inherited from application in library. Decided this should be what happens after all and made it so.
-) Upgraded misc commons-xxx dependencies.
-) Fixed some other misc broken unit tests, better be the only time this ever happens....
-) Checked in a copy of Howard's ruby script for signing releases...still needs to be modified to be more generic.
Added:
tapestry/tapestry4/trunk/sign.rb
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/TestNamespaceProperties.java (with props)
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Application.properties (with props)
Modified:
tapestry/tapestry4/trunk/pom.xml
tapestry/tapestry4/trunk/tapestry-framework/pom.xml
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/IPropertySource.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/Namespace.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/event/BrowserEvent.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/resolver/ComponentSpecificationResolverImpl.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/ComponentMessagesSource.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/ComponentPropertySource.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentPropertySourceImpl.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/ApplicationSpecification.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/IComponentSpecification.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/LibrarySpecification.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/LocatablePropertyHolder.java
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/BasePropertyHolder.java
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectEventServiceTest.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectServiceTest.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/event/BrowserEventTest.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Library.properties
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/TestComponentMessages.java
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/spec/BasicExtension.application
tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/spec/TestComponentSpecification.java
Modified: tapestry/tapestry4/trunk/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/pom.xml?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/pom.xml (original)
+++ tapestry/tapestry4/trunk/pom.xml Mon Jul 16 17:22:19 2007
@@ -97,8 +97,8 @@
<modules>
<module>tapestry-framework</module>
- <module>tapestry-contrib</module>
<module>tapestry-annotations</module>
+ <module>tapestry-contrib</module>
<module>tapestry-portlet</module>
<module>tapestry-examples</module>
<module>tapestry-archetype</module>
@@ -141,7 +141,7 @@
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
- <version>2.2</version>
+ <version>2.3</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -194,20 +194,20 @@
<version>2.3</version>
</dependency>
<dependency>
- <groupId>commons-io</groupId>
+ <groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
- <version>1.3.1</version>
+ <version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-test</artifactId>
- <version>4.1.3-SNAPSHOT</version>
+ <version>4.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>backport-util-concurrent</groupId>
<artifactId>backport-util-concurrent</artifactId>
- <version>2.2</version>
+ <version>3.0</version>
</dependency>
<dependency>
<groupId>org.openqa.selenium.client-drivers</groupId>
Added: tapestry/tapestry4/trunk/sign.rb
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/sign.rb?view=auto&rev=556780
==============================================================================
--- tapestry/tapestry4/trunk/sign.rb (added)
+++ tapestry/tapestry4/trunk/sign.rb Mon Jul 16 17:22:19 2007
@@ -0,0 +1,14 @@
+#!/usr/bin/ruby
+
+DIST_DIR="target"
+
+Dir.glob("#{DIST_DIR}/*.{zip,gz,bz2}") do |filename|
+ puts filename
+ # ... and you have to provide your passphrase again and again!
+ system "gpg --armor --output #{filename}.asc --detach-sig #{filename}"
+ system "md5sum #{filename} > #{filename}.md5"
+end
+
+puts "Uploading distributions ..."
+
+# system 'scp #{DIST_DIR}/*.* jkuhnert@people.apache.org:public_html/tapestry_releases'
Modified: tapestry/tapestry4/trunk/tapestry-framework/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/pom.xml?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/pom.xml (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/pom.xml Mon Jul 16 17:22:19 2007
@@ -65,7 +65,7 @@
<artifactId>commons-fileupload</artifactId>
</dependency>
<dependency>
- <groupId>commons-io</groupId>
+ <groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/IPropertySource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/IPropertySource.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/IPropertySource.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/IPropertySource.java Mon Jul 16 17:22:19 2007
@@ -30,6 +30,11 @@
* IPropertySource may use delegation to resolve the value (that is, if one
* property source returns null, it may forward the request to another
* source).
+ *
+ * @param propertyName
+ * Name of the property to get.
+ *
+ * @return Value of property or null if none found.
*/
String getPropertyValue(String propertyName);
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/Namespace.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/Namespace.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/Namespace.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/engine/Namespace.java Mon Jul 16 17:22:19 2007
@@ -30,7 +30,7 @@
* Implementation of {@link org.apache.tapestry.INamespace} that works with a
* {@link org.apache.tapestry.services.NamespaceResources} to obtain page and
* component specifications as needed.
- *
+ *
* @author Howard Lewis Ship
* @since 2.2
*/
@@ -76,8 +76,8 @@
private final Map _children = new ConcurrentHashMap();
- public Namespace(String id, INamespace parent,
- ILibrarySpecification specification, NamespaceResources resources)
+ public Namespace(String id, INamespace parent, ILibrarySpecification specification,
+ NamespaceResources resources)
{
_id = id;
_parent = parent;
@@ -96,7 +96,8 @@
if (_applicationNamespace)
buffer.append("<application>");
- else buffer.append(getExtendedId());
+ else
+ buffer.append(getExtendedId());
buffer.append(']');
@@ -110,9 +111,11 @@
public String getExtendedId()
{
- if (_applicationNamespace) return null;
+ if (_applicationNamespace)
+ return null;
- if (_extendedId == null) _extendedId = buildExtendedId();
+ if (_extendedId == null)
+ _extendedId = buildExtendedId();
return _extendedId;
}
@@ -206,13 +209,15 @@
private String buildExtendedId()
{
- if (_parent == null) return _id;
+ if (_parent == null)
+ return _id;
String parentId = _parent.getExtendedId();
// If immediate child of application namespace
- if (parentId == null) return _id;
+ if (parentId == null)
+ return _id;
return parentId + "." + _id;
}
@@ -235,7 +240,7 @@
/**
* Gets the specification from the specification source.
- *
+ *
* @throws ApplicationRuntimeException
* if the named page is not defined.
*/
@@ -245,16 +250,14 @@
String path = _specification.getPageSpecificationPath(name);
if (path == null)
- throw new ApplicationRuntimeException(Tapestry.format(
- "Namespace.no-such-page", name, getNamespaceId()));
+ throw new ApplicationRuntimeException(Tapestry.format("Namespace.no-such-page", name, getNamespaceId()));
// We don't record line-precise data about <page> elements
// so use the location for the specification as a whole (at least
// identifying
// the right file)
- return _resources.getPageSpecification(getSpecificationLocation(),
- path, getLocation());
+ return _resources.getPageSpecification(getSpecificationLocation(), path, getLocation());
}
private IComponentSpecification locateComponentSpecification(String type)
@@ -262,16 +265,14 @@
String path = _specification.getComponentSpecificationPath(type);
if (path == null)
- throw new ApplicationRuntimeException(Tapestry.format(
- "Namespace.no-such-alias", type, getNamespaceId()));
+ throw new ApplicationRuntimeException(Tapestry.format("Namespace.no-such-alias", type, getNamespaceId()));
// We don't record line-precise data about <component-type> elements
// so use the location for the specification as a whole (at least
// identifying
// the right file)
- return _resources.getComponentSpecification(getSpecificationLocation(),
- path, getLocation());
+ return _resources.getComponentSpecification(getSpecificationLocation(), path, getLocation());
}
private INamespace createNamespace(String id)
@@ -279,15 +280,15 @@
String path = _specification.getLibrarySpecificationPath(id);
if (path == null)
- throw new ApplicationRuntimeException(Tapestry.format(
- "Namespace.library-id-not-found", id, getNamespaceId()));
+ throw new ApplicationRuntimeException(Tapestry.format("Namespace.library-id-not-found", id, getNamespaceId()));
// We don't record line-precise data about <library> elements
// so use the location for the specification as a whole (at least
// identifying
// the right file)
- ILibrarySpecification ls = _resources.findChildLibrarySpecification(getSpecificationLocation(), path, getLocation());
+ ILibrarySpecification ls =
+ _resources.findChildLibrarySpecification(getSpecificationLocation(), path, getLocation());
return new Namespace(id, this, ls, _resources);
}
@@ -303,7 +304,8 @@
{
String prefix = getExtendedId();
- if (prefix == null) return pageName;
+ if (prefix == null)
+ return pageName;
return prefix + SEPARATOR + pageName;
}
@@ -347,20 +349,28 @@
public Location getLocation()
{
- if (_specification == null) return null;
+ if (_specification == null)
+ return null;
return _specification.getLocation();
}
/**
* Returns property values defined in the namespace's library specification.
- *
+ *
* @return the property, or null if not provided in the specification.
* @since 4.0
*/
public String getPropertyValue(String propertyName)
{
- return _specification.getProperty(propertyName);
+ String ret = _specification.getProperty(propertyName);
+
+ if (ret == null && _parent != null)
+ {
+ return _parent.getPropertyValue(propertyName);
+ }
+
+ return ret;
}
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/event/BrowserEvent.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/event/BrowserEvent.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/event/BrowserEvent.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/event/BrowserEvent.java Mon Jul 16 17:22:19 2007
@@ -13,22 +13,19 @@
// limitations under the License.
package org.apache.tapestry.event;
-import java.text.ParseException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.util.Defense;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.json.JSONArray;
+import java.text.ParseException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Represents a client side generated browser event.
- *
- * @author jkuhnert
*/
public class BrowserEvent
{
@@ -40,12 +37,12 @@
public static final String PAGE_Y="beventpageY";
public static final String LAYER_X="beventlayerX";
public static final String LAYER_Y="beventlayerY";
-
+
public static final String TARGET="beventtarget";
public static final String TARGET_ATTR_ID="id";
-
+
public static final String METHOD_ARGUMENTS="methodArguments";
-
+
private String _name;
private String _type;
private String[] _keys;
@@ -55,21 +52,21 @@
private String _layerX;
private String _layerY;
private EventTarget _target;
-
+
private String _methodArguments;
private JSONArray _methodArgumentsArray;
-
+
/**
* Creates a new browser event that will extract its own
* parameters.
- *
+ *
* @param cycle
* The request cycle to extract parameters from.
*/
public BrowserEvent(IRequestCycle cycle)
{
Defense.notNull(cycle, "cycle");
-
+
_name = cycle.getParameter(NAME);
_type = cycle.getParameter(TYPE);
_keys = cycle.getParameters(KEYS);
@@ -78,22 +75,23 @@
_pageY = cycle.getParameter(PAGE_Y);
_layerX = cycle.getParameter(LAYER_X);
_layerY = cycle.getParameter(LAYER_Y);
-
+
Map props = new HashMap();
_target = new EventTarget(props);
-
+
String targetId = cycle.getParameter(TARGET + "." + TARGET_ATTR_ID);
- if (targetId != null) {
+ if (targetId != null)
+ {
props.put(TARGET_ATTR_ID, targetId);
}
-
+
_methodArguments = cycle.getParameter(METHOD_ARGUMENTS);
}
-
+
/**
* Creates a new browser event with the specified
* name/target properties.
- *
+ *
* @param name The name of the event, ie "onClick", "onBlur", etc..
* @param target The target of the client side event.
*/
@@ -102,10 +100,10 @@
_name = name;
_target = target;
}
-
+
/**
* The name of the event that was generated.
- *
+ *
* <p>
* Examples would be <code>onClick,onSelect,onLoad,etc...</code>.
* </p>
@@ -115,17 +113,17 @@
{
return _name;
}
-
+
/**
* Returns the target of the client side event.
- *
+ *
* @return The target representation of the client side object event originally bound for.
*/
public EventTarget getTarget()
{
return _target;
}
-
+
/**
* @return the charCode
*/
@@ -133,7 +131,7 @@
{
return _charCode;
}
-
+
/**
* @return the keys
*/
@@ -181,37 +179,38 @@
{
return _type;
}
-
-
+
+
/**
* @return the method arguments of an intercepted method-call, if any. If none
* are available, return an empty JSONArray, never null.
- *
+ *
* @throws ApplicationRuntimeException when the JSON-String could not be
* parsed.
*/
- public JSONArray getMethodArguments()
- {
+ public JSONArray getMethodArguments()
+ {
if ( _methodArgumentsArray == null)
{
- try
+ try
{
- _methodArgumentsArray =
- _methodArguments != null ?
- new JSONArray( _methodArguments )
- : new JSONArray();
- }
- catch (ParseException ex)
+ _methodArgumentsArray = _methodArguments != null
+ ? new JSONArray( _methodArguments )
+ : new JSONArray();
+ }
+ catch (ParseException ex)
{
throw new ApplicationRuntimeException(ex);
}
}
+
return _methodArgumentsArray;
}
/**
* Utility method to check if the current request contains
* a browser event.
+ *
* @param cycle
* The associated request.
* @return True if the request contains browser event data.
@@ -219,23 +218,74 @@
public static boolean hasBrowserEvent(IRequestCycle cycle)
{
Defense.notNull(cycle, "cycle");
-
+
return cycle.getParameter(NAME) != null;
}
-
+
public String toString()
{
- return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
- .append("name", _name)
- .append("type", _type)
- .append("keys", _keys)
- .append("charCode", _charCode)
- .append("pageX", _pageX)
- .append("pageY", _pageY)
- .append("layerX", _layerX)
- .append("layerY", _layerY)
- .append("target", _target)
- .append("methodArguments", _methodArguments)
- .toString();
+ return "BrowserEvent[" +
+ "_name='" + _name + '\'' +
+ '\n' +
+ ", _type='" + _type + '\'' +
+ '\n' +
+ ", _keys=" + (_keys == null ? null : Arrays.asList(_keys)) +
+ '\n' +
+ ", _charCode='" + _charCode + '\'' +
+ '\n' +
+ ", _pageX='" + _pageX + '\'' +
+ '\n' +
+ ", _pageY='" + _pageY + '\'' +
+ '\n' +
+ ", _layerX='" + _layerX + '\'' +
+ '\n' +
+ ", _layerY='" + _layerY + '\'' +
+ '\n' +
+ ", _target=" + _target +
+ '\n' +
+ ", _methodArguments='" + _methodArguments + '\'' +
+ '\n' +
+ ", _methodArgumentsArray=" + _methodArgumentsArray +
+ '\n' +
+ ']';
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ BrowserEvent event = (BrowserEvent) o;
+
+ if (_charCode != null ? !_charCode.equals(event._charCode) : event._charCode != null) return false;
+ if (!Arrays.equals(_keys, event._keys)) return false;
+ if (_layerX != null ? !_layerX.equals(event._layerX) : event._layerX != null) return false;
+ if (_layerY != null ? !_layerY.equals(event._layerY) : event._layerY != null) return false;
+ if (_methodArguments != null ? !_methodArguments.equals(event._methodArguments) : event._methodArguments != null) return false;
+ if (_methodArgumentsArray != null ? !_methodArgumentsArray.equals(event._methodArgumentsArray) : event._methodArgumentsArray != null) return false;
+ if (_name != null ? !_name.equals(event._name) : event._name != null) return false;
+ if (_pageX != null ? !_pageX.equals(event._pageX) : event._pageX != null) return false;
+ if (_pageY != null ? !_pageY.equals(event._pageY) : event._pageY != null) return false;
+ if (_target != null ? !_target.equals(event._target) : event._target != null) return false;
+ if (_type != null ? !_type.equals(event._type) : event._type != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (_name != null ? _name.hashCode() : 0);
+ result = 31 * result + (_type != null ? _type.hashCode() : 0);
+ result = 31 * result + (_keys != null ? Arrays.hashCode(_keys) : 0);
+ result = 31 * result + (_charCode != null ? _charCode.hashCode() : 0);
+ result = 31 * result + (_pageX != null ? _pageX.hashCode() : 0);
+ result = 31 * result + (_pageY != null ? _pageY.hashCode() : 0);
+ result = 31 * result + (_layerX != null ? _layerX.hashCode() : 0);
+ result = 31 * result + (_layerY != null ? _layerY.hashCode() : 0);
+ result = 31 * result + (_target != null ? _target.hashCode() : 0);
+ result = 31 * result + (_methodArguments != null ? _methodArguments.hashCode() : 0);
+ result = 31 * result + (_methodArgumentsArray != null ? _methodArgumentsArray.hashCode() : 0);
+ return result;
}
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/resolver/ComponentSpecificationResolverImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/resolver/ComponentSpecificationResolverImpl.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/resolver/ComponentSpecificationResolverImpl.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/resolver/ComponentSpecificationResolverImpl.java Mon Jul 16 17:22:19 2007
@@ -47,19 +47,18 @@
* <li>By searching for a named class file within the org.apache.tapestry.component-class-packages
* property (defined within the namespace)
* </ul>
- *
+ *
* The search for components in library namespaces is more abbreviated:
* <ul>
* <li>As declared in the library specification
* <li><i>type </i>.jwc in the same folder as the library specification
* <li>By searching the framework namespace
* </ul>
- *
+ *
* @since 3.0
*/
-public class ComponentSpecificationResolverImpl extends AbstractSpecificationResolver implements
- ComponentSpecificationResolver
+public class ComponentSpecificationResolverImpl extends AbstractSpecificationResolver implements ComponentSpecificationResolver
{
/** Set by container. */
private Log _log;
@@ -74,15 +73,15 @@
protected void reset()
{
_type = null;
-
+
super.reset();
}
-
+
/**
* Passed the namespace of a container (to resolve the type in) and the type to resolve,
* performs the processing. A "bare type" (without a library prefix) may be in the
* containerNamespace, or the framework namespace (a search occurs in that order).
- *
+ *
* @param cycle
* current request cycle
* @param containerNamespace
@@ -107,9 +106,9 @@
}
else
resolve(cycle, containerNamespace, null, type, location);
-
+
IComponentSpecification spec = getSpecification();
-
+
if (spec.isDeprecated())
_log.warn(ResolverMessages.componentIsDeprecated(type, location));
}
@@ -118,7 +117,7 @@
* Like
* {@link #resolve(org.apache.tapestry.IRequestCycle, org.apache.tapestry.INamespace, java.lang.String, Location)},
* but used when the type has already been parsed into a library id and a simple type.
- *
+ *
* @param cycle
* current request cycle
* @param containerNamespace
@@ -134,7 +133,7 @@
*/
public void resolve(IRequestCycle cycle, INamespace containerNamespace, String libraryId,
- String type, Location location)
+ String type, Location location)
{
reset();
_type = type;
@@ -165,8 +164,8 @@
if (spec == null)
{
throw new ApplicationRuntimeException(ResolverMessages.noSuchComponentType(
- type,
- namespace), location, null);
+ type,
+ namespace), location, null);
}
@@ -186,22 +185,22 @@
if (_log.isDebugEnabled())
_log.debug(ResolverMessages.resolvingComponent(_type, namespace));
-
+
String expectedName = _type + ".jwc";
Resource namespaceLocation = namespace.getSpecificationLocation();
-
+
// Look for appropriate file in same folder as the library (or application)
// specificaiton.
-
+
result = check(namespaceLocation.getRelativeResource(expectedName));
-
+
if (result != null)
return result;
if (namespace.isApplicationNamespace()) {
-
+
// The application namespace gets some extra searching.
-
+
result = check(getWebInfAppLocation().getRelativeResource(expectedName));
if (result == null)
@@ -209,15 +208,15 @@
if (result == null)
result = check((getContextRoot().getRelativeResource(expectedName)));
-
+
if (result != null)
return result;
}
-
+
result = getDelegate().findComponentSpecification(cycle, namespace, _type);
if (result != null)
return result;
-
+
result = searchForComponentClass(namespace, _type);
if (result != null)
@@ -225,12 +224,12 @@
// Not in the library or app spec; does it match a component
// provided by the Framework?
-
+
INamespace framework = getSpecificationSource().getFrameworkNamespace();
-
+
if (framework.containsComponentType(_type))
return framework.getComponentSpecification(_type);
-
+
return null;
}
@@ -252,7 +251,7 @@
// try classpath relative if namespace relative doesn't resolve
if (componentResource.getResourceURL() == null) {
-
+
componentResource = new ClasspathResource(_classResolver, componentClass.getName().replace('.', '/'));
}
@@ -275,15 +274,15 @@
return getSpecificationSource().getComponentSpecification(resource);
}
-
+
private void install()
{
INamespace namespace = getNamespace();
IComponentSpecification specification = getSpecification();
-
+
if (_log.isDebugEnabled())
_log.debug(ResolverMessages.installingComponent(_type, namespace, specification));
-
+
namespace.installComponentSpecification(_type, specification);
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/ComponentMessagesSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/ComponentMessagesSource.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/ComponentMessagesSource.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/ComponentMessagesSource.java Mon Jul 16 17:22:19 2007
@@ -23,10 +23,15 @@
*
* @author Howard Lewis Ship
* @since 2.0.4
- *
*/
-
public interface ComponentMessagesSource
{
+ /**
+ * Gets the associated localized component messages.
+ *
+ * @param component
+ * The component to get properties for.
+ * @return The {@link Messages} for the specified component.
+ */
Messages getMessages(IComponent component);
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/ComponentPropertySource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/ComponentPropertySource.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/ComponentPropertySource.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/ComponentPropertySource.java Mon Jul 16 17:22:19 2007
@@ -14,17 +14,19 @@
package org.apache.tapestry.services;
-import java.util.Locale;
-
import org.apache.tapestry.IComponent;
import org.apache.tapestry.INamespace;
+import java.util.Locale;
+
/**
* Encapsulates the logic for searching for component meta-data. Deployed as service
* tapestry.props.ComponentPropertySource.
+ *
* <p>
* TODO: Adjust name, since it now provides access to namespace properties as well as component
* properties.
+ * </p>
*
* @author Howard M. Lewis Ship
* @since 4.0
@@ -39,6 +41,11 @@
* <li>The specification of the application (or the library containing the component).</li>
* <li>The chain of global property sources.</li>
* </ul>
+ *
+ * @param component
+ * The {@link IComponent} to get the property of.
+ * @param propertyName
+ * Key of the property.
*
* @return the value of the given key, or null if not found.
*/
@@ -51,7 +58,14 @@
* property name means that a suffix may be appended to it. If the fully localized name is not
* found, then the locale is generalized (i.e., from "en_UK" to "en" to nothing) until a match
* is found.
- *
+ *
+ * @param component
+ * The {@link IComponent} to get the property of.
+ * @param locale
+ * The {@link Locale} to get properties for.
+ * @param propertyName
+ * Key of the property.
+ *
* @return the value of the given property name, or null if not found.
*/
String getLocalizedComponentProperty(IComponent component, Locale locale, String propertyName);
@@ -59,10 +73,16 @@
/**
* Returns the property value for a particular named meta-data property of the namespace. The
* search order is:
+ *
* <ul>
* <li>The library or application specification for the namespace.</li>
* <li>The chain of global property sources.</li>
* </ul>
+ *
+ * @param namespace
+ * The namespace to get the property from.
+ * @param propertyName
+ * The key of the property to get.
*
* @return the value of the given key, or null if not found.
*/
@@ -72,6 +92,15 @@
/**
* As with {@link #getLocalizedComponentProperty(IComponent, Locale, String)}, but with a
* {@link INamespace}.
+ *
+ * @param namespace
+ * The namespace to get the property from.
+ * @param locale
+ * {@link Locale} to filter the properties for.
+ * @param propertyName
+ * The key of the property to get.
+ *
+ * @return The matching property, or null if not found.
*/
String getLocalizedNamespaceProperty(INamespace namespace, Locale locale, String propertyName);
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java Mon Jul 16 17:22:19 2007
@@ -15,6 +15,7 @@
package org.apache.tapestry.services.impl;
import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+import org.apache.commons.io.IOUtils;
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.Messages;
import org.apache.hivemind.Resource;
@@ -64,7 +65,7 @@
/**
* Map of Maps. The outer map is keyed on component specification location
- * (a{@link Resource}. This inner map is keyed on locale and the value is
+ * (a{@link Resource}). This inner map is keyed on locale and the value is
* a {@link Properties}.
*/
@@ -80,9 +81,15 @@
private IComponentResourceResolver _resourceResolver;
/**
- * Returns an instance of {@link Properties}containing the properly
- * localized messages for the component, in the {@link Locale}identified by
+ * Returns an instance of {@link Properties} containing the properly
+ * localized messages for the component, in the {@link Locale} identified by
* the component's containing page.
+ *
+ * @param component
+ * The component to get properties for.
+ *
+ * @return A new {@link Properties} instance representing the localized properties for
+ * the specified component.
*/
protected Properties getLocalizedProperties(IComponent component)
@@ -101,7 +108,8 @@
{
// Not found, create it now.
- result = assembleComponentProperties(component, specificationLocation, propertiesMap, locale);
+ result = assembleComponentProperties(component, specificationLocation,
+ propertiesMap, locale);
propertiesMap.put(locale, result);
}
@@ -116,6 +124,7 @@
if (result == null)
{
result = new HashMap();
+
_componentCache.put(resource, result);
}
@@ -134,7 +143,29 @@
if (result == null)
{
- result = assembleNamespaceProperties(namespace, propertiesMap, locale);
+ result = new Properties();
+
+ // recurse through parent properties
+
+ List spaceList = new ArrayList();
+ spaceList.add(namespace);
+
+ INamespace parent = namespace;
+ while (parent.getParentNamespace() != null)
+ {
+ parent = parent.getParentNamespace();
+
+ spaceList.add(parent);
+ }
+
+ // reverse it so top most namespace comes first
+
+ for (int i=spaceList.size() - 1; i > -1; i--)
+ {
+ INamespace space = (INamespace)spaceList.get(i);
+
+ result.putAll(assembleNamespaceProperties(space, findPropertiesMapForResource(space.getSpecificationLocation()), locale));
+ }
propertiesMap.put(locale, result);
}
@@ -156,20 +187,23 @@
while(i.hasNext())
{
ResourceLocalization rl = (ResourceLocalization) i.next();
-
Locale l = rl.getLocale();
// Retrieve namespace properties for current locale (and parent
// locales)
+
Properties namespaceProperties = getNamespaceProperties(component, l);
// Use the namespace properties as default for assembled properties
+
assembledProperties = new Properties(namespaceProperties);
// Read localized properties for component
+
Properties properties = readComponentProperties(component, l, rl.getResource(), null);
// Override parent properties with current locale
+
if (parent != null)
{
if (properties != null)
@@ -192,12 +226,11 @@
return assembledProperties;
}
- private Properties assembleNamespaceProperties(INamespace namespace,
- Map propertiesMap, Locale locale)
+ private Properties assembleNamespaceProperties(INamespace namespace, Map propertiesMap, Locale locale)
{
List localizations = findLocalizationsForResource(namespace.getSpecificationLocation(), locale,
namespace.getPropertyValue(NAMESPACE_PROPERTIES_NAME));
-
+
// Build them back up in reverse order.
Properties parent = _emptyProperties;
@@ -207,7 +240,7 @@
while(i.hasNext())
{
ResourceLocalization rl = (ResourceLocalization) i.next();
-
+
Locale l = rl.getLocale();
Properties properties = (Properties) propertiesMap.get(l);
@@ -255,8 +288,8 @@
Resource localizedResource = resource.getRelativeResource(localizedName);
- if (localizedResource.getResourceURL() == null) {
-
+ if (localizedResource.getResourceURL() == null)
+ {
localizedResource = _classpathResourceFactory.newResource(baseName + SUFFIX);
}
@@ -289,6 +322,7 @@
Locale l = g.getCurrentLocale();
Resource localizedResource = _resourceResolver.findComponentResource(component, null, localizedName, SUFFIX, null);
+
if (localizedResource == null)
continue;
@@ -352,24 +386,12 @@
}
finally
{
- close(input);
+ IOUtils.closeQuietly(input);
}
return result;
}
- private void close(InputStream is)
- {
- if (is != null) try
- {
- is.close();
- }
- catch (IOException ex)
- {
- // Ignore.
- }
- }
-
/**
* Clears the cache of read properties files.
*/
@@ -385,25 +407,22 @@
getLocalizedProperties(component));
}
- private String getComponentMessagesEncoding(IComponent component,
- Locale locale)
+ private String getComponentMessagesEncoding(IComponent component, Locale locale)
{
String encoding = _componentPropertySource.getLocalizedComponentProperty(component, locale,
MESSAGES_ENCODING_PROPERTY_NAME);
if (encoding == null)
- encoding = _componentPropertySource.getLocalizedComponentProperty(
- component, locale,
- TemplateSourceImpl.TEMPLATE_ENCODING_PROPERTY_NAME);
+ encoding = _componentPropertySource.
+ getLocalizedComponentProperty(component, locale, TemplateSourceImpl.TEMPLATE_ENCODING_PROPERTY_NAME);
return encoding;
}
- private String getNamespaceMessagesEncoding(INamespace namespace,
- Locale locale)
+ private String getNamespaceMessagesEncoding(INamespace namespace, Locale locale)
{
- return _componentPropertySource.getLocalizedNamespaceProperty(
- namespace, locale, MESSAGES_ENCODING_PROPERTY_NAME);
+ return _componentPropertySource.
+ getLocalizedNamespaceProperty(namespace, locale, MESSAGES_ENCODING_PROPERTY_NAME);
}
public void setComponentPropertySource(ComponentPropertySource componentPropertySource)
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentPropertySourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentPropertySourceImpl.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentPropertySourceImpl.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentPropertySourceImpl.java Mon Jul 16 17:22:19 2007
@@ -14,6 +14,7 @@
package org.apache.tapestry.services.impl;
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
import org.apache.hivemind.Resource;
import org.apache.hivemind.lib.chain.ChainBuilder;
import org.apache.tapestry.IComponent;
@@ -24,13 +25,16 @@
import org.apache.tapestry.spec.IComponentSpecification;
import org.apache.tapestry.util.PropertyHolderPropertySource;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
/**
* Implementation of tapestry.props.ComponentPropertySource.
* <p>
* TODO: Figure out a testing strategy for this beast!
- *
+ *
* @author Howard M. Lewis Ship
* @since 4.0
*/
@@ -40,15 +44,15 @@
private ChainBuilder _chainBuilder;
- private Map _componentSources = new HashMap();
+ private Map _componentSources = new ConcurrentHashMap();
- private Map _localizedComponentSources = new HashMap();
+ private Map _localizedComponentSources = new ConcurrentHashMap();
- private Map _namespaceSources = new HashMap();
+ private Map _namespaceSources = new ConcurrentHashMap();
- private Map _localizedNamespaceSources = new HashMap();
+ private Map _localizedNamespaceSources = new ConcurrentHashMap();
- public synchronized void resetEventDidOccur()
+ public void resetEventDidOccur()
{
_componentSources.clear();
_localizedComponentSources.clear();
@@ -56,7 +60,7 @@
_localizedNamespaceSources.clear();
}
- private synchronized IPropertySource getSourceForNamespace(INamespace namespace)
+ private IPropertySource getSourceForNamespace(INamespace namespace)
{
Resource key = namespace.getSpecificationLocation();
@@ -65,13 +69,14 @@
if (result == null)
{
result = createSourceForNamespace(namespace);
+
_namespaceSources.put(key, result);
}
return result;
}
- private synchronized IPropertySource getSourceForComponent(IComponent component)
+ private IPropertySource getSourceForComponent(IComponent component)
{
Resource key = component.getSpecification().getSpecificationLocation();
@@ -86,7 +91,7 @@
return result;
}
- private synchronized LocalizedPropertySource getLocalizedSourceForComponent(IComponent component)
+ private LocalizedPropertySource getLocalizedSourceForComponent(IComponent component)
{
Resource key = component.getSpecification().getSpecificationLocation();
@@ -102,7 +107,7 @@
return result;
}
- private synchronized LocalizedPropertySource getLocalizedSourceForNamespace(INamespace namespace)
+ private LocalizedPropertySource getLocalizedSourceForNamespace(INamespace namespace)
{
Resource key = namespace.getSpecificationLocation();
@@ -128,9 +133,9 @@
sources.add(getSourceForNamespace(component.getNamespace()));
return (IPropertySource) _chainBuilder.buildImplementation(
- IPropertySource.class,
- sources,
- ImplMessages.componentPropertySourceDescription(specification));
+ IPropertySource.class,
+ sources,
+ ImplMessages.componentPropertySourceDescription(specification));
}
private IPropertySource createSourceForNamespace(INamespace namespace)
@@ -140,10 +145,9 @@
sources.add(new PropertyHolderPropertySource(namespace.getSpecification()));
sources.add(_globalProperties);
- return (IPropertySource) _chainBuilder.buildImplementation(
- IPropertySource.class,
- sources,
- ImplMessages.namespacePropertySourceDescription(namespace));
+ return (IPropertySource) _chainBuilder.buildImplementation(IPropertySource.class,
+ sources,
+ ImplMessages.namespacePropertySourceDescription(namespace));
}
public String getComponentProperty(IComponent component, String propertyName)
@@ -151,8 +155,7 @@
return getSourceForComponent(component).getPropertyValue(propertyName);
}
- public String getLocalizedComponentProperty(IComponent component, Locale locale,
- String propertyName)
+ public String getLocalizedComponentProperty(IComponent component, Locale locale, String propertyName)
{
return getLocalizedSourceForComponent(component).getPropertyValue(propertyName, locale);
}
@@ -162,8 +165,7 @@
return getSourceForNamespace(namespace).getPropertyValue(propertyName);
}
- public String getLocalizedNamespaceProperty(INamespace namespace, Locale locale,
- String propertyName)
+ public String getLocalizedNamespaceProperty(INamespace namespace, Locale locale, String propertyName)
{
return getLocalizedSourceForNamespace(namespace).getPropertyValue(propertyName, locale);
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/ApplicationSpecification.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/ApplicationSpecification.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/ApplicationSpecification.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/ApplicationSpecification.java Mon Jul 16 17:22:19 2007
@@ -25,9 +25,7 @@
*
**/
-public class ApplicationSpecification
- extends LibrarySpecification
- implements IApplicationSpecification
+public class ApplicationSpecification extends LibrarySpecification implements IApplicationSpecification
{
private String _name;
private String _engineClassName;
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/IComponentSpecification.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/IComponentSpecification.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/IComponentSpecification.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/IComponentSpecification.java Mon Jul 16 17:22:19 2007
@@ -14,15 +14,15 @@
package org.apache.tapestry.spec;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
import org.apache.hivemind.Locatable;
import org.apache.hivemind.LocationHolder;
import org.apache.hivemind.Resource;
import org.apache.tapestry.util.IPropertyHolder;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
/**
* A specification for a component, as read from an XML specification file.
* <p>
@@ -171,8 +171,7 @@
* @throws IllegalArgumentException
* if the bean already has a specification.
*/
- void addBeanSpecification(String name,
- IBeanSpecification specification);
+ void addBeanSpecification(String name, IBeanSpecification specification);
/**
* Returns the {@link IBeanSpecification}for the given name, or null if not
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/LibrarySpecification.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/LibrarySpecification.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/LibrarySpecification.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/LibrarySpecification.java Mon Jul 16 17:22:19 2007
@@ -14,30 +14,24 @@
package org.apache.tapestry.spec;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.Location;
import org.apache.hivemind.Resource;
import org.apache.hivemind.util.ToStringBuilder;
import org.apache.tapestry.Tapestry;
+import java.util.*;
+
/**
* Specification for a library.
* {@link org.apache.tapestry.spec.ApplicationSpecification}is a specialized
* kind of library.
- *
+ *
* @author Howard Lewis Ship
* @since 2.2bv
*/
-public class LibrarySpecification extends LocatablePropertyHolder implements
- ILibrarySpecification
+public class LibrarySpecification extends LocatablePropertyHolder implements ILibrarySpecification
{
/**
@@ -74,7 +68,7 @@
/**
* The XML Public Id used when the library specification was read (if
* applicable).
- *
+ *
* @since 2.2
*/
@@ -93,7 +87,7 @@
/**
* Sets the specification path for an embedded library.
- *
+ *
* @throws IllegalArgumentException
* if a library with the given id already exists
*/
@@ -103,8 +97,7 @@
if (_libraries == null) _libraries = new HashMap();
if (_libraries.containsKey(id))
- throw new IllegalArgumentException(Tapestry.format(
- "LibrarySpecification.duplicate-child-namespace-id", id));
+ throw new IllegalArgumentException(Tapestry.format("LibrarySpecification.duplicate-child-namespace-id", id));
_libraries.put(id, path);
}
@@ -121,11 +114,11 @@
public void setPageSpecificationPath(String name, String path)
{
- if (_pages == null) _pages = new HashMap();
+ if (_pages == null)
+ _pages = new HashMap();
if (_pages.containsKey(name))
- throw new IllegalArgumentException(Tapestry.format(
- "LibrarySpecification.duplicate-page-name", name));
+ throw new IllegalArgumentException(Tapestry.format("LibrarySpecification.duplicate-page-name", name));
_pages.put(name, path);
}
@@ -137,11 +130,11 @@
public void setComponentSpecificationPath(String alias, String path)
{
- if (_components == null) _components = new HashMap();
+ if (_components == null)
+ _components = new HashMap();
if (_components.containsKey(alias))
- throw new IllegalArgumentException(Tapestry.format(
- "LibrarySpecification.duplicate-component-alias", alias));
+ throw new IllegalArgumentException(Tapestry.format("LibrarySpecification.duplicate-component-alias", alias));
_components.put(alias, path);
}
@@ -162,7 +155,8 @@
private List sortedKeys(Map map)
{
- if (map == null) return Collections.EMPTY_LIST;
+ if (map == null)
+ return Collections.EMPTY_LIST;
List result = new ArrayList(map.keySet());
@@ -173,7 +167,8 @@
private Object get(Map map, Object key)
{
- if (map == null) return null;
+ if (map == null)
+ return null;
return map.get(key);
}
@@ -204,27 +199,26 @@
public Map getExtensionSpecifications()
{
- if (_extensions == null) return null;
+ if (_extensions == null)
+ return null;
return Collections.unmodifiableMap(_extensions);
}
/**
* Adds another extension specification.
- *
+ *
* @throws IllegalArgumentException
* if an extension with the given name already exists.
*/
-
- public void addExtensionSpecification(String name,
- IExtensionSpecification extension)
+ public void addExtensionSpecification(String name, IExtensionSpecification extension)
{
- if (_extensions == null) _extensions = new HashMap();
+ if (_extensions == null)
+ _extensions = new HashMap();
if (_extensions.containsKey(name))
- throw new IllegalArgumentException(Tapestry
- .format("LibrarySpecification.duplicate-extension-name",
- this, name));
+ throw new IllegalArgumentException(Tapestry.format("LibrarySpecification.duplicate-extension-name",
+ this, name));
_extensions.put(name, extension);
}
@@ -245,7 +239,8 @@
public IExtensionSpecification getExtensionSpecification(String name)
{
- if (_extensions == null) return null;
+ if (_extensions == null)
+ return null;
return (IExtensionSpecification) _extensions.get(name);
}
@@ -257,7 +252,8 @@
public boolean checkExtension(String name)
{
- if (_extensions == null) return false;
+ if (_extensions == null)
+ return false;
return _extensions.containsKey(name);
}
@@ -265,7 +261,7 @@
/**
* Returns an instantiated extension. Extensions are created as needed and
* cached for later use.
- *
+ *
* @throws IllegalArgumentException
* if no extension specification exists for the given name.
*/
@@ -286,8 +282,7 @@
IExtensionSpecification spec = getExtensionSpecification(name);
if (spec == null)
- throw new IllegalArgumentException(Tapestry.format(
- "LibrarySpecification.no-such-extension", name));
+ throw new IllegalArgumentException(Tapestry.format("LibrarySpecification.no-such-extension", name));
if (result == null)
{
@@ -298,14 +293,22 @@
}
if (typeConstraint != null)
- applyTypeConstraint(name, result, typeConstraint, spec
- .getLocation());
+ applyTypeConstraint(name, result, typeConstraint, spec.getLocation());
return result;
}
/**
* Checks that an extension conforms to the supplied type constraint.
+ *
+ * @param name
+ * Name of the extension to apply constraint check to.
+ * @param extension
+ * Object extension.
+ * @param typeConstraint
+ * Constraint to check.
+ * @param location
+ * Location of specified extension.
*
* @throws IllegalArgumentException
* if the extension fails the check.
@@ -313,21 +316,22 @@
*/
protected void applyTypeConstraint(String name, Object extension,
- Class typeConstraint, Location location)
+ Class typeConstraint, Location location)
{
Class extensionClass = extension.getClass();
// Can you assign an instance of the extension to a variable
// of type typeContraint legally?
- if (typeConstraint.isAssignableFrom(extensionClass)) return;
+ if (typeConstraint.isAssignableFrom(extensionClass))
+ return;
- String key = typeConstraint.isInterface() ? "LibrarySpecification.extension-does-not-implement-interface"
- : "LibrarySpecification.extension-not-a-subclass";
+ String key = typeConstraint.isInterface()
+ ? "LibrarySpecification.extension-does-not-implement-interface"
+ : "LibrarySpecification.extension-not-a-subclass";
- throw new ApplicationRuntimeException(Tapestry.format(key, name,
- extensionClass.getName(), typeConstraint.getName()), location,
- null);
+ throw new ApplicationRuntimeException(
+ Tapestry.format(key, name, extensionClass.getName(), typeConstraint.getName()), location, null);
}
/**
@@ -337,7 +341,8 @@
public synchronized void instantiateImmediateExtensions()
{
- if (_extensions == null) return;
+ if (_extensions == null)
+ return;
Iterator i = _extensions.entrySet().iterator();
@@ -345,10 +350,10 @@
{
Map.Entry entry = (Map.Entry) i.next();
- IExtensionSpecification spec = (IExtensionSpecification) entry
- .getValue();
+ IExtensionSpecification spec = (IExtensionSpecification) entry.getValue();
- if (!spec.isImmediate()) continue;
+ if (!spec.isImmediate())
+ continue;
String name = (String) entry.getKey();
@@ -359,7 +364,7 @@
/**
* Returns the extensions map.
- *
+ *
* @return Map of objects.
*/
@@ -370,7 +375,7 @@
/**
* Updates the extension map.
- *
+ *
* @param extension
* A Map of extension specification paths keyed on extension id.
* <p>
@@ -384,7 +389,7 @@
/**
* Returns the libraries map.
- *
+ *
* @return Map of {@link LibrarySpecification}.
*/
@@ -395,7 +400,7 @@
/**
* Updates the library map.
- *
+ *
* @param libraries
* A Map of library specification paths keyed on library id.
* <p>
@@ -409,7 +414,7 @@
/**
* Returns the pages map.
- *
+ *
* @return Map of {@link IComponentSpecification}.
*/
@@ -420,7 +425,7 @@
/**
* Updates the page map.
- *
+ *
* @param pages
* A Map of page specification paths keyed on page id.
* <p>
@@ -434,7 +439,7 @@
/**
* Returns the components map.
- *
+ *
* @return Map of {@link IContainedComponent}.
*/
@@ -445,7 +450,7 @@
/**
* Updates the components map.
- *
+ *
* @param components
* A Map of {@link IContainedComponent}keyed on component id.
* The map is retained, not copied.
@@ -510,7 +515,7 @@
/**
* Does nothing, subclasses may override to add additional description.
- *
+ *
* @see #toString()
* @since 3.0
*/
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/LocatablePropertyHolder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/LocatablePropertyHolder.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/LocatablePropertyHolder.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/spec/LocatablePropertyHolder.java Mon Jul 16 17:22:19 2007
@@ -28,8 +28,7 @@
* @since 3.0
*/
-public class LocatablePropertyHolder extends BasePropertyHolder implements
- LocationHolder
+public class LocatablePropertyHolder extends BasePropertyHolder implements LocationHolder
{
private Location _location;
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/BasePropertyHolder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/BasePropertyHolder.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/BasePropertyHolder.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/BasePropertyHolder.java Mon Jul 16 17:22:19 2007
@@ -14,11 +14,7 @@
package org.apache.tapestry.util;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
/**
* Base class implementation for the {@link IPropertyHolder} interface.
@@ -26,7 +22,7 @@
*
* @author Howard Lewis Ship
*
- **/
+ */
public class BasePropertyHolder implements IPropertyHolder
{
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js Mon Jul 16 17:22:19 2007
@@ -608,8 +608,8 @@
*/
buildEventProperties:function(event, props, args){
if (!props) props={};
+
if (dojo.event.browser.isEvent(event)) {
-
if(event["type"]) props.beventtype=event.type;
if(event["keys"]) props.beventkeys=event.keys;
if(event["charCode"]) props.beventcharCode=event.charCode;
@@ -620,11 +620,10 @@
if (event["target"]) this.buildTargetProperties(props, event.target);
- } else if ( args != undefined ) {
-
+ } else if ( typeof args != "undefined" ) {
props.methodArguments = dojo.json.serialize( args );
-
}
+
return props;
},
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectEventServiceTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectEventServiceTest.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectEventServiceTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectEventServiceTest.java Mon Jul 16 17:22:19 2007
@@ -14,28 +14,21 @@
package org.apache.tapestry.engine;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.isA;
-
-import java.util.HashMap;
-import java.util.Map;
-
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.hivemind.Location;
-import org.apache.tapestry.IComponent;
-import org.apache.tapestry.IDirectEvent;
-import org.apache.tapestry.IPage;
-import org.apache.tapestry.IRequestCycle;
-import org.apache.tapestry.StaleSessionException;
+import org.apache.tapestry.*;
import org.apache.tapestry.event.BrowserEvent;
import org.apache.tapestry.services.LinkFactory;
import org.apache.tapestry.services.ResponseRenderer;
import org.apache.tapestry.services.ServiceConstants;
import org.apache.tapestry.web.WebRequest;
import org.apache.tapestry.web.WebSession;
+import static org.easymock.EasyMock.*;
import org.testng.annotations.Test;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Tests for {@link org.apache.tapestry.engine.DirectService}.
*
@@ -215,6 +208,7 @@
trainGetParameter(cycle, ServiceConstants.CONTAINER, null);
trainGetParameter(cycle, ServiceConstants.PAGE, "ActivePage");
trainGetParameter(cycle, ServiceConstants.SESSION, null);
+ trainGetParameter(cycle, BrowserEvent.METHOD_ARGUMENTS, null);
trainGetPage(cycle, "ActivePage", page);
cycle.activate(page);
@@ -260,7 +254,8 @@
trainGetParameter(cycle, ServiceConstants.CONTAINER, "ComponentPage");
trainGetParameter(cycle, ServiceConstants.PAGE, "ActivePage");
trainGetParameter(cycle, ServiceConstants.SESSION, null);
-
+ trainGetParameter(cycle, BrowserEvent.METHOD_ARGUMENTS, null);
+
trainGetPage(cycle, "ActivePage", page);
cycle.activate(page);
@@ -345,6 +340,7 @@
trainGetParameter(cycle, ServiceConstants.CONTAINER, null);
trainGetParameter(cycle, ServiceConstants.PAGE, "ActivePage");
trainGetParameter(cycle, ServiceConstants.SESSION, "T");
+ trainGetParameter(cycle, BrowserEvent.METHOD_ARGUMENTS, null);
trainGetPage(cycle, "ActivePage", page);
cycle.activate(page);
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectServiceTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectServiceTest.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectServiceTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/DirectServiceTest.java Mon Jul 16 17:22:19 2007
@@ -261,6 +261,7 @@
trainGetParameter(cycle, ServiceConstants.CONTAINER, null);
trainGetParameter(cycle, ServiceConstants.PAGE, "ActivePage");
trainGetParameter(cycle, ServiceConstants.SESSION, null);
+ trainGetParameter(cycle, BrowserEvent.METHOD_ARGUMENTS, null);
trainGetPage(cycle, "ActivePage", page);
cycle.activate(page);
Added: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/TestNamespaceProperties.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/TestNamespaceProperties.java?view=auto&rev=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/TestNamespaceProperties.java (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/TestNamespaceProperties.java Mon Jul 16 17:22:19 2007
@@ -0,0 +1,52 @@
+package org.apache.tapestry.engine;
+
+import org.apache.tapestry.INamespace;
+import org.apache.tapestry.TestBase;
+import org.apache.tapestry.spec.ILibrarySpecification;
+import org.apache.tapestry.spec.LibrarySpecification;
+import org.testng.annotations.Test;
+
+/**
+ * Tests property value getting logic of {@link Namespace}.
+ */
+@Test
+public class TestNamespaceProperties extends TestBase {
+
+ public void test_Simple_Get_Property()
+ {
+ ILibrarySpecification spec = new LibrarySpecification();
+ INamespace ns = new Namespace("test", null, spec, null);
+
+ spec.setProperty("key", "value");
+
+ assertEquals(ns.getPropertyValue("key"), "value");
+ }
+
+ public void test_Get_Immediate_Property()
+ {
+ ILibrarySpecification parentSpec = new LibrarySpecification();
+ INamespace parentNs = new Namespace("parent", null, parentSpec, null);
+
+ ILibrarySpecification spec = new LibrarySpecification();
+ INamespace ns = new Namespace("test", parentNs, spec, null);
+
+ parentSpec.setProperty("barney", "rubble");
+ spec.setProperty("barney", "bam bam");
+
+ assertEquals(ns.getPropertyValue("barney"), "bam bam");
+ }
+
+ public void test_Get_Parent_Property()
+ {
+ ILibrarySpecification parentSpec = new LibrarySpecification();
+ INamespace parentNs = new Namespace("parent", null, parentSpec, null);
+
+ ILibrarySpecification spec = new LibrarySpecification();
+ INamespace ns = new Namespace("test", parentNs, spec, null);
+
+ parentSpec.setProperty("barney", "rubble");
+
+ assertEquals(ns.getPropertyValue("barney"), "rubble");
+ assert ns.getPropertyValue("nothere") == null;
+ }
+}
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/TestNamespaceProperties.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/TestNamespaceProperties.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/engine/TestNamespaceProperties.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/event/BrowserEventTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/event/BrowserEventTest.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/event/BrowserEventTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/event/BrowserEventTest.java Mon Jul 16 17:22:19 2007
@@ -13,69 +13,56 @@
// limitations under the License.
package org.apache.tapestry.event;
-import static org.easymock.EasyMock.expect;
-
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.tapestry.BaseComponentTestCase;
import org.apache.tapestry.IRequestCycle;
+import static org.easymock.EasyMock.expect;
import org.testng.annotations.Test;
/**
- * Tests how BrowserEvent extracts itself from the RequestCycle
- *
+ * Tests how {@link BrowserEvent} extracts itself from the {@link IRequestCycle}.
*/
@Test
public class BrowserEventTest extends BaseComponentTestCase
{
- public void testConstructAndReadMethodArguments() {
+ public void test_Construct_And_Read_Method_Arguments()
+ {
IRequestCycle cycle = newCycle();
-
trainCycleForStandardBrowserEvent(cycle);
-
- expect(cycle.getParameter(BrowserEvent.METHOD_ARGUMENTS))
- .andReturn("[1,2]");
+ expect(cycle.getParameter(BrowserEvent.METHOD_ARGUMENTS)).andReturn("[1,2]");
+
replay();
-
+
BrowserEvent event = new BrowserEvent(cycle);
-
+
verify();
-
- assertEquals(1, event.getMethodArguments().getInt(0));
- assertEquals(2, event.getMethodArguments().getInt(1));
+
+ assertEquals(event.getMethodArguments().getInt(0), 1);
+ assertEquals(event.getMethodArguments().getInt(1), 2);
}
-
-
-
- public void testUnparseableJSON() {
-
+
+ @Test(expectedExceptions = ApplicationRuntimeException.class)
+ public void test_Unparseable_JSON_Method_Arguments()
+ {
IRequestCycle cycle = newCycle();
-
trainCycleForStandardBrowserEvent(cycle);
- expect(cycle.getParameter(BrowserEvent.METHOD_ARGUMENTS))
- .andReturn("*/utterRubbsh");
+ expect(cycle.getParameter(BrowserEvent.METHOD_ARGUMENTS)).andReturn("*/utterRubb�sh");
+
replay();
-
+
BrowserEvent event = new BrowserEvent(cycle);
-
+
verify();
-
- try {
- event.getMethodArguments();
- unreachable();
- } catch( ApplicationRuntimeException e) {
- //success.
- }
+
+ event.getMethodArguments();
}
- /**
- * @param cycle
- */
private void trainCycleForStandardBrowserEvent(IRequestCycle cycle)
{
expect(cycle.getParameter(BrowserEvent.NAME)).andReturn("onClick").anyTimes();
-
+
expect(cycle.getParameter(BrowserEvent.TYPE)).andReturn("click");
expect(cycle.getParameters(BrowserEvent.KEYS)).andReturn(null);
expect(cycle.getParameter(BrowserEvent.CHAR_CODE)).andReturn(null);
@@ -83,11 +70,7 @@
expect(cycle.getParameter(BrowserEvent.PAGE_Y)).andReturn("1243");
expect(cycle.getParameter(BrowserEvent.LAYER_X)).andReturn(null);
expect(cycle.getParameter(BrowserEvent.LAYER_Y)).andReturn(null);
-
- expect(cycle.getParameter(BrowserEvent.TARGET + "." + BrowserEvent.TARGET_ATTR_ID))
- .andReturn("element1");
- }
-
-
+ expect(cycle.getParameter(BrowserEvent.TARGET + "." + BrowserEvent.TARGET_ATTR_ID)).andReturn("element1");
+ }
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java Mon Jul 16 17:22:19 2007
@@ -272,6 +272,7 @@
form.setEventInvoker(invoker);
trainExtractBrowserEvent(cycle);
+ expect(cycle.getParameter(BrowserEvent.METHOD_ARGUMENTS)).andReturn("null");
replay();
@@ -669,6 +670,7 @@
form.setEventInvoker(invoker);
trainExtractBrowserEvent(cycle);
+ expect(cycle.getParameter(BrowserEvent.METHOD_ARGUMENTS)).andReturn("null");
invoker.invokeFormListeners(eq(fs), eq(cycle), isA(BrowserEvent.class));
@@ -871,6 +873,7 @@
form.setEventInvoker(invoker);
trainExtractBrowserEvent(cycle);
+ expect(cycle.getParameter(BrowserEvent.METHOD_ARGUMENTS)).andReturn("null");
invoker.invokeFormListeners(eq(fs), eq(cycle), isA(BrowserEvent.class));
@@ -1000,8 +1003,7 @@
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycle();
IValidationDelegate delegate = newDelegate();
- ComponentEventInvoker invoker =
- org.easymock.classextension.EasyMock.createMock(ComponentEventInvoker.class);
+ ComponentEventInvoker invoker = org.easymock.classextension.EasyMock.createMock(ComponentEventInvoker.class);
MockForm form = new MockForm(delegate, l);
@@ -1025,13 +1027,13 @@
final IFormComponent barney1 = newFormComponent("barney", "barney");
final IFormComponent wilma = newFormComponent("wilma", "wilma");
- IRender body = newComponentsRenderBody(fs, new IFormComponent[]
- { barney1, wilma }, writer);
+ IRender body = newComponentsRenderBody(fs, new IFormComponent[] { barney1, wilma }, writer);
form.setBody(body);
form.setEventInvoker(invoker);
trainExtractBrowserEvent(cycle);
+ expect(cycle.getParameter(BrowserEvent.METHOD_ARGUMENTS)).andReturn("null");
invoker.invokeFormListeners(eq(fs), eq(cycle), isA(BrowserEvent.class));
@@ -1324,6 +1326,7 @@
form.setEventInvoker(invoker);
trainExtractBrowserEvent(cycle);
+ expect(cycle.getParameter(BrowserEvent.METHOD_ARGUMENTS)).andReturn("null");
invoker.invokeFormListeners(eq(fs), eq(cycle), isA(BrowserEvent.class));
@@ -1357,8 +1360,8 @@
delegate.clear();
trainCycleForRewind(cycle, "", null);
-
trainExtractBrowserEvent(cycle);
+ expect(cycle.getParameter(BrowserEvent.METHOD_ARGUMENTS)).andReturn("null");
writer.print("DEFERRED");
Added: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Application.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Application.properties?view=auto&rev=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Application.properties (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Application.properties Mon Jul 16 17:22:19 2007
@@ -0,0 +1,3 @@
+inherited.app.name=Mock Wonder
+
+library-overrides-application=APPLICATION.override
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Application.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Application.properties
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Application.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Library.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Library.properties?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Library.properties (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/Library.properties Mon Jul 16 17:22:19 2007
@@ -16,3 +16,5 @@
component-overrides-namespace=LIBRARY_BASE.component-overrides-namespace
multilocale=multilocale
+
+library-overrides-application=LIBRARY.override
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/TestComponentMessages.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/TestComponentMessages.java?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/TestComponentMessages.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/TestComponentMessages.java Mon Jul 16 17:22:19 2007
@@ -50,7 +50,7 @@
* <p>
* TODO: Add tests realted to messages encoding (which can be specified as meta-data on the
* component specification or, ultimately, in the namespace (library specification).
- *
+ *
* @author Howard Lewis Ship
* @since 2.0.4
*/
@@ -84,7 +84,7 @@
}
public String getLocalizedComponentProperty(IComponent component, Locale locale,
- String propertyName)
+ String propertyName)
{
return null;
}
@@ -95,7 +95,7 @@
}
public String getLocalizedNamespaceProperty(INamespace namespace, Locale locale,
- String propertyName)
+ String propertyName)
{
return null;
}
@@ -105,7 +105,7 @@
{
String actual = messages.getMessage(key);
- assertEquals(expected, actual);
+ assertEquals(actual, expected);
}
private static final String MOCK1 = "/org/apache/tapestry/junit/MockPage1.page";
@@ -136,13 +136,12 @@
* much as the full framework would do at runtime.
*/
- private IPage newPage(IComponentSpecification specification, ComponentMessagesSource source,
- Locale locale)
+ private IPage newPage(IComponentSpecification specification, ComponentMessagesSource source, Locale locale)
{
ClassFactory classFactory = new ClassFactoryImpl();
- EnhancementOperationImpl op = new EnhancementOperationImpl(new DefaultClassResolver(),
- specification, BasePage.class, classFactory, null);
+ EnhancementOperationImpl op =
+ new EnhancementOperationImpl(new DefaultClassResolver(), specification, BasePage.class, classFactory, null);
InjectMessagesWorker injectMessages = new InjectMessagesWorker();
injectMessages.setComponentMessagesSource(source);
@@ -159,6 +158,30 @@
return result;
}
+ private Messages createFullMessages(String location, Locale locale)
+ {
+ ComponentMessagesSourceImpl source = new ComponentMessagesSourceImpl();
+ source.setClasspathResourceFactory(new ClasspathResourceFactoryImpl(new DefaultClassResolver()));
+ source.setComponentPropertySource(new NullComponentPropertySource());
+ source.setComponentResourceResolver(new ComponentResourceResolverImpl());
+
+ IComponentSpecification spec = newSpec(location);
+ spec.setLocation(_locationFixture);
+
+ IPage page = newPage(spec, source, locale);
+
+ Resource resource = new ClasspathResource(new DefaultClassResolver(), "/org/apache/tapestry/junit/Application.application");
+ ILibrarySpecification pspec = new LibrarySpecification();
+ pspec.setSpecificationLocation(resource);
+
+ INamespace parentNamespace = new Namespace(null, null, pspec, null);
+ INamespace namespace = new Namespace(null, parentNamespace, newLibrarySpec(), null);
+
+ page.setNamespace(namespace);
+
+ return source.getMessages(page);
+ }
+
private Messages createMessages(String location, Locale locale)
{
ComponentMessagesSourceImpl source = new ComponentMessagesSourceImpl();
@@ -189,17 +212,17 @@
spec.setLocation(_locationFixture);
IPage page = newPage(spec, source, locale);
-
+
ILibrarySpecification lspec = newLibrarySpec();
lspec.setProperty(ComponentMessagesSourceImpl.NAMESPACE_PROPERTIES_NAME, propname);
-
+
INamespace namespace = new Namespace(null, null, lspec, null);
page.setNamespace(namespace);
return source.getMessages(page);
}
-
+
public void test_Only_In_Base()
{
Messages messages = createMessages(MOCK1, new Locale("en", "US"));
@@ -210,17 +233,17 @@
public void test_Specification_Properties_File_Change()
{
Messages msgs = createMessages(MOCK1, new Locale("en", "US"), "override");
-
+
check(msgs, "standard-property", "Whispering wind");
}
-
+
public void test_Specification_Properties_File_Classpath_Change()
{
Messages msgs = createMessages(MOCK1, new Locale("en", "US"), "org.apache.tapestry.junit.mock.app.impl.classpath");
-
+
check(msgs, "standard-property", "Here!");
}
-
+
/** @since 4.0 */
public void test_Only_In_Namespace()
{
@@ -242,10 +265,7 @@
{
Messages messages = createMessages(MOCK1, new Locale("en", "US"));
- check(
- messages,
- "component-overrides-namespace",
- "MOCKPAGE1_BASE.component-overrides-namespace");
+ check(messages, "component-overrides-namespace", "MOCKPAGE1_BASE.component-overrides-namespace");
}
/** @since 4.0 */
@@ -254,9 +274,9 @@
Messages messages = createMessages(MOCK1, new Locale("fr"));
check(
- messages,
- "localized-component-overrides-namespace",
- "MOCKPAGE1_FR.localized-component-overrides-namespace");
+ messages,
+ "localized-component-overrides-namespace",
+ "MOCKPAGE1_FR.localized-component-overrides-namespace");
}
public void testMissingKey()
@@ -372,4 +392,18 @@
assertEquals("multilocale", source.getMessages(page).getMessage("multilocale"));
}
-}
\ No newline at end of file
+
+ public void test_Component_Property_From_Application()
+ {
+ Messages messages = createFullMessages(MOCK1, new Locale("en", "US"));
+
+ check(messages, "inherited.app.name", "Mock Wonder");
+ }
+
+ public void test_Component_Property_From_Library_Overrides_Application()
+ {
+ Messages messages = createFullMessages(MOCK1, new Locale("en", "US"));
+
+ check(messages, "library-overrides-application", "LIBRARY.override");
+ }
+}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/spec/BasicExtension.application
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/spec/BasicExtension.application?view=diff&rev=556780&r1=556779&r2=556780
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/spec/BasicExtension.application (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/spec/BasicExtension.application Mon Jul 16 17:22:19 2007
@@ -17,7 +17,7 @@
<!DOCTYPE application PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
- "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
+ "http://tapestry.apache.org/dtd/Tapestry_3_0.dtd">
<application name="Test Basic Extension">