KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > deployment > DeploymentEngine


1 /*
2 * Copyright 2004,2005 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */

16
17 package org.apache.axis2.deployment;
18
19 import org.apache.axis2.context.ConfigurationContextFactory;
20 import org.apache.axis2.deployment.listener.RepositoryListenerImpl;
21 import org.apache.axis2.deployment.repository.util.ArchiveFileData;
22 import org.apache.axis2.deployment.repository.util.ArchiveReader;
23 import org.apache.axis2.deployment.repository.util.WSInfo;
24 import org.apache.axis2.deployment.scheduler.DeploymentIterator;
25 import org.apache.axis2.deployment.scheduler.Scheduler;
26 import org.apache.axis2.deployment.scheduler.SchedulerTask;
27 import org.apache.axis2.deployment.util.DeploymentData;
28 import org.apache.axis2.description.*;
29 import org.apache.axis2.engine.AxisConfiguration;
30 import org.apache.axis2.engine.AxisConfigurationImpl;
31 import org.apache.axis2.engine.AxisFault;
32 import org.apache.axis2.engine.Handler;
33 import org.apache.axis2.modules.Module;
34 import org.apache.axis2.phaseresolver.PhaseException;
35 import org.apache.axis2.phaseresolver.PhaseMetadata;
36 import org.apache.commons.logging.Log;
37 import org.apache.commons.logging.LogFactory;
38
39 import javax.xml.namespace.QName JavaDoc;
40 import javax.xml.stream.XMLStreamException;
41 import java.io.*;
42 import java.util.*;
43
44
45 public class DeploymentEngine implements DeploymentConstants {
46
47     private Log log = LogFactory.getLog(getClass());
48     private static Scheduler scheduler;
49
50     public static String JavaDoc axis2repository = null;
51
52
53     private boolean hotDeployment = true; //to do hot deployment or not
54
private boolean hotUpdate = true; // to do hot update or not
55

56
57     /**
58      * This will store all the web Services to deploy
59      */

60     private List wsToDeploy = new ArrayList();
61     /**
62      * this will store all the web Services to undeploy
63      */

64     private List wsToUnDeploy = new ArrayList();
65
66     /**
67      * to keep a ref to engine register
68      * this ref will pass to engine when it call start()
69      * method
70      */

71     private AxisConfiguration axisConfig;
72
73     /**
74      * this constaructor for the testing
75      */

76
77     private String JavaDoc folderName;
78
79     private String JavaDoc engineConfigName;
80
81     /**
82      * This to keep a referance to serverMetaData object
83      */

84     // private static ServerMetaData axisGlobal = new ServerMetaData();
85

86     private ArchiveFileData currentArchiveFile;
87
88     //tobuild chains
89
private ConfigurationContextFactory factory;
90
91     /**
92      * Default constructor is need to deploye module and service programatically
93      */

94     public DeploymentEngine() {
95     }
96
97     /**
98      * This the constructor which is used by Engine inorder to start
99      * Deploymenat module,
100      *
101      * @param RepositaryName is the path to which Repositary Listner should
102      * listent.
103      */

104
105     public DeploymentEngine(String JavaDoc RepositaryName) throws DeploymentException {
106         this(RepositaryName, "axis2.xml");
107     }
108
109     public DeploymentEngine(String JavaDoc RepositaryName, String JavaDoc serverXMLFile) throws DeploymentException {
110         if(RepositaryName == null || RepositaryName.trim().equals("")){
111             throw new DeploymentException("Axis2 repositary can not be null");
112         }
113         this.folderName = RepositaryName;
114         axis2repository = RepositaryName;
115         File repository = new File(RepositaryName);
116         if (!repository.exists()) {
117             repository.mkdirs();
118             File servcies = new File(repository, "services");
119             File modules = new File(repository, "modules");
120             modules.mkdirs();
121             servcies.mkdirs();
122         }
123         File serverConf = new File(repository, serverXMLFile);
124         if (!serverConf.exists()) {
125             ClassLoader JavaDoc cl = Thread.currentThread().getContextClassLoader();
126             InputStream in = cl.getResourceAsStream("org/apache/axis2/deployment/axis2.xml");
127             if (in != null) {
128                 try {
129                     serverConf.createNewFile();
130                     FileOutputStream out = new FileOutputStream(serverConf);
131                     int BUFSIZE = 512; // since only a test file going to load , the size has selected
132
byte[] buf = new byte[BUFSIZE];
133                     int read;
134                     while ((read = in.read(buf)) > 0) {
135                         out.write(buf, 0, read);
136                     }
137                     in.close();
138                     out.close();
139                 } catch (IOException e) {
140                     throw new DeploymentException(e);
141                 }
142
143
144             } else {
145                 throw new DeploymentException("can not found org/apache/axis2/deployment/axis2.xml");
146
147             }
148         }
149         factory = new ConfigurationContextFactory();
150         this.engineConfigName = RepositaryName + '/' + serverXMLFile;
151     }
152
153     public ArchiveFileData getCurrentFileItem() {
154         return currentArchiveFile;
155     }
156
157
158     /**
159      * tio get ER
160      *
161      * @return
162      */

163     public AxisConfiguration getAxisConfig() {
164         return axisConfig;
165     }
166
167     /**
168      * To set hotDeployment and hot update
169      */

170     private void setDeploymentFeatures() {
171         String JavaDoc value;
172         Parameter parahotdeployment = ((AxisConfigurationImpl) axisConfig).getParameter(HOTDEPLOYMENT);
173         Parameter parahotupdate = ((AxisConfigurationImpl) axisConfig).getParameter(HOTUPDATE);
174         if (parahotdeployment != null) {
175             value = (String JavaDoc) parahotdeployment.getValue();
176             if ("false".equals(value))
177                 hotDeployment = false;
178         }
179         if (parahotupdate != null) {
180             value = (String JavaDoc) parahotupdate.getValue();
181             if ("false".equals(value))
182                 hotUpdate = false;
183
184         }
185     }
186
187     public AxisConfiguration load() throws DeploymentException {
188         if (engineConfigName == null) {
189             throw new DeploymentException("path to axis2.xml can not be NUll");
190         }
191         File tempfile = new File(engineConfigName);
192         try {
193             InputStream in = new FileInputStream(tempfile);
194             axisConfig = createEngineConfig();
195             DeploymentParser parser = new DeploymentParser(in, this);
196             parser.processGlobalConfig(((AxisConfigurationImpl) axisConfig), AXIS2CONFIG);
197         } catch (FileNotFoundException e) {
198             throw new DeploymentException("Exception at deployment", e);
199         } catch (XMLStreamException e) {
200             throw new DeploymentException(e);
201         }
202         setDeploymentFeatures();
203         if (hotDeployment) {
204             startSearch(this);
205         } else {
206             new RepositoryListenerImpl(folderName, this);
207         }
208         try {
209             engagdeModules();
210             validateSystemPredefinedPhases();
211         } catch (AxisFault axisFault) {
212             log.info("Module validation failed" + axisFault.getMessage());
213             throw new DeploymentException(axisFault);
214         }
215         return axisConfig;
216     }
217
218
219     public AxisConfiguration loadClient(String JavaDoc clientHome) throws DeploymentException {
220         InputStream in = null;
221         axis2repository = clientHome;
222         boolean isRepositoryExist = false;
223         if (!(clientHome == null ||clientHome.trim().equals(""))) {
224             checkClientHome(clientHome);
225             isRepositoryExist = true;
226             try {
227                 File tempfile = new File(engineConfigName);
228                 in = new FileInputStream(tempfile);
229             } catch (FileNotFoundException e) {
230                 throw new DeploymentException("Exception at deployment", e);
231             }
232         } else {
233             ClassLoader JavaDoc cl = Thread.currentThread().getContextClassLoader();
234             in = cl.getResourceAsStream("org/apache/axis2/deployment/axis2.xml");
235         }
236         try {
237             axisConfig = createEngineConfig();
238             DeploymentParser parser = new DeploymentParser(in, this);
239             parser.processGlobalConfig(((AxisConfigurationImpl) axisConfig), AXIS2CONFIG);
240         } catch (XMLStreamException e) {
241             throw new DeploymentException(e);
242         }
243         if (isRepositoryExist) {
244             hotDeployment = false;
245             hotUpdate = false;
246             new RepositoryListenerImpl(folderName, this);
247             try {
248                 engagdeModules();
249             } catch (AxisFault axisFault) {
250                 log.info("Module validation failed" + axisFault.getMessage());
251                 throw new DeploymentException(axisFault);
252             }
253         }
254         return axisConfig;
255     }
256
257
258     private void checkClientHome(String JavaDoc clientHome) throws DeploymentException {
259         String JavaDoc clientXML = "axis2.xml";
260         this.folderName = clientHome;
261         File repository = new File(clientHome);
262         if (!repository.exists()) {
263             repository.mkdirs();
264             File servcies = new File(repository, "services");
265             File modules = new File(repository, "modules");
266             modules.mkdirs();
267             servcies.mkdirs();
268         }
269         File serverConf = new File(repository, clientXML);
270         if (!serverConf.exists()) {
271             ClassLoader JavaDoc cl = Thread.currentThread().getContextClassLoader();
272             InputStream in = cl.getResourceAsStream("org/apache/axis2/deployment/axis2.xml");
273             if (in != null) {
274                 try {
275                     serverConf.createNewFile();
276                     FileOutputStream out = new FileOutputStream(serverConf);
277                     int BUFSIZE = 512; // since only a test file going to load , the size has selected
278
byte[] buf = new byte[BUFSIZE];
279                     int read;
280                     while ((read = in.read(buf)) > 0) {
281                         out.write(buf, 0, read);
282                     }
283                     in.close();
284                     out.close();
285                 } catch (IOException e) {
286                     throw new DeploymentException(e);
287                 }
288
289
290             } else {
291                 throw new DeploymentException("can not found org/apache/axis2/deployment/axis2.xml");
292
293             }
294         }
295         factory = new ConfigurationContextFactory();
296         this.engineConfigName = clientHome + '/' + clientXML;
297     }
298
299     /**
300      * This methode used to check the modules referd by server.xml
301      * are exist , or they have deployed
302      */

303     private void engagdeModules() throws AxisFault {
304         ArrayList modules = DeploymentData.getInstance().getModules();
305         // PhaseResolver resolver = new PhaseResolver(axisConfig);
306
for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
307             QName JavaDoc name = (QName JavaDoc) iterator.next();
308             ((AxisConfigurationImpl) axisConfig).engageModule(name);
309         }
310     }
311
312     /**
313      * This method is to check wether some one has change the system pre defined phases for all the
314      * flows if some one has done so will throw a DeploymentException
315      *
316      * @throws DeploymentException
317      */

