View Javadoc

1   /*******************************************************************************
2    *  Copyright (c) 2005, 2006, 2007 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   
9   
10  package it.imolinfo.jbi4ejb.jbi.component;
11  
12  import it.imolinfo.jbi4ejb.Logger;
13  import it.imolinfo.jbi4ejb.LoggerFactory;
14  import it.imolinfo.jbi4ejb.descriptor.ProviderServiceDescriptor;
15  import it.imolinfo.jbi4ejb.exception.EJBWSDLGenerationException;
16  import it.imolinfo.jbi4ejb.exception.Jbi4EjbDeployException;
17  import it.imolinfo.jbi4ejb.exception.Jbi4EjbException;
18  import it.imolinfo.jbi4ejb.jbi.Messages;
19  import it.imolinfo.jbi4ejb.jbi.component.runtime.ComponentRuntime;
20  import it.imolinfo.jbi4ejb.jbi.component.runtime.DefaultServiceUnitManager;
21  import it.imolinfo.jbi4ejb.jbi.component.runtime.RuntimeHelper;
22  import it.imolinfo.jbi4ejb.jbi.endpoint.Jbi4EjbEndpoint;
23  import it.imolinfo.jbi4ejb.jbi.endpoint.Jbi4EjbProviderEndpoint;
24  import it.imolinfo.jbi4ejb.jbi.wsdl.Jbi4EjbAddress;
25  import it.imolinfo.jbi4ejb.jbi.wsdl.Jbi4EjbBinding;
26  import it.imolinfo.jbi4ejb.jbi.wsdl.Jbi4EjbExtension;
27  import it.imolinfo.jbi4ejb.jbi.wsdl.Jbi4EjbExtensionUtils;
28  import it.imolinfo.jbi4ejb.jbi.wsdl.Jbi4EjbTypes;
29  
30  import java.io.File;
31  import java.io.IOException;
32  import java.util.ArrayList;
33  import java.util.List;
34  
35  import javax.jbi.JBIException;
36  import javax.jbi.management.DeploymentException;
37  import javax.jbi.servicedesc.ServiceEndpoint;
38  import javax.wsdl.Definition;
39  import javax.wsdl.PortType;
40  import javax.wsdl.WSDLException;
41  import javax.wsdl.extensions.ExtensionRegistry;
42  import javax.wsdl.factory.WSDLFactory;
43  import javax.wsdl.xml.WSDLReader;
44  import javax.xml.namespace.QName;
45  import javax.xml.parsers.DocumentBuilder;
46  import javax.xml.parsers.DocumentBuilderFactory;
47  import javax.xml.parsers.ParserConfigurationException;
48  
49  import org.w3c.dom.Document;
50  import org.xml.sax.SAXException;
51  
52  import com.ibm.wsdl.Constants;
53  import com.ibm.wsdl.factory.WSDLFactoryImpl;
54  import com.sun.jbi.management.descriptor.ConfigurationException;
55  import com.sun.jbi.management.descriptor.EndpointIdentifier;
56  import com.sun.jbi.management.descriptor.SUDescriptorSupport;
57  
58  /**
59   * Jbi4Ejb Service Unit Manager. 
60   * Redefines: deploy/implement (no init).
61   * @see Jbi4EjbLifeCycle  for more details of the generated code.
62   * @author <a href="mailto:mpiraccini@imolinfo.it">Marco Piraccini</a>
63   */
64  public class Jbi4EjbSUManager extends DefaultServiceUnitManager {
65  
66      /** The Logger. */
67      private static final Logger LOG = LoggerFactory
68              .getLogger(Jbi4EjbSUManager.class);    
69      private static final Messages MESSAGES = Messages.getMessages(Jbi4EjbSUManager.class);
70      
71      /** The deployed endpoints. */
72      private List<Jbi4EjbEndpoint> deployedEndpoints = new ArrayList<Jbi4EjbEndpoint>();
73  
74      /** The activated endpoints. */
75      private List<Jbi4EjbEndpoint> activatedEndpoints = new ArrayList<Jbi4EjbEndpoint>();
76      
77      /** The life cycle. */
78      private Jbi4EjbLifeCycle lifeCycle = null;
79      
80      /**
81       * Constructor that takes the ComponentRuntime parameter.
82       * 
83       * @param ctx the component runtime context
84       */
85      public Jbi4EjbSUManager(ComponentRuntime ctx) {        
86          super(ctx);        
87          this.lifeCycle = (Jbi4EjbLifeCycle)ctx.getLifeCycle();
88      }
89  
90      /**
91       * Deploy a Service Unit to the component.
92       * 
93       * @param suName the service unit name
94       * @param suZipPath the service unit unzip path
95       * 
96       * @return the xml message string
97       * 
98       * @throws DeploymentException if some deploy problem occurs
99       * 
100      * @see javax.jbi.component.ServiceUnitManager#deploy(String, String);
101      */
102     public String deploy(String suName, String suZipPath) 
103     throws DeploymentException {
104         
105         final String taskName = "deploy";
106         boolean isSuccess = true;
107 
108         LOG.info("EJB000109_Deploying_su_in_SA", new Object[]{suName}, 
109         		new Object[]{suZipPath});
110         // DO nothing...
111                 
112         String retMsg = createComponentTaskResultXML(taskName, isSuccess);        
113         return retMsg;
114     }
115     
116     /**
117      * Start the deployed service unit.
118      * 
119      * @param serviceUnitName the service unit name
120      * 
121      * @throws DeploymentException if some problem occurs
122      * 
123      * @see javax.jbi.component.ServiceUnitManager#start(String);
124      */
125     public void start(String serviceUnitName) throws javax.jbi.management.DeploymentException {        
126 
127     	LOG.info("EJB000110_Starting_serviceUnit", new Object[]{serviceUnitName});
128         
129     	LOG.info("EJB000111_Deployed_Endpoints_number", new Object[]{deployedEndpoints.size()});
130         
131         // activate the SU deploy
132         for (Jbi4EjbEndpoint endpoint : deployedEndpoints) {
133             LOG.debug("endpoint.getSuName():" + endpoint.getSuName() );
134             if (endpoint.getSuName().equals(serviceUnitName)) {
135                 try {
136                     // Register the service
137                     LOG.debug("Registering the service: " + endpoint.getServiceName());
138                     endpoint.registerService();
139                     // Activate the endpoint
140                     LOG.debug("Activating the service: " + endpoint.getServiceName());
141                     activateEndpoint(endpoint);
142                     // Add the endpoint to the activated list
143                     activatedEndpoints.add(endpoint);
144                 } catch (Jbi4EjbException e) {
145                 	String msg=MESSAGES.getString("EJB000112_Failure_in_starting_endpoint", 
146                 			new Object[] {endpoint});
147                     LOG.error(msg,e);
148                     throw new DeploymentException(msg,e);
149                 }
150             }
151         }
152 
153     }
154 
155     /**
156      * Undeploy a service unit from the component.
157      * 
158      * @param suZipPath
159      *            the service unit unzip path
160      * @param serviceUnitName
161      *            the service unit name
162      * @return the xml result message
163      * 
164      * @throws DeploymentException
165      *             if some problem occurs
166      * 
167      * @see javax.jbi.component.ServiceUnitManager#undeploy(String, String);
168      */
169     public String undeploy(String serviceUnitName, String suZipPath)
170             throws DeploymentException {
171         final String taskName = "undeploy";
172         boolean isSuccess = true;
173         // Do nothing...
174         String retMsg = createComponentTaskResultXML(taskName, isSuccess);
175         return retMsg;
176     }
177     
178     
179     /**
180      * Stop the service unit.
181      * 
182      * @param serviceUnitName the service unit name
183      * @throws DeploymentException if some problem occurs
184      */
185     @SuppressWarnings("unchecked")
186     public void stop(String serviceUnitName)
187     throws javax.jbi.management.DeploymentException {        
188                 
189         List<Jbi4EjbEndpoint> endpointsToRemove = new ArrayList<Jbi4EjbEndpoint>();
190        
191         // deactivate the SU deploy
192         for (Jbi4EjbEndpoint ejbEndpoint : activatedEndpoints) {
193             if (ejbEndpoint.getSuName().equals(serviceUnitName))   {          
194                 try {
195                     // Unregister the service
196                     ejbEndpoint.unregisterService();
197                     // Deactivate the endpoint
198                     deactivateEndpoint(ejbEndpoint);
199                     // Removes the endpoint from the activated endpoint list
200                     endpointsToRemove.add(ejbEndpoint);       
201 
202                 } catch (Jbi4EjbException e) {
203                 	String msg=MESSAGES.getString("EJB000113_Failure_in_stopping_endpoint", 
204                 			new Object[] {ejbEndpoint});
205                     LOG.error(msg,e);
206                     throw new DeploymentException(msg,e);
207                 }
208             }
209         }
210         activatedEndpoints.removeAll(endpointsToRemove);        
211     }    
212     
213     ///////////////////////////////////////////////////////////////////////////
214     // Service Unit Lifecycle Management methods implementation
215     ///////////////////////////////////////////////////////////////////////////
216 
217     
218     /* (non-Javadoc)
219      * @see it.imolinfo.jbi4ejb.jbi.component.runtime.DefaultServiceUnitManager#init(java.lang.String, java.lang.String)
220      */
221     
222     /**
223      * Service unit init, process the Endpoint deploy.
224      * @param serviceUnitName the service unit name
225      * @param serviceUnitRootPath the service unit root path
226      * @throws DeploymentException if some problem occurs
227      */
228     public void init(String serviceUnitName, String serviceUnitRootPath)
229     throws javax.jbi.management.DeploymentException {
230         
231         // Gets the deployed endpoints and adds to the deployed endpoint list        
232         deployedEndpoints.addAll(processDeploy(serviceUnitName, serviceUnitRootPath));
233         
234         LOG.debug("Init: do nothing");
235         
236     }
237     
238     /**
239      * Service unit shutdown, removes the deployed endpoint.
240      * @param serviceUnitName the service unit name
241      * @see javax.jbi.component.ServiceUnitManager#shutdown(String);
242      * @throws DeploymentException if some problem occurs
243      */
244     public void shutDown(String serviceUnitName)
245     throws javax.jbi.management.DeploymentException {
246 
247         // Removes the deployed endpoint
248         List<Jbi4EjbEndpoint> deployedEndpointsToRemove = new ArrayList<Jbi4EjbEndpoint>();
249         // remove the SU deployed endpoints
250         for (Jbi4EjbEndpoint ejbEndpoint : deployedEndpoints) {
251             if (ejbEndpoint.getSuName().equals(serviceUnitName))   {          
252                 deployedEndpointsToRemove.add(ejbEndpoint);       
253             }
254         }
255         // REmoves t he endpoints from the deployed endpoint list
256         deployedEndpoints.removeAll(deployedEndpointsToRemove);
257     }       
258     
259     /**
260      * Gets the started endpoint from the <code>ServiceEndpoint</code> description. 
261      * @param endpoint the <code>Jbi4EjbEndpoint</code>
262      * @return the endpoint if found, null otherwise
263      */
264     public Jbi4EjbEndpoint getStartedEndpoint(ServiceEndpoint endpoint) {
265      // deactivate the SU deploy
266         for (Jbi4EjbEndpoint ejbEndpoint : activatedEndpoints) {
267                        
268             // Two endpoits are the same if the Service and the Endpoint name is the same
269             if ((ejbEndpoint.getServiceName().equals(endpoint.getServiceName())) &&
270                     (ejbEndpoint.getEndpointName().equals(endpoint.getEndpointName()))) {
271                 return ejbEndpoint;
272             }                
273         }     
274         // endpoint not found
275         return null;
276     }
277 
278     /**
279      * Process deploy.
280      * 
281      * @param suName the service unit name
282      * @param suZipPath the unzip path
283      * 
284      * @return the list< jbi4 ejb endpoint>
285      * 
286      * @throws DeploymentException if some problem occurs
287      * @throws  
288      */
289     private List<Jbi4EjbEndpoint> processDeploy(String suName, String suZipPath)
290             throws DeploymentException {
291 
292         final File suDir = new File(suZipPath);
293 
294         LOG.debug("The SU dir path is: " + suDir.getAbsolutePath());
295 
296         final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
297                 .newInstance();
298         DocumentBuilder documentBuilder = null;
299 
300         try {
301             documentBuilder = docBuilderFactory.newDocumentBuilder();
302         } catch (ParserConfigurationException ex) {
303         	String msg=MESSAGES.getString("EJB000115_Failure_in_creating_document_builder", 
304         			new Object[] {docBuilderFactory});
305             LOG.error(msg,ex);
306             throw new DeploymentException(msg,ex);
307         }
308 
309         // read all wsdl files to see if
310         final FileToDefinitionInfo[] fileToDefs = readAllDefinitions(suDir);
311 
312         final ArrayList<Jbi4EjbEndpoint> endpoints = new ArrayList<Jbi4EjbEndpoint>();
313 
314         if (SUDescriptorSupport.TEMP_SWITCH_ENABLE_JBI_ROUTING) {
315         	LOG.info("EJB000116_Parse_jbi.xml_to_resolve_service_end_point_in_given_path", 
316         			new Object[]{suDir.getAbsolutePath()});
317 
318             EndpointIdentifier[] svcs = null;
319 
320             SUDescriptorSupport descSupport = null;
321             try {
322                 descSupport = new SUDescriptorSupport(
323                         suDir.getAbsolutePath());                        
324 				// Gets the service description from the jbi.xml
325                 svcs = descSupport.getServices();
326             } catch (ConfigurationException ex) {
327             	String msg=MESSAGES.getString("EJB000117_Failure_in_getting_service_description");
328                 LOG.error(msg,ex);
329                 throw new DeploymentException(msg,ex);
330             }
331 
332             final int len = svcs.length;   
333             
334             LOG.info("EJB000118_Found_endpoint_declared_in_the_jbi.xml", 
335             		new Object[]{svcs.length});
336 
337             for (int i = 0; i < len; i++) {
338                 Definition matchedDef = null;
339                 File matchedWSDL = null;
340                 Jbi4EjbBinding ejbBinding = null;
341                 Jbi4EjbAddress ejbAddress = null;
342                 Jbi4EjbTypes ejbTypes = null;
343 
344                 // For each endpoint, analyzes the Definition.
345                 EndpointIdentifier epDesc = svcs[i];
346                 for (FileToDefinitionInfo element : fileToDefs) {
347                     ejbBinding = Jbi4EjbExtensionUtils.getEjbBinding(element
348                             .getDefinition(), epDesc.getServiceName()
349                             .toString(), epDesc.getEndpointName());                    
350                     if (ejbBinding != null) {
351                         matchedDef = element.getDefinition();
352                         // this is the wsdl that contains the service
353                         // endpoint, save it
354                         matchedWSDL = element.getFile();
355 
356                         break;
357                     }
358                 }
359                 if (ejbBinding != null) {
360                     ejbAddress = Jbi4EjbExtensionUtils.getEjbAddress(
361                             matchedDef, epDesc.getServiceName().toString(),
362                             epDesc.getEndpointName());
363 
364                     if (ejbAddress == null) {
365                     	String msg=MESSAGES.getString("EJB000119_No_address_found");
366                         LOG.error(msg);
367                         throw new DeploymentException(msg);
368                     }
369                     
370                     ejbTypes = Jbi4EjbExtensionUtils.getEjbTypes(matchedDef);
371                     if (ejbTypes == null) {
372                         LOG.warn("EJB000120_No_types_found");
373                     }                   
374                     
375                     PortType portType = Jbi4EjbExtensionUtils.getPortType(matchedDef, epDesc.getServiceName().toString(),
376                             epDesc.getEndpointName());                                       
377                    
378                     // Gets the endpoint data
379                     final String endpoint = epDesc.getEndpointName();
380                     final String endpointNameLocalPart = QName
381                             .valueOf(endpoint).getLocalPart();
382                     
383                     // For this BC, all are Providers endpoint                    
384                     Jbi4EjbProviderEndpoint ejbEndpoint;
385                     try {
386                         ejbEndpoint = new Jbi4EjbProviderEndpoint(epDesc.getServiceName(), endpointNameLocalPart);
387                     } catch (Jbi4EjbException e1) {
388                     	String msg=MESSAGES.getString("EJB000121_Failure_in_creating_new_provider_endpoint", 
389                     			new Object[] {epDesc.getServiceName()});
390                         LOG.error(msg,e1);
391                         throw new DeploymentException(msg,e1);
392                     }
393                     
394                     // Gets the endpoint data                    
395                     ejbEndpoint.setDefinition(matchedDef);
396                     ejbEndpoint.setState(Jbi4EjbEndpoint.SHUTDOWN);
397                     ejbEndpoint.setSuName(suName);
398                     ejbEndpoint.setSuManager(this);                    
399                     ejbEndpoint.setEndpointWSDL(matchedWSDL);                    
400                     
401                     // Gets the service data
402                     ProviderServiceDescriptor providerServiceDescriptor = new ProviderServiceDescriptor();                    
403                     providerServiceDescriptor.setComponentRootPath(suZipPath);
404                     providerServiceDescriptor.setName(ejbAddress.getName());
405                     providerServiceDescriptor.setLocalizationType(ejbAddress.getLocalizationType());
406                     providerServiceDescriptor.setJndiProperties(ejbBinding.getJndiProperties());
407                     providerServiceDescriptor.setOrbProperties(ejbBinding.getOrbProperties());
408                     if (ejbTypes != null) {
409                         providerServiceDescriptor.setSerialVersionUID(ejbTypes.getTypesSerialVersionUIDs());
410                     }
411                     providerServiceDescriptor.setPortTypeName(portType.getQName());
412                     providerServiceDescriptor.setServiceName(epDesc.getServiceName());
413                     ejbEndpoint.setServiceDescriptor(providerServiceDescriptor);
414 
415                     LOG.info("EJB000122_Parses_the_matched_WSDL");
416                     Document result;
417                     try {
418                         result = documentBuilder.parse(matchedWSDL);
419                     } catch (SAXException e) {
420                     	String msg=MESSAGES.getString("EJB000123_Error_in_parsing_the_deploy_WSDL", 
421                     			new Object[] {e.getMessage()});
422                         LOG.error(msg,e);
423                         throw new DeploymentException(msg,e);
424                     } catch (IOException e) {
425                     	String msg=MESSAGES.getString("EJB000123_Error_in_parsing_the_deploy_WSDL", 
426                     			new Object[] {e.getMessage()});
427                         LOG.error(msg,e);
428                         throw new DeploymentException(msg,e);
429                     }
430                     ejbEndpoint.setServiceDescription(result);
431 
432                     endpoints.add(ejbEndpoint);
433                 }
434             }
435         }
436 
437         return endpoints;
438     }
439     
440     /**
441      * Activate the endpoint.
442      * @param endpoint the ednpoint to activate
443      * @throws Jbi4EjbDeployException if some deployment problem occurs
444      */
445     private void activateEndpoint(final Jbi4EjbEndpoint endpoint) throws Jbi4EjbDeployException {
446                 
447         LOG.info("EJB000124_Activating_endpoint", new Object[]{endpoint.getUniqueName()});
448         
449         if (activatedEndpoints.indexOf(endpoint) != -1) {            
450         	String msg=MESSAGES.getString("EJB000125_Failed_to_deploy_endpoint_because_already_registered", 
451         			new Object[] {endpoint.getUniqueName()});
452             LOG.error(msg);
453             throw new Jbi4EjbDeployException(msg);
454         }
455         try {
456             QName serviceName = (QName) endpoint.getServiceName();
457             ServiceEndpoint serviceEndpoint 
458                 = RuntimeHelper.getComponentContext().activateEndpoint(endpoint.getServiceName(), endpoint.getEndpointName());
459                         
460             endpoint.setServiceEndpoint(serviceEndpoint);
461             LOG.info("EJB000126_Activated_endpoint", new Object[]{serviceName});
462             endpoint.setState(Jbi4EjbEndpoint.RUNNING);          
463             
464         } catch (final JBIException me) {
465         	String msg=MESSAGES.getString("EJB000127_Cannot_activate_endpoint", 
466         			new Object[] {endpoint.getServiceName()}, 
467         			new Object[] {me.getMessage()});
468             LOG.error(msg);
469             throw new Jbi4EjbDeployException(msg);
470         }        
471     }
472     
473     /**
474      * Activate the endpoint array.
475      * @param endpoint the endpoints to deactivate
476      * @throws Jbi4EjbDeployException if some deployment problem occurs
477      */
478     public void deactivateEndpoint(final Jbi4EjbEndpoint endpoint) throws Jbi4EjbDeployException {
479     	LOG.info("EJB000128_Deactivating_endpoint", new Object[]{endpoint.getUniqueName()});
480         
481 
482         if(!activatedEndpoints.contains(endpoint)) {
483         	LOG.error("EJB000129_Endpoint_not_active", new Object[] {endpoint.getUniqueName()});
484         } else  {
485             try {
486                 RuntimeHelper.getComponentContext().deactivateEndpoint(endpoint.getServiceEndpoint());                
487                 LOG.info("EJB000130_Endpoint_deactivated", new Object[]{endpoint.getServiceEndpoint()});
488                 endpoint.setState(Jbi4EjbEndpoint.STOPPED);                
489             } catch (JBIException me) {
490                 //String msg = "Cannot deactivate endpoint " + endpoint.getServiceName() +", reason: " + me.getMessage();
491                 //LOG.error(msg);
492                 //throw new Jbi4EjbDeployException(msg);
493             	String msg=MESSAGES.getString("EJB000131_Cannot_deactivate_endpoint", 
494             			new Object[] {endpoint.getServiceName()}, 
495             			new Object[] {me.getMessage()});
496                 LOG.error(msg);
497                 throw new Jbi4EjbDeployException(msg);   
498 	
499             }            
500         }           
501         
502    }    
503     
504 
505     /**
506      * Get all the WSDL file recursively in a directory.
507      * @param currentDir the directory where to search for the WSDLs
508      * @return the list of wsdl files
509      */
510     private List<File> listWSDLFiles(final File currentDir) {
511         final List<File> cumulativeResults = new ArrayList<File>();
512         final File[] filesInCurrentDir = currentDir.listFiles();
513 
514         for (File element : filesInCurrentDir) {
515 
516             if (element.isFile()) {
517 
518                 if (element.getName().toLowerCase().endsWith(".wsdl")) {
519                     cumulativeResults.add(element);
520                 }
521             } else if (element.isDirectory()) {
522                 final List<File> wsdlsInSubDirectories = listWSDLFiles(element);
523                 cumulativeResults.addAll(wsdlsInSubDirectories);
524             }
525         }
526         return cumulativeResults;
527     }
528 
529     /**
530      * Return all the files an definition in a <code>FileToDefinitionInfo</code>
531      * array.
532      *      
533      * @param dir the directory where the WSDLs are
534      * 
535      * @return the  <code>FileToDefinitionInfo</code> array
536      * 
537      * @throws DeploymentException if some problem occurs
538      */
539     FileToDefinitionInfo[] readAllDefinitions(final File dir)
540             throws DeploymentException {
541 
542         final List<File> wsdls = listWSDLFiles(dir);
543         final File[] wsdlFiles = (File[]) wsdls.toArray(new File[0]);
544 
545         // read all wsdl files to see if
546         FileToDefinitionInfo[] fileToDefs = null;
547 
548         if (wsdlFiles != null) {
549             fileToDefs = new FileToDefinitionInfo[wsdlFiles.length];
550 
551             for (int i = 0; i < wsdlFiles.length; i++) {
552                 Definition def;
553                 try {
554                     def = readWsdl(wsdlFiles[i]);
555                 } catch (WSDLException e) {
556                     // TODO i18n
557                     //LOG.error(e.getMessage());
558                     //throw new DeploymentException(e);
559                 	String msg=MESSAGES.getString("EJB000132_Error_in_reading_wsdl_file", new Object[]{e.getMessage()});
560                     LOG.error(msg,e);
561                     throw new DeploymentException(msg,e);   
562 
563                 }
564                 fileToDefs[i] = new FileToDefinitionInfo(wsdlFiles[i], def);
565             }
566         }
567 
568         return fileToDefs;
569     }
570     
571   
572 
573     /**
574      * Reads a <code>Definition</code> from a <code>File</code>.
575      * @param f the file to read
576      * @return the WSDL definition
577      * @throws javax.wsdl.WSDLException if there are problem in reading the WSDL
578      */
579     public static Definition readWsdl(final File f) throws WSDLException {
580         final WSDLFactory wsdlFactory = WSDLFactory.newInstance();
581         ExtensionRegistry registry = wsdlFactory
582         .newPopulatedExtensionRegistry();
583         final WSDLReader reader = ((WSDLFactoryImpl) wsdlFactory)
584         .newWSDLReader();
585         reader.setFeature(Constants.FEATURE_VERBOSE, false);
586         reader.setFeature(Constants.FEATURE_IMPORT_DOCUMENTS, true);
587         Jbi4EjbExtension.register(registry);
588         LOG.debug("Extension QName: " + Jbi4EjbExtension.NS_URI_JBI4EJB);
589         reader.setExtensionRegistry(registry);
590         final Definition def = reader.readWSDL(f.getAbsolutePath());
591         return def;
592     }    
593 
594 
595     /**
596      *  A value type for the file/definitions pairs.   
597      */
598     static class FileToDefinitionInfo {
599         
600         /** The file. */
601         private File mFile;
602 
603         /** The definition. */
604         private Definition mDefinition;
605 
606         /**
607          * Instantiates a new file to definition info.
608          * 
609          * @param file the file
610          * @param definition the definition
611          */
612         FileToDefinitionInfo(final File file, final Definition definition) {
613             mFile = file;
614             mDefinition = definition;
615         }
616 
617         /**
618          * Gets the file.
619          * 
620          * @return the file
621          */
622         public File getFile() {
623             return mFile;
624         }
625 
626         /**
627          * Gets the definition.
628          * 
629          * @return the definition
630          */
631         public Definition getDefinition() {
632             return mDefinition;
633         }
634     }
635 
636     /**
637      * Gets the life cycle.
638      * 
639      * @return the life cycle
640      */
641     public Jbi4EjbLifeCycle getLifeCycle() {
642         return lifeCycle;
643     }
644 
645     /**
646      * Sets the life cycle.
647      * 
648      * @param lifeCycle
649      *            the new life cycle
650      */
651     public void setLifeCycle(Jbi4EjbLifeCycle lifeCycle) {
652         this.lifeCycle = lifeCycle;
653     }
654 
655     /**
656      * Gets the deployed endpoints.
657      * 
658      * @return the deployed endpoints
659      */
660     public List<Jbi4EjbEndpoint> getDeployedEndpoints() {
661         return deployedEndpoints;
662     }
663     
664     
665 }