Class GrizzlyService
- java.lang.Object
-
- com.sun.enterprise.v3.services.impl.GrizzlyService
-
- All Implemented Interfaces:
fish.payara.monitoring.collect.MonitoringDataSource,RequestDispatcher,EventListener,FutureProvider<Result<Thread>>,org.glassfish.hk2.api.PostConstruct,org.glassfish.hk2.api.PreDestroy
@Service @RunLevel(10) @Rank(50) public class GrizzlyService extends Object implements RequestDispatcher, org.glassfish.hk2.api.PostConstruct, org.glassfish.hk2.api.PreDestroy, EventListener, FutureProvider<Result<Thread>>, fish.payara.monitoring.collect.MonitoringDataSource
The Network Service is responsible for starting grizzly and register the top level proxy. It is also providing a runtime service where other services (like admin for instance) can register endpoints proxy to particular context root.- Author:
- Jerome Dochez
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGrizzlyService.NoopInvocationHandlerProbe provider that implements each probe provider method as a no-op.-
Nested classes/interfaces inherited from interface org.glassfish.api.event.EventListener
EventListener.Event<T>
-
-
Constructor Summary
Constructors Constructor Description GrizzlyService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddMapperUpdateListener(MapperUpdateListener listener)AddsMapperUpdateListenerto listeners queue.voidaddNetworkProxy(NetworkProxy proxy)Add the new proxy to our list of proxies.booleancloseNetworkProxy(NetworkProxy proxy)voidcollect(fish.payara.monitoring.collect.MonitoringDataCollector collector)Future<Result<Thread>>createNetworkProxy(NetworkListener listener)voidevent(EventListener.Event event)Method is invoked each time Glassfish state changes.List<Future<Result<Thread>>>getFutures()org.glassfish.hk2.api.ServiceLocatorgetHabitat()Gets the habitat.LoggergetLogger()Gets the logger.GrizzlyMonitoringgetMonitoring()intgetRealPort(NetworkListener listener)booleanhasMapperUpdateListener()Is there anyMapperUpdateListenerregistered?NetworkProxylookupNetworkProxy(NetworkListener listener)LookupGrizzlyProxy, which corresponds to theNetworkListener.voidnotifyMapperUpdateListeners(NetworkListener networkListener, org.glassfish.grizzly.http.server.util.Mapper mapper)Notify allMapperUpdateListeners about update happened.ReentrantReadWriteLockobtainMapperLock()Returns HTTPMapperlock to prevent concurrent access to aMapperobject.voidpostConstruct()The component has been injected with any dependency and will be placed into commission by the subsystem.voidpreDestroy()The component is about to be removed from commissionvoidregisterEndpoint(Endpoint endpoint)Registers a new endpoint for the given context root at the given port number.voidregisterEndpoint(String contextRoot, InetAddress address, int port, Collection<String> vsServers, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container)Registers a new endpoint for the given context root at the given port number.voidregisterEndpoint(String contextRoot, Collection<String> vsServers, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container)Registers a new endpoint (proxy implementation) for a particular context-root.voidregisterEndpoint(String contextRoot, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container)Registers a new endpoint (proxy implementation) for a particular context-root.voidregisterEndpoint(String contextRoot, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container, String virtualServers)Registers a new endpoint (proxy implementation) for a particular context-root.protected voidregisterMonitoringStatsProviders()booleanremoveMapperUpdateListener(MapperUpdateListener listener)RemovesMapperUpdateListenerto listeners queue.booleanremoveNetworkProxy(NetworkProxy proxy)Remove the proxy from our list of proxies.booleanremoveNetworkProxy(String id)Remove the proxy from our list of proxies by id.booleanremoveNetworkProxy(NetworkListener listener)Remove the proxy from our list of proxies by listener.voidrestartNetworkListener(String networkListenerName, long timeout, TimeUnit timeUnit)RestartNetworkListener.voidrestartNetworkListener(NetworkListener networkListener, long timeout, TimeUnit timeUnit)RestartNetworkListener.voidunregisterEndpoint(String contextRoot)Removes the context-root from our list of endpoints.voidunregisterEndpoint(String contextRoot, ApplicationContainer app)Removes the context-root from our list of endpoints.protected voidunregisterMonitoringStatsProviders()
-
-
-
Method Detail
-
collect
public void collect(fish.payara.monitoring.collect.MonitoringDataCollector collector)
- Specified by:
collectin interfacefish.payara.monitoring.collect.MonitoringDataSource
-
addNetworkProxy
public void addNetworkProxy(NetworkProxy proxy)
Add the new proxy to our list of proxies.- Parameters:
proxy- new proxy to be added
-
removeNetworkProxy
public boolean removeNetworkProxy(NetworkListener listener)
Remove the proxy from our list of proxies by listener.- Parameters:
listener- removes the proxy associated with the specified listener- Returns:
- true, if proxy removed, false if no proxy was associated with the specified listener.
-
removeNetworkProxy
public boolean removeNetworkProxy(String id)
Remove the proxy from our list of proxies by id.- Returns:
- true, if proxy on specified port was removed, false if no proxy was associated with the port.
-
closeNetworkProxy
public boolean closeNetworkProxy(NetworkProxy proxy)
-
removeNetworkProxy
public boolean removeNetworkProxy(NetworkProxy proxy)
Remove the proxy from our list of proxies.- Returns:
- true, if proxy on specified port was removed, false otherwise.
-
lookupNetworkProxy
public NetworkProxy lookupNetworkProxy(NetworkListener listener)
LookupGrizzlyProxy, which corresponds to theNetworkListener.- Parameters:
listener-NetworkListener.- Returns:
GrizzlyProxy, or null, if correspondentGrizzlyProxywasn't found.
-
restartNetworkListener
public void restartNetworkListener(String networkListenerName, long timeout, TimeUnit timeUnit) throws IOException, TimeoutException
RestartNetworkListener.- Parameters:
networkListenerName-timeout- restart timeout, if timeout value is negative - then no timeout will be applied.timeUnit- restart timeout unit- Throws:
TimeoutException- thrown if timeout had expired before server succeeded to restartIOException
-
restartNetworkListener
public void restartNetworkListener(NetworkListener networkListener, long timeout, TimeUnit timeUnit) throws IOException, TimeoutException
RestartNetworkListener.- Parameters:
networkListener-NetworkListenertimeout- restart timeout, if timeout value is negative - then no timeout will be applied.timeUnit- restart timeout unit- Throws:
TimeoutException- thrown if timeout had expired before server succeeded to restartIOException
-
hasMapperUpdateListener
public boolean hasMapperUpdateListener()
Is there anyMapperUpdateListenerregistered?
-
addMapperUpdateListener
public boolean addMapperUpdateListener(MapperUpdateListener listener)
AddsMapperUpdateListenerto listeners queue.- Parameters:
listener- the listener to be added.- Returns:
- true, if listener was successfully added, or false otherwise.
-
removeMapperUpdateListener
public boolean removeMapperUpdateListener(MapperUpdateListener listener)
RemovesMapperUpdateListenerto listeners queue.- Parameters:
listener- the listener to be removed.- Returns:
- true, if listener was successfully removed, or false otherwise.
-
notifyMapperUpdateListeners
public void notifyMapperUpdateListeners(NetworkListener networkListener, org.glassfish.grizzly.http.server.util.Mapper mapper)
Notify allMapperUpdateListeners about update happened.- Parameters:
networkListener-NetworkListener, whichMappergot changedmapper- newMappervalue
-
obtainMapperLock
public ReentrantReadWriteLock obtainMapperLock()
Returns HTTPMapperlock to prevent concurrent access to aMapperobject.
-
getLogger
public Logger getLogger()
Gets the logger.- Returns:
- the logger
-
getHabitat
public org.glassfish.hk2.api.ServiceLocator getHabitat()
Gets the habitat.- Returns:
- the habitat
-
getMonitoring
public GrizzlyMonitoring getMonitoring()
-
event
public void event(EventListener.Event event)
Method is invoked each time Glassfish state changes.- Specified by:
eventin interfaceEventListener
-
postConstruct
public void postConstruct()
The component has been injected with any dependency and will be placed into commission by the subsystem.- Specified by:
postConstructin interfaceorg.glassfish.hk2.api.PostConstruct
-
getRealPort
public int getRealPort(NetworkListener listener)
-
getFutures
public List<Future<Result<Thread>>> getFutures()
- Specified by:
getFuturesin interfaceFutureProvider<Result<Thread>>
-
createNetworkProxy
public Future<Result<Thread>> createNetworkProxy(NetworkListener listener)
-
preDestroy
public void preDestroy()
The component is about to be removed from commission- Specified by:
preDestroyin interfaceorg.glassfish.hk2.api.PreDestroy
-
registerEndpoint
public void registerEndpoint(String contextRoot, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container) throws EndpointRegistrationException
Description copied from interface:RequestDispatcherRegisters a new endpoint (proxy implementation) for a particular context-root. All request coming with the context root will be dispatched to the proxy instance passed in.- Specified by:
registerEndpointin interfaceRequestDispatcher- Parameters:
contextRoot- for the proxyendpointAdapter- servicing requests.- Throws:
EndpointRegistrationException
-
registerEndpoint
public void registerEndpoint(String contextRoot, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container, String virtualServers) throws EndpointRegistrationException
Description copied from interface:RequestDispatcherRegisters a new endpoint (proxy implementation) for a particular context-root. All request coming with the context root will be dispatched to the proxy instance passed in.- Specified by:
registerEndpointin interfaceRequestDispatcher- Parameters:
contextRoot- for the proxyendpointAdapter- servicing requests.virtualServers- comma separated list of the virtual servers- Throws:
EndpointRegistrationException
-
registerEndpoint
public void registerEndpoint(String contextRoot, Collection<String> vsServers, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container) throws EndpointRegistrationException
Description copied from interface:RequestDispatcherRegisters a new endpoint (proxy implementation) for a particular context-root. All request coming with the context root will be dispatched to the proxy instance passed in.- Specified by:
registerEndpointin interfaceRequestDispatcher- Parameters:
contextRoot- for the proxyendpointAdapter- servicing requests.- Throws:
EndpointRegistrationException
-
registerEndpoint
public void registerEndpoint(String contextRoot, InetAddress address, int port, Collection<String> vsServers, org.glassfish.grizzly.http.server.HttpHandler endpointAdapter, ApplicationContainer container) throws EndpointRegistrationException
Registers a new endpoint for the given context root at the given port number.- Specified by:
registerEndpointin interfaceRequestDispatcher- Throws:
EndpointRegistrationException
-
registerEndpoint
public void registerEndpoint(Endpoint endpoint) throws EndpointRegistrationException
Registers a new endpoint for the given context root at the given port number.- Throws:
EndpointRegistrationException
-
unregisterEndpoint
public void unregisterEndpoint(String contextRoot) throws EndpointRegistrationException
Removes the context-root from our list of endpoints.- Specified by:
unregisterEndpointin interfaceRequestDispatcher- Throws:
EndpointRegistrationException
-
unregisterEndpoint
public void unregisterEndpoint(String contextRoot, ApplicationContainer app) throws EndpointRegistrationException
Removes the context-root from our list of endpoints.- Specified by:
unregisterEndpointin interfaceRequestDispatcher- Throws:
EndpointRegistrationException
-
registerMonitoringStatsProviders
protected void registerMonitoringStatsProviders()
-
unregisterMonitoringStatsProviders
protected void unregisterMonitoringStatsProviders()
-
-