最近剛開發了一個需求
Java代碼
public abstract class AbstractIceAgent {
protected Logger logger = LoggerFactory
private static final int DEFAULT_TIME_OUT =
String identId;
public AbstractIceAgent(){
}
public AbstractIceAgent(String identId){
this
}
public String getIdentId() {
return identId;
}
public void setIdentId(String identId) {
this
}
public Object executeProxy(Object bean) {
Communicator communicator = Ice
Object returnValue = null;
try {
ObjectPrx objPrx = communicator
objPrx
returnValue = methodAction(objPrx
} catch (Exception e) {
logger
throw new RuntimeException(e);
} finally {
if (communicator != null) {
try {
communicator
communicator = null;
} catch (Exception e) {
// do nothing
}
}
}
return returnValue;
}
/**
* ice接口方法的定義
*
* @param base
*/
abstract Object methodAction(ObjectPrx base
}
這是一個虛基類
Java代碼
package com
public interface AIMFriendBO {
int[] isFriend(String memberId
}
這是本次需要實現的接口
Java代碼
public class AIMFriendAgent extends AbstractIceAgent implements AIMFriendBO {
// private static final String ICE_INTERFACE =
// private static BrmmsRemindAgent brmmsIceAgent = new BrmmsRemindAgent(ICE_INTERFACE);
protected Logger logger = LoggerFactory
private String strCaller;
private String strServiceType;
public void setStrCaller(String strCaller) {
this
}
public void setStrServiceType(String strServiceType) {
this
}
public AIMFriendAgent(){
};
public AIMFriendAgent(String identId){
super(identId);
}
@Override
Object methodAction(ObjectPrx base
WWContactInterfacePrx ctWebInterfacePrx = WWContactInterfacePrxHelper
AliIMContact contact = (AliIMContact) bean;
IntSeqHolder isFriendSeq=new IntSeqHolder();
StringHolder retMsgHolder=new StringHolder();
int result = ctWebInterfacePrx
//
if(result==
return isFriendSeq
}else{
logger
return null;
}
}
public int[] isFriend(String memberId
if (memberId == null||friendIds==null) {
throw new RuntimeException(
}
int[] returnValue=(int[]) this
return returnValue;
}
}
這是最後的實現
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26695.html