Spring RMI 源码浅析-RmiProxyFactoryBean 调用服务

Spring 实现远程访问详解——rmi Spring为各种远程访问技术提供集成工具类。Spring远程访问通过使用普通POJOs,能更容易的开发远程访问服务。目前,Spring远程访问的主要技术如下: 1. 远程调用RMI(Remote Method Invocation): 通过使用 RmiProxyFactoryBean 和 RmiServiceExporter,并且,Spring支持两个传统的RMI(使用 java.rmi.Remote接口和java.rmi.RemoteException)和通过RMI调用器实现的暴露远程调用(支持任何Java接口)。 2. Spring的HTTP调用器(Spring’s Http Invoker): Spring提供了一种特殊的允许通过HTTP进行Java串行化的远程调用策略,支持任意Java接口(就像RMI调用器)。相对应的支持类是 HttpInvokerProxyFactoryBean和 HttpInvokerServiceExporter。 3. Hessian: 通过 HessianProxyFactoryBean 和 HessianServiceExporter,可以使用Caucho提供的基于HTTP的轻量级二进制协议来透明地暴露服务。 4. Burlap: Burlap是Caucho的另外一个子项目,可以作为Hessian基于XML的替代方案。Spring提供了诸如 BurlapProxyFactoryBean 和 BurlapServiceExporter 的支持类。 5. JAX RPC: Spring通过JAX-RPC为远程Web服务提供支持(J2EE 1.4's web service API)。 6. JAX-WS:Spring通过JAX-WS为远程Web服务提供支持(the successor of JAX-RPC, as introduced in Java EE 5 and Java 6)。 7. JMS:远程访问通过类JmsInvokerServiceExporter和JmsInvokerProxyFactoryBean使用JMS的底层协议实现。 二. 远程访问------RMI 1. RMI远程访问基本流程 1). 服务端定义远程访问接口; 2). 服务端通过RmiServiceExporter暴露服务接口 3). 客户端定义与服务端已暴露的相同接口 4). 客户端通过RmiProxyFactoryBean调用服务接口 立即下载

 spring Rmi 客户端是通过 RmiProxyFactoryBean 和它的父类来完成 查找远程对象  生成代理对象 方法调用

 RmiProxyFactoryBean 定义

public class RmiProxyFactoryBean extends RmiClientInterceptor implements FactoryBean, BeanClassLoaderAware {
}

父类RmiClientInterceptor 定义

public class RmiClientInterceptor extends RemoteInvocationBasedAccessor implements MethodInterceptor {

	//spring容器 bean实例化阶段  是否要 查找远程对象 预查找 
	private boolean lookupStubOnStartup = true;

	//查找过的 远程对象是否进行缓存  
	private boolean cacheStub = true;

	//如果连接失败 是否刷新远程调用stub  
	private boolean refreshStubOnConnectFailure = false;

	//rmi客户端 套接字工厂  
	private RMIClientSocketFactory registryClientSocketFactory;

	//缓存远程调用对象
	private Remote cachedStub;

	//查找远程对象时用到的监控器  
	private final Object stubMonitor = new Object();
	
	//.....略
}

一:查找远程服务对象

  RmiProxyFactoryBean 是InitializingBean接口的实现   Spring容器在bean的实例化(getBean)阶段  回调afterPropertiesSet 来查找远程对象  然后 生成远程代理对象

	public void afterPropertiesSet() {
		//父类RmiClientInterceptor检查serviceUrl是否配置
		//父类RmiClientInterceptor 查找远程对象 
		super.afterPropertiesSet();
		//远程调用接口检查
		if (getServiceInterface() == null) {
			throw new IllegalArgumentException("Property 'serviceInterface' is required");
		}
		//创建代理对象
		//因为父类RmiClientInterceptor实现了 MethodInterceptor 接口  所以this
		this.serviceProxy = new ProxyFactory(getServiceInterface(), this).getProxy(getBeanClassLoader());
	}

父类RmiClientInterceptor的 afterPropertiesSet 方法 干了两件事

1.验证是否配置了serviceUrl  如果没有 抛出异常 

2.查找远程对象

	public void afterPropertiesSet() {
		//检查serviceUrl 属性是否为空 如果为空直接抛出异常
		super.afterPropertiesSet();
		//查找远程对象 
		prepare();
	}
	public void prepare() throws RemoteLookupFailureException {
		//预查找远程对象 默认为true
		if (this.lookupStubOnStartup) {
			//通过标准Api  查找远程对象
			Remote remoteObj = lookupStub();
			//是否对stub进行缓存
			if (this.cacheStub) {
				this.cachedStub = remoteObj;
			}
		}
	}

通过java API查找远程对象

	protected Remote lookupStub() throws RemoteLookupFailureException {
		try {
			Remote stub = null;
			if (this.registryClientSocketFactory != null) {
				...略			}
			else {
				//TODO 通过客户端配置 serviceUrl查找对象
				stub = Naming.lookup(getServiceUrl());
			}
			return stub;
		}
		catch (MalformedURLException ex) {
			throw new RemoteLookupFailureException("Service URL [" + getServiceUrl() + "] is invalid", ex);
		}
		catch (NotBoundException ex) {
			throw new RemoteLookupFailureException(
					"Could not find RMI service [" + getServiceUrl() + "] in RMI registry", ex);
		}
		catch (RemoteException ex) {
			throw new RemoteLookupFailureException("Lookup of RMI stub failed", ex);
		}
	}

二:返回代理对象

  RmiProxyFactoryBean是FactoryBean接口的实现 其返回的是getObject方法 返回的对象

	/**
	 * 返回远程代理对象
	 * 创建代理对象 是在afterPropertiesSet 方法完成
	 */
	public Object getObject() {
		return this.serviceProxy;
	}

三:调用方法

 父类实现了MethodInterceptor接口  在客户端调用方法时会被拦截

	public Object invoke(MethodInvocation invocation) throws Throwable {
		//获取远程对象  如果配置了缓存cacheStub=true  从缓存中获取  缓存中没有 现在立刻查找 
		Remote stub = getStub();
		try {
			//TODO 客户端调用远程方法时  拦截处理
			return doInvoke(invocation, stub);
		}
		catch (RemoteConnectFailureException ex) {
			return handleRemoteConnectFailure(invocation, ex);
		}
		catch (RemoteException ex) {
			//如果是连接失败异常
			if (isConnectFailure(ex)) {
				//处理连接失败. 是否需要刷新
				return handleRemoteConnectFailure(invocation, ex);
			}
			else {
				throw ex;
			}
		}
	}

 方法调用,如果是标准的Rmi 通过反射调用,非标准的交给doInvoke方法处理

	protected Object doInvoke(MethodInvocation invocation, Remote stub) throws Throwable {
		//spring RmiInvocationHandler包装的远程对象   非实现Remote接口的
		if (stub instanceof RmiInvocationHandler) {
			try {
				//不是标准的Rmi
				return doInvoke(invocation, (RmiInvocationHandler) stub);
			}
			//....略
		}
		else {
			//标准的java Rmi
			try {
				//直接通过反射调用 
				return RmiClientInterceptorUtils.invokeRemoteMethod(invocation, stub);
			}
			//....略
		}
	}

标准Rmi方法调用处理 RmiClientInterceptorUtils的  invokeRemoteMethod方法

public static Object invokeRemoteMethod(MethodInvocation invocation, Object stub)
			throws InvocationTargetException {

		Method method = invocation.getMethod();
		try {
			if (method.getDeclaringClass().isInstance(stub)) {
				// directly implemented
				return method.invoke(stub, invocation.getArguments());
			}
			else {
				// not directly implemented
				Method stubMethod = stub.getClass().getMethod(method.getName(), method.getParameterTypes());
				return stubMethod.invoke(stub, invocation.getArguments());
			}
		}
		catch (InvocationTargetException ex) {
			throw ex;
		}
		catch (NoSuchMethodException ex) {
			throw new RemoteProxyFailureException("No matching RMI stub method found for: " + method, ex);
		}
		catch (Throwable ex) {
			throw new RemoteProxyFailureException("Invocation of RMI stub method failed: " + method, ex);
		}
	}

 非标准Rmi处理 方法名 参数封装成InvocationHandler 通过中转站方法调用目标方法

	protected Object doInvoke(MethodInvocation methodInvocation, RmiInvocationHandler invocationHandler)
	    throws RemoteException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
		// 如果是toString方法 
		if (AopUtils.isToStringMethod(methodInvocation.getMethod())) {
			return "RMI invoker proxy for service URL [" + getServiceUrl() + "]";
		}
		//invocationHandler spring包装过的Rmi远程对象   服务端在暴露服务时包装
		//createRemoteInvocation方法 返回RemoteInvocation实例  封装了方法调用相关信息  例如:参数, 方法名
		//Rmi服务端接受到信息后  会通过RemoteInvocation封装的信息 进行调用
		return invocationHandler.invoke(createRemoteInvocation(methodInvocation));
	}

