Author: tchemit Date: 2009-08-31 15:18:03 +0200 (Mon, 31 Aug 2009) New Revision: 11 Added: trunk/billy-ui/src/main/java/org/chorem/billy/ui/services/BillyManager.java Modified: trunk/billy-ui/src/main/java/org/chorem/billy/ui/services/AppModule.java Log: [FIX] #31 CLassCastException H2Dialect en Dialect (build hibernate factory at init time) here use the bonzoms init logic (but I don't known if it is good ? :)) Modified: trunk/billy-ui/src/main/java/org/chorem/billy/ui/services/AppModule.java =================================================================== --- trunk/billy-ui/src/main/java/org/chorem/billy/ui/services/AppModule.java 2009-08-31 13:17:15 UTC (rev 10) +++ trunk/billy-ui/src/main/java/org/chorem/billy/ui/services/AppModule.java 2009-08-31 13:18:03 UTC (rev 11) @@ -79,14 +79,30 @@ configuration.add(SymbolConstants.PRODUCTION_MODE, "false"); } + /** + * Contribution to Tapestry Startup. Execution of BonzomsManager to registration ChoremServices and ChoremUIServices for ChoReg. + * Catch NoClassDefFoundError when ChoReg is not deployed in application server. + * + * @param configuration Tapestry configuration to contribution + * @param servicePerson test + */ + public static void contributeRegistryStartup(OrderedConfiguration<Runnable> configuration) + { + try { + configuration.add("BillyStartup", new BillyManager()); + } catch (NoClassDefFoundError eee) { + System.out.println("AppModule.contributeRegistryStartup() : ChoremRegistry unavailable"); + } + } + @EagerLoad public RegistryShutdownListener buildBillyShutdown(@InjectService("RegistryShutdownHub") RegistryShutdownHub hub) { RegistryShutdownListener listener = new ContextShutdown(); - /*try { - listener = new BonzomsManager(); + try { + listener = new BillyManager(); } catch (NoClassDefFoundError eee) { - System.out.println("AppModule.buildBonzomsShutdown() : ChoremRegistry unavailable"); - }*/ + System.out.println("AppModule.buildBillyShutdown() : ChoremRegistry unavailable"); + } hub.addRegistryShutdownListener(listener); return listener; } Added: trunk/billy-ui/src/main/java/org/chorem/billy/ui/services/BillyManager.java =================================================================== --- trunk/billy-ui/src/main/java/org/chorem/billy/ui/services/BillyManager.java (rev 0) +++ trunk/billy-ui/src/main/java/org/chorem/billy/ui/services/BillyManager.java 2009-08-31 13:18:03 UTC (rev 11) @@ -0,0 +1,102 @@ +/** + * *##% Bonzoms Web Interface + * Copyright (C) 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +package org.chorem.billy.ui.services; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.tapestry5.ioc.services.RegistryShutdownListener; +import org.chorem.billy.RegisterBillyServices; +import org.chorem.choreg.ChoremConvert; +import org.chorem.choreg.ChoremRegistry; +import org.chorem.choreg.ChoremRegistryImpl; +import org.chorem.choreg.ChoremUIService; + +/** + * BonzomsManager.java + * + * Created on 2009-07-28 + * + * BonzomsManager manage registration uis services for ChoReg. Services are register when Tapestry start (run() method), and + * unregister when Tapestry shutdown (registryDidShutdown() method). + * BonzomsManager use RegisterBonzomsServices class from Bonzoms-business to manage business services for ChoReg. + * + * <pre> + * Proprietes pour configuration du serveur UI : + * + * org.chorem.choreg.ui.server.port=8081 #default = 8080 + * org.chorem.choreg.ui.server.contextpath=bonzoms #default = bonzoms-ui-1.0.x (version used) + * org.chorem.choreg.ui.server.host=XXX.XXX.XXX #default = localhost + * </pre> + * + * @author fdesbois + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author: fdesbois $ + */ +public class BillyManager implements Runnable, RegistryShutdownListener { + + public static final String CONFIG_KEY_UI_SERVER_HOST = "org.chorem.choreg.ui.server.host"; + + public static final String CONFIG_KEY_UI_SERVER_PORT = "org.chorem.choreg.ui.server.port"; + + public static final String CONFIG_KEY_UI_SERVER_CONTEXT_PATH = "org.chorem.choreg.ui.server.contextpath"; + + public static final String CONFIG_DEFAULT_UI_SERVER_HOST = "localhost"; + + public static final String CONFIG_DEFAULT_UI_SERVER_PORT = "8080"; + + private static final Log log = LogFactory.getLog(BillyManager.class); + + private static ChoremRegistry choreg = ChoremRegistryImpl.getInstance(); + + @Override + public void run() { + RegisterBillyServices.startup(); +// +// if (log.isInfoEnabled()) { +// log.info("Bonzoms registration uis services"); +// } +// register(ServiceUIPerson.getReferenceServiceClass(), new ServiceUIPerson(config)); +// register(ServiceUIOrganization.getReferenceServiceClass(), new ServiceUIOrganization(config)); + } + + @Override + public void registryDidShutdown() { + RegisterBillyServices.shutdown(); + } + + private void register(Class<?> serviceClass, ChoremUIService service) { + String sid = ChoremConvert.toSid(serviceClass); + choreg.register(sid, service); + if (log.isDebugEnabled()) { + log.debug(sid + " registered for ui"); + } + } + + private void unregister(Class<?> serviceClass) { + String sid = ChoremConvert.toSid(serviceClass); + choreg.unregister(sid); + if (log.isDebugEnabled()) { + log.debug(sid + " unregistered"); + } + } + +} Property changes on: trunk/billy-ui/src/main/java/org/chorem/billy/ui/services/BillyManager.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL