Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 215346 | Differences between
and this patch

Collapse All | Expand All

(-)src-native-new/src/transport/TPTPClientCompTL/TPTPClientCompTL.dsp (-2 / +2 lines)
Lines 54-60 Link Here
54
# ADD BSC32 /nologo
54
# ADD BSC32 /nologo
55
LINK32=link.exe
55
LINK32=link.exe
56
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
56
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
57
# ADD LINK32 rpcrt4.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpLogUtils.lib tptpUtils.lib transportSupport.lib tptpCmpSupp.lib processControlUtil.lib /nologo /dll /machine:I386 /out:"../../../bin/tptpCCTL.dll" /libpath:"../../../lib"
57
# ADD LINK32 rpcrt4.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpLogUtils.lib tptpUtils.lib transportSupport.lib tptpCmpSupp.lib processControlUtil.lib tptpJava.lib /nologo /dll /machine:I386 /out:"../../../bin/tptpCCTL.dll" /libpath:"../../../lib"
58
58
59
!ELSEIF  "$(CFG)" == "TPTPClientCompTL - Win32 Debug"
59
!ELSEIF  "$(CFG)" == "TPTPClientCompTL - Win32 Debug"
60
60
Lines 81-87 Link Here
81
# ADD BSC32 /nologo
81
# ADD BSC32 /nologo
82
LINK32=link.exe
82
LINK32=link.exe
83
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
83
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
84
# ADD LINK32 tptpBaseTL.lib rpcrt4.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpLogUtils.lib tptpUtils.lib transportSupport.lib tptpCmpSupp.lib processControlUtil.lib /nologo /dll /debug /machine:I386 /out:"../../../bin/tptpCCTL.dll" /pdbtype:sept /libpath:"$(JAVA_HOME)/lib" /libpath:"../../../lib"
84
# ADD LINK32 tptpBaseTL.lib rpcrt4.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpLogUtils.lib tptpUtils.lib transportSupport.lib tptpCmpSupp.lib processControlUtil.lib tptpJava.lib /nologo /dll /debug /machine:I386 /out:"../../../bin/tptpCCTL.dll" /pdbtype:sept /libpath:"$(JAVA_HOME)/lib" /libpath:"../../../lib"
85
85
86
!ENDIF 
86
!ENDIF 
87
87
(-)src-native-new/src/transport/TPTPClientCompTL/java.h (-2 / +2 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 76-82 Link Here
76
76
77
77
78
/* Functions */
78
/* Functions */
79
tptp_uint32 tptpCreateJavaVitualMachine(tl_state_data_t* stateData, tptp_string *dllPath, tptp_string *classpath);
79
tptp_uint32 tptpCreateJavaVitualMachine(tl_state_data_t* stateData, tptp_string *classpath);
80
tptp_uint32 tptpSubmitJavaJob(tl_state_data_t* stateData, tptpJavaJobImplementation *jobImpl, BOOL asynchronous, TID *tid);
80
tptp_uint32 tptpSubmitJavaJob(tl_state_data_t* stateData, tptpJavaJobImplementation *jobImpl, BOOL asynchronous, TID *tid);
81
tptp_uint32 tptpDestroyJavaVirtualMachine(tl_state_data_t* stateData);
81
tptp_uint32 tptpDestroyJavaVirtualMachine(tl_state_data_t* stateData);
82
82
(-)src-native-new/src/transport/TPTPClientCompTL/ClientCTL.c (-43 / +6 lines)
Lines 56-64 Link Here
56
	BOOL		 jvmCreated;
56
	BOOL		 jvmCreated;
57
	TID			 _fileServerTID;
57
	TID			 _fileServerTID;
58
	TID			 _secsvrtid;
58
	TID			 _secsvrtid;
59
	tptp_string	*classpath;
60
	tptp_int32   classPathSize=8096;
61
	tptp_int32   result;
62
	tptp_string *isDataMultiplexed;
59
	tptp_string *isDataMultiplexed;
63
	tptp_string *processPolling;
60
	tptp_string *processPolling;
64
	tptp_string *securityEnabled;
61
	tptp_string *securityEnabled;
Lines 122-135 Link Here
122
			// In this case the config file does not have the ACProtocolPort entry.
119
			// In this case the config file does not have the ACProtocolPort entry.
123
			cctlData->acProtocolPort = 10006;
120
			cctlData->acProtocolPort = 10006;
124
		}
121
		}
125
		rc = getConfigurationString( pTransportData->configurationData, "Jvm", &cctlData->jvm );
122
126
		if ( rc == -1 )
127
		{
128
			cctlData->jvm = NULL;
129
			/* We don't really have a default JVM location.*/
130
			/* Should this be a failure condition? */
131
			TPTP_LOG_ERROR_MSG( stateData, "No JVM was specified in serviceconfig.xml.  File transfer and SSL support will be disabled." );
132
		}
133
		rc = getConfigurationString( pTransportData->configurationData, "SecurityEnabled", &securityEnabled );
123
		rc = getConfigurationString( pTransportData->configurationData, "SecurityEnabled", &securityEnabled );
134
		if ( rc == 0 )
124
		if ( rc == 0 )
