com.caucho.quercus.module
Class ModuleContext

java.lang.Object
  extended by com.caucho.quercus.module.ModuleContext
Direct Known Subclasses:
ProModuleContext, ResinModuleContext

public class ModuleContext
extends java.lang.Object

Class-loader specific context for loaded PHP.


Field Summary
protected  ExprFactory _exprFactory
           
protected  MarshalFactory _marshalFactory
           
 
Constructor Summary
ModuleContext(ModuleContext parent, java.lang.ClassLoader loader)
          Constructor.
 
Method Summary
 JavaClassDef addClass(java.lang.String name, java.lang.Class<?> type, java.lang.String extension, java.lang.Class<?> javaClassDefClass)
           
 void addExtensionClass(java.lang.String ext, java.lang.String clsName)
           
 ModuleInfo addModule(java.lang.String name, QuercusModule module)
          Adds module info.
 void addServiceClass(java.net.URL url)
          Adds a URL for the context classes
 void addServiceModule(java.net.URL url)
          Adds a URL for the context module
protected  JavaClassDef createDefaultJavaClassDef(java.lang.String className, java.lang.Class type)
           
protected  JavaClassDef createDefaultJavaClassDef(java.lang.String className, java.lang.Class type, java.lang.String extension)
           
 Marshal createMarshal(java.lang.Class type, boolean isNotNull, boolean isNullAsFalse)
           
 StaticFunction createStaticFunction(QuercusModule module, java.lang.reflect.Method method)
          Creates a static function.
 QuercusModule findModule(java.lang.String name)
          Returns the module with the given name.
 java.util.HashMap<java.lang.String,ClassDef> getClassMap()
          Returns the class maps.
 ExprFactory getExprFactory()
           
 java.util.HashSet<java.lang.String> getExtensionClasses(java.lang.String ext)
           
 JavaClassDef getJavaClassDefinition(java.lang.Class javaClass)
          Returns a javaClassDef for the given class or null if there is not one.
 JavaClassDef getJavaClassDefinition(java.lang.Class<?> type, java.lang.String className)
          Gets or creates a JavaClassDef for the given class name.
 JavaClassDef getJavaClassDefinition(java.lang.String className)
          Adds a java class
 java.util.HashSet<java.lang.String> getLoadedExtensions()
          Returns true if an extension is loaded.
static ModuleContext getLocalContext(java.lang.ClassLoader loader)
           
 MarshalFactory getMarshalFactory()
          Finds the java class wrapper.
 java.util.ArrayList<ModuleInfo> getModules()
          Returns the configured modules
 QuercusClass getStdClass()
          Returns the stdClass definition.
 java.util.HashMap<java.lang.String,JavaClassDef> getWrapperMap()
          Returns the class maps.
 boolean hasServiceClass(java.net.URL url)
          Tests if the URL has already been loaded for the context classes
 boolean hasServiceModule(java.net.URL url)
          Tests if the URL has already been loaded for the context module
 void init()
           
 void introspectJavaClass(java.lang.String name, java.lang.Class type, java.lang.String extension, java.lang.Class javaClassDefClass)
          Introspects the module class for functions.
 void introspectJavaImplClass(java.lang.String name, java.lang.Class type, java.lang.String extension)
          Introspects the module class for functions.
 boolean isExtensionLoaded(java.lang.String name)
          Returns true if an extension is loaded.
static Value objectToValue(java.lang.Object obj)
           
protected  void setContextClassLoader(java.lang.ClassLoader loader)
          Encapsulate setContextClassLoader for contexts where the security manager is set.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_marshalFactory

protected MarshalFactory _marshalFactory

_exprFactory

protected ExprFactory _exprFactory
Constructor Detail

ModuleContext

public ModuleContext(ModuleContext parent,
                     java.lang.ClassLoader loader)
Constructor.

Method Detail

getLocalContext

public static ModuleContext getLocalContext(java.lang.ClassLoader loader)

hasServiceClass

public boolean hasServiceClass(java.net.URL url)
Tests if the URL has already been loaded for the context classes


addServiceClass

public void addServiceClass(java.net.URL url)
Adds a URL for the context classes


hasServiceModule

