1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import com.eviware.soapui.config.InterfaceConfig;
19 import com.eviware.soapui.impl.InterfaceFactory;
20 import com.eviware.soapui.impl.WsdlInterfaceFactory;
21 import com.eviware.soapui.impl.rest.RestServiceFactory;
22 import com.eviware.soapui.impl.support.AbstractInterface;
23 import com.eviware.soapui.support.StringUtils;
24
25 public class InterfaceFactoryRegistry
26 {
27 private static Map<String,InterfaceFactory<?>> factories = new HashMap<String, InterfaceFactory<?>>();
28
29 static
30 {
31 factories.put( WsdlInterfaceFactory.WSDL_TYPE, new WsdlInterfaceFactory() );
32 factories.put( RestServiceFactory.REST_TYPE, new RestServiceFactory() );
33 }
34
35 public static AbstractInterface<?> createNew(WsdlProject project,String type, String name)
36 {
37 if( !factories.containsKey(type))
38 throw new RuntimeException( "Unknown interface type [" + type + "]" );
39
40 return factories.get( type ).createNew( project, name );
41 }
42
43 public static AbstractInterface<?> build(WsdlProject project, InterfaceConfig config)
44 {
45 String type = config.getType();
46 if( StringUtils.isNullOrEmpty(type))
47 type = WsdlInterfaceFactory.WSDL_TYPE;
48
49 return factories.get( type ).build( project, config );
50 }
51 }