handler

Reactor模式详解

余生颓废 提交于 2019-12-18 16:45:59
转自:http://www.blogjava.net/DLevin/archive/2015/09/02/427045.html 前记 第一次听到Reactor模式是三年前的某个晚上,一个室友突然跑过来问我什么是Reactor模式?我上网查了一下,很多人都是给出NIO中的 Selector的例子,而且就是NIO里Selector多路复用模型,只是给它起了一个比较fancy的名字而已,虽然它引入了EventLoop概 念,这对我来说是新的概念,但是代码实现却是一样的,因而我并没有很在意这个模式。然而最近开始读Netty源码,而Reactor模式是很多介绍Netty的文章中被大肆宣传的模式,因而我再次问自己,什么是Reactor模式?本文就是对这个问题关于我的一些理解和尝试着来解答。 什么是Reactor模式 要回答这个问题,首先当然是求助Google或Wikipedia,其中Wikipedia上说:“The reactor design pattern is an event handling pattern for handling service requests delivered concurrently by one or more inputs. The service handler then demultiplexes the incoming requests

Android Handler Message and ListView

ⅰ亾dé卋堺 提交于 2019-12-18 15:32:22
问题 Here's my error: *** Uncaught remote exception! (Exceptions are not yet supported across processes.) android.util.AndroidRuntimeException: { what=1008 when=368280372 } This message is already in use. at android.os.MessageQueue.enqueueMessage(MessageQueue.java:171) at android.os.Handler.sendMessageAtTime(Handler.java:457) at android.os.Handler.sendMessageDelayed(Handler.java:430) at android.os.Handler.sendMessage(Handler.java:367) at android.view.ViewRoot.dispatchAppVisibility(ViewRoot.java

使用axis发布webservice - 小头猪 - JavaEye技术网站

只愿长相守 提交于 2019-12-18 15:05:12
首先到apache的网站下载axis的开发包,好久没看了,现在已经开始出2.0的啦,不过好像还不是很成熟,这里,我们还是用1.x的包。最新的是1.4的包。 一、服务器端开发 首先编写服务端程序,这时我们完全不用考虑他是不是当作webservcies来发布的,因为在写法上没有什么不同。比如我们写了一个很简单的java程序,代码如下: package samples.userguide.example2; public class Calculator { public int add(int i1, int i2) { return i1 + i2; } public int subtract(int i1, int i2) { return i1 - i2; } } 如果我们要把他发布成为services,首先需要把axis-1_3下的lib文件复制到我们的web服务的web-inf 的lib下。 然后在web.xml里增加以下内容 <servlet> <display-name>Apache-Axis Servlet</display-name> <servlet-name>AxisServlet</servlet-name> <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class> <

Spring MVC DispatcherServlet分析

无人久伴 提交于 2019-12-18 13:09:21
前言 Spring MVC是工作在Java Servlet之上的一套MVC框架,本文将通过分析Spring MVC的请求处理流程来学习Spring MVC的工作原理。 主要将分析: DispatcherServlet 控制请求处理全局流程 HandlerMapping 控制请求到处理器的路由 HandlerAdapter 用于适配任何处理器接口 HandlerExceptionResolver 处理处理器异常 ViewResolver 解析视图名称到视图对象 版本:Spring Framework 4.3.x 1.DispatcherServlet DispatcherServlet是HTTP请求处理程序的中央调度器,它主要包括以下组件: HandlerMapping 多个,存在先后顺序 HandlerAdapter 多个,存在先后顺序 HandlerExceptionResolver 多个,存在先后顺序 ViewResolver 多个,存在先后顺序 组件的注册 支持多个组件的组件类型,将从上下文中根据类型获取。对于单个组件类型,根据bean名称和类型获取实例。如果没有找到,使用默认配置。 请求的处理流程 首先遍历询问 HandlerMapping 列表查找匹配的处理器,返回一个 HandlerExecutionChain 。 HandlerExecutionChain 包含了

Android Handler changing WeakReference

▼魔方 西西 提交于 2019-12-18 12:06:10
问题 My static handler has a WeakReference to my Activity (this is to prevent the well documented memory leak issue). I post a long delayed message and I want this message delivered to my activity (which should be in the foreground). My concern is that on orientation change, my activity is destroyed and the handler has a reference to the old activity which should have been destroyed. In order to get around this in my onCreate for the activity I do this. if(mHandler == null) mHandler = new

Passing arguments to an event handler

余生颓废 提交于 2019-12-18 10:23:12
问题 In the below code, I am defining an event handler and would like to access the age and name variable from that without declaring the name and age globally. Is there a way I can say e.age and e.name ? void Test(string name, string age) { Process myProcess = new Process(); myProcess.Exited += new EventHandler(myProcess_Exited); } private void myProcess_Exited(object sender, System.EventArgs e) { // I want to access username and age here. //////////////// eventHandled = true; Console.WriteLine(

When to use a Service or AsyncTask or Handler?

[亡魂溺海] 提交于 2019-12-18 10:02:52
问题 Can someone tell me the TRUE difference? 回答1: My rule of thumb is that an AsyncTask is for when I want to do something tied to single Activity and a Service is for when I want to do something that will carry on after the Activity which started it is in the background. So if I want to do a small bit of background processing in the Activity without tying up the UI I'll use an AsyncTask . I'll then use the default Handler from that Activity to pass messages back to ensure updates happen on the

When to use a Service or AsyncTask or Handler?

╄→尐↘猪︶ㄣ 提交于 2019-12-18 10:02:50
问题 Can someone tell me the TRUE difference? 回答1: My rule of thumb is that an AsyncTask is for when I want to do something tied to single Activity and a Service is for when I want to do something that will carry on after the Activity which started it is in the background. So if I want to do a small bit of background processing in the Activity without tying up the UI I'll use an AsyncTask . I'll then use the default Handler from that Activity to pass messages back to ensure updates happen on the

SpringMVC工作原理

笑着哭i 提交于 2019-12-18 09:15:09
SpringMVC框架介绍 Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面。   spring 框架提供了构建 Web 应用程序的全功能 MVC 模块。使用 Spring 可插入的 MVC 架构,可以选择是使用内置的 Spring Web 框架还是 Struts 这样的 Web 框架。通过策略接口,Spring 框架是高度可配置的,而且包含多种视图技术,例如 JavaServer Pages(JSP)技术、Velocity、Tiles、iText 和 POI。Spring MVC 框架并不知道使用的视图,所以不会强迫您只使用 JSP 技术。 Spring MVC 分离了控制器、模型对象、分派器以及处理程序对象的角色,这种分离让它们更容易进行定制。 Spring的MVC框架主要由DispatcherServlet、处理器映射、处理器(控制器)、视图解析器、视图组成 Spring MVC工作流程图 图一 图二 图 三 SpringMVC工作流程描述 1. 用户向服务器发送请求,请求被Spring 前端核心控制器 DispatcherServle t捕获; 2. DispatcherServlet对请求URL进行解析,得到请求资源标识符(URI)。然后根据该URI

Getting a Handler from a Thread from Service to Activity

拜拜、爱过 提交于 2019-12-18 07:23:40
问题 Situation: activity binds to started foreground service. service hands out local binder to activity. activity gets reference to service through a getService() call. activity wants to communicate directly with a thread running in the service using messages. It calls the mService.getThreadHandler() method from the activity. Problem: how do I get a Handler from the current running thread into the active activity, so that I can post messages directly to the threads messagequeue? I don't what to