dev@glassfish.java.net

code review request: admin/config-api, issue 13462

From: Bobby Bissett <bobby.bissett_at_oracle.com>
Date: Thu, 16 Sep 2010 12:08:49 -0400

Since this touches a few different people's code, am sending it to anyone who cares to look. Issue is:
https://glassfish.dev.java.net/issues/show_bug.cgi?id=13462

Fix is the same in each class: iterate over all the configs to get the info to be upgraded. Let me know if there's a problem with any of it (I haven't fully tested, but in the interest of avoiding duplicate work I wanted to get code out early).


hostname% pwd
/Users/bobby/work/ws/v3/admin/config-api
hostname% svn diff
Index: src/main/java/org/glassfish/config/support/HttpServicePropertiesUpgrade.java
===================================================================
--- src/main/java/org/glassfish/config/support/HttpServicePropertiesUpgrade.java (revision 40929)
+++ src/main/java/org/glassfish/config/support/HttpServicePropertiesUpgrade.java (working copy)
@@ -41,6 +41,8 @@
 package org.glassfish.config.support;
 
 import com.sun.enterprise.config.serverbeans.AccessLog;
+import com.sun.enterprise.config.serverbeans.Config;
+import com.sun.enterprise.config.serverbeans.Configs;
 import com.sun.enterprise.config.serverbeans.HttpService;
 import org.glassfish.api.admin.AdminCommandContext;
 import org.jvnet.hk2.annotations.Inject;
@@ -57,33 +59,40 @@
 
 @Service
 public class HttpServicePropertiesUpgrade extends BaseLegacyConfigurationUpgrade {
+
     @Inject
- private HttpService service;
+ private Configs configs;
 
     public void execute(AdminCommandContext context) {
- boolean done = false;
- try {
- final List<Property> properties = service.getProperty();
- final Iterator<Property> iterator = properties.iterator();
- while (!done && iterator.hasNext()) {
- final Property property = iterator.next();
- String name = property.getName();
- if ("accessLoggingEnabled".equals(name)
- || "accessLogBufferSize".equals(name)
- || "accessLogWriteInterval".equals(name)
- || "sso-enabled".equals(name)) {
- done = true;
- upgrade(context, property);
+ for (Config config : configs.getConfig()) {
+ HttpService service = config.getHttpService();
+ boolean done = false;
+ try {
+ final List<Property> properties = service.getProperty();
+ final Iterator<Property> iterator = properties.iterator();
+ while (!done && iterator.hasNext()) {
+ final Property property = iterator.next();
+ String name = property.getName();
+ if ("accessLoggingEnabled".equals(name)
+ || "accessLogBufferSize".equals(name)
+ || "accessLogWriteInterval".equals(name)
+ || "sso-enabled".equals(name)) {
+ done = true;
+ upgrade(context, property, service);
+ }
                 }
+ } catch (TransactionFailure tf) {
+ Logger.getAnonymousLogger().log(Level.SEVERE, "Failure while upgrading http-service properties."
+ + " Please check logs for errors", tf);
+ throw new RuntimeException(tf);
             }
- } catch (TransactionFailure tf) {
- Logger.getAnonymousLogger().log(Level.SEVERE, "Failure while upgrading http-service properties."
- + " Please check logs for errors", tf);
- throw new RuntimeException(tf);
         }
     }
 
- private void upgrade(final AdminCommandContext context, final Property property) throws TransactionFailure {
+ private void upgrade(final AdminCommandContext context,
+ final Property property, final HttpService service)
+ throws TransactionFailure {
+
         if ("accessLoggingEnabled".equals(property.getName())) {
             updatePropertyToAttribute(context, service, "accessLoggingEnabled", "accessLoggingEnabled");
         } else if ("accessLogBufferSize".equals(property.getName())) {
Index: src/main/java/org/glassfish/config/support/GrizzlyConfigSchemaMigrator.java
===================================================================
--- src/main/java/org/glassfish/config/support/GrizzlyConfigSchemaMigrator.java (revision 40929)
+++ src/main/java/org/glassfish/config/support/GrizzlyConfigSchemaMigrator.java (working copy)
@@ -94,16 +94,17 @@
     private static final String HTTP_THREAD_POOL = "http-thread-pool";
 
     public void postConstruct() {
- try {
- final Config config = domain.getConfigs().getConfig().get(0);
- rectifyThreadPools(config);
- processHttpListeners(config);
- promoteHttpServiceProperties(config.getHttpService());
- promoteVirtualServerProperties(config.getHttpService());
- promoteSystemProperties();
- } catch (TransactionFailure tf) {
- Logger.getAnonymousLogger().log(Level.SEVERE, "Failure while upgrading domain.xml. Please redeploy", tf);
- throw new RuntimeException(tf);
+ for (Config config : domain.getConfigs().getConfig()) {
+ try {
+ rectifyThreadPools(config);
+ processHttpListeners(config);
+ promoteHttpServiceProperties(config.getHttpService());
+ promoteVirtualServerProperties(config.getHttpService());
+ promoteSystemProperties();
+ } catch (TransactionFailure tf) {
+ Logger.getAnonymousLogger().log(Level.SEVERE, "Failure while upgrading domain.xml. Please redeploy", tf);
+ throw new RuntimeException(tf);
+ }
         }
     }
 
Index: src/main/java/org/glassfish/config/support/SecurityUpgradeService.java
===================================================================
--- src/main/java/org/glassfish/config/support/SecurityUpgradeService.java (revision 40929)
+++ src/main/java/org/glassfish/config/support/SecurityUpgradeService.java (working copy)
@@ -40,6 +40,8 @@
 
 package org.glassfish.config.support;
 
+import com.sun.enterprise.config.serverbeans.Config;
+import com.sun.enterprise.config.serverbeans.Configs;
 import com.sun.enterprise.config.serverbeans.JaccProvider;
 import com.sun.enterprise.config.serverbeans.SecurityService;
 import java.beans.PropertyVetoException;
@@ -70,17 +72,19 @@
 public class SecurityUpgradeService implements ConfigurationUpgrade, PostConstruct {
 
     @Inject
- private Habitat habitat;
+ Configs configs;
+
     public void postConstruct() {
- upgradeJACCProvider();
+ for (Config config : configs.getConfig()) {
+ SecurityService service = config.getSecurityService();
+ if (service != null) {
+ upgradeJACCProvider(service);
+ }
+ }
     }
 
- private void upgradeJACCProvider() {
+ private void upgradeJACCProvider(SecurityService securityService) {
         try {
- final SecurityService securityService = habitat.getComponent(SecurityService.class);
- if (securityService == null) {
- return;
- }
             List<JaccProvider> jaccProviders = securityService.getJaccProvider();
             for (JaccProvider jacc : jaccProviders) {
                 if ("com.sun.enterprise.security.jacc.provider.SimplePolicyConfigurationFactory".equals(jacc.getPolicyConfigurationFactoryProvider())) {