Tabnine Logo
DefaultEventBus
Code IndexAdd Tabnine 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)

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

  • Running tasks concurrently on multiple threads
  • getApplicationContext (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • getSystemService (Context)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now