View Javadoc

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