The Deployment Service needs to know which environment and instance are currently running.
This can be established by one of two ways. First, either the environment name and/or
instance name can be defined directly in the configuration file. This means that the names
can actually be stored as
Deployment Properties.
The second way is to create a NameLookup
component that knows how to
get the environment or instance name from some other location. In this case, the NameLookup
component would be defined in the configuration file. Note that these two methods can work together.
A NameLookup
can be defined to specify the instance name and the environment
name can be defined directly in configuration or vice versa.
If the instance name is not defined, the service creates a link
to a configuration named by the environment. If the instance is defined, the service
creates a link to a configuration named by the instance within a folder named by
the environment. See the following example of a Deployment Service configuraiton.
The following example defines environment and instance names directly within the configuration
file. It also uses Deployment Properties to look up the actual values (thus the {...} notation).
Example Deployment Service Configuration
<Configuration
ConfigurationInterface="org.sape.carbon.services.deployment.DeploymentServiceConfiguration">
<FunctionalImplementationClass>org.sape.carbon.services.deployment.DefaultDeploymentServiceImpl</FunctionalImplementationClass>
<FunctionalInterface>org.sape.carbon.services.deployment.DeploymentService</FunctionalInterface>
<DeploymentsNodeAbsoluteName>/deployment/deployments</DeploymentsNodeAbsoluteName>
<CurrentDeploymentNodeName>CurrentDeploymentLink</CurrentDeploymentNodeName>
<EnvironmentName>{carbon.environment.name}</EnvironmentName>
<InstanceName>{carbon.instance.name}</InstanceName>
</Configuration>
The next example uses a LocalHostNameLookup define the instance name. To create your own NameLookup
,
create a component that uses org.sape.carbon.services.deployment.namelookup.NameLookup
as its
functional interface.
Example Deployment Service Configuration
<Configuration
ConfigurationInterface="org.sape.carbon.services.deployment.DeploymentServiceConfiguration">
<FunctionalImplementationClass>org.sape.carbon.services.deployment.DefaultDeploymentServiceImpl</FunctionalImplementationClass>
<FunctionalInterface>org.sape.carbon.services.deployment.DeploymentService</FunctionalInterface>
<DeploymentsNodeAbsoluteName>/deployment/deployments</DeploymentsNodeAbsoluteName>
<CurrentDeploymentNodeName>CurrentDeploymentLink</CurrentDeploymentNodeName>
<EnvironmentName>{carbon.environment.name}</EnvironmentName>
<InstanceNameLookup ConfigurationInterface="org.sape.carbon.core.component.ComponentConfiguration">
<FunctionalImplementationClass>org.sape.carbon.services.deployment.namelookup.LocalHostNameLookup</FunctionalImplementationClass>
<FunctionalInterface>org.sape.carbon.services.deployment.namelookup.NameLookup</FunctionalInterface>
</InstanceNameLookup>
</Configuration>
DeploymentsNodeAbsoluteName
specifies the location of the deployment
specific configurations. CurrentDeploymentNodeName
specifies the name
of the link the service needs to create as well as the name of the link clients should
reference. Below is the configuration folder structure for the first example.
Folder Structure
/deployment/deployments
+--CurrentDeploymentLink
+--Development
+--Production
+--Production
+--Instance1
+--Instance2
The items in bold above are the targets of CurrentDeploymentLink. Note the
document named Production within the folder named Production. That document
contains the configuration values that do not vary by instace. It is
the configuration extended by Instance1 and Instance2. In order for
Instance1 and Instance2 to extend Production, they all must be
PropertyConfiguration
s.
Property replacement can now be used within other configurations to access
the deployment specific configuration values. For example, a configuration
of type QuoteServiceConfiguration
has a property named
QuoteServiceURL
. The configuration would be as follows:
QuoteServiceConfiguration
<Configuration
ConfigurationInterface="...QuoteServiceConfiguration">
<QuoteServiceURL>{/deployment/deployments/CurrentDeploymentLink$QuoteServiceURL}</QuoteServiceURL>
</Configuration>
The actual value for QuoteServiceURL would then be retrieved at runtime from
CurrentDeploymentLink's target, taking the value of QuoteServiceURL within that
configuration.