|
Foundation |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.services.deployment.AbstractDeploymentStrategy
public abstract class AbstractDeploymentStrategy
The class DeploymentDescriptorStrategy
is the abstract
superclass of classes representing strategies.
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.
This example creates a deployment file by representing a SAS Foundation Services deployment as beans within a container deployment file.
import com.sas.metadata.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.
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);
Constructor Summary | |
---|---|
AbstractDeploymentStrategy(java.util.Properties properties)
Constructs a deployment strategy for the specified properties. |
Method Summary | |
---|---|
protected void |
configureBuilder(javax.xml.parsers.DocumentBuilder builder)
A subclass should implement this method if it needs to configure the document builder. |
protected abstract void |
configureDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory factory)
Configures the document builder factory. |
protected org.w3c.dom.Document |
createClientDocument(java.util.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 org.w3c.dom.Element |
createDiscoveryServiceBean(org.w3c.dom.Document document)
Creates an XML element representing the Discovery Service bean and adds it to the document. |
protected org.w3c.dom.Document |
createDocument()
Creates an XML document representing SAS Foundation services beans that are to be deployed in an IOC container. |
protected abstract org.w3c.dom.Document |
createDocument(javax.xml.parsers.DocumentBuilder builder)
Creates an XML document using the specified document builder. |
org.w3c.dom.Document |
createDocument(com.sas.metadata.remote.SoftwareComponent softwareComponent,
java.util.Map configProperties)
Creates an XML document representing SAS Foundation services beans that are to be deployed in an IOC container. |
void |
createFile(com.sas.metadata.remote.SoftwareComponent softwareComponent,
java.io.File file)
Creates a deployment file which represents SAS Foundation Services as beans which can be deployed in an Inversion of Control (IOC) container. |
void |
createFiles(com.sas.metadata.remote.SoftwareComponent softwareComponent,
java.io.File file,
java.io.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 void |
createServiceBeans(org.w3c.dom.Document document,
com.sas.metadata.remote.SoftwareComponent softwareComponent,
java.util.Map configProperties)
Creates beans representing the service components. |
protected abstract void |
createServiceConfigFactory(org.w3c.dom.Document document)
Creates an XML element representing a factory which can be used to create service configurations. |
protected java.lang.String |
getBeanIdService(com.sas.metadata.remote.CMetadata cMetadata)
Gets the ID for the service that is to be represented as a bean. |
protected static java.lang.String |
getBeanNameConnection()
Gets the name of the bean that represents the connection. |
protected static java.lang.String |
getBeanNameConnectionFactory()
Gets the name of the bean that represents the connection factory. |
protected static java.lang.String |
getBeanNameDiscoveryService()
Gets the name of the bean the represents the discovery service. |
protected java.lang.String |
getBeanNameMetadataSource()
Gets the name of the bean that represents the metadata source. |
protected java.lang.String |
getBeanNameMetadataSourceProperties()
Gets the name of the bean that represents the configuration for the metadata source. |
protected static java.lang.String |
getBeanNameRMIConfiguration()
Gets the name of the bean the represents the RMIConfiguration bean. |
protected static java.lang.String |
getBeanNameRMIRegistry()
Gets the name of the bean the represents the RMIRegistry bean. |
protected static java.lang.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. |
protected java.lang.String |
getBeanNameService(com.sas.metadata.remote.CMetadata cMetadata)
Gets the name for the service that is to be represented as a bean. |
protected java.lang.String |
getBeanNameServiceConfigFactory()
Gets the name of the bean that represents the connection. |
protected java.lang.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. |
protected static java.lang.String |
getBeanNameSSLRMISocketFactories()
Gets the name of the bean the represents the SSLRMISocketFactories bean. |
protected static java.lang.String |
getMethodNameCreateService()
Gets the method name "createService". |
protected static java.lang.String |
getMethodNameGetInstance()
Gets the method name "getInstance". |
protected static java.lang.String |
getMethodNameGetRMIRegistry()
Gets the method name "getRMIRegistry". |
protected java.util.Properties |
getOutputFormatProperties(org.w3c.dom.Document document)
Gets properties which will be used to configure an output format that employs indentation. |
protected java.util.Properties |
getProperties()
Gets the configuration properties which define the foundation services deployment. |
java.lang.String |
getProperty(java.lang.String key)
Gets the value of the property associated with the specified key. |
protected java.lang.String |
getReconfigurationXSLT()
Gets an XSLT that can be used to reconfigure the services deployment. |
void |
reconfigure(java.util.Properties properties,
java.io.File inputFile,
java.io.File outputFile)
Reconfigures the deployment using the specified properties that describe the services deployment. |
void |
setProperty(java.lang.String key,
java.lang.String value)
Sets a property for the specified key/value. |
protected abstract void |
setServiceDependencies(org.w3c.dom.Document document,
org.w3c.dom.Element element,
com.sas.metadata.remote.ServiceComponent serviceComponent)
Specify dependencies upon other services. |
protected void |
writeFile(java.io.File file,
java.lang.String xml)
Writes the XML to the specified file using UTF-8 encoding. |
Constructor Detail |
---|
public AbstractDeploymentStrategy(java.util.Properties properties)
properties
- Configuration properties.Method Detail |
---|
public org.w3c.dom.Document createDocument(com.sas.metadata.remote.SoftwareComponent softwareComponent, java.util.Map configProperties) throws ServiceException
softwareComponent
- The SAS Foundation Services deployment.configProperties
- Configuration properties.
ServiceException
- if unable to create the document.protected org.w3c.dom.Document createDocument() throws ServiceException
ServiceException
- if unable to create the document.public void createFile(com.sas.metadata.remote.SoftwareComponent softwareComponent, java.io.File file) throws ServiceException
createFile
in interface DeploymentStrategyInterface
softwareComponent
- The software component that represents a foundation services deployment.file
- The output file to which the service deployment metadata will be written.
ServiceException
- if unable to create a document.public void createFiles(com.sas.metadata.remote.SoftwareComponent softwareComponent, java.io.File file, java.io.File clientFile) throws ServiceException
createFiles
in interface DeploymentStrategyInterface
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.
ServiceException
- if unable to create a document.public void reconfigure(java.util.Properties properties, java.io.File inputFile, java.io.File outputFile) throws ServiceException
reconfigure
in interface DeploymentStrategyInterface
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.
ServiceException
- if unable to reconfigure the deployment file.protected java.util.Properties getOutputFormatProperties(org.w3c.dom.Document document)
document
- Document which will be output.
OutputKeys
protected final java.util.Properties getProperties()
public final void setProperty(java.lang.String key, java.lang.String value)
key
- Key which will be used to lookup a value.value
- Value associated with the key.public final java.lang.String getProperty(java.lang.String key)
key
- Key used to lookup a property.
null
.protected final void writeFile(java.io.File file, java.lang.String xml) throws ServiceException
file
- Output file.xml
- XML that is to be written to the file.
ServiceException
- if unable to write the XML to the file.protected org.w3c.dom.Document createClientDocument(java.util.Map configProperties) throws ServiceException
configProperties
- Properties that describe how a client configuration for
remotely accessing a discovery service.
null
if creation of a client document is unsupported.
ServiceException
- if unable to create the client document.protected static java.lang.String getBeanNameConnectionFactory()
protected static final java.lang.String getBeanNameConnection()
protected java.lang.String getBeanNameServiceConfigFactory()
protected java.lang.String getBeanNameServiceMetadataFactory()
protected java.lang.String getBeanNameMetadataSourceProperties()
protected java.lang.String getBeanNameMetadataSource()
protected static final java.lang.String getBeanNameSSLRMISocketFactories()
protected static final java.lang.String getBeanNameRMIConfiguration()
protected static final java.lang.String getBeanNameRMIRegistry()
protected static final java.lang.String getBeanNameDiscoveryService()
protected static final java.lang.String getMethodNameGetInstance()
protected static final java.lang.String getMethodNameCreateService()
Each service factory must implement the following method.
public static createService(com.sas.services.ServiceConfigurationInterface, com.sas.services.discovery.DiscoveryServiceInterface)
.
protected static final java.lang.String getMethodNameGetRMIRegistry()
protected static final java.lang.String getBeanNameRMIRegistryDiscoveryService()
protected java.lang.String getBeanIdService(com.sas.metadata.remote.CMetadata cMetadata) throws ServiceException
cMetadata
- ServiceComponent
metadata representing a service.
ServiceException
- if unable to determine the service's ID.protected java.lang.String getBeanNameService(com.sas.metadata.remote.CMetadata cMetadata) throws ServiceException
cMetadata
- ServiceComponent
metadata representing a service.
ServiceException
- if unable to determine the name of the service.protected void configureBuilder(javax.xml.parsers.DocumentBuilder builder)
This implementation registers a SAXErrorHandler which will log exceptions.
builder
- protected abstract void setServiceDependencies(org.w3c.dom.Document document, org.w3c.dom.Element element, com.sas.metadata.remote.ServiceComponent serviceComponent) throws ServiceException
document
- element
- serviceComponent
-
ServiceException
protected java.lang.String getReconfigurationXSLT()
A sub-class should must override this method in order to transform XML using XSLT.
null
if an XSLT is not used to reconfigure the deployment.protected abstract void configureDocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory factory) throws ServiceException
factory
- Document builder factory that is to be configured.
ServiceException
protected abstract org.w3c.dom.Document createDocument(javax.xml.parsers.DocumentBuilder builder) throws ServiceException
builder
- Document builder.
ServiceException
- if unable to create an XML document.protected abstract org.w3c.dom.Element createDiscoveryServiceBean(org.w3c.dom.Document document) throws ServiceException
document
- XML document for which a document fragment should be created.
ServiceException
- if unable to create a bean that represents
the Discovery Service.protected abstract void createServiceConfigFactory(org.w3c.dom.Document document) throws ServiceException
document
- XML document for which a document fragment should be created.
ServiceException
- if unable to create a factory which can
be used to create service configurations.protected abstract void createServiceBeans(org.w3c.dom.Document document, com.sas.metadata.remote.SoftwareComponent softwareComponent, java.util.Map configProperties) throws ServiceException
document
- softwareComponent
- configProperties
-
ServiceException
|
Foundation |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |