Lines 107-112
Link Here
|
107 |
protected String dataSourceName = null; |
107 |
protected String dataSourceName = null; |
108 |
|
108 |
|
109 |
/** |
109 |
/** |
|
|
110 |
* Context local datasource. |
111 |
*/ |
112 |
protected boolean localDataSource = false; |
113 |
|
114 |
/** |
110 |
* DataSource to use |
115 |
* DataSource to use |
111 |
*/ |
116 |
*/ |
112 |
protected DataSource dataSource = null; |
117 |
protected DataSource dataSource = null; |
Lines 454-460
Link Here
|
454 |
return this.dataSourceName; |
459 |
return this.dataSourceName; |
455 |
} |
460 |
} |
456 |
|
461 |
|
|
|
462 |
/** |
463 |
* @return if the datasource will be looked up in the webapp JNDI Context. |
464 |
*/ |
465 |
public boolean getLocalDataSource() { |
466 |
return localDataSource; |
467 |
} |
457 |
|
468 |
|
|
|
469 |
/** |
470 |
* Set to true to cause the datasource to be looked up in the webapp JNDI |
471 |
* Context. |
472 |
* |
473 |
* @param localDataSource the new flag value |
474 |
*/ |
475 |
public void setLocalDataSource(boolean localDataSource) { |
476 |
this.localDataSource = localDataSource; |
477 |
} |
478 |
|
479 |
|
458 |
// --------------------------------------------------------- Public Methods |
480 |
// --------------------------------------------------------- Public Methods |
459 |
|
481 |
|
460 |
@Override |
482 |
@Override |
Lines 867-872
Link Here
|
867 |
return dbConnection; |
889 |
return dbConnection; |
868 |
|
890 |
|
869 |
if (dataSourceName != null && dataSource == null) { |
891 |
if (dataSourceName != null && dataSource == null) { |
|
|
892 |
org.apache.catalina.Context context = getManager().getContext(); |
893 |
ClassLoader oldThreadContextCL = null; |
894 |
if (localDataSource) { |
895 |
oldThreadContextCL = context.bind(Globals.IS_SECURITY_ENABLED, null); |
896 |
} |
897 |
|
870 |
Context initCtx; |
898 |
Context initCtx; |
871 |
try { |
899 |
try { |
872 |
initCtx = new InitialContext(); |
900 |
initCtx = new InitialContext(); |
Lines 873-882
Link Here
|
873 |
Context envCtx = (Context) initCtx.lookup("java:comp/env"); |
901 |
Context envCtx = (Context) initCtx.lookup("java:comp/env"); |
874 |
this.dataSource = (DataSource) envCtx.lookup(this.dataSourceName); |
902 |
this.dataSource = (DataSource) envCtx.lookup(this.dataSourceName); |
875 |
} catch (NamingException e) { |
903 |
} catch (NamingException e) { |
876 |
manager.getContext().getLogger().error( |
904 |
context.getLogger().error( |
877 |
sm.getString(getStoreName() + ".wrongDataSource", |
905 |
sm.getString(getStoreName() + ".wrongDataSource", |
878 |
this.dataSourceName), e); |
906 |
this.dataSourceName), e); |
879 |
} |
907 |
} finally { |
|
|
908 |
if (localDataSource) { |
909 |
context.unbind(Globals.IS_SECURITY_ENABLED, oldThreadContextCL); |
910 |
} |
911 |
} |
880 |
} |
912 |
} |
881 |
|
913 |
|
882 |
if (dataSource != null) { |
914 |
if (dataSource != null) { |