318     private void validateSystemPredefinedPhases() throws DeploymentException {
319         DeploymentData tempdata = DeploymentData.getInstance();
320         ArrayList inPhases = tempdata.getINPhases();
321         //TODO condition checking should be otherway since null value can occur
322
if (!(((String JavaDoc) inPhases.get(0)).equals(PhaseMetadata.PHASE_TRANSPORTIN) &&
323                 ((String JavaDoc) inPhases.get(1)).equals(PhaseMetadata.PHASE_PRE_DISPATCH) &&
324                 ((String JavaDoc) inPhases.get(2)).equals(PhaseMetadata.PHASE_DISPATCH) &&
325                 ((String JavaDoc) inPhases.get(3)).equals(PhaseMetadata.PHASE_POST_DISPATCH))) {
326             throw new DeploymentException("Invalid System predefined inphases , phase order dose not" +
327                     " support\n recheck axis2.xml");
328         }
329         // ArrayList outPhaes = tempdata.getOUTPhases();
330
//TODO do the validation code here
331
//ArrayList systemDefaultPhases =((AxisConfigurationImpl)axisConfig).getInPhasesUptoAndIncludingPostDispatch();
332
}
333
334     public ModuleDescription getModule(QName JavaDoc moduleName) throws AxisFault {
335         ModuleDescription axisModule = axisConfig.getModule(moduleName);
336         return axisModule;
337     }
338
339     /**
340      * this method use to start the Deployment engine
341      * inorder to perform Hot deployment and so on..
342      */

