Codota Logo
DefaultEventBus
Code IndexAdd Codota to your IDE (free)

How to use
DefaultEventBus
in
org.apache.shiro.event.support

Best Java code snippets using org.apache.shiro.event.support.DefaultEventBus (Showing top 9 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
origin: apache/shiro

protected EventBus eventBus() {
  return new DefaultEventBus();
}
origin: apache/shiro

public void register(Object instance) {
  if (instance == null) {
    log.info("Received null instance for event listener registration.  Ignoring registration request.");
    return;
  }
  unregister(instance);
  List<EventListener> listeners = getEventListenerResolver().getEventListeners(instance);
  if (listeners == null || listeners.isEmpty()) {
    log.warn("Unable to resolve event listeners for subscriber instance [{}]. Ignoring registration request.",
        instance);
    return;
  }
  Subscription subscription = new Subscription(listeners);
  this.registryWriteLock.lock();
  try {
    this.registry.put(instance, subscription);
  } finally {
    this.registryWriteLock.unlock();
  }
}
origin: apache/shiro

private Map<String,Object> createDefaultObjectMap() {
  Map<String,Object> map = new LinkedHashMap<String, Object>();
  map.put(EVENT_BUS_NAME, new DefaultEventBus());
  return map;
}
origin: apache/shiro

/**
 * Default no-arg constructor that will automatically attempt to initialize a default cacheManager
 */
public CachingSecurityManager() {
  //use a default event bus:
  setEventBus(new DefaultEventBus());
}
origin: apache/shiro

/**
 * Destroys the {@link #getCacheManager() cacheManager} via {@link LifecycleUtils#destroy LifecycleUtils.destroy}.
 */
public void destroy() {
  LifecycleUtils.destroy(getCacheManager());
  this.cacheManager = null;
  LifecycleUtils.destroy(getEventBus());
  this.eventBus = new DefaultEventBus();
}
origin: org.apache.shiro/shiro-core

/**
 * Default no-arg constructor that will automatically attempt to initialize a default cacheManager
 */
public CachingSecurityManager() {
  //use a default event bus:
  setEventBus(new DefaultEventBus());
}
origin: org.apache.shiro/shiro-core

/**
 * Destroys the {@link #getCacheManager() cacheManager} via {@link LifecycleUtils#destroy LifecycleUtils.destroy}.
 */
public void destroy() {
  LifecycleUtils.destroy(getCacheManager());
  this.cacheManager = null;
  LifecycleUtils.destroy(getEventBus());
  this.eventBus = new DefaultEventBus();
}
origin: org.apache.shiro/shiro-spring

protected EventBus eventBus() {
  return new DefaultEventBus();
}
origin: org.apache.shiro/shiro-config-ogdl

private Map<String,Object> createDefaultObjectMap() {
  Map<String,Object> map = new LinkedHashMap<String, Object>();
  map.put(EVENT_BUS_NAME, new DefaultEventBus());
  return map;
}
org.apache.shiro.event.supportDefaultEventBus

Javadoc

A default event bus implementation that synchronously publishes events to registered listeners. Listeners can be registered or unregistered for events as necessary.

An event bus enables a publish/subscribe paradigm within Shiro - components can publish or consume events they find relevant without needing to be tightly coupled to other components. This affords great flexibility within Shiro by promoting loose coupling and high cohesion between components and a much safer pluggable architecture that is more resilient to change over time.

Sending Events If a component wishes to publish events to other components:
 
MyEvent myEvent = createMyEvent(); 
eventBus.publish(myEvent); 
The event bus will determine the type of event and then dispatch the event to components that wish to receive events of that type. Receiving Events A component can receive events of interest by doing the following.
  1. For each type of event you wish to consume, create a public method that accepts a single event argument. The method argument type indicates the type of event to receive.
  2. Annotate each of these public methods with the org.apache.shiro.event.Subscribe annotation.
  3. Register the component with the event bus:
     
    eventBus.register(myComponent); 
    
After registering the component, when when an event of a respective type is published, the component's Subscribe-annotated method(s) will be invoked as expected. This design (and its constituent helper components) was largely influenced by Guava's EventBus concept, although no code was shared/imported (even though Guava is Apache 2.0 licensed and could have been used). This implementation is thread-safe and may be used concurrently.

Most used methods

  • <init>
  • getEventListenerResolver
  • unregister

Popular in Java

  • Start an intent from android
  • getSystemService (Context)
  • requestLocationUpdates (LocationManager)
  • orElseThrow (Optional)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • KeyStore (java.security)
    This class represents an in-memory collection of keys and certificates. It manages two types of entr
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • Pattern (java.util.regex)
    A compiled representation of a regular expression. A regular expression, specified as a string, must
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now