App.getInstance() added

This commit is contained in:
Konstantin Krivopustov 2008-12-08 12:18:25 +00:00
parent 4d84c324df
commit e00befbc87
4 changed files with 18 additions and 5 deletions

View File

@ -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');

View File

@ -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}/.."/>

View File

@ -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}/.."/>

View File

@ -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);
}