jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/Packet.java
changeset 23782 953bfc3fbe31
parent 19645 36f707905f2b
child 25429 1c4e76ec718a
equal deleted inserted replaced
23403:85dbdc227c5e 23782:953bfc3fbe31
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   246     public void setMessage(Message message) {
   246     public void setMessage(Message message) {
   247         this.message = message;
   247         this.message = message;
   248         if (message != null) this.message.setMessageMedadata(this);
   248         if (message != null) this.message.setMessageMedadata(this);
   249     }
   249     }
   250 
   250 
       
   251     // ALL NEW PACKETS SHOULD HAVE THIS AS false.
       
   252     // SETTING TO true MUST BE DONE EXPLICITLY,
       
   253     // NOT VIA COPYING/RELATING PACKETS.
       
   254     public  boolean isProtocolMessage() {
       
   255         return message != null && message.isProtocolMessage();
       
   256     }
       
   257     public void  setIsProtocolMessage() {
       
   258         assert message != null;
       
   259         message.setIsProtocolMessage();
       
   260     }
       
   261 
       
   262     private String    userStateId;
       
   263     public  String getUserStateId() {
       
   264         return userStateId;
       
   265     }
       
   266     public  void   setUserStateId(final String x) {
       
   267         assert x != null && x.length() <= 256;
       
   268         userStateId = x;
       
   269     }
       
   270 
   251     private WSDLOperationMapping wsdlOperationMapping = null;
   271     private WSDLOperationMapping wsdlOperationMapping = null;
   252 
   272 
   253     private QName wsdlOperation;
   273     private QName wsdlOperation;
   254 
   274 
   255     /**
   275     /**
   892         response.webServiceContextDelegate = request.webServiceContextDelegate;
   912         response.webServiceContextDelegate = request.webServiceContextDelegate;
   893         response.expectReply = request.expectReply;
   913         response.expectReply = request.expectReply;
   894         response.component = request.component;
   914         response.component = request.component;
   895         response.mtomAcceptable = request.mtomAcceptable;
   915         response.mtomAcceptable = request.mtomAcceptable;
   896         response.mtomRequest = request.mtomRequest;
   916         response.mtomRequest = request.mtomRequest;
       
   917         response.userStateId = request.userStateId;
   897         // copy other properties that need to be copied. is there any?
   918         // copy other properties that need to be copied. is there any?
   898     }
   919     }
   899 
   920 
   900 
   921 
   901     public Packet relateServerResponse(@Nullable Packet r, @Nullable WSDLPort wsdlPort, @Nullable SEIModel seiModel, @NotNull WSBinding binding) {
   922     public Packet relateServerResponse(@Nullable Packet r, @Nullable WSDLPort wsdlPort, @Nullable SEIModel seiModel, @NotNull WSBinding binding) {
  1253 
  1274 
  1254     public com.oracle.webservices.internal.api.message.ContentType writeTo( WritableByteChannel buffer ) {
  1275     public com.oracle.webservices.internal.api.message.ContentType writeTo( WritableByteChannel buffer ) {
  1255         return getCodec().encode(this, buffer);
  1276         return getCodec().encode(this, buffer);
  1256     }
  1277     }
  1257 
  1278 
       
  1279     /**
       
  1280      * This content type may be set by one of the following ways:
       
  1281      * (1) By the codec as a result of decoding an incoming message
       
  1282      * (2) Cached by a codec after encoding the message
       
  1283      * (3) By a caller of Codec.decode(InputStream, String contentType, Packet)
       
  1284      */
  1258     private ContentType contentType;
  1285     private ContentType contentType;
  1259 
  1286 
  1260     /**
  1287     /**
  1261      * If the request's Content-Type is multipart/related; type=application/xop+xml, then this set to to true
  1288      * If the request's Content-Type is multipart/related; type=application/xop+xml, then this set to to true
  1262      *
  1289      *
  1408 
  1435 
  1409     private boolean shouldUseMtomOutbound() {
  1436     private boolean shouldUseMtomOutbound() {
  1410         //Use the getter to make sure all the logic is executed correctly
  1437         //Use the getter to make sure all the logic is executed correctly
  1411         MTOMFeature myMtomFeature = getMtomFeature();
  1438         MTOMFeature myMtomFeature = getMtomFeature();
  1412         if(myMtomFeature != null && myMtomFeature.isEnabled()) {
  1439         if(myMtomFeature != null && myMtomFeature.isEnabled()) {
       
  1440                 //If the content type is set already on this outbound Packet,
       
  1441                 //(e.g.) through Codec.decode(InputStream, String contentType, Packet)
       
  1442                 //and it is a non-mtom content type, then don't use mtom to encode it
       
  1443                 ContentType curContentType = getInternalContentType();
       
  1444                 if (curContentType != null && !isMtomContentType(curContentType)) {
       
  1445                         return false;
       
  1446                 }
  1413             //On client, always use XOP encoding if MTOM is enabled
  1447             //On client, always use XOP encoding if MTOM is enabled
  1414             //On Server, mtomAcceptable and mtomRequest will be set - use XOP encoding
  1448             //On Server, mtomAcceptable and mtomRequest will be set - use XOP encoding
  1415             //if either request is XOP encoded (mtomRequest) or
  1449             //if either request is XOP encoded (mtomRequest) or
  1416             //client accepts XOP encoding (mtomAcceptable)
  1450             //client accepts XOP encoding (mtomAcceptable)
  1417             if (getMtomAcceptable() == null && getMtomRequest() == null) {
  1451             if (getMtomAcceptable() == null && getMtomRequest() == null) {
  1430         }
  1464         }
  1431         return false;
  1465         return false;
  1432     }
  1466     }
  1433 
  1467 
  1434     private boolean isMtomContentType() {
  1468     private boolean isMtomContentType() {
  1435         return (getInternalContentType() != null) &&
  1469         return (getInternalContentType() != null && isMtomContentType(getInternalContentType()));
  1436         (getInternalContentType().getContentType().contains("application/xop+xml"));
  1470     }
  1437     }
  1471 
  1438 
  1472     private boolean isMtomContentType(ContentType cType) {
  1439     /**
  1473                 return cType.getContentType().contains("application/xop+xml");
       
  1474         }
       
  1475 
       
  1476         /**
  1440      * @deprecated
  1477      * @deprecated
  1441      */
  1478      */
  1442     public void addSatellite(@NotNull com.sun.xml.internal.ws.api.PropertySet satellite) {
  1479     public void addSatellite(@NotNull com.sun.xml.internal.ws.api.PropertySet satellite) {
  1443         super.addSatellite(satellite);
  1480         super.addSatellite(satellite);
  1444     }
  1481     }