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

Quick Search    Search Deep

Source code: com/virtuosotechnologies/asaph/standardmodel/StandardModelPlugin.java


1   /*
2   ================================================================================
3   
4     FILE:  StandardModelPlugin.java
5     
6     PROJECT:
7     
8       Asaph
9     
10    CONTENTS:
11    
12      Plugin for the standard model
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.standardmodel;
43  
44  
45  import java.io.IOException;
46  
47  import com.virtuosotechnologies.lib.plugin.PluginInitializer;
48  import com.virtuosotechnologies.lib.plugin.PluginInitializerException;
49  import com.virtuosotechnologies.lib.plugin.PluginLinker;
50  
51  import com.virtuosotechnologies.asaph.modelutils.SongUtils;
52  import com.virtuosotechnologies.asaph.notationmanager.NotationManager;
53  
54  
55  /**
56   * Plugin for the standard model
57   */
58  public class StandardModelPlugin
59  implements PluginInitializer
60  {
61    /**
62     * Perform first initialization of the plugin. This is called after the plugin
63     * is instantiated, but before it is asked to provide any of its API implementations.
64     * Any APIs the plugin declared it needed for initialization will be available
65     * through the linker when this method is called.
66     * <p>
67     * Plugins should perform any time-consuming initialization in this method, rather
68     * than in the constructor or static initializers, and should use this method to
69     * report any fatal errors during initialization.
70     *
71     * @param linker the linker for this plugin.
72     * @exception PluginInitializerException thrown if the plugin could not
73     *    initialize itself.
74     */
75    public void initialize(
76      PluginLinker linker)
77    throws
78      PluginInitializerException
79    {
80    }
81    
82    
83    /**
84     * A plugin must implement this method to provide the implementations of the APIs
85     * that it provides. This method is called after the initialize() method.
86     * Any APIs the plugin declared it needed in to implement this API will be available
87     * through the linker when this method is called.
88     * <p>
89     * Plugins should perform any time-consuming initialization in this method, rather
90     * than in the constructor or static initializers, and should use this method to
91     * report any fatal errors during initialization.
92     *
93     * @param apiName the name of the API to implement
94     * @param linker the linker for this plugin.
95     * @return an object implementing the API.
96     * @exception PluginInitializerException thrown if the plugin could not implement the API.
97     */
98    public Object getAPIImplementation(
99      String apiName,
100     PluginLinker linker)
101   throws
102     PluginInitializerException
103   {
104     if (apiName.equals(StandardModelFactory.API_NAME))
105     {
106       try
107       {
108         return new StandardModelFactoryImpl(
109           (SongUtils)linker.getAPI(SongUtils.API_NAME).getImplementation(),
110           (NotationManager)linker.getAPI(NotationManager.API_NAME).getImplementation());
111       }
112       catch (IOException ex)
113       {
114         throw new PluginInitializerException(ex);
115       }
116     }
117     throw new PluginInitializerException();
118   }
119 }