---
title: "Hessian源码分析（三）------ HessianSkeleton"
author: "wxyfighting"
date: "2013-06-11T11:03:00Z"
tags: []
slug: "hessian-hessianskeleton"
draft: false
lastmod: "2013-06-12T14:33:26Z"
id: 1885619
url: "https://wxyfighting.iteye.com/blog/1885619"
---

HessianSkeleton是Hessian server端的核心类，主要功能是接收网络输入流（被包装为AbstractHessianInput），反序列化输入流得到methodName和参数，然后调用服务端的服务，得到结果后序列化为输出流，返回给客户端，主要流程如下图所示：

![](http://p.blog.csdn.net/images/p_blog_csdn_net/cutesource/EntryImages/20091205/HessianSkeleton.JPG)

HessianSkeleton的核心代码如下所示：

**\[java]**[view plain](http://blog.csdn.net/cutesource/article/details/4946968 "view plain")[copy](http://blog.csdn.net/cutesource/article/details/4946968 "copy")

01. publicvoidinvoke(Objectservice,
02. AbstractHessianInputin,
03. AbstractHessianOutputout)
04. throwsException
05. {
06. ......
07. StringmethodName=in.readMethod();
08. Methodmethod=getMethod(methodName);
09. ......
10. Class\[]args=method.getParameterTypes();
11. Object\[]values=newObject\[args.length];
12. for(inti=0;i&lt;args.length;i++){
13. values\[i]=in.readObject(args\[i]);
14. }
15. Objectresult=null;
16. try{
17. result=method.invoke(service,values);
18. }catch(Throwablee){
19. ......
20. }
21. //Thecompletecallneedstobeaftertheinvoketohandlea
22. //trailingInputStream
23. in.completeCall();
24. out.startReply();
25. out.writeObject(result);
26. out.completeReply();
27. out.close();
28. }

主流程代码非常清晰，不需要太多解释，关键的地方在于对网络流的序列化和反序列化，我会在hessian io分析的部分中进行详细阐述