Kettle Source Analysis one. Get and compile source code 1.1. Get source code SVN fetch
Svn://source.pentaho.org/svnkettleroot/kettle/tags
Web Capture
Official website: http://kettle.pentaho.com/ 1.2. Compiling the source code to load the project into Eclipse
Copy the Kettle project to the workspace directory of Eclipse, create a new Java project in Eclipse, and the name of the project is the same as the kettle folder you copied.
An error occurs when the project is imported into Eclipse, as shown in the following diagram, the source code for this file is commented out
compiling
Open the Build.xml, on the right. Outline Click Kettle->run as->ant Build
The first compile time need to download several files from the Internet, put in C:\Documents and Settings\administrator\.subfloor, the network is not good words download will be slower, you can also directly file in C:\Documents and Settings\administrator\ under. After compiling, copy the. bat file in the bin directory to the kettle directory click Spoon.bat Run, run successfully on behalf of the compilation has been nearly through the source run Spoon
Kettle Source engineering itself may be in the linux64 bit machine debugging, SWT configuration is linux64 Library, all in the operation of the source code needs to be modified to Win32 SWT, steps as follows: Project à property Àjava build Pathàlibrariesàadd Jars
Then remove the linux64 SWT Library
Finally open Src-uiàorg.pentaho.di.ui.spoonàspoon.java, Run Asàjava application two. Source Analysis 2.1. Modify the Kettle interface to modify the initialization interface
Open the Spoon.java of package Org.pentaho.di.ui.spoon, find the main function, which is the entry for the Spoon tool, and find the following statement
Splash Splash = new Splash (display); |
The statement, which is the interface for spoon initialization, jumps to the definition Splash.java, and the following function
Canvas.addpaintlistener (new Paintlistener () { publicvoid Paintcontrol (paintevent e) { String Versiontext = basemessages.getstring (PKG, "splashdialog.version") + "" + const.version; $NON-nls-1$//$NON-nls-2$ StringBuilder sb = new StringBuilder (); String line = null; Try { BufferedReader reader = new bufferedreader (new InputStreamReader (Splash). Class. getClassLoader (). getResourceAsStream ("Org/pentaho/di/ui/core/dialog/license/license.txt")); $NON-nls-1$ while (line = Reader.readline ())!= null) { Sb.append (line + system.getproperty ("Line.separator")); $NON-nls-1$ } catch (Exception ex) { Sb.append (""); $NON-nls-1$ Log.warn (basemessages.getstring (PKG, "Splashdialog.licensetextnotfound")); $NON-nls-1$ } String Licensetext = sb.tostring (); E.gc.drawimage (kettle_image, 0, 0); If This is a Milestone or RC release, warn the user if (Const.RELEASE.equals (Const.ReleaseType.MILESTONE)) { Versiontext = basemessages.getstring (PKG, "splashdialog.developerrelease") + "-" + versiontext; $NON-nls-1$//$NON-nls-2$ Drawversionwarning (e); } ElseIf (Const.RELEASE.equals (Const.ReleaseType.RELEASE_CANDIDATE)) { Versiontext = basemessages.getstring (PKG, "splashdialog.releasecandidate") + "-" + versiontext; $NON-nls-1$//$NON-nls-2$ } ElseIf (Const.RELEASE.equals (Const.ReleaseType.PREVIEW)) { Versiontext = basemessages.getstring (PKG, "splashdialog.previewrelease") + "-" + versiontext; $NON-nls-1$//$NON-nls-2$ } ElseIf (Const.RELEASE.equals (Const.ReleaseType.GA)) { Versiontext = basemessages.getstring (PKG, "splashdialog.ga") + "-" + versiontext; $NON-nls-1$//$NON-nls-2$ } Font verfont = new font (e.display, "Helvetica", one, SWT. BOLD); $NON-nls-1$ E.gc.setfont (Verfont); E.gc.drawtext (Versiontext, 290, 205, true); Try using the desired font size for the license text int fontsize = 8; Font licfont = new font (e.display, "Helvetica", FontSize, SWT. NORMAL); $NON-nls-1$ E.gc.setfont (Licfont); If the text won't fit the allowed spaces while (!willlicensetextfit (Licensetext, E.GC)) { fontsize--; Licfont = new Font (E.display, "Helvetica", FontSize, SWT. NORMAL); $NON-nls-1$ E.gc.setfont (Licfont); } E.gc.drawtext (Licensetext, 290, 290, true); } }); |
1. Modify background picture
Locate the Kettle_splash.png under ui/image/and replace the picture
2. Modify version Information
Find E.gc.drawtext (Versiontext, 290, 205, true); Change to E.gc.drawtext ("Hai Kang Wei as data exchange platform V1.0", 290, 205, true);
3. Modify the descriptive text below
Find E.gc.drawtext (Licensetext, 290, 290, true); Change to E.gc.drawtext ("Author: Hai Kang", 290, 290, true);
4. Preview effect
Modify the Spoon main interface title
Find the Spoon.java below.
public static final String app_name = basemessages.getstring (PKG, "Spoon.Application.Name");
Modify the main menu bar of the Spoon interface for the title you want to change
Ui/spoon.xul Reference Menubar.xul Code,
<pen:include src= "Menubar.xul" ignoreroot= "true"/> |
Menubar.xul Modify the Spoon menu bar at the configuration of the main menu bar
Spoon menu Bar
Configuration of the place under the Spoon.xul
<menupopup id= "New-file-popup" > <menuitem label= "${spoon.menubar.file.newjob}" command= "Spoon.newjobfile ()" Image= "${ChefIcon_image}"/> <menuitem id= "Menubar-new-trans" label= "${spoon.menubar.file.newtrans}" command= "Spoon.newTransFile" () "image=" $ {spoonicon_image} "/> <menuseparator/> <menuitem label= "${spoon.menubar.file.newdatabaseconn}" command= "Spoon.newconnection ()" Image= "${CNC_image}"/ > <menuitem label= "${spoon.menubar.file.newslave}" command= "Spoon.newslaveserver ()" Image= "${Slave_image}"/> </menupopup> |
Modify transformation and Job plug-in lists and icons
Src/kettle-steps.xml is the configuration file for the list of side conversion plug-ins
The file analysis is as follows, this configuration for the table input
<step id= "Tableinput" > <description>i18n:org.pentaho.di.trans.step:BaseStep.TypeLongDesc.TableInput</description> <classname>org.pentaho.di.trans.steps.tableinput.TableInputMeta</classname> <category>i18n:org.pentaho.di.trans.step:BaseStep.Category.Input</category> <tooltip>i18n:org.pentaho.di.trans.step:BaseStep.TypeTooltipDesc.TableInput</tooltip> <iconfile>ui/images/TIP.png</iconfile> </step> |
ClassName for the corresponding source file, category belong to which category, such as Tableinput belong to the "input" group, tooltip hint information, iconfile Display picture main panel layout
Within the private void Addtree () method under Spoon.java
2.2. Kettle Data Conversion Process
Kettle Data conversion process is a producer consumer model, each step is a node, each node is a separate thread, the node and the node through a blocking queue to pass the data, the previous node one by one to the blocking queue to write, followed by a section of the node from the blocking queue read, The blocking queue implementation method is Src-core/org/pentaho/di/core/blockingrowset.java.
Table Input Process
Table input connects the database through JDBC, executes the SQL statement and returns a resultset (result set) if the database supports PreparedStatement. Setfetchsize (the number of records returned each time to the result set), in batches the data is returned to the result set, and then read data from the result set to the blocking queue; If batch reads are not supported, the data is returned to the resultset one at a time and then read to the blocking queue, The method of database operation is implemented in Src-db/org/pentaho/di/core/database/database.java.
Insert Update Process
2.3. Plugin research kettle Conversion steps Workgroup Parts
Here are four classes that make up this kettle step/node, each of which has its own specific purpose and role to play.
Templatestep: The step class implements the Stepinteface interface, and when the transformation runs, its instance is where the data is actually processed. Each thread of execution represents an instance of this class.
Templatestepdata: Data classes are used to store data, and when the plug-in executes, it is unique for each thread that executes. The things that are stored during execution include database connections, file handles, caching, and much more.
Templatestepmeta: The metadata class implements the Stepmetainterface interface. Its responsibility is to save and serialize the configuration of a particular step instance, which in our case is responsible for saving the user's set step name and the name of the output field.
Templatestepdialog: The dialog class implements the interface for this step to interact with the user, which displays a dialog box that allows the user to set steps for their own preferences. The dialog class is very closely related to the metadata class, and the metadata class can track the user's settings.
In addition to the above code, there is a plugin.xml, it sets the plug-in metadata, defines the steps in the Kettle Graphics table display effect. To better understand, I'll use this step to design a transformation process and execute it. For plug-in development, we will start with the Plugin.xml configuration file, then talk about metadata and dialog box classes, and finally talk about step classes and data classes.
Write your own plugin.xml:
The following plugin.xml is the content of our plug-in, its function is to tell Kettle plug-in metadata class, plug-in name and description, as well as the need to load the jar package. To see the details, you can view the article:plug-in loading
<?xml version= "1.0" encoding= "UTF-8"?>
<plugin
Id= "Templateplugin"
Iconfile= "Icon.png"
description= "Template Plugin"
Tooltip= "Only there for demonstration purposes"
category= "Demonstration"
Classname= "Plugin.template.TemplateStepMeta" >
<librarie