org.apache.shiro.guice
Class ShiroModule

java.lang.Object
  extended by com.google.inject.PrivateModule
      extended by org.apache.shiro.guice.ShiroModule
All Implemented Interfaces:
com.google.inject.Module, Destroyable
Direct Known Subclasses:
ShiroWebModule

public abstract class ShiroModule
extends com.google.inject.PrivateModule
implements Destroyable

Sets up Shiro lifecycles within Guice, enables the injecting of Shiro objects, and binds a default SecurityManager and SessionManager. At least one realm must be added by using bindRealm.


Constructor Summary
ShiroModule()
           
 
Method Summary
 void add(Destroyable destroyable)
           
protected
<T> void
bindBeanType(com.google.inject.TypeLiteral<T> typeLiteral, com.google.inject.Key<? extends T> key)
          Binds a key to use for injecting setters in shiro classes.
protected  void bindEnvironment(com.google.inject.binder.AnnotatedBindingBuilder<Environment> bind)
          Binds the environment.
protected  com.google.inject.binder.LinkedBindingBuilder<Realm> bindRealm()
          This is the preferred manner to bind a realm.
protected  void bindSecurityManager(com.google.inject.binder.AnnotatedBindingBuilder<? super SecurityManager> bind)
          Binds the security manager.
protected  void bindSessionManager(com.google.inject.binder.AnnotatedBindingBuilder<SessionManager> bind)
          Binds the session manager.
 void configure()
           
protected abstract  void configureShiro()
          Implement this method in order to configure your realms and any other Shiro customization you may need.
 void destroy()
          Destroys all beans created within this module that implement Destroyable.
 
Methods inherited from class com.google.inject.PrivateModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindScope, configure, convertToTypes, currentStage, expose, expose, expose, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShiroModule

public ShiroModule()
Method Detail

configure

public void configure()
Specified by:
configure in class com.google.inject.PrivateModule

configureShiro

protected abstract void configureShiro()
Implement this method in order to configure your realms and any other Shiro customization you may need.


bindRealm

protected final com.google.inject.binder.LinkedBindingBuilder<Realm> bindRealm()
This is the preferred manner to bind a realm. The SecurityManager will be injected with any Realm bound with this method.

Returns:
a binding builder for a realm

bindSecurityManager

protected void bindSecurityManager(com.google.inject.binder.AnnotatedBindingBuilder<? super SecurityManager> bind)
Binds the security manager. Override this method in order to provide your own security manager binding.

By default, a DefaultSecurityManager is bound as an eager singleton.

Parameters:
bind -

bindSessionManager

protected void bindSessionManager(com.google.inject.binder.AnnotatedBindingBuilder<SessionManager> bind)
Binds the session manager. Override this method in order to provide your own session manager binding.

By default, a DefaultSessionManager is bound as an eager singleton.

Parameters:
bind -

bindEnvironment

protected void bindEnvironment(com.google.inject.binder.AnnotatedBindingBuilder<Environment> bind)
Binds the environment. Override this method in order to provide your own environment binding.

By default, a GuiceEnvironment is bound as an eager singleton.

Parameters:
bind -

bindBeanType

protected final <T> void bindBeanType(com.google.inject.TypeLiteral<T> typeLiteral,
                                      com.google.inject.Key<? extends T> key)
Binds a key to use for injecting setters in shiro classes.

Type Parameters:
T -
Parameters:
typeLiteral - the bean property type
key - the key to use to satisfy the bean property dependency

destroy

public final void destroy()
                   throws Exception
Destroys all beans created within this module that implement Destroyable. Should be called when this module will no longer be used.

Specified by:
destroy in interface Destroyable
Throws:
Exception

add

public void add(Destroyable destroyable)


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.