Author: tchemit Date: 2008-07-24 14:04:15 +0000 (Thu, 24 Jul 2008) New Revision: 773 Removed: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SimpleActionFactoryImpl.java Log: no more used Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SimpleActionFactoryImpl.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SimpleActionFactoryImpl.java 2008-07-24 14:03:59 UTC (rev 772) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SimpleActionFactoryImpl.java 2008-07-24 14:04:15 UTC (rev 773) @@ -1,103 +0,0 @@ -/* -* ##% Copyright (C) 2007, 2008 Code Lutin, Tony Chemit -* -* 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.codelutin.jaxx.action; - -import static org.codelutin.i18n.I18n._; -import org.codelutin.util.Resource; - -import javax.swing.AbstractAction; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.TreeMap; - -/** - * A simple implementation of {@link org.codelutin.jaxx.action.ActionFactory} using a properties file to - * load action mapping. - * <p/> - * An entry is in that form : <code>action.actionName=fqn</code> where - * <p/> - * <code>actionName</code> is the key of action used in factory, and - * <code>fqn</code> is the fully qualified name of the implemented action class. - * - * @author chemit - * @deprecated prefer use {@link org.codelutin.jaxx.action.ActionFactoryFromProvider} - */ -public class SimpleActionFactoryImpl extends ActionFactory { - /** default file where to load action mapping */ - protected static final String ACTIONS_FILE_PATH = "/actions.properties"; - - /** default prefix for an entryin mapping file. */ - protected static final String ACTION_KEY_PREFIX = "action."; - - /** real file where to load actions mapping */ - protected String actionFilePath; - - public SimpleActionFactoryImpl() { - this(ACTIONS_FILE_PATH); - } - - public SimpleActionFactoryImpl(String actionFilePath) { - this.actionFilePath = actionFilePath; - } - - @SuppressWarnings({"unchecked"}) - protected Map<String, Class<? extends AbstractAction>> init() { - Properties properties = new Properties(); - List<URL> urls = Resource.getURLs(".*jaxx/.+-actions\\.properties"); - for (URL url : urls) { - InputStream inputStream = null; - try { - inputStream = url.openStream(); - log.info("load " + url); - properties.load(inputStream); - } catch (IOException e) { - log.warn(_("jaxx.error.load.actions.file", e.getMessage())); - //throw new RuntimeException(_("jaxx.error.load.actions.file", e.getMessage())); - } finally { - if (inputStream != null) { - try { - inputStream.close(); - } catch (IOException e) { - log.warn(_("jaxx.error.close.actions.file", e.getMessage())); - //throw new RuntimeException(_("jaxx.error.load.actions.file", e.getMessage())); - } - } - } - } - Map<String, Class<? extends AbstractAction>> cache = new TreeMap<String, Class<? extends AbstractAction>>(); - int prefix = ACTION_KEY_PREFIX.length(); - for (Map.Entry<Object, Object> objectObjectEntry : properties.entrySet()) { - String key = objectObjectEntry.getKey() + ""; - String qfn = objectObjectEntry.getValue() + ""; - try { - Class<? extends AbstractAction> implCass; - implCass = (Class<? extends AbstractAction>) Class.forName(qfn); - log.debug("found action " + implCass); - cache.put(key.substring(prefix), implCass); - } catch (ClassNotFoundException e) { - throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn)); - } - } - return cache; - } - -} \ No newline at end of file
participants (1)
-
tchemit@users.labs.libre-entreprise.org