Package org.jboss.ws.core

Examples of org.jboss.ws.core.CommonMessageContext


   private BindingCustomization getCustomization()
   {
      BindingCustomization customization = null;

      CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
      if(msgContext!=null) // may not be available anytime
      {
         Iterator<BindingCustomization> it = msgContext.getEndpointMetaData().getBindingCustomizations().iterator();
         while(it.hasNext())
         {
            BindingCustomization current = it.next();
            if(current instanceof JAXBBindingCustomization)
            {
View Full Code Here


   protected abstract Marshaller getMarshaller();

   private Map<String, Object> createRemotingMetaData(MessageAbstraction reqMessage, Map callProps)
   {
      CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();

      Map<String, Object> metadata = new HashMap<String, Object>();

      // We need to unmarshall faults (HTTP 500)
      // metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); // since 2.0.0.GA
      metadata.put("NoThrowOnError", "true");

      if (reqMessage != null)
      {
         populateHeaders(reqMessage, metadata);

         // Enable chunked encoding. This is the default size.
         clientConfig.put("chunkedLength", "1024");
        
         // May be overridden through endpoint config
         if (msgContext != null)
         {
            CommonConfig config = msgContext.getEndpointMetaData().getConfig();

            // chunksize settings
            String chunkSizeValue = config.getProperty(EndpointProperty.CHUNKED_ENCODING_SIZE);
            int chunkSize = chunkSizeValue != null ? Integer.valueOf(chunkSizeValue) : -1;
            if (chunkSize > 0)
View Full Code Here

         // See SOAPFactoryImpl for details.

         log.debug("MTOM disabled: Force inline XOP data");

         // TODO: This property must be reset, otherwise you negate its purpose
         CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
         msgContext.put(CommonMessageContext.ALLOW_EXPAND_TO_DOM, Boolean.TRUE);
         if (msgContext instanceof MessageContextJAXWS)
            ((MessageContextJAXWS)msgContext).setScope(CommonMessageContext.ALLOW_EXPAND_TO_DOM, Scope.APPLICATION);

         expandToDOM();
      }
View Full Code Here

   protected abstract Marshaller getMarshaller();

   private Map<String, Object> createRemotingMetaData(MessageAbstraction reqMessage, Map callProps)
   {
      CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();

      Map<String, Object> metadata = new HashMap<String, Object>();

      // We need to unmarshall faults (HTTP 500)
      // metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); // since 2.0.0.GA
      metadata.put("NoThrowOnError", "true");

      if (reqMessage != null)
      {
         populateHeaders(reqMessage, metadata);

         // Enable chunked encoding. This is the default size.
         clientConfig.put("chunkedLength", "1024");

         // May be overridden through endpoint config
         if (msgContext != null)
         {
            CommonConfig config = msgContext.getEndpointMetaData().getConfig();

            // chunksize settings
            String chunkSizeValue = config.getProperty(EndpointProperty.CHUNKED_ENCODING_SIZE);
            int chunkSize = chunkSizeValue != null ? Integer.valueOf(chunkSizeValue) : -1;
            if (chunkSize > 0)
View Full Code Here

      // Get the order of pre/post handlerchains
      HandlerType[] handlerType = new HandlerType[] { HandlerType.PRE, HandlerType.ENDPOINT, HandlerType.POST };
      HandlerType[] faultType = new HandlerType[] { HandlerType.PRE, HandlerType.ENDPOINT, HandlerType.POST };

      // Associate a message context with the current thread
      CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
      MessageContextAssociation.pushMessageContext(msgContext);
      msgContext.setEndpointMetaData(epMetaData);
      msgContext.setSOAPMessage(reqMsg);
      msgContext.putAll(reqContext);

      // The contents of the request context are used to initialize the message context (see section 9.4.1)
      // prior to invoking any handlers (see chapter 9) for the outbound message. Each property within the
      // request context is copied to the message context with a scope of HANDLER.
      msgContext.put(MessageContextJAXWS.MESSAGE_OUTBOUND_PROPERTY, Boolean.TRUE);
     
      QName portName = epMetaData.getPortName();
      try
      {
         // Call the request handlers
         boolean handlerPass = callRequestHandlerChain(portName, handlerType[0]);
         handlerPass = handlerPass && callRequestHandlerChain(portName, handlerType[1]);
         handlerPass = handlerPass && callRequestHandlerChain(portName, handlerType[2]);

         // Handlers might have replaced the message
         reqMsg = (SOAPMessageImpl)msgContext.getSOAPMessage();

         MessageAbstraction resMsg = null;
         if (handlerPass)
         {
            Map<String, Object> callProps = new HashMap<String, Object>(getRequestContext());
            if (callProps.containsKey(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)) {
               targetAddress = (String) callProps.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
            }
            EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress, callProps);
            resMsg = getRemotingConnection().invoke(reqMsg, epInfo, false);

            //Pivot, switch to response ctx and save the response message there
            msgContext = MessageContextJAXWS.processPivot(msgContext);
            msgContext.setMessageAbstraction(resMsg);
           
            // Call the  response handler chain, removing the fault type entry will not call handleFault for that chain
            handlerPass = callResponseHandlerChain(portName, handlerType[2]);
            faultType[2] = null;
            handlerPass = handlerPass && callResponseHandlerChain(portName, handlerType[1]);
View Full Code Here

      return response;
   }

   public void invokeOneWay(T msg)
   {
      CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
      MessageContextAssociation.pushMessageContext(msgContext);
      msgContext.setEndpointMetaData(epMetaData);
      try
      {
         MessageAbstraction reqMsg = getRequestMessage(msg);
         String targetAddress = epMetaData.getEndpointAddress();
         getRemotingConnection().invoke(reqMsg, targetAddress, true);
View Full Code Here

   @Override
   protected void setOutboundContextProperties()
   {
      // Mark the message context as outbound
      CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
      msgContext.put(MessageContextJAXWS.MESSAGE_OUTBOUND_PROPERTY, Boolean.TRUE);

      // Map of attachments to a message for the outbound message, key is the MIME Content-ID, value is a DataHandler
      msgContext.put(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS, new HashMap<String, DataHandler>());
   }
View Full Code Here

   // Invoked by the proxy invokation handler
   public Object invoke(QName opName, Object[] args, Map<String, Object> resContext) throws RemoteException
   {
      // Associate a message context with the current thread
      CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
      MessageContextAssociation.pushMessageContext(msgContext);

      // The contents of the request context are used to initialize the message context (see section 9.4.1)
      // prior to invoking any handlers (see chapter 9) for the outbound message. Each property within the
      // request context is copied to the message context with a scope of HANDLER.
      Map<String, Object> reqContext = getBindingProvider().getRequestContext();
      msgContext.putAll(reqContext);

      try
      {
         Object retObj = invoke(opName, args, false);
         return retObj;
      }
      catch (Exception ex)
      {
         OperationMetaData opMetaData = getOperationMetaData();
         if (opMetaData.isOneWay())
         {
            handleOneWayException(opMetaData, ex);
         }
         else
         {
            handleRemoteException(opMetaData, ex);
         }
         return null;
      }
      finally
      {
         // Copy the inbound msg properties to the binding's response context
         msgContext = MessageContextAssociation.peekMessageContext();
         for (String key : msgContext.keySet())
         {
            Object value = msgContext.get(key);
            resContext.put(key, value);
         }

         // Reset the message context association
         MessageContextAssociation.popMessageContext();
View Full Code Here

          */

         saveRequired = false;
      }

      CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
      if(msgContext!=null) msgContext.setModified(true);
   }
View Full Code Here

         throw new IllegalStateException("Cannot obtain endpoint meta data");

      Type type = sepMetaData.getType();
     
      // Build the message context
      CommonMessageContext msgContext;
      if (type == EndpointMetaData.Type.JAXRPC)
      {
         msgContext = new SOAPMessageContextJAXRPC();
         invContext.addAttachment(javax.xml.rpc.handler.MessageContext.class, msgContext);
      }
      else
      {
         msgContext = new SOAPMessageContextJAXWS();
         msgContext.put(MessageContextJAXWS.MESSAGE_OUTBOUND_PROPERTY, new Boolean(false));
         msgContext.put(MessageContextJAXWS.INBOUND_MESSAGE_ATTACHMENTS, new HashMap<String, DataHandler>());
         invContext.addAttachment(javax.xml.ws.handler.MessageContext.class, msgContext);
      }

      // Set servlet specific properties
      HttpServletResponse httpResponse = null;
      ServletHeaderSource headerSource = null;
      if (invContext instanceof ServletRequestContext)
      {
         ServletRequestContext reqContext = (ServletRequestContext)invContext;
        
         ServletContext servletContext = reqContext.getServletContext();
         HttpServletRequest httpRequest = reqContext.getHttpServletRequest();
         httpResponse = reqContext.getHttpServletResponse();
         headerSource = new ServletHeaderSource(httpRequest, httpResponse);
        
         if (type == EndpointMetaData.Type.JAXRPC)
         {
            msgContext.put(MessageContextJAXRPC.SERVLET_CONTEXT, servletContext);
            msgContext.put(MessageContextJAXRPC.SERVLET_REQUEST, httpRequest);
            msgContext.put(MessageContextJAXRPC.SERVLET_RESPONSE, httpResponse);
         }
         else
         {
            msgContext.put(MessageContextJAXWS.HTTP_REQUEST_HEADERS, headerSource.getHeaderMap());
            msgContext.put(MessageContextJAXWS.HTTP_REQUEST_METHOD, httpRequest.getMethod());
            msgContext.put(MessageContextJAXWS.QUERY_STRING, httpRequest.getQueryString());
            msgContext.put(MessageContextJAXWS.PATH_INFO, httpRequest.getPathInfo());
            msgContext.put(MessageContextJAXWS.SERVLET_CONTEXT, servletContext);
            msgContext.put(MessageContextJAXWS.SERVLET_REQUEST, httpRequest);
            msgContext.put(MessageContextJAXWS.SERVLET_RESPONSE, httpResponse);
         }
      }

      // Associate a message context with the current thread
      MessageContextAssociation.pushMessageContext(msgContext);
      msgContext.setEndpointMetaData(sepMetaData);

      try
      {
         MessageAbstraction resMessage = processRequest(endpoint, headerSource, invContext, inStream);

         // Replace the message context with the response context
         msgContext = MessageContextAssociation.peekMessageContext();

         Map<String, List<String>> headers = (Map<String, List<String>>)msgContext.get(MessageContextJAXWS.HTTP_RESPONSE_HEADERS);
         if (headerSource != null && headers != null)
            headerSource.setHeaderMap(headers);

         Integer code = (Integer)msgContext.get(MessageContextJAXWS.HTTP_RESPONSE_CODE);
         if (httpResponse != null && code != null)
            httpResponse.setStatus(code.intValue());

         boolean isFault = false;
         if (resMessage instanceof SOAPMessage)
View Full Code Here

TOP

Related Classes of org.jboss.ws.core.CommonMessageContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.