运行 Java 瘦客户机应用程序
可以在安装了 WebSphere® Application Client 或 WebSphere Application Server 的机器上运行 Java™ 瘦客户机应用程序。
关于此任务
要点: Java 瘦客户机未与 JDBC 提供程序类打包在一起。例如,WebSphere Application Server V8.5 Java 瘦客户机未与
Apache Derby 10.2 类打包在一起。因此,要在 Java 瘦客户机上利用 JDBC 提供程序类(例如
Apache Derby、Oracle、DB2®、Informix® 或 Sybase),必须执行下列步骤:
在客户机与服务器之间,用于运行 Java 瘦客户机应用程序的 Java 调用有所不同。如果 Java 瘦客户机应用程序需要同时在客户机安装版本和服务器安装版本上运行,请执行“在服务器上运行 Java 瘦客户机应用程序”主题中的步骤。- 将这些类添加到 Java 瘦客户机应用程序环境。
- 使这些类对 Java 瘦客户机应用程序可视。为此,请在启动了客户机程序的脚本内的客户机类路径中添加这些类的路径。
过程
示例
如果已为 WebSphere Application Server 实例启用安全性,那么 Java 瘦应用程序客户机不再需要其他代码就可以设置安全提供程序。应该除去在 IBM® i
Java 瘦客户机中找到的此代码,以防止迁移和兼容性问题。在 properties 目录中的来自
WebSphere 实例的 java.security 文件现在用来配置安全提供程序。
在启用安全性的情况下运行瘦客户机。以下代码示例说明如何在
main() 方法中通过编程设置安全提供程序并在访问企业 bean 的所有代码之前运行:
import java.security.*;
...
if (System.getProperty("os.name").equals("OS/400")) {
// Set the default provider list first.
Provider jceProv = null;
Provider jsseProv = null;
Provider sunProv = null;
// Allow for when the Provider is not needed, when
// it is not in the client application's classpath.
try {
jceProv = new com.ibm.crypto.provider.IBMJCE();
}
catch (Exception ex) {
ex.printStackTrace();
throw new Exception("Unable to acquire provider.");
}
try {
jsseProv = new com.ibm.jsse.JSSEProvider();
}
catch (Exception ex) {
ex.printStackTrace();
throw new Exception("Unable to acquire provider.");
}
try {
sunProv = new sun.security.provider.Sun();
}
catch (Exception ex) {
ex.printStackTrace();
throw new Exception("Unable to acquire provider.");
}
// Enable providers early and ahead of other providers
// for consistent performance and function.
if ( (null != sunProv) && (1 != Security.insertProviderAt(sunProv, 1)) ) {
Security.removeProvider(sunProv.getName());
Security.insertProviderAt(sunProv, 1);
}
if ( (null != jceProv) && (2 != Security.insertProviderAt(jceProv, 2)) ) {
Security.removeProvider(jceProv.getName());
Security.insertProviderAt(jceProv, 2);
}
if ( (null != jsseProv) && (3 != Security.insertProviderAt(jsseProv, 3)) ) {
Security.removeProvider(jsseProv.getName());
Security.insertProviderAt(jsseProv, 3);
}
// Adjust default ordering based on admin/startstd properties file.
// Maximum allowed in property file is 20.
String provName;
Class provClass;
Object provObj = null;
for (int i = 0; i < 21; i++) {
provName = System.getProperty("os400.security.provider."+ i);
if (null != provName) {
try {
provClass = Class.forName(provName);
provObj = provClass.newInstance();
}
catch (Exception ex) {
// provider not found
continue;
}
if (i != Security.insertProviderAt((Provider) provObj, i)) {
// index 0 adds to end of existing list
if (i != 0) {
Security.removeProvider(((Provider) provObj).getName());
Security.insertProviderAt((Provider) provObj, i);
}
}
} // end if (null != provName)
} // end for (int i = 0; i < 21; i++)
} // end if ("os.name").equals("OS/400")
有关 Java 瘦客户机应用程序的示例,请参阅“样本 V8.5”。