📄 middlewarerfc.java
字号:
public String[][] getPropertyInfo()
{
return pinfo;
}
public int getMaxStartupDelay()
{
return mw_max_startup_delay;
}
public void setMaxStartupDelay(int maxStartupDelay)
{
setProperty("jco.middleware.max_startup_delay", Integer.toString(maxStartupDelay));
}
public void setTraceLevel(int trace_level)
{
nativeSetTraceLevel(trace_level);
}
public com.sap.mw.jco.IMiddleware.IClient getClientInterface()
{
return new Client(this);
}
public com.sap.mw.jco.IMiddleware.IServer getServerInterface()
{
return new Server(this);
}
protected void setConnParams(com.sap.mw.jco.JCO.Connection conn, String conn_params)
{
super.setConnParams(conn, conn_params);
}
protected boolean toBoolean(String value)
{
return super.toBoolean(value);
}
protected String getProperty(String key, Properties props)
{
return super.findProperty(key, props);
}
protected String getTrimmedProperty(String key, Properties props)
{
String value = super.findProperty(key, props);
if(value != null)
{
value = value.trim();
return value.length() <= 0 ? null : value;
} else
{
return null;
}
}
protected String getRightTrimmedProperty(String key, Properties props)
{
String value = super.findProperty(key, props);
if(value != null)
{
value = super.rightTrim(value);
return value.length() <= 0 ? null : value;
} else
{
return null;
}
}
protected String getBinaryProperty(String key, Properties props)
{
String value = getTrimmedProperty(key, props);
if(value != null && value.length() > 0)
{
if(value.equals("1") || value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"))
value = "1";
else
value = "0";
return value;
} else
{
return null;
}
}
public void setProperty(String key, String value)
{
JCO.fireTrace(1, "MiddlewareRFC.setProperty(" + key + ", " + value + ") ");
if(key != null)
if(key.equals("jco.middleware.wait_for_request_time"))
{
if(value != null)
try
{
wait_for_request_time = Integer.parseInt(value);
if(wait_for_request_time < 0)
wait_for_request_time = 2;
}
catch(Exception ex)
{
throw new com.sap.mw.jco.JCO.Exception(122, "JCO_ERROR_CONVERSION", "Value of property jco.middleware.wait_for_request_time not an integer.");
}
else
wait_for_request_time = 2;
} else
if(key.equals("jco.middleware.max_startup_delay"))
{
if(value != null)
try
{
mw_max_startup_delay = Integer.parseInt(value);
if(mw_max_startup_delay < 0)
mw_max_startup_delay = 3600;
}
catch(Exception ex)
{
throw new com.sap.mw.jco.JCO.Exception(122, "JCO_ERROR_CONVERSION", "Value of property jco.middleware.max_startup_delay not an integer.");
}
else
mw_max_startup_delay = 3600;
} else
if(key.equals("jco.middleware.allow_start_of_programs"))
nativeAllowStartOfPrograms(value);
else
if(key.equals("jco.middleware.monitoring"))
try
{
int iv = Integer.parseInt(value);
String old_value = getProperty("jco.middleware.monitoring");
int mode = old_value != null ? Integer.parseInt(old_value) : 0;
if(iv == 0)
{
if(mode == 1)
{
middleware_mode &= -2;
nativeSetMode(middleware_mode);
}
mode = Math.max(0, mode - 1);
} else
if(iv == 1)
{
if(mode == 0)
{
middleware_mode |= 1;
nativeSetMode(middleware_mode);
}
mode++;
} else
{
throw new com.sap.mw.jco.JCO.Exception(131, "JCO_ERROR_ILLEGAL_ARGUMENT", "Value of property jco.middleware.monitoring must be 1 or 0.");
}
value = String.valueOf(mode);
}
catch(Exception ex)
{
throw new com.sap.mw.jco.JCO.Exception(122, "JCO_ERROR_CONVERSION", "Value of property jco.middleware.monitoring not an integer.");
}
super.setProperty(key, value);
}
protected void removeProperty(String key, Properties props)
{
super.removeProperty(key, props);
}
public static synchronized int[] checkRegisteredServers(String gwhost, String gwserv, String tpname)
{
return nativeCheckRegisteredServers(gwhost, gwserv, tpname);
}
public static synchronized int[] removeRegisteredServers(String gwhost, String gwserv, String tpname)
{
return nativeRemoveRegisteredServers(gwhost, gwserv, tpname);
}
public static void testCodepage(byte bytes_in[], char chars_out[], char chars_in[], byte bytes_out[], String codepage, int mode)
{
nativeTestCodepage(bytes_in, chars_out, chars_in, bytes_out, codepage, mode);
}
protected static native int nativeInitialize();
protected static native void nativeSetMode(int i);
protected static native String nativeGetVersion();
protected static native void nativeSetRfcTrace(com.sap.mw.jco.JCO.Connection connection, boolean flag);
protected native void nativeGetAttributes(com.sap.mw.jco.JCO.Connection connection);
protected native void nativeDisconnect(com.sap.mw.jco.JCO.Connection connection);
protected native void nativeAbort(com.sap.mw.jco.JCO.Connection connection, String s);
protected native boolean nativeIsAlive(com.sap.mw.jco.JCO.Connection connection);
protected static native void nativeSetTraceLevel(int i);
protected static native void nativeTestCodepage(byte abyte0[], char ac[], char ac1[], byte abyte1[], String s, int i);
protected static native int[] nativeCheckRegisteredServers(String s, String s1, String s2);
protected static native int[] nativeRemoveRegisteredServers(String s, String s1, String s2);
protected static native void nativeAllowStartOfPrograms(String s);
private static final String VERSION = "2.1.5 (2005-02-15)";
private static final String REQUIRED_RFC_VERSION = "640.0.59";
private static String libjrfc_version;
private static String librfc_version;
private static String librfc_numversion;
private static String librfc_sap_codepage;
private static String librfc_rfc_trace;
private static String librfc_cpic_trace;
private static int wait_for_request_time = 2;
private static int default_cpc_mode = 0;
private static int middleware_mode = 0;
private static final int JCO_MONITORING_ON = 1;
private static int mw_max_startup_delay = 3600;
private static final String JCO_LIBJRFC_VERSION = "jco.middleware.libjrfc_version";
private static final String JCO_LIBJRFC_PATH = "jco.middleware.libjrfc_path";
private static final String JCO_LIBRFC_VERSION = "jco.middleware.librfc_version";
private static final String JCO_LIBRFC_NUMVERSION = "jco.middleware.librfc_numversion";
private static final String JCO_LIBRFC_PATH = "jco.middleware.librfc_path";
private static final String JCO_LIBRFC_SAP_CODEPAGE = "jco.middleware.librfc_sap_codepage";
private static final String JCO_LIBRFC_RFC_TRACE = "jco.middleware.librfc_rfc_trace";
private static final String JCO_LIBRFC_CPIC_TRACE = "jco.middleware.librfc_cpic_trace";
private static final String JCO_SNC_LIB = "jco.middleware.snc_lib";
private static final String JCO_WAIT_FOR_REQUEST_TIME = "jco.middleware.wait_for_request_time";
private static final String JCO_MW_MAX_STARTUP_DELAY = "jco.middleware.max_startup_delay";
private static final String JCO_ALLOW_START_OF_PROGRAMS = "jco.middleware.allow_start_of_programs";
private static final String JCO_MONITORING_MODE = "jco.middleware.monitoring";
private static final String JCO_CPC_DEFAULT_MODE = "jco.cpc.default_mode";
private static final String pinfo[][] = {
{
"jco.middleware.name", "Name of the middleware implementation"
}, {
"jco.middleware.version", "Version of the middleware implementation"
}, {
"jco.middleware.libjrfc_version", "Version of the sapjcorfc library"
}, {
"jco.middleware.libjrfc_path", "Path to loaded sapjcorfc library"
}, {
"jco.middleware.librfc_version", "Version of the RFC library as descriptive string"
}, {
"jco.middleware.librfc_numversion", "Version of the RFC library as numerical string"
}, {
"jco.middleware.librfc_path", "Path to loaded RFC library"
}, {
"jco.middleware.librfc_sap_codepage", "SAP_CODEPAGE environment variable"
}, {
"jco.middleware.librfc_rfc_trace", "RFC_TRACE environment variable"
}, {
"jco.middleware.librfc_cpic_trace", "CPIC_TRACE environment variable"
}, {
"jco.middleware.snc_lib", "Path to SNC library"
}, {
"jco.middleware.wait_for_request_time", "Time in seconds to wait incessantly for incoming requests"
}, {
"jco.middleware.max_startup_delay", "Maximum server startup delay time in seconds"
}, {
"jco.middleware.allow_start_of_programs", "List of programs that are allowed to be started by the RFC library"
}, {
"jco.middleware.monitoring", "Turns on reporting performance data for each call"
}
};
static
{
librfc_sap_codepage = "";
librfc_rfc_trace = "";
librfc_cpic_trace = "";
try
{
String version = System.getProperty("java.version");
int index = version.indexOf("1.1");
if(index == 0 || index > 0 && version.charAt(index - 1) != '.')
throw new ExceptionInInitializerError("JCO.nativeInit(): SAP Java Connector runs with java version 1.2.2 or higher only");
try
{
default_cpc_mode = Integer.parseInt(System.getProperty("jco.cpc.default_mode"));
}
catch(Exception ex)
{
default_cpc_mode = 0;
}
String jcolibname = null;
String libjrfcpath = null;
if(libjrfc_version == null)
try
{
jcolibname = System.getProperty("jco.middleware_library", "sapjcorfc");
libjrfcpath = loadLibrary(jcolibname);
libjrfc_version = nativeGetVersion();
}
catch(UnsatisfiedLinkError error)
{
if(libjrfcpath == null)
throw new ExceptionInInitializerError("JCO.nativeInit(): Could not initialize dynamic link library " + jcolibname + " [" + error.getMessage() + "]. java.library.path [" + System.getProperty("java.library.path", "empty") + "]");
if(libjrfc_version == null)
throw new ExceptionInInitializerError("JCO.nativeInit(): Could not initialize dynamic link library " + jcolibname + " [" + libjrfcpath + "]. Required version \"" + "2.1.5 (2005-02-15)" + "\".");
}
if(!libjrfc_version.equals("2.1.5 (2005-02-15)"))
throw new ExceptionInInitializerError("JCO.nativeInit(): Could not initialize dynamic link library " + jcolibname + ". Found version \"" + libjrfc_version + "\" but required version \"" + "2.1.5 (2005-02-15)" + "\".");
if(nativeInitialize() != 0)
throw new ExceptionInInitializerError("JCO.nativeInit(): Could not initialize dynamic link library " + jcolibname + ".");
try
{
librfc_numversion = extractRFCLibraryVersion(librfc_version);
if(compareVersions(librfc_numversion, "640.0.59") < 0)
throw new ExceptionInInitializerError("JCO.nativeInit(): Could not initialize dynamic link library librfc. Found version \"" + librfc_numversion + "\" but required at least version \"" + "640.0.59" + "\".");
}
catch(NumberFormatException nfex) { }
IMiddleware.properties.put("jco.middleware.name", jcolibname);
IMiddleware.properties.put("jco.middleware.version", "2.1.5 (2005-02-15)");
IMiddleware.properties.put("jco.middleware.libjrfc_version", libjrfc_version);
IMiddleware.properties.put("jco.middleware.libjrfc_path", libjrfcpath);
IMiddleware.properties.put("jco.middleware.librfc_version", librfc_version);
IMiddleware.properties.put("jco.middleware.librfc_numversion", librfc_numversion);
IMiddleware.properties.put("jco.middleware.librfc_sap_codepage", librfc_sap_codepage);
IMiddleware.properties.put("jco.middleware.librfc_rfc_trace", librfc_rfc_trace);
IMiddleware.properties.put("jco.middleware.librfc_cpic_trace", librfc_cpic_trace);
IMiddleware.properties.put("jco.middleware.snc_lib", "SECUDE.dll");
IMiddleware.properties.put("jco.middleware.wait_for_request_time", "2");
IMiddleware.properties.put("jco.middleware.max_startup_delay", "3600");
}
catch(Exception ex)
{
throw new ExceptionInInitializerError(ex.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -