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,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Foundation Web Interfaces</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,17 @@
package com.foundation.web.interfaces;
/**
* Allows the application to log via the web server's UI.
*/
public interface IAppLog {
public static final int TYPE_ERROR = 0;
public static final int TYPE_WARNING = 1;
public static final int TYPE_INFORMATION = 2;
/**
* Handles logging a note and/or exception from a web application via the web server's UI.
* @param type The log type code.
* @param note String An optional note to be logged. If an exception is also specified, then the note should be bundled with the exception in the log output.
* @param exception Throwable An optional exception to be logged.
*/
public void log(int type, String note, Throwable exception);
}//IAppLog//

View File

@@ -0,0 +1,20 @@
/*
* Copyright (c) 2008,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;
public interface IBadSessionHandler {
/**
* Processes a bad session.
* @param request The request object.
* @param response The response object.
* @param session The session object.
* @param wasLoggedIn Whether the client thought it was logged in in the previous session.
* @return Whether the request should not be processed. The response will still be processed, so this handler can provide a response.
*/
public boolean process(IRequest request, IResponse response, ISession session, boolean wasLoggedIn);
}//IBadSessionHandler//

View File

@@ -0,0 +1,21 @@
package com.foundation.web.interfaces;
import java.io.File;
public interface ICachedResource {
/**
* Gets the file associated with the cache.
* @return The file from which the cache was created.
*/
public File getFile();
/**
* Gets the cache.
* @return The resource data that is being cached.
*/
public byte[] getContents();
/**
* Gets the timestamp for the last modification to the file.
* @return The file's last modification timestamp at the time the file contents were cached.
*/
public long getLastModified();
}//ICachedResource//

View File

@@ -0,0 +1,106 @@
/*
* Copyright (c) 2008,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.nio.ByteBuffer;
import java.util.Date;
public interface IContent {
/** Returned by the get(ByteBuffer) method when the caller must wait for more content to become available. */
public static final int CONTENT_PENDING = 0;
/** Returned by the get(ByteBuffer) method when there is no more content to get. */
public static final int CONTENT_END = -1;
/** Tells caching mechanisms to always check the server for freshness before using the cache. */
public static final String CACHE_CONTROL_SEPERATOR = ",";
/** Tells caching mechanisms to always check the server for freshness before using the cache. */
public static final String CACHE_CONTROL_NO_CACHE = "no-cache";
/** Tells caching mechanisms not to ever cache under any circumstances. */
public static final String CACHE_CONTROL_NO_STORE = "no-store";
/** Tells caching mechanisms not to use the cache longer than X seconds, where X is the number following the directive. */
public static final String CACHE_CONTROL_MAX_AGE = "max-age=";
/** Used when setting up a mime type to specify that the content of this type requires caching mechanisms to cache for up to 30 minutes. */
public static final Integer CACHE_LENGTH_DEFAULT = new Integer(IMimeType.CACHE_LENGTH_DEFAULT);
/** Used when setting up a mime type to specify that the content of this type requires caching mechanisms to never store the content in their cache. */
public static final Integer CACHE_LENGTH_NEVER_CACHE = new Integer(IMimeType.CACHE_LENGTH_NEVER_CACHE);
/** Used when setting up a mime type to specify that the content of this type requires caching mechanisms to always check for freshness with the server before using he cache. */
public static final Integer CACHE_LENGTH_ALWAYS_TEST = new Integer(IMimeType.CACHE_LENGTH_ALWAYS_TEST);
/**
* Gets the size of the content in bytes.
* @return The number of bytes of content.
*/
public long getSize();
/**
* Gets the index of the first byte within the resource that will be returned (inclusive).
* @return
*/
public long getStart();
/**
* Gets the last byte of within the resource that will be returned (inclusive).
* @return
*/
public long getEnd();
/**
* Gets the content by filling the buffer.
* @param buffer The buffer to be filled with the next frame of content.
* @return The number of bytes retrieved, or one of the CONTENT_xxx identifiers defined by this interface (IContent). Note: The CONTENT_xxx identifiers conform to the standards of most streams including socket channels/streams.
*/
public int get(ByteBuffer buffer);
/**
* Resets the content so that it can be retrieved again.
*/
public void reset();
/**
* Releases any resource associated with the content.
*/
public void release();
/**
* Gets the date that the content was last modified.
* @return The last modified date, or null if the content is dynamic and should not be cached.
*/
public Date getLastModifiedDate();
/**
* Gets the mime type for the content.
* @param provider The mime type name provider that may be used to identify the content's mime type.
* @return The content's mime type.
*/
public IMimeType getMimeType(IMimeTypeProvider provider);
/**
* Gets the custom cache directive to be used when sending the response to the client.
* @return The directive indicating to the client whether the response should be cached, or null if the default behavior should be used (depends on the MimeType or if provided, the cacheLength attribute).
*/
public String getCacheDirective();
/**
* Gets the default expires date directive to be used when sending the response to the client.
* @return The date indicating to the client when any cache should become invalid, or null if the default behavior should be used (no date).
*/
public Date getExpiresDirective();
/**
* Gets the cache length in terms of seconds, or one of the CACHE_LENGTH_xxx identifiers defined by IContent.
* <p>Note: This is an easier way of controlling caching than a custom CacheDirective. The custom cache directive will override this if provided.</p>
* @return The number of seconds the client is allowed to cache the content, null if the mime type's default cache controls should be used, or one of the CACHE_LENGTH_xxx identifiers indicating how caching should be handled.
*/
public Integer getCacheLength();
/**
* Gets whether the content should be downloaded versus displayed in the browser.
* @return Whether the content should be downloaded, or null if the default behavior should occur based on the mime type.
*/
public Boolean getIsDownloaded();
/**
* Gets the optional file name the client should suggest when the content is downloaded to a file (versus being displayed in the browser).
* @return The name of the file including the extension.
*/
public String getDownloadName();
/**
* Sets the optional file name the client should suggest when the content is downloaded to a file (versus being displayed in the browser).
* @param downloadName The name of the file including the extension.
*/
public void setDownloadName(String downloadName);
}//IContent//

