[jbossws-commits] JBossWS SVN: r18246 - in common/trunk/src/main/java/org/jboss/ws/common: management and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Thu Jan 16 09:46:45 EST 2014


Author: asoldano
Date: 2014-01-16 09:46:45 -0500 (Thu, 16 Jan 2014)
New Revision: 18246

Added:
   common/trunk/src/main/java/org/jboss/ws/common/management/CommonConfigStoreImpl.java
Modified:
   common/trunk/src/main/java/org/jboss/ws/common/configuration/ConfigHelper.java
   common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
Log:
[JBWS-3739][JBWS-3708][JBWS-3707][JBWS-3689] svn merge -r 18113:18144 https://svn.jboss.org/repos/jbossws/stack/cxf/branches/JBWS-3739 .


Modified: common/trunk/src/main/java/org/jboss/ws/common/configuration/ConfigHelper.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/configuration/ConfigHelper.java	2014-01-16 14:45:03 UTC (rev 18245)
+++ common/trunk/src/main/java/org/jboss/ws/common/configuration/ConfigHelper.java	2014-01-16 14:46:45 UTC (rev 18246)
@@ -113,11 +113,9 @@
       } else {
          ServerConfig sc = getServerConfig();
          if (sc != null) {
-            for (ClientConfig config : sc.getClientConfigs()) {
-               if (config.getConfigName().equals(configName))
-               {
-                  return config;
-               }
+            ClientConfig cf = sc.getClientConfig(configName);
+            if (cf != null) {
+               return cf;
             }
          }
       }

Modified: common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java	2014-01-16 14:45:03 UTC (rev 18245)
+++ common/trunk/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java	2014-01-16 14:46:45 UTC (rev 18246)
@@ -26,8 +26,6 @@
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.management.MBeanServer;
 
@@ -35,6 +33,7 @@
 import org.jboss.wsf.spi.SPIProvider;
 import org.jboss.wsf.spi.WSFException;
 import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
+import org.jboss.wsf.spi.management.CommonConfigStore;
 import org.jboss.wsf.spi.management.ServerConfig;
 import org.jboss.wsf.spi.management.ServerConfigFactory;
 import org.jboss.wsf.spi.management.StackConfig;
@@ -81,11 +80,10 @@
    
    //The stack config
    protected volatile StackConfig stackConfig;
-   // The default endpoint configs, if any
-   private final List<ClientConfig> clientConfigs = new CopyOnWriteArrayList<ClientConfig>();
-   // The default endpoint configs, if any
-   private final List<EndpointConfig> endpointConfigs = new CopyOnWriteArrayList<EndpointConfig>();
    
+   protected final CommonConfigStore<ClientConfig> clientConfigStore = new CommonConfigStoreImpl<ClientConfig>();
+   protected final CommonConfigStore<EndpointConfig> endpointConfigStore = new CommonConfigStoreImpl<EndpointConfig>();
+   
    // The server integration classloader' ServerConfig instance reference
    private static ServerConfig serverConfig;
    
@@ -269,6 +267,9 @@
          mbeanServer.registerMBean(this, AbstractServerConfigMBean.OBJECT_NAME);
       }
       
+      clientConfigStore.reload();
+      endpointConfigStore.reload();
+      
       //cleanup the server integration classloader' service config reference as
       //a new server config can be created due to a server reload.
       synchronized (AbstractServerConfig.class) //synchronization to ensure visibility
@@ -283,6 +284,9 @@
       if (mbeanServer != null) {
          mbeanServer.unregisterMBean(AbstractServerConfigMBean.OBJECT_NAME);
       }
+      
+      clientConfigStore.unload();
+      endpointConfigStore.unload();
    }
    
    public static ServerConfig getServerIntegrationServerConfig()
@@ -307,27 +311,47 @@
    {
       return stackConfig.getImplementationVersion();
    }
-
-   public void addEndpointConfig(EndpointConfig config)
+   
+   public void registerClientConfig(ClientConfig config)
    {
-      this.endpointConfigs.add(config);
+      clientConfigStore.register(config);
    }
