Class ContainerConnectionDetailsFactory<C extends org.testcontainers.containers.Container<?>,D extends ConnectionDetails>
java.lang.Object
org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory<C,D>
- Type Parameters:
D
- the connection details typeC
- the container type
- All Implemented Interfaces:
RuntimeHintsRegistrar
,ConnectionDetailsFactory<ContainerConnectionSource<C>,
D>
public abstract class ContainerConnectionDetailsFactory<C extends org.testcontainers.containers.Container<?>,D extends ConnectionDetails>
extends Object
implements ConnectionDetailsFactory<ContainerConnectionSource<C>,D>, RuntimeHintsRegistrar
Base class for
ConnectionDetailsFactory
implementations that provide
ConnectionDetails
from a ContainerConnectionSource
.- Since:
- 3.1.0
- Author:
- Moritz Halbritter, Andy Wilkinson, Phillip Webb
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
ContainerConnectionDetailsFactory.ContainerConnectionDetails<C extends org.testcontainers.containers.Container<?>>
Base class forConnectionDetails
results that are backed by aContainerConnectionSource
. -
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
Constant passed to the constructor when any connection name is accepted. -
Constructor Summary
ModifierConstructorDescriptionprotected
Create a newContainerConnectionDetailsFactory
instance that acceptsany connection name
.protected
ContainerConnectionDetailsFactory
(String connectionName, String... requiredClassNames) Create a newContainerConnectionDetailsFactory
instance with the given connection name restriction. -
Method Summary
Modifier and TypeMethodDescriptionfinal D
Get theConnectionDetails
from the givensource
.protected abstract D
void
registerHints
(RuntimeHints hints, ClassLoader classLoader)
-
Field Details
-
ANY_CONNECTION_NAME
Constant passed to the constructor when any connection name is accepted.
-
-
Constructor Details
-
ContainerConnectionDetailsFactory
protected ContainerConnectionDetailsFactory()Create a newContainerConnectionDetailsFactory
instance that acceptsany connection name
. -
ContainerConnectionDetailsFactory
Create a newContainerConnectionDetailsFactory
instance with the given connection name restriction.- Parameters:
connectionName
- the required connection name orANY_CONNECTION_NAME
requiredClassNames
- the names of classes that must be present
-
-
Method Details
-
getConnectionDetails
Description copied from interface:ConnectionDetailsFactory
- Specified by:
getConnectionDetails
in interfaceConnectionDetailsFactory<C extends org.testcontainers.containers.Container<?>,
D extends ConnectionDetails> - Parameters:
source
- the source- Returns:
- the connection details or
null
-
registerHints
- Specified by:
registerHints
in interfaceRuntimeHintsRegistrar
-
getContainerConnectionDetails
Get theConnectionDetails
from the givenContainerConnectionSource
source
. May returnnull
if no connection can be created. Result types should consider extendingContainerConnectionDetailsFactory.ContainerConnectionDetails
.- Parameters:
source
- the source- Returns:
- the service connection or
null
.
-