Initial commit from SVN.

This commit is contained in:
wcrisman
2014-05-30 10:31:51 -07:00
commit b45e56b890
1968 changed files with 370949 additions and 0 deletions

View File

@@ -0,0 +1,189 @@
/*
* Copyright (c) 2009 Declarative Engineering LLC.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Declarative Engineering LLC
* verson 1 which accompanies this distribution, and is available at
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
*/
package com.foundation.web.interfaces;
import java.io.File;
import javax.net.ssl.SSLContext;
public interface IWebApplication {
/**
* Gets the web application's name, which must be unique within a bundle of web applications deployed to a server as a single zip.
* @return The name used to distinguish this web application from others in a bundle when reloading the bundle. This allows the old web application to be mapped to the new one, so it should generally not change once set.
*/
public String getName();
/**
* Gets whether responses should be compressed by default when possible. Certain resources that compress poorly will of course ignore this directive.
* @return Whether responses that can be compressed should be by default.
*/
public boolean getCompressResponses();
/**
* Gets the package name portion to prepend to a java resource call when locating the java class.
* @return The package fragment ending with a '.' or an empty string if no package prepending is required.
*/
public String getDefaultPackageName();
/**
* Sets the cache cut off size.
* @param cacheCutoffSize The largest resource to cache (in bytes). A value of zero or less will turn off caching.
*/
public void setCacheCuttoffSize(long cacheCutoffSize);
/**
* Clears all cached resources.
*/
public void clearCaches();
/**
* Determines whether the server allows resource caching.
* @return Whether resource caching occurs on the server.
*/
public boolean isCachingResources();
/**
* Gets the maximum size of a cached resource.
* @return The size limit for resources that can be cached.
*/
public long getMaxCachedResourceSize();
/**
* Gets the previously cached resource.
* @param canonicalPath The path to the resource whose cache is being retrieved.
* @return The resource cached, or null if the resource hasn't been cached or if the memory was reclaimed by GC.
*/
public ICachedResource getCachedResource(String canonicalPath);
/**
* Caches the file reference and the contents for later access.
* @param canonicalPath The path used as the key for caching. This should always be the passed file's canonical path.
* @param file The file reference being cached.
* @param contents The contents of the file being cached.
*/
public void setCachedResource(String canonicalPath, File file, byte[] contents);
/**
* Gets the mime type provider used by this server.
* @return The mime type provider that supplies mime type names for a given file extension.
*/
public IMimeTypeProvider getMimeTypeProvider();
/**
* Gets the set of domains that this application services.
* @return The set of all domains serviced by the application. For example: <code>new String[] {"www.mydomain.com"}</code>
*/
public String[] getDomains();
/**
* Gets the set of services that this application uses.
* A service is mapped to a ServiceListener in the WebServer, which controls access to a server socket in the underlying system.
* Service names are application dependant and must match the names used when setting up the web server.
* Common service names are: "HTTP" and "SSL".
* @return The names of services this application will listen to.
*/
public String[] getServices();
/**
* Gets the SSL Context for the given domain.
* @param domain The domain whose SSL context is required.
* @return The SSL Context used to create an SSL Engine specific to the domain for this application. This may be null if the domain doesn't support SSL access.
*/
public SSLContext getSslContext(String domain);
/**
* Gets the response content for the given error code.
* @return The response content.
*/
public IContent getErrorContent(int errorCode);
/**
* Gets the response header for the given error code.
* @return The response header.
*/
public String getErrorHeader(int errorCode);
/**
* Gets the base directory containing all the resources.
* @return The base resource directory.
*/
public File getBaseDirectory();
/**
* Gets the optional, externally located base *web* directory for the web application. The files located here are not part of the webapp's distribution.
* @return The external base directory, or null if not used.
*/
public File getExternalBaseDirectory();
/**
* Gets the optional, externally located base cache directory for the web application. The files located here are not part of the webapp's distribution and must be fully re-creatable.
* @return The cache base directory, or null if not used.
*/
public File getCacheBaseDirectory();
/**
* Gets the container for this application.
* @return The hosting container. Once this is set, the applicaton should become immutable.
*/
public IWebApplicationContainer getWebApplicationContainer();
/**
* Determines the maximum size (in bytes) allowed by incoming messages for this application given the header for the request.
* @param request The request whose header has been fully loaded, but whose message body has not yet been loaded.
* @param sessionData The session data assigned by the application. This might be null if the application hasn't assigned a session data object to the connection yet.
* @param secureSessionData The secure session data assigned by the application, and only passed if the request is made over a secure socket.
* @return The maximum (message body) size allowed for incoming messages for this application. The header of the request may be taken into consideration (whether they are logged in, etc).
*/
public int getMaxMessageSize(IRequest request, Object sessionData, Object secureSessionData);
/**
* Completes the initialization of the web application, locking the application to any future setup related changes.
* @param container The container for this web application.
*/
public void completeInitialization(IWebApplicationContainer container);
/**
* Serializes the sessions to a temporary file. Used to reload the web application on the fly without losing session information.
* @return The file containing the session data which can be later deserialized by a new incarnation of this web application.
*/
public File serializeSessions();
/**
* Deserializes the sessions from a temporary file. Used to reload the web application on the fly without losing session information.
* @param sessionFile The file containing the session data.
* @return Whether the session data was succesfully deserialized.
*/
public boolean deserializeSessions(File sessionFile);
/**
* Gets a session given the session identifier.
* @param sessionId The identifier of the previously created session.
* @return The session metadata.
*/
public ISession getSession(String sessionId);
/**
* Requests that the web application re-create the session (session data & secure session data) from the given session ID.
* @param sessionId The identifier of the previously created session.
* @return The session if it was re-creatable.
*/
public ISession recreateSession(String sessionId);
/**
* Creates a new session.
* @param requestHandler The request handler that can be used to setup a reflection context.
* @return The newly created and indexed session.
*/
public ISession createSession();
/**
* Creates a new secure session.
* @param session The session that we are creating a secure session for.
* @return The newly created and indexed secure session.
*/
public void createSecureSession(ISession session);
/**
* Processes a request from the client associated with the session. The result is placed in the response object.
* @param request The request metadata.
* @param response The response metadata.
* @param session The non-secure session. This may be null if the application does not use a session object.
* @param isSecure Whether the request was made over a secure connection and provided the correct secure id.
* @param clientHadBadSession Whether the client's request contained a session reference that could not be found on the server.
*/
public void processRequest(IRequest request, IResponse response, ISession session, boolean isSecure, boolean clientHadBadSession);
/**
* Releases any resources associated with the web server application.
*/
public void release();
/**
* Opens a connection to the user's OpenID authority and collects the information required to begin the open id validation process.
* @param userId The user's ID which is used both to identify the user to the authority performing the validation, but also to identify which authority will be used. This is currently assumed to be an email address.
* @return The JSON string containing the key value pairs used to perform the next step in the validation.
*/
public String initiateOpenIdAuth(String userId);
/**
* Determines whether the web server, when processing an incoming request, should retain every byte of the request. This can be useful for debugging, but even more for forwarding certain types of messages to another process without having to recreate the message.
* @param request The request being made by the client. Only the header for the request has been read at this point - the body is missing. This can be used to determine when to retain the message.
* @return Whether to retain the exact bytes received by the web server for this request.
*/
public boolean retainWholeRequestBuffer(IRequest request);
}//IWebServerApplication//