Source Code Cross Referenced for SynapseModule.java in  » ESB » synapse » org » apache » synapse » handler » 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 » ESB » synapse » org.apache.synapse.handler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one
003:         *  or more contributor license agreements.  See the NOTICE file
004:         *  distributed with this work for additional information
005:         *  regarding copyright ownership.  The ASF licenses this file
006:         *  to you under the Apache License, Version 2.0 (the
007:         *  "License"); you may not use this file except in compliance
008:         *  with the License.  You may obtain a copy of the License at
009:         *
010:         *   http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         *  Unless required by applicable law or agreed to in writing,
013:         *  software distributed under the License is distributed on an
014:         *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         *  KIND, either express or implied.  See the License for the
016:         *  specific language governing permissions and limitations
017:         *  under the License.
018:         */
019:
020:        package org.apache.synapse.handler;
021:
022:        import org.apache.axis2.modules.Module;
023:        import org.apache.axis2.context.ConfigurationContext;
024:        import org.apache.axis2.description.AxisModule;
025:        import org.apache.axis2.description.AxisDescription;
026:        import org.apache.axis2.description.Parameter;
027:        import org.apache.axis2.AxisFault;
028:        import org.apache.neethi.Assertion;
029:        import org.apache.neethi.Policy;
030:        import org.apache.synapse.SynapseConstants;
031:        import org.apache.synapse.SynapseException;
032:        import org.apache.synapse.config.SynapseConfiguration;
033:        import org.apache.synapse.core.axis2.SynapseInitializationModule;
034:        import org.apache.synapse.core.SynapseEnvironment;
035:        import org.apache.commons.logging.Log;
036:        import org.apache.commons.logging.LogFactory;
037:
038:        import java.io.File;
039:
040:        /**
041:         * This will be the Module class for the Synapse handler based mediations inside axis2 server. This
042:         * will just set the default system property of SYNAPSE_XML to the repository/conf/synapse.xml in
043:         * the axis2 servers repository and call the normal SynapseInitializationModule.init()
044:         *
045:         * @see org.apache.synapse.core.axis2.SynapseInitializationModule
046:         */
047:        public class SynapseModule implements  Module {
048:
049:            /**
050:             * Log variable to be used as the logging appender
051:             */
052:            private static final Log log = LogFactory
053:                    .getLog(SynapseModule.class);
054:
055:            /**
056:             * Normal SynapseInitializationModule which initiates the Synapse
057:             */
058:            private SynapseInitializationModule initializationModule = null;
059:
060:            /**
061:             * This method will call the normal initiation after setting the SYNAPSE_XML file to get from
062:             * the axis2 respository/conf folder
063:             * 
064:             * @param configurationContext - ConfigurationContext of the Axis2 env
065:             * @param axisModule - AxisModule describing handler initializationModule of Synapse
066:             * @throws AxisFault - incase of a failure in initiation
067:             */
068:            public void init(ConfigurationContext configurationContext,
069:                    AxisModule axisModule) throws AxisFault {
070:                if (System.getProperty(SynapseConstants.SYNAPSE_XML) == null) {
071:                    System.setProperty(SynapseConstants.SYNAPSE_XML,
072:                            configurationContext.getAxisConfiguration()
073:                                    .getRepository().getPath()
074:                                    + "/conf/synapse.xml");
075:                }
076:                if (new File(System.getProperty(SynapseConstants.SYNAPSE_XML))
077:                        .exists()) {
078:                    initializationModule = new org.apache.synapse.core.axis2.SynapseInitializationModule();
079:                    initializationModule.init(configurationContext, axisModule);
080:
081:                    // now initialize SynapseConfig
082:                    Parameter synEnv = configurationContext
083:                            .getAxisConfiguration().getParameter(
084:                                    SynapseConstants.SYNAPSE_ENV);
085:                    Parameter synCfg = configurationContext
086:                            .getAxisConfiguration().getParameter(
087:                                    SynapseConstants.SYNAPSE_CONFIG);
088:                    String message = "Unable to initialize the Synapse Configuration : Can not find the ";
089:                    if (synCfg == null
090:                            || synCfg.getValue() == null
091:                            || !(synCfg.getValue() instanceof  SynapseConfiguration)) {
092:                        log.fatal(message + "Synapse Configuration");
093:                        throw new SynapseException(message
094:                                + "Synapse Configuration");
095:                    }
096:
097:                    if (synEnv == null
098:                            || synEnv.getValue() == null
099:                            || !(synEnv.getValue() instanceof  SynapseEnvironment)) {
100:                        log.fatal(message + "Synapse Environment");
101:                        throw new SynapseException(message
102:                                + "Synapse Environment");
103:                    }
104:
105:                    ((SynapseConfiguration) synCfg.getValue())
106:                            .init((SynapseEnvironment) synEnv.getValue());
107:                } else {
108:                    handleException("Unable to initialize the Synapse initializationModule. Couldn't "
109:                            + "find the configuration file in the location "
110:                            + System.getProperty(SynapseConstants.SYNAPSE_XML));
111:                }
112:            }
113:
114:            /**
115:             * Just do what the main SynapseInitializationModule tells you to do
116:             * 
117:             * @param axisDescription
118:             * @throws AxisFault
119:             */
120:            public void engageNotify(AxisDescription axisDescription)
121:                    throws AxisFault {
122:                if (initializationModule != null) {
123:                    initializationModule.engageNotify(axisDescription);
124:                } else {
125:                    handleException("Couldn't find the initializationModule");
126:                }
127:            }
128:
129:            /**
130:             * Just do what the main SynapseInitializationModule tells you to do
131:             * 
132:             * @param assertion
133:             * @return
134:             */
135:            public boolean canSupportAssertion(Assertion assertion) {
136:                if (initializationModule != null) {
137:                    return initializationModule.canSupportAssertion(assertion);
138:                } else {
139:                    return false;
140:                }
141:            }
142:
143:            /**
144:             * Just do what the main SynapseInitializationModule tells you to do
145:             * 
146:             * @param policy
147:             * @param axisDescription
148:             * @throws AxisFault
149:             */
150:            public void applyPolicy(Policy policy,
151:                    AxisDescription axisDescription) throws AxisFault {
152:                if (initializationModule != null) {
153:                    initializationModule.applyPolicy(policy, axisDescription);
154:                } else {
155:                    handleException("Couldn't find the initializationModule");
156:                }
157:            }
158:
159:            /**
160:             * Just do what the main SynapseInitializationModule tells you to do
161:             * 
162:             * @param configurationContext
163:             * @throws AxisFault
164:             */
165:            public void shutdown(ConfigurationContext configurationContext)
166:                    throws AxisFault {
167:                if (initializationModule != null) {
168:                    initializationModule.shutdown(configurationContext);
169:                } else {
170:                    handleException("Couldn't find the initializationModule");
171:                }
172:            }
173:
174:            private void handleException(String message) throws AxisFault {
175:                log.error(message);
176:                throw new AxisFault(message);
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.