Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mentawai.filter
Class InjectionFilter  view InjectionFilter download InjectionFilter.java

java.lang.Object
  extended byorg.mentawai.filter.InjectionFilter
All Implemented Interfaces:
org.mentawai.core.Filter

public class InjectionFilter
extends java.lang.Object
implements org.mentawai.core.Filter

A filter that tries to inject the input values in the action through setters. (Ex. setUsername(), setPassword(), etc.) It can also inject the input value directly in the attribute, even if it is a private field. Use this filter if you don't want to deal with the action input object and instaed you want to inject its values in the action. This filter tries to inject all the input values in the action.


Field Summary
private  java.util.Map methods
           
private  boolean tryField
           
 
Constructor Summary
InjectionFilter()
          Creates an InjectionFilter that can be used by any action class.
InjectionFilter(boolean tryField)
          Creates an InjectionFilter that can be used by any action class.
 
Method Summary
 void destroy()
          Gives a chance to the filter to deallocalte any resources before it is destroyed.
 java.lang.String filter(org.mentawai.core.InvocationChain chain)
          Executes the filter.
(package private) static java.lang.reflect.Field getField(java.lang.Object target, java.lang.String name)
           
(package private) static java.lang.Class getPrimitiveFrom(java.lang.Object w)
           
private  void setValue(java.lang.Object target, java.lang.String name, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

methods

private java.util.Map methods

tryField

private boolean tryField
Constructor Detail

InjectionFilter

public InjectionFilter()
Creates an InjectionFilter that can be used by any action class. You may use this filter per action or as a global filter.


InjectionFilter

public InjectionFilter(boolean tryField)
Creates an InjectionFilter that can be used by any action class. You may use this filter per action or as a global filter. If tryField is true and it cannot find a setter for the input value, it will try to directly access the attribute, even if it is a private field.

Method Detail

getField

static java.lang.reflect.Field getField(java.lang.Object target,
                                        java.lang.String name)

setValue

private void setValue(java.lang.Object target,
                      java.lang.String name,
                      java.lang.Object value)

getPrimitiveFrom

static java.lang.Class getPrimitiveFrom(java.lang.Object w)

filter

public java.lang.String filter(org.mentawai.core.InvocationChain chain)
                        throws java.lang.Exception
Description copied from interface: org.mentawai.core.Filter
Executes the filter.

Specified by:
filter in interface org.mentawai.core.Filter

destroy

public void destroy()
Description copied from interface: org.mentawai.core.Filter
Gives a chance to the filter to deallocalte any resources before it is destroyed. This is called when the web application is stopped, in other words, this has nothing to do with garbage collection.

Specified by:
destroy in interface org.mentawai.core.Filter