135
		{
125
		{
Lines 205-246 Link Here
205
		/* Assume NO Security for now !!! */
195
		/* Assume NO Security for now !!! */
206
		/******************************/
196
		/******************************/
207
		/* Create JVM */
197
		/* Create JVM */
208
		if (!cctlData->jvm)
198
		rc = tptpCreateJavaVitualMachine(stateData, NULL);
199
		if (rc == 0) { 
200
			jvmCreated = TRUE;
201
		}	
202
		else
209
		{
203
		{
210
			TPTP_LOG_WARNING_MSG( stateData, "Cannot create JVM and therefore cannot create file server" );
204
			TPTP_LOG_WARNING_MSG( stateData, "Cannot create JVM and therefore cannot create file server" );
211
			jvmCreated = FALSE;
205
			jvmCreated = FALSE;
212
		}
206
		}
213
		else
214
		{
215
/* ra_getEnvironmentVariable() has some bugs still, so continue to
216
 * use workaround in setconfig for now.
217
 */
218
			/* Get the classpath from the system environment */
219
			classpath = tptp_malloc(sizeof(tptp_string) * classPathSize);
220
			//We are using a goto statement... which I admit is ugly.
221
			//we should address this case as well as the general environment case which
222
			//uses the same technique.
223
retry:
224
			result = ra_getEnvironmentVariable("CLASSPATH", classpath, classPathSize);
225
			if (result>classPathSize) {
226
				classPathSize=result+1;
227
				classpath = tptp_realloc(classpath, sizeof(tptp_string) * classPathSize);
228
				goto retry;
229
230
			}
231
			TPTP_LOG_DEBUG_MSG1(stateData, "CLASSPATH used for staring file server = %s", classpath);
232
233
			/* Create the JVM */
234
			rc = tptpCreateJavaVitualMachine(stateData, cctlData->jvm, classpath);
235
			tptp_free(classpath);
236
			if (rc == 0) 
237
				jvmCreated = TRUE;
238
			else
239
			{
240
				TPTP_LOG_WARNING_MSG( stateData, "Cannot create JVM and therefore cannot create file server" );
241
				jvmCreated = FALSE;
242
			}
243
		}
244
207
245
		/* Start createFileServer */
208
		/* Start createFileServer */
246
		if (jvmCreated)
209
		if (jvmCreated)
(-)src-native-new/src/transport/TPTPClientCompTL/java.c (-119 / +5 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
* Copyright (c) 2006 IBM Corporation and others.
2
* Copyright (c) 2008 IBM Corporation and others.
3
* All rights reserved.   This program and the accompanying materials
3
* All rights reserved.   This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
5
* which accompanies this distribution, and is available at
Lines 12-17 Link Here
12
12
13
#include "java.h"
13
#include "java.h"
14
#include "ClientCTL.h"
14
#include "ClientCTL.h"
15
#include "tptp/TPTPJava.h"
15
16
16
#ifdef _WIN32
17
#ifdef _WIN32
17
#include <windows.h>
18
#include <windows.h>
Lines 40-46 Link Here
40
/**
41
/**
41
* FILE SCOPE VARIABLES
42
* FILE SCOPE VARIABLES
42
*/
43
*/
43
static JNIEnv *_mainThread;
44
static int _currentJavaJobId = 0;
44
static int _currentJavaJobId = 0;
45
45
46
46
Lines 53-177 Link Here
53
53
54
void *JavaJob(void *args);
54
void *JavaJob(void *args);
55
55
56
56
tptp_uint32 tptpCreateJavaVitualMachine(tl_state_data_t* stateData, tptp_string *classpath) {
57
tptp_uint32 tptpCreateJavaVitualMachine(tl_state_data_t* stateData, tptp_string *dllPath, tptp_string *classpath) {
57
	_java_VM = tptpCreateJVM(classpath);
58
	jint result; /* the result of JVM creation */
58
	return (_java_VM != NULL) ? 0 : -1;
59
	JavaVMInitArgs vmArgs; /* the JVM arguments */
60
	JavaVMOption options[NUM_JVM_OPTIONS]; /* the options inside the JVM argument structure */ /* Bug 62342 */
61
	tptp_string *buffer; /* the pointer to the class path to be loaded with the JVM */
62
	tptp_uint32 bufferSize, offset; /* the size and offset of the string buffer to be allocated for the class path */
63
#ifdef _WIN32
64
	tptp_string *jvmArgBuffer; /* Bug 62342 */
65
#elif defined(__OS400__)
66
	tptp_string *versionBuffer;  /* Bug 95493 the pointer to the version to be loaded with the JVM */
67
#endif
68
69
#ifndef __OS400__
70
	tptpCreateJavaVM vmCreationFunction; /* the entry point of JNI_CreateJavaVM() call */
71
	DLL_REFERENCE dllRef; /* the pointer to the dynamic library */
72
	
73
	if (!dllPath) return -1;
74
75
	/* Load the dynamic library. */
76
	if (!(dllRef = LOAD_LIBRARY(dllPath))) {
77
		TPTP_LOG_WARNING_MSG1(stateData, "Couldn't load JVM library %s", dllPath);
78
		return -1;
79
	}
80
	else {
81
		TPTP_LOG_DEBUG_MSG1(stateData, "Loaded JVM library %s", dllPath);
82
	}
83
	
84
	/* Resolve the entry point. */
85
	if (!(vmCreationFunction = (tptpCreateJavaVM) RESOLVE_ENTRY_POINT(dllRef, "JNI_CreateJavaVM"))) {
86
		TPTP_LOG_WARNING_MSG(stateData, "Couldn't resolve entrypoint for JNI_CreateJavaVM");
87
		return -2;
88
	}
89
	else {
90
		TPTP_LOG_DEBUG_MSG(stateData, "Resolved entrypoint for JNI_CreateJavaVM");
91
	}
92
#endif
93
	offset = strlen("-Djava.class.path");
94
	/* Construct the class path for this JVM.  This path can be of an arbitrary length. */
95
	bufferSize = strlen("-Djava.class.path=") + 1;
96
	if (classpath)
97
	{
98
		bufferSize+= strlen(classpath);
99
	}
100
	buffer = (tptp_string*)tptp_malloc(sizeof(tptp_string) * bufferSize);
101
	BZERO(buffer, bufferSize);
102
	strcpy(buffer, "-Djava.class.path=");
103
	if (classpath)
104
	{
105
		strcat(buffer, classpath);
106
	}
107
/*	memcpy(buffer, "-Djava.class.path=", offset);
108
	memcpy(buffer + offset + 1, classpath, strlen(classpath));*/
109
110
	/* Bug 62342 begins */
111
	vmArgs.nOptions = 0;
112
#ifdef _WIN32
113
	/* Add the -Xrs option to prevent JVM shutdown upon user logoff */
114
	jvmArgBuffer = (char*)tptp_malloc(sizeof(char) * (strlen("-Xrs") + 1));
115
	BZERO(jvmArgBuffer, strlen("-Xrs") + 1);
116
	memcpy(jvmArgBuffer, "-Xrs", strlen("-Xrs"));
117
	options[vmArgs.nOptions].optionString = jvmArgBuffer;
118
	vmArgs.nOptions++;
119
#endif
120
	
121
	/* Set all options for the JVM. */
122
	if(classpath != NULL) {
123
#if defined(__OS400__) /* Bug 95493 */
124
		versionBuffer = (char*)tptp_malloc(sizeof(char) * 19);
125
		BZERO(versionBuffer, 19);
126
		memcpy(versionBuffer, "-Djava.version=1.4", 18);
127
		options[vmArgs.nOptions].optionString = as400_etoa(versionBuffer);
128
		vmArgs.nOptions++;
129
#endif
130
131
#ifdef __OS400__
132
		/* Set the class path using what is in the CLASSPATH variable. The encoding conversion must be done at run-time. */
133
		options[vmArgs.nOptions].optionString = as400_etoa(buffer);
134
#elif defined MVS
135
		__etoa(buffer);
136
		options[vmArgs.nOptions].optionString = buffer;
137
#else
138
		options[vmArgs.nOptions].optionString = buffer;
139
#endif
140
		vmArgs.nOptions++;
141
	}
142
	
143
	if(vmArgs.nOptions == 0) {
144
		vmArgs.options = NULL;
145
	}
146
	else {
147
		vmArgs.options = options;
148
	}
149
	
150
	/* Bug 62342 ends */
151
	
152
    vmArgs.version = JNI_VERSION_1_2;
153
    vmArgs.ignoreUnrecognized = JNI_FALSE;
154
	
155
    /* Instantiate the JVM, and clean up. */
156
#ifdef __OS400__
157
    result = JNI_CreateJavaVM(&_java_VM, (void**)&_mainThread, (void*)&vmArgs);
158
    tptp_free(options[0].optionString);
159
#else
160
    result = (*vmCreationFunction)(&_java_VM, (void**)&_mainThread, (void*)&vmArgs);
161
#endif
162
	
163
    tptp_free(buffer);
164
#ifdef _WIN32
165
	tptp_free(jvmArgBuffer); /* Bug 62342 */
166
#elif defined(__OS400__)
167
	tptp_free(versionBuffer); /* Bug 95493 */
168
#endif
169
	
170
	return result ? -1 : 0;
171
	
172
}
59
}
173
60
174
175
tptp_uint32 tptpSubmitJavaJob(tl_state_data_t* stateData, tptpJavaJobImplementation *jobImpl, BOOL asynchronous, TID *tid) {
61
tptp_uint32 tptpSubmitJavaJob(tl_state_data_t* stateData, tptpJavaJobImplementation *jobImpl, BOOL asynchronous, TID *tid) {
176
    tptpJavaJobWrapper* ptr; /* the pointer to the wrapper for the function pointer */
62
    tptpJavaJobWrapper* ptr; /* the pointer to the wrapper for the function pointer */
177
	
63
	
(-)src-native-new/src/shared/tptpConfig/tptpConfig.def (+2 lines)
Lines 19-21 Link Here
19
			copyVariableNode
19
			copyVariableNode
20
			destroyVariableT
20
			destroyVariableT
21
			destroyVariableNode
21
			destroyVariableNode
22
			getTPTPConfig
23
			getEnvironmentVariable
(-)src-native-new/src/shared/tptpConfig/TPTPConfig.cpp (-7 / +21 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 Intel Corporation.
2
 * Copyright (c) 2005, 2008 Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 36-42 Link Here
36
#include <xercesc/parsers/XercesDOMParser.hpp>
36
#include <xercesc/parsers/XercesDOMParser.hpp>
37
37
38
38
39
40
XERCES_CPP_NAMESPACE_USE
39
XERCES_CPP_NAMESPACE_USE
41
40
42
#include "tptp/ParserErrorHandler.h"
41
#include "tptp/ParserErrorHandler.h"
Lines 74-79 Link Here
74
char *applicationAliasPtr = NULL;
73
char *applicationAliasPtr = NULL;
75
static sysEnv_list_t *cacheEnv = NULL;
74
static sysEnv_list_t *cacheEnv = NULL;
76
75
76
static AC_Config_t *_ac_config = NULL;
77
77
78
void setEnvironmentVariable(char *name, char *value);
78
void setEnvironmentVariable(char *name, char *value);
79
agent_metadata_t* tptp_findAgent(tptp_list_t* agentList, char *agentName);
79
agent_metadata_t* tptp_findAgent(tptp_list_t* agentList, char *agentName);
Lines 164-180 Link Here
164
	{
164
	{
165
		DOMAttr *attributeNode = (DOMAttr*) attributes->item(i);
165
		DOMAttr *attributeNode = (DOMAttr*) attributes->item(i);
166
		char *cattrname = XMLString::transcode(attributeNode->getName());
166
		char *cattrname = XMLString::transcode(attributeNode->getName());
167
		char *cattrvalue = XMLString::transcode(attributeNode->getValue());
168
		
167
		
169
		if(strcmp(cattrname, attrName) == 0)
168
		if(strcmp(cattrname, attrName) == 0) {
170
		{
169
			char *cattrvalue = XMLString::transcode(attributeNode->getValue());
171
			*attrValue = (char *)tptp_malloc(strlen(cattrvalue)+1);
170
			
171
			*attrValue = (char *) tptp_malloc(strlen(cattrvalue)+1);
172
			strcpy(*attrValue, cattrvalue);
172
			strcpy(*attrValue, cattrvalue);
173
			
174
			XMLString::release(&cattrvalue);
173
		}
175
		}
174
		
176
		
175
		XMLString::release(&cattrvalue);
176
		XMLString::release(&cattrname);
177
		XMLString::release(&cattrname);
177
	} 
178
	} 
179
	
178
	return 0;
180
	return 0;
179
}
181
}
180
182
Lines 1743-1748 Link Here
1743
				TPTP_LOG_DEBUG_MSG1("Process Controller exe %s",ac_config->procCntlrAgent);
1745
				TPTP_LOG_DEBUG_MSG1("Process Controller exe %s",ac_config->procCntlrAgent);
1744
			
1746
			
1745
			}
1747
			}
1748
			else if(strcmp(tempnodename, ELEMENT_NAME_JVM) == 0) {
1749
				if (!getAttrs(iter->getCurrentNode(), "location", &ac_config->jvmLibPath)) {
1750
					TPTP_LOG_DEBUG_MSG1("JVM location is %s", ac_config->jvmLibPath);
1751
				}
1752
			}				
1746
			else if(strcmp(tempnodename, ELEMENT_NAME_AGENT) == 0)
1753
			else if(strcmp(tempnodename, ELEMENT_NAME_AGENT) == 0)
1747
			{
1754
			{
1748
				char *tmpAgentDirName=NULL;
1755
				char *tmpAgentDirName=NULL;
Lines 1939-1944 Link Here
1939
		delete tptp_dom_err;
1946
		delete tptp_dom_err;
1940
		parser->release();
1947
		parser->release();
1941
		
1948
		
1949
		_ac_config = ac_config;
1950
		
1942
		return 0;
1951
		return 0;
1943
	} //end try
1952
	} //end try
1944
1953
Lines 1975-1980 Link Here
1975
	}
1984
	}
