📄 servicesregistry.java
字号:
} /** * method getJahiaApplicationsDispatchingService * * @author NK 21.12.2000 */ public JahiaApplicationsDispatchingService getJahiaApplicationsDispatchingService() { return (JahiaApplicationsDispatchingService)theRegistry. get(JAHIA_APPLICATIONS_DISPATCHING_SERVICE) ; } /** * method getJahiaApplicationsPersistanceService * * @author NK 21.12.2000 */ public JahiaApplicationsPersistanceService getJahiaApplicationsPersistanceService() { return (JahiaApplicationsPersistanceService)theRegistry. get(JAHIA_APPLICATIONS_PERSISTANCE_SERVICE) ; } /** * method getJahiaIncrementorsDBService * * @author NK 21.12.2000 */ public JahiaIncrementorsDBService getJahiaIncrementorsDBService() { return (JahiaIncrementorsDBService)theRegistry. get(JAHIA_INCREMENTORS_DB_SERVICE) ; } /** * Return a reference on the DB User Manager service */ public JahiaUserManagerService getJahiaUserManagerService () { return (JahiaUserManagerService)theRegistry. get (JAHIA_USER_MANAGER_SERVICE); } /** * Return a reference on the DB User Manager service */ public JahiaGroupManagerService getJahiaGroupManagerService () { return (JahiaGroupManagerService)theRegistry. get (JAHIA_GROUP_MANAGER_SERVICE); } /** * */ public JahiaACLManagerService getJahiaACLManagerService () { return (JahiaACLManagerService)theRegistry. get (JAHIA_ACL_MANAGER_SERVICE); } /** * */ public JahiaContainersService getJahiaContainersService () { return (JahiaContainersService)theRegistry. get (JAHIA_CONTAINERS_SERVICE); } /** * DJ 03.01.2001 */ public JahiaSearchService getJahiaSearchService () { return (JahiaSearchService)theRegistry.get (JAHIA_SEARCH_SERVICE); } /** * NK 04.01.2001 */ public JahiaFilemanagerService getJahiaFilemanagerService () { return (JahiaFilemanagerService)theRegistry. get (jahia_filemgr_SERVICE); } /** * EV 11.01.2001 */ public JahiaFetcherService getJahiaFetcherService () { return (JahiaFetcherService)theRegistry.get (JAHIA_FETCHER_SERVICE); } /** * NK 20.01.2001 */ public JahiaTemplatesDeployerService getJahiaTemplatesDeployerService () { return (JahiaTemplatesDeployerService)theRegistry. get (JAHIA_TEMPLATES_DEPLOYER_SERVICE); } /** * NK 24.01.2001 */ public JahiaWebAppsDeployerService getJahiaWebAppsDeployerService () { return (JahiaWebAppsDeployerService)theRegistry. get (JAHIA_WEBAPPS_DEPLOYER_SERVICE); } /** * NK 12.01.2001 */ public JahiaFileWatcherService getJahiaFileWatcherService () { return (JahiaFileWatcherService)theRegistry. get (JAHIA_FILE_WATCHER_SERVICE); } /** * EV 12.01.2001 */ public JahiaEventGeneratorService getJahiaEventService () { return (JahiaEventGeneratorService)theRegistry. get (JAHIA_EVENT_SERVICE); } /** * NK 13.02.2001 */ public JahiaApplicationsManagerService getJahiaApplicationsManagerService () { return (JahiaApplicationsManagerService)theRegistry. get (JAHIA_APPLICATIONS_MANAGER_SERVICE); } /** * NK 18.06.2002 */ public JahiaApplicationContextService getJahiaApplicationContextService () { return (JahiaApplicationContextService)theRegistry. get (JAHIA_APPLICATION_CONTEXT_SERVICE); } /** * MJ 20.02.2001 */ public JahiaAuditLogManagerService getJahiaAuditLogManagerService () { return (JahiaAuditLogManagerService)theRegistry. get (JAHIA_AUDIT_LOG_MANAGER_SERVICE); } /** * NK 12.03.2001 */ public JahiaSitesService getJahiaSitesService () { return (JahiaSitesService)theRegistry.get (JAHIA_SITES_SERVICE); } /** * Return a reference on the DB Site User Manager service */ public JahiaSiteUserManagerService getJahiaSiteUserManagerService () { return (JahiaSiteUserManagerService)theRegistry. get (JAHIA_SITE_USER_MANAGER_SERVICE); } /** * Return a reference on the DB Site Group Manager service */ public JahiaSiteGroupManagerService getJahiaSiteGroupManagerService () { return (JahiaSiteGroupManagerService)theRegistry. get (JAHIA_SITE_GROUP_MANAGER_SERVICE); } /** * Return a reference on the apps share service */ public AppsShareService getAppsShareService () { return (AppsShareService)theRegistry. get (JAHIA_APPS_SHARE_SERVICE); } /** * Return a reference to the HTML content cache server service */ public CacheServerService getCacheServerService() { return (CacheServerService) theRegistry.get(JAHIA_CACHE_SERVER_SERVICE); } /** * Return a reference to the homepages service */ public JahiaHomepagesService getJahiaHomepagesService() { return (JahiaHomepagesService) theRegistry.get(JAHIA_HOMEPAGES_SERVICE); } //------------------------------------------------------------------------- /** * constructor * EV 19.12.2000 * */ private ServicesRegistry() { JahiaConsole.println( "Registry", "***** Starting Services Registry *****" ); } // end constructor //-------------------------------------------------------------------------- /** * method loadService * * @author NK 21.12.2000 */ private void loadService (String serviceName, String className) throws JahiaException { try { //JahiaConsole.println( "Registry", "ServicesRegistry loads services : serviceName=" + serviceName + ", classe name=" + className ); // Try to get a service by the getInstance method first JahiaService service = getServiceInstance(className); if ( service != null ) { theRegistry.put(serviceName,service); } else { theRegistry.put(serviceName,(JahiaService)Class.forName(className).newInstance()); } // Try to initialize the service JahiaService instanceObj = (JahiaService)theRegistry.get(serviceName); instanceObj.setServiceName(serviceName); // JahiaConsole.println( "Registry", "Try to init instance of " + serviceName ); instanceObj.init(this.jSettings); } catch ( ClassNotFoundException cnfe ) { String errorMsg = "ClassNotFoundException, Error in initializing Service : " + serviceName + ", class=" + className + "\n" + cnfe.toString(); JahiaConsole.println( "Registry", errorMsg + " -> BAILING OUT" ); throw new JahiaException( "ClassNotFoundException", errorMsg, JahiaException.SERVICE_ERROR, JahiaException.CRITICAL, cnfe ); } catch ( InstantiationException cie ) { String errorMsg = "InstantiationException, Error in initializing Service : " + serviceName + ", class=" + className + "\n" + cie.toString(); JahiaConsole.println( "Registry", errorMsg + " -> BAILING OUT" ); throw new JahiaException( "InstanciationException", errorMsg, JahiaException.SERVICE_ERROR, JahiaException.CRITICAL, cie ); } catch ( IllegalAccessException iae){ String errorMsg = "IllegalAccessException,Error in initializing Service : " + serviceName + ", class=" + className + "\n" + iae.toString(); JahiaConsole.println( "Registry", errorMsg + " -> BAILING OUT" ); throw new JahiaException( "IllegalAccessException", errorMsg, JahiaException.SERVICE_ERROR, JahiaException.CRITICAL, iae ); } catch ( JahiaInitializationException jie){ String errorMsg = "JahiaInitializationException,Error in initializing Service : " + serviceName + ", class=" + className + "\n" + jie.toString(); JahiaConsole.println( "Registry", errorMsg + " -> BAILING OUT" ); throw new JahiaException( "JahiaInitializationException", jie.getJahiaErrorMsg(), JahiaException.SERVICE_ERROR, JahiaException.CRITICAL, jie ); } } //------------------------------------------------------------------------- /** * Try to instanciate a service by the calling the method getInstance() * For Singleton Service * * @author NK 28.12.2000 * @return null if fail */ private JahiaService getServiceInstance (String className) throws ClassNotFoundException { JahiaService service = null; JahiaConsole.println("ServicesRegistry.getServiceInstance", "Trying to call getInstance() on class : " + className); try { Class self = Class.forName(className); Object parameters = null; java.lang.reflect.Method aMethod = self.getMethod ("getInstance", null); if (aMethod != null) { JahiaConsole.println("ServicesRegistry.getServiceInstance", "Found getInstance() method, now invoking..."); try { service = (JahiaService)aMethod.invoke(self, null); JahiaConsole.println("ServicesRegistry.getServiceInstance", "getInstance() invoked successfully, service=" + service); } catch ( java.lang.reflect.InvocationTargetException ite ) { JahiaConsole.printe("ServicesRegistry.getServiceInstance", ite.getTargetException() ); } } else { JahiaConsole.println("ServicesRegistry.getServiceInstance", "getInstance() method not found on class [" + className + "]"); } } catch ( NoSuchMethodException nme ) { JahiaConsole.println("ServicesRegistry.getServiceInstance"," Class " + className + " method getInstance NoSuchMethodException "); JahiaConsole.printe("ServicesRegistry.getServiceInstance", nme); } catch ( IllegalAccessException iae ) { JahiaConsole.println("ServicesRegistry.getServiceInstance"," Class " + className + " method getInstance IllegalAccessException "); JahiaConsole.printe("ServicesRegistry.getServiceInstance", iae); } catch ( Throwable t ) { JahiaConsole.printe("ServicesRegistry.getServiceInstance", t); } return service; }} // end ServicesRegistry
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -