Codemesh Runtime v3 C++ API Reference  3.9.205
IPv4Sockets_JavaVM.h
1 //
2 // Copyright (c) 1999-2020 by Codemesh, Inc.. ALL RIGHTS RESERVED.
3 //
4 
5 #ifndef IPv4Sockets_JavaVM_inc
6 #define IPv4Sockets_JavaVM_inc
7 
8 
9 #include "xmog.h"
10 
11 
12 #if (XMOG_IMPLEMENTS_REMOTE_CLIENT==1)
13 
14 
15 #include "ace/Barrier.h"
16 #include "ace/Synch_Traits.h"
17 #include "ace/Task_Ex_T.h"
18 #include "ace/TSS_T.h"
19 
20 class xmog_localenv;
22 #include "xmog_request.h"
23 #include "xmog_JavaVM.h"
24 #include "xmog_java_client.h"
25 
26 
48  private ACE_Task_Ex<ACE_MT_SYNCH, xmog_request>
49 {
50 public:
51 
59  const ACE_TCHAR *server_addr,
60  unsigned int connect_timeout = 0,
61  unsigned int reply_timeout = 0);
63 
66  int signon ( const char * serverAppNameUTF,
67  const char * clientDisplayNameUTF = NULL,
68  const char * clientSignOnNameUTF = NULL,
69  const char * clientCredentialsUTF = NULL,
70  int authenticationType = 0,
71  int strCopyLimit = 256,
72  int primArrayCopyLimit = 256,
73  bool bMaintainObjId = true,
74  bool bSendStringOnFirstRef = true,
75  bool bAlignData = true );
76 
77  int attach (void **penv, JavaVMAttachArgs *args, bool daemon);
78 
94  int submit (xmog_request *request);
95 
99  jstring RemoteNewString( const unsigned short * str, xmog_JNIEnv * env, int len = -1 );
100 
104  jstring RemoteNewString( const char * str, xmog_JNIEnv * env, xmog_base * encoding, int len = -1 );
105 
109  jstring RemoteNewString( const char * str, xmog_JNIEnv * env, const char * encoding, int len = -1 );
110 
114  jstring RemoteNewStringUtf( const char * str, xmog_JNIEnv * env );
115 
123  jarray RemoteNewArray( const char * arrType, jsize size, xmog_JNIEnv * env );
124 
133  jarray RemoteNewPrimitiveArray( const char * arrType, void * pData, jsize size, xmog_JNIEnv * env );
134 
145  virtual jarray RemoteNewPrimitiveArray( const char * arrType, xmog::xmog_data_code elemCode, void * pData, jsize length, jsize size, xmog_JNIEnv * env );
146 
157  void RemoteGetArrayRegion( const char * arrType, jarray array, jsize start, jsize len, void * buf, xmog_JNIEnv * env );
158 
169  void RemoteSetArrayRegion( const char * arrType, jarray array, jsize start, jsize len, void * buf, xmog_JNIEnv * env );
170 
177  jclass RemoteGetSuperClass( jclass sub, xmog_JNIEnv * env );
178 
186  jboolean RemoteIsAssignableFrom( jclass sub, jclass sup, xmog_JNIEnv * env );
187 
195  jboolean RemoteIsInstanceOf( jobject obj, jclass clazz, xmog_JNIEnv * env );
196 
203  jclass RemoteGetClass( jobject obj, xmog_JNIEnv * env );
204 
205 
206 private:
207 
212  void inner_init();
213 
220  static JNIInvokeInterface_ theFunctions;
221 
222 private:
223 
224  // Inherited from ACE_Task; runs in activated thread.
225  virtual int svc (void);
226  virtual int close (u_long flags = 0);
227 
228  // = Inherited from ACE_Event_Handler, called in svc thread context.
229 
231  virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE);
232 
235  // virtual int handle_output (ACE_HANDLE fd = ACE_INVALID_HANDLE);
236 
238  virtual int handle_exception (ACE_HANDLE fd = ACE_INVALID_HANDLE);
239 
240  virtual int handle_close (ACE_HANDLE handle,
241  ACE_Reactor_Mask close_mask);
242 
243  ACE_Barrier start_barrier_; // Cause ctor to wait for svc to begin
244  xmog_i_comm_strategy *comm_;
245  bool delete_comm_strategy_; // If we allocate it, we'll delete it
246  ACE_TCHAR server_addr_[256];
247  int connect_timeout_;
248  int reply_timeout_;
249  ACE_Message_Block *msg_in_; // Reads message coming in
250  typedef enum { LENGTH, BODY } ReadState;
251  ReadState state_;
252  size_t incoming_msg_len_;
253 
254  // It would be nice to use a standard container, but this code has to run
255  // on a wider range of compilers than STL can be trusted with.
256  ACE_DLList<xmog_request> requests_;
257 
258  // Use this for the Fake Thread ID in attach messages.
259  int fake_thread_id_;
260 
261  // the server-side class ids of various generally useful types
262  jint clsRemoteStringUtils_;
263  jint clsObject_;
264  jint clsClass_;
265  jint clsThrowable_;
266  jint clsException_;
267  jint clsString_;
268 
269  //
270  xmog_java_class clsArrayCreator;
271  xmog_java_method mGetArray;
272  xmog_java_method mGetPrimitiveArray;
273  xmog_java_method mFromNative;
274  xmog_java_method mToNative;
275  xmog_java_class clsArrayAccess;
276  xmog_java_method mSetArrayBool;
277  xmog_java_method mSetArrayByte;
278  xmog_java_method mSetArrayChar;
279  xmog_java_method mSetArrayDouble;
280  xmog_java_method mSetArrayFloat;
281  xmog_java_method mSetArrayInt;
282  xmog_java_method mSetArrayLong;
283  xmog_java_method mSetArrayShort;
284  xmog_java_method mSetArrayObject;
285  xmog_java_method mGetArrayBool;
286  xmog_java_method mGetArrayByte;
287  xmog_java_method mGetArrayChar;
288  xmog_java_method mGetArrayDouble;
289  xmog_java_method mGetArrayFloat;
290  xmog_java_method mGetArrayInt;
291  xmog_java_method mGetArrayLong;
292  xmog_java_method mGetArrayShort;
293  xmog_java_method mGetArrayObject;
294  xmog_java_method mCreateArrayLong1;
295  xmog_java_method mCreateArrayLong2;
296 };
297 
298 
299 #endif /* XMOG_IMPLEMENTS_REMOTE_CLIENT */
300 
301 
302 
303 #endif /* IPv4Sockets_JavaVM_inc */
IPv4Sockets_JavaVM::RemoteGetArrayRegion
void RemoteGetArrayRegion(const char *arrType, jarray array, jsize start, jsize len, void *buf, xmog_JNIEnv *env)
Returns the values in a region of an array.
IPv4Sockets_JavaVM::RemoteIsInstanceOf
jboolean RemoteIsInstanceOf(jobject obj, jclass clazz, xmog_JNIEnv *env)
Queries for an instance-of relationship between an object and a type.
xmog_request
Represents a request communicated between client and server.
Definition: xmog_request.h:50
xmog_request.h
IPv4Sockets_JavaVM::RemoteNewPrimitiveArray
jarray RemoteNewPrimitiveArray(const char *arrType, void *pData, jsize size, xmog_JNIEnv *env)
Creates a primitive array from the given data and returns the handle.
IPv4Sockets_JavaVM::IPv4Sockets_JavaVM
IPv4Sockets_JavaVM(xmog_i_comm_strategy *comm_strategy, const ACE_TCHAR *server_addr, unsigned int connect_timeout=0, unsigned int reply_timeout=0)
IPv4Sockets_JavaVM::RemoteIsAssignableFrom
jboolean RemoteIsAssignableFrom(jclass sub, jclass sup, xmog_JNIEnv *env)
Queries for an inheritance relationship between two types.
IPv4Sockets_JavaVM::RemoteSetArrayRegion
void RemoteSetArrayRegion(const char *arrType, jarray array, jsize start, jsize len, void *buf, xmog_JNIEnv *env)
Sets the values of a region of an array.
xmog_JavaVM
An abstract JavaVM type that is used as a base class for concrete JavaVM_ replacement types.
Definition: xmog_JavaVM.h:39
IPv4Sockets_JavaVM
A JavaVM type that uses IPv4 sockets to communicate with an out-of-process JVM.
Definition: IPv4Sockets_JavaVM.h:47
xmog_i_comm_strategy
Defines the interface that xmog_jvm uses to communicate with a server.
Definition: xmog_i_comm_strategy.h:36
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
IPv4Sockets_JavaVM::RemoteGetClass
jclass RemoteGetClass(jobject obj, xmog_JNIEnv *env)
Queries for the type of an object.
xmog_base
The baseclass for all proxy types in the framework.
Definition: xmog_base.h:29
xmog_localenv
A class representing per-thread information for the integration runtime.
Definition: xmog_localenv.h:32
IPv4Sockets_JavaVM::RemoteNewString
jstring RemoteNewString(const unsigned short *str, xmog_JNIEnv *env, int len=-1)
Attempts to create a string on the server.
IPv4Sockets_JavaVM::RemoteNewArray
jarray RemoteNewArray(const char *arrType, jsize size, xmog_JNIEnv *env)
Creates an array and returns the handle.
IPv4Sockets_JavaVM::signon
int signon(const char *serverAppNameUTF, const char *clientDisplayNameUTF=NULL, const char *clientSignOnNameUTF=NULL, const char *clientCredentialsUTF=NULL, int authenticationType=0, int strCopyLimit=256, int primArrayCopyLimit=256, bool bMaintainObjId=true, bool bSendStringOnFirstRef=true, bool bAlignData=true)
Send a SIGNON request to the remote JVM and wait for its reply.
IPv4Sockets_JavaVM::submit
int submit(xmog_request *request)
xmog_java_class
A C++ wrapper for Java types.
Definition: xmog_java_class.h:31
xmog_JNIEnv
An abstract baseclass for concrete JNIEnv implementations.
Definition: xmog_JNIEnv.h:26
IPv4Sockets_JavaVM::RemoteGetSuperClass
jclass RemoteGetSuperClass(jclass sub, xmog_JNIEnv *env)
Queries for a subtype's superclass.
IPv4Sockets_JavaVM::RemoteNewStringUtf
jstring RemoteNewStringUtf(const char *str, xmog_JNIEnv *env)
Attempts to create a string on the server.

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