public boolean hasServiceModule(java.net.URL url)
Tests if the URL has already been loaded for the context module


addServiceModule

public void addServiceModule(java.net.URL url)
Adds a URL for the context module


addModule

public ModuleInfo addModule(java.lang.String name,
                            QuercusModule module)
                     throws ConfigException
Adds module info.

Throws:
ConfigException

addClass

public JavaClassDef addClass(java.lang.String name,
                             java.lang.Class<?> type,
                             java.lang.String extension,
                             java.lang.Class<?> javaClassDefClass)
                      throws java.lang.NoSuchMethodException,
                             java.lang.reflect.InvocationTargetException,
                             java.lang.IllegalAccessException,
                             java.lang.InstantiationException
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.InstantiationException

getJavaClassDefinition

public JavaClassDef getJavaClassDefinition(java.lang.Class<?> type,
                                           java.lang.String className)
Gets or creates a JavaClassDef for the given class name.


getJavaClassDefinition

public JavaClassDef getJavaClassDefinition(java.lang.String className)
Adds a java class


getJavaClassDefinition

public JavaClassDef getJavaClassDefinition(java.lang.Class javaClass)
Returns a javaClassDef for the given class or null if there is not one.


createDefaultJavaClassDef

protected JavaClassDef createDefaultJavaClassDef(java.lang.String className,
                                                 java.lang.Class type)

createDefaultJavaClassDef

protected JavaClassDef createDefaultJavaClassDef(java.lang.String className,
                                                 java.lang.Class type,
                                                 java.lang.String extension)

getMarshalFactory

public MarshalFactory getMarshalFactory()
Finds the java class wrapper.


getExprFactory

public ExprFactory getExprFactory()

createMarshal

public Marshal createMarshal(java.lang.Class type,
                             boolean isNotNull,
                             boolean isNullAsFalse)

getStdClass

public QuercusClass getStdClass()
Returns the stdClass definition.


getClassMap

public java.util.HashMap<java.lang.String,ClassDef> getClassMap()
Returns the class maps.


getWrapperMap

public java.util.HashMap<java.lang.String,JavaClassDef> getWrapperMap()
Returns the class maps.


findModule

public QuercusModule findModule(java.lang.String name)
Returns the module with the given name.


isExtensionLoaded

public boolean isExtensionLoaded(java.lang.String name)
Returns true if an extension is loaded.


getLoadedExtensions

public java.util.HashSet<java.lang.String> getLoadedExtensions()
Returns true if an extension is loaded.


addExtensionClass

public void addExtensionClass(java.lang.String ext,
                              java.lang.String clsName)

getExtensionClasses

public java.util.HashSet<java.lang.String> getExtensionClasses(java.lang.String ext)

createStaticFunction

public StaticFunction createStaticFunction(QuercusModule module,
                                           java.lang.reflect.Method method)
Creates a static function.


init

public void init()

setContextClassLoader

protected void setContextClassLoader(java.lang.ClassLoader loader)
Encapsulate setContextClassLoader for contexts where the security manager is set.


getModules

public java.util.ArrayList<ModuleInfo> getModules()
Returns the configured modules


introspectJavaClass

public void introspectJavaClass(java.lang.String name,
                                java.lang.Class type,
                                java.lang.String extension,
                                java.lang.Class javaClassDefClass)
                         throws java.lang.IllegalAccessException,
                                java.lang.InstantiationException,
                                ConfigException,
                                java.lang.NoSuchMethodException,
                                java.lang.reflect.InvocationTargetException
Introspects the module class for functions.

Parameters:
name - the php class name
type - the class to introspect.
extension - the extension provided by the class, or null
javaClassDefClass -
Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException
ConfigException
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException

introspectJavaImplClass

public void introspectJavaImplClass(java.lang.String name,
                                    java.lang.Class type,
                                    java.lang.String extension)
                             throws java.lang.IllegalAccessException,
                                    java.lang.InstantiationException,
                                    ConfigException
Introspects the module class for functions.

Parameters:
name - the php class name
type - the class to introspect.
extension - the extension provided by the class, or null
Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException
ConfigException

objectToValue

public static Value objectToValue(java.lang.Object obj)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object