From 128c33cd9b6c62fce596f2172ac09845087fe191 Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Sat, 4 May 2002 08:20:13 +0000 Subject: [PATCH] beginning the underlying service architecture migration - the "global site" is the lowest level component, now contains the DataPool...will gradually supplant EnvEngine and the rest --- .../venice/core/impl/AdminOperationsImpl.java | 4 +- .../core/impl/AdminUserContextImpl.java | 22 +- .../venice/core/impl/AdvertisementImpl.java | 4 +- .../core/impl/BackgroundCommunityPurge.java | 2 +- .../core/impl/BackgroundConferencePurge.java | 2 +- .../core/impl/BackgroundTopicPurge.java | 2 +- .../core/impl/CategoryDescriptorImpl.java | 10 +- .../venice/core/impl/CommunityCoreData.java | 54 +-- .../core/impl/CommunityUserContextImpl.java | 26 +- .../impl/ConferenceCommunityContextImpl.java | 10 +- .../venice/core/impl/ConferenceCoreData.java | 38 +- .../core/impl/ConferenceUserContextImpl.java | 34 +- .../venice/core/impl/ContactInfoImpl.java | 2 +- .../venice/core/impl/ImageStore.java | 8 +- .../core/impl/PublishedMessageImpl.java | 8 +- .../core/impl/PublishedMessageTopicImpl.java | 2 +- .../core/impl/ServiceControlManager.java | 46 +- .../core/impl/SideBoxDescriptorImpl.java | 4 +- .../venice/core/impl/StaticCommService.java | 57 ++- .../impl/TopicMessageUserContextImpl.java | 28 +- .../core/impl/TopicUserContextImpl.java | 38 +- .../venice/core/impl/UserContextImpl.java | 42 +- .../venice/core/impl/VeniceEngineImpl.java | 64 ++- .../venice/core/internals/EnvEngine.java | 33 +- .../venice/core/internals/GlobalSiteImpl.java | 118 +++++ src/com/silverwrist/venice/db/DataPool.java | 26 +- .../venice/db/PostLinkRewriter.java | 11 +- src/com/silverwrist/venice/db/SQLUtil.java | 14 + .../venice/db/UserNameRewriter.java | 11 +- .../venice/db/WrappedConnection.java | 412 ++++++++++++++++++ .../silverwrist/venice/svc/CommService.java | 15 +- src/com/silverwrist/venice/svc/Service.java | 9 +- .../svc/internals/CommServiceInternal.java | 30 ++ .../venice/svc/internals/GlobalSite.java | 28 ++ .../ServiceInternal.java} | 18 +- 35 files changed, 921 insertions(+), 311 deletions(-) create mode 100644 src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java create mode 100644 src/com/silverwrist/venice/db/WrappedConnection.java create mode 100644 src/com/silverwrist/venice/svc/internals/CommServiceInternal.java create mode 100644 src/com/silverwrist/venice/svc/internals/GlobalSite.java rename src/com/silverwrist/venice/svc/{CommServiceSite.java => internals/ServiceInternal.java} (67%) diff --git a/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java b/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java index 6dc55c5..c4cb372 100644 --- a/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java +++ b/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java @@ -93,7 +93,7 @@ class AdminOperationsImpl implements AdminOperations } // end catch finally { // make sure the connection is released before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -120,7 +120,7 @@ class AdminOperationsImpl implements AdminOperations } // end catch finally { // make sure the connection is released before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/AdminUserContextImpl.java b/src/com/silverwrist/venice/core/impl/AdminUserContextImpl.java index d46d53f..71e693d 100644 --- a/src/com/silverwrist/venice/core/impl/AdminUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/AdminUserContextImpl.java @@ -140,7 +140,7 @@ class AdminUserContextImpl implements AdminUserContext finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -237,7 +237,7 @@ class AdminUserContextImpl implements AdminUserContext { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -280,7 +280,7 @@ class AdminUserContextImpl implements AdminUserContext { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -335,7 +335,7 @@ class AdminUserContextImpl implements AdminUserContext { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -378,7 +378,7 @@ class AdminUserContextImpl implements AdminUserContext { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -448,7 +448,7 @@ class AdminUserContextImpl implements AdminUserContext finally { // make sure the connection is released before we go AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end if @@ -484,7 +484,7 @@ class AdminUserContextImpl implements AdminUserContext { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -529,7 +529,7 @@ class AdminUserContextImpl implements AdminUserContext { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -574,7 +574,7 @@ class AdminUserContextImpl implements AdminUserContext { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -654,7 +654,7 @@ class AdminUserContextImpl implements AdminUserContext finally { // release the connection where necessary SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -689,7 +689,7 @@ class AdminUserContextImpl implements AdminUserContext finally { // release the connection where necessary SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/AdvertisementImpl.java b/src/com/silverwrist/venice/core/impl/AdvertisementImpl.java index d26c043..dce46f4 100644 --- a/src/com/silverwrist/venice/core/impl/AdvertisementImpl.java +++ b/src/com/silverwrist/venice/core/impl/AdvertisementImpl.java @@ -149,7 +149,7 @@ class AdvertisementImpl implements Advertisement finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -189,7 +189,7 @@ class AdvertisementImpl implements Advertisement finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/BackgroundCommunityPurge.java b/src/com/silverwrist/venice/core/impl/BackgroundCommunityPurge.java index e99a1f8..0394c4c 100644 --- a/src/com/silverwrist/venice/core/impl/BackgroundCommunityPurge.java +++ b/src/com/silverwrist/venice/core/impl/BackgroundCommunityPurge.java @@ -169,7 +169,7 @@ class BackgroundCommunityPurge implements Runnable finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/BackgroundConferencePurge.java b/src/com/silverwrist/venice/core/impl/BackgroundConferencePurge.java index 3b64ff3..5ef1718 100644 --- a/src/com/silverwrist/venice/core/impl/BackgroundConferencePurge.java +++ b/src/com/silverwrist/venice/core/impl/BackgroundConferencePurge.java @@ -123,7 +123,7 @@ class BackgroundConferencePurge implements Runnable finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/BackgroundTopicPurge.java b/src/com/silverwrist/venice/core/impl/BackgroundTopicPurge.java index deb5fa3..18c6172 100644 --- a/src/com/silverwrist/venice/core/impl/BackgroundTopicPurge.java +++ b/src/com/silverwrist/venice/core/impl/BackgroundTopicPurge.java @@ -107,7 +107,7 @@ class BackgroundTopicPurge implements Runnable finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/CategoryDescriptorImpl.java b/src/com/silverwrist/venice/core/impl/CategoryDescriptorImpl.java index fa1a76b..dfb15d4 100644 --- a/src/com/silverwrist/venice/core/impl/CategoryDescriptorImpl.java +++ b/src/com/silverwrist/venice/core/impl/CategoryDescriptorImpl.java @@ -104,7 +104,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable } // end catch finally { // make sure and release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -284,7 +284,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable finally { // make sure and release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -417,7 +417,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable finally { // make sure and release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -497,7 +497,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -566,7 +566,7 @@ class CategoryDescriptorImpl implements CategoryDescriptor, Cloneable finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/CommunityCoreData.java b/src/com/silverwrist/venice/core/impl/CommunityCoreData.java index 4bb2a8c..bc22d53 100644 --- a/src/com/silverwrist/venice/core/impl/CommunityCoreData.java +++ b/src/com/silverwrist/venice/core/impl/CommunityCoreData.java @@ -180,7 +180,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -347,7 +347,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -547,7 +547,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -598,7 +598,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -704,7 +704,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -743,7 +743,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -782,7 +782,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -821,7 +821,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -857,7 +857,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -893,7 +893,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -929,7 +929,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -963,7 +963,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1017,7 +1017,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1062,7 +1062,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1104,7 +1104,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1144,7 +1144,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1183,7 +1183,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1267,7 +1267,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1359,7 +1359,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1400,7 +1400,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1572,7 +1572,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1668,7 +1668,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1727,7 +1727,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1772,7 +1772,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1851,7 +1851,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1934,7 +1934,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -2096,7 +2096,7 @@ class CommunityCoreData implements CommunityData, CommunityDataBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java b/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java index 8f75149..7343660 100644 --- a/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/CommunityUserContextImpl.java @@ -405,7 +405,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend } // end catch finally { // make sure we release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -546,8 +546,10 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend } // end if + /* XXX come back to this! if (svc.isLocked()) return; // can't modify the state of a locked service + */ getData().setServiceEnable(env,token,enable); @@ -1298,7 +1300,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend } // end catch finally { // make sure the connection is released before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1334,7 +1336,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend } // end catch finally { // make sure the connection is released before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1466,7 +1468,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1522,7 +1524,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1675,7 +1677,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1703,7 +1705,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend } // end catch finally { // make sure we release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1746,7 +1748,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1839,7 +1841,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1921,7 +1923,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1973,7 +1975,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -2020,7 +2022,7 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/ConferenceCommunityContextImpl.java b/src/com/silverwrist/venice/core/impl/ConferenceCommunityContextImpl.java index d4fd705..f5db0e6 100644 --- a/src/com/silverwrist/venice/core/impl/ConferenceCommunityContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/ConferenceCommunityContextImpl.java @@ -142,7 +142,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -455,7 +455,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -501,7 +501,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -568,7 +568,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -745,7 +745,7 @@ class ConferenceCommunityContextImpl implements ConferenceCommunityContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/ConferenceCoreData.java b/src/com/silverwrist/venice/core/impl/ConferenceCoreData.java index 6e77c9e..670749c 100644 --- a/src/com/silverwrist/venice/core/impl/ConferenceCoreData.java +++ b/src/com/silverwrist/venice/core/impl/ConferenceCoreData.java @@ -115,7 +115,7 @@ class ConferenceCoreData implements ConferenceData finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -323,7 +323,7 @@ class ConferenceCoreData implements ConferenceData finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -422,7 +422,7 @@ class ConferenceCoreData implements ConferenceData finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -472,7 +472,7 @@ class ConferenceCoreData implements ConferenceData finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -604,7 +604,7 @@ class ConferenceCoreData implements ConferenceData { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -651,7 +651,7 @@ class ConferenceCoreData implements ConferenceData { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -692,7 +692,7 @@ class ConferenceCoreData implements ConferenceData finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -757,7 +757,7 @@ class ConferenceCoreData implements ConferenceData { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -837,7 +837,7 @@ class ConferenceCoreData implements ConferenceData { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -920,7 +920,7 @@ class ConferenceCoreData implements ConferenceData { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -969,7 +969,7 @@ class ConferenceCoreData implements ConferenceData finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1075,7 +1075,7 @@ class ConferenceCoreData implements ConferenceData { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1213,7 +1213,7 @@ class ConferenceCoreData implements ConferenceData finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1253,7 +1253,7 @@ class ConferenceCoreData implements ConferenceData finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1343,7 +1343,7 @@ class ConferenceCoreData implements ConferenceData { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1428,7 +1428,7 @@ class ConferenceCoreData implements ConferenceData } // end catch finally { // make sure the connection is released before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1507,7 +1507,7 @@ class ConferenceCoreData implements ConferenceData finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1544,7 +1544,7 @@ class ConferenceCoreData implements ConferenceData finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1696,7 +1696,7 @@ class ConferenceCoreData implements ConferenceData { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java b/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java index d8280ff..bacac16 100644 --- a/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/ConferenceUserContextImpl.java @@ -815,7 +815,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -860,7 +860,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -973,7 +973,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1078,7 +1078,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1132,7 +1132,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1200,7 +1200,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1315,7 +1315,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1374,7 +1374,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1421,7 +1421,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1454,7 +1454,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1604,7 +1604,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1711,7 +1711,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1764,7 +1764,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -2025,7 +2025,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -2078,7 +2078,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -2131,7 +2131,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -2204,7 +2204,7 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/ContactInfoImpl.java b/src/com/silverwrist/venice/core/impl/ContactInfoImpl.java index e95e3a4..0fb277e 100644 --- a/src/com/silverwrist/venice/core/impl/ContactInfoImpl.java +++ b/src/com/silverwrist/venice/core/impl/ContactInfoImpl.java @@ -202,7 +202,7 @@ class ContactInfoImpl implements ContactInfo, Stashable } // end catch finally { // make sure we release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/ImageStore.java b/src/com/silverwrist/venice/core/impl/ImageStore.java index 0917347..1713160 100644 --- a/src/com/silverwrist/venice/core/impl/ImageStore.java +++ b/src/com/silverwrist/venice/core/impl/ImageStore.java @@ -130,7 +130,7 @@ class ImageStore implements BinaryData finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -177,7 +177,7 @@ class ImageStore implements BinaryData finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -242,7 +242,7 @@ class ImageStore implements BinaryData } // end catch finally { // make sure we release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -297,7 +297,7 @@ class ImageStore implements BinaryData } // end catch finally { // make sure we release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/PublishedMessageImpl.java b/src/com/silverwrist/venice/core/impl/PublishedMessageImpl.java index 4c6529e..2217ed8 100644 --- a/src/com/silverwrist/venice/core/impl/PublishedMessageImpl.java +++ b/src/com/silverwrist/venice/core/impl/PublishedMessageImpl.java @@ -177,7 +177,7 @@ class PublishedMessageImpl implements TopicMessageContext } // end catch finally { // make sure we release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -251,7 +251,7 @@ class PublishedMessageImpl implements TopicMessageContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -422,7 +422,7 @@ class PublishedMessageImpl implements TopicMessageContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -477,7 +477,7 @@ class PublishedMessageImpl implements TopicMessageContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/PublishedMessageTopicImpl.java b/src/com/silverwrist/venice/core/impl/PublishedMessageTopicImpl.java index dcbe5c5..a099f56 100644 --- a/src/com/silverwrist/venice/core/impl/PublishedMessageTopicImpl.java +++ b/src/com/silverwrist/venice/core/impl/PublishedMessageTopicImpl.java @@ -113,7 +113,7 @@ class PublishedMessageTopicImpl implements TopicContext finally { // release the connection SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/ServiceControlManager.java b/src/com/silverwrist/venice/core/impl/ServiceControlManager.java index 774fed5..47182cd 100644 --- a/src/com/silverwrist/venice/core/impl/ServiceControlManager.java +++ b/src/com/silverwrist/venice/core/impl/ServiceControlManager.java @@ -27,6 +27,7 @@ import com.silverwrist.venice.core.ServiceToken; import com.silverwrist.venice.except.*; import com.silverwrist.venice.security.*; import com.silverwrist.venice.svc.*; +import com.silverwrist.venice.svc.internal.*; import com.silverwrist.venice.util.XMLLoader; class ServiceControlManager implements ServiceControl @@ -46,19 +47,6 @@ class ServiceControlManager implements ServiceControl } // end class MyServiceToken - /*-------------------------------------------------------------------------------- - * Internal "Community Service Site" class - *-------------------------------------------------------------------------------- - */ - - class MyCommServiceSite implements CommServiceSite - { - MyCommServiceSite() - { // do nothing - } // end constructor - - } // end class MyCommServiceSite - /*-------------------------------------------------------------------------------- * Internal "Service Predicate" class *-------------------------------------------------------------------------------- @@ -66,7 +54,7 @@ class ServiceControlManager implements ServiceControl abstract class ServicePredicate { - public abstract boolean test(Service svc); + public abstract boolean test(ServiceInternal svc); } // end class ServicePredicate @@ -92,7 +80,7 @@ class ServiceControlManager implements ServiceControl *-------------------------------------------------------------------------------- */ - ServiceControlManager(Document cfg, SecurityMonitorEnvironment sm_env) + ServiceControlManager(GlobalSite globalsite, Document cfg, SecurityMonitorEnvironment sm_env) throws ConfigException { XMLLoader loader = XMLLoader.get(); @@ -117,9 +105,10 @@ class ServiceControlManager implements ServiceControl Node n = nl.item(i); if ((n.getNodeType()==Node.ELEMENT_NODE) && (n.getNodeName().equals("service"))) { // create the appropriate service settings - CommService svc = initCommunityService((Element)n,sm_comm); - tmp_symbol_to_service.put(svc.getToken().getSymbol(),svc); - tmp_index_to_service.put(new Integer(svc.getToken().getIndex()),svc); + CommServiceInternal svc = initCommunityService((Element)n,globalsite,sm_comm); + ServiceToken tok = svc.getExternal().getToken(); + tmp_symbol_to_service.put(tok.getSymbol(),svc); + tmp_index_to_service.put(new Integer(tok.getIndex()),svc); } // end if @@ -171,13 +160,14 @@ class ServiceControlManager implements ServiceControl } // end newToken - private final CommService initCommunityService(Element root, SecurityMonitor sm) throws ConfigException + private final CommServiceInternal initCommunityService(Element root, GlobalSite globalsite, + SecurityMonitor sm) throws ConfigException { ServiceToken token = newToken(SVCGRP_COMMUNITY,root); - CommService svc; + CommServiceInternal svc; // FUTURE: do a create of a specific class svc = new StaticCommService(); - svc.initialize(token,root,sm,new MyCommServiceSite()); + svc.initialize(token,root,sm,globalsite); return svc; } // end initCommunityService @@ -188,9 +178,9 @@ class ServiceControlManager implements ServiceControl Iterator it = symbol_to_service[group].values().iterator(); while (it.hasNext()) { // get each service in turn - Service svc = (Service)(it.next()); + ServiceInternal svc = (ServiceInternal)(it.next()); if (predicate.test(svc)) - tmp.add(svc.getToken()); + tmp.add(svc.getExternal().getToken()); } // end while @@ -199,7 +189,7 @@ class ServiceControlManager implements ServiceControl else return Collections.unmodifiableSet(tmp); - } // end listCommunities + } // end listServices /*-------------------------------------------------------------------------------- * Implementations from interface ServiceControl @@ -218,7 +208,7 @@ class ServiceControlManager implements ServiceControl if (rc==null) { // need to regenerate the set rc = listServices(group,new ServicePredicate(){ - public final boolean test(Service svc) { return true; } + public final boolean test(ServiceInternal svc) { return true; } }); // cache the result @@ -244,7 +234,7 @@ class ServiceControlManager implements ServiceControl if (rc==null) { // need to regenerate the set rc = listServices(group,new ServicePredicate(){ - public final boolean test(Service svc) { return svc.isDefault(); } + public final boolean test(ServiceInternal svc) { return svc.isDefault(); } }); // cache the result @@ -262,7 +252,7 @@ class ServiceControlManager implements ServiceControl { if ((group<0) || (group>=NUM_SVCGRPS)) throw new IndexOutOfBoundsException("group index not valid"); - return (Service)(symbol_to_service[group].get(sym)); + return ((ServiceInternal)(symbol_to_service[group].get(sym))).getExternal(); } // end getServiceForSymbol @@ -300,7 +290,7 @@ class ServiceControlManager implements ServiceControl Iterator it = symbol_to_service[i].values().iterator(); while (it.hasNext()) { // shut down each service in turn - Service svc = (Service)(it.next()); + ServiceInternal svc = (ServiceInternal)(it.next()); svc.shutdown(); } // end while diff --git a/src/com/silverwrist/venice/core/impl/SideBoxDescriptorImpl.java b/src/com/silverwrist/venice/core/impl/SideBoxDescriptorImpl.java index 9a2b6a6..3d60185 100644 --- a/src/com/silverwrist/venice/core/impl/SideBoxDescriptorImpl.java +++ b/src/com/silverwrist/venice/core/impl/SideBoxDescriptorImpl.java @@ -123,7 +123,7 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -155,7 +155,7 @@ class SideBoxDescriptorImpl implements UserSideBoxDescriptor finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/StaticCommService.java b/src/com/silverwrist/venice/core/impl/StaticCommService.java index 2fc1ddf..50daaf0 100644 --- a/src/com/silverwrist/venice/core/impl/StaticCommService.java +++ b/src/com/silverwrist/venice/core/impl/StaticCommService.java @@ -11,7 +11,7 @@ * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ @@ -23,8 +23,9 @@ import com.silverwrist.venice.core.ServiceToken; import com.silverwrist.venice.except.*; import com.silverwrist.venice.security.*; import com.silverwrist.venice.svc.*; +import com.silverwrist.venice.svc.internal.*; -class StaticCommService implements CommService +class StaticCommService implements CommService, CommServiceInternal { /*-------------------------------------------------------------------------------- * Attributes @@ -52,16 +53,44 @@ class StaticCommService implements CommService *-------------------------------------------------------------------------------- */ - public void shutdown() - { // do nothing - } // end shutdown - public ServiceToken getToken() { return token; } // end getToken + public String getPermission() + { + return permission; + + } // end getPermission + + public Role getRole() + { + return role; + + } // end getRole + + /*-------------------------------------------------------------------------------- + * Implementations from interface CommService + *-------------------------------------------------------------------------------- + */ + + /*-------------------------------------------------------------------------------- + * Implementations from interface ServiceInternal + *-------------------------------------------------------------------------------- + */ + + public Service getExternal() + { + return (CommService)this; + + } // end getExternal + + public void shutdown() + { // do nothing + } // end shutdown + public boolean isDefault() { return is_default; @@ -75,11 +104,11 @@ class StaticCommService implements CommService } // end isLocked /*-------------------------------------------------------------------------------- - * Implementations from interface CommunityService + * Implementations from interface CommServiceInternal *-------------------------------------------------------------------------------- */ - public void initialize(ServiceToken token, Element root, SecurityMonitor sm, CommServiceSite site) + public void initialize(ServiceToken token, Element root, SecurityMonitor sm, GlobalSite site) throws ConfigException { this.token = token; @@ -139,16 +168,4 @@ class StaticCommService implements CommService } // end initialize - public String getPermission() - { - return permission; - - } // end getPermission - - public Role getRole() - { - return role; - - } // end getRole - } // end class StaticCommService diff --git a/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java b/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java index 04144b3..5256cdd 100644 --- a/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java @@ -260,7 +260,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext } // end catch finally { // make sure we release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -355,7 +355,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext } // end catch finally { // make sure we release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -480,7 +480,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -570,7 +570,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext { // make sure we release the connection before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -691,7 +691,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext { // make sure we release the connection before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -789,7 +789,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext { // make sure we release the connection before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -960,7 +960,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext { // make sure we release the connection before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1007,7 +1007,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1087,7 +1087,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext { // make sure we release the connection before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1128,7 +1128,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1306,7 +1306,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext { // make sure we release the connection before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1380,7 +1380,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1434,7 +1434,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1484,7 +1484,7 @@ class TopicMessageUserContextImpl implements TopicMessageContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java b/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java index fe7ee81..b5f91dd 100644 --- a/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java @@ -224,7 +224,7 @@ class TopicUserContextImpl implements TopicContext } // end catch finally { // make sure we release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -358,7 +358,7 @@ class TopicUserContextImpl implements TopicContext { // make sure we release the connection before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -408,7 +408,7 @@ class TopicUserContextImpl implements TopicContext { // make sure we release the connection before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -475,7 +475,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -588,7 +588,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -889,7 +889,7 @@ class TopicUserContextImpl implements TopicContext { // make sure we release the connection before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1007,7 +1007,7 @@ class TopicUserContextImpl implements TopicContext { // make sure we release the connection before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1066,7 +1066,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1127,7 +1127,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1169,7 +1169,7 @@ class TopicUserContextImpl implements TopicContext } // end catch finally { // make sure we release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1237,7 +1237,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1274,7 +1274,7 @@ class TopicUserContextImpl implements TopicContext } // end catch finally { // make sure we release the connection before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1353,7 +1353,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1461,7 +1461,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1534,7 +1534,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1585,7 +1585,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1764,7 +1764,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1804,7 +1804,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1857,7 +1857,7 @@ class TopicUserContextImpl implements TopicContext finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/UserContextImpl.java b/src/com/silverwrist/venice/core/impl/UserContextImpl.java index 8a6e116..2160c6c 100644 --- a/src/com/silverwrist/venice/core/impl/UserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/UserContextImpl.java @@ -172,7 +172,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure we release the connection SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -312,7 +312,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -481,7 +481,7 @@ class UserContextImpl implements UserContext, UserBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end if @@ -541,7 +541,7 @@ class UserContextImpl implements UserContext, UserBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end if @@ -598,7 +598,7 @@ class UserContextImpl implements UserContext, UserBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end if @@ -733,7 +733,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure the connection is released before we go AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end if @@ -764,7 +764,7 @@ class UserContextImpl implements UserContext, UserBackend } // end catch finally { // make sure the connection is released before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -793,7 +793,7 @@ class UserContextImpl implements UserContext, UserBackend } // end catch finally { // make sure the connection is released before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -836,7 +836,7 @@ class UserContextImpl implements UserContext, UserBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -874,7 +874,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1041,7 +1041,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1102,7 +1102,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1166,7 +1166,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1211,7 +1211,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1249,7 +1249,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1429,7 +1429,7 @@ class UserContextImpl implements UserContext, UserBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end if @@ -1548,7 +1548,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1604,7 +1604,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1715,7 +1715,7 @@ class UserContextImpl implements UserContext, UserBackend finally { // make sure the connection is released before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1757,7 +1757,7 @@ class UserContextImpl implements UserContext, UserBackend } // end catch finally { // make sure the connection is released before we go - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -1931,7 +1931,7 @@ class UserContextImpl implements UserContext, UserBackend { // make sure the connection is released before we go SQLUtil.shutdown(stmt); AuditRecord.store(conn,ar); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java b/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java index d0b0c32..c332880 100644 --- a/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java +++ b/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java @@ -33,6 +33,7 @@ import com.silverwrist.venice.htmlcheck.dict.*; import com.silverwrist.venice.htmlcheck.filters.*; import com.silverwrist.venice.security.*; import com.silverwrist.venice.svc.*; +import com.silverwrist.venice.svc.internal.GlobalSite; import com.silverwrist.venice.util.XMLLoader; public class VeniceEngineImpl implements VeniceEngine, EngineBackend @@ -253,6 +254,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend *-------------------------------------------------------------------------------- */ + private GlobalSiteImpl globalsite = null; // my global site private EnvEngine env = null; // my environment private Random rng; // random number generator private Properties email_props = null; // email properties @@ -319,7 +321,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend private final void checkInitialized() { - if (env==null) + if (globalsite==null) throw new InternalStateError("Venice engine not initialized!"); } // end checkInitialized @@ -424,7 +426,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend finally { // make sure we release the connection before we go SQLUtil.shutdown(stmt); - env.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally @@ -539,14 +541,13 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend { int i; // loop counter - if (env!=null) + if (globalsite!=null) { // already configured! logger.error("Venice engine already initialized"); throw new ConfigException("Venice engine already initialized"); } // end if - DataPool datapool = null; Collection dictionary_tmp; try { // first, verify that this is a valid configuration @@ -568,20 +569,8 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend if (!(services_config.startsWith("/"))) services_config = app_root + services_config; - // Get the section. - sect = loader.configGetSubSection(root_h,"database"); - - try - { // allocate the data pool object - datapool = new DataPool(sect); - - } // end try - catch (SQLException e) - { // could not initialize the SQL database! this is a big fat error! - logger.fatal("data pool init failed - " + e.getMessage(),e); - throw new ConfigException("database access initialization failed - " + e.getMessage(),e); - - } // end catch + // Create the global site. + globalsite = new GlobalSiteImpl(this,root); // Get the section. sect = loader.configGetSubSection(root_h,"security"); @@ -680,19 +669,19 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend // Now done with the sidebox config... // Load the services config file. subdoc = loader.loadConfigDocument(services_config); - scmgr = new ServiceControlManager(subdoc,sm_env); + scmgr = new ServiceControlManager(globalsite,subdoc,sm_env); } // end try catch (ConfigException ce) { // before we leave on a ConfigException, nuke the important data - if (datapool!=null) - datapool.closeAllConnections(); + if (globalsite!=null) + globalsite.shutdown(); throw ce; } // end catch // Initialize the environment. - env = new EnvEngine(this,datapool,scmgr); + env = new EnvEngine(globalsite,this,scmgr); for (i=0; i. + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.venice.core.internals; + +import java.sql.*; +import org.apache.log4j.*; +import org.w3c.dom.*; +import com.silverwrist.util.*; +import com.silverwrist.venice.db.*; +import com.silverwrist.venice.except.*; +import com.silverwrist.venice.svc.internal.GlobalSite; +import com.silverwrist.venice.util.ServiceProvider; +import com.silverwrist.venice.util.XMLLoader; + +public class GlobalSiteImpl implements GlobalSite +{ + /*-------------------------------------------------------------------------------- + * Static data members + *-------------------------------------------------------------------------------- + */ + + private static Category logger = Category.getInstance(GlobalSiteImpl.class); + + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private EngineBackend engine; // the engine back end + private DataPool datapool; // the database pool + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + public GlobalSiteImpl(EngineBackend engine, Element config) throws ConfigException + { + this.engine = engine; + XMLLoader loader = XMLLoader.get(); + + // Get the section. + DOMElementHelper config_h = new DOMElementHelper(config); + Element sect = loader.configGetSubSection(config_h,"database"); + + try + { // allocate the data pool object + datapool = new DataPool(sect); + + } // end try + catch (SQLException e) + { // could not initialize the SQL database! this is a big fat error! + logger.fatal("data pool init failed - " + e.getMessage(),e); + throw new ConfigException("database access initialization failed - " + e.getMessage(),e); + + } // end catch + + } // end class GlobalSiteImpl + + /*-------------------------------------------------------------------------------- + * Implementations from interface ServiceProvider + *-------------------------------------------------------------------------------- + */ + + public Object queryService(Class klass) + { + if (klass==DataPool.class) + return datapool; + throw new NoSuchServiceException("GlobalSite",klass); + + } // end queryService + + public Object queryService(Class klass, String serviceid) + { + return this.queryService(klass); + + } // end queryService + + /*-------------------------------------------------------------------------------- + * Implementations from interface GlobalSite + *-------------------------------------------------------------------------------- + */ + + public Connection getConnection(String db_selector) throws SQLException + { + // db_selector is ignored for now + return datapool.getConnection(); + + } // end getConnection + + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + + public void shutdown() + { + if (datapool!=null) + datapool.closeAllConnections(); + + } // end shutdown + +} // end class GlobalSiteImpl diff --git a/src/com/silverwrist/venice/db/DataPool.java b/src/com/silverwrist/venice/db/DataPool.java index d822a7c..a5edc1d 100644 --- a/src/com/silverwrist/venice/db/DataPool.java +++ b/src/com/silverwrist/venice/db/DataPool.java @@ -429,7 +429,7 @@ public class DataPool implements Runnable else { // this connection is OK - return it busy_connections.addElement(rc); - return rc; + return new WrappedConnection(this,rc); } // end else @@ -444,10 +444,28 @@ public class DataPool implements Runnable * * @param c The connection to be returned to the pool. */ - public synchronized void releaseConnection(Connection c) + synchronized void releaseConnection(Connection c) { if (c!=null) - { // move from one vector to another + { // can release this connection + if (c instanceof WrappedConnection) + { // close our wrapped connection + try + { // close the connection + c.close(); + + } // end try + catch (SQLException e) + { // log exception and continue + logger.error("c.close() exception",e); + + } // end catch + + return; + + } // end if + + // move from one vector to another busy_connections.removeElement(c); avail_connections.addElement(c); notifyAll(); // wake up! Got a new connection for you! @@ -488,5 +506,3 @@ public class DataPool implements Runnable } // end toString } // end class DataPool - - diff --git a/src/com/silverwrist/venice/db/PostLinkRewriter.java b/src/com/silverwrist/venice/db/PostLinkRewriter.java index c9f4d28..d75fc03 100644 --- a/src/com/silverwrist/venice/db/PostLinkRewriter.java +++ b/src/com/silverwrist/venice/db/PostLinkRewriter.java @@ -23,6 +23,7 @@ import com.silverwrist.venice.htmlcheck.Rewriter; import com.silverwrist.venice.htmlcheck.RewriterServices; import com.silverwrist.venice.htmlcheck.MarkupData; import com.silverwrist.venice.except.ValidationException; +import com.silverwrist.venice.svc.internal.GlobalSite; import com.silverwrist.venice.util.IDUtils; public class PostLinkRewriter implements Rewriter @@ -39,16 +40,16 @@ public class PostLinkRewriter implements Rewriter *-------------------------------------------------------------------------------- */ - private DataPool datapool; + private GlobalSite globalsite; // global site containing utilities /*-------------------------------------------------------------------------------- * Constructor *-------------------------------------------------------------------------------- */ - public PostLinkRewriter(DataPool datapool) + public PostLinkRewriter(GlobalSite globalsite) { - this.datapool = datapool; + this.globalsite = globalsite; } // end constructor @@ -155,7 +156,7 @@ public class PostLinkRewriter implements Rewriter try { // verify against the database - conn = datapool.getConnection(); + conn = globalsite.getConnection(null); pl.verifyNames(conn); } // end try @@ -166,7 +167,7 @@ public class PostLinkRewriter implements Rewriter } // end catch finally { // release the connection when we're done - datapool.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/db/SQLUtil.java b/src/com/silverwrist/venice/db/SQLUtil.java index d49c87e..43a5a2f 100644 --- a/src/com/silverwrist/venice/db/SQLUtil.java +++ b/src/com/silverwrist/venice/db/SQLUtil.java @@ -284,6 +284,20 @@ public class SQLUtil } // end shutdown + public static final void shutdown(Connection conn) + { + try + { // close the Connection + if (conn!=null) + conn.close(); + + } // end try + catch (SQLException e) + { // ignore any SQL errors + } // end catch + + } // end shutdown + public static final void unlockTables(Connection conn) { try diff --git a/src/com/silverwrist/venice/db/UserNameRewriter.java b/src/com/silverwrist/venice/db/UserNameRewriter.java index b32435f..956594d 100644 --- a/src/com/silverwrist/venice/db/UserNameRewriter.java +++ b/src/com/silverwrist/venice/db/UserNameRewriter.java @@ -22,6 +22,7 @@ import com.silverwrist.util.StringUtil; import com.silverwrist.venice.htmlcheck.Rewriter; import com.silverwrist.venice.htmlcheck.RewriterServices; import com.silverwrist.venice.htmlcheck.MarkupData; +import com.silverwrist.venice.svc.internal.GlobalSite; import com.silverwrist.venice.util.IDUtils; public class UserNameRewriter implements Rewriter @@ -38,16 +39,16 @@ public class UserNameRewriter implements Rewriter *-------------------------------------------------------------------------------- */ - private DataPool datapool; + private GlobalSite globalsite; // global site containing utilities /*-------------------------------------------------------------------------------- * Constructor *-------------------------------------------------------------------------------- */ - public UserNameRewriter(DataPool datapool) + public UserNameRewriter(GlobalSite globalsite) { - this.datapool = datapool; + this.globalsite = globalsite; } // end constructor @@ -72,7 +73,7 @@ public class UserNameRewriter implements Rewriter try { // get a database connection and create a statement - conn = datapool.getConnection(); + conn = globalsite.getConnection(null); stmt = conn.createStatement(); StringBuffer sql = new StringBuffer("SELECT uid FROM users WHERE username = '"); sql.append(SQLUtil.encodeString(data)).append("';"); @@ -89,7 +90,7 @@ public class UserNameRewriter implements Rewriter finally { // make sure and release the connection before we go SQLUtil.shutdown(stmt); - datapool.releaseConnection(conn); + SQLUtil.shutdown(conn); } // end finally diff --git a/src/com/silverwrist/venice/db/WrappedConnection.java b/src/com/silverwrist/venice/db/WrappedConnection.java new file mode 100644 index 0000000..857cbc3 --- /dev/null +++ b/src/com/silverwrist/venice/db/WrappedConnection.java @@ -0,0 +1,412 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.venice.db; + +import java.sql.*; + +class WrappedConnection implements Connection +{ + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private DataPool datapool; + private Connection conn; + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + WrappedConnection(DataPool datapool, Connection conn) + { + this.datapool = datapool; + this.conn = conn; + + } // end constructor + + /*-------------------------------------------------------------------------------- + * Overrides from class Object + *-------------------------------------------------------------------------------- + */ + + protected void finalize() throws Throwable + { + if (conn!=null) + this.close(); + super.finalize(); + + } // end finalize + + /*-------------------------------------------------------------------------------- + * Implementations from interface Connection + *-------------------------------------------------------------------------------- + */ + + /** + * Creates a Statement object for sending + * SQL statements to the database. + * + * @return a new Statement object + * @exception SQLException if a database access error occurs + */ + public Statement createStatement() throws SQLException + { + return conn.createStatement(); + + } // end createStatement + + /** + * Creates a PreparedStatement object for sending + * parameterized SQL statements to the database. + * + * @param sql a SQL statement that may contain one or more '?' IN parameter placeholders + * @return a new PreparedStatement object containing the pre-compiled statement + * @exception SQLException if a database access error occurs + */ + public PreparedStatement prepareStatement(String sql) throws SQLException + { + return conn.prepareStatement(sql); + + } // end prepareStatement + + /** + * Creates a CallableStatement object for calling + * database stored procedures. + * + * @param sql a SQL statement that may contain one or more '?' parameter placeholders. + * Typically this statement is a JDBC function call escape string. + * @return a new CallableStatement object containing the pre-compiled SQL statement + * @exception SQLException if a database access error occurs + */ + public CallableStatement prepareCall(String sql) throws SQLException + { + return conn.prepareCall(sql); + + } // end prepareCall + + /** + * Converts the given SQL statement into the system's native SQL grammar. + * + * @param sql a SQL statement that may contain one or more '?' parameter placeholders + * @return the native form of this statement + * @exception SQLException if a database access error occurs + */ + public String nativeSQL(String sql) throws SQLException + { + return conn.nativeSQL(sql); + + } // end nativeSQL + + /** + * Sets this connection's auto-commit mode. + * + * @param autoCommit true enables auto-commit; false disables auto-commit. + * @exception SQLException if a database access error occurs + */ + public void setAutoCommit(boolean autoCommit) throws SQLException + { + conn.setAutoCommit(autoCommit); + + } // end setAutoCommit + + /** + * Gets the current auto-commit state. + * + * @return the current state of auto-commit mode + * @exception SQLException if a database access error occurs + * @see #setAutoCommit + */ + public boolean getAutoCommit() throws SQLException + { + return conn.getAutoCommit(); + + } // end getAutoCommit + + /** + * Makes all changes made since the previous + * commit/rollback permanent and releases any database locks + * currently held by the Connection. This method should be + * used only when auto-commit mode has been disabled. + * + * @exception SQLException if a database access error occurs + * @see #setAutoCommit + */ + public void commit() throws SQLException + { + conn.commit(); + + } // end commit + + /** + * Drops all changes made since the previous + * commit/rollback and releases any database locks currently held + * by this Connection. This method should be used only when auto- + * commit has been disabled. + * + * @exception SQLException if a database access error occurs + * @see #setAutoCommit + */ + public void rollback() throws SQLException + { + conn.rollback(); + + } // end rollback + + /** + * Releases a Connection's database and JDBC resources + * immediately instead of waiting for them to be automatically released. + * + * @exception SQLException if a database access error occurs + */ + public synchronized void close() throws SQLException + { + if (!(conn.getAutoCommit())) + conn.rollback(); + datapool.releaseConnection(conn); + conn = null; + + } // end close + + /** + * Tests to see if a Connection is closed. + * + * @return true if the connection is closed; false if it's still open + * @exception SQLException if a database access error occurs + */ + public boolean isClosed() throws SQLException + { + return (conn==null) ? true : conn.isClosed(); + + } // end isClosed + + /** + * Gets the metadata regarding this connection's database. + * + * @return a DatabaseMetaData object for this Connection + * @exception SQLException if a database access error occurs + */ + public DatabaseMetaData getMetaData() throws SQLException + { + return conn.getMetaData(); + + } // end getMetaData + + /** + * Puts this connection in read-only mode as a hint to enable + * database optimizations. + * + * @param readOnly true enables read-only mode; false disables read-only mode. + * @exception SQLException if a database access error occurs + */ + public void setReadOnly(boolean readOnly) + { // do nothing + } // end setReadOnly + + /** + * Tests to see if the connection is in read-only mode. + * + * @return true if connection is read-only and false otherwise + * @exception SQLException if a database access error occurs + */ + public boolean isReadOnly() + { + return false; + + } // end isReadOnly + + /** + * Sets a catalog name in order to select + * a subspace of this Connection's database in which to work. + * If the driver does not support catalogs, it will + * silently ignore this request. + * + * @exception SQLException if a database access error occurs + */ + public void setCatalog(String catalog) + { // do nothing + } // end setCatalog + + /** + * Returns the Connection's current catalog name. + * + * @return the current catalog name or null + * @exception SQLException if a database access error occurs + */ + public String getCatalog() + { + return null; + + } // end getCatalog + + /** + * Attempts to change the transaction + * isolation level to the one given. + * The constants defined in the interface Connection + * are the possible transaction isolation levels. + * + * @param level one of the TRANSACTION_* isolation values with the exception of TRANSACTION_NONE; + * some databases may not support other values + * @exception SQLException if a database access error occurs + * @see DatabaseMetaData#supportsTransactionIsolationLevel + */ + public void setTransactionIsolation(int level) + { // do nothing + } // end setTransactionIsolation + + /** + * Gets this Connection's current transaction isolation level. + * + * @return the current TRANSACTION_* mode value + * @exception SQLException if a database access error occurs + */ + public int getTransactionIsolation() throws SQLException + { + return conn.getTransactionIsolation(); + + } // end getTransactionIsolation + + /** + * Returns the first warning reported by calls on this Connection. + * + * @return the first SQLWarning or null + * @exception SQLException if a database access error occurs + */ + public SQLWarning getWarnings() throws SQLException + { + return conn.getWarnings(); + + } // end getWarnings + + /** + * Clears all warnings reported for this Connection object. + * After a call to this method, the method getWarnings + * returns null until a new warning is reported for this Connection. + * + * @exception SQLException if a database access error occurs + */ + public void clearWarnings() throws SQLException + { + conn.clearWarnings(); + + } // end clearWarnings + + /** + * Creates a Statement object that will generate + * ResultSet objects with the given type and concurrency. + * + * @param resultSetType a result set type; see ResultSet.TYPE_XXX + * @param resultSetConcurrency a concurrency type; see ResultSet.CONCUR_XXX + * @return a new Statement object + * @exception SQLException if a database access error occurs + * @since 1.2 + * @see What Is in the JDBC 2.0 API + */ + public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException + { + return conn.createStatement(resultSetType,resultSetConcurrency); + + } // end createStatement + + /** + * Creates a PreparedStatement object that will generate + * ResultSet objects with the given type and concurrency. + * This method is the same as the prepareStatement method + * above, but it allows the default result set + * type and result set concurrency type to be overridden. + * + * @param resultSetType a result set type; see ResultSet.TYPE_XXX + * @param resultSetConcurrency a concurrency type; see ResultSet.CONCUR_XXX + * @return a new PreparedStatement object containing the pre-compiled SQL statement + * @exception SQLException if a database access error occurs + * @since 1.2 + * @see What Is in the JDBC 2.0 API + */ + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException + { + return conn.prepareStatement(sql,resultSetType,resultSetConcurrency); + + } // end prepareStatement + + /** + * Creates a CallableStatement object that will generate + * ResultSet objects with the given type and concurrency. + * This method is the same as the prepareCall method + * above, but it allows the default result set + * type and result set concurrency type to be overridden. + * + * @param resultSetType a result set type; see ResultSet.TYPE_XXX + * @param resultSetConcurrency a concurrency type; see ResultSet.CONCUR_XXX + * @return a new CallableStatement object containing the pre-compiled SQL statement + * @exception SQLException if a database access error occurs + * @since 1.2 + * @see What Is in the JDBC 2.0 API + */ + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException + { + return conn.prepareCall(sql,resultSetType,resultSetConcurrency); + + } // end prepareCall + + /** + * Gets the type map object associated with this connection. + * Unless the application has added an entry to the type map, + * the map returned will be empty. + * + * @return the java.util.Map object associated with this Connection object + * @since 1.2 + * @see What Is in the JDBC 2.0 API + */ + public java.util.Map getTypeMap() throws SQLException + { + return conn.getTypeMap(); + + } // end getTypeMap + + /** + * Installs the given type map as the type map for + * this connection. The type map will be used for the + * custom mapping of SQL structured types and distinct types. + * + * @param the java.util.Map object to install + * as the replacement for this Connection + * object's default type map + * @since 1.2 + * @see What Is in the JDBC 2.0 API + */ + public void setTypeMap(java.util.Map map) throws SQLException + { + conn.setTypeMap(map); + + } // end setTypeMap + + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + Connection getRealConnection() + { + return conn; + + } // end getRealConnection + +} // end class WrappedConnection diff --git a/src/com/silverwrist/venice/svc/CommService.java b/src/com/silverwrist/venice/svc/CommService.java index bd757b0..84633aa 100644 --- a/src/com/silverwrist/venice/svc/CommService.java +++ b/src/com/silverwrist/venice/svc/CommService.java @@ -11,25 +11,12 @@ * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ package com.silverwrist.venice.svc; -import org.w3c.dom.Element; -import com.silverwrist.venice.core.ServiceToken; -import com.silverwrist.venice.except.ConfigException; -import com.silverwrist.venice.security.Role; -import com.silverwrist.venice.security.SecurityMonitor; - public interface CommService extends Service { - public abstract void initialize(ServiceToken token, Element root, SecurityMonitor sm, CommServiceSite site) - throws ConfigException; - - public abstract String getPermission(); - - public abstract Role getRole(); - } // end interface CommService diff --git a/src/com/silverwrist/venice/svc/Service.java b/src/com/silverwrist/venice/svc/Service.java index 6acdd4c..2e1f2a9 100644 --- a/src/com/silverwrist/venice/svc/Service.java +++ b/src/com/silverwrist/venice/svc/Service.java @@ -11,22 +11,21 @@ * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ package com.silverwrist.venice.svc; import com.silverwrist.venice.core.ServiceToken; +import com.silverwrist.venice.security.Role; public interface Service { - public abstract void shutdown(); - public abstract ServiceToken getToken(); - public abstract boolean isDefault(); + public abstract String getPermission(); - public abstract boolean isLocked(); + public abstract Role getRole(); } // end interface Service diff --git a/src/com/silverwrist/venice/svc/internals/CommServiceInternal.java b/src/com/silverwrist/venice/svc/internals/CommServiceInternal.java new file mode 100644 index 0000000..6a66360 --- /dev/null +++ b/src/com/silverwrist/venice/svc/internals/CommServiceInternal.java @@ -0,0 +1,30 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.venice.svc.internal; + +import org.w3c.dom.Element; +import com.silverwrist.venice.core.ServiceToken; +import com.silverwrist.venice.except.ConfigException; +import com.silverwrist.venice.security.SecurityMonitor; + +public interface CommServiceInternal extends ServiceInternal +{ + public abstract void initialize(ServiceToken token, Element root, SecurityMonitor sm, GlobalSite site) + throws ConfigException; + +} // end interface CommServiceInternal diff --git a/src/com/silverwrist/venice/svc/internals/GlobalSite.java b/src/com/silverwrist/venice/svc/internals/GlobalSite.java new file mode 100644 index 0000000..e6b37b5 --- /dev/null +++ b/src/com/silverwrist/venice/svc/internals/GlobalSite.java @@ -0,0 +1,28 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.venice.svc.internal; + +import java.sql.Connection; +import java.sql.SQLException; +import com.silverwrist.venice.util.ServiceProvider; + +public interface GlobalSite extends ServiceProvider +{ + public abstract Connection getConnection(String db_selector) throws SQLException; + +} // end interface GlobalSite diff --git a/src/com/silverwrist/venice/svc/CommServiceSite.java b/src/com/silverwrist/venice/svc/internals/ServiceInternal.java similarity index 67% rename from src/com/silverwrist/venice/svc/CommServiceSite.java rename to src/com/silverwrist/venice/svc/internals/ServiceInternal.java index a940058..d393cd4 100644 --- a/src/com/silverwrist/venice/svc/CommServiceSite.java +++ b/src/com/silverwrist/venice/svc/internals/ServiceInternal.java @@ -11,12 +11,22 @@ * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are - * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ -package com.silverwrist.venice.svc; +package com.silverwrist.venice.svc.internal; -public interface CommServiceSite +import com.silverwrist.venice.svc.Service; + +public interface ServiceInternal { -} // end interface CommServiceSite + public abstract Service getExternal(); + + public abstract void shutdown(); + + public abstract boolean isDefault(); + + public abstract boolean isLocked(); + +} // end interface ServiceInternal