Codemesh Runtime v3 C++ API Reference  3.9.205
Public Member Functions | Static Public Member Functions | List of all members
xmog_localenv Class Reference

A class representing per-thread information for the integration runtime. More...

#include <xmog_localenv.h>

Public Member Functions

 xmog_localenv (xmog_jvm *jvm, JNIEnv *env=NULL)
 
void in_delete (bool bInDelete)
 Sets the value of the bInDelete_ field. More...
 
bool in_delete ()
 Returns the value of the bInDelete_ field.
 
void in_detach (bool bInDetach)
 Sets the value of the bInDetach_ field. More...
 
bool in_detach ()
 Returns the value of the bInDetach_ field.
 
void in_exception (bool bInException)
 Sets the value of the bInException_ field. More...
 
bool in_exception ()
 Returns the value of the bInException_ field.
 
xmog_jvmgetJvm ()
 Returns the xmog_jvm pointer that represents the JVM to which this local environment instance belongs.
 
JNIEnv * getJNIEnv ()
 Returns the JNIEnv pointer this local environment wraps around.
 
JNIEnv * getEnv ()
 Returns the JNIEnv pointer this local environment wraps around. More...
 
JavaVM * getJavaVM ()
 Returns the JavaVM pointer that represents the JVM to which this thread is attached.
 
jint getJNIVersion ()
 Returns the JNI version of the JVM to which this thread is attached.
 
void setDefaultEncoding (xmog_base *_enc)
 Sets the default string encoding that is used when native strings are converted to Java strings. More...
 
xmog_basegetDefaultEncoding ()
 Returns the default string encoding that is used when native strings are converted to Java strings. More...
 
void set_error_handler (xmog_error_handler *_eh)
 Sets the error handler that will be used for this local environment. More...
 
xmog_error_handlerget_error_handler ()
 Returns the error handler that's used for this local environment. More...
 
void * operator new (size_t)
 The overloaded operator new.
 
void operator delete (void *)
 

Static Public Member Functions

static xmog_localenvget_instance (xmog_localenv *env)
 Returns a local environment. More...
 
static void set_classloader (jobject cl)
 Allows the specification of a classloader to use for the resolution of Java types by name. More...
 
static xmog_localenvget_instance (JNIEnv *env)
 Returns a local environment for the JNIEnv pointer that is passed in. More...
 
static xmog_localenvget_localenv (JNIEnv *, XMOGVERSION, XMOGCONFIG, XMOGVERSION, const char *, jint)
 Returns a local environment. More...
 

Detailed Description

A class representing per-thread information for the integration runtime.

This class provides the necessary abstraction that allows us to support both in-process and out-of-process integration easily. Using APIs provided by this class rather than the internally maintained JNIEnv pointer will greatly improve performance in some scenarios.

This class also maintains several default settings that are, by virtue of this class only being used in a thread-local fashion, per thread settings. The errorhandling policy and the string default encoding are probably the most important of these thread-local settings.

Member Function Documentation

◆ get_error_handler()

xmog_error_handler* xmog_localenv::get_error_handler ( )

Returns the error handler that's used for this local environment.

Error handlers are thread specific because a programmer must be able to adjust the errorhandling policy in one thread without affecting the entire application.

◆ get_instance() [1/2]

static xmog_localenv* xmog_localenv::get_instance ( JNIEnv *  env)
static

Returns a local environment for the JNIEnv pointer that is passed in.

While the thread does not have to be attached to the JVM anymore (after all, we already have a JNIEnv pointer), we might need to perform the framework initialization for the thread.

This method is useful in the context of manually implemented native methods, when you want to get a local call environment pointer in the context of a native method call.

Parameters
enva JNIEnv pointer. Must be non-NULL.

◆ get_instance() [2/2]

static xmog_localenv* xmog_localenv::get_instance ( xmog_localenv env)
static

Returns a local environment.

Attaches the thread if necessary by calling xmog_jvm::attach().

Parameters
enva local environment. May be NULL.

Referenced by xmog_java_array_template< ElementType >::dyna_cast().

◆ get_localenv()

static xmog_localenv* xmog_localenv::get_localenv ( JNIEnv *  ,
XMOGVERSION  ,
XMOGCONFIG  ,
XMOGVERSION  ,
const char *  ,
jint   
)
static

Returns a local environment.

Deprecated:

This method is only supplied to provide already written C++ code with an easier migration path to the 3.0 version of the runtime library. Use the get_instance() method instead when you're writing new code.

◆ getDefaultEncoding()

xmog_base* xmog_localenv::getDefaultEncoding ( )

Returns the default string encoding that is used when native strings are converted to Java strings.

The default value will be based on the platform and the version of Java. A value of NULL is interpreted as meaning that we assume that native strings are UTF-8 strings.

Returns
the current value of this setting on this thread.

◆ getEnv()

JNIEnv* xmog_localenv::getEnv ( )

Returns the JNIEnv pointer this local environment wraps around.

Deprecated:

◆ in_delete()

void xmog_localenv::in_delete ( bool  bInDelete)

Sets the value of the bInDelete_ field.

Don't call this method directly. It is used internally by the framework.

Parameters
bInDeletethe new value of the field.

◆ in_detach()

void xmog_localenv::in_detach ( bool  bInDetach)

Sets the value of the bInDetach_ field.

Don't call this method directly. It is used internally by the framework.

Parameters
bInDetachthe new value of the field.

◆ in_exception()

void xmog_localenv::in_exception ( bool  bInException)

Sets the value of the bInException_ field.

Don't call this method directly. It is used internally by the framework.

Parameters
bInExceptionthe new value of the field.

◆ set_classloader()

static void xmog_localenv::set_classloader ( jobject  cl)
static

Allows the specification of a classloader to use for the resolution of Java types by name.

You normally don't have to call this function. This function exists to support the hosting of the runtime or a native library in the context of of a Java application that makes heavy use of classloaders (J2EE server, etc.)

Parameters
clthe classloader to use. May be NULL.

◆ set_error_handler()

void xmog_localenv::set_error_handler ( xmog_error_handler _eh)

Sets the error handler that will be used for this local environment.

Error handlers are thread specific because a programmer must be able to adjust the errorhandling policy in one thread without affecting the entire application.

Parameters
_ehthe error handler instance to be used.

◆ setDefaultEncoding()

void xmog_localenv::setDefaultEncoding ( xmog_base _enc)

Sets the default string encoding that is used when native strings are converted to Java strings.

The default value will be based on the platform and the version of Java. A value of NULL is interpreted as meaning that the JRE's default encoding is used for strings. The caller remains owner of the _enc instance that is passed into this method.

Parameters
_encthe default encoding that is used to convert between native strings and Java strings on this thread.
See also
xmog_jvm::setDefaultEncoding(xmog_base*)
xmog_options::setDefaultEncoding(const char*)

The documentation for this class was generated from the following file:

Copyright (c) 1999-2020 by Codemesh, Inc., ALL RIGHTS RESERVED.