/** * This is the preferred manner to bind a realm. The {@link org.apache.shiro.mgt.SecurityManager} will be injected with any Realm bound * with this method. * * @return a binding builder for a realm */ protected final LinkedBindingBuilder<Realm> bindRealm() { Multibinder<Realm> multibinder = Multibinder.newSetBinder(binder(), Realm.class); return multibinder.addBinding(); }
/** * Binds a key to use for injecting setters in shiro classes. * @param typeLiteral the bean property type * @param key the key to use to satisfy the bean property dependency * @param <T> */ protected final <T> void bindBeanType(TypeLiteral<T> typeLiteral, Key<? extends T> key) { BeanTypeListener.bindBeanType(binder(), typeLiteral, key); }
public void configure() { // setup security manager bindSecurityManager(bind(SecurityManager.class)); bindSessionManager(bind(SessionManager.class)); bindEnvironment(bind(Environment.class)); bindListener(BeanTypeListener.MATCHER, new BeanTypeListener()); bindEventBus(bind(EventBus.class)); bindListener(Matchers.any(), new SubscribedEventTypeListener()); bindListener(Matchers.any(), new EventBusAwareTypeListener()); final DestroyableInjectionListener.DestroyableRegistry registry = new DestroyableInjectionListener.DestroyableRegistry() { public void add(Destroyable destroyable) { ShiroModule.this.add(destroyable); } @PreDestroy public void destroy() { ShiroModule.this.destroy(); } }; bindListener(LifecycleTypeListener.MATCHER, new LifecycleTypeListener(registry)); expose(SecurityManager.class); expose(EventBus.class); configureShiro(); bind(realmCollectionKey()) .to(realmSetKey()); bind(DestroyableInjectionListener.DestroyableRegistry.class).toInstance(registry); BeanTypeListener.ensureBeanTypeMapExists(binder()); }
/** * This is the preferred manner to bind a realm. The {@link org.apache.shiro.mgt.SecurityManager} will be injected with any Realm bound * with this method. * * @return a binding builder for a realm */ protected final LinkedBindingBuilder<Realm> bindRealm() { Multibinder<Realm> multibinder = Multibinder.newSetBinder(binder(), Realm.class); return multibinder.addBinding(); }
/** * Binds a key to use for injecting setters in shiro classes. * @param typeLiteral the bean property type * @param key the key to use to satisfy the bean property dependency * @param <T> */ protected final <T> void bindBeanType(TypeLiteral<T> typeLiteral, Key<? extends T> key) { BeanTypeListener.bindBeanType(binder(), typeLiteral, key); }
public void configure() { // setup security manager bindSecurityManager(bind(SecurityManager.class)); bindSessionManager(bind(SessionManager.class)); bindEnvironment(bind(Environment.class)); bindListener(BeanTypeListener.MATCHER, new BeanTypeListener()); bindEventBus(bind(EventBus.class)); bindListener(Matchers.any(), new SubscribedEventTypeListener()); bindListener(Matchers.any(), new EventBusAwareTypeListener()); final DestroyableInjectionListener.DestroyableRegistry registry = new DestroyableInjectionListener.DestroyableRegistry() { public void add(Destroyable destroyable) { ShiroModule.this.add(destroyable); } @PreDestroy public void destroy() { ShiroModule.this.destroy(); } }; bindListener(LifecycleTypeListener.MATCHER, new LifecycleTypeListener(registry)); expose(SecurityManager.class); expose(EventBus.class); configureShiro(); bind(realmCollectionKey()) .to(realmSetKey()); bind(DestroyableInjectionListener.DestroyableRegistry.class).toInstance(registry); BeanTypeListener.ensureBeanTypeMapExists(binder()); }