View Javadoc

1   /*
2    * $Id: AxisMuleSession.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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  package org.mule.providers.soap.axis.extensions;
11  
12  import org.mule.umo.UMOSession;
13  
14  import java.util.Enumeration;
15  
16  import org.apache.axis.session.Session;
17  import org.apache.commons.collections.iterators.IteratorEnumeration;
18  
19  /**
20   * Provides an adapter to a MuleSession so that Axis can write to the session
21   */
22  public class AxisMuleSession implements Session
23  {
24  
25      private UMOSession session;
26      private Object lock = new Object();
27  
28      public AxisMuleSession(UMOSession session)
29      {
30          this.session = session;
31      }
32  
33      public Object get(String string)
34      {
35          synchronized(lock)
36          {
37              return session.getProperty(string);
38          }
39      }
40  
41      public void set(String string, Object object)
42      {
43          synchronized(lock)
44          {
45              session.setProperty(string, object);
46          }
47      }
48  
49      public void remove(String string)
50      {
51          synchronized(lock)
52          {
53              session.removeProperty(string);
54          }
55      }
56  
57      public Enumeration getKeys()
58      {
59          synchronized(lock)
60          {
61              return new IteratorEnumeration(session.getPropertyNames());
62          }
63      }
64  
65      public void setTimeout(int i)
66      {
67           // TODO not supported
68      }
69  
70      public int getTimeout()
71      {
72          return 0;
73      }
74  
75      public void touch()
76      {
77          // nothing here to touch
78      }
79  
80      public void invalidate()
81      {
82          synchronized(lock)
83          {
84              session.setValid(false);
85          }
86      }
87  
88      public Object getLockObject()
89      {
90          return lock;
91      }
92  }