343     private void startSearch(DeploymentEngine engine) {
344         scheduler = new Scheduler();
345         scheduler.schedule(new SchedulerTask(engine, folderName), new DeploymentIterator());
346     }
347
348     private AxisConfiguration createEngineConfig() {
349         AxisConfiguration newEngineConfig = new AxisConfigurationImpl();
350         return newEngineConfig;
351     }
352
353
354     private void addnewService(ServiceDescription serviceMetaData) throws AxisFault {
355         try {
356             loadServiceProperties(serviceMetaData);
357             axisConfig.addService(serviceMetaData);
358
359             ArrayList list = currentArchiveFile.getModules();
360             for(int i = 0;i<list.size();i++){
361                 ModuleDescription module = axisConfig.getModule((QName JavaDoc)list.get(i));
362                 if (module != null) {
363                     serviceMetaData.engageModule(module);
364                 } else {
365                     throw new DeploymentException("Service " + serviceMetaData.getName().getLocalPart() +
366                             " Refer to invalide module " + ((QName JavaDoc)list.get(i)).getLocalPart());
367                 }
368             }
369
370             HashMap opeartions = serviceMetaData.getOperations();
371             Collection opCol = opeartions.values();
372             for (Iterator iterator = opCol.iterator(); iterator.hasNext();) {
373                 OperationDescription opDesc = (OperationDescription) iterator.next();
374                 ArrayList modules = opDesc.getModuleRefs();
375                 for (int i = 0; i < modules.size(); i++) {
376                     QName JavaDoc moduleName = (QName JavaDoc) modules.get(i);
377                     ModuleDescription module = axisConfig.getModule(moduleName);
378                     if(module != null) {
379                         opDesc.engageModule(module);
380                     } else {
381                         throw new DeploymentException("Operation " + opDesc.getName().getLocalPart() +
382                                 " Refer to invalide module " + moduleName.getLocalPart());
383                     }
384                 }
385
386             }
387             ///factory.createChains(serviceMetaData, axisConfig, );
388
System.out.println("service Description : " + serviceMetaData.getServiceDescription());
389             System.out.println("adding new service : " + serviceMetaData.getName().getLocalPart());
390         } catch (PhaseException e) {
391             throw new AxisFault(e);
392         }
393
394     }
395
396     /**
397      * This method is used to fill the axis service , it dose loading service class and also the provider class
398      * and it will also load the service handlers
399      *
400      * @param axisService
401      * @throws AxisFault
402      */

