jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/transport/http/HttpAdapter.java
changeset 23782 953bfc3fbe31
parent 20590 b3b34e4344ce
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
    30 import java.io.InputStream;
    30 import java.io.InputStream;
    31 import java.io.OutputStream;
    31 import java.io.OutputStream;
    32 import java.io.OutputStreamWriter;
    32 import java.io.OutputStreamWriter;
    33 import java.io.PrintWriter;
    33 import java.io.PrintWriter;
    34 import java.net.HttpURLConnection;
    34 import java.net.HttpURLConnection;
       
    35 import java.util.AbstractMap;
       
    36 import java.util.Collection;
    35 import java.util.Collections;
    37 import java.util.Collections;
    36 import java.util.HashMap;
    38 import java.util.HashMap;
    37 import java.util.List;
    39 import java.util.List;
    38 import java.util.Map;
    40 import java.util.Map;
    39 import java.util.Map.Entry;
    41 import java.util.Map.Entry;
       
    42 import java.util.Set;
    40 import java.util.TreeMap;
    43 import java.util.TreeMap;
    41 import java.util.logging.Level;
    44 import java.util.logging.Level;
    42 import java.util.logging.Logger;
    45 import java.util.logging.Logger;
    43 
    46 
    44 import javax.xml.ws.Binding;
    47 import javax.xml.ws.Binding;
   170     /**
   173     /**
   171      * Fill in WSDL map.
   174      * Fill in WSDL map.
   172      *
   175      *
   173      * @param sdef service definition
   176      * @param sdef service definition
   174      */
   177      */
   175     public final void initWSDLMap(ServiceDefinition sdef) {
   178     public final void initWSDLMap(final ServiceDefinition serviceDefinition) {
   176         this.serviceDefinition = sdef;
   179         this.serviceDefinition = serviceDefinition;
   177         if(sdef==null) {
   180         if(serviceDefinition==null) {
   178             wsdls = Collections.emptyMap();
   181             wsdls = Collections.emptyMap();
   179             revWsdls = Collections.emptyMap();
   182             revWsdls = Collections.emptyMap();
   180         } else {
   183         } else {
   181             wsdls = new HashMap<String, SDDocument>();  // wsdl=1 --> Doc
   184             wsdls = new AbstractMap<String, SDDocument>() {
   182             // Sort WSDL, Schema documents based on SystemId so that the same
   185                 private Map<String, SDDocument> delegate = null;
   183             // document gets wsdl=x mapping
   186 
   184             Map<String, SDDocument> systemIds = new TreeMap<String, SDDocument>();
   187                 private synchronized Map<String, SDDocument> delegate() {
   185             for (SDDocument sdd : sdef) {
   188                     if (delegate != null)
   186                 if (sdd == sdef.getPrimary()) { // No sorting for Primary WSDL
   189                         return delegate;
   187                     wsdls.put("wsdl", sdd);
   190 
   188                     wsdls.put("WSDL", sdd);
   191                     delegate = new HashMap<String, SDDocument>();  // wsdl=1 --> Doc
   189                 } else {
   192                     // Sort WSDL, Schema documents based on SystemId so that the same
   190                     systemIds.put(sdd.getURL().toString(), sdd);
   193                     // document gets wsdl=x mapping
   191                 }
   194                     Map<String, SDDocument> systemIds = new TreeMap<String, SDDocument>();
   192             }
   195                     for (SDDocument sdd : serviceDefinition) {
   193 
   196                         if (sdd == serviceDefinition.getPrimary()) { // No sorting for Primary WSDL
   194             int wsdlnum = 1;
   197                             delegate.put("wsdl", sdd);
   195             int xsdnum = 1;
   198                             delegate.put("WSDL", sdd);
   196             for (Entry<String, SDDocument> e : systemIds.entrySet()) {
   199                         } else {
   197                 SDDocument sdd = e.getValue();
   200                             systemIds.put(sdd.getURL().toString(), sdd);
   198                 if (sdd.isWSDL()) {
   201                         }
   199                     wsdls.put("wsdl="+(wsdlnum++),sdd);
   202                     }
   200                 }
   203 
   201                 if (sdd.isSchema()) {
   204                     int wsdlnum = 1;
   202                     wsdls.put("xsd="+(xsdnum++),sdd);
   205                     int xsdnum = 1;
   203                 }
   206                     for (Entry<String, SDDocument> e : systemIds.entrySet()) {
   204             }
   207                         SDDocument sdd = e.getValue();
   205 
   208                         if (sdd.isWSDL()) {
   206             revWsdls = new HashMap<SDDocument,String>();    // Doc --> wsdl=1
   209                             delegate.put("wsdl="+(wsdlnum++),sdd);
   207             for (Entry<String,SDDocument> e : wsdls.entrySet()) {
   210                         }
   208                 if (!e.getKey().equals("WSDL")) {           // map Doc --> wsdl, not WSDL
   211                         if (sdd.isSchema()) {
   209                     revWsdls.put(e.getValue(),e.getKey());
   212                             delegate.put("xsd="+(xsdnum++),sdd);
   210                 }
   213                         }
   211             }
   214                     }
       
   215 
       
   216                     return delegate;
       
   217                 }
       
   218 
       
   219                 @Override
       
   220                 public void clear() {
       
   221                     delegate().clear();
       
   222                 }
       
   223 
       
   224                 @Override
       
   225                 public boolean containsKey(Object arg0) {
       
   226                     return delegate().containsKey(arg0);
       
   227                 }
       
   228 
       
   229                 @Override
       
   230                 public boolean containsValue(Object arg0) {
       
   231                     return delegate.containsValue(arg0);
       
   232                 }
       
   233 
       
   234                 @Override
       
   235                 public SDDocument get(Object arg0) {
       
   236                     return delegate().get(arg0);
       
   237                 }
       
   238 
       
   239                 @Override
       
   240                 public boolean isEmpty() {
       
   241                     return delegate().isEmpty();
       
   242                 }
       
   243 
       
   244                 @Override
       
   245                 public Set<String> keySet() {
       
   246                     return delegate().keySet();
       
   247                 }
       
   248 
       
   249                 @Override
       
   250                 public SDDocument put(String arg0, SDDocument arg1) {
       
   251                     return delegate().put(arg0, arg1);
       
   252                 }
       
   253 
       
   254                 @Override
       
   255                 public void putAll(
       
   256                         Map<? extends String, ? extends SDDocument> arg0) {
       
   257                     delegate().putAll(arg0);
       
   258                 }
       
   259 
       
   260                 @Override
       
   261                 public SDDocument remove(Object arg0) {
       
   262                     return delegate().remove(arg0);
       
   263                 }
       
   264 
       
   265                 @Override
       
   266                 public int size() {
       
   267                     return delegate().size();
       
   268                 }
       
   269 
       
   270                 @Override
       
   271                 public Collection<SDDocument> values() {
       
   272                     return delegate().values();
       
   273                 }
       
   274 
       
   275                 @Override
       
   276                 public Set<java.util.Map.Entry<String, SDDocument>> entrySet() {
       
   277                     return delegate().entrySet();
       
   278                 }
       
   279             };
       
   280 
       
   281             revWsdls = new AbstractMap<SDDocument, String>() {
       
   282                 private Map<SDDocument, String> delegate = null;
       
   283 
       
   284                 private synchronized Map<SDDocument, String> delegate() {
       
   285                     if (delegate != null)
       
   286                         return delegate;
       
   287 
       
   288                     delegate = new HashMap<SDDocument,String>();    // Doc --> wsdl=1
       
   289                     for (Entry<String,SDDocument> e : wsdls.entrySet()) {
       
   290                         if (!e.getKey().equals("WSDL")) {           // map Doc --> wsdl, not WSDL
       
   291                             delegate.put(e.getValue(),e.getKey());
       
   292                         }
       
   293                     }
       
   294 
       
   295                     return delegate;
       
   296                 }
       
   297 
       
   298                 @Override
       
   299                 public void clear() {
       
   300                     delegate().clear();
       
   301                 }
       
   302 
       
   303                 @Override
       
   304                 public boolean containsKey(Object key) {
       
   305                     return delegate().containsKey(key);
       
   306                 }
       
   307 
       
   308                 @Override
       
   309                 public boolean containsValue(Object value) {
       
   310                     return delegate().containsValue(value);
       
   311                 }
       
   312 
       
   313                 @Override
       
   314                 public Set<Entry<SDDocument, String>> entrySet() {
       
   315                     return delegate().entrySet();
       
   316                 }
       
   317 
       
   318                 @Override
       
   319                 public String get(Object key) {
       
   320                     return delegate().get(key);
       
   321                 }
       
   322 
       
   323                 @Override
       
   324                 public boolean isEmpty() {
       
   325                     // TODO Auto-generated method stub
       
   326                     return super.isEmpty();
       
   327                 }
       
   328 
       
   329                 @Override
       
   330                 public Set<SDDocument> keySet() {
       
   331                     return delegate().keySet();
       
   332                 }
       
   333 
       
   334                 @Override
       
   335                 public String put(SDDocument key, String value) {
       
   336                     return delegate().put(key, value);
       
   337                 }
       
   338 
       
   339                 @Override
       
   340                 public void putAll(Map<? extends SDDocument, ? extends String> m) {
       
   341                     delegate().putAll(m);
       
   342                 }
       
   343 
       
   344                 @Override
       
   345                 public String remove(Object key) {
       
   346                     return delegate().remove(key);
       
   347                 }
       
   348 
       
   349                 @Override
       
   350                 public int size() {
       
   351                     return delegate().size();
       
   352                 }
       
   353 
       
   354                 @Override
       
   355                 public Collection<String> values() {
       
   356                     return delegate().values();
       
   357                 }
       
   358             };
   212         }
   359         }
   213     }
   360     }
   214 
   361 
   215     /**
   362     /**
   216      * Returns the "/abc/def/ghi" portion if
   363      * Returns the "/abc/def/ghi" portion if
   979                 LOGGER.log(Level.CONFIG, "Cannot read ''{0}'' property, using defaults.",
  1126                 LOGGER.log(Level.CONFIG, "Cannot read ''{0}'' property, using defaults.",
   980                         new Object[] {HttpAdapter.class.getName() + ".dumpTreshold"});
  1127                         new Object[] {HttpAdapter.class.getName() + ".dumpTreshold"});
   981             }
  1128             }
   982         }
  1129         }
   983         try {
  1130         try {
   984             setPublishStatus(Boolean.getBoolean(HttpAdapter.class.getName() + ".publishStatusPage"));
  1131             if (System.getProperty(HttpAdapter.class.getName() + ".publishStatusPage") != null) {
       
  1132                 setPublishStatus(Boolean.getBoolean(HttpAdapter.class.getName() + ".publishStatusPage"));
       
  1133             }
   985         } catch (SecurityException se) {
  1134         } catch (SecurityException se) {
   986             if (LOGGER.isLoggable(Level.CONFIG)) {
  1135             if (LOGGER.isLoggable(Level.CONFIG)) {
   987                 LOGGER.log(Level.CONFIG, "Cannot read ''{0}'' property, using defaults.",
  1136                 LOGGER.log(Level.CONFIG, "Cannot read ''{0}'' property, using defaults.",
   988                         new Object[] {HttpAdapter.class.getName() + ".publishStatusPage"});
  1137                         new Object[] {HttpAdapter.class.getName() + ".publishStatusPage"});
   989             }
  1138             }