Permalink
Browse files

did proof of concept c# implementation reusing ikvm'ed java core libr…

…ary. Does not work yet, but pieces are in place to pick up at a later date

git-svn-id: http://liquibase.jira.com/svn/CORE/trunk@1005 e6edf6fb-f266-4316-afb4-e53d95876a76
  • Loading branch information...
1 parent dd47dc3 commit 50540eb353f38d11d80fa7cf8e94be9d6364d5fa nvoxland committed Jul 13, 2009
Showing with 1,218 additions and 110 deletions.
  1. BIN core-clr/lib-deps/IKVM.OpenJDK.Core.dll
  2. BIN core-clr/lib-deps/IKVM.OpenJDK.Jdbc.dll
  3. BIN core-clr/lib-deps/IKVM.OpenJDK.Security.dll
  4. BIN core-clr/lib-deps/IKVM.OpenJDK.Text.dll
  5. BIN core-clr/lib-deps/IKVM.OpenJDK.Util.dll
  6. BIN core-clr/lib-deps/IKVM.OpenJDK.XML.dll
  7. BIN core-clr/lib-deps/IKVM.Runtime.dll
  8. BIN core-clr/lib-deps/liquibase-core.dll
  9. +25 −0 core-clr/liquibase/LiquiBase/AssemblyResourceLoader.cs
  10. +58 −0 core-clr/liquibase/LiquiBase/ClrClassPathScanner.cs
  11. +83 −0 core-clr/liquibase/LiquiBase/Database/AdoConnection.cs
  12. +46 −0 core-clr/liquibase/LiquiBase/Executor/Core/ClrWriteExecutor.cs
  13. +10 −0 core-clr/liquibase/LiquiBase/LiquiBase.cs
  14. +96 −0 core-clr/liquibase/LiquiBase/LiquiBase.csproj
  15. +36 −0 core-clr/liquibase/LiquiBase/Properties/AssemblyInfo.cs
  16. +22 −0 core-clr/liquibase/LiquiBase/Resource/ClrResourceAccessor.cs
  17. +57 −0 core-clr/liquibase/LiquiBase/Snapshot/Core/OleDatabaseSnapshotGenerator.cs
  18. +97 −0 core-clr/liquibase/LiquiBaseConsole/LiquiBaseConsole.csproj
  19. +31 −0 core-clr/liquibase/LiquiBaseConsole/Program.cs
  20. +36 −0 core-clr/liquibase/LiquiBaseConsole/Properties/AssemblyInfo.cs
  21. +136 −0 core-clr/liquibase/LiquiBaseTest/AuthoringTests.txt
  22. +122 −0 core-clr/liquibase/LiquiBaseTest/Database/AdoConnectionTest.cs
  23. +98 −0 core-clr/liquibase/LiquiBaseTest/LiquiBaseTest.csproj
  24. +72 −0 core-clr/liquibase/LiquiBaseTest/Plugin/ClassPathScannerTest.cs
  25. +35 −0 core-clr/liquibase/LiquiBaseTest/Properties/AssemblyInfo.cs
  26. +5 −0 core-clr/liquibase/LocalTestRun.testrunconfig
  27. +38 −0 core-clr/liquibase/liquibase.sln
  28. +6 −0 core-clr/liquibase/liquibase.vsmdi
  29. +1 −2 core-jvm/src/java-dbtest/liquibase/dbtest/AbstractSimpleChangeLogRunnerTest.java
  30. +1 −2 core-jvm/src/java-test/liquibase/database/core/MockDatabase.java
  31. +1 −2 core-jvm/src/java-test/liquibase/{lock → lockservice}/LockServiceExecuteTest.java
  32. +1 −1 core-jvm/src/java-test/liquibase/{lock → lockservice}/LockServiceTest.java
  33. +1 −1 core-jvm/src/java-test/liquibase/test/DatabaseTestTemplate.java
  34. +0 −51 core-jvm/src/java/liquibase/database/DatabaseFactoryJdbc.java
  35. +1 −1 core-jvm/src/java/liquibase/integration/commandline/Main.java
  36. BIN core/lib-compile/ant-ikvmc.0.5.jar
  37. +17 −5 core/src/build.xml
  38. +2 −2 core/src/java/liquibase/Liquibase.java
  39. +0 −8 core/src/java/liquibase/database/AbstractDatabase.java
  40. +0 −2 core/src/java/liquibase/database/Database.java
  41. +32 −11 core/src/java/liquibase/database/DatabaseFactory.java
  42. +1 −1 core/src/java/liquibase/database/core/CacheDatabase.java
  43. +1 −1 core/src/java/liquibase/database/core/DB2Database.java
  44. +1 −1 core/src/java/liquibase/database/core/DerbyDatabase.java
  45. +1 −1 core/src/java/liquibase/database/core/FirebirdDatabase.java
  46. +1 −1 core/src/java/liquibase/database/core/H2Database.java
  47. +1 −1 core/src/java/liquibase/database/core/HsqlDatabase.java
  48. +1 −1 core/src/java/liquibase/database/core/InformixDatabase.java
  49. +3 −1 core/src/java/liquibase/database/core/MSSQLDatabase.java
  50. +1 −1 core/src/java/liquibase/database/core/MaxDBDatabase.java
  51. +1 −1 core/src/java/liquibase/database/core/MySQLDatabase.java
  52. +1 −1 core/src/java/liquibase/database/core/OracleDatabase.java
  53. +1 −1 core/src/java/liquibase/database/core/PostgresDatabase.java
  54. +1 −1 core/src/java/liquibase/database/core/SQLiteDatabase.java
  55. +2 −2 core/src/java/liquibase/database/core/SybaseASADatabase.java
  56. +1 −1 core/src/java/liquibase/database/core/SybaseDatabase.java
  57. +1 −1 core/src/java/liquibase/{lock → lockservice}/DatabaseChangeLogLock.java
  58. +1 −1 core/src/java/liquibase/{lock → lockservice}/LockService.java
  59. +32 −4 core/src/java/liquibase/util/plugin/ClassPathScanner.java
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Liquibase.Resource {
+ class AssemblyResourceLoader : liquibase.resource.ResourceAccessor {
+
+ #region ResourceAccessor Members
+
+ public java.io.InputStream getResourceAsStream(string str) {
+ throw new NotImplementedException();
+ }
+
+ public java.util.Enumeration getResources(string str) {
+ throw new NotImplementedException();
+ }
+
+ public java.lang.ClassLoader toClassLoader() {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using liquibase.util.plugin;
+using System.Reflection;
+using liquibase.resource;
+using java.lang;
+
+namespace LiquiBase {
+ public class ClrClassPathScanner : ClassPathScanner {
+
+
+ public ClrClassPathScanner() : base(null) {
+ }
+
+ public override void setResourceAccessor(liquibase.resource.ResourceAccessor resourceAccessor) {
+ }
+
+ public override java.lang.Class[] getClasses(java.lang.Class requiredInterface) {
+ //Console.WriteLine("looking up " + requiredInterface.getName());
+ List<Class> returnClasses = new List<Class>();
+
+ Type requiredType = Type.GetType(requiredInterface.getName()+", liquibase-core");
+ if (requiredType == null) {
+ Console.WriteLine("could not find required type for " + requiredInterface.getName());
+ return new java.lang.Class[0];
+ }
+
+ Assembly assembly = Assembly.GetExecutingAssembly();
+ foreach (Type type in assembly.GetTypes()) {
+ //if (type.AssemblyQualifiedName.Contains("LiquiBase")) {
+ // Console.WriteLine("type: " + type);
+ //}
+ if (!type.IsInterface && !type.IsAbstract && requiredType.IsAssignableFrom(type)) {
+ //Console.WriteLine("Adding class " + type.AssemblyQualifiedName);
+ returnClasses.Add(Class.forName(type.AssemblyQualifiedName));
+ }
+ }
+
+ foreach (AssemblyName refAsm in assembly.GetReferencedAssemblies()) {
+
+ foreach (Type type in Assembly.Load(refAsm).GetTypes()) {
+ //if (type.AssemblyQualifiedName.Contains("LiquiBase")) {
+ // Console.WriteLine("type: " + type);
+ //}
+ if (!type.IsInterface && !type.IsAbstract && requiredType.IsAssignableFrom(type)) {
+ //Console.WriteLine("Adding class " + type.AssemblyQualifiedName);
+ returnClasses.Add(Class.forName(type.AssemblyQualifiedName));
+ }
+ }
+ }
+
+ return returnClasses.ToArray();
+
+ }
+ }
+}
@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Data.SqlClient;
+using liquibase.database;
+using System.Data.OleDb;
+
+namespace LiquiBase.Database {
+
+ public class AdoConnection : DatabaseConnection {
+
+ OleDbConnection conn;
+ OleDbTransaction transaction;
+
+ public AdoConnection() {
+ conn = new OleDbConnection("Provider=SQLOLEDB;Data Source=localhost\\SQL2005;Initial Catalog=liquibase;User Id=liquibase;Password=liquibase;");
+ conn.Open();
+ transaction = conn.BeginTransaction();
+ }
+
+ public OleDbConnection GetUnderlyingConnection() {
+ return conn;
+
+ }
+ void DatabaseConnection.close() {
+ conn.Close();
+ }
+
+ void DatabaseConnection.commit() {
+ transaction.Commit();
+ }
+
+ bool DatabaseConnection.getAutoCommit() {
+ return transaction == null;
+ }
+
+ string DatabaseConnection.getCatalog() {
+ return null;
+ }
+
+ string DatabaseConnection.getConnectionUserName() {
+ return "liquibase"; //todo
+ }
+
+ int DatabaseConnection.getDatabaseMajorVersion() {
+ return 1; //todo
+ }
+
+ int DatabaseConnection.getDatabaseMinorVersion() {
+ return 1; //todo
+ }
+
+ string DatabaseConnection.getDatabaseProductName() {
+ return conn.Provider;
+ }
+
+ string DatabaseConnection.getDatabaseProductVersion() {
+ return conn.ServerVersion;
+ }
+
+ string DatabaseConnection.getURL() {
+ return conn.ConnectionString;
+ }
+
+ string DatabaseConnection.nativeSQL(string str) {
+ return str; //todo
+ }
+
+ void DatabaseConnection.rollback() {
+ transaction.Rollback();
+ }
+
+ void DatabaseConnection.setAutoCommit(bool b) {
+ if (b) {
+ transaction = conn.BeginTransaction();
+ } else {
+ transaction = null;
+ }
+ }
+
+ }
+}
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using LiquiBase.Database;
+
+namespace LiquiBase.Executor.Core {
+ public class ClrWriteExecutor : liquibase.executor.AbstractExecutor, liquibase.executor.WriteExecutor {
+
+ public java.util.Map call(liquibase.statement.CallableSqlStatement css, java.util.List l1, java.util.List l2) {
+ throw new NotImplementedException();
+ }
+
+ public void comment(string str) {
+ throw new NotImplementedException();
+ }
+
+ public void execute(liquibase.statement.SqlStatement ss) {
+ Console.WriteLine("execute " + ss);
+ }
+
+ public void execute(liquibase.statement.SqlStatement ss, java.util.List l) {
+ Console.WriteLine("execute " + ss);
+ }
+
+ public bool executesStatements() {
+ throw new NotImplementedException();
+ }
+
+ public void setDatabase(liquibase.database.Database d) {
+ throw new NotImplementedException();
+ }
+
+ public int update(liquibase.statement.SqlStatement ss) {
+ Console.WriteLine("update " + ss);
+ return 1;
+ }
+
+ public int update(liquibase.statement.SqlStatement ss, java.util.List l) {
+ Console.WriteLine("execute " + ss);
+
+ return 1;
+ }
+
+ }
+}
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace LiquiBase {
+ public class LiquiBase {
+
+ }
+}
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{2A4C22C1-4DC9-407E-B559-758694B53BDE}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>LiquiBase</RootNamespace>
+ <AssemblyName>liquibase-clr</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="IKVM.OpenJDK.Core, Version=0.40.0.1, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib-deps\IKVM.OpenJDK.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Jdbc, Version=0.40.0.1, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib-deps\IKVM.OpenJDK.Jdbc.dll</HintPath>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Text, Version=0.40.0.1, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib-deps\IKVM.OpenJDK.Text.dll</HintPath>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.Util, Version=0.40.0.1, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib-deps\IKVM.OpenJDK.Util.dll</HintPath>
+ </Reference>
+ <Reference Include="IKVM.OpenJDK.XML, Version=0.40.0.1, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib-deps\IKVM.OpenJDK.XML.dll</HintPath>
+ </Reference>
+ <Reference Include="IKVM.Runtime, Version=0.40.0.1, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib-deps\IKVM.Runtime.dll</HintPath>
+ </Reference>
+ <Reference Include="liquibase-core, Version=0.0.0.1, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\lib-deps\liquibase-core.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyResourceLoader.cs" />
+ <Compile Include="ClrClassPathScanner.cs" />
+ <Compile Include="Database\AdoConnection.cs" />
+ <Compile Include="Executor\Core\ClrWriteExecutor.cs" />
+ <Compile Include="LiquiBase.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Resource\ClrResourceAccessor.cs" />
+ <Compile Include="Snapshot\Core\OleDatabaseSnapshotGenerator.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Plugin\" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("liquibase")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("liquibase")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("0d080986-189b-4b3e-a3ca-21ba69a5284a")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace LiquiBase.Resource {
+ class ClrResourceAccessor : liquibase.resource.ResourceAccessor {
+
+ public java.io.InputStream getResourceAsStream(string str) {
+ throw new NotImplementedException();
+ }
+
+ public java.util.Enumeration getResources(string str) {
+ throw new NotImplementedException();
+ }
+
+ public java.lang.ClassLoader toClassLoader() {
+ throw new NotImplementedException();
+ }
+
+ }
+}
Oops, something went wrong.

0 comments on commit 50540eb

Please sign in to comment.