Hi Joe,

Yes, you could set a bus to all your port, but you need write some no JAX-WS compatible codes.

Here is a code snippet for setting the default bus for all the thread

Bus bus = BusFactory.createBus();
// in you working thread start up
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
// then just use the JAX-WS API to get the port.

Please see my other comments in the mail.

Joe Sunday wrote:
Reading through that I'm still not clear.. Is the bus associated to the running JVM and shared for all ports, or is it per-port?

To rephrase back to my actual problem, which is painfully high memory usage when trying to talk to a complex endpoint where the WSDL is just under a meg, particularly when used against multiple endpoints from multiple threads.

1) Is it safe to use a single port from multiple threads concurrently?
I don't think so.
2) Is it safe to use multiple ports to different endpoints within a thread concurrently?
It should be safe.
3) Is bus shutdown the proper way to free the 20 MB or so per thread/port when I'm done with a port (but not done using CXF in my application)
It is no need for us the shutdown the bus per port invocation , because it will take a long time to load a bus.
4) Is there any way CXF can re-use all or some of the service model objects it builds from a WSDL the next time I bind it against a different endpoint? It seems like 98% of that 20 MB model should be the same objects every time.
The bus holds the reference of WSDL manager which holds the WSDL definitions which will eat up lots of memory for big wsdl file. If we share a same bus with all the ports, I think the memory consumption will be a low level.

--Joe

On Sep 7, 2007, at 2:59 AM, Willem Jiang wrote:

Hi
If you use the Jaxws API getPort to create the client proxy. CXF will try to get a default bus first , if the default bus is not exit, it will create a bus and set default bus and default thread local bus for you.

So the thread local object in your case should be the bus :)
Here are some code snippets which can help you to know better about the default Bus and bus.shutdown()
1. Bus creation
public CXFBusImpl(Map<Class, Object> extensions) {
       if (extensions == null) {
           extensions = new ConcurrentHashMap<Class, Object>();
       } else {
extensions = new ConcurrentHashMap<Class, Object>(extensions);
       }
       this.extensions = extensions;
             state = BusState.INITIAL;
             CXFBusFactory.possiblySetDefaultBus(this);
   }

2.  CXFBusFactory.possiblySetDefaultBus(this);
public static synchronized boolean possiblySetDefaultBus(Bus bus) {
// there is a thread location variable which store the default thread local bus
      if (localBus.get() == null) {
           localBus.set(bus);
       }
             if (defaultBus == null) {
           defaultBus = bus;                      return true;
       }
       return false;
   }

3. CXFBusImpl.shutdown(boolean wait)
   public void shutdown(boolean wait) {
BusLifeCycleManager lifeCycleManager = this.getExtension(BusLifeCycleManager.class);
       if (null != lifeCycleManager) {
           lifeCycleManager.preShutdown();
       }
       synchronized (this) {
           state = BusState.SHUTDOWN;
           notifyAll();
       }
       if (null != lifeCycleManager) {
           lifeCycleManager.postShutdown();
       }
       if (BusFactory.getDefaultBus(false) == this) {
           BusFactory.setDefaultBus(null);
       }
   }
You can find more information about bus by reading the source code.

CXFBusImpl https://svn.apache.org/repos/asf/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusImpl.java CXFBusFactory https://svn.apache.org/repos/asf/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/CXFBusFactory.java

Willem.

Joe Sunday wrote:
Is that a done with the client or done with the application call?

If there's something I need to call when I'm done with a particular port, I can deal with that. I don't see it documented anywhere though.

--Joe

On Sep 6, 2007, at 3:21 PM, Daniel Kulp wrote:


Joe,

One thing to keep in mind: the Bus would still be around. You'd need to get the default Bus and call shutdown() on it if you're completely done.

Dan

--
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
[EMAIL PROTECTED]
http://www.dankulp.com/blog


Willem.

Reply via email to