}
public <T> Exporter<T> export(final Invoker<T> invoker) throws RpcException {
if (! Remote.class.isAssignableFrom(invoker.getInterface())
&& "spring".equals(invoker.getUrl().getParameter("codec", "spring"))) {
final RmiServiceExporter rmiServiceExporter = new RmiServiceExporter();
rmiServiceExporter.setRegistryPort(invoker.getUrl().getPort());
rmiServiceExporter.setServiceName(invoker.getUrl().getPath());
rmiServiceExporter.setServiceInterface(invoker.getInterface());
rmiServiceExporter.setService(proxyFactory.getProxy(invoker));
try {
rmiServiceExporter.afterPropertiesSet();
} catch (RemoteException e) {
throw new RpcException(e.getMessage(), e);
}
Exporter<T> exporter = new Exporter<T>() {
public Invoker<T> getInvoker() {
return invoker;
}
public void unexport() {
try {
rmiServiceExporter.destroy();
} catch (Throwable e) {
logger.warn(e.getMessage(), e);
}
try {
invoker.destroy();