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

A class implementing the xmog_java_dynamic interface for accessing Java methods via JNI or Codemesh's remoting protocol. More...

#include <xmog_java_method.h>

Inheritance diagram for xmog_java_method:
Inheritance graph
[legend]
Collaboration diagram for xmog_java_method:
Collaboration graph
[legend]

Public Member Functions

 xmog_java_method (xmog_java_class *clazz, jmethodID mid, bool bStatic=false, bool bIndirect=false)
 The constructor from existing method ID. More...
 
 xmog_java_method (xmog_java_class *clazz, const char *name, const char *type, bool bStatic=false, bool bIndirect=false)
 The constructor from name and type. More...
 
 xmog_java_method (const xmog_java_method &rhs)
 The copy constructor, required for the infrastructure of STL support. More...
 
void * operator new (size_t)
 Overloaded operator new that allows us to detect whether the instance is heap-allocated or not.
 
void operator delete (void *)
 Overloaded operator delete that is safe to use for non heap-allocated instances.
 
xmog_java_methodnext ()
 Returns the next method declared by the same type.
 
xmog_java_classclazz ()
 Returns the method's declaring type.
 
const char * name ()
 Returns the known method name. More...
 
const char * type ()
 Returns the known return type signature. More...
 
bool is_static () const
 Returns true if the method is static.
 
void set_methodID (jmethodID mid)
 Sets the method's ID. More...
 
int initializeMethodID (xmog_localenv *env)
 Calculates the methodID based on the information maintained by this instance. More...
 
jmethodID get_methodID ()
 Returns the field's ID.
 
jobjectArray get_argument_array (xmog_java_values *values, xmog_localenv *env=NULL)
 Returns an object array containing Value objects corresponding to the passed in values. More...
 
