Package org.pentaho.di.core.plugins
Class BasePluginType
- java.lang.Object
-
- org.pentaho.di.core.plugins.BasePluginType
-
- All Implemented Interfaces:
PluginTypeInterface
- Direct Known Subclasses:
BaseFragmentType
,DatabasePluginType
,ExtensionPointPluginType
,LoggingPluginType
,PluginRegistryPluginType
,ServiceProviderPluginType
,TwoWayPasswordEncoderPluginType
,ValueMetaPluginType
public abstract class BasePluginType extends Object implements PluginTypeInterface
-
-
Field Summary
Fields Modifier and Type Field Description protected String
id
protected LogChannel
log
protected String
name
protected Map<Class<?>,String>
objectTypes
protected static Class<?>
PKG
protected List<PluginFolderInterface>
pluginFolders
protected PluginRegistry
registry
protected boolean
searchLibDir
-
Constructor Summary
Constructors Constructor Description BasePluginType(Class<? extends Annotation> pluginClass)
BasePluginType(Class<? extends Annotation> pluginClass, String id, String name)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
addExtraClasses(Map<Class<?>,String> classMap, Class<?> clazz, Annotation annotation)
Extract extra classes information from a plugin annotation.void
addObjectType(Class<?> clz, String xmlNodeName)
Register an additional class type to be managed by the plugin system.protected URLClassLoader
createUrlClassLoader(URL jarFileUrl, ClassLoader classLoader)
Create a new URL class loader with the jar file specified.protected abstract String
extractCasesUrl(Annotation annotation)
protected abstract String
extractCategory(Annotation annotation)
protected String
extractClassLoaderGroup(Annotation annotation)
protected abstract String
extractDesc(Annotation annotation)
protected abstract String
extractDocumentationUrl(Annotation annotation)
protected abstract String
extractForumUrl(Annotation annotation)
protected abstract String
extractI18nPackageName(Annotation annotation)
protected abstract String
extractID(Annotation annotation)
protected abstract String
extractImageFile(Annotation annotation)
protected abstract String
extractName(Annotation annotation)
protected abstract boolean
extractSeparateClassLoader(Annotation annotation)
protected abstract String
extractSuggestion(Annotation annotation)
protected List<JarFileAnnotationPlugin>
findAnnotatedClassFiles(String annotationClassName)
protected List<org.apache.commons.vfs2.FileObject>
findPluginFiles(String folder, String regex)
protected List<org.apache.commons.vfs2.FileObject>
findPluginXmlFiles(String folder)
Map<Class<?>,String>
getAdditionalRuntimeObjectTypes()
protected String
getAlternativePluginFile()
This method return parameter for registerNatives() methodprotected String
getAlternativeTranslation(String input, Map<String,String> localizedMap)
protected static String
getCodedTranslation(String codedString)
protected InputStream
getFileInputStreamExternal(String name)
String
getId()
protected String
getMainTag()
This method return parameter for registerPlugins() methodString
getName()
protected String
getPath()
This method return parameter for registerPlugins() methodList<PluginFolderInterface>
getPluginFolders()
protected String
getPropertyExternal(String key, String def)
protected InputStream
getResAsStreamExternal(String name)
protected String
getSubTag()
This method return parameter for registerPlugins() methodprotected String
getTagOrAttribute(Node pluginNode, String tag)
protected static String
getTranslation(String string, String packageName, String altPackageName, Class<?> resourceClass)
protected String
getXmlPluginFile()
This method return parameter for registerNatives() methodvoid
handlePluginAnnotation(Class<?> clazz, Annotation annotation, List<String> libraries, boolean nativePluginType, URL pluginFolder)
Handle an annotated pluginprotected boolean
isReturn()
This method return parameter for registerNatives() methodprotected void
populateFolders(String xmlSubfolder)
this is a utility method for subclasses so they can easily register which folders contain pluginsprotected Map<String,String>
readPluginLocale(Node pluginNode, String localizedTag, String translationTag)
void
registerCustom(Class<?> clazz, String cat, String id, String name, String desc, String image)
This method allows for custom registration of plugins that are on the main classpath.protected void
registerNatives()
protected PluginInterface
registerPluginFromXmlResource(Node pluginNode, String path, Class<? extends PluginTypeInterface> pluginType, boolean nativePlugin, URL pluginFolder)
protected void
registerPluginJars()
protected void
registerPlugins(InputStream inputStream)
This method registers plugins from the InputStream with the XML Resourceprotected abstract void
registerXmlPlugins()
void
searchPlugins()
Let's put in code here to search for the step plugins..void
setId(String id)
void
setName(String name)
void
setPluginFolders(List<PluginFolderInterface> pluginFolders)
protected void
setTransverseLibDirs(boolean transverseLibDirs)
When set to true the PluginFolder objects created by this type will be instructed to search for additional plugins in the lib directory of plugin folders.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.pentaho.di.core.plugins.PluginTypeInterface
isFragment
-
-
-
-
Field Detail
-
PKG
protected static final Class<?> PKG
-
id
protected String id
-
name
protected String name
-
pluginFolders
protected List<PluginFolderInterface> pluginFolders
-
registry
protected PluginRegistry registry
-
log
protected LogChannel log
-
searchLibDir
protected boolean searchLibDir
-
-
Constructor Detail
-
BasePluginType
public BasePluginType(Class<? extends Annotation> pluginClass)
-
BasePluginType
public BasePluginType(Class<? extends Annotation> pluginClass, String id, String name)
- Parameters:
id
- The plugin type IDname
- the name of the plugin
-
-
Method Detail
-
getXmlPluginFile
protected String getXmlPluginFile()
This method return parameter for registerNatives() method- Returns:
- XML plugin file
-
getAlternativePluginFile
protected String getAlternativePluginFile()
This method return parameter for registerNatives() method- Returns:
- Alternative XML plugin file
-
getMainTag
protected String getMainTag()
This method return parameter for registerPlugins() method- Returns:
- Main XML tag
-
getSubTag
protected String getSubTag()
This method return parameter for registerPlugins() method- Returns:
- Subordinate XML tag
-
getPath
protected String getPath()
This method return parameter for registerPlugins() method- Returns:
- Path
-
isReturn
protected boolean isReturn()
This method return parameter for registerNatives() method- Returns:
- Flag ("return;" or "throw exception")
-
populateFolders
protected void populateFolders(String xmlSubfolder)
this is a utility method for subclasses so they can easily register which folders contain plugins- Parameters:
xmlSubfolder
- the sub-folder where xml plugin definitions can be found
-
addObjectType
public void addObjectType(Class<?> clz, String xmlNodeName)
Description copied from interface:PluginTypeInterface
Register an additional class type to be managed by the plugin system.- Specified by:
addObjectType
in interfacePluginTypeInterface
- Parameters:
clz
- category class, usually an interfacexmlNodeName
- xml node to search for a class name
-
searchPlugins
public void searchPlugins() throws KettlePluginException
Let's put in code here to search for the step plugins..- Specified by:
searchPlugins
in interfacePluginTypeInterface
- Throws:
KettlePluginException
-
registerNatives
protected void registerNatives() throws KettlePluginException
- Throws:
KettlePluginException
-
getResAsStreamExternal
protected InputStream getResAsStreamExternal(String name)
-
getFileInputStreamExternal
protected InputStream getFileInputStreamExternal(String name) throws FileNotFoundException
- Throws:
FileNotFoundException
-
registerPlugins
protected void registerPlugins(InputStream inputStream) throws KettlePluginException, KettleXMLException
This method registers plugins from the InputStream with the XML Resource- Parameters:
inputStream
-- Throws:
KettlePluginException
KettleXMLException
-
registerXmlPlugins
protected abstract void registerXmlPlugins() throws KettlePluginException
- Throws:
KettlePluginException
-
getId
public String getId()
- Specified by:
getId
in interfacePluginTypeInterface
- Returns:
- the id
-
setId
public void setId(String id)
- Parameters:
id
- the id to set
-
getName
public String getName()
- Specified by:
getName
in interfacePluginTypeInterface
- Returns:
- the name
-
setName
public void setName(String name)
- Parameters:
name
- the name to set
-
getPluginFolders
public List<PluginFolderInterface> getPluginFolders()
- Specified by:
getPluginFolders
in interfacePluginTypeInterface
- Returns:
- the pluginFolders
-
setPluginFolders
public void setPluginFolders(List<PluginFolderInterface> pluginFolders)
- Parameters:
pluginFolders
- the pluginFolders to set
-
getTranslation
protected static String getTranslation(String string, String packageName, String altPackageName, Class<?> resourceClass)
-
findAnnotatedClassFiles
protected List<JarFileAnnotationPlugin> findAnnotatedClassFiles(String annotationClassName)
-
findPluginXmlFiles
protected List<org.apache.commons.vfs2.FileObject> findPluginXmlFiles(String folder)
-
findPluginFiles
protected List<org.apache.commons.vfs2.FileObject> findPluginFiles(String folder, String regex)
-
registerCustom
public void registerCustom(Class<?> clazz, String cat, String id, String name, String desc, String image) throws KettlePluginException
This method allows for custom registration of plugins that are on the main classpath. This was originally created so that test environments could register test plugins programmatically.- Parameters:
clazz
- the plugin implementation to registercat
- the category of the pluginid
- the id for the pluginname
- the name for the plugindesc
- the description for the pluginimage
- the image for the plugin- Throws:
KettlePluginException
-
registerPluginFromXmlResource
protected PluginInterface registerPluginFromXmlResource(Node pluginNode, String path, Class<? extends PluginTypeInterface> pluginType, boolean nativePlugin, URL pluginFolder) throws KettlePluginException
- Throws:
KettlePluginException
-
getAlternativeTranslation
protected String getAlternativeTranslation(String input, Map<String,String> localizedMap)
- Parameters:
input
-localizedMap
-- Returns:
-
readPluginLocale
protected Map<String,String> readPluginLocale(Node pluginNode, String localizedTag, String translationTag)
-
createUrlClassLoader
protected URLClassLoader createUrlClassLoader(URL jarFileUrl, ClassLoader classLoader)
Create a new URL class loader with the jar file specified. Also include all the jar files in the lib folder next to that file.- Parameters:
jarFileUrl
- The jar file to includeclassLoader
- the parent class loader to use- Returns:
- The URL class loader
-
extractID
protected abstract String extractID(Annotation annotation)
-
extractName
protected abstract String extractName(Annotation annotation)
-
extractDesc
protected abstract String extractDesc(Annotation annotation)
-
extractCategory
protected abstract String extractCategory(Annotation annotation)
-
extractImageFile
protected abstract String extractImageFile(Annotation annotation)
-
extractSeparateClassLoader
protected abstract boolean extractSeparateClassLoader(Annotation annotation)
-
extractI18nPackageName
protected abstract String extractI18nPackageName(Annotation annotation)
-
extractDocumentationUrl
protected abstract String extractDocumentationUrl(Annotation annotation)
-
extractSuggestion
protected abstract String extractSuggestion(Annotation annotation)
-
extractCasesUrl
protected abstract String extractCasesUrl(Annotation annotation)
-
extractForumUrl
protected abstract String extractForumUrl(Annotation annotation)
-
extractClassLoaderGroup
protected String extractClassLoaderGroup(Annotation annotation)
-
setTransverseLibDirs
protected void setTransverseLibDirs(boolean transverseLibDirs)
When set to true the PluginFolder objects created by this type will be instructed to search for additional plugins in the lib directory of plugin folders.- Parameters:
transverseLibDirs
-
-
registerPluginJars
protected void registerPluginJars() throws KettlePluginException
- Throws:
KettlePluginException
-
handlePluginAnnotation
public void handlePluginAnnotation(Class<?> clazz, Annotation annotation, List<String> libraries, boolean nativePluginType, URL pluginFolder) throws KettlePluginException
Handle an annotated plugin- Specified by:
handlePluginAnnotation
in interfacePluginTypeInterface
- Parameters:
clazz
- The class to useannotation
- The annotation to get information fromlibraries
- The libraries to addnativePluginType
- Is this a native plugin?pluginFolder
- The plugin folder to use- Throws:
KettlePluginException
-
addExtraClasses
protected abstract void addExtraClasses(Map<Class<?>,String> classMap, Class<?> clazz, Annotation annotation)
Extract extra classes information from a plugin annotation.- Parameters:
classMap
-clazz
-annotation
-
-
-