Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2012 Red Hat, Inc., and individual contributors
   * as indicated by the @author tags.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.jboss.web.php;
 
 import static org.jboss.web.WebMessages.MESSAGES;
 
 
 
Handler.

Author(s):
Mladen Turk
Version:
$Revision: 1458 $, $Date: 2010-05-01 01:47:43 +0200 (Sat, 01 May 2010) $
Since:
1.0
 
 public class Handler extends HttpServlet
 {

    
the debugging detail level for this servlet.
 
     private int debug = 0;

    
Buffer size.
 
     private int bufferSize = 4096;

    
The Servlet configuration object we are associated with. If this value is null, this filter instance is not currently configured.
 
     private ServletConfig servletConfig = null;

    
Are doing source sysntax highlight.
 
     protected boolean syntaxHighlight = false;

    
the encoding to use for parameters
 
     private String parameterEncoding = System.getProperty("file.encoding",
                                                           "UTF-8");

    
The Script search path will start at webAppRootDir + File.separator + scriptPathPrefix (or webAppRootDir alone if scriptPathPrefix is null)
 
     private String scriptPathPrefix = null;

    
Sets instance variables.

Modified from Craig R. McClanahan's InvokerServlet

Parameters:
config a ServletConfig object containing the servlet's configuration and initialization parameters
Throws:
javax.servlet.ServletException if an exception has occurred that interferes with the servlet's normal operation
 
     public void init(ServletConfig servletConfig)
         throws ServletException
     {
         super.init(servletConfig);
 
         if (!Library.isInitialized()) {
             // try to load the library.
             try {
                 Library.initialize(null);
             } catch(Throwable t) {
                 ..errorInitializingPhpLibrary(System.getProperty("java.library.path"), t);
             }
         }
 
        if (!Library.isInitialized())
            throw new UnavailableException(.errorLoadingPhp());
        this. = servletConfig;
        // Set our properties from the initialization parameters
        String value = null;
        try {
            value = servletConfig.getInitParameter("debug");
             = Integer.parseInt(value);
             =
                servletConfig.getInitParameter("scriptPathPrefix");
            value = servletConfig.getInitParameter("bufferSize");
            if (value != null) {
                 = Integer.parseInt(value);
                if ( < 1024)
                     = 1024;
                log("init: bufferSize set to " + );
            }
        } catch (Throwable t) {
            // Nothing.
        }
        value = servletConfig.getInitParameter("parameterEncoding");
        if (value != null) {
             = value;
        }
    }

    
Finalize this servlet.
    public void destroy()
    {
        this. = null;
    }
    private static native int php(byte[] buf,
                                  ScriptEnvironment env,
                                  HttpServletRequest req,
                                  HttpServletResponse res,
                                  String requestMethod,
                                  String queryString,
                                  String contentType,
                                  String authUser,
                                  String requestURI,
                                  String pathTranslated,
                                  int contentLength,
                                  boolean syntaxHighlight);

    
Provides PHP Gateway service

Parameters:
req HttpServletRequest passed in by servlet container
res HttpServletResponse passed in by servlet container
Throws:
javax.servlet.ServletException if a servlet-specific exception occurs
java.io.IOException if a read/write exception occurs
See also:
javax.servlet.http.HttpServlet
    protected void service(HttpServletRequest reqHttpServletResponse res)
        throws ServletExceptionIOException
    {
        ScriptEnvironment env = new ScriptEnvironment(req,
                                                      getServletContext(),
                                                      );
        if (env.isValid()) {
            byte[] buf = new byte[];
            int rv = php(buf,
                         env,
                         req,
                         res,
                         req.getMethod(),
                         req.getQueryString(),
                         req.getContentType(),
                         req.getRemoteUser(),
                         req.getRequestURI(),
                         env.getFullPath(),
                         req.getContentLength(),
                         );
        }
        else {
            res.setStatus(.);
        }
    }
    
    public static void log(Handler handlerString msg)
    {
        // TODO: Log the message    
    }
New to GrepCode? Check out our FAQ X