mirror of
https://github.com/corda/corda.git
synced 2025-06-12 20:28:18 +00:00
CORDA-499: Remove further Kt
classes (#1489)
* Change how NetworkHostAndPort is parsed Change from using a global extension function to parse NetworkHostAndPort strings, into using a function on the companion object. This is a lot easier for Java interop and matches the common style used elsewhere both in Corda and in Java libraries. * Move JAR extraction into new utils file * Move path verification function to ArtemisUtils Move path verification function "requireOnDefaultFileSystem()" to new ArtemisUtils.kt file, as this makes more sense from a Java interop perspective. * Add JvmName to AMQPSchemaExtensions * Add JvmName to AMQPSerializationScheme * Revert "Move JAR extraction into new utils file" This reverts commit 1f0f41909b68ff21cc24b5efd6a1a360393a0a14. * Reformat code * Run formatter on ArtemisUtils
This commit is contained in:
@ -7,8 +7,6 @@ import org.apache.activemq.artemis.api.core.TransportConfiguration
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory
|
||||
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants
|
||||
import org.bouncycastle.asn1.x500.X500Name
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Path
|
||||
|
||||
sealed class ConnectionDirection {
|
||||
data class Inbound(val acceptorFactoryClassName: String) : ConnectionDirection()
|
||||
@ -54,8 +52,8 @@ class ArtemisTcpTransport {
|
||||
)
|
||||
|
||||
if (config != null && enableSSL) {
|
||||
config.sslKeystore.expectedOnDefaultFileSystem()
|
||||
config.trustStoreFile.expectedOnDefaultFileSystem()
|
||||
config.sslKeystore.requireOnDefaultFileSystem()
|
||||
config.trustStoreFile.requireOnDefaultFileSystem()
|
||||
val tlsOptions = mapOf(
|
||||
// Enable TLS transport layer with client certs and restrict to at least SHA256 in handshake
|
||||
// and AES encryption
|
||||
@ -81,7 +79,3 @@ class ArtemisTcpTransport {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Path.expectedOnDefaultFileSystem() {
|
||||
require(fileSystem == FileSystems.getDefault()) { "Artemis only uses the default file system" }
|
||||
}
|
||||
|
14
node-api/src/main/kotlin/net/corda/nodeapi/ArtemisUtils.kt
Normal file
14
node-api/src/main/kotlin/net/corda/nodeapi/ArtemisUtils.kt
Normal file
@ -0,0 +1,14 @@
|
||||
@file:JvmName("ArtemisUtils")
|
||||
|
||||
package net.corda.nodeapi
|
||||
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Path
|
||||
|
||||
/**
|
||||
* Require that the [Path] is on a default file system, and therefore is one that Artemis is willing to use.
|
||||
* @throws IllegalArgumentException if the path is not on a default file system.
|
||||
*/
|
||||
fun Path.requireOnDefaultFileSystem() {
|
||||
require(fileSystem == FileSystems.getDefault()) { "Artemis only uses the default file system" }
|
||||
}
|
@ -6,7 +6,6 @@ import com.typesafe.config.ConfigUtil
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.internal.noneOrSingle
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import net.corda.core.utilities.parseNetworkHostAndPort
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.net.Proxy
|
||||
import java.net.URL
|
||||
@ -69,7 +68,7 @@ private fun Config.getSingleValue(path: String, type: KType): Any? {
|
||||
Boolean::class -> getBoolean(path)
|
||||
LocalDate::class -> LocalDate.parse(getString(path))
|
||||
Instant::class -> Instant.parse(getString(path))
|
||||
NetworkHostAndPort::class -> getString(path).parseNetworkHostAndPort()
|
||||
NetworkHostAndPort::class -> NetworkHostAndPort.parse(getString(path))
|
||||
Path::class -> Paths.get(getString(path))
|
||||
URL::class -> URL(getString(path))
|
||||
Properties::class -> getConfig(path).toProperties()
|
||||
@ -97,7 +96,7 @@ private fun Config.getCollectionValue(path: String, type: KType): Collection<Any
|
||||
Boolean::class -> getBooleanList(path)
|
||||
LocalDate::class -> getStringList(path).map(LocalDate::parse)
|
||||
Instant::class -> getStringList(path).map(Instant::parse)
|
||||
NetworkHostAndPort::class -> getStringList(path).map { it.parseNetworkHostAndPort() }
|
||||
NetworkHostAndPort::class -> getStringList(path).map(NetworkHostAndPort.Companion::parse)
|
||||
Path::class -> getStringList(path).map { Paths.get(it) }
|
||||
URL::class -> getStringList(path).map(::URL)
|
||||
CordaX500Name::class -> getStringList(path).map(CordaX500Name.Companion::parse)
|
||||
|
@ -1,3 +1,5 @@
|
||||
@file:JvmName("AMQPSerializationScheme")
|
||||
|
||||
package net.corda.nodeapi.internal.serialization
|
||||
|
||||
import net.corda.core.node.CordaPluginRegistry
|
||||
|
@ -1,3 +1,5 @@
|
||||
@file:JvmName("AMQPSchemaExtensions")
|
||||
|
||||
package net.corda.nodeapi.internal.serialization.carpenter
|
||||
|
||||
import net.corda.nodeapi.internal.serialization.amqp.CompositeType
|
||||
@ -5,7 +7,7 @@ import net.corda.nodeapi.internal.serialization.amqp.RestrictedType
|
||||
import net.corda.nodeapi.internal.serialization.amqp.Field as AMQPField
|
||||
import net.corda.nodeapi.internal.serialization.amqp.Schema as AMQPSchema
|
||||
|
||||
fun AMQPSchema.carpenterSchema(classloader: ClassLoader) : CarpenterMetaSchema {
|
||||
fun AMQPSchema.carpenterSchema(classloader: ClassLoader): CarpenterMetaSchema {
|
||||
val rtn = CarpenterMetaSchema.newInstance()
|
||||
|
||||
types.filterIsInstance<CompositeType>().forEach {
|
||||
|
Reference in New Issue
Block a user