View File

@@ -0,0 +1,30 @@
package com.foundation.web.interfaces;
public interface IMimeType {
/** Used when setting up a mime type to specify that the content of this type requires caching mechanisms to cache for up to 30 minutes. */
public static final int CACHE_LENGTH_DEFAULT = 1800;
/** Used when setting up a mime type to specify that the content of this type requires caching mechanisms to never store the content in their cache. */
public static final int CACHE_LENGTH_NEVER_CACHE = -1;
/** Used when setting up a mime type to specify that the content of this type requires caching mechanisms to always check for freshness with the server before using the cache. */
public static final int CACHE_LENGTH_ALWAYS_TEST = 0;
/**
* Gets the official mime type name.
* @return The mime name recongized by browsers.
*/
public String getMimeName();
/**
* Gets the default number of seconds to cache the content.
* @return The number of seconds a cache should retain the content, or one of the CACHE_CONTROL_xxx identifiers defined in this class.
*/
public int getDefaultCacheLength();
/**
* Wether content of this type is normally downloaded versus displayed in the browser.
* @return Whether the content should be downloaded to the client (ie: open a save dialog).
*/
public boolean isDownloaded();
/**
* Whether the data is normally compressable (there is normally a reasonable size difference when the media is compressed using a general compression algorithm such as gzip - eg: jpeg's are not because they are compressed by default).
* @return Whether the data of this type should be compressed when possible.
*/
public boolean isCompressable();
}//MimeType//

View File

@@ -0,0 +1,25 @@
/*
* Copyright (c) 2008,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;
public interface IMimeTypeProvider {
/**
* Gets the mime type name for the given file.
* @param file The file whose mime type is required.
* @return The mime type.
*/
public IMimeType getMimeType(File file);
/**
* Gets the mime type name for the given file extension.
* @param extension The file extension (without the dot).
* @return The mime type.
*/
public IMimeType getMimeType(String extension);
}//IMimeTypeProvider//

View File

@@ -0,0 +1,14 @@
package com.foundation.web.interfaces;
public interface IPassThroughDomain extends IWebApplication {
/**
* Gets the address of the remote process that will receive all content from the client.
* @return The address on which to connect to the remote process.
*/
public String getAddress();
/**
* Gets the port of the remote process.
* @return The port on which to connect to the remote process.
*/
public int getPort();
}//IPassThroughDomain//

View File

@@ -0,0 +1,13 @@
package com.foundation.web.interfaces;
/**
* Used to complete the reload operation.
*/
public interface IReloadOperation {
/**
* Called after updating the web application on the file system. Will attempt to restore the sessions for the old web application.
* @param application The new web application. This should be null if it should be removed instead.
* @return False only if unable to restore the session state. The web application will always be brought back up if at all possible. If it isn't possible to bring the application up then an exception will be thrown.
*/
public boolean complete(IWebApplication application);
}//IReloadOperation//

