org.directwebremoting.guice
Class AbstractDwrModule

java.lang.Object
  extended by com.google.inject.AbstractModule
      extended by org.directwebremoting.guice.AbstractDwrModule
All Implemented Interfaces:
com.google.inject.Module
Direct Known Subclasses:
DwrGuiceServletContextListener

public abstract class AbstractDwrModule
extends com.google.inject.AbstractModule

An extension of AbstractModule that adds DWR configuration methods, in conjunction with DwrGuiceServlet.

Author:
Tim Peierls [tim at peierls dot net]

Constructor Summary
AbstractDwrModule()
           
 
Method Summary
protected  void bindAnnotatedClasses(java.lang.Class... classes)
          Call this method in configure to specify classes that DWR should scan for annotations.
protected  com.google.inject.binder.LinkedBindingBuilder<org.directwebremoting.extend.Converter> bindConversion(java.lang.Class<?> type)
          Creates a binding for a conversion for type.
protected
<T> void
bindConversion(java.lang.Class<T> type, java.lang.Class<? extends T> impl)
          Creates a binding for a conversion for type using an existing conversion for impl, which must be assignable to type.
protected  com.google.inject.binder.LinkedBindingBuilder<org.directwebremoting.extend.Converter> bindConversion(java.lang.String match)
          Creates a binding for a conversion for types with names matching match.
protected  void bindDwrScopes()
          Configure DWR scopes and bindings for servlet-related types; incompatible with Guice's ServletModule because their bindings for request, response, and session conflict.
protected  void bindDwrScopes(boolean bindPotentiallyConflictingTypes)
          Configure DWR scopes and bindings for servlet-related types, specifying whether to include bindings that conflict with those provided by Guice's ServletModule.
protected  com.google.inject.binder.LinkedBindingBuilder<org.directwebremoting.AjaxFilter> bindFilter(java.lang.String scriptName)
          Creates a binding for an Ajax filter for the script named scriptName.
protected  com.google.inject.binder.LinkedBindingBuilder<org.directwebremoting.AjaxFilter> bindGlobalFilter()
          Creates a binding for a global Ajax filter.
protected  com.google.inject.binder.ConstantBindingBuilder bindParameter(ParamName paramName)
          Call this method in configure to create a binding for a DWR parameter.
protected
<T> com.google.inject.binder.LinkedBindingBuilder<T>
bindRemoted(java.lang.Class<T> type)
          Creates a binding to type that is used as the target of a remote method call with the class's unqualified name as the script name.
protected
<T> com.google.inject.binder.LinkedBindingBuilder<T>
bindRemotedAs(java.lang.String scriptName, java.lang.Class<T> type)
          Creates a binding to a type that is used as the target of a remote method call with the given scriptName.
protected abstract  void configure()
          Implement this method to configure Guice bindings for a DWR-based web application.
 
Methods inherited from class com.google.inject.AbstractModule
addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindScope, configure, install, requestStaticInjection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDwrModule

public AbstractDwrModule()
Method Detail

configure

protected abstract void configure()
Implement this method to configure Guice bindings for a DWR-based web application.

Specified by:
configure in class com.google.inject.AbstractModule

bindDwrScopes

protected void bindDwrScopes()
Configure DWR scopes and bindings for servlet-related types; incompatible with Guice's ServletModule because their bindings for request, response, and session conflict.


bindDwrScopes

protected void bindDwrScopes(boolean bindPotentiallyConflictingTypes)
Configure DWR scopes and bindings for servlet-related types, specifying whether to include bindings that conflict with those provided by Guice's ServletModule.

Parameters:
bindPotentiallyConflictingTypes - whether to bind request, response, and session types (risking conflict with Guice)

bindConversion

protected com.google.inject.binder.LinkedBindingBuilder<org.directwebremoting.extend.Converter> bindConversion(java.lang.String match)
Creates a binding for a conversion for types with names matching match.

Parameters:
match - the string describing which types to convert

bindConversion

protected com.google.inject.binder.LinkedBindingBuilder<org.directwebremoting.extend.Converter> bindConversion(java.lang.Class<?> type)
Creates a binding for a conversion for type.

Parameters:
type - the type to be converted

bindConversion

protected <T> void bindConversion(java.lang.Class<T> type,
                                  java.lang.Class<? extends T> impl)
Creates a binding for a conversion for type using an existing conversion for impl, which must be assignable to type. The check for an existing conversion happens at run-time.

Parameters:
type - the type to be converted

bindRemoted

protected <T> com.google.inject.binder.LinkedBindingBuilder<T> bindRemoted(java.lang.Class<T> type)
Creates a binding to type that is used as the target of a remote method call with the class's unqualified name as the script name.

Note: if you are scoping the result, don't rely on implicit binding. Instead, link the type to itself explicitly. For example,

   bindRemoted(ConcreteService.class)
       .to(ConcreteService.class) // this line is required
       .in(DwrScopes.SESSION);
 
This could be considered a bug.

Parameters:
type - the type to bind as a target for remote method calls

bindRemotedAs

protected <T> com.google.inject.binder.LinkedBindingBuilder<T> bindRemotedAs(java.lang.String scriptName,
                                                                             java.lang.Class<T> type)
Creates a binding to a type that is used as the target of a remote method call with the given scriptName.

Note: if you are scoping the result, don't rely on implicit binding. Instead, link the type to itself explicitly. For example,

   bindRemotedAs("Mixer", ConcreteService.class)
       .to(ConcreteService.class) // this line is required
       .in(DwrScopes.SESSION);
 
This could be considered a bug.

Parameters:
type - the type to bind as a target for remote method calls
scriptName - the name by which the target type will be known to script callers

bindFilter

protected com.google.inject.binder.LinkedBindingBuilder<org.directwebremoting.AjaxFilter> bindFilter(java.lang.String scriptName)
Creates a binding for an Ajax filter for the script named scriptName.

Parameters:
scriptName - the script to filter

bindGlobalFilter

protected com.google.inject.binder.LinkedBindingBuilder<org.directwebremoting.AjaxFilter> bindGlobalFilter()
Creates a binding for a global Ajax filter.

Parameters:
scriptName - the script to filter

bindParameter

protected com.google.inject.binder.ConstantBindingBuilder bindParameter(ParamName paramName)
Call this method in configure to create a binding for a DWR parameter.

Parameters:
paramName - a parameter name supported by DWR

bindAnnotatedClasses

protected void bindAnnotatedClasses(java.lang.Class... classes)
Call this method in configure to specify classes that DWR should scan for annotations.

Parameters:
classes - the classes to be scanned for DWR-specific annotations


Copyright © 2007. All Rights Reserved.