您的位置:首页 > 编程语言 > Java开发

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
>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