Author: echatellier Date: 2009-09-09 15:49:12 +0200 (Wed, 09 Sep 2009) New Revision: 2776 Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/war/ trunk/pollen-ui/src/main/java/org/chorem/pollen/war/PollenWarLauncher.java trunk/pollen-ui/src/main/resources/pollenembedded.properties Log: Add war main class and specific war properties file Added: trunk/pollen-ui/src/main/java/org/chorem/pollen/war/PollenWarLauncher.java =================================================================== --- trunk/pollen-ui/src/main/java/org/chorem/pollen/war/PollenWarLauncher.java (rev 0) +++ trunk/pollen-ui/src/main/java/org/chorem/pollen/war/PollenWarLauncher.java 2009-09-09 13:49:12 UTC (rev 2776) @@ -0,0 +1,77 @@ +/* *##% + * Copyright (C) 2009 Code Lutin + * + * 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 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.chorem.pollen.war; + +import java.io.File; +import java.io.IOException; +import java.net.JarURLConnection; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import winstone.Launcher; + +/** + * War main class launcher. + * + * Based on winstone micro container. + * + * To use it : + * java -jar pollen-xxx.war + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class PollenWarLauncher { + + /** + * Main method (used by war in manifest). + * + * @param args args + * @throws IOException + */ + public static void main(String[] args) throws IOException { + + System.out.println("Starting pollen embedded mode..."); + + String fqnLauncherFile = PollenWarLauncher.class.getName().replaceAll("\\.", "/")+ ".class"; + System.out.println("Search for launcher class : " + fqnLauncherFile); + + URL classFile = PollenWarLauncher.class.getClassLoader().getResource(fqnLauncherFile); + System.out.println(" - using classFile : " + classFile); + + // strange following line seams also work for jpnl launch + File me = new File(((JarURLConnection) classFile.openConnection()).getJarFile().getName()); + System.out.println(" - using warfile file : " + me); + + Map hashArgs = new HashMap(); + hashArgs.put("warfile", me.getAbsolutePath()); // or any other command line args, eg port + + // add jndi info to swap configuration file + hashArgs.put("useJNDI", "true"); + hashArgs.put("jndi.resource.configurationfilename", String.class.getName()); + hashArgs.put("jndi.param.configurationfilename.value", "pollenembedded.properties"); + + Launcher.initLogger(hashArgs); + Launcher winstone = new Launcher(hashArgs); // spawns threads, so your application doesn't block + } +} Property changes on: trunk/pollen-ui/src/main/java/org/chorem/pollen/war/PollenWarLauncher.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL" Added: trunk/pollen-ui/src/main/resources/pollenembedded.properties =================================================================== --- trunk/pollen-ui/src/main/resources/pollenembedded.properties (rev 0) +++ trunk/pollen-ui/src/main/resources/pollenembedded.properties 2009-09-09 13:49:12 UTC (rev 2776) @@ -0,0 +1,48 @@ +##�Properties file for embedded winstone war + +## Configuration de la base de données +#hibernate.hbm2ddl.auto=update +hibernate.show_sql=false +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.connection.username=sa +hibernate.connection.password= +hibernate.connection.driver_class=org.h2.Driver +hibernate.connection.url=jdbc:h2:file:pollendata/pollen + +## Configuration de topia-migration +topia.service.migration=org.nuiton.topia.migration.TopiaMigrationServiceImpl +topia.service.migration.callbackhandlers=org.chorem.pollen.business.migration.PollenMigrationCallbackHandler +topia.service.migration.mappingsdir=oldmappings +topia.service.migration.modelnames=pollen +topia.service.migration.version=1.1 + +## Initialisation de la base de données +choiceType=DATE,IMAGE,TEXT +pollType=RESTRICTED,FREE,GROUP +voteCounting=NORMAL,PERCENTAGE,CONDORCET + +## Utilisateur par défaut +adminLogin=admin +adminPassword=pollen +adminEmail=admin@domain.com + +## Répertoire des images transférées +upImgDir=pollendata/uploadedImages + +## Taille maximal des images transférées (en octets) +upload.filesize-max=1048576 +upload.requestsize-max=10485760 + +## Configuration de l'envoi d'emails automatiques +email_host=smtp.free.fr +email_port=25 +email_from=bot@pollen.org + +## Répertoire des flux de syndication (Atom) +feedDir=pollendata/feeds + +## Adresse du site (utilisée pour les emails de rappel) +siteUrl= + +## Version de l'application +version=${project.version} \ No newline at end of file