Package com.sun.enterprise.v3.admin
Class AdminAdapter
- java.lang.Object
-
- org.glassfish.grizzly.http.server.HttpHandler
-
- org.glassfish.grizzly.http.server.StaticHttpHandlerBase
-
- org.glassfish.grizzly.http.server.StaticHttpHandler
-
- com.sun.enterprise.v3.admin.AdminAdapter
-
- All Implemented Interfaces:
Adapter
,EventListener
,org.glassfish.hk2.api.PostConstruct
- Direct Known Subclasses:
PrivateAdminAdapter
,PublicAdminAdapter
public abstract class AdminAdapter extends org.glassfish.grizzly.http.server.StaticHttpHandler implements Adapter, org.glassfish.hk2.api.PostConstruct, EventListener
Listen to admin commands...- Author:
- dochez
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.glassfish.api.event.EventListener
EventListener.Event<T>
-
-
Field Summary
Fields Modifier and Type Field Description static String
ASADMIN_PATH
static int
MAX_AGE
static String
PREFIX_URI
static String
SESSION_COOKIE_NAME
static String
VS_NAME
-
Constructor Summary
Constructors Modifier Constructor Description protected
AdminAdapter(Class<? extends Privacy> privacyClass)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
afterService(org.glassfish.grizzly.http.server.Request req, org.glassfish.grizzly.http.server.Response res)
Finish the response and recycle the request/response tokens.AdminAccessController.Access
authenticate(org.glassfish.grizzly.http.server.Request req)
String
createSessionId()
This will create a new sessionId and add the server name as a jvmroute information to itvoid
event(EventListener.Event event)
Process a Glassfish/Payara eventvoid
fireAdapterEvent(String type, Object data)
Notify all container event listeners that a particular event has occurred for this Adapter.String
getCookieHeader(org.glassfish.grizzly.http.server.Request req)
This will create a unique SessionId, Max-Age,Version,Path to be added to the Set-Cookie headerorg.glassfish.grizzly.http.server.HttpHandler
getHttpService()
Get the underlying GrizzlyHttpHandler
.String[]
getJSESSIONIDHeaders(org.glassfish.grizzly.http.server.Request req)
This method will return the Cookie header with name JSESSIONID="..."InetAddress
getListenAddress()
int
getListenPort()
Returns the listener port for this adapterstatic String[]
getUserPassword(org.glassfish.grizzly.http.server.Request req)
A convenience method to extract user name from a request.List<String>
getVirtualServers()
Returns the virtual servers supported by this adapterboolean
hasCookieHeader(org.glassfish.grizzly.http.server.Request req)
This method checks if the request has a Cookie header and if the instance name serving the request is the same as the jvmRoute informationboolean
isRegistered()
Checks whether this adapter has been registered as a network endpoint.boolean
isSingleInstanceCommand(String commandName)
This method checks if this command has @ExecuteOn annotation with RuntimeType.SINGle_INSTANCEvoid
onMissingResource(org.glassfish.grizzly.http.server.Request req, org.glassfish.grizzly.http.server.Response res)
Call the service method, and notify all listenersvoid
postConstruct()
void
setRegistered(boolean isRegistered)
Marks this adapter as having been registered or unregistered as a network endpointprotected abstract boolean
validatePrivacy(AdminCommand command)
-
Methods inherited from class org.glassfish.grizzly.http.server.StaticHttpHandler
addDocRoot, addDocRoot, getDefaultDocRoot, getDocRoots, handle, isDirectorySlashOff, removeDocRoot, setDirectorySlashOff
-
Methods inherited from class org.glassfish.grizzly.http.server.StaticHttpHandlerBase
addCachingHeaders, addToFileCache, getRelativeURI, isFileCacheEnabled, lookupFileCache, pickupContentType, sendFile, service, setFileCacheEnabled
-
Methods inherited from class org.glassfish.grizzly.http.server.HttpHandler
destroy, getErrorPageGenerator, getName, getRequestExecutorProvider, getRequestURIEncoding, getSessionCookieName, getSessionManager, isAllowCustomStatusMessage, isAllowEncodedSlash, sendAcknowledgment, setAllowCustomStatusMessage, setAllowEncodedSlash, setDecodeUrl, setDispatcherHelper, setRequestURIEncoding, setRequestURIEncoding, start, updatePaths
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.glassfish.api.container.Adapter
getContextRoot
-
-
-
-
Field Detail
-
VS_NAME
public static final String VS_NAME
- See Also:
- Constant Field Values
-
PREFIX_URI
public static final String PREFIX_URI
- See Also:
- Constant Field Values
-
SESSION_COOKIE_NAME
public static final String SESSION_COOKIE_NAME
- See Also:
- Constant Field Values
-
MAX_AGE
public static final int MAX_AGE
- See Also:
- Constant Field Values
-
ASADMIN_PATH
public static final String ASADMIN_PATH
- See Also:
- Constant Field Values
-
-
Method Detail
-
getHttpService
public final org.glassfish.grizzly.http.server.HttpHandler getHttpService()
Description copied from interface:Adapter
Get the underlying GrizzlyHttpHandler
.- Specified by:
getHttpService
in interfaceAdapter
- Returns:
- the underlying Grizzly
HttpHandler
.
-
postConstruct
public void postConstruct()
- Specified by:
postConstruct
in interfaceorg.glassfish.hk2.api.PostConstruct
-
onMissingResource
public void onMissingResource(org.glassfish.grizzly.http.server.Request req, org.glassfish.grizzly.http.server.Response res)
Call the service method, and notify all listeners- Overrides:
onMissingResource
in classorg.glassfish.grizzly.http.server.StaticHttpHandlerBase
- Throws:
RuntimeException
- if an error happens during handling of the request. Common errors are:- IOException if an input/output error occurs and we are processing an included servlet (otherwise it is swallowed and handled by the top level error handler mechanism)
- ServletException if a servlet throws an exception and we are processing an included servlet (otherwise it is swallowed and handled by the top level error handler mechanism)
-
hasCookieHeader
public boolean hasCookieHeader(org.glassfish.grizzly.http.server.Request req)
This method checks if the request has a Cookie header and if the instance name serving the request is the same as the jvmRoute information- Parameters:
req
- Request to examine the Cookie header- Returns:
- true if the Cookie header is set and the jvmRoute information is the same as the instance serving the request , false otherwise
-
getJSESSIONIDHeaders
public String[] getJSESSIONIDHeaders(org.glassfish.grizzly.http.server.Request req)
This method will return the Cookie header with name JSESSIONID="..."- Parameters:
req
- The request which may contain cookie headers- Returns:
- cookie header
-
isSingleInstanceCommand
public boolean isSingleInstanceCommand(String commandName)
This method checks if this command has @ExecuteOn annotation with RuntimeType.SINGle_INSTANCE- Parameters:
commandName
- the command which is executed- Returns:
- true only if @ExecuteOn has RuntimeType.SINGLE_INSTANCE false for other cases
-
getCookieHeader
public String getCookieHeader(org.glassfish.grizzly.http.server.Request req)
This will create a unique SessionId, Max-Age,Version,Path to be added to the Set-Cookie header- Returns:
- Set-Cookie2 header
-
createSessionId
public String createSessionId()
This will create a new sessionId and add the server name as a jvmroute information to it- Returns:
- String to be used for the JSESSIONID Set-Cookie2 header
-
authenticate
public AdminAccessController.Access authenticate(org.glassfish.grizzly.http.server.Request req) throws Exception
- Throws:
Exception
-
getUserPassword
public static String[] getUserPassword(org.glassfish.grizzly.http.server.Request req) throws IOException
A convenience method to extract user name from a request. It assumes the HTTP Basic Auth.- Parameters:
req
- instance of Request- Returns:
- a two-element string array. If Auth header exists and can be correctly decoded, returns the user name and password as the two elements. If any error occurs or if the header does not exist, returns an array with two blank strings. Never returns a null.
- Throws:
IOException
- in case of error with decoding the buffer (HTTP basic auth)
-
validatePrivacy
protected abstract boolean validatePrivacy(AdminCommand command)
-
afterService
public void afterService(org.glassfish.grizzly.http.server.Request req, org.glassfish.grizzly.http.server.Response res) throws Exception
Finish the response and recycle the request/response tokens. Base on the connection header, the underlying socket transport will be closed- Throws:
Exception
-
fireAdapterEvent
public void fireAdapterEvent(String type, Object data)
Notify all container event listeners that a particular event has occurred for this Adapter. The default implementation performs this notification synchronously using the calling thread.- Parameters:
type
- Event typedata
- Event data
-
event
public void event(EventListener.Event event)
Description copied from interface:EventListener
Process a Glassfish/Payara event- Specified by:
event
in interfaceEventListener
-
getListenPort
public int getListenPort()
Description copied from interface:Adapter
Returns the listener port for this adapter- Specified by:
getListenPort
in interfaceAdapter
- Returns:
- listener port
-
getListenAddress
public InetAddress getListenAddress()
- Specified by:
getListenAddress
in interfaceAdapter
- Returns:
- the
InetAddress
on which this adapter is listening
-
getVirtualServers
public List<String> getVirtualServers()
Description copied from interface:Adapter
Returns the virtual servers supported by this adapter- Specified by:
getVirtualServers
in interfaceAdapter
- Returns:
- List<String> the virtual server list supported by the adapter
-
isRegistered
public boolean isRegistered()
Checks whether this adapter has been registered as a network endpoint.- Specified by:
isRegistered
in interfaceAdapter
-
setRegistered
public void setRegistered(boolean isRegistered)
Marks this adapter as having been registered or unregistered as a network endpoint- Specified by:
setRegistered
in interfaceAdapter
-
-