package org.codehaus.xfire.picocontainer;

import java.net.URL;
import java.util.Map;

import org.codehaus.xfire.picocontainer.util.PicoObjectInvoker;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.ServiceFactory;
import org.codehaus.xfire.service.binding.BindingProvider;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import org.codehaus.xfire.transport.TransportManager;
import org.picocontainer.PicoContainer;
import org.picocontainer.defaults.ObjectReference;
import org.picocontainer.defaults.SimpleReference;

/**
 * PicoContainer specialization of Java objects-specific implementation of the
 * {@link ServiceFactory} interface which uses a given picocontainer to pick
 * service objects instance when it's about to invoke them.
 * 
 * @author <a href="mailto:juze@intelli.biz">Jose Peleteiro</a>
 */
public class PicoObjectServiceFactory
    extends ObjectServiceFactory
{
    private ObjectReference picoReference;

    public PicoObjectServiceFactory(PicoContainer pico)
    {
        super();
        picoReference = new SimpleReference();
        picoReference.set(pico);
    }

    public PicoObjectServiceFactory(ObjectReference picoReference)
    {
        super();
        this.picoReference = picoReference;
    }

    public PicoObjectServiceFactory(PicoContainer pico, TransportManager transportManager,
            BindingProvider provider)
    {
        super(transportManager, provider);
        picoReference = new SimpleReference();
        picoReference.set(pico);
    }

    public PicoObjectServiceFactory(ObjectReference picoReference,
            TransportManager transportManager, BindingProvider provider)
    {
        super(transportManager, provider);
        this.picoReference = picoReference;
    }

    public Service create(Class clazz, String name, String namespace, Map properties)
    {
        return prepare(super.create(clazz, name, namespace, properties));
    }

    public Service create(Class clazz, URL wsdlUrl)
        throws Exception
    {
        return prepare(super.create(clazz, wsdlUrl));
    }

    public Service create(Class clazz)
    {
        return prepare(super.create(clazz));
    }

    /**
     * Prepare an ObjectService to use pico.
     */
    protected Service prepare(Service endpoint)
    {
        endpoint.setInvoker(new PicoObjectInvoker(picoReference,
                endpoint.getServiceInfo().getServiceClass()));
        return endpoint;
    }
}

@@ -80,16 +80,51 @@
 l.Map;%0A%0A
+import javax.xml.namespace.QName;%0A%0A
 import o
@@ -1978,32 +1978,33 @@
 rties));%0A    %7D%0A%0A
+%0A
     public Servi
@@ -2030,45 +2030,173 @@
 zz, 
-URL wsdlUrl)
+Map properties)%0A    %7B%0A        return prepare(super.create(clazz, properties));
 %0A    
+%7D%0A%0A
     
-throws Exception
+public Service create(Class clazz, QName name, URL wsdlUrl, Map properties)
 %0A   
@@ -2240,24 +2240,30 @@
 e(clazz,
+ name,
  wsdlUrl
 ));%0A    
@@ -2254,16 +2254,28 @@
  wsdlUrl
+, properties
 ));%0A    

Fix error with PicoOSF