01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.jaxws;
19:
20: import java.io.File;
21:
22: import org.apache.cxf.common.util.StringUtils;
23: import org.apache.cxf.frontend.AbstractServiceFactory;
24: import org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration;
25: import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
26: import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
27:
28: public class JaxwsServiceBuilder extends AbstractServiceFactory {
29:
30: final JaxWsServiceFactoryBean serviceFactory;
31:
32: public JaxwsServiceBuilder() {
33: super ();
34: serviceFactory = new JaxWsServiceFactoryBean();
35: //As this is a javatowsdl tool, explictly populate service model from class
36: serviceFactory.setPopulateFromClass(true);
37:
38: setServiceFactory(serviceFactory);
39: setBindingConfig(new JaxWsSoapBindingConfiguration(
40: serviceFactory));
41: }
42:
43: @Override
44: public void validate() {
45: Class clz = getServiceClass();
46: if (java.rmi.Remote.class.isAssignableFrom(clz)) {
47: throw new RuntimeException(
48: "JAXWS SEIs may not implement the java.rmi.Remote interface.");
49: }
50: }
51:
52: public File getOutputFile() {
53: JaxWsImplementorInfo jaxwsImpl = serviceFactory
54: .getJaxWsImplementorInfo();
55: String wsdlLocation = jaxwsImpl.getWsdlLocation();
56: if (!StringUtils.isEmpty(wsdlLocation)) {
57: return new File(wsdlLocation);
58: }
59: return super.getOutputFile();
60: }
61:
62: }
|