RemoteInvocation定义 

public class RemoteInvocation implements Serializable {

	private String methodName;

	private Class[] parameterTypes;

	private Object[] arguments;

	private Map attributes;

	public RemoteInvocation(MethodInvocation methodInvocation) {
		this.methodName = methodInvocation.getMethod().getName();
		this.parameterTypes = methodInvocation.getMethod().getParameterTypes();
		this.arguments = methodInvocation.getArguments();
	}
}

对于客户端方法调用 有两种形式

1、标准的Rmi 即实现了jdk Remote接口的   直接使用反射机制调用

2、非标准的Rmi  spring暴露服务时包装成自己的对象[RmiInvocationHandler]  当客户段调用的时候   被拦截器拦截  封装方法名  参数等信息 最后调用RmiInvocationHandler的invoke方法  invoke方法类似中转站(泛化调用)   只要非标准Rmi 方法调用都会经过它调用目标方法。

【项目立项管理、项目整合管理】30天通过软考高项-第二天 ①项目或阶段的概述;②范围目标、范围的评估标准,证明达到完⼯标准的证据;③质量目标、项目和产品质量的评估标准、相关核实信息和实际里程碑交付日期以及偏差原因;④成本目标,包括可接受的成本区间、实际成本,产⽣任何偏差的原因等;⑤最终产品、服务或成果的确认信息的总结;⑥进度计划目标,包括成果是否实现项目预期效益:如果在项目结束时未能实现效益,则指出效益实现程度并预计未来实现情况; 阅读详情

