Author: asoldano
Date: 2013-12-04 09:52:49 -0500 (Wed, 04 Dec 2013)
New Revision: 18129
Added:
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/management/CommonConfigStoreImpl.java
Modified:
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/configuration/ConfigHelper.java
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
Log:
[JBWS-3708] Adding implementation of CommonConfigStore and updating AbstractServerConfig
to use it
Modified:
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/configuration/ConfigHelper.java
===================================================================
---
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/configuration/ConfigHelper.java 2013-12-04
14:51:38 UTC (rev 18128)
+++
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/configuration/ConfigHelper.java 2013-12-04
14:52:49 UTC (rev 18129)
@@ -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/branches/JBWS-3739/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java
===================================================================
---
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java 2013-12-04
14:51:38 UTC (rev 18128)
+++
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/management/AbstractServerConfig.java 2013-12-04
14:52:49 UTC (rev 18129)
@@ -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;
import javax.management.ObjectName;
@@ -37,6 +35,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;
@@ -89,11 +88,10 @@
//The stack config
protected 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;
@@ -277,6 +275,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
@@ -291,6 +292,9 @@
if (mbeanServer != null) {
mbeanServer.unregisterMBean(AbstractServerConfigMBean.OBJECT_NAME);
}
+
+ clientConfigStore.unload();
+ endpointConfigStore.unload();
}
public static ServerConfig getServerIntegrationServerConfig()
@@ -315,27 +319,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();
}
Added:
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/management/CommonConfigStoreImpl.java
===================================================================
---
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/management/CommonConfigStoreImpl.java
(rev 0)
+++
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/management/CommonConfigStoreImpl.java 2013-12-04
14:52:49 UTC (rev 18129)
@@ -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(a)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();
+ }
+
+}
Property changes on:
common/branches/JBWS-3739/src/main/java/org/jboss/ws/common/management/CommonConfigStoreImpl.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native