diff --git a/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java b/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java index 9431515..bf13577 100644 --- a/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java +++ b/src/com/silverwrist/venice/core/impl/AdminOperationsImpl.java @@ -26,6 +26,7 @@ import com.silverwrist.venice.db.*; import com.silverwrist.venice.except.*; import com.silverwrist.venice.security.AuditRecord; import com.silverwrist.venice.security.Role; +import com.silverwrist.venice.svc.internal.GlobalSite; class AdminOperationsImpl implements AdminOperations { @@ -41,6 +42,7 @@ class AdminOperationsImpl implements AdminOperations *-------------------------------------------------------------------------------- */ + private GlobalSite globalsite; // global site private EnvUser env; // the execution environment /*-------------------------------------------------------------------------------- @@ -48,8 +50,9 @@ class AdminOperationsImpl implements AdminOperations *-------------------------------------------------------------------------------- */ - AdminOperationsImpl(EnvUser env) + AdminOperationsImpl(GlobalSite globalsite, EnvUser env) { + this.globalsite = globalsite; this.env = env; } // end constructor @@ -61,7 +64,8 @@ class AdminOperationsImpl implements AdminOperations public SecurityInfo getSecurityInfo() { - return env.getEngine().getSelf().getSecurityInfo(); + VeniceEngine engine = (VeniceEngine)(globalsite.queryService(VeniceEngine.class)); + return engine.getSecurityInfo(); } // end getSecurityInfo @@ -81,7 +85,7 @@ class AdminOperationsImpl implements AdminOperations try { // retrieve a connection from the data pool and get the audit records - conn = env.getConnection(); + conn = globalsite.getConnection(null); rc = AuditRecord.getAuditRecords(conn,-1,offset,count); } // end try @@ -108,7 +112,7 @@ class AdminOperationsImpl implements AdminOperations try { // retrieve a connection from the data pool and get the audit records - conn = env.getConnection(); + conn = globalsite.getConnection(null); rc = AuditRecord.getAuditRecordCount(conn,-1); } // end try @@ -181,7 +185,7 @@ class AdminOperationsImpl implements AdminOperations if (auto_join) { // Need to create a normal user context here for just a minute to autojoin the communities. - UserContextImpl rc = new UserContextImpl(env.getGlobalSite(),env); + UserContextImpl rc = new UserContextImpl(globalsite,env); rc.loadNewUser("0.0.0.0",rnu.getUserID(),base_role.getLevel(),username,0,rnu.getCreationDate(), rnu.getCreationDate()); rc.autoJoinCommunities(); diff --git a/src/com/silverwrist/venice/core/impl/UserContextImpl.java b/src/com/silverwrist/venice/core/impl/UserContextImpl.java index ca58648..7f7b102 100644 --- a/src/com/silverwrist/venice/core/impl/UserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/UserContextImpl.java @@ -1130,7 +1130,7 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider public AdminOperations getAdminInterface() throws AccessError { env.testPermission(EnvUser.PERM_SYSADMINACCESS,"You are not permitted to administer the server."); - return new AdminOperationsImpl(env); + return new AdminOperationsImpl(globalsite,env); } // end getAdminInterface diff --git a/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java b/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java index 6449ba8..b278cd7 100644 --- a/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java +++ b/src/com/silverwrist/venice/core/impl/VeniceEngineImpl.java @@ -33,9 +33,10 @@ import com.silverwrist.venice.security.*; import com.silverwrist.venice.svc.*; import com.silverwrist.venice.svc.internal.GlobalSite; import com.silverwrist.venice.util.MailSend; +import com.silverwrist.venice.util.ServiceProvider; import com.silverwrist.venice.util.XMLLoader; -public class VeniceEngineImpl implements VeniceEngine, EngineBackend +public class VeniceEngineImpl implements VeniceEngine, ServiceProvider, EngineBackend { /*-------------------------------------------------------------------------------- * Internal class storing side box information. @@ -527,7 +528,7 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend services_config = app_root + services_config; // Create the global site. - globalsite = new GlobalSiteImpl(this,root,app_root); + globalsite = new GlobalSiteImpl(this,this,root,app_root); // Get the section. sect = loader.configGetSubSection(root_h,"upload"); @@ -1337,15 +1338,53 @@ public class VeniceEngineImpl implements VeniceEngine, EngineBackend } // end useCategories /*-------------------------------------------------------------------------------- - * Implementations from interface EngineBackend + * Implementations from interface ServiceProvider *-------------------------------------------------------------------------------- */ - public VeniceEngine getSelf() + /** + * Queries this object for a specified service. + * + * @param klass The class of the object that should be returned as a service. + * @return A service object. The service object is guaranteed to be of the class + * specified by klass; that is, if queryService(klass) + * yields some object x, then the expression klass.isInstance(x) + * is true. + * @exception com.silverwrist.venice.except.NoSuchServiceException If no service is available in + * the specified class. + */ + public Object queryService(Class klass) { - return this; + if (klass==VeniceEngine.class) + return ((VeniceEngine)this); + if (klass==EngineBackend.class) + return ((EngineBackend)this); + throw new NoSuchServiceException("VeniceEngine",klass); - } // end getSelf + } // end queryService + + /** + * Queries this object for a specified service. + * + * @param klass The class of the object that should be returned as a service. + * @param serviceid ID for the service to be requested, to further discriminate between requests. + * @return A service object. The service object is guaranteed to be of the class + * specified by klass; that is, if queryService(klass) + * yields some object x, then the expression klass.isInstance(x) + * is true. + * @exception com.silverwrist.venice.except.NoSuchServiceException If no service is available in + * the specified class. + */ + public Object queryService(Class klass, String serviceid) + { + return queryService(klass); // defer to no service ID + + } // end queryService + + /*-------------------------------------------------------------------------------- + * Implementations from interface EngineBackend + *-------------------------------------------------------------------------------- + */ public CommunityData getCommunityDataObject(int cid) throws DataException { diff --git a/src/com/silverwrist/venice/core/internals/EngineBackend.java b/src/com/silverwrist/venice/core/internals/EngineBackend.java index 3969f6d..30225c8 100644 --- a/src/com/silverwrist/venice/core/internals/EngineBackend.java +++ b/src/com/silverwrist/venice/core/internals/EngineBackend.java @@ -46,8 +46,6 @@ public interface EngineBackend // role parameter indexes public static final int ROLEP_CREATECOMMUNITY = 0; - public abstract VeniceEngine getSelf(); - public abstract CommunityData getCommunityDataObject(int cid) throws DataException; public abstract void detachCommunityDataObject(int cid); diff --git a/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java b/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java index ee1a734..543439c 100644 --- a/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java +++ b/src/com/silverwrist/venice/core/internals/GlobalSiteImpl.java @@ -22,6 +22,7 @@ import java.util.*; import org.apache.log4j.*; import org.w3c.dom.*; import com.silverwrist.util.*; +import com.silverwrist.venice.core.VeniceEngine; import com.silverwrist.venice.db.*; import com.silverwrist.venice.except.*; import com.silverwrist.venice.htmlcheck.*; @@ -48,7 +49,7 @@ public class GlobalSiteImpl implements GlobalSite *-------------------------------------------------------------------------------- */ - private EngineBackend engine = null; // the engine back end + private ServiceProvider engine_svc = null; // ServiceProvider for the VeniceEngine private DataPool datapool = null; // the database pool private Properties email_props = null; // email properties private javax.mail.Session mailsession = null; // email session object @@ -61,9 +62,10 @@ public class GlobalSiteImpl implements GlobalSite *-------------------------------------------------------------------------------- */ - public GlobalSiteImpl(EngineBackend engine, Element config, String application_root) throws ConfigException + public GlobalSiteImpl(ServiceProvider engine_svc, Element config, String application_root) + throws ConfigException { - this.engine = engine; + this.engine_svc = engine_svc; XMLLoader loader = XMLLoader.get(); // Get the section. @@ -387,6 +389,8 @@ public class GlobalSiteImpl implements GlobalSite return sm_env; if (klass==SecurityMonitor.class) return sm_env.getMonitor("Global"); + if (klass==VeniceEngine.class) + return engine_svc.queryService(klass); throw new NoSuchServiceException("GlobalSite",klass); } // end queryService @@ -435,7 +439,7 @@ public class GlobalSiteImpl implements GlobalSite } // end if - return this.queryService(klass); + return queryService(klass); } // end queryService @@ -464,7 +468,7 @@ public class GlobalSiteImpl implements GlobalSite public void shutdown() { - engine = null; + engine_svc = null; if (datapool!=null) datapool.closeAllConnections(); datapool = null;