< prev index next >

src/java.xml.ws/share/classes/com/sun/xml/internal/ws/protocol/soap/ServerMUTube.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.ws.protocol.soap;
  27 
  28 import com.sun.xml.internal.ws.api.message.Packet;
  29 import com.sun.xml.internal.ws.api.pipe.*;
  30 import com.sun.xml.internal.ws.client.HandlerConfiguration;
  31 import javax.xml.namespace.QName;
  32 import java.util.Set;


  33 
  34 /**
  35  * @author Rama Pulavarthi
  36  */
  37 
  38 public class ServerMUTube extends MUTube {
  39 
  40     private ServerTubeAssemblerContext tubeContext;
  41     private final Set<String> roles;
  42     private final Set<QName> handlerKnownHeaders;

  43 
  44     public ServerMUTube(ServerTubeAssemblerContext tubeContext, Tube next) {
  45         super(tubeContext.getEndpoint().getBinding(), next);
  46 
  47         this.tubeContext = tubeContext;
  48 
  49         //On Server, HandlerConfiguration does n't change after publish, so store locally
  50         HandlerConfiguration handlerConfig = binding.getHandlerConfig();
  51         roles = handlerConfig.getRoles();
  52         handlerKnownHeaders = binding.getKnownHeaders();
  53     }
  54 
  55     protected ServerMUTube(ServerMUTube that, TubeCloner cloner) {
  56         super(that,cloner);
  57         tubeContext = that.tubeContext;
  58         roles = that.roles;
  59         handlerKnownHeaders = that.handlerKnownHeaders;
  60     }
  61 
  62     /**
  63      * Do MU Header Processing on incoming message (request)
  64      * @return
  65      *      if all the headers in the packet are understood, returns action such that
  66      *      next pipe will be inovked.
  67      *      if all the headers in the packet are not understood, returns action such that
  68      *      SOAPFault Message is sent to previous pipes.
  69      */
  70     @Override
  71     public NextAction processRequest(Packet request) {
  72         Set<QName> misUnderstoodHeaders = getMisUnderstoodHeaders(request.getMessage().getHeaders(),roles, handlerKnownHeaders);






  73         if((misUnderstoodHeaders == null)  || misUnderstoodHeaders.isEmpty()) {
  74             return doInvoke(super.next, request);
  75         }
  76         return doReturnWith(request.createServerResponse(createMUSOAPFaultMessage(misUnderstoodHeaders),
  77                 tubeContext.getWsdlModel(), tubeContext.getSEIModel(), tubeContext.getEndpoint().getBinding()));
  78     }
  79 
  80     public ServerMUTube copy(TubeCloner cloner) {
  81         return new ServerMUTube(this,cloner);
  82     }
  83 
  84 }
   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.ws.protocol.soap;
  27 
  28 import com.sun.xml.internal.ws.api.message.Packet;
  29 import com.sun.xml.internal.ws.api.pipe.*;
  30 import com.sun.xml.internal.ws.client.HandlerConfiguration;
  31 import javax.xml.namespace.QName;
  32 import java.util.Set;
  33 import java.util.concurrent.locks.Lock;
  34 import java.util.concurrent.locks.ReentrantLock;
  35 
  36 /**
  37  * @author Rama Pulavarthi
  38  */
  39 
  40 public class ServerMUTube extends MUTube {
  41 
  42     private ServerTubeAssemblerContext tubeContext;
  43     private final Set<String> roles;
  44     private final Set<QName> handlerKnownHeaders;
  45     private final Lock lock = new ReentrantLock();
  46 
  47     public ServerMUTube(ServerTubeAssemblerContext tubeContext, Tube next) {
  48         super(tubeContext.getEndpoint().getBinding(), next);
  49 
  50         this.tubeContext = tubeContext;
  51 
  52         //On Server, HandlerConfiguration does n't change after publish, so store locally
  53         HandlerConfiguration handlerConfig = binding.getHandlerConfig();
  54         roles = handlerConfig.getRoles();
  55         handlerKnownHeaders = binding.getKnownHeaders();
  56     }
  57 
  58     protected ServerMUTube(ServerMUTube that, TubeCloner cloner) {
  59         super(that,cloner);
  60         tubeContext = that.tubeContext;
  61         roles = that.roles;
  62         handlerKnownHeaders = that.handlerKnownHeaders;
  63     }
  64 
  65     /**
  66      * Do MU Header Processing on incoming message (request)
  67      * @return
  68      *      if all the headers in the packet are understood, returns action such that
  69      *      next pipe will be inovked.
  70      *      if all the headers in the packet are not understood, returns action such that
  71      *      SOAPFault Message is sent to previous pipes.
  72      */
  73     @Override
  74     public NextAction processRequest(Packet request) {
  75         Set<QName> misUnderstoodHeaders=null;
  76         lock.lock();
  77         try{
  78             misUnderstoodHeaders = getMisUnderstoodHeaders(request.getMessage().getHeaders(),roles, handlerKnownHeaders);
  79         } finally {
  80             lock.unlock();
  81         }
  82         if((misUnderstoodHeaders == null)  || misUnderstoodHeaders.isEmpty()) {
  83             return doInvoke(super.next, request);
  84         }
  85         return doReturnWith(request.createServerResponse(createMUSOAPFaultMessage(misUnderstoodHeaders),
  86                 tubeContext.getWsdlModel(), tubeContext.getSEIModel(), tubeContext.getEndpoint().getBinding()));
  87     }
  88 
  89     public ServerMUTube copy(TubeCloner cloner) {
  90         return new ServerMUTube(this,cloner);
  91     }
  92 
  93 }
< prev index next >