相关推荐

STM32CubeMX和华为LiteOS Studio开发STM32

传统的STM32的开发通常使用Keil/IAR这类开发软件,随着物联网时代的到来,传统嵌入式的发展不断向物联网方向靠拢,而Keil/IAR这类开发软件无法满足IoT一站式的开发,华为LiteOS Studio结合STM32CubeMX可以快速,高效地进行物联网开发,本文提供一种开发思路及环境的配置方法。...

weixin_45680600的博客 2833

spring rmi客户端原理-RmiProxyFactoryBean

spring中rmi客户端引入使用org.springframework.remoting.rmi.RmiProxyFactoryBean进行rmi代理 如 @Bean private RmiProxyFactoryBean login() { RmiProxyFactoryBean rmiProxyFactory = new RmiProxyFactoryBean(); rmiPro...

ChinFeng的专栏 3362

第三方系统(异构系统)基于token身份认证方式访问Ecology9的Restful接口Ecology9服务器配置部分

通过Token的认证方式调用Ecology9系统Restful业务接口服务器配置部分

svsou的专栏 2175

Spring框架学习【Spring RMI实现远程调用】

1.Spring除了使用基于HTTP协议的远程调用方案,还为开发者提供了基于RMI机制的远程调用方法,RMI远程调用网络通信实现是基于TCP/IP协议完成的,而不是通过HTTP协议。 在Spring RMI实现中,集成了标准的RMI-JRIM解决方案,该方案是java虚拟机实现的一部分,它使用java序列化来完成对象的传输,是一个java到java环境的分布式处理技术,不涉及异构平台的处理。

zhixiang2010的专栏 2340

5分钟快速搭建:使用ros1_bridge实现ROS2容器与ROS1主机的无缝通信

本文详细介绍了如何在5分钟内快速搭建基于ros1_bridge的通信方案,实现运行在Docker容器中的ROS2节点与宿主机ROS1系统的无缝数据交换。通过环境隔离、Docker容器化部署及选择性桥接配置,该方案能有效整合新旧系统,避免大规模代码重构,是机器人项目渐进式升级的实用策略。

weixin_29268637的博客 179

手把手教你用DaVinci Configurator配置AUTOSAR SWC接口(含RTE避坑指南)

本文提供了一份基于DaVinci Configurator工具的AUTOSAR软件组件(SWC)接口配置实战指南。文章详细拆解了SR(发送者-接收者)和CS(客户端-服务器)接口的配置流程,并重点分享了运行时环境(RTE)生成阶段在多核部署、数据类型匹配等常见陷阱中的避坑方案与调试技巧,旨在帮助汽车电子工程师高效完成配置并规避错误。

uuu88的博客 547

Spring源码深度解析 远程服务总结

RMI 使用示例 建立 RMI 对外接口 建立接 口实现类 建立服务端配置文件。 建立服务端测试 完成了服务端的配置后,还需要在测试端建立测试环境以及测试代码 首先建立测试 端配置文件 编写测试代码 服务端实现 启动 Spring 中的 RMI 服务并没有多余的操作,仅仅是开启 Spring 的环境 new ClassPathXmlApplicationContext(”test/remote/RMIServer.xml ”),仅此一句 于是, 分析很可能是 RMIServiceExporte

勤劳的搬运工 787

ARM 汇编指令:LSL(逻辑左移) 和 LSR(逻辑右移)

ARM 汇编中的 LSL(逻辑左移)和 LSR(逻辑右移)是基础移位指令,分别实现二进制位的左移和右移操作。LSL 低位补0,等效于乘以2^n;LSR 高位补0,等效于无符号除以2^n。这两个指令可以单独使用或与其他指令结合(如ADD、MOV等),利用ARM的"桶形移位器"硬件实现高效运算。关键特性包括:移位范围0-31(LSL)或1-32(LSR),可选更新标志位,以及与其他指令结合时的无额外开销优势。LSR与ASR(算术右移)的主要区别在于高位填充方式,分别适用于无符号和有符号数处理

guigenyi的专栏 1812

spring-RMI及底层实现原理

Java远程方法调用,即Java RMI(Java Remote Method Invocation),是java里一种实现远程过程调用的应用程序编程接口。java RMI极大地依赖于接口。在需要创建一个远程对象时,程序员通过传递一个接口来隐藏底层的实现细节。客户端得到的远程对象句柄正好与本地的桩代码连接,由后者负责透过网络通信。这样一来,程序员只需关心如何通过自己的接口句柄发送消息。 在spring中,同样提供了对RMI的支持,使得在spring下的RMI开发变得更方便。 /** * 服务接口 */

xianmingsu的博客 758

bcftools实战指南:从VCF文件处理到变异分析全流程解析

在基因组数据分析中,VCF(Variant Call Format)文件是存储基因序列变异信息的标准格式,广泛应用于群体遗传学和生物信息学研究。其核心原理是通过结构化文本记录SNP、INDEL等变异位点的基因型、质量值和注释信息。掌握高效处理VCF文件的技术,对于提升变异检测、数据清洗和下游分析的工作流效率具有重要价值。在生物信息学工具生态中,bcftools作为处理VCF/BCF文件的瑞士军刀,通过模块化设计实现了数据查询、过滤、统计和格式转换等核心功能。其流式处理架构支持管道化操作,能有效应对海量基因组

weixin_29081703的博客 322

HFSS15 win10_64位破解

HFSS15 win10_64位破解 找到的别人的软件,但在首次安装时失败了,并不能patched。寻找了几种方法,已成功安装。在此写下安装经验,供大家参考。 软件安装包以及破解软件: 链接:https://pan.baidu.com/s/1MMjV_31maU5QD6fmI4zfIA 提取码:yj4q 在安装之前,建议关闭杀毒软件。 Step1:进入HFSS150Win64安装包,点击au...

玉笙寒 4万+

《Spring技术内幕》学习笔记19——Spring RMI实现远程调用

1.Spring除了使用基于HTTP协议的远程调用方案,还为开发者提供了基于RMI机制的远程调用方法,RMI远程调用网络通信实现是基于TCP/IP协议完成的,而不是通过HTTP协议。 在Spring RMI实现中,集成了标准的RMI-JRIM解决方案,该方案是java虚拟机实现的一部分,它使用java序列化来完成对象的传输,是一个java到java环境的分布式处理技术,不涉及异构平台的处理。

Tony Chen的专栏 1万+

VMware vSphere运维管理手册

ESXi 7.0 引入了一种系统存储布局,可对大型模块和第三方组件进行灵活的分区管理和支持,同时简化了调试操作。ESXi 7.0 系统存储更改在 ESXi 7.0 之前,分区大小固定不变,除 /scratch 分区和可选 VMFS 数据存储之外,且分区号是静态的,这些限制了分区管理。在 ESXi 7.0 中,分区整合为更少且更大的可扩展分区,具体取决于所使用的引导介质及其容量。ESXi 7.0 系统存储布局包含四个分区:分区适用情况类型系统引导存储引导加载程序和 EFI 模块。FAT16。

Avenjan优快云博客 3624

Spring RMI源码解读

RMI(Remote Method Invocation)远程方法调用是java的核心技术之一。是Enterprise JavaBeans的基础技术,是java建立分布式应用程序的强大支柱。 RMI允许一个应用程序访问另外一个服务器或虚拟机上的对象,方法和服务,它使远程方法调用就像在本地调用一样简单。它为用户屏蔽了底层的网络传输细节,使用的时候只需适当处理异常即可。所以RMI是非常容易使用的,但同时是非常强大的。

Charles-代码人生 2066

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

远程服务RMI源码解析(三)客户端实现

RMI客户端源码解析: 根据客户端配置文件,锁定入口类为RMIProxyFactoryBean, 客户端配置文件: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" h

u012291108的博客 2614

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

Spring RMI源码分析

1.客户端RmiProxyFactoryBean继承关系 # RemotingSupport  # \----RemoteAccessor  #      \----UrlBasedRemoteAccessor  #           \----RemoteInvocationBasedAccessor  #                \----RmiClientIntercept

sinat_23002655的博客 477

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

Spring RMI实现远程调用及源码

1.RMI简单介绍 Spring除了使用基于HTTP协议的远程调用方案,还为开发者提供了基于RMI机制的远程调用方法,RMI远程调用网络通信实现是基于TCP/IP协议完成的,而不是通过HTTP协议。 在Spring RMI实现中,集成了标准的RMI-JRIM解决方案,该方案是java虚拟机实现的一部分,它使用java序列化来完成对象的传输,是一个java到java环境的分布式处理技术,不涉及异

我只是一个简单的Coder,为了兴趣和理想奋斗在生活的道路上 1216

【dubbo源码解析~番外篇】--- JDK和Spring的RMI使用姿势简介

本文对应源码地址:https://github.com/nieandsun/dubbo-study 文章目录1 RMI简介2 JDK原生的RMI使用姿势 1 RMI简介 在不考虑dubbo的情况下,一个JVM里如何调用另一个JVM的方法? 我能想到 + 用到的姿势有: HttpClient RestTemplate WebService FeignClient ServerSocket/Socket 最近又学到了一种姿势RMI — Remote Method Invocation(远.

nrsc 707

Spring源码与分析总结——RMI整合

该文章基于《Spring源码深度解析》撰写,感谢郝佳老师的奉献 RMI的实际作用,是通过暴露对应方法的URL,从而实现高解耦。 RMI服务的流程是通过服务的发布和服务的调用组成,小Demo如下: 其工程架构如下 其对应文件代码如下 /*HelloRMIService*/ package RMIService.Impl; public class HelloRMIService i...

可爱滴老唐 688

spring RMI 解析

1.Spring除了使用基于HTTP协议的远程调用方案,还为开发者提供了基于RMI机制的远程调用方法,RMI远程调用网络通信实现是基于TCP/IP协议完成的,而不是通过HTTP协议。 在Spring RMI实现中,集成了标准的RMI-JRIM解决方案,该方案是java虚拟机实现的一部分,它使用java序列化来完成对象的传输,是一个java到java环境的分布式处理技术,不涉及异构平台的处理。

sivyer123的专栏 4974

Spring源码深度解析(郝佳)-学习-RMI使用及Spring源码解读

        java远程方法调用。

黄裳博客 588

Spring RMI实现远程调用

1. Spring 除了使用基于 HTTP 协议的远程调用方案,还为开发者提供了基于 RMI 机制的远程调用方法, RMI 远程调用网络通信实现是基于 TCP/IP 协议完成的,而不是通过 HTTP 协议。 在 Spring RMI 实现中,集成了标准的 RMI-JRIM 解决方案,该方案是 java 虚拟机实现的一部分,它使用 java 序列化来完成对象的传输,是一个 java 到 jav

先疯盗骨 1377

spring5.1.x源码解析之十(spring-rmi)

RMI demo package org.example.rmi.test; import java.rmi.*; public interface MyRemote extends Remote { public String sayHello() throws RemoteException; } package org.example.rmi.test; import java....

Nuan_Feng的博客 283

spring搭建Java RMI

服务器端: 1.创建接口 package service; public interface IRmiService { public String sayHello(); public void pringHello(); } 2.创建接口实现类 package serviceimp; import service.IRmiService; publi

Spring cloud 超时汇总 1023
上一篇: Spring FactoryBean源码浅析
下一篇: Spring HttpInvoker(一)
胸口碎大石_
博客等级 码龄17年 1154粉丝 82原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值