1 /*
2 * $HeadURL: $
3 * $Date: $
4 * $Revision: $
5 * $Author: $
6 *
7 * Copyright (c) 2005 MindTree Consulting Ltd.
8 *
9 * This file is part of Insight.
10 *
11 * Insight is free software: you can redistribute it and/or modify it under the
12 * terms of the GNU General Public License as published by the Free Software
13 * Foundation, either version 3 of the License, or (at your option) any later
14 * version.
15 *
16 * Insight is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19 * Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along with
22 * Insight. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25 package com.mindtree.techworks.insight.preferences;
26
27 import com.mindtree.techworks.insight.preferences.xmlpersistence.XMLPreferenceDataHandler;
28
29
30 /**
31 * Gets Preference Data Handler implementations.
32 *
33 * @see PreferenceDataHandler PreferenceDataHandler
34 * @author Bindul Bhowmik
35 * @version $Revision: 27 $ $Date: 2007-12-16 04:58:03 -0700 (Sun, 16 Dec 2007) $
36 */
37 public class PreferenceDataHandlerFactory {
38
39 /**
40 * The default handler class name
41 */
42 private static String defaultHandlerClass = XMLPreferenceDataHandler.class
43 .getName();
44
45 /**
46 * Returns the default Preference Data Handler implementation instance.
47 * @return Instance of the default implementation
48 * @throws PreferenceHandlerInstantiationException
49 */
50 public static PreferenceDataHandler getDefaultHandler ()
51 throws PreferenceHandlerInstantiationException {
52
53 PreferenceDataHandler preferenceDataHandler = null;
54 try {
55 preferenceDataHandler = (PreferenceDataHandler) Class.forName(
56 defaultHandlerClass).newInstance();
57 } catch (InstantiationException e) {
58 e.printStackTrace();
59 throw new PreferenceHandlerInstantiationException("Default Handler ["
60 + defaultHandlerClass + "] not found.", e);
61 } catch (IllegalAccessException e) {
62 e.printStackTrace();
63 throw new PreferenceHandlerInstantiationException("Default Handler ["
64 + defaultHandlerClass + "] not found.", e);
65 } catch (ClassNotFoundException e) {
66 e.printStackTrace();
67 throw new PreferenceHandlerInstantiationException("Default Handler ["
68 + defaultHandlerClass + "] not found.", e);
69 }
70 return preferenceDataHandler;
71 }
72
73 }