01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.synapse.core.axis2;
21:
22: import org.apache.axis2.AxisFault;
23: import org.apache.commons.logging.Log;
24: import org.apache.commons.logging.LogFactory;
25: import org.apache.synapse.SynapseConstants;
26: import org.apache.synapse.MessageContext;
27: import org.apache.synapse.SynapseException;
28: import org.apache.synapse.config.SynapseConfiguration;
29: import org.apache.synapse.core.SynapseEnvironment;
30:
31: /**
32: * The MessageContext needs to be set up and then is used by the SynapseMessageReceiver to inject messages.
33: * This class is used by the SynapseMessageReceiver to find the environment. The env is stored in a Parameter to the Axis2 config
34: */
35: public class MessageContextCreatorForAxis2 {
36:
37: private static final Log log = LogFactory
38: .getLog(MessageContextCreatorForAxis2.class);
39:
40: private static SynapseConfiguration synCfg = null;
41: private static SynapseEnvironment synEnv = null;
42:
43: public static MessageContext getSynapseMessageContext(
44: org.apache.axis2.context.MessageContext axisMsgCtx)
45: throws AxisFault {
46:
47: if (synCfg == null || synEnv == null) {
48: String msg = "Synapse environment has not initialized properly..";
49: log.fatal(msg);
50: throw new SynapseException(msg);
51: }
52:
53: return new Axis2MessageContext(axisMsgCtx, synCfg, synEnv);
54: }
55:
56: public static void setSynConfig(SynapseConfiguration synCfg) {
57: MessageContextCreatorForAxis2.synCfg = synCfg;
58: }
59:
60: public static void setSynEnv(SynapseEnvironment synEnv) {
61: MessageContextCreatorForAxis2.synEnv = synEnv;
62: }
63: }
|