mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-02 19:27:57 +08:00
App.getInstance() added
This commit is contained in:
parent
4d84c324df
commit
e00befbc87
@ -101,8 +101,8 @@ values ('60885987-1b61-4247-94c7-dff348347f93', current_timestamp, 0, 'admin', '
|
||||
insert into SEC_PROFILE (ID, CREATE_TS, VERSION, NAME, USER_ID)
|
||||
values ('bf83541f-f610-46f4-a268-dff348347f93', current_timestamp, 0, 'Default', '60885987-1b61-4247-94c7-dff348347f93');
|
||||
|
||||
/*insert into SEC_PROFILE (ID, CREATE_TS, VERSION, NAME, USER_ID)
|
||||
values ('cc1e0bc4-1062-4218-a09f-dff348347f93', current_timestamp, 0, 'Test', '60885987-1b61-4247-94c7-dff348347f93');*/
|
||||
insert into SEC_PROFILE (ID, CREATE_TS, VERSION, NAME, USER_ID)
|
||||
values ('cc1e0bc4-1062-4218-a09f-dff348347f93', current_timestamp, 0, 'Test', '60885987-1b61-4247-94c7-dff348347f93');
|
||||
|
||||
insert into SEC_ROLE (ID, CREATE_TS, VERSION, NAME)
|
||||
values ('0c018061-b26f-4de2-a5be-dff348347f93', current_timestamp, 0, 'Administrators');
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns:ext="http://haulmont.com/schema/ant"
|
||||
name="cuba-web-war" default="noop" basedir=".">
|
||||
name="cuba-web-war" default="build-module" basedir=".">
|
||||
|
||||
<property name="project.dir" location="../.."/>
|
||||
<property name="root.dir" location="${project.dir}/.."/>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns:ext="http://haulmont.com/schema/ant"
|
||||
name="cuba-web" default="noop" basedir=".">
|
||||
name="cuba-web" default="build-module" basedir=".">
|
||||
|
||||
<property name="project.dir" location="../.."/>
|
||||
<property name="root.dir" location="${project.dir}/.."/>
|
||||
|
@ -26,6 +26,8 @@ public class App extends Application
|
||||
|
||||
private Connection connection;
|
||||
|
||||
private static ThreadLocal<App> currentApp = new ThreadLocal<App>();
|
||||
|
||||
static {
|
||||
SecurityAssociation.setServer();
|
||||
}
|
||||
@ -44,7 +46,11 @@ public class App extends Application
|
||||
appContext.addTransactionListener(new RequestListener());
|
||||
}
|
||||
|
||||
protected AppWindow getAppWindow() {
|
||||
public static App getInstance() {
|
||||
return currentApp.get();
|
||||
}
|
||||
|
||||
public AppWindow getAppWindow() {
|
||||
return new AppWindow(this);
|
||||
}
|
||||
|
||||
@ -59,6 +65,9 @@ public class App extends Application
|
||||
HttpServletRequest request = (HttpServletRequest) transactionData;
|
||||
log.trace("requestStart: " + request + " from " + request.getRemoteAddr());
|
||||
}
|
||||
if (application == App.this) {
|
||||
currentApp.set((App) application);
|
||||
}
|
||||
UserSession userSession = connection.getSession();
|
||||
if (userSession != null) {
|
||||
SecurityAssociation.setPrincipal(new SimplePrincipal(userSession.getLogin()));
|
||||
@ -67,6 +76,10 @@ public class App extends Application
|
||||
}
|
||||
|
||||
public void transactionEnd(Application application, Object transactionData) {
|
||||
if (application == App.this) {
|
||||
currentApp.set(null);
|
||||
currentApp.remove();
|
||||
}
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("requestEnd: " + transactionData);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user