Java Doc for Change.java in  » Database-Client » LiquiBase » liquibase » change » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » LiquiBase » liquibase.change 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


liquibase.change.Change

All known Subclasses:   liquibase.change.AbstractChange,
Change
public interface Change (Code)
Interface all changes (refactorings) implement.

How changes are constructed and run when reading changelogs:

  1. As the changelog handler gets to each element inside a changeSet, it passes the tag name to liquibase.change.ChangeFactory which looks through all the registered changes until it finds one with matching specified tag name
  2. The ChangeFactory then constructs a new instance of the change
  3. For each attribute in the XML node, reflection is used to call a corresponding set* method on the change class
  4. The correct generateStatements(*) method is called for the current database

To implement a new change:

  1. Create a new class that implements Change (normally extend AbstractChange)
  2. Implement the abstract generateStatements(*) methods which return the correct SQL calls for each database
  3. Implement the createMessage() method to create a descriptive message for logs and dialogs
  4. Implement the createNode() method to generate an XML element based on the values in this change
  5. Add the new class to the liquibase.change.ChangeFactory

Implementing automatic rollback support

The easiest way to allow automatic rollback support is by overriding the createInverses() method. If there are no corresponding inverse changes, you can override the generateRollbackStatements(*) and canRollBack() methods.

Notes for generated SQL:
Because migration and rollback scripts can be generated for execution at a different time, or against a different database, changes you implement cannot directly reference data in the database. For example, you cannot implement a change that selects all rows from a database and modifies them based on the primary keys you find because when the SQL is actually run, those rows may not longer exist and/or new rows may have been added.

We chose the name "change" over "refactoring" because changes will sometimes change functionality whereas true refactoring will not.
See Also:   ChangeFactory
See Also:   Database





Method Summary
public  booleancanRollBack()
    
public  ElementcreateNode(Document currentChangeLogDOM)
    
public  voidexecuteRollbackStatements(Database database)
    
public  voidexecuteStatements(Database database)
    
public  SqlStatement[]generateRollbackStatements(Database database)
    
public  SqlStatement[]generateStatements(Database database)
    
public  Set<DatabaseObject>getAffectedDatabaseObjects()
    
public  StringgetChangeName()
    
public  ChangeSetgetChangeSet()
    
public  StringgetConfirmationMessage()
    
public  StringgetMD5Sum()
    
public  StringgetTagName()
    
public  voidsaveRollbackStatement(Database database, Writer writer)
    
public  voidsaveStatements(Database database, Writer writer)
    
public  voidsetChangeSet(ChangeSet changeSet)
    
public  voidsetFileOpener(FileOpener fileOpener)
     Sets the fileOpener that should be used for any file loading and resource finding for files that are provided by the user.
public  voidsetUp()
     This method will be called after the no arg constructor and all of the properties have been set to allow the task to do any heavy tasks or more importantly generate any exceptions to report to the user about the settings provided.



Method Detail
canRollBack
public boolean canRollBack()(Code)
Can this change be rolled back true if rollback is supported, false otherwise



createNode
public Element createNode(Document currentChangeLogDOM)(Code)
Creates an XML element (of type Element ) of the change object, and adds it to the Document object passed as argument
Parameters:
  currentChangeLogDOM - the current Document where this element is being added the Element object created



executeRollbackStatements
public void executeRollbackStatements(Database database) throws JDBCException, UnsupportedChangeException, RollbackImpossibleException(Code)
Rolls back the statements in this change against the Database passed as argument
Parameters:
  database - the target Database associated to this change's rollback statements
throws:
  JDBCException - if there were problems executing the rollback statements
throws:
  UnsupportedChangeException - if this change is not supported by the Database passed as argument
throws:
  RollbackImpossibleException - if rollback is not supported for this change



executeStatements
public void executeStatements(Database database) throws JDBCException, UnsupportedChangeException(Code)
Executes the statements in this change against the database passed in the argument
Parameters:
  database - the reference to the target Databaseto which the statements are executed
throws:
  JDBCException - if there were problems executing the statements
throws:
  UnsupportedChangeException - if this change is not supported by the Database passed as argument



generateRollbackStatements
public SqlStatement[] generateRollbackStatements(Database database) throws UnsupportedChangeException, RollbackImpossibleException(Code)
Generates the SQL statements required to roll back the change
Parameters:
  database - database databasethe target Database associated to this change's rollback statements an array of Strings with the rollback statements
throws:
  UnsupportedChangeException - if this change is not supported by the Database passed as argument
throws:
  RollbackImpossibleException - if rollback is not supported for this change



generateStatements
public SqlStatement[] generateStatements(Database database) throws UnsupportedChangeException(Code)
Generates the SQL statements required to run the change
Parameters:
  database - databasethe target Database associated to this change's statements an array of Strings with the statements
throws:
  UnsupportedChangeException - if this change is not supported by the Database passed as argument



getAffectedDatabaseObjects
public Set<DatabaseObject> getAffectedDatabaseObjects()(Code)



getChangeName
public String getChangeName()(Code)
Returns the name of this change the name of the change



getChangeSet
public ChangeSet getChangeSet()(Code)



getConfirmationMessage
public String getConfirmationMessage()(Code)
Confirmation message to be displayed after the change is executed a String containing the message after the change is executed



getMD5Sum
public String getMD5Sum()(Code)
Calculates the MD5 hash for the string representation of the XML element of this change the MD5 hash



getTagName
public String getTagName()(Code)
Returns the tag name of this change the tag name of the change



saveRollbackStatement
public void saveRollbackStatement(Database database, Writer writer) throws IOException, UnsupportedChangeException, RollbackImpossibleException, StatementNotSupportedOnDatabaseException(Code)
Outputs the statements necessary to roll back this change
Parameters:
  database - the target Database associated to this change's rollback statements
Parameters:
  writer - writer the target Writer to which the rollback statements are appended
throws:
  IOException - if there were problems appending the rollback statements to the writer
throws:
  UnsupportedChangeException - if this change is not supported by the Database passed as argument
throws:
  RollbackImpossibleException - if rollback is not supported for this change



saveStatements
public void saveStatements(Database database, Writer writer) throws IOException, UnsupportedChangeException, StatementNotSupportedOnDatabaseException(Code)
Outputs the SQL statements generated by this change
Parameters:
  database - the target Database associated to this change's statements
Parameters:
  writer - the target Writer to which the statements are appended
throws:
  IOException - if there were problems appending the statements to the writer
throws:
  UnsupportedChangeException - if this change is not supported by the Database passed as argument



setChangeSet
public void setChangeSet(ChangeSet changeSet)(Code)



setFileOpener
public void setFileOpener(FileOpener fileOpener)(Code)
Sets the fileOpener that should be used for any file loading and resource finding for files that are provided by the user.



setUp
public void setUp() throws SetupException(Code)
This method will be called after the no arg constructor and all of the properties have been set to allow the task to do any heavy tasks or more importantly generate any exceptions to report to the user about the settings provided.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.