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 com.sun.xml.internal.ws.api.server.SDDocumentFilter; |
30 import com.sun.xml.internal.ws.api.server.SDDocumentFilter; |
31 import com.sun.xml.internal.ws.api.server.ServiceDefinition; |
31 import com.sun.xml.internal.ws.api.server.ServiceDefinition; |
32 import com.sun.xml.internal.ws.wsdl.SDDocumentResolver; |
32 import com.sun.xml.internal.ws.wsdl.SDDocumentResolver; |
33 |
33 |
34 import java.util.ArrayList; |
34 import java.util.ArrayList; |
|
35 import java.util.Collection; |
35 import java.util.HashMap; |
36 import java.util.HashMap; |
36 import java.util.Iterator; |
37 import java.util.Iterator; |
37 import java.util.List; |
38 import java.util.List; |
38 import java.util.Map; |
39 import java.util.Map; |
39 |
40 |
45 * a list of {@link SDDocumentImpl}s. |
46 * a list of {@link SDDocumentImpl}s. |
46 * |
47 * |
47 * @author Kohsuke Kawaguchi |
48 * @author Kohsuke Kawaguchi |
48 */ |
49 */ |
49 public final class ServiceDefinitionImpl implements ServiceDefinition, SDDocumentResolver { |
50 public final class ServiceDefinitionImpl implements ServiceDefinition, SDDocumentResolver { |
50 private final List<SDDocumentImpl> docs; |
51 private final Collection<SDDocumentImpl> docs; |
51 |
52 |
52 private final Map<String,SDDocumentImpl> bySystemId; |
53 private final Map<String,SDDocumentImpl> bySystemId; |
53 private final @NotNull SDDocumentImpl primaryWsdl; |
54 private final @NotNull SDDocumentImpl primaryWsdl; |
54 |
55 |
55 /** |
56 /** |
63 * @param docs |
64 * @param docs |
64 * List of {@link SDDocumentImpl}s to form the description. |
65 * List of {@link SDDocumentImpl}s to form the description. |
65 * There must be at least one entry. |
66 * There must be at least one entry. |
66 * The first document is considered {@link #getPrimary() primary}. |
67 * The first document is considered {@link #getPrimary() primary}. |
67 */ |
68 */ |
68 public ServiceDefinitionImpl(List<SDDocumentImpl> docs, @NotNull SDDocumentImpl primaryWsdl) { |
69 public ServiceDefinitionImpl(Collection<SDDocumentImpl> docs, @NotNull SDDocumentImpl primaryWsdl) { |
69 assert docs.contains(primaryWsdl); |
70 assert docs.contains(primaryWsdl); |
70 this.docs = docs; |
71 this.docs = docs; |
71 this.primaryWsdl = primaryWsdl; |
72 this.primaryWsdl = primaryWsdl; |
|
73 this.bySystemId = new HashMap<String, SDDocumentImpl>(); |
|
74 } |
72 |
75 |
73 this.bySystemId = new HashMap<String, SDDocumentImpl>(docs.size()); |
76 private boolean isInitialized = false; |
|
77 |
|
78 private synchronized void init() { |
|
79 if (isInitialized) |
|
80 return; |
|
81 isInitialized = true; |
|
82 |
74 for (SDDocumentImpl doc : docs) { |
83 for (SDDocumentImpl doc : docs) { |
75 bySystemId.put(doc.getURL().toExternalForm(),doc); |
84 bySystemId.put(doc.getURL().toExternalForm(),doc); |
76 doc.setFilters(filters); |
85 doc.setFilters(filters); |
77 doc.setResolver(this); |
86 doc.setResolver(this); |
78 } |
87 } |