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.descriptor;
9   
10  import it.imolinfo.jbi4corba.jbi.endpoint.ProviderEndpoint;
11  import it.imolinfo.jbi4corba.webservice.generator.ChildFirstClassLoader;
12  import it.imolinfo.jbi4corba.webservice.generator.InterfaceType;
13  import it.imolinfo.jbi4corba.webservice.generator.MethodSignature;
14  import it.imolinfo.jbi4corba.webservice.generator.SearchedType;
15  import it.imolinfo.jbi4corba.webservice.generator.UnionType;
16  import it.imolinfo.jbi4corba.webservice.generator.typedef.TypeDef;
17  
18  import java.io.Serializable;
19  import java.net.URLClassLoader;
20  import java.util.ArrayList;
21  import java.util.HashMap;
22  import java.util.HashSet;
23  import java.util.List;
24  import java.util.Map;
25  import java.util.Properties;
26  import java.util.Set;
27  
28  import javax.xml.namespace.QName;
29  
30  import org.apache.commons.lang.builder.EqualsBuilder;
31  import org.apache.commons.lang.builder.ReflectionToStringBuilder;
32  
33  /**
34   * The provider service descriptor.
35   */
36  public class ProviderServiceDescriptor implements Serializable {
37  
38  	/** A type of localization. */
39  	public static final String NAMESERVICE = "NameService";
40  
41  	/** A type of localization. */
42  	public static final String CORBALOC = "corbaloc";
43  
44  	/** A type of localization. */
45  	public static final String CORBANAME = "corbaname";
46  
47  	/** A type of localization. */
48  	public static final String IOR = "IOR";
49  
50  	/** The SerialVersionUID. */
51  	private static final long serialVersionUID = -6630066280740249302L;
52  
53  	// has a ...
54  
55  	/** params used to expose the WebService. */
56  	private String serviceName;
57  
58  	private String corbaServiceName;
59  
60  	private String serviceNameSpace;
61  
62  	private String wsdlRootDirectory;
63  
64  	/** params used to define the corba service. */
65  	private Class serviceInterface;
66  
67  	private Class corbaHelperClass;
68  
69  	private Class corbaObjectInterface;
70  
71  	/* the corba reference used to run the service. */
72  	private org.omg.CORBA.Object corbaObjectReference;
73  
74  	/* The properties used to initialize the ORB. */
75  	private Properties orbProperties;
76  
77  	/* This property defines how to find the corba service. */
78  	private String localizationType;
79  
80  	private URLClassLoader urlClassLoader;
81  
82  	private ChildFirstClassLoader originalClassLoader;
83  
84  	private String componentRootPath;
85  
86  	/* The port type name. */
87  	private QName portTypeName = null;
88  
89  	/* Collects method Signature */
90  	private List<MethodSignature> methodSignatures = new ArrayList<MethodSignature>();
91  
92  	/* Substituted union types mapping */
93  	private Map<String, Map<String, String>> substitutedUnionFields = new HashMap<String, Map<String, String>>();
94  
95  	private Map<String, UnionType> allUniontypes = null;
96  
97  	/* Substituted Interface types mapping */
98  	private Map<String, Map<String, String>> substitutedInterfaceFields = new HashMap<String, Map<String, String>>();
99  
100 	private Map<String, InterfaceType> allInterfacetypes = null;
101 
102 	private Map<String, TypeDef> typeDefs = null;
103 
104 	/** The provider end point */
105 	private ProviderEndpoint endpoint = null;
106 
107 	/**
108 	 * This map contains the pairs "valueTypeID, valueTypeFactoryInstance"
109 	 * registered in the ORB.
110 	 */
111 	private Map<String, Object> valueTypeIdAndInstance;
112 
113 	/** store all types defined in IDL */
114 	private Set<Class> allIDLTypes = new HashSet<Class>();
115 
116 	/** store all enums defined in IDL */
117 	Map<String, List<String>> corbaEnumMap = new HashMap<String, List<String>>();
118 
119 	/** the ID to ClassName Map */
120 	private Map<String, String> idTOClassNameMap = new HashMap<String, String>();
121 
122 	/**
123 	 * Constructor.
124 	 */
125 	public ProviderServiceDescriptor() {
126 		super();
127 	}
128 
129 	/**
130 	 * @return Returns the serviceName.
131 	 */
132 	public String getServiceName() {
133 		return serviceName;
134 	}
135 
136 	public void setIdToClassNameMap(Map<String, String> idToClassMap) {
137 		this.idTOClassNameMap = idToClassMap;
138 	}
139 
140 	public Map<String, String> getIdToClassNameMap() {
141 		return idTOClassNameMap;
142 	}
143 
144 	/**
145 	 * @param serviceName
146 	 *            The serviceName to set.
147 	 */
148 	public void setServiceName(String serviceName) {
149 		this.serviceName = serviceName;
150 	}
151 
152 	/**
153 	 * @return Returns the serviceNameSpace.
154 	 */
155 	public String getServiceNameSpace() {
156 		return serviceNameSpace;
157 	}
158 
159 	/**
160 	 * @param serviceNameSpace
161 	 *            The serviceNameSpace to set.
162 	 */
163 	public void setServiceNameSpace(String serviceNameSpace) {
164 		this.serviceNameSpace = serviceNameSpace;
165 	}
166 
167 	/**
168 	 * 
169 	 * @return The return
170 	 */
171 	public org.omg.CORBA.Object getCorbaObjectReference() {
172 		return corbaObjectReference;
173 	}
174 
175 	/**
176 	 * 
177 	 * @param corbaObjectReference
178 	 *            The corba object reference
179 	 */
180 	public void setCorbaObjectReference(
181 			org.omg.CORBA.Object corbaObjectReference) {
182 		this.corbaObjectReference = corbaObjectReference;
183 	}
184 
185 	/**
186 	 * 
187 	 * @return The return
188 	 */
189 	public Class getServiceInterface() {
190 		return serviceInterface;
191 	}
192 
193 	/**
194 	 * 
195 	 * @param serviceInterface
196 	 *            The service interface
197 	 */
198 	public void setServiceInterface(Class serviceInterface) {
199 		this.serviceInterface = serviceInterface;
200 	}
201 
202 	/**
203 	 * 
204 	 * @return The return
205 	 */
206 	public Class getCorbaHelperClass() {
207 		return corbaHelperClass;
208 	}
209 
210 	/**
211 	 * 
212 	 * @param corbaHelperClass
213 	 *            The corba helper class
214 	 */
215 	public void setCorbaHelperClass(Class corbaHelperClass) {
216 		this.corbaHelperClass = corbaHelperClass;
217 	}
218 
219 	/**
220 	 * 
221 	 * @return The return
222 	 */
223 	public Class getCorbaObjectInterface() {
224 		return corbaObjectInterface;
225 	}
226 
227 	/**
228 	 * 
229 	 * @param corbaObjectInterface
230 	 *            The corba object interface
231 	 */
232 	public void setCorbaObjectInterface(Class corbaObjectInterface) {
233 		this.corbaObjectInterface = corbaObjectInterface;
234 	}
235 
236 	/**
237 	 * 
238 	 * @return The return
239 	 */
240 	public String toString() {
241 		return ReflectionToStringBuilder.toString(this);
242 	}
243 
244 	/**
245 	 * @param obj
246 	 *            The object
247 	 * @return The return
248 	 */
249 	public boolean equals(Object obj) {
250 		return EqualsBuilder.reflectionEquals(this, obj);
251 	}
252 
253 	/**
254 	 * 
255 	 * @return The return
256 	 */
257 	public String getLocalizationType() {
258 		return localizationType;
259 	}
260 
261 	/**
262 	 * 
263 	 * @param localizationType
264 	 *            The localization type
265 	 */
266 	public void setLocalizationType(String localizationType) {
267 		this.localizationType = localizationType;
268 	}
269 
270 	/**
271 	 * 
272 	 * @return The return
273 	 */
274 	public Properties getOrbProperties() {
275 		return orbProperties;
276 	}
277 
278 	/**
279 	 * 
280 	 * @param orbProperties
281 	 *            The orb properties
282 	 */
283 	public void setOrbProperties(Properties orbProperties) {
284 		this.orbProperties = orbProperties;
285 	}
286 
287 	/**
288 	 * 
289 	 * @return The return
290 	 */
291 	public String getWsdlRootDirectory() {
292 		return wsdlRootDirectory;
293 	}
294 
295 	/**
296 	 * 
297 	 * @param wsdlRootDirectory
298 	 *            The wsdl root directory
299 	 */
300 	public void setWsdlRootDirectory(String wsdlRootDirectory) {
301 		this.wsdlRootDirectory = wsdlRootDirectory;
302 	}
303 
304 	/**
305 	 * 
306 	 * @return The return
307 	 */
308 	public String getCorbaServiceName() {
309 		return corbaServiceName;
310 	}
311 
312 	/**
313 	 * 
314 	 * @param corbaServiceName
315 	 *            The corba service name
316 	 */
317 	public void setCorbaServiceName(String corbaServiceName) {
318 		this.corbaServiceName = corbaServiceName;
319 	}
320 
321 	/**
322 	 * 
323 	 * @return The return
324 	 */
325 	public URLClassLoader getUrlClassLoader() {
326 		return urlClassLoader;
327 	}
328 
329 	/**
330 	 * 
331 	 * @param urlClassLoader
332 	 *            The url class loader
333 	 */
334 	public void setUrlClassLoader(URLClassLoader urlClassLoader) {
335 		this.urlClassLoader = urlClassLoader;
336 	}
337 
338 	/**
339 	 * 
340 	 * @return The return
341 	 */
342 	public ChildFirstClassLoader getOriginalClassLoader() {
343 		return originalClassLoader;
344 	}
345 
346 	/**
347 	 * Return the Original Class LoaderURL that refer the original classes
348 	 * before the bytecode manipulation
349 	 * 
350 	 * @param urlClassLoader
351 	 *            The url class loader
352 	 */
353 	public void setOriginalClassLoader(ChildFirstClassLoader originalClassLoader) {
354 		this.originalClassLoader = originalClassLoader;
355 	}
356 
357 	/**
358 	 * 
359 	 * @return The return
360 	 */
361 	public Map<String, Object> getValueTypeIdAndInstance() {
362 		return valueTypeIdAndInstance;
363 	}
364 
365 	/**
366 	 * 
367 	 * @param valueTypeIdAndInstance
368 	 *            The value type Id and instance
369 	 */
370 	public void setValueTypeIdAndInstance(
371 			Map<String, Object> valueTypeIdAndInstance) {
372 		this.valueTypeIdAndInstance = valueTypeIdAndInstance;
373 	}
374 
375 	/**
376 	 * 
377 	 * @return The return
378 	 */
379 	public String getComponentRootPath() {
380 		return componentRootPath;
381 	}
382 
383 	/**
384 	 * 
385 	 * @param componentRootPath
386 	 *            The component root path
387 	 */
388 	public void setComponentRootPath(String componentRootPath) {
389 		this.componentRootPath = componentRootPath;
390 	}
391 
392 	public QName getPortTypeName() {
393 		return portTypeName;
394 	}
395 
396 	public void setPortTypeName(QName portTypeName) {
397 		this.portTypeName = portTypeName;
398 	}
399 
400 	public List<MethodSignature> getMethodSignatures() {
401 		return methodSignatures;
402 	}
403 
404 	public void setMethodSignatures(List<MethodSignature> methodSignatures) {
405 		this.methodSignatures = methodSignatures;
406 	}
407 
408 	/**
409 	 * Set End point
410 	 * 
411 	 * @param endpoint
412 	 *            The ProviderEndpoint class
413 	 */
414 	public void setEndpoint(ProviderEndpoint endpoint) {
415 		this.endpoint = endpoint;
416 	}
417 
418 	/**
419 	 * Get End point
420 	 * 
421 	 * @return the return
422 	 */
423 	public ProviderEndpoint getEndpoint() {
424 		return endpoint;
425 	}
426 
427 	public Map<String, Map<String, String>> getSubstitutedUnionFields() {
428 		return substitutedUnionFields;
429 	}
430 
431 	public void setSubstitutedUnionFields(
432 			Map<String, Map<String, String>> substitutedUnionFields) {
433 		this.substitutedUnionFields = substitutedUnionFields;
434 	}
435 
436 	public Map<String, UnionType> getAllUniontypes() {
437 		return allUniontypes;
438 	}
439 
440 	public void setAllUniontypes(Map<String, UnionType> allUniontypes) {
441 		this.allUniontypes = allUniontypes;
442 	}
443 
444 	public Map<String, Map<String, String>> getSubstitutedInterfaceFields() {
445 		return substitutedUnionFields;
446 	}
447 
448 	public void setSubstitutedInterfaceFields(
449 			Map<String, Map<String, String>> substitutedInterfaceFields) {
450 		this.substitutedInterfaceFields = substitutedInterfaceFields;
451 	}
452 
453 	public Map<String, InterfaceType> getAllInterfacetypes() {
454 		return allInterfacetypes;
455 	}
456 
457 	public void setAllInterfacetypes(Map<String, InterfaceType> allInterfaceypes) {
458 		this.allInterfacetypes = allInterfaceypes;
459 	}
460 
461 	public Map<String, SearchedType> getAllCorbaTypes() {
462 		Map<String, SearchedType> allCorbaTypes = new HashMap<String, SearchedType>();
463 
464 		allCorbaTypes.putAll(allInterfacetypes);
465 		allCorbaTypes.putAll(allUniontypes);
466 
467 		return allCorbaTypes;
468 	}
469 
470 	public Set<Class> getAllIDLTypes() {
471 		return allIDLTypes;
472 	}
473 
474 	public void setAllIDLTypes(Set<Class> allIDLTypes) {
475 		this.allIDLTypes = allIDLTypes;
476 	}
477 
478 	public Map<String, List<String>> getCorbaEnumMap() {
479 		return corbaEnumMap;
480 	}
481 
482 	public void setCorbaEnumMap(Map<String, List<String>> corbaEnumMap) {
483 		this.corbaEnumMap = corbaEnumMap;
484 	}
485 
486 	public Map<String, TypeDef> getTypeDefs() {
487 		return typeDefs;
488 	}
489 
490 	public void setTypeDefs(Map<String, TypeDef> typeDefs) {
491 		this.typeDefs = typeDefs;
492 	}
493 
494 }