View File

@@ -0,0 +1,308 @@
/*
* Copyright (c) 2008,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.InputStream;
import java.nio.ByteBuffer;
import java.util.Date;
public interface IRequest {
public static final int TYPE_GET = 0;
public static final int TYPE_POST = 1;
public static final int TYPE_PUT = 2;
public static final int TYPE_HEAD = 3; //HEAD is the same as GET, but the caller is requesting header only info. The response shouldn't contain a message body - so no content is sent.//
public static final int TYPE_OPTIONS = 4;
//Can find info on web dav protocol at http://en.wikipedia.org/wiki/PROPFIND.//
public static final int TYPE_WEBDAV_PROPFIND = 5;
public static final int TYPE_WEBDAV_PROPPATCH = 6;
public static final int TYPE_WEBDAV_MKCOL = 7;
public static final int TYPE_WEBDAV_COPY = 8;
public static final int TYPE_WEBDAV_MOVE = 9;
public static final int TYPE_WEBDAV_LOCK = 10;
public static final int TYPE_WEBDAV_UNLOCK = 11;
/** The content type code for application/x-www-form-urlencoded. */
public static final int CONTENT_TYPE_URL_ENCODED = 0;
/** The content type code for multipart/form-data. */
public static final int CONTENT_TYPE_MULTI_PART_FORM_DATA = 1;
/** The content type code for application/xml or text/xml. */
public static final int CONTENT_TYPE_XML = 2;
/** The content type code for customized content such as application/pdf. */
public static final int CONTENT_TYPE_CUSTOM = 3;
/**
* Defines the metadata interface for a single part of a multi part request.
*/
public interface IContentPart {
/**
* Gets the content dispositon type.
* @return The type of content disposition (expect "form-data").
*/
public String getContentDisposition();
/**
* Gets the name if provided in the content disposition attributes.
* @return The name of the part (usually the form input's name).
*/
public String getName();
/**
* Gets the set of parameter keys.
* @return The parameter keys.
*/
public String[] getParameterKeys();
/**
* Gets the value for the associated key.
* @param key The key of the parameter whose value is to be retrieved.
* @return The value, or null if the parameter was not part of the request. The result if non-null will be a String if the contentTypeCode == CONTENT_TYPE_URL_ENCODED, otherwise it will be an IContentPart instance.
*/
public String getParameter(String key);
/**
* Gets the content type.
* @return The type of the content.
*/
public String getContentType();
/**
* Gets the part's data length.
* @return The number of data bytes for this part within the request's data.
*/
public long getContentSize();
/**
* Gets the content of the message.
* @return The content stream. The formatting depends on the content type.
*/
public InputStream getContent();
}//IContentPart//
/**
* Gets the header text as received by the server.
* @return The exact text for the request header.
*/
public String getHeaderText();
/**
* Gets the web application associated with the request.
* <p>Note for web server internal use: This should not be called outside the increment and decrement counter calls on the application container.</p>
* @return The web application associated with the request.
*/
public IWebApplication getWebApplication();
/**
* Gets the first line in the header which is the request sent by the client.
* @return The request line as received by the server.
*/
public String getHeaderRequest();
/**
* Gets the ordered list of header field names.
* @return The list of field names used in the header in order received.
*/
public String[] getHeaderFieldNames();
/**
* Gets the header field value for the given name.
* @param fieldName The field name. See getHeaderFieldNames().
* @return The field value for the given field name, or null if the key is not used.
*/
public String getHeaderFieldValue(String fieldName);
/**
* Gets the IP address of the requesting machine.
* @return The requester's IP address.
*/
public String getAddress();
/**
* Gets the set of cookie keys.
* @return The cookie keys.
*/
public String[] getCookieKeys();
/**
* Gets the value for the associated key.
* @param key The key of the cookie whose value is to be retrieved.
* @return The cookie value, or null if the cookie was not part of the request.
*/
public String getCookie(String key);
/**
* Gets the set of parameter keys.
* @return The parameter keys.
*/
public String[] getParameterKeys();
/**
* Gets the value for the associated key.
* @param key The key of the parameter whose value is to be retrieved.
* @return The value, or null if the parameter was not part of the request. The result if non-null will be a String or IList if the contentTypeCode == CONTENT_TYPE_URL_ENCODED, otherwise it will be an IContentPart instance. IList instances will be used to hold multiple values with the same key.
*/
public Object getParameter(String key);
/**
* Gets the value for the associated key as a string.
* @param key The key of the parameter whose value is to be retrieved.
* @param defaultValue The value to use if the parameter doesn't exist, or if there is a conversion error.
* @return The value.
*/
public String getParameterAsString(String key, String defaultValue);
/**
* Gets the value for the associated key as a string.
* @param key The key of the parameter whose value is to be retrieved.
* @param defaultValue The value to use if the parameter doesn't exist, or if there is a conversion error.
* @param emptySameAsNull Whether an empty string is the same as null.
* @param trim Whether the value should be trimed prior to being returned or checked for being empty.
* @return The value.
*/
public String getParameterAsString(String key, String defaultValue, boolean emptySameAsNull, boolean trim);
/**
* Gets the value for the associated key as an integer.
* @param key The key of the parameter whose value is to be retrieved.
* @param defaultValue The value to use if the parameter doesn't exist, or if there is a conversion error.
* @return The value.
*/
public Integer getParameterAsInteger(String key, Integer defaultValue);
/**
* Gets the value for the associated key as a long number.
* @param key The key of the parameter whose value is to be retrieved.
* @param defaultValue The value to use if the parameter doesn't exist, or if there is a conversion error.
* @return The value.
*/
public Long getParameterAsLong(String key, Long defaultValue);
/**
* Gets the value for the associated key as a string.
* @param key The key of the parameter whose value is to be retrieved.
* @param defaultValue The value to use if the parameter doesn't exist, or if there is a conversion error.
* @return The value.
*/
public Boolean getParameterAsBoolean(String key, Boolean defaultValue);
/**
* Determines whether the parameter with the given key exists in the request.
* @param key The key for the parameter.
* @return Whether the parameter is specified in the request.
*/
public boolean hasParameter(String key);
/**
* Gets the parameter string that was part of the URI request including the question mark.
* @return The parameter string portion of the client's request. This will be null if there were no parameters or if the parameters were encoded.
*/
public String getParameterString();
/**
* Gets the client's cached response timestamp useable by the server to send a not modified message if the resource has not changed.
* @return The cached response date that the client passed indicating that a 304 Not Modified message should be sent if the resource hasn't changed since the date.
*/
public Date getCacheDate();
/**
* Gets the textual range requested.
* @return
*/
public String getRange();
/**
* Gets the lower value of the range for a download. If not set then the download should start at the beginning of the content.
* @return
*/
public Long getLowerRange();
/**
* Gets the upper value of the range for a download. If not set then the download should end at the last byte of the content.
* @return
*/
public Long getUpperRange();
/**
* Gets the date associated with the byte range. The byte range will only be valid (for resumed downloads) if the file modification date is older than the unmodified-since date.
* @return
*/
public Date getUnmodifiedSinceDate();
/**
* Gets the content buffer.
* @return The buffer used for temporary storage of the content. This will be null if a file channel is provided, or if there is no content to the request.
*/
public ByteBuffer getContent();
/**
* Gets the length of the message content.
* @return The message content byte count.
*/
public int getContentLength();
/**
* Gets the mime type for the content.
* @return The mime type name that identifies the encoding of the content, or null if there isn't any content (including any encoded in the uri).
*/
public String getContentType();
/**
* Gets the mime type code for the content.
* @return The mime type code that identifies the encoding of the content. One of the CONTENT_TYPE_xxx identifiers.
*/
public int getContentTypeCode();
/**
* Gets the character set name used to encode the parameters of the request (used with POST type requests that use the application/x-www-form-urlencoded encoding.
* @return The character set specificed, otherwise UTF-8. This value will never be null.
*/
public String getParameterCharacterSet();
/**
* Gets the input stream that can be used to access the content regardless of whether it is stored in a file or a memory buffer.
* <p>Note that a request that contains binary data may have properties for the data as well, but the properties will only house metadata. This method must be called to access the actual data.</p>
* @return The stream containing the content bytes.
* @throws java.io.IOException
*/
public InputStream getContentStream() throws java.io.IOException;
/**
* Gets the URL of the page that made the request if available.
* @return The full URL of the requesting page.
*/
public String getReferer();
/**
* Gets the URI which is the path to the requested resource.
* @return The requested resource's univeral resource identifier.
*/
public String getUri();
/**
* Whether the request was made over an SSL connection.
* @return Whether an SSL socket was used for the request.
*/
public boolean getIsSsl();
/**
* Gets the host ip or domain used to access the server.
* @return The host name used by the client.
*/
public String getHost();
/**
* Gets the version of HTTP being used by the client - most likely HTTP/1.1 or HTTP/1.0.
* @return The http version string passed by the client.
*/
public String getHttpVersion();
/**
* Gets the type code for the request.
* @return One of the TYPE_xxx identifiers.
*/
public int getRequestType();
/**
* Gets the identifier supplied by the browser that describes its self.
* @return The browser identifier string.
*/
public String getBrowser();
/**
* Gets the ISO language code for the language the client is using.
* @return The language used by the client.
*/
public String getLanguage();
/**
* Gets the message encodings used by the client.
* @return The transfer encodings used on the message (in order of application).
*/
public String getTransferEncoding();
/**
* Determines whether the CLIENT thought it was logged in at the time of the request.
* @return Whether the client thought it had logged in at the time of the request - useful in determining what to do if the session was stale.
*/
public boolean isLoggedIn();
/**
* Gets the session id that is derived from a cookie set in a previous response.
* @return The session id passed in the request.
*/
public String getSessionId();
/**
* Gets the secure session id that is derived from a cookie set in a previous response.
* @return The secure session id passed in the request.
*/
public String getSecureSessionId();
/**
* Gets the session object that the request is operating within.
* @return The session for this request. This may be null if one was not assigned.
*/
public ISession getSession();
/**
* Gets the exact bytes sent by the client that form this request.
* @return The bytes for the request as sent by the client. Will be null if the web application did not request the bytes be saved. See com.foundation.web.ISessionLifecycleAware and com.foundation.web.WebOptions.
*/
public ByteBuffer getRequestBytes();
}//IRequest//

