Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/virtuosotechnologies/asaph/notationmanager/NotationManagerPlugin.java


1   /*
2   ================================================================================
3   
4     FILE:  NotationManagerPlugin.java
5     
6     PROJECT:
7     
8       Asaph
9     
10    CONTENTS:
11    
12      Plugin for notation manager
13    
14    PROGRAMMERS:
15    
16      Daniel Azuma (DA)  <dazuma@kagi.com>
17    
18    COPYRIGHT:
19    
20      Copyright (C) 2003  Daniel Azuma  (dazuma@kagi.com)
21      
22      This program is free software; you can redistribute it and/or
23      modify it under the terms of the GNU General Public License as
24      published by the Free Software Foundation; either version 2
25      of the License, or (at your option) any later version.
26      
27      This program is distributed in the hope that it will be useful,
28      but WITHOUT ANY WARRANTY; without even the implied warranty of
29      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30      GNU General Public License for more details.
31      
32      You should have received a copy of the GNU General Public
33      License along with this program; if not, write to
34        Free Software Foundation, Inc.
35        59 Temple Place, Suite 330
36        Boston, MA 02111-1307 USA
37  
38  ================================================================================
39  */
40  
41  
42  package com.virtuosotechnologies.asaph.notationmanager;
43  
44  
45  import java.util.logging.Logger;
46  
47  import com.virtuosotechnologies.lib.plugin.PluginInitializer;
48  import com.virtuosotechnologies.lib.plugin.PluginInitializerException;
49  import com.virtuosotechnologies.lib.plugin.PluginLinker;
50  
51  
52  /**
53   * Plugin for notation manager
54   */
55  public class NotationManagerPlugin
56  implements PluginInitializer
57  {
58    private Logger logger_;
59    
60    private NotationManagerImpl notationManager_;
61    
62    
63    /**
64     * Constructor
65     */
66    public NotationManagerPlugin()
67    {
68      logger_ = Logger.getLogger("com.virtuosotechnologies.asaph.notationmanager");
69      logger_.fine("Starting NotationManager");
70    }
71    
72    
73    /**
74     * Perform first initialization of the plugin. This is called after the plugin
75     * is instantiated, but before it is asked to provide any of its API implementations.
76     * Any APIs the plugin declared it needed for initialization will be available
77     * through the linker when this method is called.
78     * <p>
79     * Plugins should perform any time-consuming initialization in this method, rather
80     * than in the constructor or static initializers, and should use this method to
81     * report any fatal errors during initialization.
82     *
83     * @param linker the linker for this plugin.
84     * @exception PluginInitializerException thrown if the plugin could not
85     *    initialize itself.
86     */
87    public void initialize(
88      PluginLinker linker)
89    throws
90      PluginInitializerException
91    {
92      notationManager_ = new NotationManagerImpl();
93    }
94    
95    
96    /**
97     * A plugin must implement this method to provide the implementations of the APIs
98     * that it provides. This method is called after the initialize() method.
99     * Any APIs the plugin declared it needed in to implement this API will be available
100    * through the linker when this method is called.
101    * <p>
102    * Plugins should perform any time-consuming initialization in this method, rather
103    * than in the constructor or static initializers, and should use this method to
104    * report any fatal errors during initialization.
105    *
106    * @param apiName the name of the API to implement
107    * @param linker the linker for this plugin.
108    * @return an object implementing the API.
109    * @exception PluginInitializerException thrown if the plugin could not implement the API.
110    */
111   public Object getAPIImplementation(
112     String apiName,
113     PluginLinker linker)
114   throws
115     PluginInitializerException
116   {
117     if (apiName.equals(NotationManager.API_NAME))
118     {
119       return notationManager_;
120     }
121     throw new PluginInitializerException("Unknown API: "+apiName);
122   }
123 }