403     private void loadServiceProperties(ServiceDescription axisService) throws AxisFault {
404         Flow inflow = axisService.getInFlow();
405         if (inflow != null) {
406             addFlowHandlers(inflow);
407         }
408
409         Flow outFlow = axisService.getOutFlow();
410         if (outFlow != null) {
411             addFlowHandlers(outFlow);
412         }
413
414         Flow faultInFlow = axisService.getFaultInFlow();
415         if (faultInFlow != null) {
416             addFlowHandlers(faultInFlow);
417         }
418
419         Flow faultOutFlow = axisService.getFaultOutFlow();
420         if (faultOutFlow != null) {
421             addFlowHandlers(faultOutFlow);
422         }
423         axisService.setClassLoader(currentArchiveFile.getClassLoader());
424     }
425
426
427     private void loadModuleClass(ModuleDescription module) throws AxisFault {
428         Class JavaDoc moduleClass = null;
429         try {
430             String JavaDoc readInClass = currentArchiveFile.getModuleClass();
431             if (readInClass != null && !"".equals(readInClass)) {
432                 moduleClass = Class.forName(readInClass, true, currentArchiveFile.getClassLoader());
433                 module.setModule((Module) moduleClass.newInstance());
434             }
435         } catch (Exception JavaDoc e) {
436             throw new AxisFault(e.getMessage(), e);
437         }
438
439     }
440
441
442     private void addFlowHandlers(Flow flow) throws AxisFault {
443         int count = flow.getHandlerCount();
444         ClassLoader JavaDoc loader1 = currentArchiveFile.getClassLoader();
445         for (int j = 0; j < count; j++) {
446             HandlerDescription handlermd = flow.getHandler(j);
447             Class JavaDoc handlerClass = null;
448             Handler handler;
449             handlerClass = getHandlerClass(handlermd.getClassName(), loader1);
450             try {
451                 handler = (Handler) handlerClass.newInstance();
452                 handler.init(handlermd);
453                 handlermd.setHandler(handler);
454
455             } catch (InstantiationException JavaDoc e) {
456                 throw new AxisFault(e.getMessage());
457             } catch (IllegalAccessException JavaDoc e) {
458                 throw new AxisFault(e.getMessage());
459             }
460
461         }
462     }
463
464
465     public Class JavaDoc getHandlerClass(String JavaDoc className, ClassLoader JavaDoc loader1) throws AxisFault {
466         Class JavaDoc handlerClass = null;
467
468         try {
469             handlerClass = Class.forName(className, true, loader1);
470         } catch (ClassNotFoundException JavaDoc e) {
471             throw new AxisFault(e.getMessage());
472         }
473         return handlerClass;
474     }
475
476
477     private void addNewModule(ModuleDescription moduelmetada) throws AxisFault {
478         // currentArchiveFile.setClassLoader();
479
Flow inflow = moduelmetada.getInFlow();
480         if (inflow != null) {
481             addFlowHandlers(inflow);
482         }
483         Flow outFlow = moduelmetada.getOutFlow();
484         if (outFlow != null) {
485             addFlowHandlers(outFlow);
486         }
487         Flow faultInFlow = moduelmetada.getFaultInFlow();
488         if (faultInFlow != null) {
489             addFlowHandlers(faultInFlow);
490         }
491
492         Flow faultOutFlow = moduelmetada.getFaultOutFlow();
493         if (faultOutFlow != null) {
494             addFlowHandlers(faultOutFlow);
495         }
496         loadModuleClass(moduelmetada);
497         axisConfig.addMdoule(moduelmetada);
498         System.out.println("adding new module");
499     }
500
501
502     /**
503      * @param file
504      */

