本文整理了Java中org.apache.synapse.MessageContext.getProperty()
方法的一些代码示例,展示了MessageContext.getProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MessageContext.getProperty()
方法的具体详情如下:
包路径:org.apache.synapse.MessageContext
类名称:MessageContext
方法名:getProperty
[英]Get the value of a custom (local) property set on the message instance
[中]获取消息实例上的自定义(本地)属性集的值
代码示例来源:origin: wso2/wso2-synapse
/**
* {@inheritDoc}
*/
public Object getProperty(String key) {
return mc.getProperty(key);
}
代码示例来源:origin: wso2/wso2-synapse
protected boolean shouldCaptureTracing(MessageContext synCtx) {
Boolean isCollectingTraces = (Boolean) synCtx.getProperty(StatisticsConstants.FLOW_TRACE_IS_COLLECTED);
if (isCollectingTraces == null) {
return false;
}
else {
return isCollectingTraces;
}
}
代码示例来源:origin: wso2/wso2-synapse
/**
* {@inheritDoc}
*/
public Object getProperty(String key) {
return mc.getProperty(key);
}
代码示例来源:origin: org.apache.synapse/synapse-core
private void popFuncContextFrom(MessageContext synCtx) {
Stack<TemplateContext> stack = (Stack) synCtx.getProperty(SynapseConstants.SYNAPSE__FUNCTION__STACK);
if (stack != null) {
stack.pop();
}
}
代码示例来源:origin: wso2/wso2-synapse
/**
* Checks is this is a Out_Only message flow.
*
* @param messageContext synapse message context.
* @return true is message flow is Out_Only flow.
*/
public static boolean isOutOnlyFlow(MessageContext messageContext) {
return "true".equals(messageContext.getProperty(SynapseConstants.OUT_ONLY));
}
代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.gateway
/**
* Retrieve the AuthenticationContext information from the request. If the request hasn't
* been validated yet, this method will return null.
*
* @param synCtx Current message
* @return An AuthenticationContext instance or null
*/
public static AuthenticationContext getAuthenticationContext(MessageContext synCtx) {
AuthenticationContext authContext = (AuthenticationContext) synCtx.getProperty(API_AUTH_CONTEXT);
authContext.setUsername((String)synCtx.getProperty("Subject"));
return authContext;
}
代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.gateway
public static String extractResource(org.apache.synapse.MessageContext mc) {
Pattern resourcePattern = Pattern.compile("^/.+?/.+?([/?].+)$");
String resource = "/";
Matcher matcher = resourcePattern.matcher((String) mc.getProperty(RESTConstants.REST_FULL_REQUEST_PATH));
if (matcher.find()) {
resource = matcher.group(1);
}
return resource;
}
代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.gateway
private String getRequestPath(MessageContext synCtx, String apiContext, String apiVersion, String fullRequestPath) {
String requestPath;
String versionStrategy = (String) synCtx.getProperty(RESTConstants.SYNAPSE_REST_API_VERSION_STRATEGY);
if (VersionStrategyFactory.TYPE_URL.equals(versionStrategy)) {
// most used strategy. server:port/context/version/resource
requestPath = fullRequestPath.substring((apiContext + apiVersion).length() + 1, fullRequestPath.length());
} else {
// default version. assume there is no version is used
requestPath = fullRequestPath.substring(apiContext.length(), fullRequestPath.length());
}
return requestPath;
}
代码示例来源:origin: org.apache.synapse/synapse-core
protected void informFailure(MessageContext synCtx, int errorCode, String errorMsg) {
log.warn("Endpoint failure - Error Code: " + errorCode + ", Error Message: " + errorMsg);
if (synCtx.getProperty(SynapseConstants.LAST_ENDPOINT) == null ||
synCtx.getProperty(SynapseConstants.ERROR_CODE) == null) {
setErrorOnMessage(synCtx, String.valueOf(errorCode), errorMsg);
}
invokeNextFaultHandler(synCtx);
}
代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.gateway
private String getRedirectionReadyFullRequestPath(MessageContext messageContext) {
String fullResourceURL = (String) messageContext.getProperty(RESTConstants.REST_FULL_REQUEST_PATH);
// If the request has come though the default Synapse API (without versioning) remove the version part of the URL.
org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) messageContext).getAxis2MessageContext();
Map<String, Object> headers = (Map<String, Object>) axis2MessageContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
String hasRequestedThoughDefaultVersion = (String) headers.get(AppMConstants.GATEWAY_DEFAULT_VERSION_INDICATION_HEADER_NAME);
if(hasRequestedThoughDefaultVersion != null && Boolean.parseBoolean(hasRequestedThoughDefaultVersion)){
String webAppVersion = (String) messageContext.getProperty(RESTConstants.SYNAPSE_REST_API_VERSION);
return fullResourceURL.replaceFirst("/" + webAppVersion, "");
}
return fullResourceURL;
}
代码示例来源:origin: wso2-attic/esb-connectors
public void generateHash(MessageContext msgctx) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException {
StringBuilder baseString = new StringBuilder();
MessageDigest md = MessageDigest.getInstance("SHA-1");
String timeStamp = String.valueOf(System.currentTimeMillis() / 1000);
msgctx.setProperty("uri.var.ts", timeStamp);
String input = msgctx.getProperty(Encoder.SHA1KEY).toString() + timeStamp;
md.update(input.getBytes());
String hash = String.format("%032x", new BigInteger(1, md.digest()));
msgctx.setProperty("uri.var.hash", hash);
}
代码示例来源:origin: wso2-attic/esb-connectors
public boolean mediate(MessageContext msgctx) {
String unencoded = msgctx.getProperty("flickr.unencoded").toString();
try {
String encoded = URLEncoder.encode(unencoded, ENC);
encoded = encoded.replace("+","%20");
msgctx.setProperty("flickr.encoded", encoded);
} catch (UnsupportedEncodingException e) {
throw new SynapseException(e);
}
return true;
}
}
代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.gateway
private List<String> getApplicableEntitlementPolicyIds(MessageContext messageContext) throws AppManagementException {
Integer appId = (Integer) messageContext.getProperty(AppMConstants.MESSAGE_CONTEXT_PROPERTY_APP_ID);
URITemplate matchedURITemplate = (URITemplate) messageContext.getProperty(AppMConstants.MESSAGE_CONTEXT_PROPERTY_MATCHED_URI_TEMPLATE);
AppMDAO appMDAO = new AppMDAO();
return appMDAO.getApplicableEntitlementPolicyIds(appId, matchedURITemplate.getUriTemplate(), matchedURITemplate.getHTTPVerb());
}
代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.gateway
@Override
public boolean handleResponseInFlow(MessageContext messageContext) {
if (Util.tracingEnabled()) {
TracingSpan backendLatencySpan =
(TracingSpan) messageContext.getProperty(APIMgtGatewayConstants.BACKEND_LATENCY_SPAN);
Util.finishSpan(backendLatencySpan);
}
return true;
}
代码示例来源:origin: wso2/wso2-synapse
public void handle(MessageContext synCtx) {
result.append("T4");
assertEquals("test", synCtx.getProperty(SynapseConstants.ERROR_MESSAGE));
}
});
代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.gateway
public static String getHostName(org.apache.synapse.MessageContext messageContext) {
String hostname = DataPublisherUtil.getApiManagerAnalyticsConfiguration().getDatacenterId();
if (hostname == null) {
hostname = (String) messageContext.getProperty(APIMgtGatewayConstants.HOST_NAME);
}
return hostname;
}
}
代码示例来源:origin: wso2/wso2-synapse
private String getTenantDomain(SynapseEnvironment synapseEnvironment) {
TenantInfoConfigurator configurator = synapseEnvironment.getTenantInfoConfigurator();
if (configurator != null) {
org.apache.axis2.context.MessageContext axisMessageContext = new org.apache.axis2.context.MessageContext();
MessageContext messageContext = new Axis2MessageContext(axisMessageContext, this, synapseEnvironment);
configurator.extractTenantInfo(messageContext);
if (messageContext.getProperty("tenant.info.domain") != null) {
return (String) messageContext.getProperty("tenant.info.domain");
}
}
return null;
}
代码示例来源:origin: org.apache.synapse/synapse-core
private boolean isOutOnly(MessageContext messageIn,
org.apache.axis2.context.MessageContext axis2Ctx) {
return "true".equals(messageIn.getProperty(SynapseConstants.OUT_ONLY)) ||
axis2Ctx.getOperationContext() != null && WSDL2Constants.MEP_URI_IN_ONLY.equals(
axis2Ctx.getOperationContext().getAxisOperation().getMessageExchangePattern());
}
代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.gateway
private boolean isHandlerApplicable(MessageContext messageContext) {
if(GatewayUtils.shouldSkipSecurity(messageContext)){
return false;
}
URITemplate matchedURITemplate = (URITemplate) messageContext.getProperty(AppMConstants.MESSAGE_CONTEXT_PROPERTY_MATCHED_URI_TEMPLATE);
boolean isEntitlementPolicyAvailable = matchedURITemplate.getPolicyGroup().getFirstEntitlementPolicyId() > 0;
return isEntitlementPolicyAvailable;
}
代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.gateway
public static Session getSession(MessageContext messageContext, boolean createIfNotExists) {
String sessionID = (String) messageContext.getProperty(AppMConstants.APPM_SAML2_COOKIE);
Session session = SessionStore.getInstance().getSession(sessionID, createIfNotExists);
if(createIfNotExists){
messageContext.setProperty(AppMConstants.APPM_SAML2_COOKIE, session.getUuid());
}
return session;
}
内容来源于网络,如有侵权,请联系作者删除!