Class InjvmExporterListener

java.lang.Object
org.apache.dubbo.rpc.listener.ExporterListenerAdapter
org.apache.dubbo.rpc.listener.InjvmExporterListener
All Implemented Interfaces:
ExporterListener

public class InjvmExporterListener extends ExporterListenerAdapter
The InjvmExporterListener class is an implementation of the ExporterListenerAdapter abstract class,

which is used to listen for changes to the InjvmExporter instances.

It maintains two ConcurrentHashMaps, one to keep track of the ExporterChangeListeners registered for each service,

and another to keep track of the currently exported services and their associated Exporter instances.

It overrides the exported and unexported methods to add or remove the corresponding Exporter instances to/from

the exporters ConcurrentHashMap, and to notify all registered ExporterChangeListeners of the change.

It also provides methods to add or remove ExporterChangeListeners for a specific service, and to retrieve the

currently exported Exporter instance for a given service.

  • Constructor Details

    • InjvmExporterListener

      public InjvmExporterListener()
  • Method Details

    • exported

      public void exported(Exporter<?> exporter) throws RpcException
      Overrides the exported method to add the given exporter to the exporters ConcurrentHashMap,

      and to notify all registered ExporterChangeListeners of the export event.

      Specified by:
      exported in interface ExporterListener
      Overrides:
      exported in class ExporterListenerAdapter
      Parameters:
      exporter - The Exporter instance that has been exported.
      Throws:
      RpcException - If there is an error during the export process.
      See Also:
    • unexported

      public void unexported(Exporter<?> exporter) throws RpcException
      Overrides the unexported method to remove the given exporter from the exporters ConcurrentHashMap,

      and to notify all registered ExporterChangeListeners of the unexport event.

      Specified by:
      unexported in interface ExporterListener
      Overrides:
      unexported in class ExporterListenerAdapter
      Parameters:
      exporter - The Exporter instance that has been unexported.
      Throws:
      RpcException - If there is an error during the unexport process.
      See Also:
    • addExporterChangeListener

      public void addExporterChangeListener(ExporterChangeListener listener, String serviceKey)
      Adds an ExporterChangeListener for a specific service, and notifies the listener of the current Exporter instance

      if it exists.

      Parameters:
      listener - The ExporterChangeListener to add.
      serviceKey - The service key for the service to listen for changes on.
    • removeExporterChangeListener

      public void removeExporterChangeListener(ExporterChangeListener listener, String listenerKey)
      Removes an ExporterChangeListener for a specific service.
      Parameters:
      listener - The ExporterChangeListener to remove.
      listenerKey - The service key for the service to remove the listener from.