001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    
018    package org.apache.geronimo.cxf.builder;
019    
020    import java.net.URI;
021    import java.util.Map;
022    
023    import javax.xml.namespace.QName;
024    
025    import org.apache.geronimo.common.DeploymentException;
026    import org.apache.geronimo.gbean.GBeanInfo;
027    import org.apache.geronimo.gbean.GBeanInfoBuilder;
028    import org.apache.geronimo.j2ee.deployment.Module;
029    import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
030    import org.apache.geronimo.jaxws.builder.JAXWSServiceRefBuilder;
031    import org.apache.geronimo.kernel.repository.Environment;
032    import org.apache.geronimo.naming.deployment.ServiceRefBuilder;
033    import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
034    import org.apache.geronimo.xbeans.javaee.PortComponentRefType;
035    import org.apache.geronimo.xbeans.javaee.ServiceRefType;
036    
037    public class CXFServiceRefBuilder extends JAXWSServiceRefBuilder {
038    
039        private final CXFBuilder cxfBuilder;
040        
041        public CXFServiceRefBuilder(Environment defaultEnvironment,
042                                    String[] eeNamespaces,
043                                    CXFBuilder cxfBuilder) {
044            super(defaultEnvironment, eeNamespaces);
045            this.cxfBuilder = cxfBuilder;
046        }
047           
048        public Object createService(ServiceRefType serviceRef, GerServiceRefType gerServiceRef, 
049                                    Module module, ClassLoader cl, Class serviceInterfaceClass, 
050                                    QName serviceQName, URI wsdlURI, Class serviceReferenceType, 
051                                    Map<Class, PortComponentRefType> portComponentRefMap) throws DeploymentException {   
052            return this.cxfBuilder.createService(serviceInterfaceClass, serviceReferenceType, wsdlURI, 
053                                                 serviceQName, portComponentRefMap, serviceRef.getHandlerChains(),
054                                                 gerServiceRef, module, cl);
055        }
056        
057        public static final GBeanInfo GBEAN_INFO;
058    
059        static {
060            GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(
061                    CXFServiceRefBuilder.class, NameFactory.MODULE_BUILDER);
062            infoBuilder.addInterface(ServiceRefBuilder.class);
063            infoBuilder.addAttribute("defaultEnvironment", Environment.class, true,
064                    true);
065            infoBuilder.addAttribute("eeNamespaces", String[].class, true, true);
066            infoBuilder.addReference("CXFBuilder", CXFBuilder.class,
067                    NameFactory.MODULE_BUILDER);
068    
069            infoBuilder.setConstructor(new String[] { "defaultEnvironment",
070                    "eeNamespaces", "CXFBuilder" });
071    
072            GBEAN_INFO = infoBuilder.getBeanInfo();
073        }
074    
075        public static GBeanInfo getGBeanInfo() {
076            return GBEAN_INFO;
077        }
078    }