505     public void addtowsToDeploy(ArchiveFileData file) {
506         wsToDeploy.add(file);
507     }
508
509     /**
510      * @param file
511      */

512     public void addtowstoUnDeploy(WSInfo file) {
513         wsToUnDeploy.add(file);
514     }
515
516     public void doDeploy() {
517         if (wsToDeploy.size() > 0) {
518             for (int i = 0; i < wsToDeploy.size(); i++) {
519                 currentArchiveFile = (ArchiveFileData) wsToDeploy.get(i);
520                 int type = currentArchiveFile.getType();
521                 try {
522                     currentArchiveFile.setClassLoader();
523                 } catch (AxisFault axisFault) {
524                     log.info("Setting Class Loader " +axisFault);
525                     continue;
526                 }
527                 ArchiveReader archiveReader = new ArchiveReader();
528                 String JavaDoc serviceStatus = "";
529                 StringWriter errorWriter= new StringWriter();
530                 switch (type) {
531                     case SERVICE:
532                         try {
533                            // ServiceDescription service = archiveReader.createService(currentArchiveFile.getAbsolutePath());
534
ServiceDescription service = archiveReader.createService(currentArchiveFile);
535                             archiveReader.readServiceArchive(currentArchiveFile.getAbsolutePath(), this, service);
536                             addnewService(service);
537                             log.info("Deployement WS Name " + currentArchiveFile.getName());
538                         } catch (DeploymentException de) {
539                             log.info("Invalid service" + currentArchiveFile.getName());
540                             log.info("DeploymentException " + de);
541                             PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
542                             de.printStackTrace(error_ptintWriter);
543                             serviceStatus = "Error:\n" + errorWriter.toString();
544                         } catch (AxisFault axisFault) {
545                             log.info("Invalid service" + currentArchiveFile.getName());
546                             log.info("AxisFault " + axisFault);
547                             PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
548                             axisFault.printStackTrace(error_ptintWriter);
549                             serviceStatus = "Error:\n" + errorWriter.toString();
550                         } catch (Exception JavaDoc e) {
551                             log.info("Invalid service" + currentArchiveFile.getName());
552                             log.info("Exception " + e);
553                             PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
554                             e.printStackTrace(error_ptintWriter);
555                             serviceStatus = "Error:\n" + errorWriter.toString();
556                         } finally {
557                             if (serviceStatus.startsWith("Error:")) {
558                                 axisConfig.getFaulytServices().put(getAxisServiceName(currentArchiveFile.getName()), serviceStatus);
559                             }
560                             currentArchiveFile = null;
561                         }
562                         break;
563                     case MODULE:
564                         String JavaDoc moduleStatus = "";
565                         try {
566                             ModuleDescription metaData = new ModuleDescription();
567                             archiveReader.readModuleArchive(currentArchiveFile.getAbsolutePath(), this, metaData);
568                             addNewModule(metaData);
569                             log.info("Moduel WS Name " + currentArchiveFile.getName() + " modulename :" + metaData.getName());
570                         } catch (DeploymentException e) {
571                             log.info("Invalid module" + currentArchiveFile.getName());
572                             log.info("DeploymentException " + e);
573                             PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
574                             e.printStackTrace(error_ptintWriter);
575                             moduleStatus = "Error:\n" + errorWriter.toString();
576                         } catch (AxisFault axisFault) {
577                             log.info("Invalid module" + currentArchiveFile.getName());
578                             log.info("AxisFault " + axisFault);
579                             PrintWriter error_ptintWriter = new PrintWriter(errorWriter);
580                             axisFault.printStackTrace(error_ptintWriter);
581                             moduleStatus = "Error:\n" + errorWriter.toString();
582                         } finally {
583                             if (moduleStatus.startsWith("Error:")) {
584                                 axisConfig.getFaulytModules().put(getAxisServiceName(currentArchiveFile.getName()), moduleStatus);
585                             }
586                             currentArchiveFile = null;
587                         }
588                         break;
589
590                 }
591             }
592         }
593         wsToDeploy.clear();
594     }
595
596     public void unDeploy() {
597         String JavaDoc serviceName = "";
598         try {
599             if (wsToUnDeploy.size() > 0) {
600                 for (int i = 0; i < wsToUnDeploy.size(); i++) {
601                     WSInfo wsInfo = (WSInfo) wsToUnDeploy.get(i);
602                     if (wsInfo.getType() == SERVICE) {
603                         serviceName = getAxisServiceName(wsInfo.getFilename());
604                         axisConfig.removeService(new QName JavaDoc(serviceName));
605                         log.info("UnDeployement WS Name " + wsInfo.getFilename());
606                     }
607                     axisConfig.getFaulytServices().remove(serviceName);
608                 }
609
610             }
611         } catch (AxisFault e) {
612             log.info("AxisFault " + e);
613         }
614         wsToUnDeploy.clear();
615     }
616
617     public boolean isHotUpdate() {
618         return hotUpdate;
619     }
620
621     /**
622      * This method is used to retrive service name form the arechive file name
623      * if the archive file name is service1.aar , then axis service name would be service1
624      *
625      * @param fileName
626      * @return
627      */

