1 /* 2 * $Id: MuleSession.java 22686 2011-08-16 19:39:20Z pablo.lagreca $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com 5 * 6 * The software in this package is published under the terms of the CPAL v1.0 7 * license, a copy of which has been included with this distribution in the 8 * LICENSE.txt file. 9 */ 10 11 package org.mule.api; 12 13 import org.mule.api.construct.FlowConstruct; 14 import org.mule.api.security.SecurityContext; 15 16 import java.io.Serializable; 17 import java.util.Iterator; 18 import java.util.Set; 19 20 /** 21 * <code>MuleSession</code> is the context in which a request is executed. The 22 * session manages the marshalling of events to and from components This object is 23 * not usually referenced by client code directly. If needed Components should manage 24 * events via the <code>MuleEventContext</code> which is obtainable via the 25 * <code>UMOManager</code> or by implementing 26 * <code>org.mule.api.lifecycle.Callable</code>. 27 */ 28 29 public interface MuleSession extends Serializable 30 { 31 /** 32 * Returns the Service associated with the session in its current execution 33 * 34 * @return the Service associated with the session in its current execution 35 * @see FlowConstruct 36 */ 37 FlowConstruct getFlowConstruct(); 38 39 /** 40 * Sets the Service associated with the session in its current execution 41 * 42 * @see FlowConstruct 43 */ 44 void setFlowConstruct(FlowConstruct flowConstruct); 45 46 /** 47 * Determines if this session is valid. A session becomes invalid if an exception 48 * occurs while processing 49 * 50 * @return true if the service is functioning properly, false otherwise 51 */ 52 boolean isValid(); 53 54 /** 55 * Determines if this session is valid. A session becomes invalid if an exception 56 * occurs while processing 57 * 58 * @param value true if the service is functioning properly, false otherwise 59 */ 60 void setValid(boolean value); 61 62 /** 63 * Returns the unique id for this session 64 * 65 * @return the unique id for this session 66 */ 67 String getId(); 68 69 /** 70 * The security context for this session. If not null outbound, inbound and/or 71 * method invocations will be authenticated using this context 72 * 73 * @param context the context for this session or null if the request is not 74 * secure. 75 */ 76 void setSecurityContext(SecurityContext context); 77 78 /** 79 * The security context for this session. If not null outbound, inbound and/or 80 * method invocations will be authenticated using this context 81 * 82 * @return the context for this session or null if the request is not secure. 83 */ 84 SecurityContext getSecurityContext(); 85 86 /** 87 * Will set a session level property. These will either be stored and retrieved 88 * using the underlying transport mechanism of stored using a default mechanism 89 * 90 * @param key the key for the object data being stored on the session 91 * @param value the value of the session data 92 */ 93 void setProperty(String key, Object value); 94 95 /** 96 * Will retrieve a session level property. 97 * 98 * @param key the key for the object data being stored on the session 99 * @return the value of the session data or null if the property does not exist 100 */ 101 <T> T getProperty(Object key); 102 103 /** 104 * Will retrieve a session level property and remove it from the session 105 * 106 * @param key the key for the object data being stored on the session 107 * @return the value of the session data or null if the property does not exist 108 */ 109 Object removeProperty(Object key); 110 111 /** 112 * Returns an iterater of property keys for the session properties on this 113 * session 114 * 115 * @return an iterater of property keys for the session properties on this 116 * session 117 * @deprecated Use getPropertyNamesAsSet() instead 118 */ 119 Iterator getPropertyNames(); 120 121 /** 122 * @return property keys for all session properties 123 */ 124 Set<String> getPropertyNamesAsSet(); 125 126 /** 127 * Merge current session with an updated version 128 * Result session will contain all the properties from updatedSession 129 * plus those properties in the current session that couldn't be serialized 130 * In case updatedSession is null, then no change will be applied. 131 * 132 * @param updatedSession mule session with updated properties 133 */ 134 void merge(MuleSession updatedSession); 135 }