KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > apt > core > internal > PluginFactoryContainer


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 BEA Systems, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * mkaufman@bea.com - initial API and implementation
10  *******************************************************************************/

11
12
13 package org.eclipse.jdt.apt.core.internal;
14
15 import java.io.IOException JavaDoc;
16 import java.util.LinkedHashMap JavaDoc;
17 import java.util.Map JavaDoc;
18
19 import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
20
21 public class PluginFactoryContainer extends FactoryContainer
22 {
23     /** The label of the plug that owns this factory container. */
24     private final String JavaDoc id;
25     
26     /** Whether the plugin's factories are enabled by default */
27     private final boolean enableDefault;
28     
29     /**
30      * In general clients should not construct this object. This c'tor should
31      * only be called from @see FactoryPathUtil#loadPluginFactories().
32      * @param pluginId
33      * @param enableDefault
34      */

35     public PluginFactoryContainer(final String JavaDoc pluginId, boolean enableDefault) {
36         this.id = pluginId;
37         this.enableDefault = enableDefault;
38     }
39     
40     public void addFactoryName( String JavaDoc factoryName, String JavaDoc serviceName ) {
41         try {
42             getFactoryNames().put( factoryName, serviceName );
43         }
44         catch (IOException JavaDoc ioe) {
45             AptPlugin.log(ioe, "IOException reading a plugin"); //$NON-NLS-1$
46
}
47     }
48     
49     @Override JavaDoc
50     public boolean exists() {
51         // This object is created only in the process of loading factory plugins.
52
return true;
53     }
54
55     protected Map JavaDoc<String JavaDoc, String JavaDoc> loadFactoryNames() {
56         // The list is populated when factory plugins are loaded.
57
return new LinkedHashMap JavaDoc<String JavaDoc, String JavaDoc>();
58     }
59     
60     public String JavaDoc getId() {
61         return id;
62     }
63     
64     public boolean getEnableDefault() {
65         return enableDefault;
66     }
67     
68     @Override JavaDoc
69     public FactoryType getType() {
70         return FactoryType.PLUGIN;
71     }
72
73 }
74
Popular Tags