View Javadoc

1    /****************************************************************************
2    * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the LGPL License v2.1
5    * which accompanies this distribution, and is available at
6    * http://www.gnu.org/licenses/lgpl.html
7    ****************************************************************************/
8   package it.imolinfo.jbi4corba.webservice.generator;
9   
10  
11  import it.imolinfo.jbi4corba.webservice.generator.typedef.TypeDef;
12  
13  import java.net.URLClassLoader;
14  import java.util.ArrayList;
15  import java.util.HashMap;
16  import java.util.HashSet;
17  import java.util.List;
18  import java.util.Map;
19  import java.util.Set;
20  
21  import org.apache.commons.lang.builder.EqualsBuilder;
22  import org.apache.commons.lang.builder.ReflectionToStringBuilder;
23  
24  /** 
25   * This class contains all the information collectect during the code generation
26   * (WSDL to CORBA) of the component.
27   */
28  public class ServerCorbaClassesHolder {
29  
30    private Class webServiceInterface;
31    private Class webServiceImpl;
32    private Class corbaOperations;
33    private Class corbaPOATie;
34    private Class corbaHelper;
35    private boolean generateClassesFromIDL;
36  
37    /**
38     * A class that implements a corba interface.
39     */
40    private Class corbaImplClass;
41  
42    private URLClassLoader urlClassLoader;
43    
44    private URLClassLoader originalClassLoader;
45   
46    /**
47     * This map contains the pairs "valueTypeID, valueTypeFactoryInstance"
48     * registered in the ORB.
49     */
50    private Map<String, Object> valueTypeIdAndInstance;  
51  
52    /** Collects method Signature */
53    private List<MethodSignature> methodSignatures 
54        = new ArrayList<MethodSignature>();
55    
56    /** The information extracted from the WSDL during the code generation. */
57    private WsdlInformation wsdlInformation = null;
58    
59    /* Substituted union types mapping */
60    private Map<String, Map<String,String>> substitutedUnionFields 
61        = new HashMap<String, Map<String,String>>();
62  
63    private Map<String, UnionType> allUniontypes = null;
64    
65    /* Substituted Interface types mapping */
66    private Map<String, Map<String,String>> substitutedInterfaceFields 
67        = new HashMap<String, Map<String,String>>();
68    
69    private Map<String, InterfaceType> allInterfacetypes = null;
70    
71    /** store all types defined in IDL */
72    private Set<Class> allIDLTypes = new HashSet<Class>();
73    
74    /** store all enums defined in IDL */
75    Map<String, List<String>> corbaEnumMap = new HashMap<String, List<String>>();
76  
77    private Map<String,String> idTOClassNameMap = new HashMap<String, String>();
78    
79    private Map<String, TypeDef> typeDefs = new HashMap<String, TypeDef>();
80    // ========================
81    //        Getter And Setter
82    // ========================
83  
84    public WsdlInformation getWsdlInformation() {
85      return wsdlInformation;
86    }
87  
88    public void setWsdlInformation(WsdlInformation wsdlInformation) {
89      this.wsdlInformation = wsdlInformation;
90    }
91  
92    /**
93     * Default constructor.
94     */
95    public ServerCorbaClassesHolder (){
96    }
97  
98    /**
99     * @return  A map where the key is the valuetype ID
100    *          and the value is an instance of the factory.
101    */
102   public Map<String, Object> getValueTypeIdAndInstance() {
103     return valueTypeIdAndInstance;
104   }
105 
106   /**
107    * @param valueTypeIdAndInstance  The value type id and instance
108    */
109   public void setValueTypeIdAndInstance(Map<String, Object> valueTypeIdAndInstance) {
110     this.valueTypeIdAndInstance = valueTypeIdAndInstance;
111   }
112 
113   /**
114    * @return  The return
115    */
116   public Class getCorbaOperations() {
117     return corbaOperations;
118   }
119 
120   /**
121    * @param corbaOperations The corba operations
122    */
123   public void setCorbaOperations(Class corbaOperations) {
124     this.corbaOperations = corbaOperations;
125   }
126 
127   /**
128    * @return  The return
129    */
130   public Class getCorbaPOATie() {
131     return corbaPOATie;
132   }
133   
134   /**
135    * @param corbaPOATie  The corba POA tie
136    */
137   public void setCorbaPOATie(Class corbaPOATie) {
138     this.corbaPOATie = corbaPOATie;
139   }
140   
141   /**
142    * @return  The return
143    */
144   public Class getWebServiceInterface() {
145     return webServiceInterface;
146   }
147   
148   /**
149    * @param webServiceInterface  The web service interface
150    */
151   public void setWebServiceInterface(Class webServiceInterface) {
152     this.webServiceInterface = webServiceInterface;
153   }
154 
155   /**
156    * @return  The return
157    */
158   public String toString() {
159     return ReflectionToStringBuilder.toString(this);
160   }
161 
162   /**
163    * @param obj  The object
164    * @return     The return
165    */
166   public boolean equals(Object obj) {
167     return EqualsBuilder.reflectionEquals(this, obj);
168   }
169   
170   /**
171    * @return  The return
172    */
173   public Class getCorbaHelper() {
174     return corbaHelper;
175   }
176   
177   /**
178    * @param corbaHelper  The corba helper
179    */
180   public void setCorbaHelper(Class corbaHelper) {
181     this.corbaHelper = corbaHelper;
182   }
183 
184   /**
185    * @return  The return
186    */
187   public URLClassLoader getUrlClassLoader() {
188     return urlClassLoader;
189   }
190 
191   /**
192    * @param urlClassLoader  The urlClassLoader
193    */
194   public void setUrlClassLoader(URLClassLoader urlClassLoader) {
195     this.urlClassLoader = urlClassLoader;
196   }
197 
198   public Class getWebServiceImpl() {
199       return webServiceImpl;
200   }
201   public void setWebServiceImpl(Class webServiceImpl) {
202       this.webServiceImpl = webServiceImpl;
203   }
204 
205   /**
206    * A getter.
207    *
208    * @return  A class that implements a corba interface.
209    */
210   public Class getCorbaImplClass() {
211     return corbaImplClass;
212   }
213 
214   /**
215    * A setter.
216    *
217    * @param  corbaImpl  A class that implements a corba interface.
218    */
219   public void setCorbaImplClass(Class corbaImpl) {
220     this.corbaImplClass = corbaImpl;
221   }
222 
223   public boolean isGenerateClassesFromIDL() {
224 	return generateClassesFromIDL;
225   }
226   public void setGenerateClassesFromIDL(boolean generateClassesFromIDL) {
227 	this.generateClassesFromIDL = generateClassesFromIDL;
228   }
229 
230   
231   /**
232   * 
233   * @return  The return
234   */
235  public URLClassLoader getOriginalClassLoader() {
236      return originalClassLoader;
237  }
238 
239  /**
240   * Return the Original Class LoaderURL that refer the original classes before the
241   * bytecode manipulation
242   * @param urlClassLoader  The url class loader
243   */
244  public void setOriginalClassLoader(URLClassLoader originalClassLoader) {
245      this.originalClassLoader = originalClassLoader;
246  }
247 
248 
249 	public List<MethodSignature> getMethodSignatures() {
250 		return methodSignatures;
251 	}
252 
253 	public void setMethodSignatures(List<MethodSignature> methodSignatures) {
254 		this.methodSignatures = methodSignatures;
255 	}
256 
257 	public Map<String, Map<String, String>> getSubstitutedUnionFields() {
258 		return substitutedUnionFields;
259 	}
260 
261 	public void setSubstitutedUnionFields(
262 			Map<String, Map<String, String>> substitutedUnionFields) {
263 		this.substitutedUnionFields = substitutedUnionFields;
264 	}
265 
266 	public Map<String, UnionType> getAllUniontypes() {
267 		return allUniontypes;
268 	}
269 
270 	public void setAllUniontypes(Map<String, UnionType> allUniontypes) {
271 		this.allUniontypes = allUniontypes;
272 	}
273 
274 	public void setSubstitutedInterfaceFields(
275 			Map<String, Map<String, String>> substitutedInterfaceFields) {
276 		this.substitutedInterfaceFields = substitutedInterfaceFields;
277 	}
278 
279 	public Map<String, InterfaceType> getAllInterfacetypes() {
280 		return allInterfacetypes;
281 	}
282 
283 	public void setAllInterfacetypes(Map<String, InterfaceType> allInterfaceypes) {
284 		this.allInterfacetypes = allInterfaceypes;
285 	}
286 
287 	public Map<String, SearchedType> getAllCorbaTypes() {
288 		Map<String, SearchedType> allCorbaTypes = new HashMap<String, SearchedType>();
289 
290 		allCorbaTypes.putAll(allInterfacetypes);
291 		allCorbaTypes.putAll(allUniontypes);
292 
293 		return allCorbaTypes;
294 	} 
295  
296 	public Set<Class> getAllIDLTypes() {
297 		return allIDLTypes;
298 	}
299 
300 	public void setAllIDLTypes(Set<Class> allIDLTypes) {
301 		this.allIDLTypes = allIDLTypes;
302 	}
303 
304 	public Map<String, List<String>> getCorbaEnumMap() {
305 		return corbaEnumMap;
306 	}
307 
308 	public void setCorbaEnumMap(Map<String, List<String>> corbaEnumMap) {
309 		this.corbaEnumMap = corbaEnumMap;
310 	}
311 
312     public void setIdToClassNameMap(Map<String, String> idToClassMap) {
313         idTOClassNameMap=idToClassMap;
314     }
315     
316     public Map<String,String> getIdToClassNameMap(){
317         return idTOClassNameMap;
318     }
319 
320 	public Map<String, TypeDef> getTypeDefs() {
321 		return typeDefs;
322 	}
323 
324 	public void setTypeDefs(Map<String, TypeDef> typeDefs) {
325 		this.typeDefs = typeDefs;
326 	}
327     
328     
329 }