1976
}
1985
}
1977
1986
1987
1988
AC_Config_t* getTPTPConfig() {
1989
	return _ac_config; 
1990
}
1991
1978
/**
1992
/**
1979
 *********************************************************************
1993
 *********************************************************************
1980
 *                                                       
1994
 *                                                       
(-)src-native-new/include/tptp/TPTPConfig.h (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 Intel Corporation.
2
 * Copyright (c) 2005, 2008 Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 99-104 Link Here
99
    tptp_list_t                   agentList;       /* agent_metadata_t   */
99
    tptp_list_t                   agentList;       /* agent_metadata_t   */
100
    tptp_list_t                   msgPipelineList; /* message_pipeline_t */
100
    tptp_list_t                   msgPipelineList; /* message_pipeline_t */
101
    char                          *procCntlrAgent;
101
    char                          *procCntlrAgent;
102
	char						  *jvmLibPath;
102
    struct ConnectionManager_tag* connectionManager;
103
    struct ConnectionManager_tag* connectionManager;
103
} AC_Config_t;
104
} AC_Config_t;
104
105
Lines 131-136 Link Here
131
void printList(tptp_list_t *inputList);
132
void printList(tptp_list_t *inputList);
132
133
133
int loadTPTPConfig(char *acConfigFile, AC_Config_t *ac_config, BOOL calledByAC);
134
int loadTPTPConfig(char *acConfigFile, AC_Config_t *ac_config, BOOL calledByAC);
135
AC_Config_t* getTPTPConfig();
134
int parseApplicationAliases(char *applicationString, tptp_list_t **pUserAppList, int *launchAliasesOnly);
136
int parseApplicationAliases(char *applicationString, tptp_list_t **pUserAppList, int *launchAliasesOnly);
135
int parseApplication(char *applicationString, App_Label_t **pLabel);
137
int parseApplication(char *applicationString, App_Label_t **pLabel);
136
138
Lines 252-256 Link Here
252
#define ELEMENT_NAME_AGENT_CFGFILE	"ConfigFile"
254
#define ELEMENT_NAME_AGENT_CFGFILE	"ConfigFile"
253
//Agent Config - AgentName
255
//Agent Config - AgentName
254
#define ATTRB_AGENT_NAME			"Name"
256
#define ATTRB_AGENT_NAME			"Name"
257
// JVM configuration
258
#define ELEMENT_NAME_JVM    "Jvm"
255
259
256
#endif /*TPTPCONFIG_H_*/
260
#endif /*TPTPCONFIG_H_*/
(-)src-native-new/src/TPTPJava/TPTPJava.c (+242 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Intel Corporation, IBM Corporation.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * $Id: TPTPJava.c,v 1.0 2008/01/17 03:35:47 ialelekov Exp $ 
9
 *******************************************************************************/ 
10
11
/*
12
 *	TPTP JVM provider
13
 *
14
 *  TODO: error logging, thread synchronization
15
 *
16
 */
17
18
#include <stdio.h>
19
#include <stdlib.h>
20
#include <string.h>
21
22
#include "tptp/TPTPConfig.h"
23
#include "tptp/TPTPJava.h"
24
25
#define DEFINE_CLASSPATH "-Djava.class.path="
26
27
typedef jint (JNICALL *CreateJavaVM)(JavaVM**, void**, void*);
28
29
JavaVM* jvm = NULL;
30
31
	/* Get the classpath from the system environment */
32
char* getSystemClasspath() {
33
	int   classPathSize = 8096;
34
	char* classpath;
35
	int result;
36
37
	classpath = (char*) malloc(classPathSize);
38
	while (1) {
39
		result = getEnvironmentVariable("CLASSPATH", classpath, classPathSize);
40
		if (result <= classPathSize) break;
41
42
		classPathSize = result + 1;
43
		classpath = realloc(classpath, classPathSize);
44
	}
45
	
46
	return classpath;
47
}
48
49
int createJVM(const char* classpath) {
50
	DLL_REFERENCE jvmLib;
51
	CreateJavaVM vmCreate; 
52
	JavaVMInitArgs vmArgs;
53
	JavaVMOption options[2];
54
	JNIEnv* jenv = NULL;
55
	char* cpe=NULL;
56
	char* cp=NULL;
57
	int cplen;
58
	jint result;
59
	AC_Config_t* cfg;
60
61
	cfg = getTPTPConfig();
62
	if (cfg == NULL) return AC_CONFIG_NOT_FOUND;
63
	if (cfg->jvmLibPath == NULL) return JVM_LIB_NOT_SET;
64
65
	// Load the dynamic library.
66
	if(!(jvmLib = LOAD_LIBRARY(cfg->jvmLibPath))) return JVM_LOAD_ERROR;
67
68
	// Resolve the entry point. 
69
	if(!(vmCreate = (CreateJavaVM) RESOLVE_ENTRY_POINT(jvmLib, "JNI_CreateJavaVM"))) {
70
		return JVM_RESOLVE_ERROR;
71
	}
72
73
	vmArgs.nOptions = 0;
74
75
#ifdef _WIN32
76
	// Add the -Xrs option to prevent JVM shutdown upon user logoff 
77
	options[vmArgs.nOptions++].optionString = "-Xrs";
78
#endif
79
80
	cplen = 0;
81
	if (classpath != NULL) 
82
		cplen = strlen(classpath);
83
84
	cpe = getSystemClasspath();
85
	if (cpe != NULL) cplen += strlen(cpe);
86
87
	if (cplen > 0) {
88
		cp = (char*) malloc(cplen + strlen(DEFINE_CLASSPATH) + 2); // including PATH_SEPARATOR
89
		strcpy(cp, DEFINE_CLASSPATH);
90
		
91
		if (classpath != NULL) strcat(cp, classpath);		
92
		
93
		if (cpe != NULL) {
94
			if (classpath != NULL) {
95
				cplen = strlen(cp);
96
				*(cp + cplen) = PATH_SEPARATOR;
97
				*(cp + cplen + 1) = '\0';
98
			}
99
			
100
			strcat(cp, cpe);
101
		}
102
103
		options[vmArgs.nOptions++].optionString = cp;
104
	}
105
	
106
	vmArgs.options = options;
107
	vmArgs.version = JNI_VERSION_1_2;
108
	vmArgs.ignoreUnrecognized = JNI_FALSE;
109
110
	// Instantiate the JVM, and clean up. 
111
	result = (*vmCreate)(&jvm, (void**)&jenv, (void*)&vmArgs);
112
113
	if(cp != NULL) free(cp);
114
	if(cpe != NULL) free(cpe);
115
116
	return (result == 0) ? 0 : JVM_CREATION_ERROR;
117
}
118
119
static jstring nativeToJavaString(JNIEnv *env, const char *s) {
120
	jclass clsString; 
121
    jmethodID mthInit;
122
    jbyteArray ba = NULL;
123
    jstring jstr;
124
    int slen;
125
126
    clsString = (*env)->FindClass(env, "java/lang/String");
127
    if (clsString == NULL) return NULL;
128
129
    mthInit = (*env)->GetMethodID(env, clsString, "<init>", "([B)V");
130
    if (mthInit == NULL) return NULL;
131
132
    slen = strlen(s);
133
    ba = (*env)->NewByteArray(env, slen);
134
    if (ba == NULL) return NULL;
135
    
136
    (*env)->SetByteArrayRegion(env, ba, 0, slen, (jbyte *)s);
137
	jstr = (*env)->NewObject(env, clsString, mthInit, ba);
138
	(*env)->DeleteLocalRef(env, ba);
139
	
140
	return jstr;
141
}
142
143
static char *JavaToNativeString(JNIEnv *env, jstring jstr) {
144
    jclass clsString;
145
    jmethodID mthGetBytes;
146
    jbyteArray ba = NULL;
147
    jthrowable ex;
148
    jint slen;
149
    char *s = NULL;
150
      
151
    clsString = (*env)->FindClass(env, "java/lang/String");
152
    if (clsString == NULL) return NULL;
153
    
154
    mthGetBytes = (*env)->GetMethodID(env, clsString, "getBytes", "()[B");
155
    if (mthGetBytes == NULL) return NULL;
156
       
157
    ba = (*env)->CallObjectMethod(env, jstr, mthGetBytes);
158
    ex = (*env)->ExceptionOccurred(env);
159
    if (ex != NULL) {
160
        (*env)->DeleteLocalRef(env, ex);
161
        return NULL;
162
    }
163
    
164
    slen = (*env)->GetArrayLength(env, ba);
165
    s = (char *) malloc(slen + 1);
166
	
167
	(*env)->GetByteArrayRegion(env, ba, 0, slen, (jbyte *)s);
168
	*(s+slen) = 0;
169
170
    (*env)->DeleteLocalRef(env, ba);
171
    
172
    return s;
173
}
174
175
void setClasspath(JNIEnv* jenv, const char* classpath) {
176
	jclass clsSystem = NULL;
177
	jmethodID mthGetProp = NULL;
178
	jmethodID mthSetProp = NULL;
179
	jobject obj = NULL;
180
	jstring prop, jcp;
181
    jthrowable exc;
182
	char *cp0, *cp;
183
	
184
	if (classpath == NULL) return;
185
	if (strlen(classpath) <= 0) return;
186
	
187
	clsSystem = (*jenv)->FindClass(jenv, "java/lang/System");
188
	if (clsSystem == NULL) return;
189
	
190
	mthGetProp = (*jenv)->GetStaticMethodID(jenv, clsSystem, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
191
	if (mthGetProp == NULL) return;
192
	
193
	mthSetProp = (*jenv)->GetStaticMethodID(jenv, clsSystem, "setProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
194
	if (mthSetProp == NULL) return;
195
196
	prop = nativeToJavaString(jenv, "java.class.path");
197
	if (prop == NULL) return;
198
		
199
	jcp = (jstring) (*jenv)->CallStaticObjectMethod(jenv, clsSystem, mthGetProp, prop);
200
	if (jcp == NULL) return;
201
202
	cp0 = JavaToNativeString(jenv, jcp);
203
	if (cp0 == NULL) {
204
		cp = (char*) classpath;
205
	}
206
	else {
207
		int len = strlen(cp0);
208
		cp = (char*) malloc(len + strlen(classpath) + 2); // including path separator
209
		strcpy(cp, cp0);
210
		*(cp + len) = PATH_SEPARATOR;
211
		*(cp + len + 1) = '\0';
212
		strcat(cp, classpath);
213
	}
214
215
	jcp = nativeToJavaString(jenv, cp);
216
	if (jcp != NULL) {
217
		(*jenv)->CallStaticObjectMethod(jenv, clsSystem, mthSetProp, prop, jcp);
218
		
219
    	exc = (*jenv)->ExceptionOccurred(jenv);
220
    	if (exc) {
221
        	(*jenv)->DeleteLocalRef(jenv, exc);
222
    	}
223
	}
224
225
	if (cp0 != NULL) {
226
		free(cp);
227
		free(cp0);
228
	}	
229
}
230
231
JavaVM* tptpCreateJVM(const char* classpath) {
232
	if (jvm == NULL) 
233
		createJVM(classpath);
234
	else {
235
		JNIEnv* jenv;
236
237
		(*jvm)->AttachCurrentThread(jvm, (void**)&jenv, NULL);
238
		setClasspath(jenv, classpath);
239
	}
240
	
241
	return jvm;
242
}
(-)src-native-new/src/TPTPJava/TPTPJava.def (+5 lines)
Added Link Here
1
LIBRARY TPTPJava
2
DESCRIPTION "TPTP JVM provider"
3
EXPORTS
4
	tptpCreateJVM
5
	
(-)src-native-new/src/TPTPJava/TPTPJava.make (+127 lines)
Added Link Here
1
2
################################################################################
3
#                                       
4
#  makefile:  socketTL project          
5
#                                       
6
# $Id: TPTPJava.make,v 1.0 2008/01/17 15:43:07 ialelekov Exp $                                  
7
################################################################################
8
9
10
#-----------------------------------
11
#
12
#   Customizable section
13
#
14
#   - The TARGETREALNAME variable specifies the name of the library file
15
#     that will be generated, this includes a base (TARGETLIB) plus	a 
16
#     version number plus a minor number plus a release number
17
#   - The TARGETSONAME variable specifies a file name that has just the
18
#     library name plus the major version number
19
#   - The TARGETLIB variable specifies the base library name
20
#   - The TARGETSONAME and TARGETLIB are generated as symbolic links
21
#     when the library is built
22
#
23
#-----------------------------------
24
TARGET         :=  libtptpJava
25
TARGETDIR      :=  ../../lib
26
27
if [ x$VERSIONNUM = x ]; then export VERSIONNUM=0; fi
28
if [ x$MINORNUM = x ]; then export MINORNUM=0; fi
29
if [ x$RELEASENUM = x ]; then export RELEASENUM=0; fi
30
31
TARGETLIB      :=  $(TARGET).so
32
TARGETSONAME   :=  $(TARGETLIB).$(VERSIONNUM)
33
TARGETREALNAME :=  $(TARGETSONAME).$(MINORNUM).$(RELEASENUM)
34
35
36
#-----------------------------------
37
#   list of additional INCLUDE directories to search headers from
38
#      (separated by blanks)
39
#-----------------------------------
40
INCLUDEDIRS    :=  . ../../include
41
42
43
#-----------------------------------
44
#   list of additional libraries to be linked with
45
#      (separated by blanks)
46
#-----------------------------------
47
LIBS       :=  dl tptpConfig
48
49
#-----------------------------------
50
#   list of additional library directories to search from
51
#      (separated by blanks)
52
#-----------------------------------
53
LIBDIRS    :=  ../../lib
54
55
56
#-----------------------------------
57
#
58
#   Compiler options
59
#
60
#      -g       produce debug info
61
#      -Wall    enable all types of warnings
62
#      -O3      highest level of code optimization
63
#      -fPIC    generate position-independent code (PIC).
64
#               This is required for building shared library.
65
#      -c       compile only
66
#
67
#   Linking options
68
#
69
#       -Wl       pass options to linker
70
#       -shared   produce shared library
71
#       -L        add the given directory to the search path for libraries
72
#
73
#-----------------------------------
74
75
CFLAGS     :=  $(C_FLAGS) $(DEBUGABLE) -Wall $(OPTIMIZABLE) -fPIC $(addprefix -I,$(INCLUDEDIRS))  -D_LINUX_X86
76
77
CXXFLAGS   :=  $(CFLAGS)
78
79
LINKOPTS   :=  $(L_FLAGS) $(DEBUGABLE) -shared -Wl,-soname,$(TARGETSONAME) -o $(TARGETDIR)/$(TARGETREALNAME) $(addprefix -L,$(LIBDIRS))
80
81
82
#-----------------------------------
83
#   general commands and options
84
#-----------------------------------
85
86
CC          :=  gcc
87
CXX         :=  $(CC)
88
89
SOURCE     :=  $(wildcard *.c)  $(wildcard *.cpp)
90
91
OBJS       :=  $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
92
93
REMOVEFILE :=  rm -f
94
CREATELINK :=  ln -sf
95
96
97
#-----------------------------------
98
#   "make" rules
99
#-----------------------------------
100
101
.PHONY : default everything objs clean veryclean rebuild $(TARGET)
102
103
104
default : $(TARGET)
105
106
107
objs : $(OBJS)
108
109
110
clean :
111
	$(REMOVEFILE) *.o
112
113
114
veryclean: clean
115
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETLIB)
116
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETSONAME)
117
	$(REMOVEFILE) $(TARGETDIR)/$(TARGETREALNAME)
118
119
120
rebuild: veryclean everything
121
122
123
$(TARGET) : $(OBJS)
124
	$(CC) $(LINKOPTS) $(OBJS) $(addprefix -l,$(LIBS))
125
	$(CREATELINK) $(TARGETREALNAME)  $(TARGETDIR)/$(TARGETSONAME)
126
	$(CREATELINK) $(TARGETSONAME)    $(TARGETDIR)/$(TARGETLIB)
127
(-)src-native-new/include/tptp/TPTPJava.h (+24 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Intel Corporation, IBM Corporation.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * $Id: TPTPJava.h,v 1.0 2008/01/17 03:35:47 ialelekov Exp $ 
9
 *******************************************************************************/ 
10
11
#ifndef _TPTP_JAVA_H
12
#define _TPTP_JAVA_H
13
14
#include <jni.h>
15
16
#define	AC_CONFIG_NOT_FOUND	-1
17
#define	JVM_LIB_NOT_SET		-2
18
#define	JVM_LOAD_ERROR		-3
19
#define	JVM_RESOLVE_ERROR	-4
20
#define	JVM_CREATION_ERROR	-4
21
22
extern JavaVM* tptpCreateJVM(const char* classpath);
23
24
#endif
(-)src-native-new/src/TPTPJava/TPTPJava.dsp (+118 lines)
Added Link Here
1
# Microsoft Developer Studio Project File - Name="TPTPJava" - Package Owner=<4>
2
# Microsoft Developer Studio Generated Build File, Format Version 6.00
3
# ** DO NOT EDIT **
4
5
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
6
7
CFG=TPTPJava - Win32 Debug
8
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
9
!MESSAGE use the Export Makefile command and run
10
!MESSAGE 
11
!MESSAGE NMAKE /f "TPTPJava.mak".
12
!MESSAGE 
13
!MESSAGE You can specify a configuration when running NMAKE
14
!MESSAGE by defining the macro CFG on the command line. For example:
15
!MESSAGE 
16
!MESSAGE NMAKE /f "TPTPJava.mak" CFG="TPTPJava - Win32 Debug"
17
!MESSAGE 
18
!MESSAGE Possible choices for configuration are:
19
!MESSAGE 
20
!MESSAGE "TPTPJava - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
21
!MESSAGE "TPTPJava - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
22
!MESSAGE 
23
24
# Begin Project
25
# PROP AllowPerConfigDependencies 0
26
# PROP Scc_ProjName ""
27
# PROP Scc_LocalPath ""
28
CPP=cl.exe
29
MTL=midl.exe
30
RSC=rc.exe
31
32
!IF  "$(CFG)" == "TPTPJava - Win32 Release"
33
34
# PROP BASE Use_MFC 0
35
# PROP BASE Use_Debug_Libraries 0
36
# PROP BASE Output_Dir "Release"
37
# PROP BASE Intermediate_Dir "Release"
38
# PROP BASE Target_Dir ""
39
# PROP Use_MFC 0
40
# PROP Use_Debug_Libraries 0
41
# PROP Output_Dir "../../bin"
42
# PROP Intermediate_Dir "Release"
43
# PROP Ignore_Export_Lib 0
44
# PROP Target_Dir ""
45
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPJAVA_EXPORTS" /Yu"stdafx.h" /FD /c
46
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPJAVA_EXPORTS" /FD /c
47
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
48
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
49
# ADD BASE RSC /l 0x419 /d "NDEBUG"
50
# ADD RSC /l 0x419 /d "NDEBUG"
51
BSC32=bscmake.exe
52
# ADD BASE BSC32 /nologo
53
# ADD BSC32 /nologo
54
LINK32=link.exe
55
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
56
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpConfig.lib /nologo /dll /machine:I386 /def:".\TPTPJava.def" /implib:"../../lib/TPTPJava.lib" /libpath:"../../lib"
57
# SUBTRACT LINK32 /pdb:none
58
59
!ELSEIF  "$(CFG)" == "TPTPJava - Win32 Debug"
60
61
# PROP BASE Use_MFC 0
62
# PROP BASE Use_Debug_Libraries 1
63
# PROP BASE Output_Dir "Debug"
64
# PROP BASE Intermediate_Dir "Debug"
65
# PROP BASE Target_Dir ""
66
# PROP Use_MFC 0
67
# PROP Use_Debug_Libraries 1
68
# PROP Output_Dir "../../bin"
69
# PROP Intermediate_Dir "Debug"
70
# PROP Ignore_Export_Lib 0
71
# PROP Target_Dir ""
72
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPJAVA_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
73
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TPTPJAVA_EXPORTS" /FD /GZ /c
74
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
75
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
76
# ADD BASE RSC /l 0x419 /d "_DEBUG"
77
# ADD RSC /l 0x419 /d "_DEBUG"
78
BSC32=bscmake.exe
79
# ADD BASE BSC32 /nologo
80
# ADD BSC32 /nologo
81
LINK32=link.exe
82
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
83
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tptpConfig.lib /nologo /dll /debug /machine:I386 /implib:"../../lib/tptpJava.lib" /pdbtype:sept /libpath:"../../lib"
84
# SUBTRACT LINK32 /pdb:none
85
86
!ENDIF 
87
88
# Begin Target
89
90
# Name "TPTPJava - Win32 Release"
91
# Name "TPTPJava - Win32 Debug"
92
# Begin Group "Source Files"
93
94
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
95
# Begin Source File
96
97
SOURCE=.\TPTPJava.c
98
# End Source File
99
# Begin Source File
100
101
SOURCE=.\TPTPJava.def
102
103
!IF  "$(CFG)" == "TPTPJava - Win32 Release"
104
105
# PROP Exclude_From_Build 1
106
107
!ELSEIF  "$(CFG)" == "TPTPJava - Win32 Debug"
108
109
!ENDIF 
110
111
# End Source File
112
# End Group
113
# Begin Group "Header Files"
114
115
# PROP Default_Filter "h;hpp;hxx;hm;inl"
116
# End Group
117
# End Target
118
# End Project

Return to bug 215346