mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
[CORDA-2636] Ensure states created with contract upgrades can be migrated (#4786)
* Ensure states created with contract upgrades can be migrated * Remove line from api-current.txt representing an uncallable constructor
This commit is contained in:
committed by
Tommy Lillehagen
parent
21d32681ff
commit
efabab35c4
@ -0,0 +1,33 @@
|
||||
package net.corda.nodeapi.internal.cordapp
|
||||
|
||||
import net.corda.core.cordapp.Cordapp
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.internal.cordapp.CordappImpl
|
||||
import net.corda.core.schemas.MappedSchema
|
||||
|
||||
/**
|
||||
* Handles loading [Cordapp]s.
|
||||
*/
|
||||
interface CordappLoader : AutoCloseable {
|
||||
|
||||
/**
|
||||
* Returns all [Cordapp]s found.
|
||||
*/
|
||||
val cordapps: List<CordappImpl>
|
||||
|
||||
/**
|
||||
* Returns a [ClassLoader] containing all types from all [Cordapp]s.
|
||||
*/
|
||||
val appClassLoader: ClassLoader
|
||||
|
||||
/**
|
||||
* Returns a map between flow class and owning [Cordapp].
|
||||
* The mappings are unique, and the node will not start otherwise.
|
||||
*/
|
||||
val flowCordappMap: Map<Class<out FlowLogic<*>>, Cordapp>
|
||||
|
||||
/**
|
||||
* Returns all [MappedSchema] found inside the [Cordapp]s.
|
||||
*/
|
||||
val cordappSchemas: Set<MappedSchema>
|
||||
}
|
@ -12,6 +12,7 @@ import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.nodeapi.internal.MigrationHelpers.getMigrationResource
|
||||
import net.corda.core.schemas.MappedSchema
|
||||
import net.corda.core.utilities.contextLogger
|
||||
import net.corda.nodeapi.internal.cordapp.CordappLoader
|
||||
import sun.security.x509.X500Name
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.InputStream
|
||||
@ -28,7 +29,7 @@ class SchemaMigration(
|
||||
val schemas: Set<MappedSchema>,
|
||||
val dataSource: DataSource,
|
||||
private val databaseConfig: DatabaseConfig,
|
||||
private val classLoader: ClassLoader = Thread.currentThread().contextClassLoader,
|
||||
cordappLoader: CordappLoader? = null,
|
||||
private val currentDirectory: Path?,
|
||||
private val ourName: CordaX500Name) {
|
||||
|
||||
@ -36,8 +37,15 @@ class SchemaMigration(
|
||||
private val logger = contextLogger()
|
||||
const val NODE_BASE_DIR_KEY = "liquibase.nodeDaseDir"
|
||||
const val NODE_X500_NAME = "liquibase.nodeName"
|
||||
val loader = ThreadLocal<CordappLoader>()
|
||||
}
|
||||
|
||||
init {
|
||||
loader.set(cordappLoader)
|
||||
}
|
||||
|
||||
private val classLoader = cordappLoader?.appClassLoader ?: Thread.currentThread().contextClassLoader
|
||||
|
||||
/**
|
||||
* Main entry point to the schema migration.
|
||||
* Called during node startup.
|
||||
|
@ -16,7 +16,7 @@ import net.corda.core.serialization.deserialize
|
||||
import net.corda.core.serialization.serialize
|
||||
import net.corda.core.transactions.LedgerTransaction
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.node.cordapp.CordappLoader
|
||||
import net.corda.nodeapi.internal.cordapp.CordappLoader
|
||||
import net.corda.node.internal.cordapp.CordappProviderImpl
|
||||
import net.corda.node.internal.cordapp.JarScanningCordappLoader
|
||||
import net.corda.nodeapi.internal.AttachmentsClassLoaderStaticContractTests.AttachmentDummyContract.Companion.ATTACHMENT_PROGRAM_ID
|
||||
|
Reference in New Issue
Block a user