001: /**********************************************************************
002: Copyright (c) 2006 Erik Bengtson and others. All rights reserved.
003: Licensed under the Apache License, Version 2.0 (the "License");
004: you may not use this file except in compliance with the License.
005: You may obtain a copy of the License at
006:
007: http://www.apache.org/licenses/LICENSE-2.0
008:
009: Unless required by applicable law or agreed to in writing, software
010: distributed under the License is distributed on an "AS IS" BASIS,
011: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: See the License for the specific language governing permissions and
013: limitations under the License.
014:
015:
016: Contributors:
017: ...
018: **********************************************************************/package org.jpox.plugin;
019:
020: import java.io.IOException;
021: import java.lang.reflect.InvocationTargetException;
022: import java.net.URL;
023:
024: /**
025: * Loader and registry of Extensions and Extension Points. The implementation of this interface must have a public
026: * constructor taking the ClassLoaderResolver interface as argument The plugin registry metadata/bundle resolution is
027: * ruled by OSGi specification. The following sections of the OSGi 3.0 specification must be fully supported: 3.5.2,
028: * 3.5.2, 3.2.4, 3.2.5. The section 3.6.3 is optional. All other OSGi parts not mentioned above are not likely to be
029: * supported.
030: * @version $Revision: 1.8 $
031: */
032: public interface PluginRegistry {
033:
034: /**
035: * Acessor for the ExtensionPoint
036: * @param id the unique id of the extension point
037: * @return null if the ExtensionPoint is not registered
038: */
039: ExtensionPoint getExtensionPoint(String id);
040:
041: /**
042: * Acessor for the currently registed ExtensionPoints
043: * @return array of ExtensionPoints
044: */
045: ExtensionPoint[] getExtensionPoints();
046:
047: /**
048: * Look for Bundles/Plugins and register them. Register also ExtensionPoints and Extensions declared in /plugin.xml
049: * files
050: */
051: void registerExtensionPoints();
052:
053: /**
054: * Look for Bundles/Plugins and register them. Register also ExtensionPoints and Extensions declared in /plugin.xml
055: * files
056: */
057: void registerExtensions();
058:
059: /**
060: * Loads a class (do not initialize) from an attribute of {@link ConfigurationElement}
061: * @param confElm the configuration element
062: * @param name the attribute name
063: * @return the Class
064: */
065: Object createExecutableExtension(ConfigurationElement confElm,
066: String name, Class[] argsClass, Object[] args)
067: throws ClassNotFoundException, SecurityException,
068: NoSuchMethodException, IllegalArgumentException,
069: InstantiationException, IllegalAccessException,
070: InvocationTargetException;
071:
072: /**
073: * Loads a class (do not initialize)
074: * @param pluginId the plugin id
075: * @param className the class name
076: * @return the Class
077: * @throws ClassNotFoundException
078: */
079: Class loadClass(String pluginId, String className)
080: throws ClassNotFoundException;
081:
082: /**
083: * Converts a URL that uses a user-defined protocol into a URL that uses the file protocol.
084: * @param url the url to be converted
085: * @return the converted URL
086: * @throws IOException
087: */
088: URL resolveURLAsFileURL(URL url) throws IOException;
089:
090: /**
091: * Resolve constraints declared in bundle manifest.mf files.
092: * This must be invoked after registering all bundles.
093: * Should log errors if bundles are not resolvable, or raise runtime exceptions.
094: */
095: void resolveConstraints();
096:
097: /**
098: * Accessor for all registered bundles
099: * @return the bundles
100: * @throws UnsupportedOperationException if this operation is not supported by the implementation
101: */
102: Bundle[] getBundles();
103: }
|