View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.soap.axis.extensions;
8   
9   import org.mule.api.MuleSession;
10  
11  import java.util.Enumeration;
12  
13  import org.apache.commons.collections.iterators.IteratorEnumeration;
14  
15  /**
16   * Provides an adapter to a DefaultMuleSession so that Axis can write to the session
17   */
18  public class AxisMuleSession implements org.apache.axis.session.Session
19  {
20  
21      private MuleSession session;
22      private Object lock = new Object();
23  
24      public AxisMuleSession(MuleSession session)
25      {
26          this.session = session;
27      }
28  
29      public Object get(String string)
30      {
31          synchronized(lock)
32          {
33              return session.getProperty(string);
34          }
35      }
36  
37      public void set(String string, Object object)
38      {
39          synchronized(lock)
40          {
41              session.setProperty(string, object);
42          }
43      }
44  
45      public void remove(String string)
46      {
47          synchronized(lock)
48          {
49              session.removeProperty(string);
50          }
51      }
52  
53      public Enumeration getKeys()
54      {
55          synchronized(lock)
56          {
57              return new IteratorEnumeration(session.getPropertyNames());
58          }
59      }
60  
61      public void setTimeout(int i)
62      {
63           // TODO not supported
64      }
65  
66      public int getTimeout()
67      {
68          return 0;
69      }
70  
71      public void touch()
72      {
73          // nothing here to touch
74      }
75  
76      public void invalidate()
77      {
78          synchronized(lock)
79          {
80              session.setValid(false);
81          }
82      }
83  
84      public Object getLockObject()
85      {
86          return lock;
87      }
88  }