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 2010/01/06 20:39:29 UTC
svn commit: r896636 - in
/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5:
internal/ internal/beaneditor/ internal/structure/ internal/transform/
services/
Author: hlship
Date: Wed Jan 6 19:39:28 2010
New Revision: 896636
URL: http://svn.apache.org/viewvc?rev=896636&view=rev
Log:
Make use of InternalConstants.EMPTY_STRING_ARRAY in a few extra places
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/EmptyEventContext.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ComponentWorker.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TransformMethodSignature.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/EmptyEventContext.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/EmptyEventContext.java?rev=896636&r1=896635&r2=896636&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/EmptyEventContext.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/EmptyEventContext.java Wed Jan 6 19:39:28 2010
@@ -1,4 +1,4 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 2010 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.
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java?rev=896636&r1=896635&r2=896636&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/TapestryInternalUtils.java Wed Jan 6 19:39:28 2010
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2009 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2010 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.
@@ -44,8 +44,6 @@
private static final int BUFFER_SIZE = 5000;
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
-
/**
* Capitalizes the string, and inserts a space before each upper case character (or sequence of upper case
* characters). Thus "userId" becomes "User Id", etc. Also, converts underscore into space (and capitalizes the
@@ -391,8 +389,8 @@
public static String[] splitAtCommas(String value)
{
if (InternalUtils.isBlank(value))
- return EMPTY_STRING_ARRAY;
-
+ return InternalConstants.EMPTY_STRING_ARRAY;
+
return COMMA_PATTERN.split(value.trim());
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java?rev=896636&r1=896635&r2=896636&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/beaneditor/BeanModelUtils.java Wed Jan 6 19:39:28 2010
@@ -1,10 +1,10 @@
-// Copyright 2007, 2008, 2009 The Apache Software Foundation
+// Copyright 2007, 2008, 2009, 2010 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
+// 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,
@@ -15,6 +15,7 @@
package org.apache.tapestry5.internal.beaneditor;
import org.apache.tapestry5.beaneditor.BeanModel;
+import org.apache.tapestry5.internal.InternalConstants;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
/**
@@ -24,41 +25,53 @@
{
/**
- * Performs standard set of modifications to a {@link org.apache.tapestry5.beaneditor.BeanModel}. First new
+ * Performs standard set of modifications to a {@link org.apache.tapestry5.beaneditor.BeanModel}
+ * . First new
* properties may be added, then properties removed, then properties reordered.
- *
- * @param model to modifiy
- * @param addPropertyNames comma seperated list of property names to add, or null
- * @param includePropertyNames comma seperated list of property names to include
- * @param excludePropertyNames comma seperated list of property names to exclude, or null
- * @param reorderPropertyNames comma seperated list of property names to reorder, or null
+ *
+ * @param model
+ * to modifiy
+ * @param addPropertyNames
+ * comma seperated list of property names to add, or null
+ * @param includePropertyNames
+ * comma seperated list of property names to include
+ * @param excludePropertyNames
+ * comma seperated list of property names to exclude, or null
+ * @param reorderPropertyNames
+ * comma seperated list of property names to reorder, or null
*/
- public static void modify(BeanModel model, String addPropertyNames, String includePropertyNames,
- String excludePropertyNames,
- String reorderPropertyNames)
+ public static void modify(BeanModel model, String addPropertyNames,
+ String includePropertyNames, String excludePropertyNames, String reorderPropertyNames)
{
- if (addPropertyNames != null) add(model, addPropertyNames);
+ if (addPropertyNames != null)
+ add(model, addPropertyNames);
- if (includePropertyNames != null) include(model, join(includePropertyNames, addPropertyNames));
+ if (includePropertyNames != null)
+ include(model, join(includePropertyNames, addPropertyNames));
- if (excludePropertyNames != null) exclude(model, excludePropertyNames);
+ if (excludePropertyNames != null)
+ exclude(model, excludePropertyNames);
- if (reorderPropertyNames != null) reorder(model, reorderPropertyNames);
+ if (reorderPropertyNames != null)
+ reorder(model, reorderPropertyNames);
}
private static final String join(String firstList, String optionalSecondList)
{
- if (InternalUtils.isBlank(optionalSecondList)) return firstList;
+ if (InternalUtils.isBlank(optionalSecondList))
+ return firstList;
return firstList + "," + optionalSecondList;
}
/**
- * Adds empty properties to the bean model. New properties are added with a <em>null</em> {@link
- * org.apache.tapestry5.PropertyConduit}. `
- *
- * @param model to be modified
- * @param propertyNames comma-separated list of property names
+ * Adds empty properties to the bean model. New properties are added with a <em>null</em>
+ * {@link org.apache.tapestry5.PropertyConduit}. `
+ *
+ * @param model
+ * to be modified
+ * @param propertyNames
+ * comma-separated list of property names
*/
public static void add(BeanModel model, String propertyNames)
{
@@ -70,9 +83,10 @@
/**
* Removes properties from the bean model.
- *
+ *
* @param model
- * @param propertyNames comma-separated list of property names
+ * @param propertyNames
+ * comma-separated list of property names
* @see BeanModel#exclude(String...)
*/
public static void exclude(BeanModel model, String propertyNames)
@@ -90,9 +104,10 @@
/**
* Reorders properties within the bean model.
- *
+ *
* @param model
- * @param propertyNames comma-separated list of property names
+ * @param propertyNames
+ * comma-separated list of property names
* @see BeanModel#reorder(String...)
*/
public static void reorder(BeanModel model, String propertyNames)
@@ -104,7 +119,8 @@
{
String trimmed = propertyNames.trim();
- if (trimmed.length() == 0) return new String[0];
+ if (trimmed.length() == 0)
+ return InternalConstants.EMPTY_STRING_ARRAY;
return trimmed.split("\\s*,\\s*");
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java?rev=896636&r1=896635&r2=896636&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java Wed Jan 6 19:39:28 2010
@@ -4,7 +4,7 @@
// 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
+// 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,
@@ -42,6 +42,7 @@
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.internal.AbstractEventContext;
import org.apache.tapestry5.internal.InternalComponentResources;
+import org.apache.tapestry5.internal.InternalConstants;
import org.apache.tapestry5.internal.services.ComponentEventImpl;
import org.apache.tapestry5.internal.services.EventImpl;
import org.apache.tapestry5.internal.services.Instantiator;
@@ -65,15 +66,18 @@
import org.slf4j.Logger;
/**
- * Implements {@link RenderCommand} and represents a component within an overall page. Much of a component page
- * element's behavior is delegated to user code, via a {@link org.apache.tapestry5.runtime.Component} instance.
+ * Implements {@link RenderCommand} and represents a component within an overall page. Much of a
+ * component page
+ * element's behavior is delegated to user code, via a
+ * {@link org.apache.tapestry5.runtime.Component} instance.
* <p/>
- * Once instantiated, a ComponentPageElement should be registered as a {@linkplain
- * org.apache.tapestry5.internal.structure.Page#addLifecycleListener(org.apache.tapestry5.runtime.PageLifecycleListener)
- * lifecycle listener}. This could be done inside the constructors, but that tends to complicate unit tests, so its done
- * by {@link org.apache.tapestry5.internal.services.PageElementFactoryImpl}.
+ * Once instantiated, a ComponentPageElement should be registered as a
+ * {@linkplain org.apache.tapestry5.internal.structure.Page#addLifecycleListener(org.apache.tapestry5.runtime.PageLifecycleListener)
+ * lifecycle listener}. This could be done inside the constructors, but that tends to complicate
+ * unit tests, so its done by {@link org.apache.tapestry5.internal.services.PageElementFactoryImpl}.
*/
-public class ComponentPageElementImpl extends BaseLocatable implements ComponentPageElement, PageLifecycleListener
+public class ComponentPageElementImpl extends BaseLocatable implements ComponentPageElement,
+ PageLifecycleListener
{
/**
* Placeholder for the body used when the component has no real content.
@@ -93,7 +97,6 @@
private static final Block PLACEHOLDER_BLOCK = new PlaceholderBlock();
-
private static final ComponentCallback RESTORE_STATE_BEFORE_PAGE_ATTACH = new LifecycleNotificationComponentCallback()
{
public void run(Component component)
@@ -196,7 +199,8 @@
return sharedEventHandler.getResult();
}
- protected abstract void invokeComponent(Component component, MarkupWriter writer, Event event);
+ protected abstract void invokeComponent(Component component, MarkupWriter writer,
+ Event event);
}
private class SetupRenderPhase extends AbstractPhase
@@ -245,7 +249,9 @@
}
/**
- * Replaces {@link org.apache.tapestry5.internal.structure.ComponentPageElementImpl.BeginRenderPhase} when there is
+ * Replaces
+ * {@link org.apache.tapestry5.internal.structure.ComponentPageElementImpl.BeginRenderPhase}
+ * when there is
* a handler for AfterRender but not BeginRender.
*/
private class OptimizedBeginRenderPhase implements RenderCommand
@@ -264,8 +270,10 @@
}
/**
- * Reponsible for rendering the component's template. Even a component that doesn't have a template goes through
- * this phase, as a synthetic template (used to trigger the rendering of the component's body) will be supplied.
+ * Reponsible for rendering the component's template. Even a component that doesn't have a
+ * template goes through
+ * this phase, as a synthetic template (used to trigger the rendering of the component's body)
+ * will be supplied.
*/
private class BeforeRenderTemplatePhase extends AbstractPhase
{
@@ -274,7 +282,6 @@
super("BeforeRenderTemplate");
}
-
protected void invokeComponent(Component component, MarkupWriter writer, Event event)
{
component.beforeRenderTemplate(writer, event);
@@ -294,7 +301,8 @@
}
/**
- * Alternative version of BeforeRenderTemplatePhase used when the BeforeRenderTemplate render phase is not handled.
+ * Alternative version of BeforeRenderTemplatePhase used when the BeforeRenderTemplate render
+ * phase is not handled.
*/
private class RenderTemplatePhase implements RenderCommand
{
@@ -337,7 +345,6 @@
}
}
-
private class AfterRenderBodyPhase extends AbstractPhase
{
@@ -346,7 +353,6 @@
super("AfterRenderBody");
}
-
protected void invokeComponent(Component component, MarkupWriter writer, Event event)
{
component.afterRenderBody(writer, event);
@@ -406,7 +412,6 @@
}
}
-
private final ComponentPageElementResources elementResources;
private class CleanupRenderPhase extends AbstractPhase
@@ -434,9 +439,11 @@
private class PostRenderCleanupPhase implements RenderCommand
{
/**
- * Used to detect mismatches calls to {@link MarkupWriter#element(String, Object[])} } and {@link
- * org.apache.tapestry5.MarkupWriter#end()}. The expectation is that any element(s) begun by this component
- * during rendering will be balanced by end() calls, resulting in the current element reverting to its initial
+ * Used to detect mismatches calls to {@link MarkupWriter#element(String, Object[])} and
+ * {@link org.apache.tapestry5.MarkupWriter#end()}. The expectation is that any element(s)
+ * begun by this component
+ * during rendering will be balanced by end() calls, resulting in the current element
+ * reverting to its initial
* value.
*/
private final Element expectedElementAtCompletion;
@@ -453,7 +460,8 @@
Element current = writer.getElement();
if (current != expectedElementAtCompletion)
- throw new TapestryException(StructureMessages.unbalancedElements(completeId), getLocation(), null);
+ throw new TapestryException(StructureMessages.unbalancedElements(completeId),
+ getLocation(), null);
invoke(false, POST_RENDER_CLEANUP);
@@ -490,8 +498,10 @@
private final Component coreComponent;
/**
- * Component lifecycle instances for all mixins; the core component is added to this list during page load. This is
- * only used in the case that a component has mixins (in which case, the core component is listed last).
+ * Component lifecycle instances for all mixins; the core component is added to this list during
+ * page load. This is
+ * only used in the case that a component has mixins (in which case, the core component is
+ * listed last).
*/
private List<Component> components = null;
@@ -510,7 +520,8 @@
private boolean loaded;
/**
- * Map from mixin id (the simple name of the mixin class) to resources for the mixin. Created when first mixin is
+ * Map from mixin id (the simple name of the mixin class) to resources for the mixin. Created
+ * when first mixin is
* added.
*/
private Map<String, InternalComponentResources> mixinIdToComponentResources;
@@ -521,7 +532,6 @@
private boolean rendering;
-
// We know that, at the very least, there will be an element to force the component to render
// its body, so there's no reason to wait to initialize the list.
@@ -529,36 +539,40 @@
private boolean renderPhasesInitalized;
- private RenderCommand setupRenderPhase, beginRenderPhase, beforeRenderTemplatePhase, beforeRenderBodyPhase,
- afterRenderBodyPhase, afterRenderTemplatePhase, afterRenderPhase, cleanupRenderPhase;
-
+ private RenderCommand setupRenderPhase, beginRenderPhase, beforeRenderTemplatePhase,
+ beforeRenderBodyPhase, afterRenderBodyPhase, afterRenderTemplatePhase,
+ afterRenderPhase, cleanupRenderPhase;
private final RenderPhaseEventHandler sharedEventHandler = new RenderPhaseEventHandler();
private final EventImpl sharedEvent;
/**
- * Constructor for other components embedded within the root component or at deeper levels of the hierarchy.
- *
- * @param page ultimately containing this component
- * @param container component immediately containing this component (may be null for a root component)
- * @param id unique (within the container) id for this component (may be null for a root component)
- * @param elementName the name of the element which represents this component in the template, or null for
- * <comp> element or a page component
- * @param instantiator used to create the new component instance and access the component's model
- * @param location location of the element (within a template), used as part of exception reporting
- * @param elementResources Provides access to common methods of various services
+ * Constructor for other components embedded within the root component or at deeper levels of
+ * the hierarchy.
+ *
+ * @param page
+ * ultimately containing this component
+ * @param container
+ * component immediately containing this component (may be null for a root component)
+ * @param id
+ * unique (within the container) id for this component (may be null for a root
+ * component)
+ * @param elementName
+ * the name of the element which represents this component in the template, or null
+ * for
+ * <comp> element or a page component
+ * @param instantiator
+ * used to create the new component instance and access the component's model
+ * @param location
+ * location of the element (within a template), used as part of exception reporting
+ * @param elementResources
+ * Provides access to common methods of various services
*/
- ComponentPageElementImpl(Page page,
- ComponentPageElement container,
- String id,
- String nestedId,
- String completeId,
- String elementName,
- Instantiator instantiator,
- Location location,
- ComponentPageElementResources elementResources)
+ ComponentPageElementImpl(Page page, ComponentPageElement container, String id, String nestedId,
+ String completeId, String elementName, Instantiator instantiator, Location location,
+ ComponentPageElementResources elementResources)
{
super(location);
@@ -570,14 +584,11 @@
this.elementName = elementName;
this.elementResources = elementResources;
- ComponentResources containerResources = container == null
- ? null
- : container.getComponentResources();
-
+ ComponentResources containerResources = container == null ? null : container
+ .getComponentResources();
coreResources = new InternalComponentResourcesImpl(this.page, this, containerResources,
- this.elementResources,
- completeId, nestedId, instantiator);
+ this.elementResources, completeId, nestedId, instantiator);
coreComponent = coreResources.getComponent();
@@ -590,12 +601,10 @@
/**
* Constructor for the root component of a page.
*/
- public ComponentPageElementImpl(Page page,
- Instantiator instantiator,
- ComponentPageElementResources elementResources)
+ public ComponentPageElementImpl(Page page, Instantiator instantiator,
+ ComponentPageElementResources elementResources)
{
- this(page, null, null, null, page.getName(), null, instantiator, null,
- elementResources);
+ this(page, null, null, null, page.getName(), null, instantiator, null, elementResources);
}
private void initializeRenderPhases()
@@ -609,7 +618,6 @@
afterRenderPhase = new AfterRenderPhase();
cleanupRenderPhase = new CleanupRenderPhase();
-
// Now the optimization, where we remove, replace and collapse unused phases. We use
// the component models to determine which phases have handler methods for the
// render phases.
@@ -622,7 +630,8 @@
handled.addAll(r.getComponentModel().getHandledRenderPhases());
}
- if (!handled.contains(CleanupRender.class)) cleanupRenderPhase = null;
+ if (!handled.contains(CleanupRender.class))
+ cleanupRenderPhase = null;
// Now, work back to front.
@@ -640,9 +649,8 @@
if (!handled.contains(BeginRender.class))
{
- RenderCommand replacement = afterRenderPhase != null
- ? new OptimizedBeginRenderPhase()
- : beforeRenderTemplatePhase;
+ RenderCommand replacement = afterRenderPhase != null ? new OptimizedBeginRenderPhase()
+ : beforeRenderTemplatePhase;
beginRenderPhase = replacement;
}
@@ -653,26 +661,19 @@
renderPhasesInitalized = true;
}
- public ComponentPageElement newChild(String id, String nestedId, String completeId, String elementName,
- Instantiator instantiator,
- Location location)
- {
- ComponentPageElementImpl child = new ComponentPageElementImpl(page,
- this,
- id,
- nestedId,
- completeId,
- elementName,
- instantiator,
- location,
- elementResources);
+ public ComponentPageElement newChild(String id, String nestedId, String completeId,
+ String elementName, Instantiator instantiator, Location location)
+ {
+ ComponentPageElementImpl child = new ComponentPageElementImpl(page, this, id, nestedId,
+ completeId, elementName, instantiator, location, elementResources);
addEmbeddedElement(child);
return child;
}
- void push(RenderQueue queue, boolean forward, RenderCommand forwardPhase, RenderCommand backwardPhase)
+ void push(RenderQueue queue, boolean forward, RenderCommand forwardPhase,
+ RenderCommand backwardPhase)
{
push(queue, forward ? forwardPhase : backwardPhase);
}
@@ -685,17 +686,17 @@
void addEmbeddedElement(ComponentPageElement child)
{
- if (children == null) children = CollectionFactory.newCaseInsensitiveMap();
+ if (children == null)
+ children = CollectionFactory.newCaseInsensitiveMap();
String childId = child.getId();
ComponentPageElement existing = children.get(childId);
if (existing != null)
- throw new TapestryException(StructureMessages.duplicateChildComponent(this, childId), child,
- new TapestryException(StructureMessages.originalChildComponent(this, childId,
- existing.getLocation()),
- existing, null));
+ throw new TapestryException(StructureMessages.duplicateChildComponent(this, childId),
+ child, new TapestryException(StructureMessages.originalChildComponent(this,
+ childId, existing.getLocation()), existing, null));
children.put(childId, child);
}
@@ -710,31 +711,35 @@
String mixinExtension = "$" + mixinId.toLowerCase();
- InternalComponentResourcesImpl resources = new InternalComponentResourcesImpl(page, this, coreResources,
- elementResources,
- completeId + mixinExtension,
- nestedId + mixinExtension,
- instantiator);
+ InternalComponentResourcesImpl resources = new InternalComponentResourcesImpl(page, this,
+ coreResources, elementResources, completeId + mixinExtension, nestedId
+ + mixinExtension, instantiator);
mixinIdToComponentResources.put(mixinId, resources);
- //note that since we're using explicit ordering now,
- //we don't add anything to components until we page load; instead, we add
- //to the orderers.
- if (order == null) order = new String[0];
+ // note that since we're using explicit ordering now,
+ // we don't add anything to components until we page load; instead, we add
+ // to the orderers.
+ if (order == null)
+ order = InternalConstants.EMPTY_STRING_ARRAY;
+
if (resources.getComponentModel().isMixinAfter())
{
- if (mixinAfterOrderer == null) mixinAfterOrderer = new Orderer<Component>(getLogger());
- mixinAfterOrderer.add(mixinId,resources.getComponent(),order);
- } else
- {
- if (mixinBeforeOrderer == null) mixinBeforeOrderer =new Orderer<Component>(getLogger());
- mixinBeforeOrderer.add(mixinId,resources.getComponent(),order);
+ if (mixinAfterOrderer == null)
+ mixinAfterOrderer = new Orderer<Component>(getLogger());
+ mixinAfterOrderer.add(mixinId, resources.getComponent(), order);
+ }
+ else
+ {
+ if (mixinBeforeOrderer == null)
+ mixinBeforeOrderer = new Orderer<Component>(getLogger());
+ mixinBeforeOrderer.add(mixinId, resources.getComponent(), order);
}
}
public void bindMixinParameter(String mixinId, String parameterName, Binding binding)
{
- InternalComponentResources mixinResources = InternalUtils.get(mixinIdToComponentResources, mixinId);
+ InternalComponentResources mixinResources = InternalUtils.get(mixinIdToComponentResources,
+ mixinId);
mixinResources.bindParameter(parameterName, binding);
}
@@ -751,7 +756,8 @@
public void addToBody(RenderCommand element)
{
- if (bodyBlock == null) bodyBlock = new BlockImpl(getLocation(), "Body of " + getCompleteId());
+ if (bodyBlock == null)
+ bodyBlock = new BlockImpl(getLocation(), "Body of " + getCompleteId());
bodyBlock.addToBody(element);
}
@@ -761,13 +767,15 @@
template.add(element);
}
- private void addUnboundParameterNames(String prefix, List<String> unbound, InternalComponentResources resource)
+ private void addUnboundParameterNames(String prefix, List<String> unbound,
+ InternalComponentResources resource)
{
ComponentModel model = resource.getComponentModel();
for (String name : model.getParameterNames())
{
- if (resource.isBound(name)) continue;
+ if (resource.isBound(name))
+ continue;
ParameterModel parameterModel = model.getParameterModel(name);
@@ -814,7 +822,7 @@
ordered.addAll(mixinAfterOrderer.getOrdered());
components = ordered;
- //no need to keep the orderers around.
+ // no need to keep the orderers around.
mixinBeforeOrderer = null;
mixinAfterOrderer = null;
}
@@ -831,12 +839,13 @@
private void executeDeferredLoadActions()
{
- if (deferredLoadActions == null) return;
- for(Runnable action : deferredLoadActions)
+ if (deferredLoadActions == null)
+ return;
+ for (Runnable action : deferredLoadActions)
{
action.run();
}
- deferredLoadActions = null;//having executed them, we have no need now to store them.
+ deferredLoadActions = null;// having executed them, we have no need now to store them.
}
public void enqueueBeforeRenderBody(RenderQueue queue)
@@ -880,7 +889,8 @@
{
Set<String> ids = InternalUtils.keys(children);
- throw new TapestryException(StructureMessages.noSuchComponent(this, embeddedId, ids), this, null);
+ throw new TapestryException(StructureMessages.noSuchComponent(this, embeddedId, ids),
+ this, null);
}
return embeddedElement;
@@ -891,7 +901,6 @@
return id;
}
-
public Logger getLogger()
{
return coreResources.getLogger();
@@ -901,9 +910,9 @@
{
Component result = mixinForClassName(mixinClassName);
-
- if (result == null) throw new TapestryException(StructureMessages.unknownMixin(completeId, mixinClassName),
- getLocation(), null);
+ if (result == null)
+ throw new TapestryException(StructureMessages.unknownMixin(completeId, mixinClassName),
+ getLocation(), null);
return result;
}
@@ -911,13 +920,12 @@
private Component mixinForClassName(String mixinClassName)
{
- if (mixinIdToComponentResources == null) return null;
+ if (mixinIdToComponentResources == null)
+ return null;
for (InternalComponentResources resources : mixinIdToComponentResources.values())
{
- if (resources.getComponentModel().getComponentClassName().equals(mixinClassName))
- {
- return resources.getComponent();
- }
+ if (resources.getComponentModel().getComponentClassName().equals(mixinClassName)) { return resources
+ .getComponent(); }
}
return null;
}
@@ -929,7 +937,8 @@
public void deferLoadAction(Runnable action)
{
- if (deferredLoadActions == null) deferredLoadActions = CollectionFactory.newList();
+ if (deferredLoadActions == null)
+ deferredLoadActions = CollectionFactory.newList();
deferredLoadActions.add(action);
}
@@ -941,8 +950,8 @@
result = mixinIdToComponentResources.get(mixinId);
if (result == null)
- throw new IllegalArgumentException(
- String.format("Unable to locate mixin '%s' for component '%s'.", mixinId, completeId));
+ throw new IllegalArgumentException(String.format(
+ "Unable to locate mixin '%s' for component '%s'.", mixinId, completeId));
return result;
}
@@ -965,7 +974,8 @@
{
result |= component.dispatchComponentEvent(event);
- if (event.isAborted()) break;
+ if (event.isAborted())
+ break;
}
return result;
@@ -973,10 +983,13 @@
/**
* Invokes a callback on the component instances (the core component plus any mixins).
- *
- * @param reverse if true, the callbacks are in the reverse of the normal order (this is associated with AfterXXX
- * phases)
- * @param callback the object to receive each component instance
+ *
+ * @param reverse
+ * if true, the callbacks are in the reverse of the normal order (this is associated
+ * with AfterXXX
+ * phases)
+ * @param callback
+ * the object to receive each component instance
*/
private void invoke(boolean reverse, ComponentCallback callback)
{
@@ -990,13 +1003,15 @@
return;
}
- Iterator<Component> i = reverse ? InternalUtils.reverseIterator(components) : components.iterator();
+ Iterator<Component> i = reverse ? InternalUtils.reverseIterator(components)
+ : components.iterator();
while (i.hasNext())
{
callback.run(i.next());
- if (callback.isEventAborted()) return;
+ if (callback.isEventAborted())
+ return;
}
}
catch (RuntimeException ex)
@@ -1023,13 +1038,13 @@
return String.format("%s[%s]", phaseName, completeId);
}
-
/**
* Pushes the SetupRender phase state onto the queue.
*/
public final void render(MarkupWriter writer, RenderQueue queue)
{
- // We assume that by the time we start to render, the structure (i.e., mixins) is nailed down.
+ // We assume that by the time we start to render, the structure (i.e., mixins) is nailed
+ // down.
// We could add a lock, but that seems wasteful.
if (!renderPhasesInitalized)
@@ -1059,11 +1074,12 @@
return String.format("ComponentPageElement[%s]", completeId);
}
- public boolean triggerEvent(String eventType, Object[] contextValues, ComponentEventCallback callback)
+ public boolean triggerEvent(String eventType, Object[] contextValues,
+ ComponentEventCallback callback)
{
return triggerContextEvent(eventType,
- createParameterContext(contextValues == null ? new Object[0] : contextValues),
- callback);
+ createParameterContext(contextValues == null ? new Object[0] : contextValues),
+ callback);
}
private EventContext createParameterContext(final Object... values)
@@ -1082,8 +1098,8 @@
};
}
-
- public boolean triggerContextEvent(String eventType, EventContext context, ComponentEventCallback callback)
+ public boolean triggerContextEvent(String eventType, EventContext context,
+ ComponentEventCallback callback)
{
Defense.notBlank(eventType, "eventType");
Defense.notNull(context, "context");
@@ -1094,8 +1110,9 @@
String componentId = "";
// Provide a default handler for when the provided handler is null.
- final ComponentEventCallback providedHandler = callback == null ? new NotificationEventCallback(eventType,
- completeId) : callback;
+ final ComponentEventCallback providedHandler = callback == null ? new NotificationEventCallback(
+ eventType, completeId)
+ : callback;
ComponentEventCallback wrapped = new ComponentEventCallback()
{
@@ -1104,7 +1121,8 @@
// Boolean value is not passed to the handler; it will be true (abort event)
// or false (continue looking for event handlers).
- if (result instanceof Boolean) return (Boolean) result;
+ if (result instanceof Boolean)
+ return (Boolean) result;
return providedHandler.handleResult(result);
}
@@ -1129,29 +1147,33 @@
{
Logger logger = component.getEventLogger();
- ComponentEvent event = new ComponentEventImpl(currentEventType, componentId, currentContext, wrapped,
- elementResources, logger);
+ ComponentEvent event = new ComponentEventImpl(currentEventType, componentId,
+ currentContext, wrapped, elementResources, logger);
logger.debug(TapestryMarkers.EVENT_DISPATCH, "Dispatch event: {}", event);
result |= component.dispatchEvent(event);
- if (event.isAborted()) return result;
+ if (event.isAborted())
+ return result;
}
catch (RuntimeException ex)
{
// An exception in an event handler method
// while we're trying to handle a previous exception!
- if (rootException != null) throw rootException;
+ if (rootException != null)
+ throw rootException;
// We know component is not null and therefore has a component resources that
// should have a location.
- // Wrap it up to help ensure that a location is available to the event handler method or,
+ // Wrap it up to help ensure that a location is available to the event handler
+ // method or,
// more likely, to the exception report page.
- rootException = new ComponentEventException(ex.getMessage(), eventType, context, location, ex);
+ rootException = new ComponentEventException(ex.getMessage(), eventType, context,
+ location, ex);
// Switch over to triggering an "exception" event, starting in the component that
// threw the exception.
@@ -1170,11 +1192,14 @@
component = component.getContainerElement();
}
- // If there was a handler for the exception event, it is required to return a non-null (and non-boolean) value
- // to tell Tapestry what to do. Since that didn't happen, we have no choice but to rethrow the (wrapped)
+ // If there was a handler for the exception event, it is required to return a non-null (and
+ // non-boolean) value
+ // to tell Tapestry what to do. Since that didn't happen, we have no choice but to rethrow
+ // the (wrapped)
// exception.
- if (rootException != null) throw rootException;
+ if (rootException != null)
+ throw rootException;
return result;
}
@@ -1188,7 +1213,8 @@
for (String name : InternalUtils.sortedKeys(mixinIdToComponentResources))
addUnboundParameterNames(name, unbound, mixinIdToComponentResources.get(name));
- if (unbound.isEmpty()) return;
+ if (unbound.isEmpty())
+ return;
throw new TapestryException(StructureMessages.missingParameters(unbound, this), this, null);
}
@@ -1208,7 +1234,8 @@
Block result = findBlock(id);
if (result == null)
- throw new BlockNotFoundException(StructureMessages.blockNotFound(completeId, id), getLocation());
+ throw new BlockNotFoundException(StructureMessages.blockNotFound(completeId, id),
+ getLocation());
return result;
}
@@ -1222,10 +1249,12 @@
public void addBlock(String blockId, Block block)
{
- if (blocks == null) blocks = CollectionFactory.newCaseInsensitiveMap();
+ if (blocks == null)
+ blocks = CollectionFactory.newCaseInsensitiveMap();
if (blocks.containsKey(blockId))
- throw new TapestryException(StructureMessages.duplicateBlock(this, blockId), block, null);
+ throw new TapestryException(StructureMessages.duplicateBlock(this, blockId), block,
+ null);
blocks.put(blockId, block);
}
@@ -1262,7 +1291,8 @@
public Link createActionLink(String eventType, boolean forForm, Object... context)
{
- return elementResources.createComponentEventLink(coreResources, eventType, forForm, context);
+ return elementResources
+ .createComponentEventLink(coreResources, eventType, forForm, context);
}
public Link createFormEventLink(String eventType, Object... context)
@@ -1280,5 +1310,4 @@
return elementResources.createPageRenderLink(pageClass, override, context);
}
-
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ComponentWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ComponentWorker.java?rev=896636&r1=896635&r2=896636&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ComponentWorker.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ComponentWorker.java Wed Jan 6 19:39:28 2010
@@ -4,7 +4,7 @@
// 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
+// 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,
@@ -17,6 +17,7 @@
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.MixinClasses;
import org.apache.tapestry5.annotations.Mixins;
+import org.apache.tapestry5.internal.InternalConstants;
import org.apache.tapestry5.internal.KeyValue;
import org.apache.tapestry5.internal.TapestryInternalUtils;
import org.apache.tapestry5.ioc.Location;
@@ -34,9 +35,10 @@
import org.apache.tapestry5.services.TransformConstants;
/**
- * Finds fields with the {@link org.apache.tapestry5.annotations.Component} annotation and updates the model. Also
- * checks for the {@link Mixins} and {@link MixinClasses} annotations and uses them to update the {@link
- * ComponentModel}.
+ * Finds fields with the {@link org.apache.tapestry5.annotations.Component} annotation and updates
+ * the model. Also
+ * checks for the {@link Mixins} and {@link MixinClasses} annotations and uses them to update the
+ * {@link ComponentModel}.
*/
public class ComponentWorker implements ComponentClassTransformWorker
{
@@ -57,7 +59,8 @@
String id = annotation.id();
- if (InternalUtils.isBlank(id)) id = InternalUtils.stripMemberName(fieldName);
+ if (InternalUtils.isBlank(id))
+ id = InternalUtils.stripMemberName(fieldName);
String type = transformation.getFieldType(fieldName);
@@ -69,18 +72,17 @@
addParameters(embedded, annotation.parameters());
-
String names = annotation.publishParameters();
if (InternalUtils.isNonBlank(names))
{
- embedded.setPublishedParameters(CollectionFactory.newList(TapestryInternalUtils.splitAtCommas(names)));
+ embedded.setPublishedParameters(CollectionFactory.newList(TapestryInternalUtils
+ .splitAtCommas(names)));
}
-
transformation.makeReadOnly(fieldName);
- String body = String.format("%s = (%s) %s.getEmbeddedComponent(\"%s\");", fieldName, type,
- transformation.getResourcesFieldName(), id);
+ String body = String.format("%s = (%s) %s.getEmbeddedComponent(\"%s\");", fieldName,
+ type, transformation.getResourcesFieldName(), id);
transformation
.extendMethod(TransformConstants.CONTAINING_PAGE_DID_LOAD_SIGNATURE, body);
@@ -91,40 +93,41 @@
}
private void addMixinClasses(String fieldName, ClassTransformation transformation,
- MutableEmbeddedComponentModel model)
+ MutableEmbeddedComponentModel model)
{
MixinClasses annotation = transformation.getFieldAnnotation(fieldName, MixinClasses.class);
- if (annotation == null) return;
+ if (annotation == null)
+ return;
boolean orderEmpty = annotation.order().length == 0;
if (!orderEmpty && annotation.order().length != annotation.value().length)
- throw new TapestryException(TransformMessages.badMixinConstraintLength(annotation,fieldName),
- model,null);
+ throw new TapestryException(TransformMessages.badMixinConstraintLength(annotation,
+ fieldName), model, null);
-
- for (int i=0; i<annotation.value().length;i++)
+ for (int i = 0; i < annotation.value().length; i++)
{
- String[] constraints = orderEmpty?
- new String[0]:
- TapestryInternalUtils.splitMixinConstraints(annotation.order()[i]);
+ String[] constraints = orderEmpty ? InternalConstants.EMPTY_STRING_ARRAY
+ : TapestryInternalUtils.splitMixinConstraints(annotation.order()[i]);
+
model.addMixin(annotation.value()[i].getName(), constraints);
}
}
private void addMixinTypes(String fieldName, ClassTransformation transformation,
- MutableEmbeddedComponentModel model)
+ MutableEmbeddedComponentModel model)
{
Mixins annotation = transformation.getFieldAnnotation(fieldName, Mixins.class);
- if (annotation == null) return;
+ if (annotation == null)
+ return;
for (String typeName : annotation.value())
{
Orderable<String> typeAndOrder = TapestryInternalUtils.mixinTypeAndOrder(typeName);
String mixinClassName = resolver.resolveMixinTypeToClassName(typeAndOrder.getTarget());
- model.addMixin(mixinClassName,typeAndOrder.getConstraints());
+ model.addMixin(mixinClassName, typeAndOrder.getConstraints());
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TransformMethodSignature.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TransformMethodSignature.java?rev=896636&r1=896635&r2=896636&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TransformMethodSignature.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TransformMethodSignature.java Wed Jan 6 19:39:28 2010
@@ -4,7 +4,7 @@
// 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
+// 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,
@@ -18,12 +18,15 @@
import java.lang.reflect.Modifier;
+import org.apache.tapestry5.internal.InternalConstants;
+
/**
- * A representation of a method signature, which consists of its name, modifiers (primarily, visibility), return type,
+ * A representation of a method signature, which consists of its name, modifiers (primarily,
+ * visibility), return type,
* parameter types, and declared exception types.
* <p/>
- * Types are stored as class names (or primitive names) because the signature is used with {@link ClassTransformation}
- * (which operates on as-yet unloaded classes).
+ * Types are stored as class names (or primitive names) because the signature is used with
+ * {@link ClassTransformation} (which operates on as-yet unloaded classes).
*/
public class TransformMethodSignature implements Comparable<TransformMethodSignature>
{
@@ -35,19 +38,18 @@
private final String[] parameterTypes, exceptionTypes;
- private static final String[] EMPTY_STRINGS = new String[0];
-
/**
* Convenience for adding a public void method with no parameters or exception types.
*/
public TransformMethodSignature(String name)
{
- this(Modifier.PUBLIC, "void", name, EMPTY_STRINGS, EMPTY_STRINGS);
+ this(Modifier.PUBLIC, "void", name, InternalConstants.EMPTY_STRING_ARRAY,
+ InternalConstants.EMPTY_STRING_ARRAY);
}
public TransformMethodSignature(int modifiers, String type, String name,
- String[] parameterTypes, String[] exceptionTypes)
+ String[] parameterTypes, String[] exceptionTypes)
{
this.modifiers = modifiers;
@@ -63,11 +65,12 @@
private String[] typeNamesOrEmpty(String[] types)
{
- return types == null ? EMPTY_STRINGS : types;
+ return types == null ? InternalConstants.EMPTY_STRING_ARRAY : types;
}
/**
- * Returns a non-null array of the names of each declared exception type thrown by the method. Calling code should
+ * Returns a non-null array of the names of each declared exception type thrown by the method.
+ * Calling code should
* not modify the array.
*/
public String[] getExceptionTypes()
@@ -85,7 +88,7 @@
/**
* Returns the set of modifier flags for this method.
- *
+ *
* @see java.lang.reflect.Modifier
*/
public int getModifiers()
@@ -94,7 +97,8 @@
}
/**
- * Returns an array of the type name for each parameter. Calling code should not modify the array.
+ * Returns an array of the type name for each parameter. Calling code should not modify the
+ * array.
*/
public String[] getParameterTypes()
{
@@ -135,31 +139,35 @@
@Override
public boolean equals(Object other)
{
- if (other == null || !(other instanceof TransformMethodSignature)) return false;
+ if (other == null || !(other instanceof TransformMethodSignature))
+ return false;
TransformMethodSignature ms = (TransformMethodSignature) other;
return modifiers == ms.modifiers && returnType.equals(ms.returnType)
- && methodName.equals(ms.methodName)
- && matches(parameterTypes, ms.parameterTypes)
+ && methodName.equals(ms.methodName) && matches(parameterTypes, ms.parameterTypes)
&& matches(exceptionTypes, ms.exceptionTypes);
}
private boolean matches(String[] values, String[] otherValues)
{
- if (values.length != otherValues.length) return false;
+ if (values.length != otherValues.length)
+ return false;
for (int i = 0; i < values.length; i++)
{
- if (!values[i].equals(otherValues[i])) return false;
+ if (!values[i].equals(otherValues[i]))
+ return false;
}
return true;
}
/**
- * Returns the long form description of the signature. This includes modifiers, return type, method name, parameters
- * and thrown exceptions, formatted approximately as it would appear in Java source (except that parameter names,
+ * Returns the long form description of the signature. This includes modifiers, return type,
+ * method name, parameters
+ * and thrown exceptions, formatted approximately as it would appear in Java source (except that
+ * parameter names,
* which are not known, do no appear).
*/
@Override
@@ -200,7 +208,8 @@
for (int i = 0; i < parameterTypes.length; i++)
{
- if (i > 0) builder.append(", ");
+ if (i > 0)
+ builder.append(", ");
builder.append(parameterTypes[i]);
}
@@ -209,7 +218,8 @@
}
/**
- * Sorting is primarily via method name. For methods with the same name, the second level of sorting is by parameter
+ * Sorting is primarily via method name. For methods with the same name, the second level of
+ * sorting is by parameter
* count (descending).
*/
public int compareTo(TransformMethodSignature o)
@@ -217,15 +227,17 @@
int result = methodName.compareTo(o.methodName);
// Sort descending
- if (result == 0) result = o.parameterTypes.length - parameterTypes.length;
+ if (result == 0)
+ result = o.parameterTypes.length - parameterTypes.length;
return result;
}
/**
- * Returns a shortened form of the string representation of the method. It lists just the name of the method and the
+ * Returns a shortened form of the string representation of the method. It lists just the name
+ * of the method and the
* types of any parameters, omitting return type, exceptions and modifiers.
- *
+ *
* @return
*/
public String getMediumDescription()