MembershipServiceBase (Apache Tomcat 10.1.55 API Documentation)
Description: declaration: package: org.apache.catalina.tribes.membership, class: MembershipServiceBase

# Class MembershipServiceBase

java.lang.Object
org.apache.catalina.tribes.membership.MembershipServiceBase

All Implemented Interfaces:
  `MembershipListener, MembershipService`

Direct Known Subclasses:
  `CloudMembershipService, McastService, StaticMembershipService`

public abstract class MembershipServiceBase extends Object implements MembershipService, MembershipListener

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Channel`
  `channel`
  `protected MembershipListener`
  `listener`
  `protected Properties`
  `properties`
  The implementation specific properties

  ### Fields inherited from interface MembershipService

  `MBR_RX, MBR_TX`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MembershipServiceBase()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `broadcast(ChannelMessage message)`
  Broadcasts a message to all members.
  `Member`
  `findMemberByName(String name)`
  Get a member.
  `Channel`
  `getChannel()`
  Return the channel that is related to this MembershipService
  `Member`
  `getMember(Member mbr)`
  Retrieve the specified member from the membership.
  `Member[]`
  `getMembers()`
  `String[]`
  `getMembersByName()`
  `Properties`
  `getProperties()`
  `boolean`
  `hasMembers()`
  `void`
  `memberAdded(Member member)`
  A member was added to the group
  `void`
  `memberDisappeared(Member member)`
  A member was removed from the group
  If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD data
  `void`
  `removeMembershipListener()`
  Removes the membership listener.
  `void`
  `setChannel(Channel channel)`
  Set the channel that is related to this MembershipService
  `void`
  `setMembershipListener(MembershipListener listener)`
  Sets the membership listener, only one listener can be added.
  `void`
  `setProperties(Properties properties)`
  Sets the properties for the membership service.
  `void`
  `start()`
  Starts the membership service.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface MembershipService

  `getLocalMember, getMembershipProvider, setDomain, setLocalMemberProperties, setPayload, start, stop`

- ## Field Details

  - ### properties

    protected Properties properties
    The implementation specific properties

  - ### listener

    protected volatile MembershipListener listener

  - ### channel

    protected Channel channel

- ## Constructor Details

  - ### MembershipServiceBase

    public MembershipServiceBase()

- ## Method Details

  - ### setProperties

    public void setProperties(Properties properties)
    Description copied from interface: `MembershipService`
    Sets the properties for the membership service. This must be called before the `start()` method is called. The properties are implementation specific.
    Specified by:
      `setProperties` in interface `MembershipService`
    Parameters:
      `properties` - - to be used to configure the membership service.

  - ### getProperties

    public Properties getProperties()
    Specified by:
      `getProperties` in interface `MembershipService`
    Returns:
      the properties for the configuration used.

  - ### hasMembers

    public boolean hasMembers()
    Specified by:
      `hasMembers` in interface `MembershipService`
    Returns:
      true if the group contains members

  - ### getMember

    public Member getMember(Member mbr)
    Description copied from interface: `MembershipService`
    Retrieve the specified member from the membership.
    Specified by:
      `getMember` in interface `MembershipService`
    Parameters:
      `mbr` - The member to retrieve
    Returns:
      the member

  - ### getMembers

    public Member[] getMembers()
    Specified by:
      `getMembers` in interface `MembershipService`
    Returns:
      an array of all the members in the cluster.

  - ### getMembersByName

    public String[] getMembersByName()
    Specified by:
      `getMembersByName` in interface `MembershipService`
    Returns:
      all members by name

  - ### findMemberByName

    public Member findMemberByName(String name)
    Description copied from interface: `MembershipService`
    Get a member.
    Specified by:
      `findMemberByName` in interface `MembershipService`
    Parameters:
      `name` - The member name
    Returns:
      the member

  - ### setMembershipListener

    public void setMembershipListener(MembershipListener listener)
    Description copied from interface: `MembershipService`
    Sets the membership listener, only one listener can be added. If you call this method twice, the last listener will be used.
    Specified by:
      `setMembershipListener` in interface `MembershipService`
    Parameters:
      `listener` - The listener

  - ### removeMembershipListener

    public void removeMembershipListener()
    Description copied from interface: `MembershipService`
    Removes the membership listener.
    Specified by:
      `removeMembershipListener` in interface `MembershipService`

  - ### memberAdded

    public void memberAdded(Member member)
    Description copied from interface: `MembershipListener`
    A member was added to the group
    Specified by:
      `memberAdded` in interface `MembershipListener`
    Parameters:
      `member` - Member - the member that was added

  - ### memberDisappeared

    public void memberDisappeared(Member member)
    Description copied from interface: `MembershipListener`
    A member was removed from the group
    If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD data
    Specified by:
      `memberDisappeared` in interface `MembershipListener`
    Parameters:
      `member` - Member
    See Also:
      - `Member.SHUTDOWN_PAYLOAD`

  - ### broadcast

    public void broadcast(ChannelMessage message) throws ChannelException
    Description copied from interface: `MembershipService`
    Broadcasts a message to all members.
    Specified by:
      `broadcast` in interface `MembershipService`
    Parameters:
      `message` - The message to broadcast
    Throws:
      `ChannelException` - Message broadcast failed

  - ### getChannel

    public Channel getChannel()
    Description copied from interface: `MembershipService`
    Return the channel that is related to this MembershipService
    Specified by:
      `getChannel` in interface `MembershipService`
    Returns:
      Channel

  - ### setChannel

    public void setChannel(Channel channel)
    Description copied from interface: `MembershipService`
    Set the channel that is related to this MembershipService
    Specified by:
      `setChannel` in interface `MembershipService`
    Parameters:
      `channel` - The channel

  - ### start

    public void start() throws Exception
    Description copied from interface: `MembershipService`
    Starts the membership service. If a membership listeners is added the listener will start to receive membership events. Performs a start level 1 and 2
    Specified by:
      `start` in interface `MembershipService`
    Throws:
      `Exception` - if the service fails to start.