Source Code Cross Referenced for DeploymentEngine.java in  » Web-Services-AXIS2 » kernal » org » apache » axis2 » deployment » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services AXIS2 » kernal » org.apache.axis2.deployment 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Licensed to the Apache Software Foundation (ASF) under one
0003:         * or more contributor license agreements. See the NOTICE file
0004:         * distributed with this work for additional information
0005:         * regarding copyright ownership. The ASF licenses this file
0006:         * to you under the Apache License, Version 2.0 (the
0007:         * "License"); you may not use this file except in compliance
0008:         * with the License. You may obtain a copy of the License at
0009:         *
0010:         * http://www.apache.org/licenses/LICENSE-2.0
0011:         *
0012:         * Unless required by applicable law or agreed to in writing,
0013:         * software distributed under the License is distributed on an
0014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0015:         * KIND, either express or implied. See the License for the
0016:         * specific language governing permissions and limitations
0017:         * under the License.
0018:         */
0019:
0020:        package org.apache.axis2.deployment;
0021:
0022:        import org.apache.axiom.om.OMElement;
0023:        import org.apache.axis2.AxisFault;
0024:        import org.apache.axis2.Constants;
0025:        import org.apache.axis2.context.ConfigurationContext;
0026:        import org.apache.axis2.deployment.repository.util.ArchiveReader;
0027:        import org.apache.axis2.deployment.repository.util.DeploymentFileData;
0028:        import org.apache.axis2.deployment.repository.util.WSInfo;
0029:        import org.apache.axis2.deployment.scheduler.DeploymentIterator;
0030:        import org.apache.axis2.deployment.scheduler.Scheduler;
0031:        import org.apache.axis2.deployment.scheduler.SchedulerTask;
0032:        import org.apache.axis2.deployment.util.Utils;
0033:        import org.apache.axis2.deployment.resolver.AARBasedWSDLLocator;
0034:        import org.apache.axis2.deployment.resolver.AARFileBasedURIResolver;
0035:        import org.apache.axis2.description.*;
0036:        import org.apache.axis2.engine.AxisConfiguration;
0037:        import org.apache.axis2.engine.MessageReceiver;
0038:        import org.apache.axis2.i18n.Messages;
0039:        import org.apache.axis2.util.JavaUtils;
0040:        import org.apache.commons.logging.Log;
0041:        import org.apache.commons.logging.LogFactory;
0042:
0043:        import javax.xml.namespace.QName;
0044:        import javax.xml.stream.XMLStreamException;
0045:        import java.io.*;
0046:        import java.net.MalformedURLException;
0047:        import java.net.URL;
0048:        import java.util.ArrayList;
0049:        import java.util.HashMap;
0050:        import java.util.Iterator;
0051:        import java.util.List;
0052:        import java.util.zip.ZipEntry;
0053:        import java.util.zip.ZipInputStream;
0054:
0055:        public abstract class DeploymentEngine implements  DeploymentConstants {
0056:            private static final Log log = LogFactory
0057:                    .getLog(DeploymentEngine.class);
0058:
0059:            //to keep the web resource location if any
0060:            protected static String webLocationString = null;
0061:            protected Scheduler scheduler;
0062:
0063:            public static void setWebLocationString(String webLocationString) {
0064:                DeploymentEngine.webLocationString = webLocationString;
0065:            }
0066:
0067:            /**
0068:             * Support for hot update is controlled by this flag
0069:             */
0070:            protected boolean hotUpdate = true;
0071:
0072:            /**
0073:             * Support for hot deployment is controlled by this flag
0074:             */
0075:            protected boolean hotDeployment = true;
0076:
0077:            /**
0078:             * Stores all the web Services to deploy.
0079:             */
0080:            protected List wsToDeploy = new ArrayList();
0081:
0082:            /**
0083:             * Stores all the web Services to undeploy.
0084:             */
0085:            protected List wsToUnDeploy = new ArrayList();
0086:
0087:            /**
0088:             * to keep a ref to engine register
0089:             * this ref will pass to engine when it call start()
0090:             * method
0091:             */
0092:            protected AxisConfiguration axisConfig;
0093:
0094:            protected ConfigurationContext configContext;
0095:
0096:            protected RepositoryListener repoListener;
0097:
0098:            protected String servicesPath = null;
0099:            protected File servicesDir = null;
0100:            protected String modulesPath = null;
0101:            protected File modulesDir = null;
0102:            private File repositoryDir = null;
0103:
0104:            //to deploy service (both aar and expanded)
0105:            protected ServiceDeployer serviceDeployer;
0106:            //To deploy modules (both mar and expanded)
0107:            protected ModuleDeployer moduleDeployer;
0108:
0109:            //To keep the mapping that which directory will contain which type ,
0110:            // for exmaple directory services will contains .aar
0111:            private HashMap directoryToExtensionMappingMap = new HashMap();
0112:            //to keep map of which deployer can process which file extension ,
0113:            // for example ServiceDeployer will process .aar file
0114:            private HashMap extensionToDeployerMappingMap = new HashMap();
0115:
0116:            public void loadServices() {
0117:                repoListener.checkServices();
0118:                if (hotDeployment) {
0119:                    startSearch(repoListener);
0120:                }
0121:            }
0122:
0123:            public void loadRepository(String repoDir)
0124:                    throws DeploymentException {
0125:                File axisRepo = new File(repoDir);
0126:                if (!axisRepo.exists()) {
0127:                    throw new DeploymentException(Messages.getMessage(
0128:                            "cannotfindrepo", repoDir));
0129:                }
0130:                setDeploymentFeatures();
0131:                prepareRepository(repoDir);
0132:                // setting the CLs
0133:                setClassLoaders(repoDir);
0134:                repoListener = new RepositoryListener(this , false);
0135:                org.apache.axis2.util.Utils.calculateDefaultModuleVersion(
0136:                        axisConfig.getModules(), axisConfig);
0137:                try {
0138:                    try {
0139:                        axisConfig.setRepository(axisRepo.toURL());
0140:                    } catch (MalformedURLException e) {
0141:                        log.info(e.getMessage());
0142:                    }
0143:                    axisConfig.validateSystemPredefinedPhases();
0144:                } catch (AxisFault axisFault) {
0145:                    throw new DeploymentException(axisFault);
0146:                }
0147:            }
0148:
0149:            public void loadFromClassPath() throws DeploymentException {
0150:                //loading modules from the classpath
0151:                new RepositoryListener(this , true);
0152:                org.apache.axis2.util.Utils.calculateDefaultModuleVersion(
0153:                        axisConfig.getModules(), axisConfig);
0154:                axisConfig.validateSystemPredefinedPhases();
0155:                try {
0156:                    engageModules();
0157:                } catch (AxisFault axisFault) {
0158:                    log.info(Messages.getMessage(
0159:                            DeploymentErrorMsgs.MODULE_VALIDATION_FAILED,
0160:                            axisFault.getMessage()));
0161:                    throw new DeploymentException(axisFault);
0162:                }
0163:            }
0164:
0165:            public void loadServicesFromUrl(URL repoURL) {
0166:                try {
0167:                    String path = servicesPath == null ? DeploymentConstants.SERVICE_PATH
0168:                            : servicesPath;
0169:                    if (!path.endsWith("/")) {
0170:                        path += "/";
0171:                    }
0172:                    String repoPath = repoURL.getPath();
0173:                    if (!repoPath.endsWith("/")) {
0174:                        repoPath += "/";
0175:                        repoURL = new URL(repoURL.getProtocol() + "://"
0176:                                + repoPath);
0177:                    }
0178:                    URL servicesDir = new URL(repoURL, path);
0179:                    URL filelisturl = new URL(servicesDir, "services.list");
0180:                    ArrayList files = getFileList(filelisturl);
0181:
0182:                    for (Iterator fileIterator = files.iterator(); fileIterator
0183:                            .hasNext();) {
0184:                        String fileUrl = (String) fileIterator.next();
0185:                        if (fileUrl.endsWith(".aar")) {
0186:                            AxisServiceGroup serviceGroup = new AxisServiceGroup();
0187:                            URL servicesURL = new URL(servicesDir, fileUrl);
0188:                            ArrayList servicelist = populateService(
0189:                                    serviceGroup, servicesURL, fileUrl
0190:                                            .substring(0, fileUrl
0191:                                                    .indexOf(".aar")));
0192:                            addServiceGroup(serviceGroup, servicelist,
0193:                                    servicesURL, null, axisConfig);
0194:                            log.info(Messages.getMessage(
0195:                                    DeploymentErrorMsgs.DEPLOYING_WS,
0196:                                    org.apache.axis2.util.Utils
0197:                                            .getModuleName(serviceGroup
0198:                                                    .getServiceGroupName())));
0199:                        }
0200:                    }
0201:                } catch (MalformedURLException e) {
0202:                    log.error(e.getMessage(), e);
0203:                } catch (IOException e) {
0204:                    log.error(e.getMessage(), e);
0205:                }
0206:            }
0207:
0208:            public void loadRepositoryFromURL(URL repoURL)
0209:                    throws DeploymentException {
0210:                try {
0211:                    String path = modulesPath == null ? DeploymentConstants.MODULE_PATH
0212:                            : modulesPath;
0213:                    if (!path.endsWith("/")) {
0214:                        path = path + "/";
0215:                    }
0216:                    String repoPath = repoURL.getPath();
0217:                    if (!repoPath.endsWith("/")) {
0218:                        repoPath += "/";
0219:                        repoURL = new URL(repoURL.getProtocol() + "://"
0220:                                + repoPath);
0221:                    }
0222:                    URL moduleDir = new URL(repoURL, path);
0223:                    URL filelisturl = new URL(moduleDir, "modules.list");
0224:                    ArrayList files = getFileList(filelisturl);
0225:                    Iterator fileIterator = files.iterator();
0226:                    while (fileIterator.hasNext()) {
0227:                        String fileUrl = (String) fileIterator.next();
0228:                        if (fileUrl.endsWith(".mar")) {
0229:                            URL moduleurl = new URL(moduleDir, fileUrl);
0230:                            ClassLoader deploymentClassLoader = Utils
0231:                                    .createClassLoader(
0232:                                            new URL[] { moduleurl },
0233:                                            axisConfig.getModuleClassLoader(),
0234:                                            true,
0235:                                            (File) axisConfig
0236:                                                    .getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR));
0237:                            AxisModule module = new AxisModule();
0238:                            module.setModuleClassLoader(deploymentClassLoader);
0239:                            module.setParent(axisConfig);
0240:                            String moduleFile = fileUrl.substring(0, fileUrl
0241:                                    .indexOf(".mar"));
0242:                            if (module.getName() == null) {
0243:                                module.setName(org.apache.axis2.util.Utils
0244:                                        .getModuleName(moduleFile));
0245:                                module.setVersion(org.apache.axis2.util.Utils
0246:                                        .getModuleVersion(moduleFile));
0247:                            }
0248:                            populateModule(module, moduleurl);
0249:                            module.setFileName(moduleurl);
0250:                            addNewModule(module, axisConfig);
0251:                            log.info(Messages.getMessage(
0252:                                    DeploymentErrorMsgs.DEPLOYING_MODULE,
0253:                                    org.apache.axis2.util.Utils.getModuleName(
0254:                                            module.getName(), module
0255:                                                    .getVersion())));
0256:                        }
0257:                    }
0258:                    org.apache.axis2.util.Utils.calculateDefaultModuleVersion(
0259:                            axisConfig.getModules(), axisConfig);
0260:                    axisConfig.validateSystemPredefinedPhases();
0261:                } catch (MalformedURLException e) {
0262:                    throw new DeploymentException(e);
0263:                } catch (IOException e) {
0264:                    throw new DeploymentException(e);
0265:                }
0266:            }
0267:
0268:            private void populateModule(AxisModule module, URL moduleUrl)
0269:                    throws DeploymentException {
0270:                try {
0271:                    ClassLoader classLoader = module.getModuleClassLoader();
0272:                    InputStream moduleStream = classLoader
0273:                            .getResourceAsStream("META-INF/module.xml");
0274:                    if (moduleStream == null) {
0275:                        moduleStream = classLoader
0276:                                .getResourceAsStream("meta-inf/module.xml");
0277:                    }
0278:                    if (moduleStream == null) {
0279:                        throw new DeploymentException(Messages.getMessage(
0280:                                DeploymentErrorMsgs.MODULE_XML_MISSING,
0281:                                moduleUrl.toString()));
0282:                    }
0283:                    ModuleBuilder moduleBuilder = new ModuleBuilder(
0284:                            moduleStream, module, axisConfig);
0285:                    moduleBuilder.populateModule();
0286:                } catch (IOException e) {
0287:                    throw new DeploymentException(e);
0288:                }
0289:            }
0290:
0291:            protected ArrayList populateService(AxisServiceGroup serviceGroup,
0292:                    URL servicesURL, String serviceName)
0293:                    throws DeploymentException {
0294:                try {
0295:                    serviceGroup.setServiceGroupName(serviceName);
0296:                    ClassLoader serviceClassLoader = Utils
0297:                            .createClassLoader(
0298:                                    new URL[] { servicesURL },
0299:                                    axisConfig.getServiceClassLoader(),
0300:                                    true,
0301:                                    (File) axisConfig
0302:                                            .getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR));
0303:                    String metainf = "meta-inf";
0304:                    serviceGroup.setServiceGroupClassLoader(serviceClassLoader);
0305:                    //processing wsdl.list
0306:                    InputStream wsdlfilesStream = serviceClassLoader
0307:                            .getResourceAsStream("meta-inf/wsdl.list");
0308:                    if (wsdlfilesStream == null) {
0309:                        wsdlfilesStream = serviceClassLoader
0310:                                .getResourceAsStream("META-INF/wsdl.list");
0311:                        if (wsdlfilesStream != null) {
0312:                            metainf = "META-INF";
0313:                        }
0314:                    }
0315:                    HashMap servicesMap = new HashMap();
0316:                    if (wsdlfilesStream != null) {
0317:                        ArchiveReader reader = new ArchiveReader();
0318:                        BufferedReader input = new BufferedReader(
0319:                                new InputStreamReader(wsdlfilesStream));
0320:                        String line;
0321:                        while ((line = input.readLine()) != null) {
0322:                            line = line.trim();
0323:                            if (line.length() > 0 && line.charAt(0) != '#') {
0324:                                line = metainf + "/" + line;
0325:                                try {
0326:                                    List services = reader
0327:                                            .getAxisServiceFromWsdl(
0328:                                                    serviceClassLoader
0329:                                                            .getResourceAsStream(line),
0330:                                                    serviceClassLoader, line);
0331:                                    if (services != null) {
0332:                                        for (int i = 0; i < services.size(); i++) {
0333:                                            AxisService axisService = (AxisService) services
0334:                                                    .get(i);
0335:                                            servicesMap.put(axisService
0336:                                                    .getName(), axisService);
0337:                                        }
0338:                                    }
0339:
0340:                                } catch (Exception e) {
0341:                                    throw new DeploymentException(e);
0342:                                }
0343:                            }
0344:                        }
0345:                    }
0346:                    InputStream servicexmlStream = serviceClassLoader
0347:                            .getResourceAsStream("META-INF/services.xml");
0348:                    if (servicexmlStream == null) {
0349:                        servicexmlStream = serviceClassLoader
0350:                                .getResourceAsStream("meta-inf/services.xml");
0351:                    } else {
0352:                        metainf = "META-INF";
0353:                    }
0354:                    if (servicexmlStream == null) {
0355:                        throw new DeploymentException(Messages.getMessage(
0356:                                DeploymentErrorMsgs.SERVICE_XML_NOT_FOUND,
0357:                                servicesURL.toString()));
0358:                    }
0359:                    DescriptionBuilder builder = new DescriptionBuilder(
0360:                            servicexmlStream, configContext);
0361:                    OMElement rootElement = builder.buildOM();
0362:                    String elementName = rootElement.getLocalName();
0363:
0364:                    if (TAG_SERVICE.equals(elementName)) {
0365:                        AxisService axisService = null;
0366:                        String wsdlLocation = "META-INF/service.wsdl";
0367:                        InputStream wsdlStream = serviceClassLoader
0368:                                .getResourceAsStream(wsdlLocation);
0369:                        if (wsdlStream == null) {
0370:                            wsdlLocation = "META-INF/" + serviceName + ".wsdl";
0371:                            wsdlStream = serviceClassLoader
0372:                                    .getResourceAsStream(wsdlLocation);
0373:                        }
0374:                        if (wsdlStream != null) {
0375:                            WSDL11ToAxisServiceBuilder wsdl2AxisServiceBuilder = new WSDL11ToAxisServiceBuilder(
0376:                                    wsdlStream, null, null);
0377:                            File file = Utils.toFile(servicesURL);
0378:                            if (file != null && file.exists()) {
0379:                                wsdl2AxisServiceBuilder
0380:                                        .setCustomWSLD4JResolver(new AARBasedWSDLLocator(
0381:                                                wsdlLocation, file, wsdlStream));
0382:                                wsdl2AxisServiceBuilder
0383:                                        .setCustomResolver(new AARFileBasedURIResolver(
0384:                                                file));
0385:                            }
0386:                            axisService = wsdl2AxisServiceBuilder
0387:                                    .populateService();
0388:                            axisService.setWsdlFound(true);
0389:                            axisService.setCustomWsdl(true);
0390:                            axisService.setName(serviceName);
0391:                        }
0392:                        if (axisService == null) {
0393:                            axisService = new AxisService(serviceName);
0394:                        }
0395:
0396:                        axisService.setParent(serviceGroup);
0397:                        axisService.setClassLoader(serviceClassLoader);
0398:
0399:                        ServiceBuilder serviceBuilder = new ServiceBuilder(
0400:                                configContext, axisService);
0401:                        AxisService service = serviceBuilder
0402:                                .populateService(rootElement);
0403:
0404:                        ArrayList serviceList = new ArrayList();
0405:                        serviceList.add(service);
0406:                        return serviceList;
0407:                    } else if (TAG_SERVICE_GROUP.equals(elementName)) {
0408:                        ServiceGroupBuilder groupBuilder = new ServiceGroupBuilder(
0409:                                rootElement, servicesMap, configContext);
0410:                        ArrayList servicList = groupBuilder
0411:                                .populateServiceGroup(serviceGroup);
0412:                        Iterator serviceIterator = servicList.iterator();
0413:                        while (serviceIterator.hasNext()) {
0414:                            AxisService axisService = (AxisService) serviceIterator
0415:                                    .next();
0416:                            String wsdlLocation = "META-INF/service.wsdl";
0417:                            InputStream wsdlStream = serviceClassLoader
0418:                                    .getResourceAsStream(wsdlLocation);
0419:                            if (wsdlStream == null) {
0420:                                wsdlLocation = "META-INF/" + serviceName
0421:                                        + ".wsdl";
0422:                                wsdlStream = serviceClassLoader
0423:                                        .getResourceAsStream(wsdlLocation);
0424:                            }
0425:                            if (wsdlStream != null) {
0426:                                WSDL11ToAxisServiceBuilder wsdl2AxisServiceBuilder = new WSDL11ToAxisServiceBuilder(
0427:                                        wsdlStream, axisService);
0428:                                File file = Utils.toFile(servicesURL);
0429:                                if (file != null && file.exists()) {
0430:                                    wsdl2AxisServiceBuilder
0431:                                            .setCustomWSLD4JResolver(new AARBasedWSDLLocator(
0432:                                                    wsdlLocation, file,
0433:                                                    wsdlStream));
0434:                                    wsdl2AxisServiceBuilder
0435:                                            .setCustomResolver(new AARFileBasedURIResolver(
0436:                                                    file));
0437:                                }
0438:                                axisService = wsdl2AxisServiceBuilder
0439:                                        .populateService();
0440:                                axisService.setWsdlFound(true);
0441:                                axisService.setCustomWsdl(true);
0442:                                // Set the default message receiver for the operations that were
0443:                                // not listed in the services.xml
0444:                                Iterator operations = axisService
0445:                                        .getOperations();
0446:                                while (operations.hasNext()) {
0447:                                    AxisOperation operation = (AxisOperation) operations
0448:                                            .next();
0449:                                    if (operation.getMessageReceiver() == null) {
0450:                                        operation
0451:                                                .setMessageReceiver(loadDefaultMessageReceiver(
0452:                                                        operation
0453:                                                                .getMessageExchangePattern(),
0454:                                                        axisService));
0455:                                    }
0456:                                }
0457:                            }
0458:                        }
0459:                        return servicList;
0460:                    }
0461:                } catch (IOException e) {
0462:                    throw new DeploymentException(e);
0463:                } catch (XMLStreamException e) {
0464:                    throw new DeploymentException(e);
0465:                }
0466:                return null;
0467:            }
0468:
0469:            protected MessageReceiver loadDefaultMessageReceiver(String mepURL,
0470:                    AxisService service) {
0471:                MessageReceiver messageReceiver;
0472:                if (mepURL == null) {
0473:                    mepURL = WSDL2Constants.MEP_URI_IN_OUT;
0474:                }
0475:                if (service != null) {
0476:                    messageReceiver = service.getMessageReceiver(mepURL);
0477:                    if (messageReceiver != null) {
0478:                        return messageReceiver;
0479:                    }
0480:                }
0481:                return axisConfig.getMessageReceiver(mepURL);
0482:            }
0483:
0484:            public static void addNewModule(AxisModule modulemetadata,
0485:                    AxisConfiguration axisConfiguration) throws AxisFault {
0486:
0487:                Flow inflow = modulemetadata.getInFlow();
0488:                ClassLoader moduleClassLoader = modulemetadata
0489:                        .getModuleClassLoader();
0490:
0491:                if (inflow != null) {
0492:                    Utils.addFlowHandlers(inflow, moduleClassLoader);
0493:                }
0494:
0495:                Flow outFlow = modulemetadata.getOutFlow();
0496:
0497:                if (outFlow != null) {
0498:                    Utils.addFlowHandlers(outFlow, moduleClassLoader);
0499:                }
0500:
0501:                Flow faultInFlow = modulemetadata.getFaultInFlow();
0502:
0503:                if (faultInFlow != null) {
0504:                    Utils.addFlowHandlers(faultInFlow, moduleClassLoader);
0505:                }
0506:
0507:                Flow faultOutFlow = modulemetadata.getFaultOutFlow();
0508:
0509:                if (faultOutFlow != null) {
0510:                    Utils.addFlowHandlers(faultOutFlow, moduleClassLoader);
0511:                }
0512:
0513:                axisConfiguration.addModule(modulemetadata);
0514:                log.debug(Messages
0515:                        .getMessage(DeploymentErrorMsgs.ADDING_NEW_MODULE));
0516:            }
0517:
0518:            public static void addServiceGroup(AxisServiceGroup serviceGroup,
0519:                    ArrayList serviceList, URL serviceLocation,
0520:                    DeploymentFileData currentDeploymentFile,
0521:                    AxisConfiguration axisConfiguration) throws AxisFault {
0522:                fillServiceGroup(serviceGroup, serviceList, serviceLocation,
0523:                        axisConfiguration);
0524:                axisConfiguration.addServiceGroup(serviceGroup);
0525:                if (currentDeploymentFile != null) {
0526:                    addAsWebResources(currentDeploymentFile.getFile(),
0527:                            serviceGroup.getServiceGroupName(), serviceGroup);
0528:                }
0529:            }
0530:
0531:            protected static void fillServiceGroup(
0532:                    AxisServiceGroup serviceGroup, ArrayList serviceList,
0533:                    URL serviceLocation, AxisConfiguration axisConfig)
0534:                    throws AxisFault {
0535:                //        serviceGroup.setParent(axisConfig);
0536:                // module from services.xml at serviceGroup level
0537:                ArrayList groupModules = serviceGroup.getModuleRefs();
0538:                serviceGroup.setParent(axisConfig);
0539:                for (int i = 0; i < groupModules.size(); i++) {
0540:                    String moduleName = (String) groupModules.get(i);
0541:                    AxisModule module = axisConfig.getModule(moduleName);
0542:
0543:                    if (module != null) {
0544:                        serviceGroup.engageModule(axisConfig
0545:                                .getModule(moduleName));
0546:                    } else {
0547:                        throw new DeploymentException(Messages.getMessage(
0548:                                DeploymentErrorMsgs.BAD_MODULE_FROM_SERVICE,
0549:                                serviceGroup.getServiceGroupName(), moduleName));
0550:                    }
0551:                }
0552:
0553:                Iterator services = serviceList.iterator();
0554:
0555:                while (services.hasNext()) {
0556:                    AxisService axisService = (AxisService) services.next();
0557:                    axisService.setUseDefaultChains(false);
0558:
0559:                    axisService.setFileName(serviceLocation);
0560:                    serviceGroup.addService(axisService);
0561:
0562:                    // modules from <service>
0563:                    ArrayList list = axisService.getModules();
0564:
0565:                    for (int i = 0; i < list.size(); i++) {
0566:                        AxisModule module = axisConfig.getModule((String) list
0567:                                .get(i));
0568:
0569:                        if (module == null) {
0570:                            throw new DeploymentException(
0571:                                    Messages
0572:                                            .getMessage(
0573:                                                    DeploymentErrorMsgs.BAD_MODULE_FROM_SERVICE,
0574:                                                    axisService.getName(),
0575:                                                    ((QName) list.get(i))
0576:                                                            .getLocalPart()));
0577:                        }
0578:
0579:                        axisService.engageModule(module);
0580:                    }
0581:
0582:                    for (Iterator iterator = axisService.getOperations(); iterator
0583:                            .hasNext();) {
0584:                        AxisOperation opDesc = (AxisOperation) iterator.next();
0585:                        ArrayList modules = opDesc.getModuleRefs();
0586:
0587:                        for (int i = 0; i < modules.size(); i++) {
0588:                            String moduleName = (String) modules.get(i);
0589:                            AxisModule module = axisConfig
0590:                                    .getModule(moduleName);
0591:
0592:                            if (module != null) {
0593:                                opDesc.engageModule(module);
0594:                            } else {
0595:                                throw new DeploymentException(
0596:                                        Messages
0597:                                                .getMessage(
0598:                                                        DeploymentErrorMsgs.BAD_MODULE_FROM_OPERATION,
0599:                                                        opDesc.getName()
0600:                                                                .getLocalPart(),
0601:                                                        moduleName));
0602:                            }
0603:                        }
0604:                    }
0605:                }
0606:            }
0607:
0608:            /**
0609:             * @param file ArchiveFileData
0610:             */
0611:            public void addWSToDeploy(DeploymentFileData file) {
0612:                wsToDeploy.add(file);
0613:            }
0614:
0615:            /**
0616:             * @param file WSInfo
0617:             */
0618:            public void addWSToUndeploy(WSInfo file) {
0619:                wsToUnDeploy.add(file);
0620:            }
0621:
0622:            public void doDeploy() {
0623:                try {
0624:                    if (wsToDeploy.size() > 0) {
0625:                        for (int i = 0; i < wsToDeploy.size(); i++) {
0626:                            DeploymentFileData fileToDeploy = (DeploymentFileData) wsToDeploy
0627:                                    .get(i);
0628:                            try {
0629:                                fileToDeploy.deploy();
0630:                            } catch (DeploymentException e) {
0631:                                // TODO : This probably isn't sufficient.  Maybe provide an option to stop?
0632:                                log.info(e);
0633:                            }
0634:                        }
0635:                    }
0636:                } finally {
0637:                    wsToDeploy.clear();
0638:                }
0639:            }
0640:
0641:            /**
0642:             * Checks if the modules, referred by server.xml, exist or that they are deployed.
0643:             *
0644:             * @throws org.apache.axis2.AxisFault : If smt goes wrong
0645:             */
0646:            public void engageModules() throws AxisFault {
0647:                axisConfig.engageGlobalModules();
0648:            }
0649:
0650:            /**
0651:             * To get AxisConfiguration for a given inputStream this method can be used.
0652:             * The inputstream should be a valid axis2.xml , else you will be getting
0653:             * DeploymentExceptions.
0654:             * <p/>
0655:             * First creat a AxisConfiguration using given inputSream , and then it will
0656:             * try to find the repository location parameter from AxisConfiguration, so
0657:             * if user has add a parameter with the name "repository" , then the value
0658:             * specified by that parameter will be the repository and system will try to
0659:             * load modules and services from that repository location if it a valid
0660:             * location. hot deployment and hot update will work as usual in this case.
0661:             * <p/>
0662:             * You will be getting AxisConfiguration corresponding to given inputstream
0663:             * if it is valid , if something goes wrong you will be getting
0664:             * DeploymentException
0665:             *
0666:             * @param in : InputStream to axis2.xml
0667:             * @return a populated AxisConfiguration
0668:             * @throws DeploymentException : If something goes wrong
0669:             */
0670:            public AxisConfiguration populateAxisConfiguration(InputStream in)
0671:                    throws DeploymentException {
0672:                axisConfig = new AxisConfiguration();
0673:                AxisConfigBuilder builder = new AxisConfigBuilder(in,
0674:                        axisConfig, this );
0675:                builder.populateConfig();
0676:                try {
0677:                    if (in != null) {
0678:                        in.close();
0679:                    }
0680:                } catch (IOException e) {
0681:                    log.info("error in closing input stream");
0682:                }
0683:                moduleDeployer = new ModuleDeployer(axisConfig);
0684:                return axisConfig;
0685:            }
0686:
0687:            /**
0688:             * Starts the Deployment engine to perform Hot deployment and so on.
0689:             *
0690:             * @param listener : RepositoryListener
0691:             */
0692:            protected void startSearch(RepositoryListener listener) {
0693:                scheduler = new Scheduler();
0694:
0695:                scheduler.schedule(new SchedulerTask(listener),
0696:                        new DeploymentIterator());
0697:            }
0698:
0699:            public void unDeploy() {
0700:                try {
0701:                    if (wsToUnDeploy.size() > 0) {
0702:                        for (int i = 0; i < wsToUnDeploy.size(); i++) {
0703:                            WSInfo wsInfo = (WSInfo) wsToUnDeploy.get(i);
0704:                            if (wsInfo.getType() == WSInfo.TYPE_SERVICE) {
0705:                                //No matter what we need to undeploy the service
0706:                                // if user has deleted the file from the repository
0707:                                serviceDeployer.unDeploy(wsInfo.getFileName());
0708:                            } else {
0709:                                //We need to undeploy the service whether we have enable hotUpdate or not ,
0710:                                // o.w what happen if someone delete the service from the repo
0711:                                Deployer deployer = wsInfo.getDeployer();
0712:                                if (deployer != null) {
0713:                                    deployer.unDeploy(wsInfo.getFileName());
0714:                                }
0715:                            }
0716:                        }
0717:                    }
0718:                } catch (Exception e) {
0719:                    log.info(e);
0720:                }
0721:                wsToUnDeploy.clear();
0722:            }
0723:
0724:            /**
0725:             * Gets AxisConfiguration.
0726:             *
0727:             * @return AxisConfiguration <code>AxisConfiguration</code>
0728:             */
0729:            public AxisConfiguration getAxisConfig() {
0730:                return axisConfig;
0731:            }
0732:
0733:            /**
0734:             * Retrieves service name from the archive file name.
0735:             * If the archive file name is service1.aar , then axis2 service name would be service1
0736:             *
0737:             * @param fileName the archive file name
0738:             * @return Returns String.
0739:             */
0740:            public static String getAxisServiceName(String fileName) {
0741:                char seperator = '.';
0742:                String value;
0743:                int index = fileName.lastIndexOf(seperator);
0744:
0745:                if (index > 0) {
0746:                    value = fileName.substring(0, index);
0747:
0748:                    return value;
0749:                }
0750:
0751:                return fileName;
0752:            }
0753:
0754:            public AxisModule getModule(String moduleName) throws AxisFault {
0755:                return axisConfig.getModule(moduleName);
0756:            }
0757:
0758:            public boolean isHotUpdate() {
0759:                return hotUpdate;
0760:            }
0761:
0762:            private static void addAsWebResources(File in,
0763:                    String serviceFileName, AxisServiceGroup serviceGroup) {
0764:                try {
0765:                    if (webLocationString == null) {
0766:                        return;
0767:                    }
0768:                    if (in.isDirectory()) {
0769:                        return;
0770:                    }
0771:                    File webLocation = new File(webLocationString);
0772:                    File out = new File(webLocation, serviceFileName);
0773:                    int BUFFER = 1024;
0774:                    byte data[] = new byte[BUFFER];
0775:                    FileInputStream fin = new FileInputStream(in);
0776:                    ZipInputStream zin = new ZipInputStream(fin);
0777:                    ZipEntry entry;
0778:                    while ((entry = zin.getNextEntry()) != null) {
0779:                        ZipEntry zip = new ZipEntry(entry);
0780:                        if (zip.getName().toUpperCase().startsWith("WWW")) {
0781:                            String fileName = zip.getName();
0782:                            fileName = fileName.substring("WWW/".length(),
0783:                                    fileName.length());
0784:                            if (zip.isDirectory()) {
0785:                                new File(out, fileName).mkdirs();
0786:                            } else {
0787:                                FileOutputStream tempOut = new FileOutputStream(
0788:                                        new File(out, fileName));
0789:                                int count;
0790:                                while ((count = zin.read(data, 0, BUFFER)) != -1) {
0791:                                    tempOut.write(data, 0, count);
0792:                                }
0793:                                tempOut.close();
0794:                                tempOut.flush();
0795:                            }
0796:                            serviceGroup.setFoundWebResources(true);
0797:                        }
0798:                    }
0799:                    zin.close();
0800:                    fin.close();
0801:                } catch (IOException e) {
0802:                    log.info(e.getMessage());
0803:                }
0804:            }
0805:
0806:            public String getWebLocationString() {
0807:                return webLocationString;
0808:            }
0809:
0810:            /**
0811:             * To set the all the classLoader hierarchy this method can be used , the top most parent is
0812:             * CCL then SCL(system Class Loader)
0813:             * CCL
0814:             * :
0815:             * SCL
0816:             * :  :
0817:             * MCCL  SCCL
0818:             * :      :
0819:             * MCL    SCL
0820:             * <p/>
0821:             * <p/>
0822:             * MCCL :  module common class loader
0823:             * SCCL : Service common class loader
0824:             * MCL : module class loader
0825:             * SCL  : Service class loader
0826:             *
0827:             * @param axis2repoURI : The repository folder of Axis2
0828:             * @throws DeploymentException if there's a problem
0829:             */
0830:            protected void setClassLoaders(String axis2repoURI)
0831:                    throws DeploymentException {
0832:                ClassLoader sysClassLoader = Utils.getClassLoader(Thread
0833:                        .currentThread().getContextClassLoader(), axis2repoURI);
0834:
0835:                axisConfig.setSystemClassLoader(sysClassLoader);
0836:                if (servicesDir.exists()) {
0837:                    axisConfig.setServiceClassLoader(Utils.getClassLoader(
0838:                            axisConfig.getSystemClassLoader(), servicesDir));
0839:                } else {
0840:                    axisConfig.setServiceClassLoader(axisConfig
0841:                            .getSystemClassLoader());
0842:                }
0843:
0844:                if (modulesDir.exists()) {
0845:                    axisConfig.setModuleClassLoader(Utils.getClassLoader(
0846:                            axisConfig.getSystemClassLoader(), modulesDir));
0847:                } else {
0848:                    axisConfig.setModuleClassLoader(axisConfig
0849:                            .getSystemClassLoader());
0850:                }
0851:            }
0852:
0853:            /**
0854:             * Sets hotDeployment and hot update.
0855:             */
0856:            protected void setDeploymentFeatures() {
0857:                Parameter hotDeployment = axisConfig
0858:                        .getParameter(TAG_HOT_DEPLOYMENT);
0859:                Parameter hotUpdate = axisConfig.getParameter(TAG_HOT_UPDATE);
0860:
0861:                if (hotDeployment != null) {
0862:                    this .hotDeployment = JavaUtils.isTrue(hotDeployment
0863:                            .getValue(), true);
0864:                }
0865:
0866:                if (hotUpdate != null) {
0867:                    this .hotUpdate = JavaUtils.isTrue(hotUpdate.getValue(),
0868:                            true);
0869:                }
0870:
0871:                String serviceDirPara = (String) axisConfig
0872:                        .getParameterValue(DeploymentConstants.SERVICE_DIR_PATH);
0873:                if (serviceDirPara != null) {
0874:                    servicesPath = serviceDirPara;
0875:                }
0876:
0877:                String moduleDirPara = (String) axisConfig
0878:                        .getParameterValue(DeploymentConstants.MODULE_DRI_PATH);
0879:                if (moduleDirPara != null) {
0880:                    modulesPath = moduleDirPara;
0881:                }
0882:            }
0883:
0884:            /**
0885:             * Creates directories for modules/services, copies configuration xml from class loader if necessary
0886:             *
0887:             * @param repositoryName the pathname of the repository
0888:             */
0889:
0890:            protected void prepareRepository(String repositoryName) {
0891:                repositoryDir = new File(repositoryName);
0892:                if (servicesPath != null) {
0893:                    servicesDir = new File(servicesPath);
0894:                    if (!servicesDir.exists()) {
0895:                        servicesDir = new File(repositoryDir, servicesPath);
0896:                    }
0897:                } else {
0898:                    servicesDir = new File(repositoryDir,
0899:                            DeploymentConstants.SERVICE_PATH);
0900:                }
0901:                if (!servicesDir.exists()) {
0902:                    log.info(Messages.getMessage("noservicedirfound",
0903:                            getRepositoryPath(repositoryDir)));
0904:                }
0905:                if (modulesPath != null) {
0906:                    modulesDir = new File(modulesPath);
0907:                    if (!modulesDir.exists()) {
0908:                        modulesDir = new File(repositoryDir, modulesPath);
0909:                    }
0910:                } else {
0911:                    modulesDir = new File(repositoryDir,
0912:                            DeploymentConstants.MODULE_PATH);
0913:                }
0914:                if (!modulesDir.exists()) {
0915:                    log.info(Messages.getMessage("nomoduledirfound",
0916:                            getRepositoryPath(repositoryDir)));
0917:                }
0918:            }
0919:
0920:            protected String getRepositoryPath(File repository) {
0921:                try {
0922:                    return repository.getCanonicalPath();
0923:                } catch (IOException e) {
0924:                    return repository.getAbsolutePath();
0925:                }
0926:            }
0927:
0928:            protected ArrayList getFileList(URL fileListUrl) {
0929:                ArrayList fileList = new ArrayList();
0930:                InputStream in;
0931:                try {
0932:                    in = fileListUrl.openStream();
0933:                } catch (IOException e) {
0934:                    return fileList;
0935:                }
0936:                BufferedReader input = null;
0937:                try {
0938:                    input = new BufferedReader(new InputStreamReader(in));
0939:                    String line;
0940:                    while ((line = input.readLine()) != null) {
0941:                        line = line.trim();
0942:                        if (line.length() > 0 && line.charAt(0) != '#') {
0943:                            fileList.add(line);
0944:                        }
0945:                    }
0946:                } catch (IOException ex) {
0947:                    ex.printStackTrace();
0948:                } finally {
0949:                    try {
0950:                        if (input != null) {
0951:                            input.close();
0952:                        }
0953:                    } catch (IOException ex) {
0954:                        ex.printStackTrace();
0955:                    }
0956:                }
0957:                return fileList;
0958:            }
0959:
0960:            public void setConfigContext(ConfigurationContext configContext) {
0961:                this .configContext = configContext;
0962:                initializeDeployers(this .configContext);
0963:            }
0964:
0965:            private void initializeDeployers(ConfigurationContext configContext) {
0966:                serviceDeployer = new ServiceDeployer();
0967:                serviceDeployer.init(configContext);
0968:                Iterator deployers = extensionToDeployerMappingMap.values()
0969:                        .iterator();
0970:                while (deployers.hasNext()) {
0971:                    Deployer deployer = (Deployer) deployers.next();
0972:                    deployer.init(configContext);
0973:                }
0974:            }
0975:
0976:            /**
0977:             * Builds an AxisModule for a given module archive file. This does not
0978:             * called the init method since there is no reference to configuration context
0979:             * so who ever create module using this has to called module.init if it is
0980:             * required
0981:             *
0982:             * @param modulearchive : Actual module archive file
0983:             * @param config        : AxisConfiguration : for get classloaders etc..
0984:             * @return a complete AxisModule read from the file.
0985:             * @throws org.apache.axis2.deployment.DeploymentException
0986:             *          if there's a problem
0987:             */
0988:            public static AxisModule buildModule(File modulearchive,
0989:                    AxisConfiguration config) throws DeploymentException {
0990:                final String MODULE_DEPLOYER = "moduleDeployer";
0991:                AxisModule axismodule;
0992:                ModuleDeployer deployer = (ModuleDeployer) config
0993:                        .getParameterValue(MODULE_DEPLOYER);
0994:                try {
0995:                    if (deployer == null) {
0996:                        deployer = new ModuleDeployer(config);
0997:                        config.addParameter(MODULE_DEPLOYER, deployer);
0998:                    }
0999:
1000:                    DeploymentFileData currentDeploymentFile = new DeploymentFileData(
1001:                            modulearchive, deployer);
1002:                    axismodule = new AxisModule();
1003:                    ArchiveReader archiveReader = new ArchiveReader();
1004:
1005:                    currentDeploymentFile.setClassLoader(false, config
1006:                            .getModuleClassLoader(), null);
1007:                    axismodule.setModuleClassLoader(currentDeploymentFile
1008:                            .getClassLoader());
1009:                    archiveReader.readModuleArchive(currentDeploymentFile,
1010:                            axismodule, false, config);
1011:                    ClassLoader moduleClassLoader = axismodule
1012:                            .getModuleClassLoader();
1013:                    Flow inflow = axismodule.getInFlow();
1014:
1015:                    if (inflow != null) {
1016:                        Utils.addFlowHandlers(inflow, moduleClassLoader);
1017:                    }
1018:
1019:                    Flow outFlow = axismodule.getOutFlow();
1020:
1021:                    if (outFlow != null) {
1022:                        Utils.addFlowHandlers(outFlow, moduleClassLoader);
1023:                    }
1024:
1025:                    Flow faultInFlow = axismodule.getFaultInFlow();
1026:
1027:                    if (faultInFlow != null) {
1028:                        Utils.addFlowHandlers(faultInFlow, moduleClassLoader);
1029:                    }
1030:
1031:                    Flow faultOutFlow = axismodule.getFaultOutFlow();
1032:
1033:                    if (faultOutFlow != null) {
1034:                        Utils.addFlowHandlers(faultOutFlow, moduleClassLoader);
1035:                    }
1036:                } catch (AxisFault axisFault) {
1037:                    throw new DeploymentException(axisFault);
1038:                }
1039:                return axismodule;
1040:            }
1041:
1042:            /**
1043:             * Fills an axisservice object using services.xml. First creates
1044:             * an axisservice object using WSDL and then fills it using the given services.xml.
1045:             * Loads all the required class and builds the chains, finally adds the
1046:             * servicecontext to EngineContext and axisservice into EngineConfiguration.
1047:             *
1048:             * @param serviceInputStream InputStream containing configuration data
1049:             * @param configCtx          the ConfigurationContext in which we're deploying
1050:             * @return Returns AxisService.
1051:             * @throws DeploymentException if there's a problem
1052:             */
1053:            public static AxisService buildService(
1054:                    InputStream serviceInputStream,
1055:                    ConfigurationContext configCtx) throws DeploymentException {
1056:                AxisService axisService = new AxisService();
1057:                try {
1058:                    ServiceBuilder builder = new ServiceBuilder(
1059:                            serviceInputStream, configCtx, axisService);
1060:                    builder.populateService(builder.buildOM());
1061:                } catch (AxisFault axisFault) {
1062:                    throw new DeploymentException(axisFault);
1063:                } catch (XMLStreamException e) {
1064:                    throw new DeploymentException(e);
1065:                }
1066:
1067:                return axisService;
1068:            }
1069:
1070:            /**
1071:             * To build a AxisServiceGroup for a given services.xml
1072:             * You have to add the created group into AxisConfig
1073:             *
1074:             * @param servicesxml      InputStream created from services.xml or equivalent
1075:             * @param classLoader      ClassLoader to use
1076:             * @param serviceGroupName name of the service group
1077:             * @param configCtx        the ConfigurationContext in which we're deploying
1078:             * @param archiveReader    the ArchiveReader we're working with
1079:             * @param wsdlServices     Map of existing WSDL services
1080:             * @return a fleshed-out AxisServiceGroup
1081:             * @throws AxisFault if there's a problem
1082:             */
1083:            public static AxisServiceGroup buildServiceGroup(
1084:                    InputStream servicesxml, ClassLoader classLoader,
1085:                    String serviceGroupName, ConfigurationContext configCtx,
1086:                    ArchiveReader archiveReader, HashMap wsdlServices)
1087:                    throws AxisFault {
1088:                DeploymentFileData currentDeploymentFile = new DeploymentFileData(
1089:                        null, null);
1090:                currentDeploymentFile.setClassLoader(classLoader);
1091:                AxisServiceGroup serviceGroup = new AxisServiceGroup();
1092:                serviceGroup.setServiceGroupClassLoader(classLoader);
1093:                serviceGroup.setServiceGroupName(serviceGroupName);
1094:                AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
1095:                try {
1096:                    ArrayList serviceList = archiveReader.buildServiceGroup(
1097:                            servicesxml, currentDeploymentFile, serviceGroup,
1098:                            wsdlServices, configCtx);
1099:                    fillServiceGroup(serviceGroup, serviceList, null,
1100:                            axisConfig);
1101:                    return serviceGroup;
1102:                } catch (XMLStreamException e) {
1103:                    throw AxisFault.makeFault(e);
1104:                }
1105:            }
1106:
1107:            public static AxisServiceGroup loadServiceGroup(File serviceFile,
1108:                    ConfigurationContext configCtx) throws AxisFault {
1109:                try {
1110:                    DeploymentFileData currentDeploymentFile = new DeploymentFileData(
1111:                            serviceFile, null);
1112:                    DeploymentClassLoader classLoader = new DeploymentClassLoader(
1113:                            new URL[] { serviceFile.toURL() }, new ArrayList(),
1114:                            Thread.currentThread().getContextClassLoader());
1115:                    currentDeploymentFile.setClassLoader(classLoader);
1116:                    AxisServiceGroup serviceGroup = new AxisServiceGroup();
1117:                    serviceGroup.setServiceGroupClassLoader(classLoader);
1118:
1119:                    // Drop the extension and take the name
1120:                    String fileName = serviceFile.getName();
1121:                    String serviceGroupName = fileName.substring(0, fileName
1122:                            .lastIndexOf("."));
1123:                    serviceGroup.setServiceGroupName(serviceGroupName);
1124:                    AxisConfiguration axisConfig = configCtx
1125:                            .getAxisConfiguration();
1126:
1127:                    ArchiveReader archiveReader = new ArchiveReader();
1128:                    HashMap wsdlServices = archiveReader
1129:                            .processWSDLs(currentDeploymentFile);
1130:                    InputStream serviceXml = classLoader
1131:                            .getResourceAsStream("META-INF/services.xml");
1132:                    ArrayList serviceList = archiveReader.buildServiceGroup(
1133:                            serviceXml, currentDeploymentFile, serviceGroup,
1134:                            wsdlServices, configCtx);
1135:                    fillServiceGroup(serviceGroup, serviceList, null,
1136:                            axisConfig);
1137:                    return serviceGroup;
1138:                } catch (Exception e) {
1139:                    throw new DeploymentException(e);
1140:                }
1141:            }
1142:
1143:            public File getServicesDir() {
1144:                return servicesDir;
1145:            }
1146:
1147:            public File getModulesDir() {
1148:                return modulesDir;
1149:            }
1150:
1151:            public File getRepositoryDir() {
1152:                return repositoryDir;
1153:            }
1154:
1155:            public void setExtensionToDeployerMappingMap(
1156:                    HashMap extensionToDeployerMappingMap) {
1157:                this .extensionToDeployerMappingMap = extensionToDeployerMappingMap;
1158:            }
1159:
1160:            public void setDirectoryToExtensionMappingMap(
1161:                    HashMap directoryToExtensionMappingMap) {
1162:                this .directoryToExtensionMappingMap = directoryToExtensionMappingMap;
1163:            }
1164:
1165:            public HashMap getDirectoryToExtensionMappingMap() {
1166:                return directoryToExtensionMappingMap;
1167:            }
1168:
1169:            public RepositoryListener getRepoListener() {
1170:                return repoListener;
1171:            }
1172:
1173:            public ServiceDeployer getServiceDeployer() {
1174:                return serviceDeployer;
1175:            }
1176:
1177:            public ModuleDeployer getModuleDeployer() {
1178:                return moduleDeployer;
1179:            }
1180:
1181:            public Deployer getDeployerForExtension(String extension) {
1182:                return (Deployer) extensionToDeployerMappingMap.get(extension);
1183:            }
1184:
1185:            /**
1186:             * Clean up the mess
1187:             */
1188:            public void cleanup() {
1189:                if (scheduler != null) {
1190:                    scheduler.cleanup();
1191:                }
1192:            }
1193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.