The deployment of Java EE applications is a significant thing for the deployer. Existing application servers generally support the deployment of applications based on the Web, or hot deployment, or through the deployment of tools. WebSphere Application Server 5.x provides an application programming interface for deployment and management of Java EE applications. This article is written for such a goal.
A. WebSphere Deployment overview
Under normal circumstances, there are a few things you need to do to deploy an application based on Java EE: First, create a data source where you need to specify the Jndi name, and secondly, modify the resource Jndi name and resource reference for the enterprise application. ear file; Third, modify the EJB Jndi name and reference reference of enterprise application. ear file; Automatically deploy the modified enterprise application. Ear file. Finally, restart the WebSphere server.
These steps, if done manually, can be done almost quickly in situations where the EJB component is not many, resource references, and reference references are not many. But imagine that if the same set of applications were to run on the same WebSphere application server, and the EJB components involved, the Jndi name modifications, and the resources (references) were modified a lot, we would need to automate the process with the help of the program.
The Java interface provided by WebSphere (based on JMX technology) can handle the process well. Specific reference materials, you can go to:
Http://www7b.software.ibm.com/wsdd/techjournal/0309_apte/apte.html
Get.
The following is a general process based on the deployment process (because of the complexity of the process, here are just the main ideas).
Ii. automatic creation of data sources
This process will mainly cover the following aspects:
1. Locate the data source that is available on the WebSphere server to see if the name is conflicting with what we will configure.
2. If not, our program creates the required data source.
3. If the JDBC provider for the data source you are creating does not exist, you should create it before step first to second.
With such a few steps, we can realize the automatic creation of the data source.
Here's how to show the sample code:
To create the Adminclient program code:
Properties props = new Properties();
props.setProperty(AdminClient.CONNECTOR_TYPE,
AdminClient.CONNECTOR_TYPE_SOAP);
props.setProperty(AdminClient.CONNECTOR_HOST, ipAddress);
props.setProperty(AdminClient.CONNECTOR_PORT, port);
AdminClient adminClient =
AdminClientFactory.createAdminClient(props);
To locate an existing JDBC Provider:
ConfigService configService = new ConfigServiceProxy(adminClient);
Session session = new Session();
ObjectName[] provider = configService.resolve(session,
"Cell=" + cell + ":Node=" + node + ":JDBCProvider");
ObjectName db2Provider = null;
for (int i = 0; i < provider.length; i++) {
String jdbcProviderName = (String) configService.getAttribute(session,
provider[i], "name");
if (jdbcProviderName.equals("xxx JDBC Provider")) {
db2Provider = provider[i];
break;
}
}
To save the Create data source action:
configService.save(session, true);
configService.discard(session);