# php_java.h File Reference

## Detailed Description

This is the main entry point for the java extension.

It contains the global structures and the callbacks required for zend engine 1 and 2.

`#include "php_wrapper.h"`
`#include "php_config.h"`
`#include "zend_compile.h"`
`#include "php_ini.h"`
`#include "php_globals.h"`
`#include "protocol.h"`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <fcntl.h>`
`#include <sys/socket.h>`
`#include <netinet/in.h>`
`#include <netinet/tcp.h>`
`#include <arpa/inet.h>`
`#include <netdb.h>`

Go to the source code of this file.

## Defines

#define | U_LOGFILE (1<<1)
#define | U_LOGLEVEL (1<<2)
#define | U_JAVA_HOME (1<<3)
#define | U_JAVA (1<<4)
#define | U_LIBRARY_PATH (1<<5)
#define | U_CLASSPATH (1<<6)
#define | U_SOCKNAME (1<<7)
#define | U_HOSTS (1<<8)
#define | U_SERVLET (1<<9)
#define | U_WRAPPER (1<<10)
#define | U_EXT_JAVA_COMPATIBILITY (1<<11)
#define | U_PERSISTENT_CONNECTIONS (1<<12)
#define | U_POLICY (1<<13)
#define | phpext_java_ptr &EXT_GLOBAL(module_entry)
#define | JG(v) EXT_GLOBAL(globals).v

## Functions

| PHP_MINIT_FUNCTION (EXT)
| Called when the module is initialized.
| PHP_MSHUTDOWN_FUNCTION (EXT)
| Called when the module terminates.
| PHP_MINFO_FUNCTION (EXT)
| Displays the module info.
char * | get_server_string (TSRMLS_D)
void | override_ini_for_redirect (TSRMLS_D)
| Adjust the standard environment for the current request before we connect to the back-end.
proxyenv * | try_connect_to_server (TSRMLS_D)
proxyenv * | connect_to_server (TSRMLS_D)
short | close_connection (proxyenv *env, short persistent_connection TSRMLS_DC)
| Close an active connection.
void | start_server (TSRMLS_D)
void | activate_connection (proxyenv *env TSRMLS_DC)
void | passivate_connection (proxyenv *env TSRMLS_DC)
void | clone_cfg (TSRMLS_D)
void | destroy_cloned_cfg (TSRMLS_D)
char * | test_server (int *socket, short *is_local, struct sockaddr *saddr TSRMLS_DC)
char * | get_servlet_context (TSRMLS_D)
char * | get_sockname (TSRMLS_D)

## Variables

zend_module_entry | module_entry
| PROTOCOL.TXT doesn't have a way to send hex numbers, if backward compatibility is enabled.
zend_class_entry * | class_entry
| Represents the java class struct.
zend_class_entry * | array_entry
| Represents the java class array struct.
zend_class_entry * | class_class_entry
| Represents the java_class class struct.
zend_class_entry * | class_class_entry_jsr
| Represents the javaclass class struct.
zend_class_entry * | exception_class_entry
| Represents the javaexception class struct.
function_entry | class_functions []
zend_object_handlers | handlers
| The object handlers, see create_object.
const char *const | bridge_version
int | ini_updated
| Holds the flags set/unset for all java ini entries.
int | ini_user
| The options set by the user.
int | ini_set
| The options which carry a value.
int | ini_override
| Holds the flags set/unset for all overridden java ini entries these are U_HOST, U_SERVLET and U_SOCKNAME.
cfg * | cfg
| Holds the global configuration.
proxyenv * | jenv
| The following structure contains per-request variables.
short | is_closed
char * | hosts
char * | servlet
char * | redirect_port
char * | channel
char * | channel_in
char * | channel_out
int | lockfile
zval * | exception
zval ** | object
zval * | func
zval ** | retval_ptr
zval * | func_params
HashTable | connections

## Function Documentation

short close_connection | ( | proxyenv * | env,
|  | short persistent_connection | TSRMLS_DC
| ) |

Close an active connection.

The connection must be active, i.e. JG(cfg).hosts, JG(cfg).servlet and JG(cfg).ini_user must contain the appropriate values.

Parameters:

  | env | The proxy env
  | persistent_connection | true for keep alive, false closes physical connection

See also:
  activate_connection

void override_ini_for_redirect | ( | TSRMLS_D |  | ) |

| Adjust the standard environment for the current request before we connect to the back-end. Used by Fast CGI and Apache so that we can connect back to the current VM. Checks [HTTP_]XJAVABRIDGE_OVERRIDE_HOSTS_REDIRECT and adjusts JG(hosts). Must be called after clone(cfg).

PHP_MINIT_FUNCTION | ( | EXT |  | ) |

Called when the module is initialized.

Creates the Java and JavaClass structures and tries to start the back-end if java.socketname, java.servlet or java.hosts are not set. The back-end is not started if the environment variable X_JAVABRIDGE_OVERRIDE_HOSTS exists and contains either "/" or "host:port//context/servlet". When running as a Apache/IIS module or Fast CGI, this procedure is called only once. When running as a CGI binary, it is called whenever the CGI binary is called.

PHP_MSHUTDOWN_FUNCTION | ( | EXT |  | ) |

| Called when the module terminates. Stops the back-end, if it is running. When running in Apache/IIS or as a FastCGI binary, this procedure is called only once. When running as a CGI binary this is called whenever the CGI binary terminates.

## Variable Documentation

struct cfg* cfg

| Holds the global configuration. This structure is shared by all php instances

int ini_override

Holds the flags set/unset for all overridden java ini entries these are U_HOST, U_SERVLET and U_SOCKNAME.

See also:
  X_JAVABRIDGE_OVERRIDE_HOSTS