Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can obtain
* a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
* or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
* Sun designates this particular file as subject to the "Classpath" exception
* as provided by Sun in the GPL Version 2 section of the License file that
* accompanied this code. If applicable, add the following below the License
* Header, with the fields enclosed by brackets [] replaced by your own
* identifying information: "Portions Copyrighted [year]
* [name of copyright owner]"
*
* Contributor(s):
*
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package org.glassfish.scripting.jython.grizzly;
import org.python.core.PyDictionary;
import org.python.core.PyObject;
public interface JythonApp {
/* From the WSGI spec:
The application object is simply a callable object that accepts two arguments.
The term "object" should not be misconstrued as requiring an actual object instance:
a function, method, class, or instance with a __call__ method are all acceptable for use as an application object.
Application objects must be able to be invoked more than once,
as virtually all servers/gateways (other than CGI) will make such repeated requests.
The application object must accept two positional arguments. For the sake of illustration,
we have named them environ and start_response, but they are not required to have these names.
A server or gateway must invoke the application object using positional (not keyword) arguments.
(E.g. by calling result = application(environ,start_response) as shown above.)
The environ parameter is a dictionary object, containing CGI-style environment variables.
This object must be a builtin Python dictionary (not a subclass, UserDict or other dictionary emulation),
and the application is allowed to modify the dictionary in any way it desires.
The dictionary must also include certain WSGI-required variables (described in a later section),
and may also include server-specific extension variables.
When called by the server, the application object must return an iterable yielding zero or more strings.
This can be accomplished in a variety of ways, such as by returning a list of strings,
or by the application being a generator function that yields strings,
or by the application being a class whose instances are iterable. Regardless of how it is accomplished,
the application object must always return an iterable yielding zero or more strings.
The server or gateway must transmit the yielded strings to the client in an unbuffered fashion,
completing the transmission of each string before requesting another one.
If a call to len(iterable) succeeds, the server must be able to rely on the result being accurate.
That is, if the iterable returned by the application provides a working __len__() method,
it must return an accurate result.
If the iterable returned by the application has a close() method,
the server or gateway must call that method upon completion of the current request,
whether the request was completed normally, or terminated early due to an error.
This is to support resource release by the application. This protocol is intended to complement PEP 325's
generator support, and other common iterables with close() methods.
(Note: the application must invoke the start_response() callable before the iterable yields its first body string,
so that the server can send the headers before any body content.
However, this invocation may be performed by the iterable's first iteration,
so servers must not assume that start_response() has been called before they begin iterating over the iterable.)
*/
// brings the wrapped application up and ready to serve requests. Returns True if sucessful, false otherwise
public boolean start (JyConfig config);
// serves a single request, as per WSGI spec above. Implied to be iterable
public PyObject call (PyDictionary environment, Response start_response);
// Informs Jython that it can try to call the "close" method, if the iterable has one.
public void finish();
// brings the wrapped application down
public void stop();
}