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.endpoints.dispatch;
21:
22: import org.apache.synapse.MessageContext;
23: import org.apache.synapse.endpoints.Endpoint;
24:
25: /**
26: * Defines the behavior of session dispatchers. There can be two dispatcher types. Server initiated
27: * session dispatchers and client initiated session dispatchers. In the former one, server generates
28: * the session ID and sends it to the client in the first RESPONSE. In the later case, client should
29: * generate the session ID and send it to the server in the first REQUEST. A dispatcher object will
30: * be created for each session affinity load balance endpoint.
31: */
32: public interface Dispatcher {
33:
34: /**
35: * Dispatcher should check the session id pattern in the synapseMessageContext and return the
36: * matching endpoint for that session id, if available. If the session id in the given
37: * synapseMessageContext is not found it should return null.
38: *
39: * @param synCtx client -> esb message context.
40: * @return Endpoint Endpoint associated with this session.
41: */
42: public Endpoint getEndpoint(MessageContext synCtx,
43: DispatcherContext dispatcherContext);
44:
45: /**
46: * Updates the session maps. This will be called in the first client -> synapse -> server flow
47: * for client initiated sessions. For server initiated sessions, this will be called in the first
48: * server -> synapse -> client flow.
49: *
50: * @param synCtx SynapseMessageContext
51: * @param endpoint Selected endpoint for this session.
52: */
53: public void updateSession(MessageContext synCtx,
54: DispatcherContext dispatcherContext, Endpoint endpoint);
55:
56: /**
57: * Removes the session belonging to the given message context.
58: *
59: * @param synCtx MessageContext containing an session ID.
60: */
61: public void unbind(MessageContext synCtx,
62: DispatcherContext dispatcherContext);
63:
64: /**
65: * Determine whether the session supported by the implementing dispatcher is initiated by the
66: * server (e.g. soap session) or by the client. This can be used for optimizing session updates.
67: *
68: * @return true, if the session is initiated by the server. false, otherwise.
69: */
70: public boolean isServerInitiatedSession();
71: }
|