欢迎来到天天文库
浏览记录
ID:37913206
大小:65.50 KB
页数:13页
时间:2019-06-02
《EJB工作原理学习笔记》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、EJB工作原理学习笔记EJB工作原理学习笔记1 publicintgetAge()throwsThrowable; publicStringgetName()throwsThrowable;} 2. intage; Stringname; publicPersonServer(Stringname,intage){ this.age=age; this.name=name; } publicintgetAge(){ returnage; } publicStringgetName(){ returnname;
2、}} 3.importjava.io.ObjectInputStream;importjava.net.Socket;publicclassPerson_StubimplementsPerson{ Socketsocket; publicPerson_Stub()throwsThrowable{ //connecttoskeleton socket=newSocket("computer_name",9000); } publicintgetAge()throwsThrowable{ //passmethodnametoskeleton
3、 ObjectOutputStreamoutStream= newObjectOutputStream(socket.getOutputStream()); outStream.writeObject("age"); outStream.flush(); ObjectInputStreaminStream= newObjectInputStream(socket.getInputStream()); returninStream.readInt(); } publicStringgetName
4、()throwsThrowable{ //passmethodnametoskeleton ObjectOutputStreamoutStream= newObjectOutputStream(socket.getOutputStream()); outStream.writeObject("name"); outStream.flush(); ObjectInputStreaminStream= newObjectInputStream(socket.getInputStream());
5、 return(String)inStream.readObject(); }} importjava.io.ObjectInputStream;importjava.net.Socket;importjava.net.ServerSocket;publicclassPerson_SkeletonextendsThread{ PersonServermyServer; publicPerson_Skeleton(PersonServerserver){ //getreferenceofobjectserver this.myServer=server;
6、 } publicvoidrun(){ try{ //newsocketatport9000 ServerSocketserverSocket=newServerSocket(9000); //acceptstub'srequest Socketsocket=serverSocket.accept(); while(socket!=null){ //getstub'srequest ObjectInputStreamin
7、Stream= newObjectInputStream(socket.getInputStream()); Stringmethod=(String)inStream.readObject(); //checkmethodname if(method.equals("age")
此文档下载收益归作者所有