View Javadoc

1   /*
2    * Copyright 2005-2010 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.ws.soap.axiom;
18  
19  import java.util.Arrays;
20  import java.util.Iterator;
21  import java.util.List;
22  
23  import org.springframework.util.ObjectUtils;
24  import org.springframework.ws.soap.SoapHeaderElement;
25  import org.springframework.ws.soap.soap11.Soap11Header;
26  
27  import org.apache.axiom.soap.RolePlayer;
28  import org.apache.axiom.soap.SOAPFactory;
29  import org.apache.axiom.soap.SOAPHeader;
30  import org.apache.axiom.soap.SOAPHeaderBlock;
31  
32  /**
33   * Axiom-specific version of <code>org.springframework.ws.soap.Soap11Header</code>.
34   *
35   * @author Arjen Poutsma
36   * @since 1.0.0
37   */
38  class AxiomSoap11Header extends AxiomSoapHeader implements Soap11Header {
39  
40      AxiomSoap11Header(SOAPHeader axiomHeader, SOAPFactory axiomFactory) {
41          super(axiomHeader, axiomFactory);
42      }
43  
44      @SuppressWarnings("unchecked")
45      public Iterator<SoapHeaderElement> examineHeaderElementsToProcess(final String[] actors) {
46          RolePlayer rolePlayer = null;
47          if (!ObjectUtils.isEmpty(actors)) {
48              rolePlayer = new RolePlayer() {
49  
50                  public List<?> getRoles() {
51                      return Arrays.asList(actors);
52                  }
53  
54                  public boolean isUltimateDestination() {
55                      return false;
56                  }
57              };
58          }
59          Iterator<SOAPHeaderBlock> result = (Iterator<SOAPHeaderBlock>)getAxiomHeader().getHeadersToProcess(rolePlayer);
60          return new AxiomSoapHeaderElementIterator(result);
61      }
62  }