本文整理汇总了Java中org.apache.synapse.MessageContext.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.getProperty方法的具体用法?Java MessageContext.getProperty怎么用?Java MessageContext.getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.synapse.MessageContext
的用法示例。
在下文中一共展示了MessageContext.getProperty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import org.apache.synapse.MessageContext; //导入方法依赖的package包/类
/**
* Throw Synapse Exception for any exception in class mediator
* so that the fault handler will be invoked
*
* @param ERROR_CODE
* @param ERROR_MESSAGE
* @param ERROR_DETAIL
* @param context
*/
public static void handle(String ERROR_CODE, String ERROR_MESSAGE, String ERROR_DETAIL, MessageContext context) {
int array[] = {20, 20, 40};
int total = 0;
try {
for (int i = 5; i >= 0; i--) {
total += array[i];
}
} catch (Exception e) {
context.setProperty(ERROR_CODE, "AB005");
context.setProperty(ERROR_MESSAGE, "Error Message from class CsvValidatorMediator");
context.setProperty(ERROR_DETAIL, "Error Details from class");
String messageContextErrorCode = (String) context.getProperty(ERROR_CODE);
String messageContextErrorMessage = (String) context.getProperty(ERROR_MESSAGE);
String messageContextErrorDetail = (String) context.getProperty(ERROR_DETAIL);
String separator = "?";
String concatenatedMessage = (messageContextErrorCode + separator + messageContextErrorMessage + separator + messageContextErrorDetail);
throw new SynapseException(concatenatedMessage);
}
}
示例2: mediate
import org.apache.synapse.MessageContext; //导入方法依赖的package包/类
public boolean mediate(MessageContext messageContext) {
try {
if (log.isDebugEnabled()) {
log.debug("Response interceptor mediation started");
}
String clusterId = (String) messageContext.getProperty(LoadBalancerConstants.CLUSTER_ID);
if (StringUtils.isNotBlank(clusterId)) {
FutureTask<Object> task = new FutureTask<Object>(new InFlightRequestDecrementCallable(clusterId));
LoadBalancerStatisticsExecutor.getInstance().getService().submit(task);
} else {
if (log.isDebugEnabled()) {
log.debug("Could not decrement in-flight request count : cluster id not found in message context");
}
}
} catch (Exception e) {
if (log.isErrorEnabled()) {
log.error("Could not decrement in-flight request count", e);
}
}
return true;
}
示例3: prepareEndPointSequence
import org.apache.synapse.MessageContext; //导入方法依赖的package包/类
private void prepareEndPointSequence(MessageContext synCtx, Endpoint endpoint) {
Object o = synCtx.getProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST);
List<Endpoint> endpointList;
if (o instanceof List) {
endpointList = (List<Endpoint>) o;
endpointList.add(this);
} else {
// this is the first endpoint in the hierarchy. so create the queue and
// insert this as the first element.
endpointList = new ArrayList<Endpoint>();
endpointList.add(this);
synCtx.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpointList);
}
// if the next endpoint is not a session affinity one, endpoint sequence ends
// here. but we have to add the next endpoint to the list.
if (!(endpoint instanceof TenantAwareLoadBalanceEndpoint)) {
endpointList.add(endpoint);
// Clearing out if there any any session information with current message
if (dispatcher.isServerInitiatedSession()) {
dispatcher.removeSessionID(synCtx);
}
}
}
示例4: getOMElement
import org.apache.synapse.MessageContext; //导入方法依赖的package包/类
private OMElement getOMElement(MessageContext messageContext, String location) {
OMElement omElement = null;
if (location.equals(Constants.RULE_SOURCE_SOAP_BODY)) {
omElement = messageContext.getEnvelope().getBody().getFirstElement();
} else if (location.equals(Constants.RULE_SOURCE_SOAP_HEADER)) {
omElement = messageContext.getEnvelope().getHeader();
} else if (location.startsWith(Constants.RULE_PROPERTY_PREFIX)) {
// property name should have started with $ so remove it
String propertyName = location.substring(1);
if (messageContext.getProperty(propertyName) instanceof OMElement) {
omElement = (OMElement) messageContext.getProperty(propertyName);
} else if (messageContext.getProperty(propertyName) instanceof ArrayList) {
ArrayList arrayList = (ArrayList) messageContext.getProperty(propertyName);
//here we take the first OMElement
omElement = (OMElement) arrayList.get(0);
}
} else {
handleException("invalde source value " + location, messageContext);
}
return omElement;
}
示例5: incrementInFlightRequestCount
import org.apache.synapse.MessageContext; //导入方法依赖的package包/类
private void incrementInFlightRequestCount(MessageContext messageContext) {
try {
String clusterId = (String) messageContext.getProperty(LoadBalancerConstants.CLUSTER_ID);
if (StringUtils.isBlank(clusterId)) {
throw new RuntimeException("Cluster id not found in message context");
}
FutureTask<Object> task = new FutureTask<Object>(new InFlightRequestIncrementCallable(clusterId));
LoadBalancerStatisticsExecutor.getInstance().getService().submit(task);
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Could not increment in-flight request count", e);
}
}
}
示例6: decrementInFlightRequestCount
import org.apache.synapse.MessageContext; //导入方法依赖的package包/类
private void decrementInFlightRequestCount(MessageContext messageContext) {
try {
String clusterId = (String) messageContext.getProperty(LoadBalancerConstants.CLUSTER_ID);
if (StringUtils.isBlank(clusterId)) {
throw new RuntimeException("Cluster id not found in message context");
}
FutureTask<Object> task = new FutureTask<Object>(new InFlightRequestDecrementCallable(clusterId));
LoadBalancerStatisticsExecutor.getInstance().getService().submit(task);
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Could not decrement in-flight request count", e);
}
}
}
示例7: send
import org.apache.synapse.MessageContext; //导入方法依赖的package包/类
@Override
public void send(MessageContext synCtx) {
SessionInformation sessionInformation = null;
org.apache.axis2.clustering.Member currentMember = null;
if (isSessionAffinityBasedLB()) {
// Check existing session information
sessionInformation = (SessionInformation) synCtx.getProperty(
SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION);
currentMember = (org.apache.axis2.clustering.Member) synCtx.getProperty(
SynapseConstants.PROP_SAL_ENDPOINT_CURRENT_MEMBER);
if (sessionInformation == null && currentMember == null) {
sessionInformation = dispatcher.getSession(synCtx);
if (sessionInformation != null) {
if (log.isDebugEnabled()) {
log.debug(String.format("Existing session found: %s for request: %s", sessionInformation.getId(),
synCtx.getMessageID()));
}
currentMember = sessionInformation.getMember();
synCtx.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_CURRENT_MEMBER, currentMember);
// This is for reliably recovery any session information if while response is getting ,
// session information has been removed by cleaner.
// This will not be a cost as session information is not a heavy data structure
synCtx.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, sessionInformation);
}
}
}
TenantAwareLoadBalanceFaultHandler faultHandler = new TenantAwareLoadBalanceFaultHandler();
if (sessionInformation != null && currentMember != null) {
// Update axis2 member ports
updateAxis2MemberPorts(synCtx, currentMember);
// Send request to the member with the existing session
sessionInformation.updateExpiryTime();
sendToApplicationMember(synCtx, currentMember, faultHandler, false);
} else {
// No existing session found
// Find next member
org.apache.axis2.clustering.Member axis2Member = findNextMember(synCtx);
if (axis2Member != null) {
// Send request to member
sendToApplicationMember(synCtx, axis2Member, faultHandler, true);
} else {
throwSynapseException(synCtx, 404, "Active application instances not found");
}
}
}