1
Synapseハンドラでカスタムロガーを実装しようとしていますが、APIとサービスを区別できますが、どのようにしてシナプスハンドラコードからAPI名を取得できますか?すべてのAPIのサービス名は__SynapseService
です。SynapseハンドラからAPI名を取得する
public static boolean isProxyService(MessageContext messageContext,
AxisService axisService) {
if (axisService != null) {
Parameter val = axisService.getParameter("serviceType");
if (val != null && val.getValue().toString().equalsIgnoreCase("Proxy")) {
if (logger.isDebugEnabled()) {
logger.debug("Parameter Value Service Type: "
+ val.getValue().toString());
}
return true;
}
}
return false;
}
public static boolean isAPI(MessageContext messageContext,
AxisService axisService) {
if(!isProxyService(messageContext, axisService) && axisService.getAxisServiceGroup().getServiceGroupName().equals(SynapseConstants.SYNAPSE_SERVICE_NAME)){
return true;
}
return false;
}
public static String getServiceName(MessageContext messageContext, AxisService axisService) {
org.apache.axis2.context.MessageContext msgContext = ((Axis2MessageContext) messageContext).getAxis2MessageContext();
return msgContext.getServiceContext().getName();
}
これは常にnullです。 – iozeren
それは変です。これは、WSO2製品がAPI名を読み取る方法です。例えば。 https://github.com/wso2/carbon-apimgt/blob/v6.0.4/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/ハンドラ/セキュリティ/ APIAuthenticationHandler.java#L294 – Bee
ESB 5.0のコードベースが同じかどうかはわかりません。私はこのコードがAPIマネージャーに関係していると思います。 – iozeren