java 实例化PortableRemoteObject笔记
来源:互联网 发布:开淘宝店前期如何推广 编辑:程序博客网 时间:2024/06/08 01:35
之前获取Bean实例都是new,spring context,class.newInstance。今天阅读发现一种新的实例方法。
该方法有如下优点:
1、对实例化作check
2、支持远程interface,abstract
此处为官方解释:
Server implementation objects may either inherit from javax.rmi.PortableRemoteObject or they may implement a remote interface and then use the exportObject method to register themselves as a server object. The toStub method takes a server implementation and returns a stub that can be used to access that server object. The connect method makes a Remote object ready for remote communication. The unexportObject method is used to deregister a server object, allowing it to become available for garbage collection. The narrow method takes an object reference or abstract interface type and attempts to narrow it to conform to the given interface. If the operation is successful the result will be an object of the specified type, otherwise an exception will be thrown.
该类可执行方法有:
static void connect(Remote target, Remote source)
Makes a Remote object ready for remote communication.
static void exportObject(Remote obj)
Makes a server object ready to receive remote calls.
static Object narrow(Object narrowFrom, Class narrowTo)
Checks to ensure that an object of a remote or abstract interface type can be cast to a desired type.
static Remote toStub(Remote obj)
Returns a stub for the given server object.
static void unexportObject(Remote obj)
Deregisters a server object from the runtime, allowing the object to become available for garbage collection.
具体执行方法为PortableRemoteObject.narrow(Object narrowFrom, Class narrowTo);返回一个实例的对象。
- java 实例化PortableRemoteObject笔记
- java.lang.ClassCastException com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow
- javax.rmi.PortableRemoteObject.narrow
- PortableRemoteObject.narrow方法杂谈
- Java Mail实例学习笔记
- Java]操作Mysql实例 笔记
- java初学笔记—实例化的含义
- Java4Android笔记之Java中的子类实例化过程
- 疯狂java笔记:子类实例变量。
- java学习笔记1 - Mybatis简单实例
- Java学习笔记3-多线程实例
- java笔记-网络编程-实例操作
- Java学习笔记(4) 项目搭建实例
- JAVA学习笔记- 网络编程登录实例
- Java学习笔记---------SqlHelper 类实例
- JAVA学习笔记-Semaphore和CountDownLatch实例
- 【Java学习笔记】I/O实例
- Protobuf笔记以及Java Javascript使用实例
- IO流_IO流概述及分类
- Linux下一个简单守护进程的实现 (Daemon)
- [stackoverflow翻译] “yield” 关键字有什么用?what-does-the-yield-keyword-do
- tegra_multimedia_api里的README
- sql语句中order by、group by和having的区别
- java 实例化PortableRemoteObject笔记
- IRP的同步
- zeppelin安装部署配置
- 1078. Hashing (25)
- sqlite应用2
- 数组程序练习
- C++循环的嵌套
- Vue.js学习系列四——Webpack学习实践
- TCP三次握手