forked from tada/pljava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionManager.java
More file actions
43 lines (39 loc) · 1014 Bytes
/
Copy pathSessionManager.java
File metadata and controls
43 lines (39 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Copyright (c) 2004-2019 Tada AB and other contributors, as listed below.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the The BSD 3-Clause License
* which accompanies this distribution, and is available at
* http://opensource.org/licenses/BSD-3-Clause
*
* Contributors:
* Tada AB
* Chapman Flack
*/
package org.postgresql.pljava;
import java.sql.SQLException;
import static java.util.ServiceLoader.load;
/**
* The SessionManager makes the current {@link Session} available to the
* caller.
* @author Thomas Hallgren
*/
public class SessionManager
{
private static Session s_session;
/**
* Returns the current session.
*/
public static Session current()
throws SQLException
{
if(s_session == null)
{
s_session = load(
Session.class.getModule().getLayer(), Session.class)
.findFirst().orElseThrow(() -> new SQLException(
"could not obtain PL/Java Session object"));
}
return s_session;
}
}