views:

593

answers:

2

I recently migrated my web services from Axis to CXF (2.1). It appears that while Axis needed the "axis.socketSecureFactory" set, CXF grabs the default. How do I set the default SocketFactory in Java to my own implementation (such as a property)?

What I am not looking to do is to set the default SocketFactory properties like setting the property for my truststore, keystore and passwords.

+1  A: 

According to the OpenJDK7 source code for javax.net.SocketFactory, the Sun JVM is hard coded to return a javax.net.DefaultSocketFactory for getDefault();

Edit: However, the default SSLSocketFactory can be set by the security property ssl.SocketFactory.provider

R. Bemrose
+1  A: 

If we are talking about the standard sockets then Socket.setSocketImplFactory(SocketImplFactory) is used to change factory for ordinary sockets and ServerSocket.setSocketFactory(SocketImplFactory) for server sockets.

If you are using these, then take note of the fact that you can only set these factories once.

Note the java socket implementation defaults to using SocksSocketImpl (a package visible class in java.net) if the it discovers that the factory is null in case you want a factory that can switch pack to the standard java implementation.

Nuoji