public class

RequestFactoryInterfaceValidator

extends Object
java.lang.Object
   ↳ com.google.gwt.requestfactory.server.RequestFactoryInterfaceValidator

Class Overview

Encapsulates validation logic to determine if a RequestFactory interface, its RequestContext, and associated EntityProxy interfaces match their domain counterparts. This implementation examines the classfiles directly in order to avoid the need to load the types into the JVM.

This class is amenable to being used as a unit test:

 public void testRequestFactory() {
   Logger logger = Logger.getLogger("");
   RequestFactoryInterfaceValidator v = new RequestFactoryInterfaceValidator(
     logger, new ClassLoaderLoader(MyRequestContext.class.getClassLoader()));
   v.validateRequestContext(MyRequestContext.class.getName());
   assertFalse(v.isPoisoned());
 }
 
This class also has a main method and can be used as a build-time tool:
 java -cp gwt-servlet.jar:your-code.jar \
   com.google.gwt.requestfactory.server.RequestFactoryInterfaceValidator \
   com.example.MyRequestFactory
 

Summary

Nested Classes
class RequestFactoryInterfaceValidator.ClassLoaderLoader An implementation of RequestFactoryInterfaceValidator.ClassLoaderLoader that uses a ClassLoader to retrieve the class files. 
interface RequestFactoryInterfaceValidator.Loader Abstracts the mechanism by which class files are loaded. 
Public Constructors
RequestFactoryInterfaceValidator(Logger logger, RequestFactoryInterfaceValidator.Loader loader)
Public Methods
void antidote()
Reset the poisoned status of the validator so that it may be reused without destroying cached state.
boolean isPoisoned()
Returns true if validation failed.
static void main(String[] args)
void validateEntityProxy(String binaryName)
This method checks an EntityProxy interface against its peer domain object to determine if the server code would be able to process a request using the methods defined in the EntityProxy interface.
void validateProxy(String binaryName)
Determine if the specified type implements a proxy interface and apply the appropriate validations.
void validateRequestContext(String binaryName)
This method checks a RequestContext interface against its peer domain domain object to determine if the server code would be able to process a request using the the methods defined in the RequestContext interface.
void validateRequestFactory(String binaryName)
This method checks a RequestFactory interface.
void validateValueProxy(String binaryName)
This method checks a ValueProxy interface against its peer domain object to determine if the server code would be able to process a request using the methods defined in the ValueProxy interface.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public RequestFactoryInterfaceValidator (Logger logger, RequestFactoryInterfaceValidator.Loader loader)

Public Methods

public void antidote ()

Reset the poisoned status of the validator so that it may be reused without destroying cached state.

public boolean isPoisoned ()

Returns true if validation failed.

public static void main (String[] args)

public void validateEntityProxy (String binaryName)

This method checks an EntityProxy interface against its peer domain object to determine if the server code would be able to process a request using the methods defined in the EntityProxy interface. It does not perform any checks as to whether or not the EntityProxy could actually be generated by the Generator.

This method may be called repeatedly on a single instance of the validator. Doing so will amortize type calculation costs.

Checks implemented:

  • binaryName implements EntityProxy
  • binaryName has a ProxyFor or ProxyForName annotation
  • The domain object has getId() and getVersion() methods
  • All property methods in the EntityProxy can be mapped onto an equivalent domain method
  • All referenced proxy types are valid

Parameters
binaryName the binary name (e.g. getName()) of the EntityProxy subtype

public void validateProxy (String binaryName)

Determine if the specified type implements a proxy interface and apply the appropriate validations. This can be used as a general-purpose entry method when writing unit tests.

Parameters
binaryName the binary name (e.g. getName()) of the EntityProxy or ValueProxy subtype

public void validateRequestContext (String binaryName)

This method checks a RequestContext interface against its peer domain domain object to determine if the server code would be able to process a request using the the methods defined in the RequestContext interface. It does not perform any checks as to whether or not the RequestContext could actually be generated by the Generator.

This method may be called repeatedly on a single instance of the validator. Doing so will amortize type calculation costs.

Checks implemented:

  • binaryName implements RequestContext
  • binaryName has a Service or ServiceName annotation
  • All service methods in the RequestContext can be mapped onto an equivalent domain method
  • All referenced EntityProxy types are valid

Parameters
binaryName the binary name (e.g. getName()) of the RequestContext subtype

public void validateRequestFactory (String binaryName)

This method checks a RequestFactory interface.

This method may be called repeatedly on a single instance of the validator. Doing so will amortize type calculation costs. It does not perform any checks as to whether or not the RequestContext could actually be generated by the Generator.

Checks implemented:

  • binaryName implements RequestFactory
  • All referenced RequestContext types are valid

Parameters
binaryName the binary name (e.g. getName()) of the RequestContext subtype

public void validateValueProxy (String binaryName)

This method checks a ValueProxy interface against its peer domain object to determine if the server code would be able to process a request using the methods defined in the ValueProxy interface. It does not perform any checks as to whether or not the ValueProxy could actually be generated by the Generator.

This method may be called repeatedly on a single instance of the validator. Doing so will amortize type calculation costs.

Checks implemented:

  • binaryName implements ValueProxy
  • binaryName has a ProxyFor or ProxyForName annotation
  • All property methods in the EntityProxy can be mapped onto an equivalent domain method
  • All referenced proxy types are valid

Parameters
binaryName the binary name (e.g. getName()) of the EntityProxy subtype