virtual bool get_bool (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value returned by a boolean method. More...
 
virtual jboolean get_jboolean (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value returned by a boolean method. More...
 
virtual jbyte get_byte (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value returned by a byte method. More...
 
virtual jchar get_char (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value returned by a char method. More...
 
virtual jdouble get_double (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value returned by a double method. More...
 
virtual jfloat get_float (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value returned by a float method. More...
 
virtual jint get_int (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value returned by a int method. More...
 
virtual jlong get_long (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value returned by a long method. More...
 
virtual jshort get_short (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Returns the value returned by a short method. More...
 
virtual jobject get_jobject (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=xmog_base::GLOBAL)
 Returns the value returned by a reference type method. More...
 
virtual void get_void (xmog_base *obj, xmog_java_values *args=NULL, xmog_localenv *env=NULL, xmog_flags flags=0)
 Dynamically resolves a reference that evaluates to a void value.
More...
 
virtual void set_bool (xmog_base *obj, bool b, xmog_localenv *env=NULL)
 Sets a bool value of a dynamic instance. More...
 
virtual void set_jboolean (xmog_base *obj, jboolean b, xmog_localenv *env=NULL)
 Sets a jboolean value of a dynamic instance. More...
 
virtual void set_byte (xmog_base *obj, jbyte b, xmog_localenv *env=NULL)
 Sets a jbyte value of a dynamic instance. More...
 
virtual void set_char (xmog_base *obj, jchar ch, xmog_localenv *env=NULL)
 Sets a jchar value of a dynamic instance. More...
 
virtual void set_double (xmog_base *obj, jdouble d, xmog_localenv *env=NULL)
 Sets a double value of a dynamic instance. More...
 
virtual void set_float (xmog_base *obj, jfloat f, xmog_localenv *env=NULL)
 Sets a float value of a dynamic instance. More...
 
virtual void set_int (xmog_base *obj, jint i, xmog_localenv *env=NULL)
 Sets an int value of a dynamic instance. More...
 
virtual void set_long (xmog_base *obj, jlong l, xmog_localenv *env=NULL)
 Sets a long value of a dynamic instance. More...
 
virtual void set_short (xmog_base *obj, jshort sh, xmog_localenv *env=NULL)
 Sets a short value of a dynamic instance. More...
 
virtual void set_jobject (xmog_base *obj, jobject o, xmog_localenv *env=NULL)
 Sets an object reference into a dynamic instance. More...
 
void call_remote (xmog_remote_java_value &result, int mid, xmog_base *base, xmog_java_values *args, xmog_localenv *env)
 Calls a remote method in the shared JVM. More...
 
- Public Member Functions inherited from xmog_java_dynamic
int handleException (int error_code, xmog_localenv *env=NULL)
 Handles an exception.
 

Friends

class xmog_java_class
 

Detailed Description

A class implementing the xmog_java_dynamic interface for accessing Java methods via JNI or Codemesh's remoting protocol.

This type is a specialization of the xmog_java_dynamic interface that knows how to call Java methods. This type is a support type that is used by the actual proxy methods. Each declared method is represented by exactly one instance of an xmog_java_method. That instance is then used by a concrete method to call the underlying Java method. The following snippet illustrates the infrastructure:

xmog_java_class clsContext( "javax/naming/Context", true );
xmog_java_method mLookup( &clsContext, "lookup", "(Ljava/lang/String;)Ljava/lang/Object;", false );

and the following snippet illustrates how the generated code uses the infrastructure:

java::lang::Object javax::naming::Context::lookup( const java::lang::String & name )
{
return java::lang::Object( mLookup.get_jobject( ... ), ... );
}

Constructor & Destructor Documentation

◆ xmog_java_method() [1/3]

xmog_java_method::xmog_java_method ( xmog_java_class clazz,
jmethodID  mid,
bool  bStatic = false,
bool  bIndirect = false 
)

The constructor from existing method ID.

Parameters
clazzpointer to the class instance that declares the method.
midthe method identifier.
bStatictrue if the method is a static method, false if not. Default value is false.
bIndirecttrue if the method requires another Java method on the callstack. Default value is false.

◆ xmog_java_method() [2/3]

xmog_java_method::xmog_java_method ( xmog_java_class clazz,
const char *  name,
const char *  type,
bool  bStatic = false,
bool  bIndirect = false 
)

The constructor from name and type.

Parameters
clazzpointer to the class instance that declares the method.
namethe method name.
typethe method type.
bStatictrue if the method is a static method, false if not. Default value is false.
bIndirecttrue if the method requires another Java method on the callstack. Default value is false.

◆ xmog_java_method() [3/3]

xmog_java_method::xmog_java_method ( const xmog_java_method rhs)

The copy constructor, required for the infrastructure of STL support.

Parameters
rhsthe method to copy from.

Member Function Documentation

◆ call_remote()

void xmog_java_method::call_remote ( xmog_remote_java_value result,
int  mid,
xmog_base base,
xmog_java_values args,
xmog_localenv env 
)

Calls a remote method in the shared JVM.

Parameters
resultthe result holder.
midthe method identifier.
basethe target.
argsthe arguments.

◆ get_argument_array()

jobjectArray xmog_java_method::get_argument_array ( xmog_java_values values,
xmog_localenv env = NULL 
)

Returns an object array containing Value objects corresponding to the passed in values.

Parameters
valuesthe argument holder.
envthe local call environment. Defaults to NULL.

◆ get_bool()

virtual bool xmog_java_method::get_bool ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value returned by a boolean method.

Parameters
objpointer to the owning instance or NULL if the method is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_byte()

virtual jbyte xmog_java_method::get_byte ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value returned by a byte method.

Parameters
objpointer to the owning instance or NULL if the method is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_char()

virtual jchar xmog_java_method::get_char ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value returned by a char method.

Parameters
objpointer to the owning instance or NULL if the method is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_double()

virtual jdouble xmog_java_method::get_double ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value returned by a double method.

Parameters
objpointer to the owning instance or NULL if the method is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_float()

virtual jfloat xmog_java_method::get_float ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value returned by a float method.

Parameters
objpointer to the owning instance or NULL if the method is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_int()

virtual jint xmog_java_method::get_int ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value returned by a int method.

Parameters
objpointer to the owning instance or NULL if the method is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_jboolean()

virtual jboolean xmog_java_method::get_jboolean ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value returned by a boolean method.

Parameters
objpointer to the owning instance or NULL if the method is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_jobject()

virtual jobject xmog_java_method::get_jobject ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = xmog_base::GLOBAL 
)
virtual

Returns the value returned by a reference type method.

Parameters
objpointer to the owning instance or NULL if the method is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_long()

virtual jlong xmog_java_method::get_long ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value returned by a long method.

Parameters
objpointer to the owning instance or NULL if the method is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_short()

virtual jshort xmog_java_method::get_short ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Returns the value returned by a short method.

Parameters
objpointer to the owning instance or NULL if the method is static.
argsalways NULL.
envthe local environment used in this call. This value may be NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ get_void()

virtual void xmog_java_method::get_void ( xmog_base obj,
xmog_java_values args = NULL,
xmog_localenv env = NULL,
xmog_flags  flags = 0 
)
virtual

Dynamically resolves a reference that evaluates to a void value.

This function is mostly useful for method invocations.

Parameters
objthe object which we're going to use to derive the value the dynamic value. This is typically a proxy instance representing a Java object.
argsthe arguments used to derive the dynamic value. This will tpyically be the array of parameters passed to a method or NULL. The default value is NULL.
envthe local environment used for the request. If NULL is passed, a local environment is acquired in the execution of the request. The default value is NULL.
flagsthe processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

◆ initializeMethodID()

int xmog_java_method::initializeMethodID ( xmog_localenv env)

Calculates the methodID based on the information maintained by this instance.

Parameters
envthe local environment used for this operation.
Returns
0 if everything worked out, -1 otherwise.

◆ name()

const char* xmog_java_method::name ( )

Returns the known method name.

This method may return NULL if it was constructed with a known methodID as input.

◆ set_bool()

virtual void xmog_java_method::set_bool ( xmog_base obj,
bool  b,
xmog_localenv env = NULL 
)
virtual

Sets a bool value of a dynamic instance.

Parameters
objthe object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
bthe new value.
envthe local environment used for the request. If NULL is passed, a local environment is acquired in the execution of the request. The default value is NULL.

Implements xmog_java_dynamic.

◆ set_byte()

virtual void xmog_java_method::set_byte ( xmog_base obj,
jbyte  b,
xmog_localenv env = NULL 
)
virtual

Sets a jbyte value of a dynamic instance.

Parameters
objthe object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
bthe new value.
envthe local environment used for the request. If NULL is passed, a local environment is acquired in the execution of the request. The default value is NULL.

Implements xmog_java_dynamic.

◆ set_char()

virtual void xmog_java_method::set_char ( xmog_base obj,
jchar  ch,
xmog_localenv env = NULL 
)
virtual

Sets a jchar value of a dynamic instance.

Parameters
objthe object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
chthe new value.
envthe local environment used for the request. If NULL is passed, a local environment is acquired in the execution of the request. The default value is NULL.

Implements xmog_java_dynamic.

◆ set_double()

virtual void xmog_java_method::set_double ( xmog_base obj,
jdouble  d,
xmog_localenv env = NULL 
)
virtual

Sets a double value of a dynamic instance.

Parameters
objthe object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
dthe new value.
envthe local environment used for the request. If NULL is passed, a local environment is acquired in the execution of the request. The default value is NULL.

Implements xmog_java_dynamic.

◆ set_float()

virtual void xmog_java_method::set_float ( xmog_base obj,
jfloat  f,
xmog_localenv env = NULL 
)
virtual

Sets a float value of a dynamic instance.

Parameters
objthe object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
fthe new value.
envthe local environment used for the request. If NULL is passed, a local environment is acquired in the execution of the request. The default value is NULL.

Implements xmog_java_dynamic.

◆ set_int()

virtual void xmog_java_method::set_int ( xmog_base obj,
jint  i,
xmog_localenv env = NULL 
)
virtual

Sets an int value of a dynamic instance.

Parameters
objthe object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
ithe new value.
envthe local environment used for the request. If NULL is passed, a local environment is acquired in the execution of the request. The default value is NULL.

Implements xmog_java_dynamic.

◆ set_jboolean()

virtual void xmog_java_method::set_jboolean ( xmog_base obj,
jboolean  b,
xmog_localenv env = NULL 
)
virtual

Sets a jboolean value of a dynamic instance.

Parameters
objthe object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
bthe new value.
envthe local environment used for the request. If NULL is passed, a local environment is acquired in the execution of the request. The default value is NULL.

Implements xmog_java_dynamic.

◆ set_jobject()

virtual void xmog_java_method::set_jobject ( xmog_base obj,
jobject  o,
xmog_localenv env = NULL 
)
virtual

Sets an object reference into a dynamic instance.

Parameters
objthe object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
othe new value.
envthe local environment used for the request. If NULL is passed, a local environment is acquired in the execution of the request. The default value is NULL.

Implements xmog_java_dynamic.

◆ set_long()

virtual void xmog_java_method::set_long ( xmog_base obj,
jlong  l,
xmog_localenv env = NULL 
)
virtual

Sets a long value of a dynamic instance.

Parameters
objthe object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
lthe new value.
envthe local environment used for the request. If NULL is passed, a local environment is acquired in the execution of the request. The default value is NULL.

Implements xmog_java_dynamic.

◆ set_methodID()

void xmog_java_method::set_methodID ( jmethodID  mid)

Sets the method's ID.

This method is used when we perform bulk initialization of elements declared by a type in the remoting protocol.

◆ set_short()

virtual void xmog_java_method::set_short ( xmog_base obj,
jshort  sh,
xmog_localenv env = NULL 
)
virtual

Sets a short value of a dynamic instance.

Parameters
objthe object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
shthe new value.
envthe local environment used for the request. If NULL is passed, a local environment is acquired in the execution of the request. The default value is NULL.

Implements xmog_java_dynamic.

◆ type()

const char* xmog_java_method::type ( )

Returns the known return type signature.

This method may return NULL if it was constructed with a known methodID as input.


The documentation for this class was generated from the following file:
xmog_java_method::name
const char * name()
Returns the known method name.
xmog_java_method
A class implementing the xmog_java_dynamic interface for accessing Java methods via JNI or Codemesh's...
Definition: xmog_java_method.h:38
xmog_java_class
A C++ wrapper for Java types.
Definition: xmog_java_class.h:31

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