Of course:
1. Following jars included:
cxf-rt-wsdl-3.3.3.jar
cxf-core-3.3.3.jar
wsdl4j-1.6.3.jar
woodstox-core-5.0.3.jar
cxf-rt-transports-http-3.3.3.jar
cxf-rt-bindings-soap-3.3.3.jar
cxf-rt-databinding-aegis-3.3.3.jar
cxf-rt-frontend-simple-3.3.3.jar
stax2-api-3.1.4.jar
2. Main function:
public class RemoveDefinition {
private static String ipAddress = "10.110.108.41";
public static void main(String[] args) {
for (int i = 0; i < 5; i++) {
SMPConfigHandler handler = new SMPConfigHandler();
handler.removeDefinition(ipAddress);
handler = new SMPConfigHandler();
handler.removeDefinition(ipAddress);
}
}
}
3. SMPConfigHandler class:
public class SMPConfigHandler {
public void removeDefinition(String ipAddress) {
String wsdlLocation = "http" + "://" + ipAddress +
"/services/SMPConfig?wsdl";
try {
Bus bus = BusFactory.getDefaultBus();
WSDLManager wsdlManager =
bus.getExtension(WSDLManager.class);
if(wsdlManager!=null){
Definition def =
wsdlManager.getDefinition(wsdlLocation);
if(def!=null){
Long numOfOccurrences = 0l;
Long maxOfOccurrences = 1000L;
while(wsdlManager.getDefinitions().containsKey(wsdlLocation) &&
numOfOccurrences<=maxOfOccurrences) {
wsdlManager.removeDefinition(def);
numOfOccurrences++;
}
System.out.println("Definition removed for:
"+wsdlLocation+". Number
of occurrences: "+numOfOccurrences+". Definition still exist:
"+wsdlManager.getDefinitions().containsKey(wsdlLocation));
}
def = wsdlManager.getDefinition(wsdlLocation);
ServiceSchemaInfo schemas =
wsdlManager.getSchemasForDefinition(def);
wsdlManager.putSchemasForDefinition(def,schemas);
String msg = "Definition added for: "+wsdlLocation;
System.out.println(msg);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
4. Output:
Definition removed for: http://10.110.108.41/services/SMPConfig?wsdl. Number
of occurrences: 1. Definition still exist: false
Definition added for: http://10.110.108.41/services/SMPConfig?wsdl
Definition removed for: http://10.110.108.41/services/SMPConfig?wsdl.
*Number of occurrences: 2*. Definition still exist: false
Definition added for: http://10.110.108.41/services/SMPConfig?wsdl
Definition removed for: http://10.110.108.41/services/SMPConfig?wsdl.
*Number of occurrences: 2*. Definition still exist: false
Definition added for: http://10.110.108.41/services/SMPConfig?wsdl
Definition removed for: http://10.110.108.41/services/SMPConfig?wsdl. Number
of occurrences: 1. Definition still exist: false
Definition added for: http://10.110.108.41/services/SMPConfig?wsdl
5. Problem description:
CachMap class uses 2 internal maps which doesn't work correctly:
WeakIdentityHashMap sometimes contains more than 1 entry for specific wsdl.
Why 2 maps is needed ????
6. Suggested fix: I put these 2 internal maps to be ConcurrentHashMap and
everything works fine.
Thanks,
Arkady
--
Sent from: http://cxf.547215.n5.nabble.com/cxf-dev-f569328.html