添加动态航班整体处理框架
This commit is contained in:
@@ -1,27 +1,62 @@
|
||||
package com.gzzn.omms.msgexchangeapi.msghandler;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.Msg;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.FLTR;
|
||||
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
|
||||
import com.gzzn.omms.msgexchangeapi.service.flightInfo.UpdateByCminmsgsResult;
|
||||
|
||||
@Service
|
||||
public class MsgHandlerDispatcher {
|
||||
@Autowired
|
||||
IExchangeService exchangeService;
|
||||
|
||||
public List<FLTR> dispatch(String xmlMsg)
|
||||
public UpdateByCminmsgsResult dispatch(String xmlMsg)
|
||||
{
|
||||
|
||||
Msg msg = exchangeService.xmlstrToObject(xmlMsg, Msg.class);
|
||||
String type = msg.getMeta().getType();
|
||||
String subType = msg.getMeta().getStyp();
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try
|
||||
{
|
||||
Class clazzHandler = Class.forName(getHandlerClassName(type,subType));
|
||||
Object classObject = clazzHandler.newInstance();
|
||||
Method runMethod = clazzHandler.getMethod("run", String.class);
|
||||
UpdateByCminmsgsResult result = (UpdateByCminmsgsResult) runMethod.invoke(classObject, xmlMsg);
|
||||
return result;
|
||||
} catch (ClassNotFoundException
|
||||
| InstantiationException
|
||||
| IllegalAccessException
|
||||
| NoSuchMethodException
|
||||
| SecurityException
|
||||
| IllegalArgumentException
|
||||
| InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}//end function
|
||||
|
||||
/**
|
||||
* 获取handler 类的名称
|
||||
* @param type
|
||||
* @param subType
|
||||
* @return
|
||||
*/
|
||||
private String getHandlerClassName(String type , String subType)
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("com.gzzn.omms.msgexchangeapi.msghandler" );
|
||||
buffer.append(".");
|
||||
buffer.append(type);
|
||||
buffer.append(".");
|
||||
buffer.append(subType);
|
||||
buffer.append("Handler");
|
||||
|
||||
|
||||
return buffer.toString();
|
||||
} //end function
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user