Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

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]
List of all members.

Public Member Functions

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.
xmog_java_classclazz ()
 Returns the method's declaring type.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
jmethodID get_methodID ()
 Returns the field's ID.
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.
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.
int initializeMethodID (xmog_localenv *env)
 Calculates the methodID based on the information maintained by this instance.
bool is_static () const
 Returns true if the method is static.
const char * name ()
 Returns the known method name.
xmog_java_methodnext ()
 Returns the next method declared by the same type.
void operator delete (void *)
 Overloaded operator delete that is safe to use for non heap-allocated instances.
void * operator new (size_t)
 Overloaded operator new that allows us to detect whether the instance is heap-allocated or not.
virtual void set_bool (xmog_base *obj, bool b, xmog_localenv *env=NULL)
 Sets a bool value of a dynamic instance.
virtual void set_byte (xmog_base *obj, jbyte b, xmog_localenv *env=NULL)
 Sets a jbyte value of a dynamic instance.
virtual void set_char (xmog_base *obj, jchar ch, xmog_localenv *env=NULL)
 Sets a jchar value of a dynamic instance.
virtual void set_double (xmog_base *obj, jdouble d, xmog_localenv *env=NULL)
 Sets a double value of a dynamic instance.
virtual void set_float (xmog_base *obj, jfloat f, xmog_localenv *env=NULL)
 Sets a float value of a dynamic instance.
virtual void set_int (xmog_base *obj, jint i, xmog_localenv *env=NULL)
 Sets an int value of a dynamic instance.
virtual void set_jboolean (xmog_base *obj, jboolean b, xmog_localenv *env=NULL)
 Sets a jboolean value of a dynamic instance.
virtual void set_jobject (xmog_base *obj, jobject o, xmog_localenv *env=NULL)
 Sets an object reference into a dynamic instance.
virtual void set_long (xmog_base *obj, jlong l, xmog_localenv *env=NULL)
 Sets a long value of a dynamic instance.
void set_methodID (jmethodID mid)
 Sets the method's ID.
virtual void set_short (xmog_base *obj, jshort sh, xmog_localenv *env=NULL)
 Sets a short value of a dynamic instance.
const char * type ()
 Returns the known return type signature.
 xmog_java_method (const xmog_java_method &rhs)
 The copy constructor, required for the infrastructure of STL support.
 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.
 xmog_java_method (xmog_java_class *clazz, jmethodID mid, bool bStatic=false, bool bIndirect=false)
 The constructor from existing method ID.

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::xmog_java_method xmog_java_class clazz,
jmethodID  mid,
bool  bStatic = false,
bool  bIndirect = false
 

The constructor from existing method ID.

Parameters:
clazz pointer to the class instance that declares the method.
mid the method identifier.
bStatic true if the method is a static method, false if not. Default value is false.
bIndirect true if the method requires another Java method on the callstack. Default value is false.

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:
clazz pointer to the class instance that declares the method.
name the method name.
type the method type.
bStatic true if the method is a static method, false if not. Default value is false.
bIndirect true if the method requires another Java method on the callstack. Default value is false.

xmog_java_method::xmog_java_method const xmog_java_method rhs  ) 
 

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

Parameters:
rhs the method to copy from.


Member Function Documentation

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:
result the result holder.
mid the method identifier.
base the target.
args the arguments.

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:
values the argument holder.
env the local call environment. Defaults to NULL.

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:
obj pointer to the owning instance or NULL if the method is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the method is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the method is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the method is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the method is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the method is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the method is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the method is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the method is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj pointer to the owning instance or NULL if the method is static.
args always NULL.
env the local environment used in this call. This value may be NULL.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

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:
obj the object which we're going to use to derive the value the dynamic value. This is typically a proxy instance representing a Java object.
args the 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.
env the 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.
flags the processing flags for the operation. The default value is 0.

Implements xmog_java_dynamic.

int xmog_java_method::initializeMethodID xmog_localenv env  ) 
 

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

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

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.

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:
obj the object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
b the new value.
env the 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.

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:
obj the object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
b the new value.
env the 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.

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:
obj the object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
ch the new value.
env the 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.

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:
obj the object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
d the new value.
env the 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.

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:
obj the object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
f the new value.
env the 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.

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:
obj the object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
i the new value.
env the 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.

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:
obj the object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
b the new value.
env the 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.

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:
obj the object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
o the new value.
env the 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.

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:
obj the object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
l the new value.
env the 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.

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.

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:
obj the object which we're going to use as the target for the dynamic value. This is typically a proxy instance representing a Java object.
sh the new value.
env the 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.

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:
Generated on Fri Jun 16 10:19:09 2006 for JMS Courier for C++ by  doxygen 1.4.1