src/share/jaxws_classes/com/sun/xml/internal/ws/server/ServiceDefinitionImpl.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -30,10 +30,11 @@
import com.sun.xml.internal.ws.api.server.SDDocumentFilter;
import com.sun.xml.internal.ws.api.server.ServiceDefinition;
import com.sun.xml.internal.ws.wsdl.SDDocumentResolver;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -45,11 +46,11 @@
* a list of {@link SDDocumentImpl}s.
*
* @author Kohsuke Kawaguchi
*/
public final class ServiceDefinitionImpl implements ServiceDefinition, SDDocumentResolver {
- private final List<SDDocumentImpl> docs;
+ private final Collection<SDDocumentImpl> docs;
private final Map<String,SDDocumentImpl> bySystemId;
private final @NotNull SDDocumentImpl primaryWsdl;
/**
@@ -63,16 +64,24 @@
* @param docs
* List of {@link SDDocumentImpl}s to form the description.
* There must be at least one entry.
* The first document is considered {@link #getPrimary() primary}.
*/
- public ServiceDefinitionImpl(List<SDDocumentImpl> docs, @NotNull SDDocumentImpl primaryWsdl) {
+ public ServiceDefinitionImpl(Collection<SDDocumentImpl> docs, @NotNull SDDocumentImpl primaryWsdl) {
assert docs.contains(primaryWsdl);
this.docs = docs;
this.primaryWsdl = primaryWsdl;
+ this.bySystemId = new HashMap<String, SDDocumentImpl>();
+ }
+
+ private boolean isInitialized = false;
+
+ private synchronized void init() {
+ if (isInitialized)
+ return;
+ isInitialized = true;
- this.bySystemId = new HashMap<String, SDDocumentImpl>(docs.size());
for (SDDocumentImpl doc : docs) {
bySystemId.put(doc.getURL().toExternalForm(),doc);
doc.setFilters(filters);
doc.setResolver(this);
}
@@ -93,10 +102,11 @@
public void addFilter(SDDocumentFilter filter) {
filters.add(filter);
}
public Iterator<SDDocument> iterator() {
+ init();
return (Iterator)docs.iterator();
}
/**
* Gets the {@link SDDocumentImpl} whose {@link SDDocumentImpl#getURL()}
@@ -104,8 +114,9 @@
*
* @return
* null if none is found.
*/
public SDDocument resolve(String systemId) {
+ init();
return bySystemId.get(systemId);
}
}