第一次尝试从 swing 应用程序连接到 glassfish v3 时,速度非常慢。需要 4-10 秒。
在客户端:
public void myMethod(){
NewSessionBeanRemote facade;
try {
InitialContext ic = new InitialContext();
facade = (NewSessionBeanRemote) ic.lookup(NewSessionBeanRemote.class.getName());
target.setText(facade.businessMethod());
} catch (NamingException ex) {
ex.printStackTrace();
}
}
在服务器端:
@Stateless
public class NewSessionBean implements NewSessionBeanRemote {
@Override
public String businessMethod() {
return String.valueOf(Math.random() + 121 + 300);
}
}
@Remote
public interface NewSessionBeanRemote {
String businessMethod();
}
我需要改变什么环境?
最佳答案
When trying to connect to glassfish v3 from swing application it is very slow for the first time.
可能是由于 lazy initialization of Application Server services (EJB 容器、连接池...)。
Takes 4-10 seconds.
后续调用呢?
关于java - 第一次连接到 Glassfish v3 很慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3707369/