You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-dev@ws.apache.org by an...@apache.org on 2003/04/17 12:17:48 UTC
cvs commit: xml-axis-wsif/java/src/org/apache/wsif/base WSIFServiceImpl.java
antelder 2003/04/17 03:17:48
Modified: java/src/org/apache/wsif/base WSIFServiceImpl.java
Log:
Tidy up the code a bit
Revision Changes Path
1.37 +19 -41 xml-axis-wsif/java/src/org/apache/wsif/base/WSIFServiceImpl.java
Index: WSIFServiceImpl.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/base/WSIFServiceImpl.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- WSIFServiceImpl.java 24 Mar 2003 13:05:36 -0000 1.36
+++ WSIFServiceImpl.java 17 Apr 2003 10:17:47 -0000 1.37
@@ -120,8 +120,7 @@
private Definition def = null;
private Service service;
private PortType portType;
- private Port[] myPortsArr;
- private Map myPortsMap;
+ private Map availablePorts;
private WSIFDynamicTypeMap typeMap = new WSIFDynamicTypeMap();
private String preferredPort = null;
private Map typeReg = null;
@@ -451,14 +450,7 @@
this.def = svc.def;
this.service = svc.service;
this.portType = svc.portType;
- this.myPortsArr = new Port[svc.myPortsArr.length];
- System.arraycopy(
- svc.myPortsArr,
- 0,
- this.myPortsArr,
- 0,
- svc.myPortsArr.length);
- this.myPortsMap = (Map) ((Hashtable) svc.myPortsMap).clone();
+ this.availablePorts = (Map) ((Hashtable) svc.availablePorts).clone();
this.typeMap = svc.typeMap.copy();
this.schemaTypesInitialised = svc.schemaTypesInitialised;
this.typeMapInitialised = svc.typeMapInitialised;
@@ -534,13 +526,10 @@
public Iterator getAvailablePortNames() throws WSIFException {
Trc.entry(this);
Iterator it = null;
- try {
- it = this.myPortsMap.keySet().iterator();
- } catch (NullPointerException ne) {
- Trc.exception(ne);
- it = null;
+ if (availablePorts != null) {
+ it = availablePorts.keySet().iterator();
}
- Trc.exit();
+ Trc.exit(it);
return it;
}
@@ -573,7 +562,7 @@
public WSIFPort getPort() throws WSIFException {
Trc.entry(this);
WSIFPort wp = null;
- if (preferredPort != null && myPortsMap.get(preferredPort) != null) {
+ if (preferredPort != null && availablePorts.get(preferredPort) != null) {
wp = getPort(this.preferredPort);
} else {
if (preferredPort != null)
@@ -593,16 +582,15 @@
if (portName == null) {
// Get first available port
- if (myPortsArr.length > 0) {
- port = myPortsArr[0];
+ if (availablePorts.size() > 0) {
+ port = (Port) availablePorts.entrySet().iterator().next();
}
- } else {
- port = (Port) myPortsMap.get(portName);
- }
- if (port == null) {
- if (portName == null) {
+ if (port == null) {
throw new WSIFException("Unable to find an available port");
- } else {
+ }
+ } else {
+ port = (Port) availablePorts.get(portName);
+ if (port == null) {
throw new WSIFException(
"Port '"
+ portName
@@ -611,12 +599,12 @@
}
}
- portName = port.getName();
WSIFPort portInstance = createDynamicWSIFPort(def, service, port);
if (portInstance == null) {
throw new WSIFException(
- "Provider was unable to create WSIFPort for port " + portName);
+ "Provider was unable to create WSIFPort for port " + port.getName());
}
+
// Store the chosen port so that we can query which was is being used
chosenPort = port;
@@ -911,7 +899,7 @@
"WSDL must contain at least one port in " + service.getQName());
}
- myPortsMap = new Hashtable();
+ availablePorts = new Hashtable();
for (Iterator i = ports.values().iterator(); i.hasNext();) {
Port port = (Port) i.next();
@@ -951,7 +939,7 @@
.getQName()
.equals(portType.getQName())) {
String portName = port.getName();
- myPortsMap.put(portName, port);
+ availablePorts.put(portName, port);
}
}
} catch (NullPointerException e) {
@@ -964,14 +952,6 @@
// Extensibility element 0 does not exist
}
}
- int size = myPortsMap.size();
- myPortsArr = new Port[size];
- int count = 0;
- for (Iterator i = myPortsMap.values().iterator(); i.hasNext();) {
- // NOTE: there is no order in ports (it is hash function dependent...)
- Port port = (Port) i.next();
- myPortsArr[count++] = port;
- }
// Set up the WSIFMapper and WSIFMappingConvention appropriately
String mapperClass = null;
@@ -1247,7 +1227,7 @@
}
SchemaType[] types = new SchemaType[schemaTypes.size()];
schemaTypes.toArray(types);
-
+
Map mappings = mapper.getMappings(types);
if (mappings != null) {
Iterator it = mappings.keySet().iterator();
@@ -1318,9 +1298,7 @@
buff += "\ndef:" + Trc.brief(def);
buff += "\nservice:" + Trc.brief(service);
buff += "\nportType:" + Trc.brief(portType);
- buff += "\nmyPortsArr:"
- + (myPortsArr == null ? "null" : myPortsArr.toString());
- buff += "\nmyPortsMap:" + Trc.brief(myPortsMap);
+ buff += "\navailablePorts:" + Trc.brief(availablePorts);
buff += "\ntypeMap:"
+ (typeMap == null ? "null" : typeMap.toString());
buff += "\ntypeMapInitialised:" + typeMapInitialised;