You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/05/07 17:41:02 UTC
svn commit: r654153 [3/3] -
/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextImpl.java Wed May 7 08:40:57 2008
@@ -14,8 +14,7 @@
package org.apache.tapestry.internal.services;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newStack;
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
import org.apache.tapestry.ioc.util.Stack;
import org.apache.tapestry.services.Context;
@@ -29,18 +28,18 @@
public class ContextImpl implements Context
{
- private final ServletContext _servletContext;
+ private final ServletContext servletContext;
public ContextImpl(ServletContext servletContext)
{
- _servletContext = servletContext;
+ this.servletContext = servletContext;
}
public URL getResource(String path)
{
try
{
- return _servletContext.getResource(path);
+ return servletContext.getResource(path);
}
catch (MalformedURLException ex)
{
@@ -50,21 +49,21 @@
public File getRealFile(String path)
{
- String realPath = _servletContext.getRealPath(path);
+ String realPath = servletContext.getRealPath(path);
return realPath == null ? null : new File(realPath);
}
public String getInitParameter(String name)
{
- return _servletContext.getInitParameter(name);
+ return servletContext.getInitParameter(name);
}
@SuppressWarnings("unchecked")
public List<String> getResourcePaths(String path)
{
- List<String> result = newList();
- Stack<String> queue = newStack();
+ List<String> result = CollectionFactory.newList();
+ Stack<String> queue = CollectionFactory.newStack();
queue.push(path);
@@ -72,7 +71,7 @@
{
String current = queue.pop();
- Set<String> matches = _servletContext.getResourcePaths(current);
+ Set<String> matches = servletContext.getResourcePaths(current);
// Tomcat 5.5.20 inside JBoss 4.0.2 has been observed to do this!
// Perhaps other servers do as well.
@@ -96,7 +95,7 @@
public Object getAttribute(String name)
{
- return _servletContext.getAttribute(name);
+ return servletContext.getAttribute(name);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextResource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextResource.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextResource.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextResource.java Wed May 7 08:40:57 2008
@@ -30,7 +30,7 @@
{
private static final int PRIME = 37;
- private final Context _context;
+ private final Context context;
public ContextResource(Context context, String path)
{
@@ -38,7 +38,7 @@
notNull(context, "context");
- _context = context;
+ this.context = context;
}
@Override
@@ -50,7 +50,7 @@
@Override
protected Resource newResource(String path)
{
- return new ContextResource(_context, path);
+ return new ContextResource(context, path);
}
public URL toURL()
@@ -64,7 +64,7 @@
// Always prefer the actual file to the URL. This is critical for templates to
// reload inside Tomcat.
- File file = _context.getRealFile(contextPath);
+ File file = context.getRealFile(contextPath);
if (file != null && file.exists())
{
@@ -81,13 +81,13 @@
// But, when packaged inside a WAR or JAR, the File will not be available, so use whatever
// URL we get ... but reloading won't work.
- return _context.getResource(contextPath);
+ return context.getResource(contextPath);
}
@Override
public int hashCode()
{
- return PRIME * _context.hashCode() + getPath().hashCode();
+ return PRIME * context.hashCode() + getPath().hashCode();
}
@Override
@@ -99,7 +99,7 @@
final ContextResource other = (ContextResource) obj;
- return _context == other._context && getPath().equals(other.getPath());
+ return context == other.context && getPath().equals(other.getPath());
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextValueEncoderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextValueEncoderImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextValueEncoderImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ContextValueEncoderImpl.java Wed May 7 08:40:57 2008
@@ -21,18 +21,18 @@
public class ContextValueEncoderImpl implements ContextValueEncoder
{
- private final ValueEncoderSource _valueEncoderSource;
+ private final ValueEncoderSource valueEncoderSource;
public ContextValueEncoderImpl(ValueEncoderSource valueEncoderSource)
{
- _valueEncoderSource = valueEncoderSource;
+ this.valueEncoderSource = valueEncoderSource;
}
public String toClient(Object value)
{
Defense.notNull(value, "value");
- ValueEncoder encoder = _valueEncoderSource.getValueEncoder(value.getClass());
+ ValueEncoder encoder = valueEncoderSource.getValueEncoder(value.getClass());
return encoder.toClient(value);
}
@@ -42,7 +42,7 @@
{
Defense.notNull(requiredType, "requiredType");
- ValueEncoder<T> encoder = _valueEncoderSource.getValueEncoder(requiredType);
+ ValueEncoder<T> encoder = valueEncoderSource.getValueEncoder(requiredType);
return encoder.toValue(clientValue);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CookiesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CookiesImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CookiesImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/CookiesImpl.java Wed May 7 08:40:57 2008
@@ -27,13 +27,13 @@
*/
public class CookiesImpl implements Cookies
{
- private final Request _request;
+ private final Request request;
- private final CookieSource _cookieSource;
+ private final CookieSource cookieSource;
- private final CookieSink _cookieSink;
+ private final CookieSink cookieSink;
- private final int _defaultMaxAge;
+ private final int defaultMaxAge;
/**
* @param request
@@ -50,15 +50,15 @@
@Symbol("tapestry.default-cookie-max-age") @IntermediateType(TimeInterval.class)
long defaultMaxAge)
{
- _request = request;
- _cookieSource = cookieSource;
- _cookieSink = cookieSink;
- _defaultMaxAge = (int) (defaultMaxAge / 1000l);
+ this.request = request;
+ this.cookieSource = cookieSource;
+ this.cookieSink = cookieSink;
+ this.defaultMaxAge = (int) (defaultMaxAge / 1000l);
}
public String readCookieValue(String name)
{
- Cookie[] cookies = _cookieSource.getCookies();
+ Cookie[] cookies = cookieSource.getCookies();
if (cookies == null) return null;
@@ -72,16 +72,16 @@
public void writeCookieValue(String name, String value)
{
- writeCookieValue(name, value, _defaultMaxAge);
+ writeCookieValue(name, value, defaultMaxAge);
}
public void writeCookieValue(String name, String value, int maxAge)
{
Cookie cookie = new Cookie(name, value);
- cookie.setPath(_request.getContextPath() + "/");
+ cookie.setPath(request.getContextPath() + "/");
cookie.setMaxAge(maxAge);
- _cookieSink.addCookie(cookie);
+ cookieSink.addCookie(cookie);
}
public void writeCookieValue(String name, String value, String path)
@@ -89,26 +89,26 @@
Cookie cookie = new Cookie(name, value);
cookie.setPath(path);
- _cookieSink.addCookie(cookie);
+ cookieSink.addCookie(cookie);
}
public void writeDomainCookieValue(String name, String value, String domain)
{
Cookie cookie = new Cookie(name, value);
- cookie.setPath(_request.getContextPath() + "/");
+ cookie.setPath(request.getContextPath() + "/");
cookie.setDomain(domain);
- _cookieSink.addCookie(cookie);
+ cookieSink.addCookie(cookie);
}
public void writeDomainCookieValue(String name, String value, String domain, int maxAge)
{
Cookie cookie = new Cookie(name, value);
- cookie.setPath(_request.getContextPath() + "/");
+ cookie.setPath(request.getContextPath() + "/");
cookie.setDomain(domain);
cookie.setMaxAge(maxAge);
- _cookieSink.addCookie(cookie);
+ cookieSink.addCookie(cookie);
}
public void writeCookieValue(String name, String value, String path, String domain)
@@ -117,16 +117,16 @@
cookie.setPath(path);
cookie.setDomain(domain);
- _cookieSink.addCookie(cookie);
+ cookieSink.addCookie(cookie);
}
public void removeCookieValue(String name)
{
Cookie cookie = new Cookie(name, null);
- cookie.setPath(_request.getContextPath() + "/");
+ cookie.setPath(request.getContextPath() + "/");
cookie.setMaxAge(0);
- _cookieSink.addCookie(cookie);
+ cookieSink.addCookie(cookie);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultDataTypeAnalyzer.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultDataTypeAnalyzer.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultDataTypeAnalyzer.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultDataTypeAnalyzer.java Wed May 7 08:40:57 2008
@@ -28,11 +28,11 @@
*/
public class DefaultDataTypeAnalyzer implements DataTypeAnalyzer, InvalidationListener
{
- private final StrategyRegistry<String> _registry;
+ private final StrategyRegistry<String> registry;
public DefaultDataTypeAnalyzer(Map<Class, String> configuration)
{
- _registry = StrategyRegistry.newInstance(String.class, configuration);
+ registry = StrategyRegistry.newInstance(String.class, configuration);
}
/**
@@ -41,14 +41,14 @@
*/
public void objectWasInvalidated()
{
- _registry.clearCache();
+ registry.clearCache();
}
public String identifyDataType(PropertyAdapter adapter)
{
Class propertyType = adapter.getType();
- String dataType = _registry.get(propertyType);
+ String dataType = registry.get(propertyType);
// To avoid "no strategy" exceptions, we expect a contribution of Object.class to the empty
// string. We convert that back to a null.
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultInjectionProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultInjectionProvider.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultInjectionProvider.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultInjectionProvider.java Wed May 7 08:40:57 2008
@@ -33,14 +33,14 @@
*/
public class DefaultInjectionProvider implements InjectionProvider
{
- private final MasterObjectProvider _masterObjectProvider;
+ private final MasterObjectProvider masterObjectProvider;
- private final ObjectLocator _locator;
+ private final ObjectLocator locator;
public DefaultInjectionProvider(MasterObjectProvider masterObjectProvider, ObjectLocator locator)
{
- _masterObjectProvider = masterObjectProvider;
- _locator = locator;
+ this.masterObjectProvider = masterObjectProvider;
+ this.locator = locator;
}
@SuppressWarnings("unchecked")
@@ -55,7 +55,7 @@
}
};
- Object inject = _masterObjectProvider.provide(fieldType, annotationProvider, _locator, false);
+ Object inject = masterObjectProvider.provide(fieldType, annotationProvider, this.locator, false);
// Null means that no ObjectProvider could provide the value. We have set up the chain of
// command so that InjectResources can give it a try next. Later, we'll try to match against
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultRequestExceptionHandler.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultRequestExceptionHandler.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultRequestExceptionHandler.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DefaultRequestExceptionHandler.java Wed May 7 08:40:57 2008
@@ -27,24 +27,24 @@
*/
public class DefaultRequestExceptionHandler implements RequestExceptionHandler
{
- private final RequestPageCache _pageCache;
+ private final RequestPageCache pageCache;
- private final PageResponseRenderer _renderer;
+ private final PageResponseRenderer renderer;
- private final Logger _logger;
+ private final Logger logger;
public DefaultRequestExceptionHandler(RequestPageCache pageCache, PageResponseRenderer renderer, Logger logger)
{
- _pageCache = pageCache;
- _renderer = renderer;
- _logger = logger;
+ this.pageCache = pageCache;
+ this.renderer = renderer;
+ this.logger = logger;
}
public void handleRequestException(Throwable exception) throws IOException
{
- _logger.error(ServicesMessages.requestException(exception), exception);
+ logger.error(ServicesMessages.requestException(exception), exception);
- Page page = _pageCache.get("ExceptionReport");
+ Page page = pageCache.get("ExceptionReport");
ExceptionReporter rootComponent = (ExceptionReporter) page.getRootComponent();
@@ -52,6 +52,6 @@
rootComponent.reportException(exception);
- _renderer.renderPageResponse(page);
+ renderer.renderPageResponse(page);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DocumentLinkerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DocumentLinkerImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DocumentLinkerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/DocumentLinkerImpl.java Wed May 7 08:40:57 2008
@@ -16,8 +16,7 @@
import org.apache.tapestry.dom.Document;
import org.apache.tapestry.dom.Element;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newSet;
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
import org.apache.tapestry.ioc.internal.util.InternalUtils;
import java.util.List;
@@ -25,19 +24,19 @@
public class DocumentLinkerImpl implements DocumentLinker
{
- private final List<String> _scripts = newList();
+ private final List<String> scripts = CollectionFactory.newList();
- private final StringBuilder _scriptBlock = new StringBuilder();
+ private final StringBuilder scriptBlock = new StringBuilder();
- private final Set<String> _stylesheets = newSet();
+ private final Set<String> stylesheets = CollectionFactory.newSet();
- private final List<IncludedStylesheet> _includedStylesheets = newList();
+ private final List<IncludedStylesheet> includedStylesheets = CollectionFactory.newList();
- private final boolean _developmentMode;
+ private final boolean developmentMode;
public DocumentLinkerImpl(boolean productionMode)
{
- _developmentMode = !productionMode;
+ developmentMode = !productionMode;
}
private class IncludedStylesheet
@@ -68,26 +67,26 @@
public void addStylesheetLink(String styleURL, String media)
{
- if (_stylesheets.contains(styleURL)) return;
+ if (stylesheets.contains(styleURL)) return;
- _includedStylesheets.add(new IncludedStylesheet(styleURL, media));
+ includedStylesheets.add(new IncludedStylesheet(styleURL, media));
- _stylesheets.add(styleURL);
+ stylesheets.add(styleURL);
}
public void addScriptLink(String scriptURL)
{
- if (_scripts.contains(scriptURL)) return;
+ if (scripts.contains(scriptURL)) return;
- _scripts.add(scriptURL);
+ scripts.add(scriptURL);
}
public void addScript(String script)
{
if (InternalUtils.isBlank(script)) return;
- _scriptBlock.append(script);
- _scriptBlock.append("\n");
+ scriptBlock.append(script);
+ scriptBlock.append("\n");
}
/**
@@ -109,7 +108,7 @@
if (!root.getName().equals("html")) return;
- int stylesheets = _includedStylesheets.size();
+ int stylesheets = includedStylesheets.size();
if (stylesheets > 0)
{
@@ -118,7 +117,7 @@
if (head == null) head = root.elementAt(0, "head");
for (int i = 0; i < stylesheets; i++)
- _includedStylesheets.get(i).add(head, i);
+ includedStylesheets.get(i).add(head, i);
}
Element body = root.find("body");
@@ -128,24 +127,24 @@
// TAPESTRY-2364
- for (String scriptURL : _scripts)
+ for (String scriptURL : scripts)
{
body.element("script", "src", scriptURL, "type", "text/javascript");
}
- boolean blockNeeded = (_developmentMode && !_scripts.isEmpty()) || _scriptBlock.length() > 0;
+ boolean blockNeeded = (developmentMode && !scripts.isEmpty()) || scriptBlock.length() > 0;
if (blockNeeded)
{
Element e = body.element("script", "type", "text/javascript");
e.raw("\n<!--\n");
- if (_developmentMode)
+ if (developmentMode)
e.text("Tapestry.DEBUG_ENABLED = true;\n");
e.text("Tapestry.onDOMLoaded(function() {\n");
- e.text(_scriptBlock.toString());
+ e.text(scriptBlock.toString());
e.text("});\n");
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EnvironmentImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EnvironmentImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EnvironmentImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EnvironmentImpl.java Wed May 7 08:40:57 2008
@@ -18,7 +18,6 @@
import org.apache.tapestry.ioc.annotations.Scope;
import org.apache.tapestry.ioc.internal.util.CollectionFactory;
import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newLinkedList;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
import org.apache.tapestry.services.Environment;
import java.util.LinkedList;
@@ -34,17 +33,17 @@
// My generics mojo breaks down when we talk about the key and the value being related
// types.
- private final Map<Class, LinkedList> _stacks = newMap();
+ private final Map<Class, LinkedList> stacks = CollectionFactory.newMap();
@SuppressWarnings("unchecked")
private <T> LinkedList<T> stackFor(Class<T> type)
{
- LinkedList<T> result = _stacks.get(type);
+ LinkedList<T> result = stacks.get(type);
if (result == null)
{
result = newLinkedList();
- _stacks.put(type, result);
+ stacks.put(type, result);
}
return result;
@@ -64,7 +63,7 @@
if (result == null)
{
List<Class> types = CollectionFactory.newList();
- for (Map.Entry<Class, LinkedList> e : _stacks.entrySet())
+ for (Map.Entry<Class, LinkedList> e : stacks.entrySet())
{
LinkedList list = e.getValue();
@@ -97,6 +96,6 @@
public void clear()
{
- _stacks.clear();
+ stacks.clear();
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EnvironmentalShadowBuilderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EnvironmentalShadowBuilderImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EnvironmentalShadowBuilderImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EnvironmentalShadowBuilderImpl.java Wed May 7 08:40:57 2008
@@ -21,15 +21,14 @@
import org.apache.tapestry.services.Environment;
import org.apache.tapestry.services.EnvironmentalShadowBuilder;
-import static java.lang.String.format;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
public class EnvironmentalShadowBuilderImpl implements EnvironmentalShadowBuilder
{
- private final ClassFactory _classFactory;
+ private final ClassFactory classFactory;
- private final Environment _environment;
+ private final Environment environment;
/**
* Construct using the default builtin factory, not the component layer version.
@@ -38,8 +37,8 @@
Environment environment)
{
- _classFactory = classFactory;
- _environment = environment;
+ this.classFactory = classFactory;
+ this.environment = environment;
}
public <T> T build(Class<T> serviceType)
@@ -52,7 +51,7 @@
{
Constructor cons = proxyClass.getConstructors()[0];
- Object raw = cons.newInstance(_environment, serviceType);
+ Object raw = cons.newInstance(environment, serviceType);
return serviceType.cast(raw);
}
@@ -64,19 +63,19 @@
private Class buildProxyClass(Class serviceType)
{
- ClassFab classFab = _classFactory.newClass(serviceType);
+ ClassFab classFab = classFactory.newClass(serviceType);
- classFab.addField("_environment", Environment.class);
+ classFab.addField("environment", Environment.class);
classFab.addField("_serviceType", Class.class);
classFab.addConstructor(new Class[] { Environment.class, Class.class }, null,
- "{ _environment = $1; _serviceType = $2; }");
+ "{ environment = $1; _serviceType = $2; }");
classFab.addMethod(Modifier.PRIVATE, new MethodSignature(serviceType, "_delegate", null, null),
- "return ($r) _environment.peekRequired(_serviceType); ");
+ "return ($r) environment.peekRequired(_serviceType); ");
classFab.proxyMethodsToDelegate(serviceType, "_delegate()",
- format("<EnvironmentalProxy for %s>", serviceType.getName()));
+ String.format("<EnvironmentalProxy for %s>", serviceType.getName()));
return classFab.createClass();
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EventImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EventImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EventImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/EventImpl.java Wed May 7 08:40:57 2008
@@ -20,25 +20,25 @@
public class EventImpl implements Event
{
- private boolean _aborted;
+ private boolean aborted;
- private String _methodDescription;
+ private String methodDescription;
- private final ComponentEventCallback _handler;
+ private final ComponentEventCallback handler;
public EventImpl(ComponentEventCallback handler)
{
- _handler = notNull(handler, "handler");
+ this.handler = notNull(handler, "handler");
}
public boolean isAborted()
{
- return _aborted;
+ return aborted;
}
public void setMethodDescription(String methodDescription)
{
- _methodDescription = methodDescription;
+ this.methodDescription = methodDescription;
}
@SuppressWarnings("unchecked")
@@ -49,17 +49,17 @@
// this should never, ever happen. But what the hell,
// let's check anyway.
- if (_aborted) throw new IllegalStateException(ServicesMessages
- .componentEventIsAborted(_methodDescription));
+ if (aborted) throw new IllegalStateException(ServicesMessages
+ .componentEventIsAborted(methodDescription));
- if (result != null) _aborted |= _handler.handleResult(result);
+ if (result != null) aborted |= handler.handleResult(result);
- return _aborted;
+ return aborted;
}
protected String getMethodDescription()
{
- return _methodDescription;
+ return methodDescription;
}
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidationSupportImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidationSupportImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidationSupportImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidationSupportImpl.java Wed May 7 08:40:57 2008
@@ -30,13 +30,13 @@
static final String TO_CLIENT_EVENT = "toClient";
static final String VALIDATE_EVENT = "validate";
- private final ValidationMessagesSource _messagesSource;
+ private final ValidationMessagesSource messagesSource;
private final TypeCoercer _typeCoercer;
public FieldValidationSupportImpl(ValidationMessagesSource messagesSource, TypeCoercer typeCoercer)
{
- _messagesSource = messagesSource;
+ this.messagesSource = messagesSource;
_typeCoercer = typeCoercer;
}
@@ -131,7 +131,7 @@
// Otherwise, let the normal translator do the job.
- Messages messages = _messagesSource.getValidationMessages(componentResources.getLocale());
+ Messages messages = messagesSource.getValidationMessages(componentResources.getLocale());
return translator.parseClient(effectiveValue, messages);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorDefaultSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorDefaultSourceImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorDefaultSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorDefaultSourceImpl.java Wed May 7 08:40:57 2008
@@ -28,16 +28,16 @@
public class FieldValidatorDefaultSourceImpl implements FieldValidatorDefaultSource
{
- private final ValidationConstraintGenerator _validationConstraintGenerator;
+ private final ValidationConstraintGenerator validationConstraintGenerator;
- private final FieldValidatorSource _fieldValidatorSource;
+ private final FieldValidatorSource fieldValidatorSource;
public FieldValidatorDefaultSourceImpl(
ValidationConstraintGenerator validationConstraintGenerator,
FieldValidatorSource fieldValidatorSource)
{
- _validationConstraintGenerator = validationConstraintGenerator;
- _fieldValidatorSource = fieldValidatorSource;
+ this.validationConstraintGenerator = validationConstraintGenerator;
+ this.fieldValidatorSource = fieldValidatorSource;
}
public FieldValidator createDefaultValidator(Field field, String overrideId,
@@ -46,7 +46,7 @@
{
List<FieldValidator> validators = newList();
- for (String constraint : _validationConstraintGenerator.buildConstraints(
+ for (String constraint : validationConstraintGenerator.buildConstraints(
propertyType,
propertyAnnotations))
{
@@ -55,7 +55,7 @@
String validatorType = equalsx > 0 ? constraint.substring(0, equalsx) : constraint;
String constraintValue = equalsx > 0 ? constraint.substring(equalsx + 1) : null;
- FieldValidator validator = _fieldValidatorSource.createValidator(
+ FieldValidator validator = fieldValidatorSource.createValidator(
field,
validatorType,
constraintValue,
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorImpl.java Wed May 7 08:40:57 2008
@@ -20,45 +20,45 @@
public class FieldValidatorImpl implements FieldValidator
{
- private final Field _field;
+ private final Field field;
- private final Object _constraintValue;
+ private final Object constraintValue;
- private final MessageFormatter _messageFormatter;
+ private final MessageFormatter messageFormatter;
- private final Validator _validator;
+ private final Validator validator;
- private final FormSupport _formSupport;
+ private final FormSupport formSupport;
public FieldValidatorImpl(Field field, Object constraintValue, MessageFormatter messageFormatter,
Validator validator, FormSupport formSupport)
{
- _field = field;
- _constraintValue = constraintValue;
- _messageFormatter = messageFormatter;
- _validator = validator;
- _formSupport = formSupport;
+ this.field = field;
+ this.constraintValue = constraintValue;
+ this.messageFormatter = messageFormatter;
+ this.validator = validator;
+ this.formSupport = formSupport;
}
@SuppressWarnings("unchecked")
public void validate(Object value) throws ValidationException
{
- if (!_validator.isRequired() && isBlank(value)) return;
+ if (!validator.isRequired() && isBlank(value)) return;
- if (value != null && !_validator.getValueType().isInstance(value)) return;
+ if (value != null && !validator.getValueType().isInstance(value)) return;
- _validator.validate(_field, _constraintValue, _messageFormatter, value);
+ validator.validate(field, constraintValue, messageFormatter, value);
}
@SuppressWarnings("unchecked")
public void render(MarkupWriter writer)
{
- _validator.render(_field, _constraintValue, _messageFormatter, writer, _formSupport);
+ validator.render(field, constraintValue, messageFormatter, writer, formSupport);
}
public boolean isRequired()
{
- return _validator.isRequired();
+ return validator.isRequired();
}
private boolean isBlank(Object value)
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorSourceImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/FieldValidatorSourceImpl.java Wed May 7 08:40:57 2008
@@ -36,21 +36,21 @@
public class FieldValidatorSourceImpl implements FieldValidatorSource
{
- private final ValidationMessagesSource _messagesSource;
+ private final ValidationMessagesSource messagesSource;
- private final Map<String, Validator> _validators;
+ private final Map<String, Validator> validators;
- private final TypeCoercer _typeCoercer;
+ private final TypeCoercer typeCoercer;
- private final FormSupport _formSupport;
+ private final FormSupport formSupport;
public FieldValidatorSourceImpl(ValidationMessagesSource messagesSource, TypeCoercer typeCoercer,
FormSupport formSupport, Map<String, Validator> validators)
{
- _messagesSource = messagesSource;
- _typeCoercer = typeCoercer;
- _formSupport = formSupport;
- _validators = validators;
+ this.messagesSource = messagesSource;
+ this.typeCoercer = typeCoercer;
+ this.formSupport = formSupport;
+ this.validators = validators;
}
public FieldValidator createValidator(Field field, String validatorType, String constraintValue)
@@ -75,10 +75,10 @@
{
notBlank(validatorType, "validatorType");
- Validator validator = _validators.get(validatorType);
+ Validator validator = validators.get(validatorType);
if (validator == null) throw new IllegalArgumentException(
- ServicesMessages.unknownValidatorType(validatorType, InternalUtils.sortedKeys(_validators)));
+ ServicesMessages.unknownValidatorType(validatorType, InternalUtils.sortedKeys(validators)));
// I just have this thing about always treating parameters as finals, so
// we introduce a second variable to treat a mutable.
@@ -103,7 +103,7 @@
MessageFormatter formatter = findMessageFormatter(overrideId, overrideMessages, locale, validatorType,
validator);
- return new FieldValidatorImpl(field, coercedConstraintValue, formatter, validator, _formSupport);
+ return new FieldValidatorImpl(field, coercedConstraintValue, formatter, validator, formSupport);
}
private MessageFormatter findMessageFormatter(String overrideId, Messages overrideMessages, Locale locale,
@@ -114,7 +114,7 @@
if (overrideMessages.contains(overrideKey)) return overrideMessages.getFormatter(overrideKey);
- Messages messages = _messagesSource.getValidationMessages(locale);
+ Messages messages = messagesSource.getValidationMessages(locale);
String key = validator.getMessageKey();
@@ -143,7 +143,7 @@
{
if (constraintType == null) return null;
- return _typeCoercer.coerce(constraintValue, constraintType);
+ return typeCoercer.coerce(constraintValue, constraintType);
}
/**
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformation.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformation.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformation.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformation.java Wed May 7 08:40:57 2008
@@ -53,7 +53,7 @@
/**
* Returns a copy of the list of constructor arguments for this class.
*/
- List<ConstructorArg> getConstructorArgs();
+ List<InternalClassTransformationImpl.ConstructorArg> getConstructorArgs();
/**
* Searchs for an existing injection of an object, returning the name of the protected field into which the value
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java Wed May 7 08:40:57 2008
@@ -131,6 +131,29 @@
null);
/**
+ * Stores transformation type data about one argument to a class constructor.
+ */
+ static class ConstructorArg
+ {
+ private final CtClass type;
+
+ private final Object value;
+
+ /**
+ * Constructs new instance.
+ *
+ * @param type type of the parameter to be created (may not be null)
+ * @param value value to be injected via the constructor (may be null)
+ */
+ ConstructorArg(CtClass type, Object value)
+ {
+ this.type = Defense.notNull(type, "type");
+ this.value = value;
+ }
+
+ }
+
+ /**
* This is a constructor for a base class.
*/
public InternalClassTransformationImpl(ClassFactory classFactory, CtClass ctClass,
@@ -1302,7 +1325,7 @@
{
ConstructorArg arg = _constructorArgs.get(i);
- types[i] = arg.getType();
+ types[i] = arg.type;
}
// Add a call to the initializer; the method converted fromt the classes default
@@ -1380,7 +1403,7 @@
{
ConstructorArg arg = _constructorArgs.get(i);
- CtClass argCtType = arg.getType();
+ CtClass argCtType = arg.type;
Class argType = toClass(argCtType.getName());
boolean primitive = argCtType.isPrimitive();
@@ -1390,7 +1413,7 @@
String fieldName = "_param_" + i;
constructorParameterTypes[i + 1] = argType;
- constructorParameterValues[i + 1] = arg.getValue();
+ constructorParameterValues[i + 1] = arg.value;
cf.addField(fieldName, fieldType);
@@ -1720,4 +1743,5 @@
{
return _parentTransformation == null;
}
+
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PagePoolCache.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PagePoolCache.java?rev=654153&r1=654152&r2=654153&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PagePoolCache.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/PagePoolCache.java Wed May 7 08:40:57 2008
@@ -42,19 +42,19 @@
*/
final class PagePoolCache
{
- private final String _pageName;
+ private final String pageName;
- private final Locale _locale;
+ private final Locale locale;
- private final int _softLimit;
+ private final int softLimit;
- private final long _softWait;
+ private final long softWait;
- private final int _hardLimit;
+ private final int hardLimit;
- private final long _activeWindow;
+ private final long activeWindow;
- private final PageLoader _pageLoader;
+ private final PageLoader pageLoader;
/**
* Pages that are available for use.
@@ -78,6 +78,28 @@
private final Condition _pageAvailable = _lock.newCondition();
/**
+ * Tracks the usage of a page instance, allowing a last access property to be associated with the page. CachedPage
+ * instances are only accessed from within a {@link org.apache.tapestry.internal.services.PagePoolCache}, which
+ * handles synchronization concerns.
+ * <p/>
+ * An earlier version of this code used <em>soft references</em>, but those seem to be problematic (the test suite
+ * started behaving erratically and response time suffered). Perhaps that could be addressed via tuning of the VM,
+ * but for the meantime, we use hard references and rely more on the soft and hard limits and the culling of unused
+ * pages periodically.
+ */
+ static class CachedPage
+ {
+ private final Page page;
+
+ private long lastAccess;
+
+ CachedPage(Page page)
+ {
+ this.page = page;
+ }
+ }
+
+ /**
* @param pageName logical name of page, needed when creating a fresh instance
* @param locale locale of the page, needed when creating a fresh instance
* @param pageLoader used to create a fresh page instance, if necessary
@@ -90,13 +112,13 @@
public PagePoolCache(String pageName, Locale locale, PageLoader pageLoader, int softLimit, long softWait,
int hardLimit, long activeWindow)
{
- _pageName = pageName;
- _locale = locale;
- _pageLoader = pageLoader;
- _softLimit = softLimit;
- _softWait = softWait;
- _hardLimit = hardLimit;
- _activeWindow = activeWindow;
+ this.pageName = pageName;
+ this.locale = locale;
+ this.pageLoader = pageLoader;
+ this.softLimit = softLimit;
+ this.softWait = softWait;
+ this.hardLimit = hardLimit;
+ this.activeWindow = activeWindow;
}
/**
@@ -139,12 +161,12 @@
// which is largely accurate as long as there haven't been a lot
// of request exceptions. We'll take the count at face value.
- if (_inUse.size() < _softLimit) break;
+ if (_inUse.size() < softLimit) break;
// We'll wait for pages to be available, but careful that the
// total wait period is less than the soft wait limit.
- long waitMillis = (start + _softWait) - System.currentTimeMillis();
+ long waitMillis = (start + softWait) - System.currentTimeMillis();
// We've run out of time to wait.
@@ -173,8 +195,8 @@
// If past the hard limit, we don't try to create the page fresh.
- if (_inUse.size() >= _hardLimit)
- throw new RuntimeException(ServicesMessages.pagePoolExausted(_pageName, _locale, _hardLimit));
+ if (_inUse.size() >= hardLimit)
+ throw new RuntimeException(ServicesMessages.pagePoolExausted(pageName, locale, hardLimit));
}
finally
{
@@ -185,7 +207,7 @@
// That does mean that we may slip over a hard or soft limit momentarily, if
// just the right race condition occurs.
- Page page = _pageLoader.loadPage(_pageName, _locale);
+ Page page = pageLoader.loadPage(pageName, locale);
_lock.lock();
@@ -204,8 +226,8 @@
/**
* Finds and returns the first available page.
* <p/>
- * Side effect: removes the {@link org.apache.tapestry.internal.services.CachedPage} from the available list and
- * moves it to the in use list.
+ * Side effect: removes the {@link org.apache.tapestry.internal.services.PagePoolCache.CachedPage} from the
+ * available list and moves it to the in use list.
*
* @return the page, if any found, or null if no page is available
*/
@@ -218,7 +240,7 @@
_inUse.addFirst(cachedPage);
- return cachedPage.get();
+ return cachedPage.page;
}
/**
@@ -238,7 +260,7 @@
{
cached = i.next();
- if (cached.get() == page)
+ if (cached.page == page)
{
i.remove();
break;
@@ -256,7 +278,7 @@
if (cached == null) return;
- cached.setLastAccess(System.currentTimeMillis());
+ cached.lastAccess = System.currentTimeMillis();
_available.addFirst(cached);
@@ -285,7 +307,7 @@
{
CachedPage cached = i.next();
- if (cached.get() == page)
+ if (cached.page == page)
{
i.remove();
@@ -305,7 +327,7 @@
*/
void cleanup()
{
- long cutoff = System.currentTimeMillis() - _activeWindow;
+ long cutoff = System.currentTimeMillis() - activeWindow;
_lock.lock();
@@ -318,7 +340,7 @@
{
CachedPage cached = i.next();
- if (cached.getLastAccess() < cutoff) i.remove();
+ if (cached.lastAccess < cutoff) i.remove();
}
}
finally
@@ -327,4 +349,5 @@
}
}
+
}