KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > addressbook > main > AddressbookMain


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.addressbook.main;
17
18 import java.util.logging.Logger JavaDoc;
19
20 import org.apache.commons.cli.CommandLine;
21 import org.apache.commons.cli.Option;
22 import org.columba.addressbook.facade.ContactFacade;
23 import org.columba.addressbook.facade.DialogFacade;
24 import org.columba.addressbook.facade.FolderFacade;
25 import org.columba.addressbook.facade.ModelFacade;
26 import org.columba.addressbook.shutdown.SaveAllAddressbooksPlugin;
27 import org.columba.api.plugin.PluginLoadingFailedException;
28 import org.columba.core.backgroundtask.BackgroundTaskManager;
29 import org.columba.core.component.api.IComponentPlugin;
30 import org.columba.core.facade.ServiceFacadeRegistry;
31 import org.columba.core.gui.frame.FrameManager;
32 import org.columba.core.main.ColumbaCmdLineParser;
33 import org.columba.core.resourceloader.GlobalResourceLoader;
34 import org.columba.core.shutdown.ShutdownManager;
35
36 /**
37  * Main entrypoint for addressbook component
38  *
39  * @author fdietz
40  */

41 public class AddressbookMain implements IComponentPlugin {
42     /** JDK 1.4+ logging framework logger, used for logging. */
43     private static final Logger JavaDoc LOG = Logger
44             .getLogger("org.columba.addressbook.main");
45
46     private static final String JavaDoc RESOURCE_PATH = "org.columba.addressbook.i18n.global";
47
48     public AddressbookMain() {
49     }
50
51     /**
52      * @see org.columba.core.component.api.IComponentPlugin#handleCommandLineParameters()
53      */

54     public void handleCommandLineParameters(CommandLine commandLine) {
55         if (commandLine.hasOption("addressbook")) {
56             try {
57                 FrameManager.getInstance().openView("Addressbook");
58
59                 ColumbaCmdLineParser.getInstance().setRestoreLastSession(false);
60             } catch (PluginLoadingFailedException e) {
61                 LOG.severe(e.getLocalizedMessage());
62             }
63         }
64     }
65
66     /**
67      * @see org.columba.core.component.api.IComponentPlugin#init()
68      */

69     public void init() {
70         // init addressbook plugin handlers
71
// PluginManager.getInstance().addHandlers(
72
// "org/columba/addressbook/plugin/pluginhandler.xml");
73

74     /* try {
75             InputStream is = this.getClass().getResourceAsStream(
76                     "/org/columba/addressbook/action/action.xml");
77              PluginManager.getInstance().getHandler(
78                     IExtensionHandlerKeys.ORG_COLUMBA_CORE_ACTION).loadExtensionsFromStream(is);
79         } catch (PluginHandlerNotFoundException ex) {
80         }*/

81
82         Runnable JavaDoc plugin = new SaveAllAddressbooksPlugin();
83         BackgroundTaskManager.getInstance().register(plugin);
84         ShutdownManager.getInstance().register(plugin);
85
86         ServiceFacadeRegistry.getInstance().register(
87                 org.columba.addressbook.facade.IContactFacade.class,
88                 new ContactFacade());
89         ServiceFacadeRegistry.getInstance().register(
90                 org.columba.addressbook.facade.IFolderFacade.class,
91                 new FolderFacade());
92         ServiceFacadeRegistry.getInstance().register(
93                 org.columba.addressbook.facade.IModelFacade.class,
94                 new ModelFacade());
95         ServiceFacadeRegistry.getInstance().register(
96                 org.columba.addressbook.facade.IDialogFacade.class,
97                 new DialogFacade());
98     }
99
100     /**
101      * @see org.columba.core.component.api.IComponentPlugin#postStartup()
102      */

103     public void postStartup() {
104     }
105
106     /**
107      * @see org.columba.core.component.api.IComponentPlugin#registerCommandLineArguments()
108      */

109     public void registerCommandLineArguments() {
110         ColumbaCmdLineParser parser = ColumbaCmdLineParser.getInstance();
111
112         parser.addOption(new Option("addressbook", GlobalResourceLoader
113                 .getString(RESOURCE_PATH, "global", "cmdline_addressbook")));
114
115     }
116 }
Popular Tags