JavaAdapter扩展进行Service调用拦截处理
2010-06-17 20:28
369 查看
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 680460288 22 0 262145 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 680460288 22 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
Flex
客户端调用
java
服务可以通过
blazeds
来进行桥接,为此我们需要在
java
端配置
blazeds
的几个配置文件,如:
services-config.xml
、
remote-config.xml
等等。
配置完毕之后,我们即可在
flex
端访问
remote-config.xml
中配置的
service
了,有时我们需要在
service
调用时进行拦截处理,如调用前的相关验证处理,调用后的结果处理,为此就需要对
JavaAdapter
进行扩展。
package flex.messaging.services.remoting.adapters;
import flex.messaging.FactoryInstance;
import flex.messaging.messages.Message;
import
flex.messaging.messages.RemotingMessage;
import
flex.messaging.services.remoting.RemotingDestination;
public class JavaAdapterEX extends
JavaAdapter {
@Override
public
Object invoke(Message message) {
//RemotingMessage
remotingMessage = (RemotingMessage) message;
//RemotingDestination
remotingDestination = (RemotingDestination) getDestination();
//FactoryInstance
factoryInstance = remotingDestination
//
.getFactoryInstance();
//String
className = factoryInstance.getSource();
//do
something before invoke.
Object
result = super.invoke(message);
//do
something after invoke.
return
result;
}
}
修改
remote-config.xml
配置文件如下:
<
adapters
>
<
adapter-definition
id
=
"java-object"
class
=
"flex.messaging.services.remoting.adapters.JavaAdapterEX"
default
=
"true"
/>
</
adapters
>
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 680460288 22 0 262145 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 680460288 22 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
Flex
客户端调用
java
服务可以通过
blazeds
来进行桥接,为此我们需要在
java
端配置
blazeds
的几个配置文件,如:
services-config.xml
、
remote-config.xml
等等。
配置完毕之后,我们即可在
flex
端访问
remote-config.xml
中配置的
service
了,有时我们需要在
service
调用时进行拦截处理,如调用前的相关验证处理,调用后的结果处理,为此就需要对
JavaAdapter
进行扩展。
package flex.messaging.services.remoting.adapters;
import flex.messaging.FactoryInstance;
import flex.messaging.messages.Message;
import
flex.messaging.messages.RemotingMessage;
import
flex.messaging.services.remoting.RemotingDestination;
public class JavaAdapterEX extends
JavaAdapter {
@Override
public
Object invoke(Message message) {
//RemotingMessage
remotingMessage = (RemotingMessage) message;
//RemotingDestination
remotingDestination = (RemotingDestination) getDestination();
//FactoryInstance
factoryInstance = remotingDestination
//
.getFactoryInstance();
//String
className = factoryInstance.getSource();
//do
something before invoke.
Object
result = super.invoke(message);
//do
something after invoke.
return
result;
}
}
修改
remote-config.xml
配置文件如下:
<
adapters
>
<
adapter-definition
id
=
"java-object"
class
=
"flex.messaging.services.remoting.adapters.JavaAdapterEX"
default
=
"true"
/>
</
adapters
>
相关文章推荐
- Java调用语言技术平台(LTP) 3.4.0进行汉语文本处理经验总结
- HTTP请求中的Body构建——.NET客户端调用JAVA服务进行文件上传
- JAVA调用SYBASE过程报过程模式不对的处理
- repeater绑定的时候的小技巧(调用后台方法对当前绑定项进行进一步处理)
- 使用Java对文件进行压缩处理
- Java调用MatLab进行FFT运算及滤波
- Java 调用FFMPEG命令进行视频格式转换 (windows环境)
- Analysis Service不能对数据集进行属性、备份、还原、处理等操作
- android5.0之后必须显示调用,否则报java.lang.IllegalArgumentException: Service Intent must be explicit
- JNI学习笔记:(1)开篇(2)本地代码访问Java代码 (3)本地方法取得Java属性/调用java方法 (4)本地代码创建Java对象(包括javaString) (5) 本地方法处理java数组
- JAVA语言如何进行异常处理,关键字:throws,throw,try,catch,finally分别代表什么意义?在try块中可以抛出异常吗
- Java读取文件夹下的文件并进行处理
- python调用java webservice
- 删除信息[置顶] Java中怎样实现批量删除操作(Java对数据库进行事务处理)?
- JNA的一个小问题-调用dll处理字符串,在java中不能反映出字符串变化
- Java try-catch-finally进行异常处理以及throw主动抛出异常
- activiti designer源码的研究(三) 之servicetask调用除Java之后的其他语言发布的webservice
- CXF之使用工厂方法(java代码)发布服务与进行客户端调用
- 批处理命令调用WINRAR对文件进行压缩
- JAVA使用EPoll来进行NIO处理的方法(转)