628     private String JavaDoc getAxisServiceName(String JavaDoc fileName) {
629         char seperator = '.';
630         String JavaDoc value = null;
631         int index = fileName.indexOf(seperator);
632         if (index > 0) {
633             value = fileName.substring(0, index);
634             return value;
635         }
636         return fileName;
637     }
638
639     /* public ServiceDescription deployService(ClassLoader classLoder, InputStream serviceStream, String servieName) throws DeploymentException {
640     ServiceDescription service = null;
641     try {
642     currentArchiveFileile = new ArchiveFileData(SERVICE, servieName);
643     currentArchiveFileile.setClassLoader(classLoder);
644     service = new ServiceDescription();
645     DeploymentParser schme = new DeploymentParser(serviceStream, this);
646     schme.parseServiceXML(service);
647     service = loadServiceProperties(service);
648     } catch (XMLStreamException e) {
649     throw new DeploymentException(e.getMessage());
650     } catch (PhaseException e) {
651     throw new DeploymentException(e.getMessage());
652     } catch (AxisFault axisFault) {
653     throw new DeploymentException(axisFault.getMessage());
654     }
655     return service;
656     }
657 */

658
659     /**
660      * This method is used to fill a axisservice object using service.xml , first it should create
661      * an axisservice object using WSDL and then fill that using given servic.xml and load all the requed
662      * class and build the chains , finally add the servicecontext to EngineContext and axisservice into
663      * EngineConfiguration
664      *
665      * @param axisService
666      * @param serviceInputStream
667      * @param classLoader
668      * @return
669      * @throws DeploymentException
670      */

