mirror of
https://github.com/corda/corda.git
synced 2025-06-17 22:58:19 +00:00
CordApps back in node classpath (#2843) [CORDA-1232]
This commit is contained in:
@ -52,8 +52,7 @@ class CordaPersistence(
|
|||||||
val dataSource: DataSource,
|
val dataSource: DataSource,
|
||||||
databaseConfig: DatabaseConfig,
|
databaseConfig: DatabaseConfig,
|
||||||
schemas: Set<MappedSchema>,
|
schemas: Set<MappedSchema>,
|
||||||
attributeConverters: Collection<AttributeConverter<*, *>> = emptySet(),
|
attributeConverters: Collection<AttributeConverter<*, *>> = emptySet()
|
||||||
val cordappClassLoader: ClassLoader? = null
|
|
||||||
) : Closeable {
|
) : Closeable {
|
||||||
companion object {
|
companion object {
|
||||||
private val log = contextLogger()
|
private val log = contextLogger()
|
||||||
@ -62,7 +61,7 @@ class CordaPersistence(
|
|||||||
private val defaultIsolationLevel = databaseConfig.transactionIsolationLevel
|
private val defaultIsolationLevel = databaseConfig.transactionIsolationLevel
|
||||||
val hibernateConfig: HibernateConfiguration by lazy {
|
val hibernateConfig: HibernateConfiguration by lazy {
|
||||||
transaction {
|
transaction {
|
||||||
HibernateConfiguration(schemas, databaseConfig, attributeConverters, cordappClassLoader)
|
HibernateConfiguration(schemas, databaseConfig, attributeConverters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val entityManagerFactory get() = hibernateConfig.sessionFactoryForRegisteredSchemas
|
val entityManagerFactory get() = hibernateConfig.sessionFactoryForRegisteredSchemas
|
||||||
|
@ -82,6 +82,7 @@ public class CordaCaplet extends Capsule {
|
|||||||
|
|
||||||
(new File(baseDir, "cordapps")).mkdir();
|
(new File(baseDir, "cordapps")).mkdir();
|
||||||
// Add additional directories of JARs to the classpath (at the end). e.g. for JDBC drivers
|
// Add additional directories of JARs to the classpath (at the end). e.g. for JDBC drivers
|
||||||
|
augmentClasspath((List<Path>) cp, new File(baseDir, "cordapps"));
|
||||||
try {
|
try {
|
||||||
List<String> jarDirs = nodeConfig.getStringList("jarDirs");
|
List<String> jarDirs = nodeConfig.getStringList("jarDirs");
|
||||||
log(LOG_VERBOSE, "Configured JAR directories = " + jarDirs);
|
log(LOG_VERBOSE, "Configured JAR directories = " + jarDirs);
|
||||||
|
@ -643,7 +643,7 @@ abstract class AbstractNode(val configuration: NodeConfiguration,
|
|||||||
protected open fun initialiseDatabasePersistence(schemaService: SchemaService, identityService: IdentityService): CordaPersistence {
|
protected open fun initialiseDatabasePersistence(schemaService: SchemaService, identityService: IdentityService): CordaPersistence {
|
||||||
val props = configuration.dataSourceProperties
|
val props = configuration.dataSourceProperties
|
||||||
if (props.isEmpty()) throw DatabaseConfigurationException("There must be a database configured.")
|
if (props.isEmpty()) throw DatabaseConfigurationException("There must be a database configured.")
|
||||||
val database = configureDatabase(props, configuration.database, identityService, schemaService, cordappLoader.appClassLoader)
|
val database = configureDatabase(props, configuration.database, identityService, schemaService)
|
||||||
// Now log the vendor string as this will also cause a connection to be tested eagerly.
|
// Now log the vendor string as this will also cause a connection to be tested eagerly.
|
||||||
logVendorString(database, log)
|
logVendorString(database, log)
|
||||||
runOnStop += database::close
|
runOnStop += database::close
|
||||||
@ -879,8 +879,7 @@ internal class NetworkMapCacheEmptyException : Exception()
|
|||||||
fun configureDatabase(hikariProperties: Properties,
|
fun configureDatabase(hikariProperties: Properties,
|
||||||
databaseConfig: DatabaseConfig,
|
databaseConfig: DatabaseConfig,
|
||||||
identityService: IdentityService,
|
identityService: IdentityService,
|
||||||
schemaService: SchemaService = NodeSchemaService(),
|
schemaService: SchemaService = NodeSchemaService()): CordaPersistence {
|
||||||
cordappClassLoader: ClassLoader? = null): CordaPersistence {
|
|
||||||
// Register the AbstractPartyDescriptor so Hibernate doesn't warn when encountering AbstractParty. Unfortunately
|
// Register the AbstractPartyDescriptor so Hibernate doesn't warn when encountering AbstractParty. Unfortunately
|
||||||
// Hibernate warns about not being able to find a descriptor if we don't provide one, but won't use it by default
|
// Hibernate warns about not being able to find a descriptor if we don't provide one, but won't use it by default
|
||||||
// so we end up providing both descriptor and converter. We should re-examine this in later versions to see if
|
// so we end up providing both descriptor and converter. We should re-examine this in later versions to see if
|
||||||
@ -888,5 +887,5 @@ fun configureDatabase(hikariProperties: Properties,
|
|||||||
JavaTypeDescriptorRegistry.INSTANCE.addDescriptor(AbstractPartyDescriptor(identityService))
|
JavaTypeDescriptorRegistry.INSTANCE.addDescriptor(AbstractPartyDescriptor(identityService))
|
||||||
val dataSource = DataSourceFactory.createDataSource(hikariProperties)
|
val dataSource = DataSourceFactory.createDataSource(hikariProperties)
|
||||||
val attributeConverters = listOf(AbstractPartyToX500NameAsStringConverter(identityService))
|
val attributeConverters = listOf(AbstractPartyToX500NameAsStringConverter(identityService))
|
||||||
return CordaPersistence(dataSource, databaseConfig, schemaService.schemaOptions.keys, attributeConverters, cordappClassLoader)
|
return CordaPersistence(dataSource, databaseConfig, schemaService.schemaOptions.keys, attributeConverters)
|
||||||
}
|
}
|
||||||
|
@ -173,8 +173,6 @@ open class Node(configuration: NodeConfiguration,
|
|||||||
printBasicNodeInfo("Advertised P2P messaging addresses", info.addresses.joinToString())
|
printBasicNodeInfo("Advertised P2P messaging addresses", info.addresses.joinToString())
|
||||||
rpcServerAddresses?.let {
|
rpcServerAddresses?.let {
|
||||||
rpcMessagingClient = RPCMessagingClient(configuration.rpcOptions.sslConfig, it.admin, /*networkParameters.maxMessageSize*/MAX_FILE_SIZE)
|
rpcMessagingClient = RPCMessagingClient(configuration.rpcOptions.sslConfig, it.admin, /*networkParameters.maxMessageSize*/MAX_FILE_SIZE)
|
||||||
printBasicNodeInfo("RPC connection address", it.primary.toString())
|
|
||||||
printBasicNodeInfo("RPC admin connection address", it.admin.toString())
|
|
||||||
}
|
}
|
||||||
verifierMessagingClient = when (configuration.verifierType) {
|
verifierMessagingClient = when (configuration.verifierType) {
|
||||||
VerifierType.OutOfProcess -> throw IllegalArgumentException("OutOfProcess verifier not supported") //VerifierMessagingClient(configuration, serverAddress, services.monitoringService.metrics, /*networkParameters.maxMessageSize*/MAX_FILE_SIZE)
|
VerifierType.OutOfProcess -> throw IllegalArgumentException("OutOfProcess verifier not supported") //VerifierMessagingClient(configuration, serverAddress, services.monitoringService.metrics, /*networkParameters.maxMessageSize*/MAX_FILE_SIZE)
|
||||||
|
@ -102,7 +102,7 @@ open class MockServices private constructor(
|
|||||||
val cordappLoader = CordappLoader.createWithTestPackages(cordappPackages)
|
val cordappLoader = CordappLoader.createWithTestPackages(cordappPackages)
|
||||||
val dataSourceProps = makeTestDataSourceProperties()
|
val dataSourceProps = makeTestDataSourceProperties()
|
||||||
val schemaService = NodeSchemaService(cordappLoader.cordappSchemas)
|
val schemaService = NodeSchemaService(cordappLoader.cordappSchemas)
|
||||||
val database = configureDatabase(dataSourceProps, DatabaseConfig(), identityService, schemaService, cordappLoader.appClassLoader)
|
val database = configureDatabase(dataSourceProps, DatabaseConfig(), identityService, schemaService)
|
||||||
val mockService = database.transaction {
|
val mockService = database.transaction {
|
||||||
object : MockServices(cordappLoader, identityService, networkParameters, initialIdentity, moreKeys) {
|
object : MockServices(cordappLoader, identityService, networkParameters, initialIdentity, moreKeys) {
|
||||||
override val vaultService: VaultService = makeVaultService(database.hibernateConfig, schemaService)
|
override val vaultService: VaultService = makeVaultService(database.hibernateConfig, schemaService)
|
||||||
|
Reference in New Issue
Block a user