Package fish.payara.service.example
Class ExampleService
- java.lang.Object
-
- fish.payara.service.example.ExampleService
-
- All Implemented Interfaces:
MessageReceiver
,EventListener
,ConfigListener
@Service(name="example-service") @RunLevel(10) public class ExampleService extends Object implements EventListener, MessageReceiver, ConfigListener
An example of a service which can be used as an aid to developing future services The service implements Event Listener to hook into the Sever wide events system The service implements MessageReceiver to hook into the cluster wide messaging system The service implements ConfigListener to receive notifications if it's configuration changes Note you do not need to inject all the services below they are just examples of what is available Note if you need to respond to configuration changes and be dynamic then implement the ConfigListener interface if you are unable to respond to config changes don't implement the interface.- Author:
- steve
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.glassfish.api.event.EventListener
EventListener.Event<T>
-
-
Constructor Summary
Constructors Constructor Description ExampleService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bootService()
This method is called after the service instance has been createdUnprocessedChangeEvents
changed(PropertyChangeEvent[] pces)
This is the required method for the ConfigListener it is called if our configuration is changed.void
doSomethingDirectly(String message)
Example method to be used by the instance targeted asadmin command to interact with the service directlyvoid
event(EventListener.Event event)
This is the required method for the EventListener interface for server wide messages handling these events means your service can take action depending on things happening within the servervoid
receiveMessage(ClusterMessage message)
This is the required method for the Payara Specific cluster wide event busvoid
reconfigure()
-
-
-
Method Detail
-
bootService
@PostConstruct public void bootService()
This method is called after the service instance has been created
-
event
public void event(EventListener.Event event)
This is the required method for the EventListener interface for server wide messages handling these events means your service can take action depending on things happening within the server- Specified by:
event
in interfaceEventListener
- Parameters:
event
-
-
receiveMessage
public void receiveMessage(ClusterMessage message)
This is the required method for the Payara Specific cluster wide event bus- Specified by:
receiveMessage
in interfaceMessageReceiver
- Parameters:
message
-
-
changed
public UnprocessedChangeEvents changed(PropertyChangeEvent[] pces)
This is the required method for the ConfigListener it is called if our configuration is changed. Note: Look at the implementation you must check whether you are the DAS and if so check that it is the DAS config that has been changed- Specified by:
changed
in interfaceConfigListener
- Parameters:
pces
-- Returns:
- See Also:
isCurrentInstanceMatchTarget(java.beans.PropertyChangeEvent)
-
reconfigure
public void reconfigure()
-
doSomethingDirectly
public void doSomethingDirectly(String message)
Example method to be used by the instance targeted asadmin command to interact with the service directly
-
-