671     public ServiceDescription buildService(ServiceDescription axisService, InputStream serviceInputStream, ClassLoader JavaDoc classLoader) throws DeploymentException {
672         try {
673             currentArchiveFile = new ArchiveFileData(SERVICE, "");
674             currentArchiveFile.setClassLoader(classLoader);
675             DeploymentParser schme = new DeploymentParser(serviceInputStream, this);
676             schme.parseServiceXML(axisService);
677             loadServiceProperties(axisService);
678             axisConfig.addService(axisService);
679         } catch (XMLStreamException e) {
680             throw new DeploymentException(e);
681         } catch (AxisFault axisFault) {
682             throw new DeploymentException(axisFault);
683         }
684         return axisService;
685     }
686
687     /**
688      * This method can be used to build ModuleDescription for a given module archiev file
689      *
690      * @param modulearchive
691      * @return
692      * @throws DeploymentException
693      */

694
695     public ModuleDescription buildModule(File modulearchive) throws DeploymentException {
696         ModuleDescription axismodule = null;
697         try {
698             currentArchiveFile = new ArchiveFileData(modulearchive, MODULE);
699             axismodule = new ModuleDescription();
700             ArchiveReader archiveReader = new ArchiveReader();
701             archiveReader.readModuleArchive(currentArchiveFile.getAbsolutePath(), this, axismodule);
702             currentArchiveFile.setClassLoader();
703             Flow inflow = axismodule.getInFlow();
704             if (inflow != null) {
705                 addFlowHandlers(inflow);
706             }
707             Flow outFlow = axismodule.getOutFlow();
708             if (outFlow != null) {
709                 addFlowHandlers(outFlow);
710             }
711             Flow faultInFlow = axismodule.getFaultInFlow();
712             if (faultInFlow != null) {
713                 addFlowHandlers(faultInFlow);
714             }
715             Flow faultOutFlow = axismodule.getFaultOutFlow();
716             if (faultOutFlow != null) {
717                 addFlowHandlers(faultOutFlow);
718             }
719             loadModuleClass(axismodule);
720         } catch (AxisFault axisFault) {
721             throw new DeploymentException(axisFault);
722         }
723         return axismodule;
724     }
725
726 }
727
Popular Tags