rmi

EJB是什么?

不问归期 提交于 2019-11-29 19:17:02
1. 我们不禁要问,什么是"服务集群"?什么是"企业级开发"? 既然说了EJB 是为了"服务集群"和"企业级开发",那么,总得说说什么是所谓的"服务集群"和"企业级开发"吧!这个问题其实挺关键的,因为J2EE 中并没有说明白,也没有具体的指标或者事例告诉广大程序员什么时候用EJB 什么时候不用。于是大家都产生一些联想,认为EJB"分布式运算"指得是"负载均衡"提高系统的运行效率。然而,估计很多人都搞错了,这个"服务群集"和"分布式运算"并没有根本解决运行负载的问题,尤其是针对 数据库 的应用系统。 为什么? 我们先把EJB 打回原形给大家来慢慢分析。 2. 把EJB 掰开了揉碎了 我们把EJB 的概念好好的分析一下,看看能发现些什么蛛丝马迹。 3.1 EJB 概念的剖析 我们先看一下,EJB 的官方解释: 商务软件的核心部分是它的业务逻辑。业务逻辑抽象了整个商务过程的流程,并使用计算机语言将他们实现。 …… J2EE 对于这个问题的处理方法是将业务逻辑从客户端软件中抽取出来,封装在一个组件中。这个组件运行在一个独立的服务器上,客户端软件通过网络调用组件提供的服务以实现业务逻辑,而客户端软件的功能单纯到只负责发送调用请求和显示处理结果。在J2EE 中,这个运行在一个独立的服务器上,并封装了业务逻辑的组件就是EJB(Enterprise Java Bean)组件

RMI lookup works but method invocation not

血红的双手。 提交于 2019-11-29 17:30:39
UPDATE: The problem is, that i'm using a kind of 2-way connection. On client side, this works: String a = this.lobby.getMsg(); and this not: this.lobby.login((Player)UnicastRemoteObject.exportObject(player, 0)); and ideas? I'm working on a java application which uses RMI for network communication. On one computer everythings works good, but if i try to run it via the internet i ran into problems. It seems, that the client is able to retreive the registry from the server and to lookup the lobby-object. But if the client tries to call the login method of the lobby object via rmi, it takes very

In Java RMI, how can a client know that its server is dead?

蹲街弑〆低调 提交于 2019-11-29 15:44:35
Currently, I'm working on a chat server-client program which is built on Java RMI. In order for a client to detect that its connected server has been died, I can only think of two possible solutions, but neither of them works well in my case. 1. Wait until the client needs to invoke some methods of the server, this way does not work well because if the chat client does not invoke any method of server, it will not know that server is dead, thus the chat client can not receive any new chat message in that time anymore. 2. Routine check by invoking a server's method every few seconds. But this

Java RMI Proxy issue

时间秒杀一切 提交于 2019-11-29 11:59:01
I am getting this error: java.lang.ClassCastException: $Proxy0 cannot be cast to rmi.engine.Call at Main.main(Main.java:39) My Abstract and Call class both extend Remote . Call: public class Call extends UnicastRemoteObject implements rmi.engine.Abstract { public Call() throws Exception { super(Store.PORT, new RClient(), new RServer()); } public String getHello() { System.out.println("CONN"); return "HEY"; } } Abstract: public interface Abstract extends Remote { String getHello() throws RemoteException; } This is my main: public static void main(String[] args) { if (args.length == 0) { try {

How do I ensure that RMI uses only a specific set of ports?

萝らか妹 提交于 2019-11-29 09:27:53
问题 In our application, we are using RMI for client-server communication in very different ways: Pushing data from the server to the client to be displayed. Sending control information from the client to the server. Callbacks from those control messages code paths that reach back from the server to the client (sidebar note - this is a side-effect of some legacy code and is not our long-term intent). What we would like to do is ensure that all of our RMI-related code will use only a known

“ClassCastException: $Proxy0 cannot be cast” error while creating simple RMI application

久未见 提交于 2019-11-29 09:27:12
I am creating my first, very simple RMI client-server application. Here is the code: Interface "ICommunication" package itu.exercies.RMI.server; import java.rmi.Remote; import java.rmi.RemoteException; public interface ICommunication extends Remote { public String doCommunicate(String name) throws RemoteException; } Interface implementation "CommunicationImpl": package itu.exercies.RMI.server; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class CommunicationImpl extends UnicastRemoteObject implements ICommunication { /** * */ private static final long

When using a JMX server with ephemeral port, how to get the server port number?

人走茶凉 提交于 2019-11-29 06:12:51
When launching a Java application with these options: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=0 -Dcom.sun.management.jmxremote.local.only=false Java uses an ephemeral port, which is very useful to avoid collisions. Is it possible to get the actual port (or connection URL) programmatically from within the application ? String url = sun.management.ConnectorAddressLink.importRemoteFrom(0) .get("sun.management.JMXConnectorServer.0.remoteAddress"); System.out.println(url); This will

the significance of java RMI please? [closed]

跟風遠走 提交于 2019-11-29 03:18:07
Why do people use RMI, or when should I use RMI? I read those tutorials about RMI on oracle's website.But it doesn't provides enough practical examples. To my understanding, a software should have its modules as "unrelated and separated" as possible. RMI somehow seems to be an example of high coupling to me. Why is this not a bad coding practice? I thought the client should only fire instructions,whereas all the actually manipulations of the object were done by the server. (I am currently working towards a computer science bachelor degree and very inexperienced, so please correct me if I

Java RMI + SSL + Compression = IMPOSSIBLE!

99封情书 提交于 2019-11-29 02:10:39
I've setup RMI + SSL. This works great. But it doesn't seem possible to slip compression in between RMI and SSL. So that the RMI requests are compressed before they're sent over SSL. I've seen some posts online suggest using SSLSocketFactory.createSocket() which takes a Socket to wrap SSL over a compressing socket. But that seems like it would try to compress the SSL protocol itself, which probably isn't very compressable. I supposed I should create a Socket proxy (subclass of Socket that defers to another Socket , like FilterOutputStream does). Have the proxy wrap the Input/Ouput streams with

MyToy No.1: RMI

岁酱吖の 提交于 2019-11-29 01:52:45
假设有n个银行,每个银行有m个ATM,每台ATM都可以withdraw自己银行的钱(废话),也可以withdraw别的银行的钱,for example,工商银行的机器也可以插交通银行的卡。总之有一个叫CCH的地方(central......house,想不起来了:)来处理这种类型的提款。另外,ATM还有deposit的功能(真先进,两机一体化),那么处理别的银行的存款时,CCH也要负责处理。当然,ATM也可以仅仅查账,看看account里还剩多少钱。一般来说,account不能为负数(不要考虑小数点之类的问题,处理整数就ok了)。CCH里每个银行对应一个银行账户,记录每个银行一共有多少存款(即这个银行所有accounts的balance总和),每当有transaction的时候要同步更新。(纯粹给人添麻烦,这种信息实际怎么会公布给银行之外的人)。不用保持高事务性,即用不着考虑类似transaction进行到一半时,目标银行或者CCH的服务器突然挂掉了这类情况。所有的account记录用简单的文件操作就ok了。 exception情况,如果request的目标银行的服务器not available怎么办?通常对withdrawal都是拒绝操作,(举例来说,你用交行的卡到工行的机器上去拿钱,交行的服务器发现工行的服务器连不上,当然就不能给你提款了,万一你丫的乘机疯狂透支怎么办