View File

@@ -0,0 +1,116 @@
/*
* Copyright (c) 2008,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.nio.ByteBuffer;
import java.util.Date;
public interface IResponse {
public static final Integer INFINATE_CACHE_LENGTH = new Integer(15724800);
public static final int ERROR_TYPE_RESOURCE_NOT_FOUND = 1;
public static final int ERROR_TYPE_INVALID_ACCESS = 2;
/** Not exactly an error - more like information, but we will use the error mechanism to pass the info to the web server engine. */
public static final int ERROR_TYPE_RESOURCE_NOT_MODIFIED = 3;
/** Used to warn the user that their client did not use TLS + the domain extension, and the server cannot identify which certificate to use to allow them to connect. The user should upgrade their browser. */
public static final int ERROR_TYPE_TLS_FAILURE = 4;
/**
* Gets the request this response is responding to.
* @return The request that created this response.
*/
public IRequest getRequest();
/**
* Gets the content bytes.
* @return The content of the response.
*/
public IContent getContent();
/**
* Sets the content.
* @param content The content of the response.
*/
public void setContent(IContent content);
/**
* Gets whether the response should be compressed when possible. Certain resources that compress poorly should of course ignore this directive.
* @return Whether this response should be compressed is possible and reasonable. Will never return a null value.
*/
public Boolean getCompress();
/**
* Sets whether the response should be compressed when possible. Certain resources that compress poorly should of course ignore this directive.
* @param compress Whether this response should be compressed is possible and reasonable. A null value will use the application's default setting.
*/
public void setCompress(Boolean compress);
/**
* Gets the error type code.
* @return The error type code, or zero if no error occured.
*/
public int getErrorType();
/**
* Determines whether there was an error.
* @return Whether there was an error.
*/
public boolean isError();
/**
* Sets the content to be an error message.
* @param errorType The type of error.
*/
public void setError(int errorType);
/**
* Gets the URI that the client should forward to.
* @return The forward URI.
*/
public String getForwardUri();
/**
* Sets the URI that the client should forward to.
* @param forwardUri The forward URI.
*/
public void setForwardUri(String forwardUri);
/**
* Gets the URI that the client should redirect to.
* @return The redirect URI.
*/
public String getRedirectUri();
/**
* Sets the URI that the client should redirect to.
* @param redirectUri The redirect URI.
*/
public void setRedirectUri(String redirectUri);
/**
* Gets a user defined header for the response.
* This is useful for specifying non-standard error codes useable by either the browser or javascript in their processing.
* The content will be written out as usual if any content is set.
* The error code prempts this.
* <p>Example: "HTTP/1.1 404 Resource Not Found\r\n". Ensure that there is a \r\n at the end of each line you add to the header.</p>
* @param header The header to be used in place of the standard header. This must at the very least include the HTTP tag similar to the one in the above example.
*/
public String getCustomHeader();
/**
* Sets a user defined header for the response.
* This is useful for specifying non-standard error codes useable by either the browser or javascript in their processing.
* The content will be written out as usual if any content is set.
* The error code prempts this.
* <p>Example: "HTTP/1.1 404 Resource Not Found\r\n". Ensure that there is a \r\n at the end of each line you add to the header.</p>
* @param customHeader The header to be used in place of the standard header. This must at the very least include the HTTP tag similar to the one in the above example.
*/
public void setCustomHeader(String customHeader);
/**
* Gets the web server application that the request/response is being handled through.
* @return The web server application object that for the web app handling the request/response.
*/
public IWebApplication getApplication();
/**
* Gets the header field value for the given field name if a header was set [via setHeader(String)].
* @param name The field name.
* @return The field value, or null if none exists.
*/
public String getHeaderFieldValue(String name);
/**
* Sets the content provider which is used to provide all the headers and content for the message.
* @param header Sets a custom header (the entire header, properly formatted for HTTP and ending with \r\n\r\n).
*/
public void setHeader(String header);
}//IResponse//

