com.sun.enterprise.v3.admin
Class AdminAdapter

java.lang.Object
  extended by org.glassfish.grizzly.http.server.HttpHandler
      extended by org.glassfish.grizzly.http.server.StaticHttpHandler
          extended by com.sun.enterprise.v3.admin.AdminAdapter
All Implemented Interfaces:
Adapter, EventListener, org.glassfish.hk2.PostConstruct
Direct Known Subclasses:
PrivateAdminAdapter, PublicAdminAdapter

public abstract class AdminAdapter
extends org.glassfish.grizzly.http.server.StaticHttpHandler
implements Adapter, org.jvnet.hk2.component.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
static String PREFIX_URI
           
static String VS_NAME
           
 
Fields inherited from class org.glassfish.grizzly.http.server.StaticHttpHandler
docRoots
 
Constructor Summary
protected AdminAdapter(Class<? extends Privacy> privacyClass)
           
 
Method Summary
 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)
           
 void event(EventListener.Event event)
           
 void fireAdapterEvent(String type, Object data)
          Notify all container event listeners that a particular event has occurred for this Adapter.
 org.glassfish.grizzly.http.server.HttpHandler getHttpService()
           
 InetAddress getListenAddress()
           
 int getListenPort()
           
static String[] getUserPassword(org.glassfish.grizzly.http.server.Request req)
          A convenience method to extract user name from a request.
 List<String> getVirtualServers()
           
 boolean isRegistered()
          Checks whether this adapter has been registered as a network endpoint.
 void onMissingResource(org.glassfish.grizzly.http.server.Request req, org.glassfish.grizzly.http.server.Response res)
          Call the service method, and notify all listeners
 void postConstruct()
           
 void setRegistered(boolean isRegistered)
          Marks this adapter as having been registered or unregistered as a network endpoint
protected abstract  boolean validatePrivacy(AdminCommand command)
           
 
Methods inherited from class org.glassfish.grizzly.http.server.StaticHttpHandler
addDocRoot, addDocRoot, addToFileCache, getDefaultDocRoot, getDocRoots, getRelativeURI, handle, isFileCacheEnabled, removeDocRoot, sendFile, service, setFileCacheEnabled
 
Methods inherited from class org.glassfish.grizzly.http.server.HttpHandler
customizedErrorPage, destroy, doHandle, getName, getRequestURIEncoding, isAllowCustomStatusMessage, isAllowEncodedSlash, sendAcknowledgment, setAllowCustomStatusMessage, setAllowEncodedSlash, setDecodeUrl, setDispatcherHelper, setRequestURIEncoding, setRequestURIEncoding, start, updateContextPath
 
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
Constructor Detail

AdminAdapter

protected AdminAdapter(Class<? extends Privacy> privacyClass)
Method Detail

getHttpService

public final org.glassfish.grizzly.http.server.HttpHandler getHttpService()
Specified by:
getHttpService in interface Adapter

postConstruct

public void postConstruct()
Specified by:
postConstruct in interface org.glassfish.hk2.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 class org.glassfish.grizzly.http.server.StaticHttpHandler
Throws:
Exception - 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)
Tomcat should be able to handle and log any other exception ( including runtime exceptions )

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 type
data - Event data

event

public void event(EventListener.Event event)
Specified by:
event in interface EventListener

getListenPort

public int getListenPort()
Specified by:
getListenPort in interface Adapter

getListenAddress

public InetAddress getListenAddress()
Specified by:
getListenAddress in interface Adapter

getVirtualServers

public List<String> getVirtualServers()
Specified by:
getVirtualServers in interface Adapter

isRegistered

public boolean isRegistered()
Checks whether this adapter has been registered as a network endpoint.

Specified by:
isRegistered in interface Adapter

setRegistered

public void setRegistered(boolean isRegistered)
Marks this adapter as having been registered or unregistered as a network endpoint

Specified by:
setRegistered in interface Adapter


Copyright © 2012. All Rights Reserved.