-
-   public void addClientConfig(ClientConfig config)
+   
+   public void unregisterClientConfig(ClientConfig config)
    {
-      this.clientConfigs.add(config);
+      clientConfigStore.unregister(config);
    }
-
-   public List<EndpointConfig> getEndpointConfigs()
+   
+   public void reloadClientConfigs()
    {
-      return this.endpointConfigs;
+      clientConfigStore.reload();
    }
-
-   public List<ClientConfig> getClientConfigs()
+   
+   public ClientConfig getClientConfig(String name)
    {
-      return this.clientConfigs;
+      return clientConfigStore.getConfig(name);
    }
    
+   public void registerEndpointConfig(EndpointConfig config)
+   {
+      endpointConfigStore.register(config);
+   }
+   
+   public void unregisterEndpointConfig(EndpointConfig config)
+   {
+      endpointConfigStore.unregister(config);
+   }
+   
+   public void reloadEndpointConfigs()
+   {
+      endpointConfigStore.reload();
+   }
+   
+   public EndpointConfig getEndpointConfig(String name)
+   {
+      return endpointConfigStore.getConfig(name);
+   }
+   
    public interface UpdateCallbackHandler {
       public void onBeforeUpdate();
    }

Copied: common/trunk/src/main/java/org/jboss/ws/common/management/CommonConfigStoreImpl.java (from rev 18129, common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/management/CommonConfigStoreImpl.java)
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/management/CommonConfigStoreImpl.java	                        (rev 0)
+++ common/trunk/src/main/java/org/jboss/ws/common/management/CommonConfigStoreImpl.java	2014-01-16 14:46:45 UTC (rev 18246)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.common.management;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.wsf.spi.management.CommonConfigStore;
+import org.jboss.wsf.spi.metadata.config.AbstractCommonConfig;
+
+
+/**
+ * A implementation of the CommonConfigStore based on HashMap;
+ * configs are stored using their name as key.
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 04-Dec-2013
+ */
+public class CommonConfigStoreImpl<T extends AbstractCommonConfig> implements CommonConfigStore<T>
+{
+   private final Map<String, T> configs = new HashMap<String, T>(4);
+   private volatile T wrapper;
+   private volatile Map<String, T> loadedConfigs = Collections.emptyMap();
+
+   @Override
+   public synchronized void register(T config)
+   {
+      configs.put(config.getConfigName(), config);
+   }
+
+   @Override
+   public synchronized void unregister(T config)
+   {
+      configs.remove(config.getConfigName());
+   }
+   
+   @SuppressWarnings("unchecked")
+   private T newInstance(T obj, T wrapper) {
+      Class<?> clazz = obj.getClass();
+      try {
+         return (T)clazz.getConstructor(clazz, wrapper.getClass()).newInstance(obj, wrapper);
+      } catch (Exception e) {
+         throw new RuntimeException(e);
+      }
+   }
+
+   @Override
+   public synchronized void reload()
+   {
+      Map<String, T> map = new HashMap<String, T>(configs.size(), 1);
+      if (wrapper != null) {
+         for (Entry<String, T> e : configs.entrySet()) {
+            map.put(e.getKey(), newInstance(e.getValue(), wrapper));
+         }
+      } else {
+         for (Entry<String, T> e : configs.entrySet()) {
+            map.put(e.getKey(), e.getValue());
+         }
+      }
+      this.loadedConfigs = Collections.unmodifiableMap(map);
+   }
+   
+   @Override
+   public synchronized void unload()
+   {
+      this.loadedConfigs = Collections.emptyMap();
+   }
+
+   @Override
+   public synchronized void setWrapperConfig(T config, boolean reload)
+   {
+      this.wrapper = config;
+      if (reload) {
+         reload();
+      }
+   }
+
+   @Override
+   public synchronized T getWrapperConfig()
+   {
+      return this.wrapper;
+   }
+
+   @Override
+   public T getConfig(String name)
+   {
+      return this.loadedConfigs.get(name);
+   }
+
+   @Override
+   public Collection<T> getConfigs()
+   {
+      return this.loadedConfigs.values();
+   }
+   
+}



More information about the jbossws-commits mailing list