从 Delphi 到 Java EE 转换
Ispirer MnMTK从Delphi应用程序转换到用Spring MVC框架的Java EE。
该视频演示如何Ispirer MnMTK进行从Delphi到Java EE的转换。
转换特征
- 将含业务逻辑的Delphi源代码(*.pas)转换成Java类
Delphi:
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm4 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
begin
Edit1.Text :=
IntToStr(StrToInt(Edit1.Text) + StrToInt(Edit2.Text));
end;
end.
Java:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletRequest;
import java.util.logging.Logger;
@Controller
public class Unit4
{
Logger logger = Logger.getGlobal();
@Autowired
private TForm4 Form4 = null;
@RequestMapping(value="/TForm4",method=RequestMethod.POST,
params="Button1")
public String Button1Click(HttpServletRequest request, Model model)
{
this.setPageValues(request);
this.Form4.setEdit1Text(String.valueOf(
Integer.parseInt(this.Form4.getEdit1Text())+
Integer.parseInt(this.Form4.getEdit2Text())));
this.addModelAttributes(model);
return "TForm4";
}
public void setPageValues(HttpServletRequest request)
{
this.Form4.setEdit1Text(request.getParameter("Edit1"));
this.Form4.setEdit2Text(request.getParameter("Edit2"));
}
public void addModelAttributes(Model model)
{
model.addAttribute("Edit1Text",this.Form4.getEdit1Text());
model.addAttribute("Edit2Text",this.Form4.getEdit2Text());
}
}
Pas转换以窗体类自动装配为根据。其包含ButtonClick的方法、setPageValues和addModelAttrributes。它们对累的表示制定jsp值并将它们发送到页面。
- 将Delphi Forms (*.dfm)文件转换成JSP和Java类
Delphi:
object Form4: TForm4
Left = 0
Top = 0
Caption = 'Form4'
ClientHeight = 158
ClientWidth = 201
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 24
Top = 107
Width = 46
Height = 13
Caption = 'Summand'
end
object Button1: TButton
Left = 24
Top = 64
Width = 153
Height = 25
Caption = 'Sum'
TabOrder = 0
OnClick = Button1Click
end
object Edit1: TEdit
Left = 24
Top = 37
Width = 153
Height = 21
TabOrder = 1
Text = '0'
end
object Edit2: TEdit
Left = 76
Top = 104
Width = 101
Height = 21
TabOrder = 2
Text = '0'
end
end
Java:
package com.ispirer.controller.demo.Logic;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class TForm4
{
private String Edit1Text = null;
private String Edit2Text = null;
public String getEdit1Text()
{
return Edit1Text;
}
public void setEdit1Text(String edit1Text)
{
Edit1Text = edit1Text;
}
public String getEdit2Text()
{
return Edit2Text;
}
public void setEdit2Text(String edit2Text)
{
Edit2Text = edit2Text;
}
@RequestMapping(value = "/TForm4")
public String FormCreate(Model model)
{
this.Edit1Text = "0";
model.addAttribute("Edit1Text",this.Edit1Text);
this.Edit2Text = "0";
model.addAttribute("Edit2Text",this.Edit2Text);
return “TForm4";
}
}
JSP:
<%@taglib prefix="c"
uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="form"
uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="mvc"
uri="http://www.springframework.org/tags/form"%>
<%@page contentType="text/html;charset=UTF-8" language="java"%>
<html>
<head>
<title>Form4</title>
<link rel="stylesheet" type="text/css"
href="<c:url value="/resources/css/style.css"/>" />
</head>
<body>
<div class="layout">
<div class="left">
</div>
<div class="content">
<form:form method="post">
<label
style="left:24px;top:107px;width:46px;height:13px;">Summand</label>
<input type="submit" name="Button1" value="Sum"
style="left:24px;top:64px; width:153px;height:25px;"/>
<input type="text" name="Edit1" value="${Edit1Text}"
style="left:24px;top:37px; width:153px;height:21px;"/>
<input type="text" name="Edit2" value="${Edit2Text}"
style="left:76px;top:104px; width:101px;height:21px;"/>
</form:form>
</div>
<div class="right">
</div>
</div>
</body>
</html>
Delphi |
|
Java |
|
|
|
Dfm文件由各种属性组成。对这些脚本Ispirer MnMTK 2915生成JSP和Java类。Delphi forms被转换到三个在<div class=”content”>标签有内容的JSP柱和默认的CSS文件(用于应用程序的正确的形式)。Ispirer MnMTK 2015还创建Delphi组件的模型类似物。窗体属性在FormCreate方法被制定。
- 将Delphi Data Access (BDE、ADO等)转换成Java Database Access框架(JDBC、Hibernate、Torque等)
Delphi:
end object Form2: TForm2
Left = 0
Top = 0
Width = 156
Height = 198
Caption = 'Test'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object DBGrid1: TDBGrid
Left = 32
Top = 8
Width = 81
Height = 120
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
Columns = <
item
Expanded = False
FieldName = 'col1'
Visible = True
end>
end
object ADOConnection1: TADOConnection
Connected = True
ConnectionString =
'Provider=MSDASQL.1;Persist Security Info=False;
User ID=sa;Data S' +
'ource=MSSQL_VMDBSRV002_ETEST'
Left = 24
Top = 136
end
object ADOQuery1: TADOQuery
Active = True
Connection = ADOConnection1
CursorType = ctStatic
Parameters = <>
SQL.Strings = (
'select col1 from tab1_test')
Left = 56
Top = 136
end
object DataSource1: TDataSource
DataSet = ADOQuery1
Left = 88
Top = 136
end
end
Java:
import java.sql.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import util.TDBGrid;
@Controller
public class TForm2
{
private TDBGrid DBGrid1 = null;
private static String[] connectionString=
{"jdbc:odbc:MSSQL_VMDBSRV002_ETEST","sa","" };
public static Connection ADOConnection1()
{
try
{
return DriverManager.getConnection(
connectionString[0],
connectionString[1],
connectionString[2]);
}
catch(SQLException e)
{
e.printStackTrace();
}
return null;
}
private PreparedStatement ADOQuery1 = null;
private String ADOQuery1_SQL_Strings =
"select col1 from tab2_test";
private ResultSet DataSource1 = null;
public void setADOQuery1(PreparedStatement ADOQuery1)
{
this.ADOQuery1 = ADOQuery1;
}
public PreparedStatement getADOQuery1()
{
return this.ADOQuery1;
}
public void setADOQuery1_SQL_Strings(String ADOQuery1_SQL_Strings)
{
this.ADOQuery1_SQL_Strings = ADOQuery1_SQL_Strings;
}
public String getADOQuery1_SQL_Strings()
{
return this.ADOQuery1_SQL_Strings;
}
public void setDataSource1(ResultSet DataSource1)
{
this.DataSource1 = DataSource1;
}
public ResultSet getDataSource1()
{
return this.DataSource1;
}
public void initDBGrid1(Model model)
{
this.DBGrid1 = new TDBGrid(this.DataSource1,new String[]
{ "col1" });
this.DBGrid1.initDBGridModel();
model.addAttribute("DBGrid1",this.DBGrid1.getDBGridModel());
model.addAttribute("DBGrid1ColWidth",new Integer[] { 100 });
}
@RequestMapping(value = "/TForm2")
public String FormCreate(Model model)
{
try
{
this.ADOQuery1 =
ADOConnection1().prepareStatement(getADOQuery1_SQL_Strings(),
ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
}
catch(SQLException e)
{
e.printStackTrace();
}
try
{
this.DataSource1 = this.ADOQuery1.executeQuery();
}
catch(SQLException e)
{
e.printStackTrace();
}
initDBGrid1(model);
return "TForm2";
}
}
Delphi |
|
Java |
|
|
|
这是用TADOConnection、TADOQuery和TDataSource的Ispirer MnMTK DBGrid转换的个例子。结果是Ispirer MnMTK生成JSP和从数据库中填充的表。此外,Ispirer MnMTK可以根据数据库的表自动生成Hibernate、Torque XML映射。
为什么Ispirer MnMTK?
Ispirer MnMTK可以帮助您经您的Delphi应用程序转换成Java。此外,用Ispirer MnMTK,您可以减少大部分的相关风险以及相当减少您所费的用力。这些好处的费用合理又竞争,大家真可以享受。在类型项目中,这使Ispirer MnMTK更具吸引力的工具在类型项目中。
我们的转换技术能够保证:
- 可读与可维护的代码
生成可读与可维护的代码,代码有手动转换质量
- 代码转换和重构
转换代码时实施Java最佳做法,而不模拟老技术在新平台上
- 最新的技术
可利用Java框架和技术的优势
- 纯Java代码
转换后不使用任何Ispirer库或IP
SQLWays是很合适更大脚本转换为万到亿代码行多数量:
- 自动解决依赖关系
以自动解决依赖关系与冲突,可以从依赖文件、数据库中等提取信息
- 配置
可以从各种配置与项目文档(Ispirer MnMTK5配置文件、.xml文件)读取信息
- 快速和强大的自定义
抽象层、可重复使用的转换模板、内部转换语言和工具允许快速的定制和复杂的代码转换。
这里您可以下载Delphi源代码的实例和转换的结果:
评估过程
请您在写问卷为拥有我们的服务帮助与对您的项目:
Ispirer为ISV企业建议成套合作模式对应用转换有亿代码行多
Ispirer转换解决方案
从 Delphi 到 Java EE 请求
Ispirer转换解决方案
从 Delphi 到 Java EE 服务
工具
您可以通过联系页面联系我们。
|