📄 callhelloworld.java
字号:
package examples;
import java.security.*;
import javax.naming.*;
import java.util.Hashtable;
import javax.rmi.PortableRemoteObject;
/**
* This is a helper class that knows how to call a
* "Hello, World!" bean. It does so in a secure manner,
* automatically propagating the logged in security context
* to the J2EE server.
*/
public class CallHelloWorld implements PrivilegedAction {
/*
* This is our one business method. It performs an action
* securely, and returns application-specific results.
*/
public Object run() {
String result = "Error";
try {
/*
* Make a bean
*/
Context ctx = new InitialContext(System.getProperties());
Object obj = ctx.lookup("HelloHome");
HelloHome home = (HelloHome)
PortableRemoteObject.narrow(obj, HelloHome.class);
Hello hello = home.create();
/*
* Call a business method, propagating the security context
*/
result = hello.hello();
}
catch (Exception e) {
e.printStackTrace();
}
/*
* Return the result to the client
*/
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -