View Javadoc

1   /*
2    *  $Id: OmContext.java,v 1.6 2004/07/25 19:10:09 roku Exp $ 
3    *
4    *  Copyright 2004 University of Hannover
5    *
6    *  Licensed under the Apache License, Version 2.0 (the "License");
7    *  you may not use this file except in compliance with the License.
8    *  You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing, software
13   *  distributed under the License is distributed on an "AS IS" BASIS,
14   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *  See the License for the specific language governing permissions and
16   *  limitations under the License.
17   */
18  
19  package olr.om;
20  
21  import java.sql.Connection;
22  import java.sql.SQLException;
23  
24  
25  public final class OmContext
26  {
27      private static Connection connection;
28      private static RdfUser user = null;
29      
30      private OmContext() {}
31               
32      /***
33       * @return Returns the connection.
34       */
35      static Connection getConnection()
36      {
37          try 
38          {
39              assert(OmContext.connection != null
40                      && !OmContext.connection.isClosed());
41          }
42          catch(SQLException e) {}
43          
44          return OmContext.connection;
45      }
46      
47      /***
48       * @param connection The connection to set.
49       */
50      public static void setConnection(Connection connection)
51      {
52          OmContext.connection = connection;
53      }
54      
55      /***
56       * TODO Make only visible pacga wide
57       * @return Returns the user.
58       */
59      public static RdfUser getUser()
60      {
61          return OmContext.user;
62      }
63      
64      public static void setUser(RdfUser user) 
65      {
66          OmContext.user = user;
67      } 
68  }