View File

@@ -0,0 +1,11 @@
/*
* Copyright (c) 2008 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;
public interface ISecureSession extends ISession {
}//ISecureSession//

View File

@@ -0,0 +1,40 @@
/*
* Copyright (c) 2008,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;
public interface ISession {
/**
* Gets the application specific session data.
* @return The data set by the application and retained by the session.
*/
public Object getApplicationData();
/**
* Gets the application specific secure session data.
* @return The secure data set by the application and retained by the session.
*/
public Object getApplicationSecureData();
/**
* Gets whether the user is currently logged in. This is intended for CLIENT state only, the server should maintain its own login state.
* @return The secure session's identifier used to identify the secure portion of the session when the client connects.
*/
public boolean getIsLoggedIn();
/**
* Gets the session id.
* @return The session's identifier used to identify the session when the client connects.
*/
public String getSessionId();
/**
* Gets the secure session id.
* @return The secure session's identifier used to identify the secure portion of the session when the client connects.
*/
public String getSecureSessionId();
/**
* Updates the repository with the latest session changes.
*/
public void updateRepository();
}//ISession//

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//

View File

@@ -0,0 +1,17 @@
package com.foundation.web.interfaces;
public interface IWebApplicationContainer {
/**
* Increments the activity counter, allowing safe access to the web application until the counter is decremented.
* This method blocks until the activity counter can be incremented.
* Blocking may occur if the application is in the middle of, or has a pending reload or unload.
* <p>The caller does not need to synchronize when calling this method since it will be done internally.</p>
* @return Whether the activity counter could be incremented. This will only be false if the application has been closed while the thread was waiting.
*/
public boolean incrementActivityCounter();
/**
* Decrements the activity counter and runs the unload/reload thread for the web application if one is waiting.
* <p>The caller does not need to synchronize when calling this method since it will be done internally.</p>
*/
public void decrementActivityCounter();
}//IWebApplicationContainer//

View File

@@ -0,0 +1,21 @@
package com.foundation.web.interfaces;
import java.io.File;
import java.util.Properties;
public interface IWebApplicationFactory {
/**
* Creates a web application instance.
* @param baseDirectory The base directory for the webapp's static resources.
* @param externalBaseDirectory The optional external base directory for additional static resources not deployed with the webapp (specific to the server).
* @param cacheBaseDirectory The optional base directory where cache files should be stored. Cache files are those that like external files are generated during the run of the web server, but unlike external files can be deleted at any time and recreated as needed. These files, unlike external files, should never be backed up.
* @param log The logger provided by the web server which can be used to log via the server's UI.
* @param appProperties The property map containing custom properties for the web application.
* @return The web application.
*/
public IWebApplication[] createWebApplications(File baseDirectory, File externalBaseDirectory, File cacheBaseDirectory, IAppLog log, Properties appProperties);
/**
* Provides the factory a chance to shutdown any shared resources between the web applications, such as an Application class or thread service.
*/
public void shutdown();
}//IWebApplicationFactory//