Format changes only. Applied new auto-formatter in prep for real changes.
Review at http://gwt-code-reviews.appspot.com/1370807
Review by: rjrjr@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9822 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/requestfactory/server/LocatorServiceLayer.java b/user/src/com/google/gwt/requestfactory/server/LocatorServiceLayer.java
index d5efc04..5539d29 100644
--- a/user/src/com/google/gwt/requestfactory/server/LocatorServiceLayer.java
+++ b/user/src/com/google/gwt/requestfactory/server/LocatorServiceLayer.java
@@ -1,12 +1,12 @@
/*
* Copyright 2010 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -49,8 +49,8 @@
@Override
public Object createServiceInstance(Method contextMethod, Method domainMethod) {
- Class<? extends ServiceLocator> locatorType = getTop().resolveServiceLocator(
- contextMethod, domainMethod);
+ Class<? extends ServiceLocator> locatorType =
+ getTop().resolveServiceLocator(contextMethod, domainMethod);
ServiceLocator locator = newInstance(locatorType, ServiceLocator.class);
return locator.getInstance(domainMethod.getDeclaringClass());
}
@@ -89,8 +89,7 @@
* method is non-static.
*/
@Override
- public boolean requiresServiceLocator(Method contextMethod,
- Method domainMethod) {
+ public boolean requiresServiceLocator(Method contextMethod, Method domainMethod) {
return Request.class.isAssignableFrom(contextMethod.getReturnType())
&& !Modifier.isStatic(domainMethod.getModifiers());
}
@@ -98,8 +97,7 @@
@Override
public Class<? extends Locator<?, ?>> resolveLocator(Class<?> domainType) {
// Find the matching BaseProxy
- Class<?> proxyType = getTop().resolveClientType(domainType,
- BaseProxy.class, false);
+ Class<?> proxyType = getTop().resolveClientType(domainType, BaseProxy.class, false);
if (proxyType == null) {
return null;
}
@@ -116,13 +114,10 @@
try {
@SuppressWarnings("unchecked")
Class<? extends Locator<?, ?>> found = (Class<? extends Locator<?, ?>>) Class.forName(
- ln.locator(), false, domainType.getClassLoader()).asSubclass(
- Locator.class);
+ ln.locator(), false, domainType.getClassLoader()).asSubclass(Locator.class);
locatorType = found;
} catch (ClassNotFoundException e) {
- return die(
- e,
- "Could not find the locator type specified in the @%s annotation %s",
+ return die(e, "Could not find the locator type specified in the @%s annotation %s",
ProxyForName.class.getCanonicalName(), ln.value());
}
} else {
@@ -145,13 +140,11 @@
locatorType = l.locator();
} else if (ln != null && ln.locator().length() > 0) {
try {
- locatorType = Class.forName(ln.locator(), false,
- requestContextClass.getClassLoader()).asSubclass(
- ServiceLocator.class);
+ locatorType =
+ Class.forName(ln.locator(), false, requestContextClass.getClassLoader()).asSubclass(
+ ServiceLocator.class);
} catch (ClassNotFoundException e) {
- return die(
- e,
- "Could not find the locator type specified in the @%s annotation %s",
+ return die(e, "Could not find the locator type specified in the @%s annotation %s",
ServiceName.class.getCanonicalName(), ln.value());
}
} else {
@@ -202,8 +195,7 @@
@SuppressWarnings("unchecked")
private <T, I> Locator<T, I> getLocator(Class<T> domainType) {
- Class<? extends Locator<?, ?>> locatorType = getTop().resolveLocator(
- domainType);
+ Class<? extends Locator<?, ?>> locatorType = getTop().resolveLocator(domainType);
if (locatorType == null) {
return null;
}
@@ -219,8 +211,7 @@
} catch (IllegalAccessException e) {
ex = e;
}
- return this.<T> die(ex,
- "Could not instantiate %s %s. Is it default-instantiable?",
+ return this.<T> die(ex, "Could not instantiate %s %s. Is it default-instantiable?",
base.getSimpleName(), clazz.getCanonicalName());
}
}
diff --git a/user/src/com/google/gwt/requestfactory/server/ResolverServiceLayer.java b/user/src/com/google/gwt/requestfactory/server/ResolverServiceLayer.java
index aafbe52..12eb799 100644
--- a/user/src/com/google/gwt/requestfactory/server/ResolverServiceLayer.java
+++ b/user/src/com/google/gwt/requestfactory/server/ResolverServiceLayer.java
@@ -1,12 +1,12 @@
/*
* Copyright 2010 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -43,37 +43,34 @@
* can use a shared validator. The use of the validator should be
* synchronized, since it is stateful.
*/
- private static final RequestFactoryInterfaceValidator validator = new RequestFactoryInterfaceValidator(
- log, new RequestFactoryInterfaceValidator.ClassLoaderLoader(
- ServiceLayer.class.getClassLoader()));
+ private static final RequestFactoryInterfaceValidator validator =
+ new RequestFactoryInterfaceValidator(log,
+ new RequestFactoryInterfaceValidator.ClassLoaderLoader(
+ ServiceLayer.class.getClassLoader()));
@Override
public Class<? extends BaseProxy> resolveClass(String typeToken) {
Class<?> found = forName(typeToken);
- if (!EntityProxy.class.isAssignableFrom(found)
- && !ValueProxy.class.isAssignableFrom(found)) {
- die(null, "The requested type %s is not assignable to %s or %s",
- typeToken, EntityProxy.class.getCanonicalName(),
- ValueProxy.class.getCanonicalName());
+ if (!EntityProxy.class.isAssignableFrom(found) && !ValueProxy.class.isAssignableFrom(found)) {
+ die(null, "The requested type %s is not assignable to %s or %s", typeToken,
+ EntityProxy.class.getCanonicalName(), ValueProxy.class.getCanonicalName());
}
synchronized (validator) {
validator.antidote();
validator.validateProxy(found.getName());
if (validator.isPoisoned()) {
- die(null, "The type %s did not pass RequestFactory validation",
- found.getCanonicalName());
+ die(null, "The type %s did not pass RequestFactory validation", found.getCanonicalName());
}
}
return found.asSubclass(BaseProxy.class);
}
@Override
- public <T> Class<? extends T> resolveClientType(Class<?> domainClass,
- Class<T> clientClass, boolean required) {
+ public <T> Class<? extends T> resolveClientType(
+ Class<?> domainClass, Class<T> clientClass, boolean required) {
String name;
synchronized (validator) {
- name = validator.getEntityProxyTypeName(domainClass.getName(),
- clientClass.getName());
+ name = validator.getEntityProxyTypeName(domainClass.getName(), clientClass.getName());
}
if (name != null) {
return forName(name).asSubclass(clientClass);
@@ -88,8 +85,7 @@
return domainClass.asSubclass(clientClass);
}
if (required) {
- die(null, "The domain type %s cannot be sent to the client",
- domainClass.getCanonicalName());
+ die(null, "The domain type %s cannot be sent to the client", domainClass.getCanonicalName());
}
return null;
}
@@ -111,8 +107,8 @@
return toReturn;
}
}
- return die(null, "Could not resolve a domain type for client type %s",
- clazz.getCanonicalName());
+ return die(
+ null, "Could not resolve a domain type for client type %s", clazz.getCanonicalName());
}
@Override
@@ -137,12 +133,10 @@
Class<?>[] domainArgs = new Class<?>[parameterTypes.length];
for (int i = 0, j = domainArgs.length; i < j; i++) {
if (BaseProxy.class.isAssignableFrom(parameterTypes[i])) {
- domainArgs[i] = getTop().resolveDomainClass(
- parameterTypes[i].asSubclass(BaseProxy.class));
+ domainArgs[i] = getTop().resolveDomainClass(parameterTypes[i].asSubclass(BaseProxy.class));
} else if (EntityProxyId.class.isAssignableFrom(parameterTypes[i])) {
domainArgs[i] = TypeUtils.ensureBaseType(TypeUtils.getSingleParameterization(
- EntityProxyId.class,
- requestContextMethod.getGenericParameterTypes()[i]));
+ EntityProxyId.class, requestContextMethod.getGenericParameterTypes()[i]));
} else {
domainArgs[i] = parameterTypes[i];
}
@@ -154,22 +148,19 @@
} catch (SecurityException e) {
ex = e;
} catch (NoSuchMethodException e) {
- return report("Could not locate domain method %s",
- requestContextMethod.getName());
+ return report("Could not locate domain method %s", requestContextMethod.getName());
}
- return die(ex, "Could not get domain method %s in type %s",
- requestContextMethod.getName(), searchIn.getCanonicalName());
+ return die(ex, "Could not get domain method %s in type %s", requestContextMethod.getName(),
+ searchIn.getCanonicalName());
}
@Override
- public Method resolveRequestContextMethod(String requestContextClass,
- String methodName) {
+ public Method resolveRequestContextMethod(String requestContextClass, String methodName) {
synchronized (validator) {
validator.antidote();
validator.validateRequestContext(requestContextClass);
if (validator.isPoisoned()) {
- die(null, "The RequestContext type %s did not pass validation",
- requestContextClass);
+ die(null, "The RequestContext type %s did not pass validation", requestContextClass);
}
}
Class<?> searchIn = forName(requestContextClass);
@@ -178,8 +169,8 @@
return method;
}
}
- return report("Could not locate %s method %s::%s",
- RequestContext.class.getSimpleName(), requestContextClass, methodName);
+ return report("Could not locate %s method %s::%s", RequestContext.class.getSimpleName(),
+ requestContextClass, methodName);
}
@Override
@@ -193,8 +184,7 @@
*/
private Class<?> forName(String name) {
try {
- return Class.forName(name, false,
- Thread.currentThread().getContextClassLoader());
+ return Class.forName(name, false, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
return die(e, "Could not locate class %s", name);
}
diff --git a/user/src/com/google/gwt/requestfactory/server/ServiceLayer.java b/user/src/com/google/gwt/requestfactory/server/ServiceLayer.java
index 1c4062a..d7535ca 100644
--- a/user/src/com/google/gwt/requestfactory/server/ServiceLayer.java
+++ b/user/src/com/google/gwt/requestfactory/server/ServiceLayer.java
@@ -1,12 +1,12 @@
/*
* Copyright 2010 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -46,13 +46,13 @@
/**
* Provides a flag to disable the ServiceLayerCache for debugging purposes.
*/
- private static final boolean ENABLE_CACHE = Boolean.valueOf(System.getProperty(
- "gwt.rf.ServiceLayerCache", "true"));
+ private static final boolean ENABLE_CACHE =
+ Boolean.valueOf(System.getProperty("gwt.rf.ServiceLayerCache", "true"));
/**
* Create a RequestFactory ServiceLayer that is optionally modified by the
* given decorators.
- *
+ *
* @param decorators the decorators that will modify the behavior of the core
* service layer implementation
* @return a ServiceLayer instance
@@ -60,8 +60,8 @@
public static ServiceLayer create(ServiceLayerDecorator... decorators) {
List<ServiceLayerDecorator> list = new ArrayList<ServiceLayerDecorator>();
// Always hit the cache first
- ServiceLayerDecorator cache = ENABLE_CACHE ? new ServiceLayerCache()
- : new ServiceLayerDecorator();
+ ServiceLayerDecorator cache =
+ ENABLE_CACHE ? new ServiceLayerCache() : new ServiceLayerDecorator();
list.add(cache);
// The the user-provided decorators
if (decorators != null) {
@@ -100,7 +100,7 @@
/**
* Create an instance of the requested domain type.
- *
+ *
* @param <T> the requested domain type
* @param clazz the requested domain type
* @return an instance of the requested domain type
@@ -109,7 +109,7 @@
/**
* Create an instance of the requested {@link Locator} type.
- *
+ *
* @param <T> the requested Locator type
* @param clazz the requested Locator type
* @return an instance of the requested Locator type
@@ -119,17 +119,16 @@
/**
* Create an instance of a service object that can be used as the target for
* the given method invocation.
- *
+ *
* @param contextMethod a method defined in a RequestContext
* @param domainMethod the method that the service object must implement
* @return an instance of the requested service object
*/
- public abstract Object createServiceInstance(Method contextMethod,
- Method domainMethod);
+ public abstract Object createServiceInstance(Method contextMethod, Method domainMethod);
/**
* Determine the method to invoke when retrieving the given property.
- *
+ *
* @param domainType a domain entity type
* @param property the name of the property to be retrieved
* @return the Method that should be invoked to retrieve the property or
@@ -145,7 +144,7 @@
* <p>
* The values returned from this method may be passed to
* {@link #loadDomainObject(Class, Object)} in the future.
- *
+ *
* @param domainObject a domain object
* @return the persistent id of the domain object or {@code null} if the
* object is not persistent
@@ -156,7 +155,7 @@
* Returns the type of object the domain type's {@code findFoo()} or
* {@link com.google.gwt.requestfactory.shared.Locator#getId(Object)
* Locator.getId()} expects to receive.
- *
+ *
* @param domainType a domain entity type
* @return the type of the persistent id value used to represent the domain
* type
@@ -165,7 +164,7 @@
/**
* Retrieve the named property from the domain object.
- *
+ *
* @param domainObject the domain object being examined
* @param property the property name
* @return the value of the property
@@ -180,11 +179,11 @@
/**
* Determine the method to invoke when setting the given property.
- *
+ *
* @param domainType a domain entity type
* @param property the name of the property to be set
- * @return the Method that should be invoked to set the property or
- * {@code null} if the method could not be located
+ * @return the Method that should be invoked to set the property or {@code
+ * null} if the method could not be located
*/
public abstract Method getSetter(Class<?> domainType, String property);
@@ -193,7 +192,7 @@
* persisted. The value returned from this method must be a simple type (e.g.
* Integer, String) or a domain type for which a mapping to an EntityProxy or
* Value proxy exists.
- *
+ *
* @param domainObject a domain object
* @return the version of the domain object or {@code null} if the object is
* not persistent
@@ -203,7 +202,7 @@
/**
* Invoke a domain service method. The underlying eventually calls
* {@link Method#invoke(Object, Object...)}.
- *
+ *
* @param domainMethod the method to invoke
* @param args the arguments to pass to the method
* @return the value returned from the method invocation
@@ -213,7 +212,7 @@
/**
* Returns {@code true} if the given domain object is still live (i.e. not
* deleted) in the backing store.
- *
+ *
* @param domainObject a domain entity
* @return {@code true} if {@code domainObject} could be retrieved at a later
* point in time
@@ -223,7 +222,7 @@
/**
* Load an object from the backing store. This method may return {@code null}
* to indicate that the requested object is no longer available.
- *
+ *
* @param <T> the type of object to load
* @param clazz the type of object to load
* @param domainId an id previously returned from {@link #getId(Object)}
@@ -238,32 +237,30 @@
* <p>
* The default implementation of this method will delegate to
* {@link #loadDomainObject(Class, Object)}.
- *
+ *
* @param classes type type of each object to load
* @param domainIds the ids previously returned from {@link #getId(Object)}
* @return the requested objects, elements of which may be {@code null} if the
* requested objects were irretrievable
*/
- public abstract List<Object> loadDomainObjects(List<Class<?>> classes,
- List<Object> domainIds);
+ public abstract List<Object> loadDomainObjects(List<Class<?>> classes, List<Object> domainIds);
/**
* Determines if the invocation of a domain method requires a
* {@link ServiceLocator} as the 0th parameter when passed into
* {@link #invoke(Method, Object...)}.
- *
+ *
* @param contextMethod a method defined in a RequestContext
* @param domainMethod a domain method
* @return {@code true} if a ServiceLocator is required
*/
- public abstract boolean requiresServiceLocator(Method contextMethod,
- Method domainMethod);
+ public abstract boolean requiresServiceLocator(Method contextMethod, Method domainMethod);
/**
* Given a type token previously returned from
* {@link #resolveTypeToken(Class)}, return the Class literal associated with
* the token.
- *
+ *
* @param typeToken a string token
* @return the type represented by the token
*/
@@ -273,7 +270,7 @@
* Determine the type used by the client code to represent a given domain
* type. If multiple proxy types have been mapped to the same domain type, the
* {@code clientType} parameter is used to ensure assignability.
- *
+ *
* @param domainClass the server-side type to be transported to the client
* @param clientType the type to which the returned type must be assignable
* @param required if {@code true} and no mapping is available, throw an
@@ -288,7 +285,7 @@
/**
* Determine the domain (server-side) type that the given client type is
* mapped to.
- *
+ *
* @param clientType a client-side type
* @return the domain type that {@code clientType} represents
*/
@@ -298,7 +295,7 @@
* Return the domain service method associated with a RequestContext method
* declaration. The {@code requestContextMethod} will have been previously
* resolved by {@link #resolveRequestContextMethod(String, String)}.
- *
+ *
* @param requestContextMethod a RequestContext method declaration.
* @return the domain service method that should be invoked
*/
@@ -307,17 +304,16 @@
/**
* Return the type of {@link Locator} that should be used to access the given
* domain type.
- *
+ *
* @param domainType a domain (server-side) type
* @return the type of Locator to use, or {@code null} if the type conforms to
* the RequestFactory entity protocol
*/
- public abstract Class<? extends Locator<?, ?>> resolveLocator(
- Class<?> domainType);
+ public abstract Class<? extends Locator<?, ?>> resolveLocator(Class<?> domainType);
/**
* Find a RequestContext method declaration by name.
- *
+ *
* @param requestContextClass the fully-qualified binary name of the
* RequestContext
* @param methodName the name of the service method declared within the
@@ -325,15 +321,14 @@
* @return the method declaration, or {@code null} if the method does not
* exist
*/
- public abstract Method resolveRequestContextMethod(
- String requestContextClass, String methodName);
+ public abstract Method resolveRequestContextMethod(String requestContextClass, String methodName);
/**
* Given a RequestContext method declaration, resolve the
* {@link ServiceLocator} that should be used when invoking the domain method.
* This method will only be called if {@link #requiresServiceLocator(Method)}
* returned {@code true} for the associated domain method.
- *
+ *
* @param contextMethod a RequestContext method declaration
* @param domainMethod the domain method that will be invoked
* @return the type of ServiceLocator to use
@@ -343,7 +338,7 @@
/**
* Return a string used to represent the given type in the wire protocol.
- *
+ *
* @param proxyType a client-side EntityProxy or ValueProxy type
* @return the type token used to represent the proxy type
*/
@@ -351,19 +346,19 @@
/**
* Sets a property on a domain object.
- *
+ *
* @param domainObject the domain object to operate on
* @param property the name of the property to set
* @param expectedType the type of the property
* @param value the new value
*/
- public abstract void setProperty(Object domainObject, String property,
- Class<?> expectedType, Object value);
+ public abstract void setProperty(
+ Object domainObject, String property, Class<?> expectedType, Object value);
/**
* Invoke a JSR 303 validator on the given domain object. If no validator is
* available, this method is a no-op.
- *
+ *
* @param <T> the type of data being validated
* @param domainObject the domain objcet to validate
* @return the violations associated with the domain object
diff --git a/user/src/com/google/gwt/requestfactory/server/ServiceLayerDecorator.java b/user/src/com/google/gwt/requestfactory/server/ServiceLayerDecorator.java
index 3167acb..568303e 100644
--- a/user/src/com/google/gwt/requestfactory/server/ServiceLayerDecorator.java
+++ b/user/src/com/google/gwt/requestfactory/server/ServiceLayerDecorator.java
@@ -1,12 +1,12 @@
/*
* Copyright 2010 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -110,14 +110,12 @@
}
@Override
- public List<Object> loadDomainObjects(List<Class<?>> classes,
- List<Object> domainIds) {
+ public List<Object> loadDomainObjects(List<Class<?>> classes, List<Object> domainIds) {
return getNext().loadDomainObjects(classes, domainIds);
}
@Override
- public boolean requiresServiceLocator(Method contextMethod,
- Method domainMethod) {
+ public boolean requiresServiceLocator(Method contextMethod, Method domainMethod) {
return getNext().requiresServiceLocator(contextMethod, domainMethod);
}
@@ -127,8 +125,8 @@
}
@Override
- public <T> Class<? extends T> resolveClientType(Class<?> domainClass,
- Class<T> clientType, boolean required) {
+ public <T> Class<? extends T> resolveClientType(
+ Class<?> domainClass, Class<T> clientType, boolean required) {
return getNext().resolveClientType(domainClass, clientType, required);
}
@@ -148,10 +146,8 @@
}
@Override
- public Method resolveRequestContextMethod(String requestContextClass,
- String methodName) {
- return getNext().resolveRequestContextMethod(requestContextClass,
- methodName);
+ public Method resolveRequestContextMethod(String requestContextClass, String methodName) {
+ return getNext().resolveRequestContextMethod(requestContextClass, methodName);
}
@Override
@@ -166,8 +162,8 @@
}
@Override
- public void setProperty(Object domainObject, String property,
- Class<?> expectedType, Object value) {
+ public void setProperty(
+ Object domainObject, String property, Class<?> expectedType, Object value) {
getNext().setProperty(domainObject, property, expectedType, value);
}
@@ -181,7 +177,7 @@
* should be used to provide diagnostic information that will help the
* end-developer track down problems when that data would expose
* implementation details of the server to the client.
- *
+ *
* @param e a throwable with more data, may be {@code null}
* @param message a printf-style format string
* @param args arguments for the message
@@ -200,7 +196,7 @@
* should use the instance provided by {@code getTop()} when calling public
* methods on the ServiceLayer API to allow higher-level decorators to
* override behaviors built into lower-level decorators.
- *
+ *
* @return the ServiceLayer returned by
* {@link #create(ServiceLayerDecorator...)}
*/
@@ -211,7 +207,7 @@
/**
* Report an exception thrown by code that is under the control of the
* end-developer.
- *
+ *
* @param an {@link InvocationTargetException} thrown by an invocation of
* user-provided code
* @throws ReportableException this method never returns normally
@@ -224,14 +220,13 @@
/**
* Return a message to the client. This method should not include any data
* that was not sent to the server by the client to avoid leaking data.
- *
+ *
* @param msg a printf-style format string
* @param args arguments for the message
* @throws ReportableException this method never returns normally
* @see #die(Throwable, String, Object...)
*/
- protected final <T> T report(String msg, Object... args)
- throws ReportableException {
+ protected final <T> T report(String msg, Object... args) throws ReportableException {
throw new ReportableException(String.format(msg, args));
}