private String getParameterValue(String key, MessageContext msgCtx) { Parameter param = msgCtx.getParameter(key); if (param != null) { return (String) param.getValue(); } return null; } }
/** * By the time the exception comes here it can be wrapped by so many levels. This will crip down * to the root cause and get the initial error depending on the property * * @param e exception to get the string representation * @param context current message context for which the exception occurred * @return generated fault reason as a string */ private static String getFaultReasonFromException(Throwable e, MessageContext context) { Throwable throwable = e; Parameter param = context.getParameter( Constants.Configuration.DRILL_DOWN_TO_ROOT_CAUSE_FOR_FAULT_REASON); boolean drillDownToRootCauseForFaultReason = param != null && ((String) param.getValue()).equalsIgnoreCase("true"); if (drillDownToRootCauseForFaultReason) { while (throwable.getCause() != null) { throwable = throwable.getCause(); } } return throwable.getMessage(); }
/** * By the time the exception comes here it can be wrapped by so many levels. This will crip down * to the root cause and get the initial error depending on the property * * @param e exception to get the string representation * @param context current message context for which the exception occurred * @return generated fault reason as a string */ private static String getFaultReasonFromException(Throwable e, MessageContext context) { Throwable throwable = e; Parameter param = context.getParameter( Constants.Configuration.DRILL_DOWN_TO_ROOT_CAUSE_FOR_FAULT_REASON); boolean drillDownToRootCauseForFaultReason = param != null && ((String) param.getValue()).equalsIgnoreCase("true"); if (drillDownToRootCauseForFaultReason) { while (throwable.getCause() != null) { throwable = throwable.getCause(); } } return throwable.getMessage(); }
private void updateStatistics(MessageContext outMsgContext) throws AxisFault { // Process System Request count Parameter globalRequestCounter = outMsgContext.getParameter(StatisticsConstants.GLOBAL_REQUEST_COUNTER); ((AtomicInteger) globalRequestCounter.getValue()).incrementAndGet(); // Process System Response count Parameter globalResponseCounter = outMsgContext.getParameter(StatisticsConstants.GLOBAL_RESPONSE_COUNTER); ((AtomicInteger) globalResponseCounter.getValue()).incrementAndGet(); updateCurrentInvocationGlobalStatistics(outMsgContext); // Calculate response times ResponseTimeCalculator.calculateResponseTimes(outMsgContext); }
private void updateStatistics(MessageContext msgContext) throws AxisFault { // Process System Request count Parameter globalRequestCounter = msgContext.getParameter(StatisticsConstants.GLOBAL_REQUEST_COUNTER); ((AtomicInteger) globalRequestCounter.getValue()).incrementAndGet(); // Increment the global fault count Parameter globalFaultCounter = msgContext.getParameter(StatisticsConstants.GLOBAL_FAULT_COUNTER); ((AtomicInteger) globalFaultCounter.getValue()).incrementAndGet(); updateCurrentInvocationGlobalStatistics(msgContext); // Calculate response times ResponseTimeCalculator.calculateResponseTimes(msgContext); }
public static boolean isAttachmentsCacheEnabled(MessageContext msgContext) { Object cacheAttachmentProperty = msgContext .getProperty(Constants.Configuration.CACHE_ATTACHMENTS); String cacheAttachmentString; boolean fileCacheForAttachments; if (cacheAttachmentProperty != null && cacheAttachmentProperty instanceof String) { cacheAttachmentString = (String)cacheAttachmentProperty; } else { Parameter parameter_cache_attachment = msgContext.getParameter(Constants.Configuration.CACHE_ATTACHMENTS); cacheAttachmentString = (parameter_cache_attachment != null) ? (String)parameter_cache_attachment.getValue() : null; } fileCacheForAttachments = (Constants.VALUE_TRUE.equals(cacheAttachmentString)); return fileCacheForAttachments; }
private String getAddressingNamesapce(MessageContext messageContext){ String namespace = (String) messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION); if (namespace == null){ namespace = Utils.getParameterValue(messageContext.getParameter(AddressingConstants.WS_ADDRESSING_VERSION)); } if (namespace == null){ namespace = AddressingConstants.Final.WSA_NAMESPACE; } return namespace; }
public static boolean isAttachmentsCacheEnabled(MessageContext msgContext) { Object cacheAttachmentProperty = msgContext .getProperty(Constants.Configuration.CACHE_ATTACHMENTS); String cacheAttachmentString; boolean fileCacheForAttachments; if (cacheAttachmentProperty != null && cacheAttachmentProperty instanceof String) { cacheAttachmentString = (String)cacheAttachmentProperty; } else { Parameter parameter_cache_attachment = msgContext.getParameter(Constants.Configuration.CACHE_ATTACHMENTS); cacheAttachmentString = (parameter_cache_attachment != null) ? (String)parameter_cache_attachment.getValue() : null; } fileCacheForAttachments = (Constants.VALUE_TRUE.equals(cacheAttachmentString)); return fileCacheForAttachments; }
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault { msgContext .setProperty(MetricsConstants.REQUEST_RECEIVED_TIME, System.currentTimeMillis()); // global increment ((Counter) msgContext.getParameter(MetricsConstants.GLOBAL_REQUEST_COUNTER).getValue()) .increment(); return InvocationResponse.CONTINUE; } }
public static int getMtomThreshold(MessageContext msgCtxt){ Integer value = null; if(!msgCtxt.isServerSide()){ value = (Integer)msgCtxt.getProperty(Constants.Configuration.MTOM_THRESHOLD); }else{ Parameter param = msgCtxt.getParameter(Constants.Configuration.MTOM_THRESHOLD); if(param!=null){ value = (Integer)param.getValue(); } } int threshold = (value!=null)?value.intValue():0; if(log.isDebugEnabled()){ log.debug("MTOM optimized Threshold value ="+threshold); } return threshold; } /**
private String getUserAgent(MessageContext messageContext) { String userAgentString = "Axis2"; boolean locked = false; if (messageContext.getParameter(HTTPConstants.USER_AGENT) != null) { OMElement userAgentElement = messageContext.getParameter(HTTPConstants.USER_AGENT) .getParameterElement(); userAgentString = userAgentElement.getText().trim(); OMAttribute lockedAttribute = userAgentElement.getAttribute(new QName("locked")); if (lockedAttribute != null) { if (lockedAttribute.getAttributeValue().equalsIgnoreCase("true")) { locked = true; } } } // Runtime overing part if (!locked) { if (messageContext.getProperty(HTTPConstants.USER_AGENT) != null) { userAgentString = (String) messageContext.getProperty(HTTPConstants.USER_AGENT); } } return userAgentString; }
public static int getMtomThreshold(MessageContext msgCtxt){ Integer value = null; if(!msgCtxt.isServerSide()){ value = (Integer)msgCtxt.getProperty(Constants.Configuration.MTOM_THRESHOLD); }else{ Parameter param = msgCtxt.getParameter(Constants.Configuration.MTOM_THRESHOLD); if(param!=null){ value = (Integer)param.getValue(); } } int threshold = (value!=null)?value.intValue():0; if(log.isDebugEnabled()){ log.debug("MTOM optimized Threshold value ="+threshold); } return threshold; } /**
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault { msgContext .setProperty(MetricsConstants.REQUEST_RECEIVED_TIME, System.currentTimeMillis()); // global increment ((Counter) msgContext.getParameter(MetricsConstants.GLOBAL_REQUEST_COUNTER).getValue()) .increment(); return InvocationResponse.CONTINUE; } }
private static String getMessageFormatterProperty(MessageContext msgContext) { String messageFormatterProperty = null; Object property = msgContext .getProperty(Constants.Configuration.MESSAGE_TYPE); if (property != null) { messageFormatterProperty = (String) property; } if (messageFormatterProperty == null) { Parameter parameter = msgContext .getParameter(Constants.Configuration.MESSAGE_TYPE); if (parameter != null) { messageFormatterProperty = (String) parameter.getValue(); } } return messageFormatterProperty; }
private String getUserAgent(MessageContext messageContext) { String userAgentString = "Axis2"; boolean locked = false; if (messageContext.getParameter(HTTPConstants.USER_AGENT) != null) { OMElement userAgentElement = messageContext.getParameter(HTTPConstants.USER_AGENT) .getParameterElement(); userAgentString = userAgentElement.getText().trim(); OMAttribute lockedAttribute = userAgentElement.getAttribute(new QName("locked")); if (lockedAttribute != null) { if (lockedAttribute.getAttributeValue().equalsIgnoreCase("true")) { locked = true; } } } // Runtime overing part if (!locked) { if (messageContext.getProperty(HTTPConstants.USER_AGENT) != null) { userAgentString = (String) messageContext.getProperty(HTTPConstants.USER_AGENT); } } return userAgentString; }
private static String getMessageFormatterProperty(MessageContext msgContext) { String messageFormatterProperty = null; Object property = msgContext .getProperty(Constants.Configuration.MESSAGE_TYPE); if (property != null) { messageFormatterProperty = (String) property; } if (messageFormatterProperty == null) { Parameter parameter = msgContext .getParameter(Constants.Configuration.MESSAGE_TYPE); if (parameter != null) { messageFormatterProperty = (String) parameter.getValue(); } } return messageFormatterProperty; }
private String getUserAgent(MessageContext messageContext) { String userAgentString = "Axis2"; boolean locked = false; if (messageContext.getParameter(HTTPConstants.USER_AGENT) != null) { OMElement userAgentElement = messageContext.getParameter(HTTPConstants.USER_AGENT) .getParameterElement(); userAgentString = userAgentElement.getText().trim(); OMAttribute lockedAttribute = userAgentElement.getAttribute(new QName("locked")); if (lockedAttribute != null) { if (lockedAttribute.getAttributeValue().equalsIgnoreCase("true")) { locked = true; } } } // Runtime overing part if (!locked) { if (messageContext.getProperty(HTTPConstants.USER_AGENT) != null) { userAgentString = (String) messageContext.getProperty(HTTPConstants.USER_AGENT); } } return userAgentString; }
public boolean shouldInvoke(MessageContext msgContext) throws AxisFault { //Set the defaults on the message context. msgContext.setProperty(DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE); msgContext.setProperty(IS_ADDR_INFO_ALREADY_PROCESSED, Boolean.FALSE); //Determine if we want to ignore addressing headers. This parameter must //be retrieved from the message context because it's value can vary on a //per service basis. Parameter disableParam = msgContext.getParameter(DISABLE_ADDRESSING_FOR_IN_MESSAGES); String value = Utils.getParameterValue(disableParam); if (JavaUtils.isTrueExplicitly(value)) { if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { log.debug( "The AddressingInHandler has been disabled. No further processing will take place."); } return false; } // if there are not headers put a flag to disable addressing temporary SOAPHeader header = msgContext.getEnvelope().getHeader(); return header != null; }
/** * Invoking invoke method and assert for the incremented counter value * @throws Exception */ public void testInvoke() throws Exception { GlobalRequestCountHandler globalRequestCountHandler = new GlobalRequestCountHandler(); MessageContext messageContext; Counter counter = new Counter(); Parameter parameter = new Parameter(); parameter.setValue(counter); messageContext = Mockito.mock(MessageContext.class, Mockito.CALLS_REAL_METHODS); Mockito.doReturn(parameter).when(messageContext).getParameter(Mockito.anyString()); Handler.InvocationResponse response = globalRequestCountHandler.invoke(messageContext); Assert.assertEquals("Asserting the response of the method",response, Handler.InvocationResponse.CONTINUE); Assert.assertEquals("Counter should be incremented to 1", counter.getCount(), 1); } }
WSHandlerConstants.PW_CALLBACK_REF); if(cbHandler == null) { Parameter param = msgContext.getParameter( WSHandlerConstants.PW_CALLBACK_REF); if(param != null) {