*** This class provides Binary Compatibility only, not Source Compatibility ***
Class AbstractDeploymentStrategy
- All Implemented Interfaces:
DeploymentStrategyInterface
DeploymentDescriptorStrategy is the abstract
superclass of classes representing strategies.
Creating a Deployment File
A SAS Foundation Services deployment may be exported from a SAS Metadata Server to a deployment file where each SAS Foundation Service will be represented as a bean. Service configurations may be queried from either a SAS Metadata Server or from a URL that designates a services deployment XML file which has been exported from a Server.
Example 1: Create a Deployment File
This example creates a deployment file by representing a SAS Foundation Services deployment as beans within a container deployment file.
import com.sas.metadata.remote.SoftwareComponent;
// configure a deployment context (OMRDeploymentContext or URLDeploymentContext)
DeploymentContext context = createDeploymentContext();
// the file to which the beans are to be written
File file = getOutputFile();
// the SAS Foundation Services deployment that is to be
// represented as beans in the file
SoftwareComponent softwareComponent = getSoftwareComponent();
// create a file that represents SAS Foundation Services
// for the specified services deployment (i.e. SoftwareComponent)
// using the strategy obtained from the configured context
DeploymentDescriptorStrategy strategy = context.getStrategy();
strategy.createFile(
softwareComponent,
file);
Reconfiguring a XML file
A deployment file may be reconfigured by specifying substitution
properties and invoking the reconfigure method on a configured strategy object.
Code samples are provided for the following substitution scenarios. Refer to
the documentation for
OMRDeploymentContext and
URLDeploymentContext
for a summary of valid properties for each type of deployment context.
- URL to the exported services deployment XML file
- Metadata Server host and port
- Metadata Server repository name
- Metadata Server user ID and password
- SoftwareComponent (services deployment) name
Example 2: Reconfigure the URL specified in a Deployment File
This example reconfigures a deployment file that is configured to query its services configurations from a URL.
// specify the file that contains beans which are to be reconfigured
File inputFile = getInputFile();
// specify the file to which the reconfigured beans should be written
File outputFile = getOutputFile();
// define properties and values which should be substituted
Properties properties = new Properties();
properties.put(
MetadataSourceFactory.PROPERTY_URL,
"file:///C:/xxx/local_services_NEW.xml");
strategy.reconfigure(
properties,
inputFile,
outputFile);
Example 3: Reconfigure the host and port specified in a Deployment File
This example reconfigures a deployment file to change the host and port
for the SAS Metadata Server.
// specify the file that contains beans which are to be reconfigured
File inputFile = getInputFile();
// specify the file to which the reconfigured beans should be written
File outputFile = getOutputFile();
// define properties and values which should be substituted
Properties properties = new Properties();
properties.put(
MetadataSourceFactory.PROPERTY_METADATASERVER_HOST,
"com.newhost");
properties.put(
MetadataSourceFactory.PROPERTY_METADATASERVER_PORT,
"9999");
strategy.reconfigure(
properties,
inputFile,
outputFile);
Example 4: Reconfigure the SoftwareComponent specified in a Deployment File
This example reconfigures a deployment file to change the SoftwareComponent
(i.e. the SAS Foundation Services deployment).
// specify the file that contains beans which are to be reconfigured
File inputFile = getInputFile();
// specify the file to which the reconfigured beans should be written
File outputFile = getOutputFile();
// define properties and values which should be substituted
Properties properties = new Properties();
properties.put(
MetadataSourceFactory.PROPERTY_SOFTWARECOMPONENT,
"New Local Services");
strategy.reconfigure(
properties,
inputFile,
outputFile);
Example 5: Reconfigure the SAS Metadata Repository specified in a Deployment File
This example reconfigures a deployment file to change the SAS Metadata Repository
(i.e. the SAS Foundation Services deployment).
// specify the file that contains beans which are to be reconfigured
File inputFile = getInputFile();
// specify the file to which the reconfigured beans should be written
File outputFile = getOutputFile();
// define properties and values which should be substituted
Properties properties = new Properties();
properties.put(
MetadataSourceFactory.PROPERTY_METADATASERVER_REPOSITORY,
"New Foundation Repository");
strategy.reconfigure(
properties,
inputFile,
outputFile);
Example 6: Reconfigure the user ID and password specified in a Deployment File
This example reconfigures a deployment file to change the user ID and password.
// specify the file that contains beans which are to be reconfigured
File inputFile = getInputFile();
// specify the file to which the reconfigured beans should be written
File outputFile = getOutputFile();
// define properties and values which should be substituted
Properties properties = new Properties();
properties.put(
MetadataSourceFactory.PROPERTY_METADATASERVER_USERID,
"NewUserID");
properties.put(
MetadataSourceFactory.PROPERTY_METADATASERVER_USERPASSWORD,
"NewUserPassword");
strategy.reconfigure(
properties,
inputFile,
outputFile);
- Since:
- 9.2
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractDeploymentStrategy(Properties properties) Constructs a deployment strategy for the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigureBuilder(DocumentBuilder builder) A subclass should implement this method if it needs to configure the document builder.protected abstract voidconfigureDocumentBuilderFactory(DocumentBuilderFactory factory) Configures the document builder factory.protected DocumentcreateClientDocument(Map configProperties) Creates an XML document that represents a deployment a client would use to access foundation services which have been deployed in a remote JVM.protected abstract ElementcreateDiscoveryServiceBean(Document document) Creates an XML element representing the Discovery Service bean and adds it to the document.protected DocumentCreates an XML document representing SAS Foundation services beans that are to be deployed in an IOC container.DocumentcreateDocument(com.sas.metadata.remote.SoftwareComponent softwareComponent, Map configProperties) Creates an XML document representing SAS Foundation services beans that are to be deployed in an IOC container.protected abstract DocumentcreateDocument(DocumentBuilder builder) Creates an XML document using the specified document builder.voidcreateFile(com.sas.metadata.remote.SoftwareComponent softwareComponent, File file) Creates a deployment file which represents SAS Foundation Services as beans which can be deployed in an Inversion of Control (IOC) container.voidcreateFiles(com.sas.metadata.remote.SoftwareComponent softwareComponent, File file, File clientFile) Creates deployment files which represents SAS Foundation Services as beans which can be deployed and looked up by applications using an Inversion of Control (IOC) container.protected abstract voidcreateServiceBeans(Document document, com.sas.metadata.remote.SoftwareComponent softwareComponent, Map configProperties) Creates beans representing the service components.protected abstract voidcreateServiceConfigFactory(Document document) Creates an XML element representing a factory which can be used to create service configurations.protected StringgetBeanIdService(com.sas.metadata.remote.CMetadata cMetadata) Gets the ID for the service that is to be represented as a bean.protected static final StringGets the name of the bean that represents the connection.protected static StringGets the name of the bean that represents the connection factory.protected static final StringGets the name of the bean the represents the discovery service.protected StringGets the name of the bean that represents the metadata source.protected StringGets the name of the bean that represents the configuration for the metadata source.protected static final StringGets the name of the bean the represents the RMIConfiguration bean.protected static final StringGets the name of the bean the represents the RMIRegistry bean.protected static final StringGets the bean name "com.sas.services.discovery.RegistryDiscoveryService" representing a discovery service which can locate foundation services which have been bound to an RMI registry.protected StringgetBeanNameService(com.sas.metadata.remote.CMetadata cMetadata) Gets the name for the service that is to be represented as a bean.protected StringGets the name of the bean that represents the connection.protected StringGets the name of the bean that represents the factory which processes the configuration properties to determine the object that will be used to query a service's configuration.protected static final StringGets the name of the bean the represents the SSLRMISocketFactories bean.protected static final StringGets the method name "createService".protected static final StringGets the method name "getInstance".protected static final StringGets the method name "getRMIRegistry".protected PropertiesgetOutputFormatProperties(Document document) Gets properties which will be used to configure an output format that employs indentation.protected final PropertiesGets the configuration properties which define the foundation services deployment.final StringgetProperty(String key) Gets the value of the property associated with the specified key.protected StringGets an XSLT that can be used to reconfigure the services deployment.voidreconfigure(Properties properties, File inputFile, File outputFile) Reconfigures the deployment using the specified properties that describe the services deployment.final voidsetProperty(String key, String value) Sets a property for the specified key/value.protected abstract voidsetServiceDependencies(Document document, Element element, com.sas.metadata.remote.ServiceComponent serviceComponent) Specify dependencies upon other services.protected final voidwriteFile(File file, String xml) Writes the XML to the specified file using UTF-8 encoding.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
AbstractDeploymentStrategy
public AbstractDeploymentStrategy(Properties properties) Constructs a deployment strategy for the specified properties.- Parameters:
properties- Configuration properties.
-
-
Method Details
-
createDocument
public Document createDocument(com.sas.metadata.remote.SoftwareComponent softwareComponent, Map configProperties) throws ServiceException Creates an XML document representing SAS Foundation services beans that are to be deployed in an IOC container.- Parameters:
softwareComponent- The SAS Foundation Services deployment.configProperties- Configuration properties.- Returns:
- XML document representation of a foundation services deployment.
- Throws:
ServiceException- if unable to create the document.
-
createDocument
Creates an XML document representing SAS Foundation services beans that are to be deployed in an IOC container.- Returns:
- XML document representation of a foundation services deployment.
- Throws:
ServiceException- if unable to create the document.
-
createFile
public void createFile(com.sas.metadata.remote.SoftwareComponent softwareComponent, File file) throws ServiceException Creates a deployment file which represents SAS Foundation Services as beans which can be deployed in an Inversion of Control (IOC) container.}- Specified by:
createFilein interfaceDeploymentStrategyInterface- Parameters:
softwareComponent- The software component that represents a foundation services deployment.file- The output file to which the service deployment metadata will be written.- Throws:
ServiceException- if unable to create a document.
-
createFiles
public void createFiles(com.sas.metadata.remote.SoftwareComponent softwareComponent, File file, File clientFile) throws ServiceException Creates deployment files which represents SAS Foundation Services as beans which can be deployed and looked up by applications using an Inversion of Control (IOC) container.}- Specified by:
createFilesin interfaceDeploymentStrategyInterface- Parameters:
softwareComponent- The software component that represents a foundation services deployment.file- The output file to which beans will be written describing a services deployment from the perspective of an application that is deploying the services.clientFile- The output file to which beans will be written describing a services deployment from the perspective of an application that is looking up remote services remotely.- Throws:
ServiceException- if unable to create a document.
-
reconfigure
public void reconfigure(Properties properties, File inputFile, File outputFile) throws ServiceException Reconfigures the deployment using the specified properties that describe the services deployment.}- Specified by:
reconfigurein interfaceDeploymentStrategyInterface- Parameters:
properties- Properties whose values should be substituted in order to reconfigure the deployment.inputFile- The input file containing the deployment which is to be reconfigured.outputFile- The output file to which the reconfigured deployment will be written.- Throws:
ServiceException- if unable to reconfigure the deployment file.
-
getOutputFormatProperties
protected Properties getOutputFormatProperties(Document document) Gets properties which will be used to configure an output format that employs indentation.- Parameters:
document- Document which will be output.- Returns:
- Output format properties.
- See Also:
-
getProperties
protected final Properties getProperties()Gets the configuration properties which define the foundation services deployment.- Returns:
- Configuration properties which define the foundation services deployment. An Properties object containing no elements will be returned if no properties are configured.
-
setProperty
public final void setProperty(String key, String value) Sets a property for the specified key/value.- Parameters:
key- Key which will be used to lookup a value.value- Value associated with the key.
-
getProperty
public final String getProperty(String key) Gets the value of the property associated with the specified key.- Parameters:
key- Key used to lookup a property.- Returns:
- Value associated with the key or
null.
-
writeFile
Writes the XML to the specified file using UTF-8 encoding.- Parameters:
file- Output file.xml- XML that is to be written to the file.- Throws:
ServiceException- if unable to write the XML to the file.
-
createClientDocument
Creates an XML document that represents a deployment a client would use to access foundation services which have been deployed in a remote JVM.- Parameters:
configProperties- Properties that describe how a client configuration for remotely accessing a discovery service.- Returns:
- XML document representing the services a client would use
to access the remotely accessible foundation services or
nullif creation of a client document is unsupported. - Throws:
ServiceException- if unable to create the client document.
-
getBeanNameConnectionFactory
protected static String getBeanNameConnectionFactory()Gets the name of the bean that represents the connection factory.- Returns:
- Name of the bean that represents the connection factory.
-
getBeanNameConnection
protected static final String getBeanNameConnection()Gets the name of the bean that represents the connection.- Returns:
- Name of the bean that represents the connection.
-
getBeanNameServiceConfigFactory
protected String getBeanNameServiceConfigFactory()Gets the name of the bean that represents the connection.- Returns:
- Name of the bean that represents the connection.
-
getBeanNameServiceMetadataFactory
protected String getBeanNameServiceMetadataFactory()Gets the name of the bean that represents the factory which processes the configuration properties to determine the object that will be used to query a service's configuration.- Returns:
- Name of the bean that represents the factory which processes the configuration properties to determine the object that will be used to query a service's configuration.
-
getBeanNameMetadataSourceProperties
protected String getBeanNameMetadataSourceProperties()Gets the name of the bean that represents the configuration for the metadata source.- Returns:
- Name of the bean that represents the configuration properties.
-
getBeanNameMetadataSource
protected String getBeanNameMetadataSource()Gets the name of the bean that represents the metadata source.- Returns:
- Name of the bean that represents the metadata source.
-
getBeanNameSSLRMISocketFactories
protected static final String getBeanNameSSLRMISocketFactories()Gets the name of the bean the represents the SSLRMISocketFactories bean.- Returns:
- Name of the bean that represents the SSLRMISocketFactories bean.
-
getBeanNameRMIConfiguration
protected static final String getBeanNameRMIConfiguration()Gets the name of the bean the represents the RMIConfiguration bean.- Returns:
- Name of the bean that represents the RMIConfiguration bean.
-
getBeanNameRMIRegistry
protected static final String getBeanNameRMIRegistry()Gets the name of the bean the represents the RMIRegistry bean.- Returns:
- Name of the bean that represents the RMIRegistry bean.
-
getBeanNameDiscoveryService
protected static final String getBeanNameDiscoveryService()Gets the name of the bean the represents the discovery service.- Returns:
- Name of the bean that represents the discovery service.
-
getMethodNameGetInstance
protected static final String getMethodNameGetInstance()Gets the method name "getInstance".- Returns:
- Method name "getInstance".
-
getMethodNameCreateService
protected static final String getMethodNameCreateService()Gets the method name "createService".Each service factory must implement the following method.
public static createService(com.sas.services.ServiceConfigurationInterface, com.sas.services.discovery.DiscoveryServiceInterface).- Returns:
- Method name "createService".
-
getMethodNameGetRMIRegistry
protected static final String getMethodNameGetRMIRegistry()Gets the method name "getRMIRegistry".- Returns:
- Method name "getRMIRegistry".
-
getBeanNameRMIRegistryDiscoveryService
protected static final String getBeanNameRMIRegistryDiscoveryService()Gets the bean name "com.sas.services.discovery.RegistryDiscoveryService" representing a discovery service which can locate foundation services which have been bound to an RMI registry.- Returns:
- Bean name "com.sas.services.discovery.RegistryDiscoveryService".
-
getBeanIdService
protected String getBeanIdService(com.sas.metadata.remote.CMetadata cMetadata) throws ServiceException Gets the ID for the service that is to be represented as a bean.- Parameters:
cMetadata-ServiceComponentmetadata representing a service.- Returns:
- Id of the bean that represents a service.
- Throws:
ServiceException- if unable to determine the service's ID.
-
getBeanNameService
protected String getBeanNameService(com.sas.metadata.remote.CMetadata cMetadata) throws ServiceException Gets the name for the service that is to be represented as a bean.- Parameters:
cMetadata-ServiceComponentmetadata representing a service.- Returns:
- Name of the bean that represents a service.
- Throws:
ServiceException- if unable to determine the name of the service.
-
configureBuilder
protected void configureBuilder(DocumentBuilder builder) A subclass should implement this method if it needs to configure the document builder.This implementation registers a SAXErrorHandler which will log exceptions.
- Parameters:
builder-
-
setServiceDependencies
protected abstract void setServiceDependencies(Document document, Element element, com.sas.metadata.remote.ServiceComponent serviceComponent) throws ServiceException Specify dependencies upon other services.- Parameters:
document-element-serviceComponent-- Throws:
ServiceException
-
getReconfigurationXSLT
protected String getReconfigurationXSLT()Gets an XSLT that can be used to reconfigure the services deployment.A sub-class should must override this method in order to transform XML using XSLT.
- Returns:
- XSLT to reconfigure the services deployment or
nullif an XSLT is not used to reconfigure the deployment.
-
configureDocumentBuilderFactory
protected abstract void configureDocumentBuilderFactory(DocumentBuilderFactory factory) throws ServiceException Configures the document builder factory.- Parameters:
factory- Document builder factory that is to be configured.- Throws:
ServiceException
-
createDocument
Creates an XML document using the specified document builder.- Parameters:
builder- Document builder.- Returns:
- XML document.
- Throws:
ServiceException- if unable to create an XML document.
-
createDiscoveryServiceBean
Creates an XML element representing the Discovery Service bean and adds it to the document.- Parameters:
document- XML document for which a document fragment should be created.- Returns:
- Element representing the discovery service bean which has been added to the document.
- Throws:
ServiceException- if unable to create a bean that represents the Discovery Service.
-
createServiceConfigFactory
Creates an XML element representing a factory which can be used to create service configurations.- Parameters:
document- XML document for which a document fragment should be created.- Throws:
ServiceException- if unable to create a factory which can be used to create service configurations.
-
createServiceBeans
protected abstract void createServiceBeans(Document document, com.sas.metadata.remote.SoftwareComponent softwareComponent, Map configProperties) throws ServiceException Creates beans representing the service components.- Parameters:
document-softwareComponent-configProperties-- Throws:
ServiceException
-