Source Code Cross Referenced for AxisConfiguration.java in  » Web-Services-AXIS2 » kernal » org » apache » axis2 » engine » 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.engine 
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.engine;
0021:
0022:        import org.apache.axis2.AxisFault;
0023:        import org.apache.axis2.builder.Builder;
0024:        import org.apache.axis2.clustering.ClusterManager;
0025:        import org.apache.axis2.context.MessageContext;
0026:        import org.apache.axis2.dataretrieval.AxisDataLocator;
0027:        import org.apache.axis2.deployment.DeploymentException;
0028:        import org.apache.axis2.deployment.ModuleDeployer;
0029:        import org.apache.axis2.deployment.repository.util.DeploymentFileData;
0030:        import org.apache.axis2.deployment.util.PhasesInfo;
0031:        import org.apache.axis2.description.*;
0032:        import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
0033:        import org.apache.axis2.i18n.Messages;
0034:        import org.apache.axis2.phaseresolver.PhaseResolver;
0035:        import org.apache.axis2.transport.MessageFormatter;
0036:        import org.apache.axis2.util.TargetResolver;
0037:        import org.apache.axis2.util.Utils;
0038:        import org.apache.commons.logging.Log;
0039:        import org.apache.commons.logging.LogFactory;
0040:
0041:        import javax.xml.namespace.QName;
0042:        import java.io.File;
0043:        import java.net.URL;
0044:        import java.security.PrivilegedAction;
0045:        import java.util.*;
0046:
0047:        /**
0048:         * Class AxisConfiguration
0049:         */
0050:        public class AxisConfiguration extends AxisDescription {
0051:
0052:            private static final Log log = LogFactory
0053:                    .getLog(AxisConfiguration.class);
0054:            /* 
0055:             * To store configured data locators
0056:             */
0057:            private HashMap dataLocators = new HashMap();
0058:            private HashMap dataLocatorClassNames = new HashMap();
0059:
0060:            /**
0061:             * This is a Map of String name -> AxisModule for all available Modules.
0062:             */
0063:            private final HashMap allModules = new HashMap();
0064:
0065:            // To store mapping between default version and module name
0066:            private final HashMap nameToversionMap = new HashMap();
0067:
0068:            // private final HashMap serviceGroups = new HashMap();
0069:            private final HashMap transportsIn = new HashMap();
0070:
0071:            private final HashMap transportsOut = new HashMap();
0072:
0073:            private final HashMap policySupportedModules = new HashMap();
0074:
0075:            /**
0076:             * Stores the QNames of local policy assertions
0077:             */
0078:            private final ArrayList localPolicyAssertions = new ArrayList();
0079:
0080:            // to store AxisObserver Objects
0081:            private ArrayList observersList = null;
0082:
0083:            private URL axis2Repository = null;
0084:
0085:            private HashMap allServices = new HashMap();
0086:            private HashMap allEndpoints = new HashMap();
0087:
0088:            /**
0089:             * Stores the module specified in the server.xml at the document parsing time.
0090:             */
0091:            private List globalModuleList;
0092:
0093:            private Hashtable faultyModules;
0094:
0095:            /**
0096:             * To store faulty services
0097:             */
0098:            private Hashtable faultyServices;
0099:
0100:            private ArrayList inFaultPhases;
0101:
0102:            private ArrayList inPhasesUptoAndIncludingPostDispatch;
0103:
0104:            private HashMap messageReceivers;
0105:
0106:            private HashMap messageBuilders;
0107:
0108:            private HashMap messageFormatters;
0109:
0110:            private ClassLoader moduleClassLoader;
0111:
0112:            private HashMap moduleConfigmap;
0113:
0114:            private ArrayList outFaultPhases;
0115:
0116:            private ArrayList outPhases;
0117:
0118:            protected PhasesInfo phasesinfo;
0119:
0120:            private ClassLoader serviceClassLoader;
0121:
0122:            private ClassLoader systemClassLoader;
0123:
0124:            //To keep track of whether the system has started or not
0125:            private boolean start;
0126:
0127:            private ArrayList targetResolvers;
0128:
0129:            private ClusterManager clusterManager;
0130:
0131:            private AxisConfigurator configurator;
0132:
0133:            /**
0134:             * Constructor AxisConfiguration.
0135:             */
0136:            public AxisConfiguration() {
0137:                moduleConfigmap = new HashMap();
0138:                globalModuleList = new ArrayList();
0139:                messageReceivers = new HashMap();
0140:                messageBuilders = new HashMap();
0141:                messageFormatters = new HashMap();
0142:                outPhases = new ArrayList();
0143:                inFaultPhases = new ArrayList();
0144:                outFaultPhases = new ArrayList();
0145:                faultyServices = new Hashtable();
0146:                faultyModules = new Hashtable();
0147:                observersList = new ArrayList();
0148:                inPhasesUptoAndIncludingPostDispatch = new ArrayList();
0149:                systemClassLoader = (ClassLoader) org.apache.axis2.java.security.AccessController
0150:                        .doPrivileged(new PrivilegedAction() {
0151:                            public Object run() {
0152:                                return Thread.currentThread()
0153:                                        .getContextClassLoader();
0154:                            }
0155:                        });
0156:                serviceClassLoader = systemClassLoader;
0157:                moduleClassLoader = systemClassLoader;
0158:
0159:                this .phasesinfo = new PhasesInfo();
0160:                targetResolvers = new ArrayList();
0161:            }
0162:
0163:            public void addMessageReceiver(String mepURL,
0164:                    MessageReceiver messageReceiver) {
0165:                messageReceivers.put(mepURL, messageReceiver);
0166:            }
0167:
0168:            /**
0169:             * Register a messageBuilder implementation against a content type.
0170:             * This is used by Axis2 to support different message formats.
0171:             *
0172:             * @param contentType    the relevant content-type (i.e. "text/xml")
0173:             * @param messageBuilder a Builder implementation
0174:             */
0175:            public void addMessageBuilder(String contentType,
0176:                    Builder messageBuilder) {
0177:                messageBuilders.put(contentType, messageBuilder);
0178:            }
0179:
0180:            /**
0181:             * Register a messageFormatter implementation against a content type.
0182:             * This is used by Axis2 to support serialization of messages to different
0183:             * message formats. (Eg: JSON)
0184:             *
0185:             * @param contentType      the relevant content-type (i.e. "text/xml")
0186:             * @param messageFormatter a MessageFormatter implementation
0187:             */
0188:            public void addMessageFormatter(String contentType,
0189:                    MessageFormatter messageFormatter) {
0190:                messageFormatters.put(contentType, messageFormatter);
0191:            }
0192:
0193:            /**
0194:             * Add an available Module to this configuration
0195:             *
0196:             * @param module an AxisModule
0197:             * @throws AxisFault in case of error
0198:             */
0199:            public void addModule(AxisModule module) throws AxisFault {
0200:                module.setParent(this );
0201:
0202:                if (module.getVersion() == null) {
0203:                    if (module.getName().endsWith(AxisModule.VERSION_SNAPSHOT)) {
0204:                        allModules.put(module.getName(), module);
0205:                        String moduleName = module.getName().substring(
0206:                                0,
0207:                                module.getName().indexOf(
0208:                                        AxisModule.VERSION_SNAPSHOT) - 1);
0209:                        module.setName(moduleName);
0210:                        module.setVersion(AxisModule.VERSION_SNAPSHOT);
0211:                    } else {
0212:                        allModules.put(module.getName(), module);
0213:                    }
0214:
0215:                } else { // Calculate the module version from the name
0216:                    allModules.put(Utils.getModuleName(module.getName(), module
0217:                            .getVersion()), module);
0218:                }
0219:                notifyObservers(AxisEvent.MODULE_DEPLOY, module);
0220:
0221:                // Registering the policy namespaces that the module understand
0222:                registerModulePolicySupport(module);
0223:                // Registering the policy assertions that are local to the system
0224:                registerLocalPolicyAssertions(module);
0225:
0226:            }
0227:
0228:            public void deployModule(String moduleFileName)
0229:                    throws DeploymentException {
0230:                File moduleFile = new File(moduleFileName);
0231:                if (!moduleFile.exists()) {
0232:                    throw new DeploymentException("Module archive '"
0233:                            + moduleFileName + "' doesn't exist");
0234:                }
0235:                DeploymentFileData dfd = new DeploymentFileData(moduleFile,
0236:                        new ModuleDeployer(this ));
0237:                dfd.deploy();
0238:            }
0239:
0240:            /**
0241:             * To remove a given module from the system
0242:             *
0243:             * @param module name of module to remove
0244:             * @deprecated Use {@link #removeModule(String,String)}
0245:             */
0246:            public void removeModule(String module) {
0247:                allModules.remove(module);
0248:                // TODO disengage has to be done here
0249:            }
0250:
0251:            /**
0252:             * Remove a module with moduleName & moduleVersion
0253:             *
0254:             * @param moduleName
0255:             * @param moduleVersion
0256:             */
0257:            public void removeModule(String moduleName, String moduleVersion) {
0258:                allModules.remove(Utils
0259:                        .getModuleName(moduleName, moduleVersion));
0260:                // TODO disengage has to be done here
0261:            }
0262:
0263:            /**
0264:             * Adds module configuration, if there is a moduleConfig tag in service.
0265:             *
0266:             * @param moduleConfiguration a ModuleConfiguration to remember
0267:             */
0268:            public void addModuleConfig(ModuleConfiguration moduleConfiguration) {
0269:                moduleConfigmap.put(moduleConfiguration.getModuleName(),
0270:                        moduleConfiguration);
0271:            }
0272:
0273:            public void addObservers(AxisObserver axisObserver) {
0274:                observersList.add(axisObserver);
0275:            }
0276:
0277:            /**
0278:             * Method addService.
0279:             *
0280:             * @param service
0281:             * @throws AxisFault
0282:             */
0283:            public synchronized void addService(AxisService service)
0284:                    throws AxisFault {
0285:                AxisServiceGroup axisServiceGroup = new AxisServiceGroup();
0286:                axisServiceGroup.setServiceGroupName(service.getName());
0287:                axisServiceGroup.setParent(this );
0288:                axisServiceGroup.addService(service);
0289:                addServiceGroup(axisServiceGroup);
0290:            }
0291:
0292:            public synchronized void addServiceGroup(
0293:                    AxisServiceGroup axisServiceGroup) throws AxisFault {
0294:                axisServiceGroup.setParent(this );
0295:                notifyObservers(AxisEvent.SERVICE_DEPLOY, axisServiceGroup);
0296:                AxisService axisService;
0297:
0298:                Iterator services = axisServiceGroup.getServices();
0299:                while (services.hasNext()) {
0300:                    axisService = (AxisService) services.next();
0301:                    if (axisService.getSchematargetNamespace() == null) {
0302:                        axisService
0303:                                .setSchemaTargetNamespace(Java2WSDLConstants.AXIS2_XSD);
0304:                    }
0305:                }
0306:                services = axisServiceGroup.getServices();
0307:                while (services.hasNext()) {
0308:                    axisService = (AxisService) services.next();
0309:                    if (axisService.isUseDefaultChains()) {
0310:                        Iterator operations = axisService.getOperations();
0311:                        while (operations.hasNext()) {
0312:                            AxisOperation operation = (AxisOperation) operations
0313:                                    .next();
0314:                            phasesinfo.setOperationPhases(operation);
0315:                        }
0316:                    }
0317:                }
0318:                Iterator enModule = getEngagedModules().iterator();
0319:                while (enModule.hasNext()) {
0320:                    axisServiceGroup.engageModule((AxisModule) enModule.next());
0321:                }
0322:                services = axisServiceGroup.getServices();
0323:                ArrayList servicesIAdded = new ArrayList();
0324:                while (services.hasNext()) {
0325:                    axisService = (AxisService) services.next();
0326:
0327:                    Map endpoints = axisService.getEndpoints();
0328:                    String serviceName = axisService.getName();
0329:                    try {
0330:                        addToAllServicesMap(axisService);
0331:                    } catch (AxisFault axisFault) {
0332:                        // Whoops, must have been a duplicate!  If we had a problem here, we have to
0333:                        // remove all the ones we added...
0334:                        for (Iterator i = servicesIAdded.iterator(); i
0335:                                .hasNext();) {
0336:                            AxisService service = (AxisService) i.next();
0337:                            allServices.remove(service.getName());
0338:                        }
0339:                        // And toss this in case anyone wants it?
0340:                        throw axisFault;
0341:                    }
0342:                    servicesIAdded.add(axisService);
0343:                    if (endpoints != null) {
0344:                        Iterator endpointNameIter = endpoints.keySet()
0345:                                .iterator();
0346:                        while (endpointNameIter.hasNext()) {
0347:                            String endpointName = (String) endpointNameIter
0348:                                    .next();
0349:                            allEndpoints.put(serviceName + "." + endpointName,
0350:                                    axisService);
0351:                        }
0352:                    }
0353:
0354:                    if (!axisService.isClientSide()) {
0355:                        notifyObservers(AxisEvent.SERVICE_DEPLOY, axisService);
0356:                    }
0357:                }
0358:                // serviceGroups.put(axisServiceGroup.getServiceGroupName(),
0359:                // axisServiceGroup);
0360:                addChild(axisServiceGroup);
0361:            }
0362:
0363:            public void addToAllServicesMap(AxisService axisService)
0364:                    throws AxisFault {
0365:                String serviceName = axisService.getName();
0366:                AxisService oldService = (AxisService) allServices
0367:                        .get(serviceName);
0368:                if (oldService == null) {
0369:                    allServices.put(serviceName, axisService);
0370:                } else {
0371:                    // If we were already there, that's fine.  If not, fault!
0372:                    if (oldService != axisService) {
0373:                        throw new AxisFault(Messages.getMessage(
0374:                                "twoservicecannothavesamename", axisService
0375:                                        .getName()));
0376:                    }
0377:                }
0378:            }
0379:
0380:            public AxisServiceGroup removeServiceGroup(String serviceGroupName)
0381:                    throws AxisFault {
0382:                AxisServiceGroup axisServiceGroup = (AxisServiceGroup) getChild(serviceGroupName);
0383:                if (axisServiceGroup == null) {
0384:                    throw new AxisFault(Messages.getMessage(
0385:                            "invalidservicegroupname", serviceGroupName));
0386:                }
0387:                Iterator services = axisServiceGroup.getServices();
0388:                while (services.hasNext()) {
0389:                    AxisService axisService = (AxisService) services.next();
0390:                    allServices.remove(axisService.getName());
0391:                    if (!axisService.isClientSide()) {
0392:                        notifyObservers(AxisEvent.SERVICE_REMOVE, axisService);
0393:                    }
0394:                }
0395:                removeChild(serviceGroupName);
0396:                notifyObservers(AxisEvent.SERVICE_REMOVE, axisServiceGroup);
0397:                return axisServiceGroup;
0398:            }
0399:
0400:            /**
0401:             * Method addTransportIn.
0402:             *
0403:             * @param transport
0404:             * @throws AxisFault
0405:             */
0406:            public void addTransportIn(TransportInDescription transport)
0407:                    throws AxisFault {
0408:                if (transport.getReceiver() == null) {
0409:                    throw new AxisFault(
0410:                            "Transport Receiver can not be null for the transport "
0411:                                    + transport.getName());
0412:                }
0413:                transportsIn.put(transport.getName(), transport);
0414:            }
0415:
0416:            /**
0417:             * Method addTransportOut.
0418:             *
0419:             * @param transport
0420:             * @throws AxisFault
0421:             */
0422:            public void addTransportOut(TransportOutDescription transport)
0423:                    throws AxisFault {
0424:                if (transport.getSender() == null) {
0425:                    throw new AxisFault(
0426:                            "Transport sender can not be null for the transport "
0427:                                    + transport.getName());
0428:                }
0429:                transportsOut.put(transport.getName(), transport);
0430:            }
0431:
0432:            /**
0433:             * Engages the default module version corresponding to the given module name,
0434:             * or if the module name contains version number in it then it will engage
0435:             * the correct module. Both the below cases are valid : -
0436:             * 1. engageModule("addressing"); 2. engageModule("addressing-1.23");
0437:             *
0438:             * @param moduleref QName of module to engage
0439:             * @throws AxisFault
0440:             * @deprecated Please use the String version instead
0441:             */
0442:            public void engageModule(QName moduleref) throws AxisFault {
0443:                engageModule(moduleref.getLocalPart());
0444:            }
0445:
0446:            /**
0447:             * Engages the default module version corresponding to given module name ,
0448:             * or if the module name contains version number in it then it will engage
0449:             * the correct module. Both of the below two cases are valid 1.
0450:             * engageModule("addressing"); 2. engageModule("addressing-1.23");
0451:             *
0452:             * @param moduleref name of module to engage
0453:             * @throws AxisFault
0454:             */
0455:            public void engageModule(String moduleref) throws AxisFault {
0456:                AxisModule module = getModule(moduleref);
0457:                if (module != null) {
0458:                    engageModule(module);
0459:                } else {
0460:                    throw new AxisFault(Messages.getMessage(
0461:                            "modulenotavailble", moduleref));
0462:                }
0463:            }
0464:
0465:            /**
0466:             * Engages a module using given name and its version ID.
0467:             *
0468:             * @param moduleName
0469:             * @param versionID
0470:             * @throws AxisFault
0471:             */
0472:            public void engageModule(String moduleName, String versionID)
0473:                    throws AxisFault {
0474:                String actualName = Utils.getModuleName(moduleName, versionID);
0475:                AxisModule module = getModule(actualName);
0476:                if (module != null) {
0477:                    engageModule(module);
0478:                } else {
0479:                    throw new AxisFault(Messages
0480:                            .getMessage("refertoinvalidmodule"));
0481:                }
0482:            }
0483:
0484:            public void onEngage(AxisModule module, AxisDescription engager)
0485:                    throws AxisFault {
0486:                Iterator servicegroups = getServiceGroups();
0487:                while (servicegroups.hasNext()) {
0488:                    AxisServiceGroup serviceGroup = (AxisServiceGroup) servicegroups
0489:                            .next();
0490:                    serviceGroup.engageModule(module, engager);
0491:                }
0492:            }
0493:
0494:            /**
0495:             * To dis-engage a module from the system. This will remove all the handlers
0496:             * belonging to this module from all the handler chains.
0497:             *
0498:             * @param module module to disengage
0499:             */
0500:            public void onDisengage(AxisModule module) throws AxisFault {
0501:                PhaseResolver phaseResolver = new PhaseResolver(this );
0502:                phaseResolver.disengageModuleFromGlobalChains(module);
0503:
0504:                Iterator serviceGroups = getServiceGroups();
0505:                while (serviceGroups.hasNext()) {
0506:                    AxisServiceGroup axisServiceGroup = (AxisServiceGroup) serviceGroups
0507:                            .next();
0508:                    axisServiceGroup.disengageModule(module);
0509:                }
0510:            }
0511:
0512:            public void notifyObservers(int event_type, AxisService service) {
0513:                AxisEvent event = new AxisEvent(event_type);
0514:
0515:                for (int i = 0; i < observersList.size(); i++) {
0516:                    AxisObserver axisObserver = (AxisObserver) observersList
0517:                            .get(i);
0518:
0519:                    try {
0520:                        if (!service.isClientSide()) {
0521:                            axisObserver.serviceUpdate(event, service);
0522:                        }
0523:                    } catch (Throwable e) {
0524:                        // No need to stop the system due to this, so log and ignore
0525:                        log.debug(e);
0526:                    }
0527:                }
0528:            }
0529:
0530:            public void notifyObservers(int event_type, AxisModule moule) {
0531:                AxisEvent event = new AxisEvent(event_type);
0532:
0533:                for (int i = 0; i < observersList.size(); i++) {
0534:                    AxisObserver axisObserver = (AxisObserver) observersList
0535:                            .get(i);
0536:
0537:                    try {
0538:                        axisObserver.moduleUpdate(event, moule);
0539:                    } catch (Throwable e) {
0540:                        // No need to stop the system due to this, so log and ignore
0541:                        log.debug(e);
0542:                    }
0543:                }
0544:            }
0545:
0546:            public void notifyObservers(int event_type,
0547:                    AxisServiceGroup serviceGroup) {
0548:                AxisEvent event = new AxisEvent(event_type);
0549:
0550:                for (int i = 0; i < observersList.size(); i++) {
0551:                    AxisObserver axisObserver = (AxisObserver) observersList
0552:                            .get(i);
0553:
0554:                    try {
0555:                        axisObserver.serviceGroupUpdate(event, serviceGroup);
0556:                    } catch (Throwable e) {
0557:                        // No need to stop the system due to this, so log and ignore
0558:                        log.debug(e);
0559:                    }
0560:                }
0561:            }
0562:
0563:            /**
0564:             * Method removeService.
0565:             *
0566:             * @param name
0567:             * @throws AxisFault
0568:             */
0569:            public synchronized void removeService(String name)
0570:                    throws AxisFault {
0571:                AxisService service = (AxisService) allServices.remove(name);
0572:                if (service != null) {
0573:                    AxisServiceGroup serviceGroup = service
0574:                            .getAxisServiceGroup();
0575:                    serviceGroup.removeService(name);
0576:                    log.debug(Messages.getMessage("serviceremoved", name));
0577:                }
0578:            }
0579:
0580:            /**
0581:             * Add an AxisModule to the list of globally deployed modules.
0582:             * <p/>
0583:             * TODO: should this check for duplicate names?
0584:             *
0585:             * @param moduleName name of AxisModule to add to list.
0586:             */
0587:            public void addGlobalModuleRef(String moduleName) {
0588:                globalModuleList.add(moduleName);
0589:            }
0590:
0591:            /**
0592:             * Engage all the previously added global modules.
0593:             *
0594:             * @throws AxisFault if an individual engageModule() fails
0595:             */
0596:            public void engageGlobalModules() throws AxisFault {
0597:                for (Iterator i = globalModuleList.iterator(); i.hasNext();) {
0598:                    engageModule((String) i.next());
0599:                }
0600:            }
0601:
0602:            public Hashtable getFaultyModules() {
0603:                return faultyModules;
0604:            }
0605:
0606:            public Hashtable getFaultyServices() {
0607:                return faultyServices;
0608:            }
0609:
0610:            public void removeFaultyService(String key) {
0611:                Iterator itr = faultyServices.keySet().iterator();
0612:                while (itr.hasNext()) {
0613:                    String fullFileName = (String) itr.next();
0614:                    if (fullFileName.indexOf(key) > 0) {
0615:                        faultyServices.remove(fullFileName);
0616:                        return;
0617:                    }
0618:                }
0619:            }
0620:
0621:            // to get the out flow correpodning to the global out flow;
0622:            public ArrayList getOutFlowPhases() {
0623:                return this .outPhases;
0624:            }
0625:
0626:            /**
0627:             * @return Returns ArrayList.
0628:             */
0629:            public ArrayList getInFaultFlowPhases() {
0630:                return inFaultPhases;
0631:            }
0632:
0633:            public ArrayList getInFlowPhases() {
0634:                return inPhasesUptoAndIncludingPostDispatch;
0635:            }
0636:
0637:            public MessageReceiver getMessageReceiver(String mepURL) {
0638:                return (MessageReceiver) messageReceivers.get(mepURL);
0639:            }
0640:
0641:            /**
0642:             * @param contentType
0643:             * @return the configured message builder implementation class name against
0644:             *         the given content type.
0645:             */
0646:            public Builder getMessageBuilder(String contentType) {
0647:                return (Builder) messageBuilders.get(contentType);
0648:            }
0649:
0650:            /**
0651:             * @param contentType
0652:             * @return the configured message formatter implementation class name
0653:             *         against the given content type.
0654:             */
0655:            public MessageFormatter getMessageFormatter(String contentType) {
0656:                return (MessageFormatter) messageFormatters.get(contentType);
0657:            }
0658:
0659:            //    /**
0660:            //     *
0661:            //     * @deprecate Please use String version instead
0662:            //     * @param qname
0663:            //     * @return
0664:            //     */
0665:            //    public AxisModule getModule(QName qname) {
0666:            //        return getModule(qname.getLocalPart());
0667:            //    }
0668:
0669:            /**
0670:             * Method getModule. First it will check whether the given module is there
0671:             * in the hashMap, if so returns that and the name, which can be either with
0672:             * version string or without version string. <p/> If its not found and the
0673:             * name does not contain the version string in it then checks whether the default
0674:             * version of the module is available in the sytem for the given name, then returns
0675:             * that.
0676:             *
0677:             * @param name
0678:             * @return Returns ModuleDescription.
0679:             */
0680:            public AxisModule getModule(String name) {
0681:                AxisModule module = (AxisModule) allModules.get(name);
0682:                if (module != null) {
0683:                    return module;
0684:                }
0685:                // checks whether the version string seperator is not there in the
0686:                // module name
0687:                String moduleName = name;
0688:                String defaultModuleVersion = getDefaultModuleVersion(moduleName);
0689:                if (defaultModuleVersion != null) {
0690:                    module = (AxisModule) allModules.get(Utils.getModuleName(
0691:                            moduleName, defaultModuleVersion));
0692:                    if (module != null) {
0693:                        return module;
0694:                    }
0695:                }
0696:                return null;
0697:            }
0698:
0699:            /**
0700:             * Return the module having name=moduleName & version=moduleVersion
0701:             *
0702:             * @param moduleName    The module name
0703:             * @param moduleVersion The version of the module
0704:             * @return The AxisModule having name=moduleName & version=moduleVersion
0705:             */
0706:            public AxisModule getModule(String moduleName, String moduleVersion) {
0707:                if (moduleVersion == null && moduleVersion.trim().length() == 0) {
0708:                    moduleVersion = getDefaultModuleVersion(moduleName);
0709:                }
0710:                return (AxisModule) allModules.get(Utils.getModuleName(
0711:                        moduleName, moduleVersion));
0712:            }
0713:
0714:            /**
0715:             * The class loader that becomes the parent of all the modules
0716:             *
0717:             * @return
0718:             */
0719:            public ClassLoader getModuleClassLoader() {
0720:                return this .moduleClassLoader;
0721:            }
0722:
0723:            public ModuleConfiguration getModuleConfig(String moduleName) {
0724:                return (ModuleConfiguration) moduleConfigmap.get(moduleName);
0725:            }
0726:
0727:            /**
0728:             * @return Returns HashMap.
0729:             */
0730:            public HashMap getModules() {
0731:                return allModules;
0732:            }
0733:
0734:            /**
0735:             * Get a list of the global modules
0736:             *
0737:             * @return the global module list.  BE CAREFUL, this list is mutable.
0738:             * @deprecated please use addGlobalModule()
0739:             */
0740:            public List getGlobalModules() {
0741:                return globalModuleList;
0742:            }
0743:
0744:            /**
0745:             * @return Returns ArrayList.
0746:             */
0747:            public ArrayList getOutFaultFlowPhases() {
0748:                return outFaultPhases;
0749:            }
0750:
0751:            public PhasesInfo getPhasesInfo() {
0752:                return phasesinfo;
0753:            }
0754:
0755:            public URL getRepository() {
0756:                return axis2Repository;
0757:            }
0758:
0759:            /**
0760:             * Method getService.
0761:             *
0762:             * @param name
0763:             * @return Returns AxisService.
0764:             */
0765:            public AxisService getService(String name) throws AxisFault {
0766:                AxisService axisService = (AxisService) allServices.get(name);
0767:                if (axisService != null) {
0768:                    if (axisService.isActive()) {
0769:                        return axisService;
0770:                    } else {
0771:                        throw new AxisFault(Messages.getMessage(
0772:                                "serviceinactive", name));
0773:                    }
0774:                } else {
0775:                    axisService = (AxisService) allEndpoints.get(name);
0776:                    if (axisService != null) {
0777:                        if (axisService.isActive()) {
0778:                            return axisService;
0779:                        } else {
0780:                            throw new AxisFault(Messages.getMessage(
0781:                                    "serviceinactive", name));
0782:                        }
0783:                    }
0784:                }
0785:                return null;
0786:            }
0787:
0788:            /**
0789:             * Service can start and stop, once stopped it cannot be accessed, so we
0790:             * need a way to get the service even if service is not active.
0791:             *
0792:             * @return AxisService
0793:             */
0794:            public AxisService getServiceForActivation(String serviceName) {
0795:                AxisService axisService = (AxisService) allServices
0796:                        .get(serviceName);
0797:                if (axisService != null) {
0798:                    return axisService;
0799:                } else {
0800:                    return null;
0801:                }
0802:            }
0803:
0804:            // The class loader that becomes the parent of all the services
0805:            public ClassLoader getServiceClassLoader() {
0806:                return this .serviceClassLoader;
0807:            }
0808:
0809:            public AxisServiceGroup getServiceGroup(
0810:                    String serviceNameAndGroupString) {
0811:                // return (AxisServiceGroup)
0812:                // serviceGroups.get(serviceNameAndGroupString);
0813:                return (AxisServiceGroup) getChild(serviceNameAndGroupString);
0814:            }
0815:
0816:            public Iterator getServiceGroups() {
0817:                // return serviceGroups.values().iterator();
0818:                return getChildren();
0819:            }
0820:
0821:            // To get all the services in the system
0822:            public HashMap getServices() {
0823:                return allServices;
0824:            }
0825:
0826:            // The class loader which become the top most parent of all the modules and
0827:            // services
0828:            public ClassLoader getSystemClassLoader() {
0829:                return this .systemClassLoader;
0830:            }
0831:
0832:            public TransportInDescription getTransportIn(String name) {
0833:                return (TransportInDescription) transportsIn.get(name);
0834:            }
0835:
0836:            public TransportOutDescription getTransportOut(String name) {
0837:                return (TransportOutDescription) transportsOut.get(name);
0838:            }
0839:
0840:            public HashMap getTransportsIn() {
0841:                return transportsIn;
0842:            }
0843:
0844:            public HashMap getTransportsOut() {
0845:                return transportsOut;
0846:            }
0847:
0848:            public boolean isEngaged(String moduleId) {
0849:                AxisModule module = getModule(moduleId);
0850:                if (module == null) {
0851:                    return false;
0852:                }
0853:                boolean isEngaged = super .isEngaged(module);
0854:                if (!isEngaged) {
0855:                    AxisModule defaultModule = getDefaultModule(moduleId);
0856:                    isEngaged = engagedModules != null
0857:                            && engagedModules.values().contains(defaultModule);
0858:                }
0859:                return isEngaged;
0860:            }
0861:
0862:            public boolean isEngaged(AxisModule axisModule) {
0863:                boolean isEngaged = super .isEngaged(axisModule);
0864:                if (!isEngaged) {
0865:                    isEngaged = engagedModules != null
0866:                            && engagedModules.values().contains(axisModule);
0867:                }
0868:                return isEngaged;
0869:            }
0870:
0871:            public void setGlobalOutPhase(ArrayList outPhases) {
0872:                this .outPhases = outPhases;
0873:            }
0874:
0875:            /**
0876:             * @param list
0877:             */
0878:            public void setInFaultPhases(ArrayList list) {
0879:                inFaultPhases = list;
0880:            }
0881:
0882:            public void setInPhasesUptoAndIncludingPostDispatch(
0883:                    ArrayList inPhasesUptoAndIncludingPostDispatch) {
0884:                this .inPhasesUptoAndIncludingPostDispatch = inPhasesUptoAndIncludingPostDispatch;
0885:            }
0886:
0887:            public void setModuleClassLoader(ClassLoader classLoader) {
0888:                this .moduleClassLoader = classLoader;
0889:            }
0890:
0891:            /**
0892:             * @param list
0893:             */
0894:            public void setOutFaultPhases(ArrayList list) {
0895:                outFaultPhases = list;
0896:            }
0897:
0898:            public void setPhasesInfo(PhasesInfo phasesInfo) {
0899:                this .phasesinfo = phasesInfo;
0900:            }
0901:
0902:            public void setRepository(URL axis2Repository) {
0903:                this .axis2Repository = axis2Repository;
0904:            }
0905:
0906:            public void setServiceClassLoader(ClassLoader classLoader) {
0907:                this .serviceClassLoader = classLoader;
0908:            }
0909:
0910:            public void setSystemClassLoader(ClassLoader classLoader) {
0911:                this .systemClassLoader = classLoader;
0912:            }
0913:
0914:            /**
0915:             * Adds a default module version, which can be done either programmatically
0916:             * or by using axis2.xml. The default module version is important if user
0917:             * asks to engage a module without given version ID, in which case,
0918:             * the default version is engaged.
0919:             *
0920:             * @param moduleName
0921:             * @param moduleVersion
0922:             */
0923:            public void addDefaultModuleVersion(String moduleName,
0924:                    String moduleVersion) {
0925:                if (nameToversionMap.get(moduleName) == null) {
0926:                    nameToversionMap.put(moduleName, moduleVersion);
0927:                }
0928:            }
0929:
0930:            public String getDefaultModuleVersion(String moduleName) {
0931:                return (String) nameToversionMap.get(moduleName);
0932:            }
0933:
0934:            public AxisModule getDefaultModule(String moduleName) {
0935:                String defaultModuleVersion = getDefaultModuleVersion(moduleName);
0936:                if (defaultModuleVersion == null) {
0937:                    return (AxisModule) allModules.get(moduleName);
0938:                } else {
0939:                    return (AxisModule) allModules.get(moduleName + "-"
0940:                            + defaultModuleVersion);
0941:                }
0942:            }
0943:
0944:            public ClusterManager getClusterManager() {
0945:                return clusterManager;
0946:            }
0947:
0948:            public void setClusterManager(ClusterManager clusterManager) {
0949:                this .clusterManager = clusterManager;
0950:            }
0951:
0952:            public Object getKey() {
0953:                return toString();
0954:            }
0955:
0956:            public void stopService(String serviceName) throws AxisFault {
0957:                AxisService service = (AxisService) allServices
0958:                        .get(serviceName);
0959:                if (service == null) {
0960:                    throw new AxisFault(Messages.getMessage(
0961:                            "servicenamenotvalid", serviceName));
0962:                }
0963:                service.setActive(false);
0964:                notifyObservers(AxisEvent.SERVICE_STOP, service);
0965:            }
0966:
0967:            public void startService(String serviceName) throws AxisFault {
0968:                AxisService service = (AxisService) allServices
0969:                        .get(serviceName);
0970:                if (service == null) {
0971:                    throw new AxisFault(Messages.getMessage(
0972:                            "servicenamenotvalid", serviceName));
0973:                }
0974:                service.setActive(true);
0975:                notifyObservers(AxisEvent.SERVICE_START, service);
0976:            }
0977:
0978:            public List getModulesForPolicyNamesapce(String namesapce) {
0979:                return (List) policySupportedModules.get(namesapce);
0980:            }
0981:
0982:            public void registerModulePolicySupport(AxisModule axisModule) {
0983:                String[] namespaces = axisModule.getSupportedPolicyNamespaces();
0984:
0985:                if (namespaces == null) {
0986:                    return;
0987:                }
0988:
0989:                List modulesList;
0990:
0991:                for (int i = 0; i < namespaces.length; i++) {
0992:                    modulesList = (List) policySupportedModules
0993:                            .get(namespaces[i]);
0994:
0995:                    if (modulesList != null) {
0996:                        modulesList.add(axisModule);
0997:                    } else {
0998:                        modulesList = new ArrayList();
0999:                        modulesList.add(axisModule);
1000:                        policySupportedModules.put(namespaces[i], modulesList);
1001:                    }
1002:                }
1003:            }
1004:
1005:            public void registerLocalPolicyAssertions(AxisModule axisModule) {
1006:                QName[] localPolicyAssertions = axisModule
1007:                        .getLocalPolicyAssertions();
1008:
1009:                if (localPolicyAssertions == null) {
1010:                    return;
1011:                }
1012:
1013:                for (int i = 0; i < localPolicyAssertions.length; i++) {
1014:                    addLocalPolicyAssertion(localPolicyAssertions[i]);
1015:                }
1016:            }
1017:
1018:            public ArrayList getObserversList() {
1019:                return observersList;
1020:            }
1021:
1022:            public boolean isStart() {
1023:                return start;
1024:            }
1025:
1026:            public void setStart(boolean start) {
1027:                this .start = start;
1028:            }
1029:
1030:            /**
1031:             * getTargetResolverChain returns an instance of
1032:             * TargetResolver which iterates over the registered
1033:             * TargetResolvers, calling each one in turn when
1034:             * resolveTarget is called.
1035:             */
1036:            public TargetResolver getTargetResolverChain() {
1037:                if (targetResolvers.isEmpty()) {
1038:                    return null;
1039:                }
1040:                return new TargetResolver() {
1041:                    public void resolveTarget(MessageContext messageContext) {
1042:                        Iterator iter = targetResolvers.iterator();
1043:                        while (iter.hasNext()) {
1044:                            TargetResolver tr = (TargetResolver) iter.next();
1045:                            tr.resolveTarget(messageContext);
1046:                        }
1047:                    }
1048:                };
1049:            }
1050:
1051:            public void addTargetResolver(TargetResolver tr) {
1052:                targetResolvers.add(tr);
1053:            }
1054:
1055:            public void addLocalPolicyAssertion(QName name) {
1056:                this .localPolicyAssertions.add(name);
1057:            }
1058:
1059:            public List getLocalPolicyAssertions() {
1060:                return this .localPolicyAssertions;
1061:            }
1062:
1063:            public void removeLocalPolicyAssertion(QName name) {
1064:                this .localPolicyAssertions.remove(name);
1065:            }
1066:
1067:            public boolean isAssertionLocal(QName name) {
1068:                return this .localPolicyAssertions.contains(name);
1069:            }
1070:
1071:            /**
1072:             * Allows to define/configure Data Locator for specified dialect at Axis 2 Configuration.
1073:             *
1074:             * @param dialect-  an absolute URI represents the format and version of data
1075:             * @param classname - class name of the Data Locator configured to support retrieval
1076:             *                  for the specified dialect.
1077:             */
1078:            public void addDataLocatorClassNames(String dialect,
1079:                    String classname) {
1080:                dataLocatorClassNames.put(dialect, classname);
1081:            }
1082:
1083:            /**
1084:             * For internal used only! To store instance of DataLocator when it is first loaded. This allows to
1085:             * reuse of the DataLocator after it is initially loaded.
1086:             *
1087:             * @param dialect-    an absolute URI represents the format and version of data
1088:             * @param dataLocator - specified an DataLocator instance  to support retrieval
1089:             *                    of the specified dialect.
1090:             */
1091:            public void addDataLocator(String dialect,
1092:                    AxisDataLocator dataLocator) {
1093:                dataLocators.put(dialect, dataLocator);
1094:            }
1095:
1096:            /**
1097:             * Return DataLocator instance for specified dialect.
1098:             */
1099:            public AxisDataLocator getDataLocator(String dialect) {
1100:                return (AxisDataLocator) dataLocators.get(dialect);
1101:            }
1102:
1103:            /**
1104:             * Return classname of DataLocator configured for specified dialect.
1105:             */
1106:            public String getDataLocatorClassName(String dialect) {
1107:                return (String) dataLocatorClassNames.get(dialect);
1108:            }
1109:
1110:            /**
1111:             * Checks whether the system pre-defined phases
1112:             * for all the flows, have been changed. If they have been changed, throws a DeploymentException.
1113:             *
1114:             * @throws org.apache.axis2.deployment.DeploymentException
1115:             *
1116:             */
1117:            public void validateSystemPredefinedPhases()
1118:                    throws DeploymentException {
1119:                PhasesInfo phasesInfo = getPhasesInfo();
1120:                setInPhasesUptoAndIncludingPostDispatch(phasesInfo
1121:                        .getGlobalInflow());
1122:                setInFaultPhases(phasesInfo.getGlobalInFaultPhases());
1123:                setGlobalOutPhase(phasesInfo.getGlobalOutPhaseList());
1124:                setOutFaultPhases(phasesInfo.getOUT_FaultPhases());
1125:            }
1126:
1127:            public AxisConfigurator getConfigurator() {
1128:                return configurator;
1129:            }
1130:
1131:            public void setConfigurator(AxisConfigurator configurator) {
1132:                this .configurator = configurator;
1133:            }
1134:
1135:            public void cleanup() {
1136:                if (configurator != null) {
1137:                    configurator.cleanup();
1138:                }
1139:            }
1140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.