[jboss-cvs] JBossAS SVN: r90481 - in branches/dml-log-service-integration: cluster/src/main/org/jboss/ha/framework/server/managed and 13 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jun 19 16:18:45 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-06-19 16:18:44 -0400 (Fri, 19 Jun 2009)
New Revision: 90481
Added:
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ProtocolStackConfigInfo.java
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ProtocolStackUtil.java
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/OpenChannelsMapper.java
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolDataProtocolStackConfigurator.java
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigurationsMapper.java
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ChannelFactoryManagedObjectsTestCase.java
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryOverrideUnitTestCase.java
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/OpenChannelsMapperUnitTestCase.java
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ProtocolStackConfigurationsMapperUnitTestCase.java
Removed:
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/OpenChannelsMapper.java
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolDataProtocolStackConfigurator.java
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigurationsMapper.java
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java
Modified:
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ChannelInfo.java
branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/JChannelFactory.java
branches/dml-log-service-integration/component-matrix/pom.xml
branches/dml-log-service-integration/connector/src/main/org/jboss/resource/deployers/management/AbstractConnectionFactoryICF.java
branches/dml-log-service-integration/connector/src/main/org/jboss/resource/deployers/management/AbstractNonXADataSourceICF.java
branches/dml-log-service-integration/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java
branches/dml-log-service-integration/security/src/main/org/jboss/security/plugins/JaasSecurityDomain.java
branches/dml-log-service-integration/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java
branches/dml-log-service-integration/server/src/main/org/jboss/deployment/dependency/JndiDependencyMetaData.java
branches/dml-log-service-integration/system-jmx/src/main/org/jboss/system/metadata/ServiceAnnotationMetaData.java
branches/dml-log-service-integration/system-jmx/src/main/org/jboss/system/server/jmx/JMXKernel.java
branches/dml-log-service-integration/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryUnitTestCase.java
branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
Merge from trunk: -r90433:90480
Modified: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ChannelInfo.java
===================================================================
--- branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ChannelInfo.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ChannelInfo.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -69,6 +69,11 @@
return id;
}
+ public String getClusterName()
+ {
+ return channel.getClusterName();
+ }
+
public String getStackName()
{
return stackName;
Modified: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/JChannelFactory.java
===================================================================
--- branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/JChannelFactory.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/JChannelFactory.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -23,7 +23,6 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URL;
@@ -31,25 +30,29 @@
import java.rmi.server.UID;
import java.security.AccessController;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import org.jboss.bootstrap.spi.util.ServerConfigUtil;
+import org.jboss.ha.framework.server.managed.OpenChannelsMapper;
+import org.jboss.ha.framework.server.managed.ProtocolStackConfigurationsMapper;
import org.jboss.logging.Logger;
import org.jboss.managed.api.annotation.ManagementComponent;
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperties;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.metatype.api.annotations.MetaMapping;
import org.jboss.system.ServiceMBean;
import org.jboss.util.loading.ContextClassLoaderSwitcher;
import org.jgroups.Channel;
@@ -63,7 +66,6 @@
import org.jgroups.conf.ProtocolData;
import org.jgroups.conf.ProtocolParameter;
import org.jgroups.conf.ProtocolStackConfigurator;
-import org.jgroups.conf.XmlConfigurator;
import org.jgroups.jmx.JmxConfigurator;
import org.jgroups.protocols.TP;
import org.jgroups.stack.IpAddress;
@@ -75,11 +77,7 @@
import org.jgroups.util.ThreadFactory;
import org.jgroups.util.ThreadManager;
import org.jgroups.util.Util;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* Implementation of the JGroups <code>ChannelFactory</code> that supports a
@@ -105,8 +103,9 @@
*
* @version $Revision$
*/
- at ManagementObject(componentType=@ManagementComponent(type="MCBean", subtype="ChannelFactory"),
- name="JChannelFactory", properties=ManagementProperties.CLASS_AND_EXPLICIT,
+ at ManagementObject(name="JChannelFactory",
+ componentType=@ManagementComponent(type="MCBean", subtype="JGroupsChannelFactory"),
+ properties=ManagementProperties.EXPLICIT,
isRuntime=true)
public class JChannelFactory
implements ChannelFactory, JChannelFactoryMBean, MBeanRegistration
@@ -120,6 +119,9 @@
*/
public static final String UNSHARED_TRANSPORT_NAME_BASE = "unnamed_";
+ /** Default value for property {@link #getDomain() domain}. */
+ public static final String DEFAULT_JMX_DOMAIN = "jgroups";
+
private static final int CREATED = ServiceMBean.CREATED;
private static final int STARTING = ServiceMBean.STARTING;
private static final int STARTED = ServiceMBean.STARTED;
@@ -128,11 +130,6 @@
private static final int DESTROYED = ServiceMBean.DESTROYED;
private static final int FAILED = ServiceMBean.FAILED;
- private static final String PROTOCOL_STACKS="protocol_stacks";
- private static final String STACK="stack";
- private static final String NAME="name";
- private static final String CONFIG="config";
-
private InetAddress nodeAddress;
private String nodeName;
private int namingServicePort = -1;
@@ -153,9 +150,15 @@
* configs. This is (re-)populated whenever a setMultiplexerConfig() method
* is called
*/
- private final Map<String,ProtocolStackConfigurator> stacks =
- new ConcurrentHashMap<String, ProtocolStackConfigurator>(16, 0.75f, 2);
+ private final Map<String,ProtocolStackConfigInfo> stacks =
+ new ConcurrentHashMap<String, ProtocolStackConfigInfo>(16, 0.75f, 2);
+ /**
+ * Placeholder for stacks injected via {@link #setProtocolStackConfigurations(Map)}
+ * until createService is called.
+ */
+ private Map<String,ProtocolStackConfigInfo> injectedStacks;
+
/**
* The MBeanServer to expose JMX management data with (no management data
* will be available if null)
@@ -163,7 +166,7 @@
private MBeanServer server = null;
/** To expose the channels and protocols */
- private String domain = "jgroups";
+ private String domain = DEFAULT_JMX_DOMAIN;
private boolean domainSet = false;
/** Whether or not to expose channels via JMX */
@@ -173,151 +176,6 @@
private boolean expose_protocols=true;
/**
- * Parses the contents of <code>input</code> into a map of the
- * protocol stack configurations contained in the XML.
- *
- * @param input stream which must contain XML content in the JGroups
- * <code>stacks.xml</code> format
- *
- * @return a map of the protocol stack configurations contained in the XML
- *
- * @throws IllegalArgumentException if <code>input</code> is <code>null</code>
- * @throws Exception
- */
- public static Map<String, ProtocolStackConfigurator> parse(InputStream input) throws Exception
- {
- if (input == null)
- {
- throw new IllegalArgumentException("null input");
- }
-
- DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
- factory.setValidating(false); //for now
- DocumentBuilder builder=factory.newDocumentBuilder();
- Document document=builder.parse(input);
-
- // The root element of the document should be the "config" element,
- // but the parser(Element) method checks this so a check is not
- // needed here.
- Element configElement = document.getDocumentElement();
- return parse(configElement);
- }
-
- /**
- * Parses the contents of <code>root</code> into a map of the
- * protocol stack configurations contained in the XML.
- *
- * @param root document root node for XML content in the JGroups
- * <code>stacks.xml</code> format
- *
- * @return a map of the protocol stack configurations contained in the XML
- *
- * @throws IllegalArgumentException if <code>input</code> is <code>null</code>
- * @throws Exception
- */
- public static Map<String, ProtocolStackConfigurator> parse(Element root) throws Exception
- {
- if (root == null)
- {
- throw new IllegalArgumentException("null root");
- }
-
- String root_name = root.getNodeName();
- if (!PROTOCOL_STACKS.equals(root_name.trim().toLowerCase()))
- {
- throw new IOException("Invalid XML configuration: configuration does not start with a '" +
- PROTOCOL_STACKS + "' element");
- }
-
- Map<String, ProtocolStackConfigurator> result = new HashMap<String, ProtocolStackConfigurator>();
-
- NodeList tmp_stacks = root.getChildNodes();
- for (int i = 0; i < tmp_stacks.getLength(); i++)
- {
- Node node = tmp_stacks.item(i);
- if (node.getNodeType() != Node.ELEMENT_NODE)
- continue;
-
- Element stack = (Element) node;
- String tmp = stack.getNodeName();
- if (!STACK.equals(tmp.trim().toLowerCase()))
- {
- throw new IOException("Invalid configuration: didn't find a \"" + STACK + "\" element under \""
- + PROTOCOL_STACKS + "\"");
- }
-
- NamedNodeMap attrs = stack.getAttributes();
- Node name = attrs.getNamedItem(NAME);
- // Node descr=attrs.getNamedItem(DESCR);
- String st_name = name.getNodeValue();
- // String stack_descr=descr.getNodeValue();
- // System.out.print("Parsing \"" + st_name + "\" (" + stack_descr + ")");
- NodeList configs = stack.getChildNodes();
- for (int j = 0; j < configs.getLength(); j++)
- {
- Node tmp_config = configs.item(j);
- if (tmp_config.getNodeType() != Node.ELEMENT_NODE)
- continue;
- Element cfg = (Element) tmp_config;
- tmp = cfg.getNodeName();
- if (!CONFIG.equals(tmp))
- {
- throw new IOException("Invalid configuration: didn't find a \"" +
- CONFIG + "\" element under \"" + STACK + "\"");
- }
-
- XmlConfigurator conf = XmlConfigurator.getInstance(cfg);
- // fixes http://jira.jboss.com/jira/browse/JGRP-290
- ConfiguratorFactory.substituteVariables(conf); // replace vars with system props
-
- result.put(st_name, conf);
- }
- }
-
- return result;
- }
-
- public static ProtocolData[] getProtocolData(ProtocolStackConfigurator config)
- {
- ProtocolData[] result = null;
- try
- {
- result = config.getProtocolStack();
- }
- catch (UnsupportedOperationException e)
- {
- String s = config.getProtocolStackString();
- String[] prots = s.split(":");
- result = new ProtocolData[prots.length];
- for (int i = 0; i < prots.length; i++)
- {
- ProtocolParameter[] params = null;
- int paren = prots[i].indexOf('(');
- String name = paren > - 1 ? prots[i].substring(0, paren) : prots[1];
- if (paren > -1 && paren < prots[1].length() - 2)
- {
- String unsplit = prots[i].substring(paren + 1, prots[i].length() -1);
- String[] split = unsplit.split(";");
- params = new ProtocolParameter[split.length];
- for (int j = 0; j < split.length; j++)
- {
- String[] keyVal = split[j].split("=");
- params[j] = new ProtocolParameter(keyVal[0], keyVal[1]);
- }
- }
- else
- {
- params = new ProtocolParameter[0];
- }
-
- result[i] = new ProtocolData(name, null, name, params);
- }
- }
-
- return result == null ? new ProtocolData[0] : result;
- }
-
- /**
* Creates a new JChannelFactory.
*/
@SuppressWarnings("unchecked")
@@ -367,7 +225,7 @@
try
{
- registerChannel(channel, null, null, getProtocolData(config));
+ registerChannel(channel, null, null, ProtocolStackUtil.getProtocolData(config));
}
catch (ChannelException ce)
{
@@ -577,18 +435,19 @@
* @return the domain. Will not return <code>null</code> after {@link #create()}
* has been invoked.
*/
+ @ManagementProperty(use={ViewUse.CONFIGURATION}, description="The domain portion of the JMX ObjectName to use when registering channels and protocols")
public String getDomain()
{
return domain == null ? "jgroups" : domain;
}
- @ManagementProperty(use={ViewUse.CONFIGURATION}, description="The domain portion of the JMX ObjectName to use when registering channels and protocols")
public void setDomain(String domain)
{
this.domain = domain;
this.domainSet = true;
}
+ @ManagementProperty(use={ViewUse.CONFIGURATION}, description="Whether to expose channels we create via JMX")
public boolean isExposeChannels()
{
return expose_channels;
@@ -599,6 +458,7 @@
this.expose_channels=expose_channels;
}
+ @ManagementProperty(use={ViewUse.CONFIGURATION}, description="Whether to expose protocols via JMX as well if we expose channels")
public boolean isExposeProtocols()
{
return expose_protocols;
@@ -832,9 +692,9 @@
*/
public void setMultiplexerConfig(Element properties, boolean replace) throws Exception
{
- Map<String, ProtocolStackConfigurator> map = parse(properties);
+ Map<String, ProtocolStackConfigInfo> map = ProtocolStackUtil.parse(properties);
- for (Map.Entry<String, ProtocolStackConfigurator> entry : map.entrySet())
+ for (Map.Entry<String, ProtocolStackConfigInfo> entry : map.entrySet())
{
addConfig(entry.getKey(), entry.getValue(), replace);
}
@@ -914,6 +774,42 @@
addConfigs(input, url.toString(), replace);
}
+
+ // -------------------------------------------------------- Management View
+
+ /**
+ * Gets information on channels created by this factory that are currently
+ * open.
+ */
+ @ManagementProperty(use={ViewUse.STATISTIC},
+ description="Information on channels created by this factory that are currently open",
+ readOnly=true)
+ @MetaMapping(value=OpenChannelsMapper.class)
+ public Set<ChannelInfo> getOpenChannels()
+ {
+ return new HashSet<ChannelInfo>(registeredChannels.values());
+ }
+
+ @ManagementProperty(use={ViewUse.CONFIGURATION, ViewUse.RUNTIME},
+ description="Protocol stack configurations available for use")
+ @MetaMapping(value=ProtocolStackConfigurationsMapper.class)
+ public Map<String, ProtocolStackConfigInfo> getProtocolStackConfigurations()
+ {
+ return Collections.unmodifiableMap(stacks);
+ }
+
+ public void setProtocolStackConfigurations(Map<String, ProtocolStackConfigInfo> configs)
+ {
+ this.injectedStacks = configs;
+
+ if (state == STARTED)
+ {
+ // We're already running so this must be a ManagedComponent update
+ // so apply immediately
+ processInjectedStacks();
+ }
+ }
+
// --------------------------------------------------- JChannelFactoryMBean
/**
@@ -945,10 +841,10 @@
*/
public String getConfig(String stack_name) throws Exception
{
- ProtocolStackConfigurator cfg = stacks.get(stack_name);
+ ProtocolStackConfigInfo cfg = stacks.get(stack_name);
if (cfg == null)
throw new Exception("stack \"" + stack_name + "\" not found in " + stacks.keySet());
- return cfg.getProtocolStackString();
+ return cfg.getConfigurator().getProtocolStackString();
}
/**
@@ -957,9 +853,9 @@
public String getMultiplexerConfig()
{
StringBuilder sb = new StringBuilder();
- for (Map.Entry<String, ProtocolStackConfigurator> entry : stacks.entrySet())
+ for (Map.Entry<String, ProtocolStackConfigInfo> entry : stacks.entrySet())
{
- sb.append(entry.getKey()).append(": ").append(entry.getValue().getProtocolStackString()).append("\n");
+ sb.append(entry.getKey()).append(": ").append(entry.getValue().getConfigurator().getProtocolStackString()).append("\n");
}
return sb.toString();
}
@@ -976,6 +872,10 @@
/**
* {@inheritDoc}
+ * <p>
+ * This method largely directly concerns itself with the {@link #getStateString() state}
+ * field, delegating the real work to {@link #createService()}.
+ * </p>
*/
public void create() throws Exception
{
@@ -1005,6 +905,10 @@
/**
* {@inheritDoc}
+ * <p>
+ * This method largely directly concerns itself with the {@link #getStateString() state}
+ * field, delegating the real work to {@link #startService()}.
+ * </p>
*/
public void start() throws Exception
{
@@ -1041,6 +945,10 @@
/**
* {@inheritDoc}
+ * <p>
+ * This method largely directly concerns itself with the {@link #getStateString() state}
+ * field, delegating the real work to {@link #stopService()}.
+ * </p>
*/
public void stop()
{
@@ -1070,6 +978,10 @@
/**
* {@inheritDoc}
+ * <p>
+ * This method largely directly concerns itself with the {@link #getStateString() state}
+ * field, delegating the real work to {@link #destroyService()}.
+ * </p>
*/
public void destroy()
{
@@ -1160,21 +1072,36 @@
if(domain == null)
{
- domain="jgroups";
+ domain= DEFAULT_JMX_DOMAIN;
}
}
}
+ /**
+ * The actual startup work.
+ *
+ * @throws Exception
+ */
protected void startService() throws Exception
{
- // no-op
+ // If the ProfileService injected stacks, process them now
+ processInjectedStacks();
}
+ /**
+ * The actual service stop work. This base implementation does nothing.
+ *
+ * @throws Exception
+ */
protected void stopService() throws Exception
{
// no-op
}
+ /**
+ * The actual service destruction work.
+ *
+ */
protected void destroyService()
{
for (Channel ch : registeredChannels.keySet())
@@ -1199,10 +1126,10 @@
throw new FileNotFoundException(source);
}
- Map<String, ProtocolStackConfigurator> map = null;
+ Map<String, ProtocolStackConfigInfo> map = null;
try
{
- map = parse(input);
+ map = ProtocolStackUtil.parse(input);
}
catch(Exception ex)
{
@@ -1213,13 +1140,13 @@
Util.close(input);
}
- for (Map.Entry<String, ProtocolStackConfigurator> entry : map.entrySet())
+ for (Map.Entry<String, ProtocolStackConfigInfo> entry : map.entrySet())
{
addConfig(entry.getKey(), entry.getValue(), replace);
}
}
- private boolean addConfig(String st_name, ProtocolStackConfigurator val, boolean replace)
+ private boolean addConfig(String st_name, ProtocolStackConfigInfo val, boolean replace)
{
boolean added = replace;
if (replace)
@@ -1245,10 +1172,19 @@
}
return added;
}
+
+ private synchronized void processInjectedStacks()
+ {
+ if (injectedStacks != null)
+ {
+ clearConfigurations();
+ stacks.putAll(injectedStacks);
+ injectedStacks = null;
+ }
+ }
/**
- * Creates a channel from one of the known stack configurations
- * FIXME Comment this
+ * Creates a channel from one of the known stack configurations.
*
* @param stack_name the name of the stack config
* @param id optional id for the channel
@@ -1257,8 +1193,9 @@
*
* @return the channel
*
- * @throws IllegalStateException if stack_name is unknown or forceSingletonStack
- * is true but a singleton_name couldn't be configured
+ * @throws IllegalArgumentException if stack_name is unknown
+ * @throws IllegalStateException if forceSingletonStack is <code>true</code>
+ * but a singleton_name couldn't be configured
*
* @throws Exception
*/
@@ -1266,14 +1203,14 @@
{
checkStarted();
- ProtocolStackConfigurator config = stacks.get(stack_name);
+ ProtocolStackConfigInfo config = stacks.get(stack_name);
if (config == null)
- throw new IllegalStateException("Unknown stack_name " + stack_name);
+ throw new IllegalArgumentException("Unknown stack_name " + stack_name);
- JChannel channel = initializeChannel(config, stack_name, forceSingletonStack);
+ JChannel channel = initializeChannel(config.getConfigurator(), stack_name, forceSingletonStack);
- registerChannel(channel, id, stack_name, getProtocolData(config));
+ registerChannel(channel, id, stack_name, ProtocolStackUtil.getProtocolData(config.getConfigurator()));
return channel;
}
@@ -1328,6 +1265,14 @@
return channel;
}
+ /**
+ * Gets the current runtime lifecycle state (e.g. CREATED, STARTED).
+ */
+ private String getStateString()
+ {
+ return ServiceMBean.states[state];
+ }
+
private void setChannelUniqueId(Channel channel)
{
IpAddress address = (IpAddress) channel.getLocalAddress();
@@ -1360,11 +1305,6 @@
"additional data -- setting nodeName to " + nodeName);
}
}
-
- private String getStateString()
- {
- return ServiceMBean.states[state];
- }
private String generateUniqueNodeName ()
{
@@ -1416,7 +1356,7 @@
private Map<String, String> getTransportProperties(ProtocolStackConfigurator config)
{
Map<String, String> tpProps = null;
- ProtocolData[] protocols= getProtocolData(config);
+ ProtocolData[] protocols= ProtocolStackUtil.getProtocolData(config);
ProtocolData transport=protocols[0];
@SuppressWarnings("unchecked")
Map<String,ProtocolParameter> tmp=transport.getParameters();
Copied: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ProtocolStackConfigInfo.java (from rev 90480, trunk/cluster/src/main/org/jboss/ha/framework/server/ProtocolStackConfigInfo.java)
===================================================================
--- branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ProtocolStackConfigInfo.java (rev 0)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ProtocolStackConfigInfo.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ha.framework.server;
+
+import org.jgroups.conf.ProtocolData;
+import org.jgroups.conf.ProtocolStackConfigurator;
+
+/**
+ *
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: $
+ */
+public class ProtocolStackConfigInfo
+{
+ private final String name;
+ private final String description;
+ private final ProtocolStackConfigurator configurator;
+
+ public ProtocolStackConfigInfo(String name, String description, ProtocolStackConfigurator configurator)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("null name");
+ }
+ if (configurator == null)
+ {
+ throw new IllegalArgumentException("null configurator");
+ }
+ this.name = name;
+ this.description = description;
+ this.configurator = configurator;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ ProtocolStackConfigurator getConfigurator()
+ {
+ return configurator;
+ }
+
+ public ProtocolData[] getConfiguration()
+ {
+ return ProtocolStackUtil.getProtocolData(configurator);
+ }
+}
Copied: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ProtocolStackUtil.java (from rev 90480, trunk/cluster/src/main/org/jboss/ha/framework/server/ProtocolStackUtil.java)
===================================================================
--- branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ProtocolStackUtil.java (rev 0)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/ProtocolStackUtil.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -0,0 +1,217 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ha.framework.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.logging.Logger;
+import org.jgroups.conf.ConfiguratorFactory;
+import org.jgroups.conf.ProtocolData;
+import org.jgroups.conf.ProtocolParameter;
+import org.jgroups.conf.ProtocolStackConfigurator;
+import org.jgroups.conf.XmlConfigurator;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Utilities related to JGroups protocol stack manipulation.
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: $
+ */
+public final class ProtocolStackUtil
+{
+ private static final Logger log = Logger.getLogger(ProtocolStackUtil.class);
+
+ private static final String PROTOCOL_STACKS="protocol_stacks";
+ private static final String STACK="stack";
+ private static final String NAME="name";
+ private static final String DESCR="description";
+ private static final String CONFIG="config";
+
+ /**
+ * Parses the contents of <code>input</code> into a map of the
+ * protocol stack configurations contained in the XML.
+ *
+ * @param input stream which must contain XML content in the JGroups
+ * <code>stacks.xml</code> format
+ *
+ * @return a map of the protocol stack configurations contained in the XML
+ *
+ * @throws IllegalArgumentException if <code>input</code> is <code>null</code>
+ * @throws Exception
+ */
+ public static Map<String, ProtocolStackConfigInfo> parse(InputStream input) throws Exception
+ {
+ if (input == null)
+ {
+ throw new IllegalArgumentException("null input");
+ }
+
+ DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
+ factory.setValidating(false); //for now
+ DocumentBuilder builder=factory.newDocumentBuilder();
+ Document document=builder.parse(input);
+
+ // The root element of the document should be the "config" element,
+ // but the parser(Element) method checks this so a check is not
+ // needed here.
+ Element configElement = document.getDocumentElement();
+ return parse(configElement);
+ }
+
+ /**
+ * Parses the contents of <code>root</code> into a map of the
+ * protocol stack configurations contained in the XML.
+ *
+ * @param root document root node for XML content in the JGroups
+ * <code>stacks.xml</code> format
+ *
+ * @return a map of the protocol stack configurations contained in the XML
+ *
+ * @throws IllegalArgumentException if <code>input</code> is <code>null</code>
+ * @throws Exception
+ */
+ public static Map<String, ProtocolStackConfigInfo> parse(Element root) throws Exception
+ {
+ if (root == null)
+ {
+ throw new IllegalArgumentException("null root");
+ }
+
+ String root_name = root.getNodeName();
+ if (!PROTOCOL_STACKS.equals(root_name.trim().toLowerCase()))
+ {
+ throw new IOException("Invalid XML configuration: configuration does not start with a '" +
+ PROTOCOL_STACKS + "' element");
+ }
+
+ Map<String, ProtocolStackConfigInfo> result = new HashMap<String, ProtocolStackConfigInfo>();
+
+ NodeList tmp_stacks = root.getChildNodes();
+ for (int i = 0; i < tmp_stacks.getLength(); i++)
+ {
+ Node node = tmp_stacks.item(i);
+ if (node.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+
+ Element stack = (Element) node;
+ String tmp = stack.getNodeName();
+ if (!STACK.equals(tmp.trim().toLowerCase()))
+ {
+ throw new IOException("Invalid configuration: didn't find a \"" + STACK + "\" element under \""
+ + PROTOCOL_STACKS + "\"");
+ }
+
+ NamedNodeMap attrs = stack.getAttributes();
+ Node name = attrs.getNamedItem(NAME);
+ String st_name = name.getNodeValue();
+ Node descr=attrs.getNamedItem(DESCR);
+ String stack_descr=descr.getNodeValue();
+ if (log.isTraceEnabled())
+ {
+ log.trace("Parsing \"" + st_name + "\" (" + stack_descr + ")");
+ }
+ NodeList configs = stack.getChildNodes();
+ for (int j = 0; j < configs.getLength(); j++)
+ {
+ Node tmp_config = configs.item(j);
+ if (tmp_config.getNodeType() != Node.ELEMENT_NODE)
+ continue;
+ Element cfg = (Element) tmp_config;
+ tmp = cfg.getNodeName();
+ if (!CONFIG.equals(tmp))
+ {
+ throw new IOException("Invalid configuration: didn't find a \"" +
+ CONFIG + "\" element under \"" + STACK + "\"");
+ }
+
+ XmlConfigurator conf = XmlConfigurator.getInstance(cfg);
+ // fixes http://jira.jboss.com/jira/browse/JGRP-290
+ ConfiguratorFactory.substituteVariables(conf); // replace vars with system props
+
+ result.put(st_name, new ProtocolStackConfigInfo(st_name, stack_descr, conf));
+ }
+ }
+
+ return result;
+ }
+
+ public static ProtocolData[] getProtocolData(ProtocolStackConfigurator config)
+ {
+ ProtocolData[] result = null;
+ try
+ {
+ result = config.getProtocolStack();
+ }
+ catch (UnsupportedOperationException e)
+ {
+ String s = config.getProtocolStackString();
+ String[] prots = s.split(":");
+ result = new ProtocolData[prots.length];
+ for (int i = 0; i < prots.length; i++)
+ {
+ ProtocolParameter[] params = null;
+ int paren = prots[i].indexOf('(');
+ String name = paren > - 1 ? prots[i].substring(0, paren) : prots[1];
+ if (paren > -1 && paren < prots[1].length() - 2)
+ {
+ String unsplit = prots[i].substring(paren + 1, prots[i].length() -1);
+ String[] split = unsplit.split(";");
+ params = new ProtocolParameter[split.length];
+ for (int j = 0; j < split.length; j++)
+ {
+ String[] keyVal = split[j].split("=");
+ params[j] = new ProtocolParameter(keyVal[0], keyVal[1]);
+ }
+ }
+ else
+ {
+ params = new ProtocolParameter[0];
+ }
+
+ result[i] = new ProtocolData(name, null, name, params);
+ }
+ }
+
+ return result == null ? new ProtocolData[0] : result;
+ }
+
+ /**
+ * Prevent instantiation.
+ */
+ private ProtocolStackUtil()
+ {
+ }
+
+}
Copied: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed (from rev 90480, trunk/cluster/src/main/org/jboss/ha/framework/server/managed)
Deleted: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/OpenChannelsMapper.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/managed/OpenChannelsMapper.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/OpenChannelsMapper.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -1,239 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.ha.framework.server.managed;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-
-import javax.management.ObjectName;
-
-import org.jboss.ha.framework.server.ChannelInfo;
-import org.jboss.ha.framework.server.JChannelFactory;
-import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.MetaTypeFactory;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.CollectionValueSupport;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.metatype.spi.values.MetaMapper;
-import org.jgroups.Address;
-import org.jgroups.View;
-
-/**
- * MetaMapper for the {@link JChannelFactory#getOpenChannels()} property.
- *
- * @author Brian Stansberry
- *
- * @version $Revision: $
- */
-public class OpenChannelsMapper extends MetaMapper<Set<ChannelInfo>>
-{
- public static final MetaType OBJECT_NAME_TYPE;
- public static final CollectionMetaType PROTOCOL_OBJECT_NAMES_TYPE;
- public static final CollectionMetaType MEMBERS_TYPE;
- public static final CompositeMetaType VIEW_TYPE;
- public static final CompositeMetaType CHANNEL_TYPE;
- public static final CollectionMetaType TYPE;
-
- private static final ProtocolStackConfigMapper CONFIG_MAPPER = new ProtocolStackConfigMapper();
-
- static
- {
- OBJECT_NAME_TYPE = MetaTypeFactory.getInstance().resolve(ObjectName.class);
-
- PROTOCOL_OBJECT_NAMES_TYPE =
- new CollectionMetaType(List.class.getName(), OBJECT_NAME_TYPE);
-
- MEMBERS_TYPE =
- new CollectionMetaType(List.class.getName(), SimpleMetaType.STRING);
-
- String[] viewItemNames = {
- "id",
- "creator",
- "members",
- "coordinator",
- "payload"
- };
-
- String[] viewDescriptions = {
- "sequence number of the view",
- "Address of the node that issued the view",
- "Addresses of the group members",
- "Address of the node acting as group coordinator",
- "arbitrary information added by the application to the view"
- };
- MetaType[] viewItemTypes = {
- SimpleMetaType.LONG_PRIMITIVE,
- SimpleMetaType.STRING,
- MEMBERS_TYPE,
- SimpleMetaType.STRING,
- SimpleMetaType.STRING
- };
-
- VIEW_TYPE = new ImmutableCompositeMetaType(View.class.getName(), "JGroups View",
- viewItemNames, viewDescriptions, viewItemTypes);
-
- String[] itemNames = {
- "id",
- "clusterName",
- "stackName",
- "protocolStackConfiguration",
- "channelObjectName",
- "protocolObjectNames",
- "localAddress",
- "currentView"
- };
- String[] itemDescriptions = {
- "id, if any, passed by the client when it requested the channel",
- "name of the cluster group, shared by all channels that form a group",
- "name, if any, of the protocol stack configuration that was used to create the channel",
- "the channel's protocol stack configuration",
- "ObjectName of the mbean that represents the channel, if the factory registered one",
- "ObjectNames of the mbeans that represent the channel's protocol, if the factory registered them",
- "Address of this node in the group",
- "the channel's current group membership view"
- };
- MetaType[] itemTypes = {
- SimpleMetaType.STRING,
- SimpleMetaType.STRING,
- SimpleMetaType.STRING,
- CONFIG_MAPPER.getMetaType(),
- OBJECT_NAME_TYPE,
- PROTOCOL_OBJECT_NAMES_TYPE,
- SimpleMetaType.STRING,
- VIEW_TYPE
- };
-
- CHANNEL_TYPE = new ImmutableCompositeMetaType(ChannelInfo.class.getName(),
- "Channel",
- itemNames, itemDescriptions, itemTypes);
- TYPE = new CollectionMetaType(Set.class.getName(), CHANNEL_TYPE);
- }
-
- @Override
- public MetaType getMetaType()
- {
- return TYPE;
- }
-
- @Override
- public Type mapToType()
- {
- return Set.class;
- }
-
- @Override
- public MetaValue createMetaValue(MetaType metaType, Set<ChannelInfo> object)
- {
- MetaValueFactory valueFactory = MetaValueFactory.getInstance();
-
- List<MetaValue> elements = new ArrayList<MetaValue>();
- for (ChannelInfo chInfo : object)
- {
- Map<String, MetaValue> data = new HashMap<String, MetaValue>();
-
- String id = chInfo.getId();
- if (id != null)
- {
- data.put("id", SimpleValueSupport.wrap(id));
- }
-
- data.put("clusterName", SimpleValueSupport.wrap(chInfo.getClusterName()));
-
- String stackName = chInfo.getStackName();
- if (stackName != null)
- {
- data.put("stackName", SimpleValueSupport.wrap(stackName));
- }
-
- ObjectName on = chInfo.getChannelObjectName();
- if (on != null)
- {
- data.put("channelObjectName", valueFactory.create(on));
- }
-
- data.put("protocolStackConfiguration", CONFIG_MAPPER.createMetaValue(getMetaType(), chInfo.getProtocolStackConfiguration()));
-
- List<ObjectName> protNames = chInfo.getProtocolObjectNames();
- if (protNames != null)
- {
- List<MetaValue> onValues = new ArrayList<MetaValue>();
- for (ObjectName protON : protNames)
- {
- onValues.add(valueFactory.create(protON));
- }
- data.put("protocolObjectNames",
- new CollectionValueSupport(PROTOCOL_OBJECT_NAMES_TYPE,
- onValues.toArray(new MetaValue[onValues.size()])));
- }
-
- data.put("localAddress", SimpleValueSupport.wrap(chInfo.getLocalAddress().toString()));
-
- MetaValue viewValue = createViewMetaValue(chInfo.getCurrentView());
- data.put("currentView", viewValue);
-
- elements.add(new MapCompositeValueSupport(data, CHANNEL_TYPE));
- }
- return new CollectionValueSupport(TYPE, elements.toArray(new MetaValue[elements.size()]));
- }
-
- private MetaValue createViewMetaValue(View view)
- {
- Map<String, MetaValue> viewMap = new HashMap<String, MetaValue>();
- viewMap.put("id", SimpleValueSupport.wrap(view.getVid().getId()));
- viewMap.put("creator", SimpleValueSupport.wrap(view.getCreator().toString()));
- Vector<Address> members = view.getMembers();
- MetaValue[] memberValues = new MetaValue[members.size()];
- for (int i = 0; i < memberValues.length; i++)
- {
- memberValues[i] = SimpleValueSupport.wrap(members.get(i).toString());
- }
- viewMap.put("members", new CollectionValueSupport(MEMBERS_TYPE, memberValues));
- if (memberValues.length > 0)
- {
- viewMap.put("coordinator", memberValues[0]);
- }
-
- MetaValue viewValue = new MapCompositeValueSupport(viewMap, VIEW_TYPE);
- return viewValue;
- }
-
- @Override
- public Set<ChannelInfo> unwrapMetaValue(MetaValue metaValue)
- {
- // We cannot create a ChannelInfo from a metaValue, and it is a
- // read-only property
- return null;
- }
-
-}
Copied: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/OpenChannelsMapper.java (from rev 90480, trunk/cluster/src/main/org/jboss/ha/framework/server/managed/OpenChannelsMapper.java)
===================================================================
--- branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/OpenChannelsMapper.java (rev 0)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/OpenChannelsMapper.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -0,0 +1,239 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ha.framework.server.managed;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.management.ObjectName;
+
+import org.jboss.ha.framework.server.ChannelInfo;
+import org.jboss.ha.framework.server.JChannelFactory;
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
+import org.jgroups.Address;
+import org.jgroups.View;
+
+/**
+ * MetaMapper for the {@link JChannelFactory#getOpenChannels()} property.
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: $
+ */
+public class OpenChannelsMapper extends MetaMapper<Set<ChannelInfo>>
+{
+ public static final MetaType OBJECT_NAME_TYPE;
+ public static final CollectionMetaType PROTOCOL_OBJECT_NAMES_TYPE;
+ public static final CollectionMetaType MEMBERS_TYPE;
+ public static final CompositeMetaType VIEW_TYPE;
+ public static final CompositeMetaType CHANNEL_TYPE;
+ public static final CollectionMetaType TYPE;
+
+ private static final ProtocolStackConfigMapper CONFIG_MAPPER = new ProtocolStackConfigMapper();
+
+ static
+ {
+ OBJECT_NAME_TYPE = MetaTypeFactory.getInstance().resolve(ObjectName.class);
+
+ PROTOCOL_OBJECT_NAMES_TYPE =
+ new CollectionMetaType(List.class.getName(), OBJECT_NAME_TYPE);
+
+ MEMBERS_TYPE =
+ new CollectionMetaType(List.class.getName(), SimpleMetaType.STRING);
+
+ String[] viewItemNames = {
+ "id",
+ "creator",
+ "members",
+ "coordinator",
+ "payload"
+ };
+
+ String[] viewDescriptions = {
+ "sequence number of the view",
+ "Address of the node that issued the view",
+ "Addresses of the group members",
+ "Address of the node acting as group coordinator",
+ "arbitrary information added by the application to the view"
+ };
+ MetaType[] viewItemTypes = {
+ SimpleMetaType.LONG_PRIMITIVE,
+ SimpleMetaType.STRING,
+ MEMBERS_TYPE,
+ SimpleMetaType.STRING,
+ SimpleMetaType.STRING
+ };
+
+ VIEW_TYPE = new ImmutableCompositeMetaType(View.class.getName(), "JGroups View",
+ viewItemNames, viewDescriptions, viewItemTypes);
+
+ String[] itemNames = {
+ "id",
+ "clusterName",
+ "stackName",
+ "protocolStackConfiguration",
+ "channelObjectName",
+ "protocolObjectNames",
+ "localAddress",
+ "currentView"
+ };
+ String[] itemDescriptions = {
+ "id, if any, passed by the client when it requested the channel",
+ "name of the cluster group, shared by all channels that form a group",
+ "name, if any, of the protocol stack configuration that was used to create the channel",
+ "the channel's protocol stack configuration",
+ "ObjectName of the mbean that represents the channel, if the factory registered one",
+ "ObjectNames of the mbeans that represent the channel's protocol, if the factory registered them",
+ "Address of this node in the group",
+ "the channel's current group membership view"
+ };
+ MetaType[] itemTypes = {
+ SimpleMetaType.STRING,
+ SimpleMetaType.STRING,
+ SimpleMetaType.STRING,
+ CONFIG_MAPPER.getMetaType(),
+ OBJECT_NAME_TYPE,
+ PROTOCOL_OBJECT_NAMES_TYPE,
+ SimpleMetaType.STRING,
+ VIEW_TYPE
+ };
+
+ CHANNEL_TYPE = new ImmutableCompositeMetaType(ChannelInfo.class.getName(),
+ "Channel",
+ itemNames, itemDescriptions, itemTypes);
+ TYPE = new CollectionMetaType(Set.class.getName(), CHANNEL_TYPE);
+ }
+
+ @Override
+ public MetaType getMetaType()
+ {
+ return TYPE;
+ }
+
+ @Override
+ public Type mapToType()
+ {
+ return Set.class;
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, Set<ChannelInfo> object)
+ {
+ MetaValueFactory valueFactory = MetaValueFactory.getInstance();
+
+ List<MetaValue> elements = new ArrayList<MetaValue>();
+ for (ChannelInfo chInfo : object)
+ {
+ Map<String, MetaValue> data = new HashMap<String, MetaValue>();
+
+ String id = chInfo.getId();
+ if (id != null)
+ {
+ data.put("id", SimpleValueSupport.wrap(id));
+ }
+
+ data.put("clusterName", SimpleValueSupport.wrap(chInfo.getClusterName()));
+
+ String stackName = chInfo.getStackName();
+ if (stackName != null)
+ {
+ data.put("stackName", SimpleValueSupport.wrap(stackName));
+ }
+
+ ObjectName on = chInfo.getChannelObjectName();
+ if (on != null)
+ {
+ data.put("channelObjectName", valueFactory.create(on));
+ }
+
+ data.put("protocolStackConfiguration", CONFIG_MAPPER.createMetaValue(getMetaType(), chInfo.getProtocolStackConfiguration()));
+
+ List<ObjectName> protNames = chInfo.getProtocolObjectNames();
+ if (protNames != null)
+ {
+ List<MetaValue> onValues = new ArrayList<MetaValue>();
+ for (ObjectName protON : protNames)
+ {
+ onValues.add(valueFactory.create(protON));
+ }
+ data.put("protocolObjectNames",
+ new CollectionValueSupport(PROTOCOL_OBJECT_NAMES_TYPE,
+ onValues.toArray(new MetaValue[onValues.size()])));
+ }
+
+ data.put("localAddress", SimpleValueSupport.wrap(chInfo.getLocalAddress().toString()));
+
+ MetaValue viewValue = createViewMetaValue(chInfo.getCurrentView());
+ data.put("currentView", viewValue);
+
+ elements.add(new MapCompositeValueSupport(data, CHANNEL_TYPE));
+ }
+ return new CollectionValueSupport(TYPE, elements.toArray(new MetaValue[elements.size()]));
+ }
+
+ private MetaValue createViewMetaValue(View view)
+ {
+ Map<String, MetaValue> viewMap = new HashMap<String, MetaValue>();
+ viewMap.put("id", SimpleValueSupport.wrap(view.getVid().getId()));
+ viewMap.put("creator", SimpleValueSupport.wrap(view.getCreator().toString()));
+ Vector<Address> members = view.getMembers();
+ MetaValue[] memberValues = new MetaValue[members.size()];
+ for (int i = 0; i < memberValues.length; i++)
+ {
+ memberValues[i] = SimpleValueSupport.wrap(members.get(i).toString());
+ }
+ viewMap.put("members", new CollectionValueSupport(MEMBERS_TYPE, memberValues));
+ if (memberValues.length > 0)
+ {
+ viewMap.put("coordinator", memberValues[0]);
+ }
+
+ MetaValue viewValue = new MapCompositeValueSupport(viewMap, VIEW_TYPE);
+ return viewValue;
+ }
+
+ @Override
+ public Set<ChannelInfo> unwrapMetaValue(MetaValue metaValue)
+ {
+ // We cannot create a ChannelInfo from a metaValue, and it is a
+ // read-only property
+ return null;
+ }
+
+}
Deleted: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolDataProtocolStackConfigurator.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolDataProtocolStackConfigurator.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolDataProtocolStackConfigurator.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.ha.framework.server.managed;
-
-import org.jgroups.conf.ProtocolData;
-import org.jgroups.conf.ProtocolStackConfigurator;
-
-/**
- *
- *
- * @author Brian Stansberry
- *
- * @version $Revision: $
- */
-public class ProtocolDataProtocolStackConfigurator implements ProtocolStackConfigurator
-{
- private final ProtocolData[] protocolData;
-
- /**
- * Create a new ProtocolDataProtocolStackConfigurator.
- *
- */
- public ProtocolDataProtocolStackConfigurator(ProtocolData[] protocolData)
- {
- if (protocolData == null)
- {
- throw new IllegalArgumentException("null protocolData");
- }
- this.protocolData = protocolData;
- }
-
- public ProtocolData[] getProtocolStack()
- {
- return this.protocolData;
- }
-
- public String getProtocolStackString()
- {
- StringBuilder buf=new StringBuilder();
- for (int i = 0; i < protocolData.length; i++)
- {
- buf.append(protocolData[i].getProtocolString(false));
- if(i < protocolData.length - 1)
- {
- buf.append(':');
- }
- }
- return buf.toString();
- }
-
-}
Copied: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolDataProtocolStackConfigurator.java (from rev 90480, trunk/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolDataProtocolStackConfigurator.java)
===================================================================
--- branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolDataProtocolStackConfigurator.java (rev 0)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolDataProtocolStackConfigurator.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ha.framework.server.managed;
+
+import org.jgroups.conf.ProtocolData;
+import org.jgroups.conf.ProtocolStackConfigurator;
+
+/**
+ *
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: $
+ */
+public class ProtocolDataProtocolStackConfigurator implements ProtocolStackConfigurator
+{
+ private final ProtocolData[] protocolData;
+
+ /**
+ * Create a new ProtocolDataProtocolStackConfigurator.
+ *
+ */
+ public ProtocolDataProtocolStackConfigurator(ProtocolData[] protocolData)
+ {
+ if (protocolData == null)
+ {
+ throw new IllegalArgumentException("null protocolData");
+ }
+ this.protocolData = protocolData;
+ }
+
+ public ProtocolData[] getProtocolStack()
+ {
+ return this.protocolData;
+ }
+
+ public String getProtocolStackString()
+ {
+ StringBuilder buf=new StringBuilder();
+ for (int i = 0; i < protocolData.length; i++)
+ {
+ buf.append(protocolData[i].getProtocolString(false));
+ if(i < protocolData.length - 1)
+ {
+ buf.append(':');
+ }
+ }
+ return buf.toString();
+ }
+
+}
Deleted: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -1,193 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.ha.framework.server.managed;
-
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.metatype.api.types.CollectionMetaType;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.CollectionValue;
-import org.jboss.metatype.api.values.CollectionValueSupport;
-import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.metatype.api.values.CompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.metatype.spi.values.MetaMapper;
-import org.jgroups.conf.ProtocolData;
-import org.jgroups.conf.ProtocolParameter;
-
-/**
- * MetaMapper for the ProtocolData[] description of a JGroups protocol stack
- * configuration.
- *
- * @author Brian Stansberry
- *
- * @version $Revision: $
- */
-public class ProtocolStackConfigMapper extends MetaMapper<ProtocolData[]>
-{
- public static final CompositeMetaType PROTOCOL_PARAMETER_TYPE;
- public static final CollectionMetaType PROTOCOL_PARAMETER_SET_TYPE;
- public static final CompositeMetaType PROTOCOL_STACK_CONFIG_TYPE;
- public static final CollectionMetaType TYPE;
-
- static
- {
- String[] paramItemNames = {
- "name",
- "description",
- "value"
- };
- String[] paramItemDescs = {
- "the name of the configuration parameter",
- "description of the meaning of the attribute",
- "the value of the configuration parameter"
- };
- MetaType[] paramItemTypes = {
- SimpleMetaType.STRING,
- SimpleMetaType.STRING,
- SimpleMetaType.STRING
- };
-
- PROTOCOL_PARAMETER_TYPE = new ImmutableCompositeMetaType(ProtocolParameter.class.getName(),
- "Protocol Parameters",
- paramItemNames, paramItemDescs, paramItemTypes);
-
- PROTOCOL_PARAMETER_SET_TYPE = new CollectionMetaType(Set.class.getName(), PROTOCOL_PARAMETER_TYPE);
-
- String[] configItemNames = {
- "name",
- "description",
- "className",
- "protocolParameters"
- };
- String[] configItemDescs = {
- "the name of the protocol",
- "description of the protocol",
- "fully-qualified name of the protocol implementation class",
- "set of configuration parameters for the protocol"
- };
-
- MetaType[] configItemTypes = {
- SimpleMetaType.STRING,
- SimpleMetaType.STRING,
- SimpleMetaType.STRING,
- PROTOCOL_PARAMETER_SET_TYPE
-
- };
-
- PROTOCOL_STACK_CONFIG_TYPE = new ImmutableCompositeMetaType(ProtocolData.class.getName(),
- "Protocol Stack Configuration",
- configItemNames, configItemDescs, configItemTypes);
-
- TYPE = new CollectionMetaType(List.class.getName(), PROTOCOL_STACK_CONFIG_TYPE);
- }
-
- @Override
- public MetaType getMetaType()
- {
- return TYPE;
- }
-
- @Override
- public Type mapToType()
- {
- return List.class;
- }
-
- @Override
- public MetaValue createMetaValue(MetaType metaType, ProtocolData[] data)
- {
- MetaValue[] dataElements = new MetaValue[data.length];
- for (int i = 0; i < data.length; i++)
- {
- Map<String, MetaValue> protocolValue = new HashMap<String, MetaValue>();
- protocolValue.put("name", SimpleValueSupport.wrap(data[i].getProtocolName()));
- protocolValue.put("description", SimpleValueSupport.wrap(data[i].getDescription()));
- protocolValue.put("className", SimpleValueSupport.wrap(data[i].getClassName()));
-
- ProtocolParameter[] params = data[i].getParametersAsArray();
- MetaValue[] paramElements = new MetaValue[params.length];
- for (int j = 0; j < params.length; j++)
- {
- Map<String, MetaValue> paramValue = new HashMap<String, MetaValue>();
- paramValue.put("name", SimpleValueSupport.wrap(params[j].getName()));
- // FIXME -- deal with description
-// protocolValue.put("description", SimpleValueSupport.wrap(params[j].getDescription()));
-// paramValue.put("description", null);
- paramValue.put("value", SimpleValueSupport.wrap(params[j].getValue()));
-
- paramElements[j] = new CompositeValueSupport(PROTOCOL_PARAMETER_TYPE, paramValue);
- }
- protocolValue.put("protocolParameters", new CollectionValueSupport(PROTOCOL_PARAMETER_SET_TYPE, paramElements));
-
- dataElements[i] = new CompositeValueSupport(PROTOCOL_STACK_CONFIG_TYPE, protocolValue);
- }
- return new CollectionValueSupport(TYPE, dataElements);
- }
-
- @Override
- public ProtocolData[] unwrapMetaValue(MetaValue metaValue)
- {
- if (metaValue == null)
- {
- return null;
- }
-
- if ((metaValue instanceof CollectionValue) == false)
- {
- throw new IllegalArgumentException(metaValue + " is not a " + CollectionValue.class.getSimpleName());
- }
- MetaValue[] elements = ((CollectionValue) metaValue).getElements();
-
- ProtocolData[] protocolData = new ProtocolData[elements.length];
- for (int i = 0; i < elements.length; i++)
- {
- CompositeValue protocolValue = (CompositeValue) elements[i];
- String protName = (String) ((SimpleValue) protocolValue.get("name")).getValue();
- String protDesc = (String) ((SimpleValue) protocolValue.get("description")).getValue();
- String protClass = (String) ((SimpleValue) protocolValue.get("className")).getValue();
- CollectionValue paramsValue = (CollectionValue) protocolValue.get("protocolParameters");
- MetaValue[] paramElements = paramsValue.getElements();
- ProtocolParameter[] protParams = paramElements == null ? null : new ProtocolParameter[paramElements.length];
- for (int j = 0 ; j < paramElements.length; j++)
- {
- CompositeValue paramValue = (CompositeValue) paramElements[j];
- String paramName = (String) ((SimpleValue) paramValue.get("name")).getValue();
- String paramVal = (String) ((SimpleValue) paramValue.get("value")).getValue();
- protParams[j] = new ProtocolParameter(paramName, paramVal);
- }
- protocolData[i] = new ProtocolData(protName, protDesc, protClass, protParams);
- }
- return protocolData;
- }
-
-}
Copied: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java (from rev 90480, trunk/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java)
===================================================================
--- branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java (rev 0)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigMapper.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ha.framework.server.managed;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
+import org.jgroups.conf.ProtocolData;
+import org.jgroups.conf.ProtocolParameter;
+
+/**
+ * MetaMapper for the ProtocolData[] description of a JGroups protocol stack
+ * configuration.
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: $
+ */
+public class ProtocolStackConfigMapper extends MetaMapper<ProtocolData[]>
+{
+ public static final CompositeMetaType PROTOCOL_PARAMETER_TYPE;
+ public static final CollectionMetaType PROTOCOL_PARAMETER_SET_TYPE;
+ public static final CompositeMetaType PROTOCOL_STACK_CONFIG_TYPE;
+ public static final CollectionMetaType TYPE;
+
+ static
+ {
+ String[] paramItemNames = {
+ "name",
+ "description",
+ "value"
+ };
+ String[] paramItemDescs = {
+ "the name of the configuration parameter",
+ "description of the meaning of the attribute",
+ "the value of the configuration parameter"
+ };
+ MetaType[] paramItemTypes = {
+ SimpleMetaType.STRING,
+ SimpleMetaType.STRING,
+ SimpleMetaType.STRING
+ };
+
+ PROTOCOL_PARAMETER_TYPE = new ImmutableCompositeMetaType(ProtocolParameter.class.getName(),
+ "Protocol Parameters",
+ paramItemNames, paramItemDescs, paramItemTypes);
+
+ PROTOCOL_PARAMETER_SET_TYPE = new CollectionMetaType(Set.class.getName(), PROTOCOL_PARAMETER_TYPE);
+
+ String[] configItemNames = {
+ "name",
+ "description",
+ "className",
+ "protocolParameters"
+ };
+ String[] configItemDescs = {
+ "the name of the protocol",
+ "description of the protocol",
+ "fully-qualified name of the protocol implementation class",
+ "set of configuration parameters for the protocol"
+ };
+
+ MetaType[] configItemTypes = {
+ SimpleMetaType.STRING,
+ SimpleMetaType.STRING,
+ SimpleMetaType.STRING,
+ PROTOCOL_PARAMETER_SET_TYPE
+
+ };
+
+ PROTOCOL_STACK_CONFIG_TYPE = new ImmutableCompositeMetaType(ProtocolData.class.getName(),
+ "Protocol Stack Configuration",
+ configItemNames, configItemDescs, configItemTypes);
+
+ TYPE = new CollectionMetaType(List.class.getName(), PROTOCOL_STACK_CONFIG_TYPE);
+ }
+
+ @Override
+ public MetaType getMetaType()
+ {
+ return TYPE;
+ }
+
+ @Override
+ public Type mapToType()
+ {
+ return List.class;
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, ProtocolData[] data)
+ {
+ MetaValue[] dataElements = new MetaValue[data.length];
+ for (int i = 0; i < data.length; i++)
+ {
+ Map<String, MetaValue> protocolValue = new HashMap<String, MetaValue>();
+ protocolValue.put("name", SimpleValueSupport.wrap(data[i].getProtocolName()));
+ protocolValue.put("description", SimpleValueSupport.wrap(data[i].getDescription()));
+ protocolValue.put("className", SimpleValueSupport.wrap(data[i].getClassName()));
+
+ ProtocolParameter[] params = data[i].getParametersAsArray();
+ MetaValue[] paramElements = new MetaValue[params.length];
+ for (int j = 0; j < params.length; j++)
+ {
+ Map<String, MetaValue> paramValue = new HashMap<String, MetaValue>();
+ paramValue.put("name", SimpleValueSupport.wrap(params[j].getName()));
+ // FIXME -- deal with description
+// protocolValue.put("description", SimpleValueSupport.wrap(params[j].getDescription()));
+// paramValue.put("description", null);
+ paramValue.put("value", SimpleValueSupport.wrap(params[j].getValue()));
+
+ paramElements[j] = new CompositeValueSupport(PROTOCOL_PARAMETER_TYPE, paramValue);
+ }
+ protocolValue.put("protocolParameters", new CollectionValueSupport(PROTOCOL_PARAMETER_SET_TYPE, paramElements));
+
+ dataElements[i] = new CompositeValueSupport(PROTOCOL_STACK_CONFIG_TYPE, protocolValue);
+ }
+ return new CollectionValueSupport(TYPE, dataElements);
+ }
+
+ @Override
+ public ProtocolData[] unwrapMetaValue(MetaValue metaValue)
+ {
+ if (metaValue == null)
+ {
+ return null;
+ }
+
+ if ((metaValue instanceof CollectionValue) == false)
+ {
+ throw new IllegalArgumentException(metaValue + " is not a " + CollectionValue.class.getSimpleName());
+ }
+ MetaValue[] elements = ((CollectionValue) metaValue).getElements();
+
+ ProtocolData[] protocolData = new ProtocolData[elements.length];
+ for (int i = 0; i < elements.length; i++)
+ {
+ CompositeValue protocolValue = (CompositeValue) elements[i];
+ String protName = (String) ((SimpleValue) protocolValue.get("name")).getValue();
+ String protDesc = (String) ((SimpleValue) protocolValue.get("description")).getValue();
+ String protClass = (String) ((SimpleValue) protocolValue.get("className")).getValue();
+ CollectionValue paramsValue = (CollectionValue) protocolValue.get("protocolParameters");
+ MetaValue[] paramElements = paramsValue.getElements();
+ ProtocolParameter[] protParams = paramElements == null ? null : new ProtocolParameter[paramElements.length];
+ for (int j = 0 ; j < paramElements.length; j++)
+ {
+ CompositeValue paramValue = (CompositeValue) paramElements[j];
+ String paramName = (String) ((SimpleValue) paramValue.get("name")).getValue();
+ String paramVal = (String) ((SimpleValue) paramValue.get("value")).getValue();
+ protParams[j] = new ProtocolParameter(paramName, paramVal);
+ }
+ protocolData[i] = new ProtocolData(protName, protDesc, protClass, protParams);
+ }
+ return protocolData;
+ }
+
+}
Deleted: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigurationsMapper.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigurationsMapper.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigurationsMapper.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -1,159 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.ha.framework.server.managed;
-
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.ha.framework.server.ProtocolStackConfigInfo;
-import org.jboss.logging.Logger;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.CollectionValue;
-import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.metatype.api.values.CompositeValueSupport;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.metatype.spi.values.MetaMapper;
-import org.jgroups.conf.ConfiguratorFactory;
-import org.jgroups.conf.ProtocolData;
-import org.jgroups.conf.ProtocolParameter;
-import org.jgroups.conf.ProtocolStackConfigurator;
-
-/**
- * {@link MetaMapper} for a map of {@link ProtocolStackConfigInfo}s keyed by
- * the name of the protocol stack.
- *
- * @author Brian Stansberry
- */
-public class ProtocolStackConfigurationsMapper extends MetaMapper<Map<String, ProtocolStackConfigInfo>>
-{
- private static final Logger log = Logger.getLogger(ProtocolStackConfigurationsMapper.class);
-
- private static final ProtocolStackConfigMapper CONFIG_MAPPER = new ProtocolStackConfigMapper();
- public static final CompositeMetaType TYPE;
-
- static
- {
-
- String[] itemNames = {
- "name",
- "description",
- "configuration"
- };
- String[] itemDescriptions = {
- "the name of the protocol stack",
- "description of the protocol stack",
- "list of protocol configuration elements, each configuring a single protocol",
- };
- MetaType[] itemTypes = {
- SimpleMetaType.STRING,
- SimpleMetaType.STRING,
- CONFIG_MAPPER.getMetaType()
- };
- TYPE = new ImmutableCompositeMetaType(ProtocolStackConfigInfo.class.getName(),
- "Protocol Stack Configurations",
- itemNames, itemDescriptions, itemTypes);
- }
-
- @Override
- public MetaType getMetaType()
- {
- return TYPE;
- }
-
- @Override
- public Type mapToType()
- {
- return Map.class;
- }
-
- @Override
- public MetaValue createMetaValue(MetaType metaType, Map<String, ProtocolStackConfigInfo> object)
- {
- Map<String, MetaValue> result = new HashMap<String, MetaValue>();
- for (Map.Entry<String, ProtocolStackConfigInfo> entry : object.entrySet())
- {
- ProtocolStackConfigInfo info = entry.getValue();
- Map<String, MetaValue> stackValue = new HashMap<String, MetaValue>();
- stackValue.put("name", SimpleValueSupport.wrap(info.getName()));
- stackValue.put("description", SimpleValueSupport.wrap(info.getDescription()));
-
- ProtocolData[] data = info.getConfiguration();
- stackValue.put("configuration", CONFIG_MAPPER.createMetaValue(CONFIG_MAPPER.getMetaType(), data));
-
- result.put(entry.getKey(), new CompositeValueSupport(TYPE, stackValue));
- }
-
- return new MapCompositeValueSupport(result, TYPE);
- }
-
- /**
- * Converts the {@link CompositeValue} <code>metaValue</code> into a
- * <code>Map<String, ProtocolStackConfigInfo></code>.
- *
- * {@inheritDoc}
- *
- * @throws IllegalArgumentException if <code>metaValue</code> is not a
- * {@link CompositeValue}
- */
- @Override
- public Map<String, ProtocolStackConfigInfo> unwrapMetaValue(MetaValue metaValue)
- {
- if (metaValue == null)
- {
- return null;
- }
-
- if ((metaValue instanceof CompositeValue) == false)
- {
- throw new IllegalArgumentException(metaValue + " is not a " + CompositeValue.class.getSimpleName());
- }
- Map<String, ProtocolStackConfigInfo> result = new HashMap<String, ProtocolStackConfigInfo>();
- CompositeValue topCompValue = (CompositeValue) metaValue;
- for (String stack : topCompValue.getMetaType().keySet())
- {
- CompositeValue stackValue = (CompositeValue) topCompValue.get(stack);
-
- String name = (String) ((SimpleValue) stackValue.get("name")).getValue();
-
- String description = (String) ((SimpleValue) stackValue.get("description")).getValue();
-
- CollectionValue protocolsValue = (CollectionValue) stackValue.get("configuration");
- ProtocolData[] protocolData = CONFIG_MAPPER.unwrapMetaValue(protocolsValue);
- ProtocolStackConfigurator configurator = new ProtocolDataProtocolStackConfigurator(protocolData);
- // fixes http://jira.jboss.com/jira/browse/JGRP-290
- ConfiguratorFactory.substituteVariables(configurator); // replace vars with system props
-
- result.put(stack, new ProtocolStackConfigInfo(name, description, configurator));
- }
-
- return result;
- }
-
-}
Copied: branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigurationsMapper.java (from rev 90480, trunk/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigurationsMapper.java)
===================================================================
--- branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigurationsMapper.java (rev 0)
+++ branches/dml-log-service-integration/cluster/src/main/org/jboss/ha/framework/server/managed/ProtocolStackConfigurationsMapper.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ha.framework.server.managed;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.ha.framework.server.ProtocolStackConfigInfo;
+import org.jboss.logging.Logger;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
+import org.jgroups.conf.ConfiguratorFactory;
+import org.jgroups.conf.ProtocolData;
+import org.jgroups.conf.ProtocolParameter;
+import org.jgroups.conf.ProtocolStackConfigurator;
+
+/**
+ * {@link MetaMapper} for a map of {@link ProtocolStackConfigInfo}s keyed by
+ * the name of the protocol stack.
+ *
+ * @author Brian Stansberry
+ */
+public class ProtocolStackConfigurationsMapper extends MetaMapper<Map<String, ProtocolStackConfigInfo>>
+{
+ private static final Logger log = Logger.getLogger(ProtocolStackConfigurationsMapper.class);
+
+ private static final ProtocolStackConfigMapper CONFIG_MAPPER = new ProtocolStackConfigMapper();
+ public static final CompositeMetaType TYPE;
+
+ static
+ {
+
+ String[] itemNames = {
+ "name",
+ "description",
+ "configuration"
+ };
+ String[] itemDescriptions = {
+ "the name of the protocol stack",
+ "description of the protocol stack",
+ "list of protocol configuration elements, each configuring a single protocol",
+ };
+ MetaType[] itemTypes = {
+ SimpleMetaType.STRING,
+ SimpleMetaType.STRING,
+ CONFIG_MAPPER.getMetaType()
+ };
+ TYPE = new ImmutableCompositeMetaType(ProtocolStackConfigInfo.class.getName(),
+ "Protocol Stack Configurations",
+ itemNames, itemDescriptions, itemTypes);
+ }
+
+ @Override
+ public MetaType getMetaType()
+ {
+ return TYPE;
+ }
+
+ @Override
+ public Type mapToType()
+ {
+ return Map.class;
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, Map<String, ProtocolStackConfigInfo> object)
+ {
+ Map<String, MetaValue> result = new HashMap<String, MetaValue>();
+ for (Map.Entry<String, ProtocolStackConfigInfo> entry : object.entrySet())
+ {
+ ProtocolStackConfigInfo info = entry.getValue();
+ Map<String, MetaValue> stackValue = new HashMap<String, MetaValue>();
+ stackValue.put("name", SimpleValueSupport.wrap(info.getName()));
+ stackValue.put("description", SimpleValueSupport.wrap(info.getDescription()));
+
+ ProtocolData[] data = info.getConfiguration();
+ stackValue.put("configuration", CONFIG_MAPPER.createMetaValue(CONFIG_MAPPER.getMetaType(), data));
+
+ result.put(entry.getKey(), new CompositeValueSupport(TYPE, stackValue));
+ }
+
+ return new MapCompositeValueSupport(result, TYPE);
+ }
+
+ /**
+ * Converts the {@link CompositeValue} <code>metaValue</code> into a
+ * <code>Map<String, ProtocolStackConfigInfo></code>.
+ *
+ * {@inheritDoc}
+ *
+ * @throws IllegalArgumentException if <code>metaValue</code> is not a
+ * {@link CompositeValue}
+ */
+ @Override
+ public Map<String, ProtocolStackConfigInfo> unwrapMetaValue(MetaValue metaValue)
+ {
+ if (metaValue == null)
+ {
+ return null;
+ }
+
+ if ((metaValue instanceof CompositeValue) == false)
+ {
+ throw new IllegalArgumentException(metaValue + " is not a " + CompositeValue.class.getSimpleName());
+ }
+ Map<String, ProtocolStackConfigInfo> result = new HashMap<String, ProtocolStackConfigInfo>();
+ CompositeValue topCompValue = (CompositeValue) metaValue;
+ for (String stack : topCompValue.getMetaType().keySet())
+ {
+ CompositeValue stackValue = (CompositeValue) topCompValue.get(stack);
+
+ String name = (String) ((SimpleValue) stackValue.get("name")).getValue();
+
+ String description = (String) ((SimpleValue) stackValue.get("description")).getValue();
+
+ CollectionValue protocolsValue = (CollectionValue) stackValue.get("configuration");
+ ProtocolData[] protocolData = CONFIG_MAPPER.unwrapMetaValue(protocolsValue);
+ ProtocolStackConfigurator configurator = new ProtocolDataProtocolStackConfigurator(protocolData);
+ // fixes http://jira.jboss.com/jira/browse/JGRP-290
+ ConfiguratorFactory.substituteVariables(configurator); // replace vars with system props
+
+ result.put(stack, new ProtocolStackConfigInfo(name, description, configurator));
+ }
+
+ return result;
+ }
+
+}
Modified: branches/dml-log-service-integration/component-matrix/pom.xml
===================================================================
--- branches/dml-log-service-integration/component-matrix/pom.xml 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/component-matrix/pom.xml 2009-06-19 20:18:44 UTC (rev 90481)
@@ -92,7 +92,7 @@
<version.org.jboss.vfs>2.1.0.GA</version.org.jboss.vfs>
<version.org.jboss.security.negotiation>2.0.3.SP1</version.org.jboss.security.negotiation>
<version.org.jboss.slf4j>1.0.2.GA</version.org.jboss.slf4j>
- <version.org.jboss.xnio.metadata>1.0.0.GA</version.org.jboss.xnio.metadata>
+ <version.org.jboss.xnio.metadata>1.0.1.GA</version.org.jboss.xnio.metadata>
<version.org.jboss.xnio>1.2.0.GA</version.org.jboss.xnio>
<version.org.slf4j>1.5.6</version.org.slf4j>
<version.org.springframework>2.5.5</version.org.springframework>
@@ -2088,7 +2088,7 @@
<dependency>
<groupId>org.jboss.security</groupId>
<artifactId>jbossxacml</artifactId>
- <version>2.0.3</version>
+ <version>2.0.3.SP2</version>
<exclusions>
<exclusion>
<groupId>sun-jaf</groupId>
Modified: branches/dml-log-service-integration/connector/src/main/org/jboss/resource/deployers/management/AbstractConnectionFactoryICF.java
===================================================================
--- branches/dml-log-service-integration/connector/src/main/org/jboss/resource/deployers/management/AbstractConnectionFactoryICF.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/connector/src/main/org/jboss/resource/deployers/management/AbstractConnectionFactoryICF.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -72,7 +72,7 @@
PropertyInfo propertyInfo = property.getField(Fields.PROPERTY_INFO, PropertyInfo.class);
if(propertyInfo == null)
propertyInfo = beanInfo.getProperty(propertyName);
-
+
// Check if the property is readable
if(propertyInfo != null && propertyInfo.isReadable() == false)
return null;
Modified: branches/dml-log-service-integration/connector/src/main/org/jboss/resource/deployers/management/AbstractNonXADataSourceICF.java
===================================================================
--- branches/dml-log-service-integration/connector/src/main/org/jboss/resource/deployers/management/AbstractNonXADataSourceICF.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/connector/src/main/org/jboss/resource/deployers/management/AbstractNonXADataSourceICF.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -76,11 +76,6 @@
}
value = mapValue;
}
- else if("interleaving".equals(property.getName()))
- {
- Boolean interleaving = attachment.isInterleaving();
- value = SimpleValueSupport.wrap(interleaving);
- }
else
{
value = super.getValue(beanInfo, property, metaData, attachment);
Modified: branches/dml-log-service-integration/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java
===================================================================
--- branches/dml-log-service-integration/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/connector/src/main/org/jboss/resource/metadata/mcf/ManagedConnectionFactoryDeploymentMetaData.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -257,7 +257,6 @@
{
return useJavaContext;
}
-
/**
* Set the useJavaContext.
*
@@ -504,7 +503,6 @@
{
return backgroundValidation;
}
-
public void setBackgroundValidation(boolean backgroundValidation)
{
this.backgroundValidation = backgroundValidation;
@@ -531,7 +529,6 @@
{
return this.validateOnMatch;
}
-
@ManagementProperty(name="isSameRM-override-value", includeInTemplate=true)
public Boolean getIsSameRMOverrideValue()
{
@@ -542,9 +539,9 @@
{
this.isSameRMOverrideValue = isSameRMOverrideValue;
}
-
@Deprecated
- @ManagementProperty(name="track-connection-by-tx", includeInTemplate=true)
+ @ManagementProperty(name="track-connection-by-tx", includeInTemplate=true,
+ use={ViewUse.CONFIGURATION})
public Boolean getTrackConnectionByTransaction()
{
return !isInterleaving();
@@ -561,13 +558,16 @@
setInterleaving(!Boolean.TRUE.equals(trackConnectionByTransaction));
}
- @ManagementProperty(name="interleaving", includeInTemplate=true,
- use={ViewUse.CONFIGURATION})
public Boolean isInterleaving()
{
return interleaving == Boolean.TRUE && !Boolean.TRUE.equals(getLocalTransactions());
}
-
+ @ManagementProperty(name="interleaving", includeInTemplate=true,
+ use={ViewUse.CONFIGURATION})
+ public Boolean getInterleaving()
+ {
+ return isInterleaving();
+ }
public void setInterleaving(Boolean interleaving)
{
this.interleaving = interleaving;
Modified: branches/dml-log-service-integration/security/src/main/org/jboss/security/plugins/JaasSecurityDomain.java
===================================================================
--- branches/dml-log-service-integration/security/src/main/org/jboss/security/plugins/JaasSecurityDomain.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/security/src/main/org/jboss/security/plugins/JaasSecurityDomain.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -644,7 +644,7 @@
{
keyStore = KeyStore.getInstance(keyStoreType);
InputStream is = null;
- if (!"PKCS11".equalsIgnoreCase(keyStoreType) && keyStoreURL != null)
+ if ((!"PKCS11".equalsIgnoreCase(keyStoreType) || !"PKCS11IMPLKS".equalsIgnoreCase(keyStoreType)) && keyStoreURL != null)
{
is = keyStoreURL.openStream();
}
@@ -669,7 +669,7 @@
{
trustStore = KeyStore.getInstance(trustStoreType);
InputStream is = null;
- if (!"PKCS11".equalsIgnoreCase(trustStoreType) && trustStoreURL != null)
+ if ((!"PKCS11".equalsIgnoreCase(trustStoreType) || !"PKCS11IMPLKS".equalsIgnoreCase(trustStoreType)) && trustStoreURL != null)
{
is = trustStoreURL.openStream();
}
Modified: branches/dml-log-service-integration/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java
===================================================================
--- branches/dml-log-service-integration/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -36,7 +36,7 @@
* Metadata for an endpoint container and its dependencies on other endpoints.
*
* @author Scott.Stark at jboss.org
- * @version $Revision:$
+ * @version $Revision$
*/
public class ContainerDependencyMetaData extends JBossObject
{
@@ -77,6 +77,7 @@
*/
public ContainerDependencyMetaData(String containerName, String componentName, String deploymentPath)
{
+ super(log);
this.containerName = containerName;
this.componentName = componentName;
this.deploymentPath = deploymentPath;
Modified: branches/dml-log-service-integration/server/src/main/org/jboss/deployment/dependency/JndiDependencyMetaData.java
===================================================================
--- branches/dml-log-service-integration/server/src/main/org/jboss/deployment/dependency/JndiDependencyMetaData.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/server/src/main/org/jboss/deployment/dependency/JndiDependencyMetaData.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -65,6 +65,7 @@
public JndiDependencyMetaData(String jndiName, ClassLoader loader,
ControllerState whenRequired)
{
+ super(log);
this.jndiName = jndiName;
this.loader = loader;
this.whenRequired = whenRequired;
Modified: branches/dml-log-service-integration/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java
===================================================================
--- branches/dml-log-service-integration/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/system/src/main/org/jboss/system/server/profileservice/VFSScanner.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -43,6 +43,7 @@
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.logging.Logger;
/**
* A DeploymentScanner build on top of the VFS and ProfileService. This is a
@@ -55,6 +56,8 @@
*/
public abstract class VFSScanner extends JBossObject
{
+ private static final Logger log = Logger.getLogger(VFSScanner.class);
+
/** The profile service */
private ProfileService profileService;
@@ -81,8 +84,16 @@
/** The deployment factory */
private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
-
- /**
+
+ /**
+ * Construct a new instance.
+ */
+ protected VFSScanner()
+ {
+ super(log);
+ }
+
+ /**
* Get the profileKey.
*
* @return the profileKey.
Modified: branches/dml-log-service-integration/system-jmx/src/main/org/jboss/system/metadata/ServiceAnnotationMetaData.java
===================================================================
--- branches/dml-log-service-integration/system-jmx/src/main/org/jboss/system/metadata/ServiceAnnotationMetaData.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/system-jmx/src/main/org/jboss/system/metadata/ServiceAnnotationMetaData.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -29,6 +29,7 @@
import org.jboss.util.JBossObject;
import org.jboss.util.JBossStringBuilder;
import org.jboss.util.StringPropertyReplacer;
+import org.jboss.logging.Logger;
/**
* Service annotation metadata
@@ -41,6 +42,8 @@
{
private static final long serialVersionUID = 1L;
+ private static final Logger log = Logger.getLogger(ServiceAnnotationMetaData.class);
+
public String annotation;
protected Annotation ann;
@@ -52,7 +55,7 @@
*/
public ServiceAnnotationMetaData()
{
- super();
+ super(log);
}
/**
* Create a new annotation meta data
@@ -60,7 +63,7 @@
*/
public ServiceAnnotationMetaData(String ann)
{
- super();
+ super(log);
setAnnotation(ann);
}
Modified: branches/dml-log-service-integration/system-jmx/src/main/org/jboss/system/server/jmx/JMXKernel.java
===================================================================
--- branches/dml-log-service-integration/system-jmx/src/main/org/jboss/system/server/jmx/JMXKernel.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/system-jmx/src/main/org/jboss/system/server/jmx/JMXKernel.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -63,6 +63,7 @@
import org.jboss.util.file.FileSuffixFilter;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
+import org.jboss.logging.Logger;
/**
* A pojo that creates a legacy jmx kernel ala the jboss-4.x server bootstrap.
@@ -77,6 +78,8 @@
private final static ObjectName DEFAULT_LOADER_NAME =
ObjectNameFactory.create(ServerConstants.DEFAULT_LOADER_NAME);
+ private static final Logger log = Logger.getLogger(JMXKernel.class);
+
/** The JMX MBeanServer which will serve as our communication bus. */
private MBeanServer mbeanServer;
private ServerProcess serverImpl;
@@ -94,7 +97,12 @@
private boolean started;
/** Whether to use the old classloader */
private boolean oldClassLoader;
-
+
+ public JMXKernel()
+ {
+ super(log);
+ }
+
public ServerProcess getServerImpl()
{
return serverImpl;
Copied: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory (from rev 90480, trunk/testsuite/src/main/org/jboss/test/cluster/channelfactory)
Copied: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed (from rev 90480, trunk/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed)
Deleted: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -1,274 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.test.cluster.channelfactory.managed;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.management.ObjectName;
-
-import org.jboss.logging.Logger;
-import org.jboss.metatype.api.values.CollectionValue;
-import org.jboss.metatype.api.values.CompositeValue;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.plugins.values.mappers.PropertiesCompositeObjectNameMetaMapper;
-
-/**
- *
- *
- * @author Brian Stansberry
- *
- * @version $Revision: $
- */
-public class ManagedObjectTestUtil
-{
- private static final Logger log = Logger.getLogger(ManagedObjectTestUtil.class);
-
- public static void validateProtocolStackConfigurations(MetaValue metaVal, String[] expectedStacks)
- {
- assertTrue(metaVal instanceof CompositeValue);
- CompositeValue compVal = (CompositeValue) metaVal;
- if (expectedStacks != null)
- {
- for (String stack : expectedStacks)
- {
- assertTrue("ChannelFactory has stack " + stack, compVal.containsKey(stack));
- }
- }
- for (String stack : compVal.getMetaType().keySet())
- {
- validateProtocolStackValue(stack, compVal.get(stack));
- }
- }
-
- public static Set<ChannelIds> validateOpenChannels(MetaValue metaVal)
- {
- assertTrue(metaVal instanceof CollectionValue);
-
- Set<ChannelIds> result = new HashSet<ChannelIds>();
-
- MetaValue[] elements = ((CollectionValue) metaVal).getElements();
- assertNotNull(elements);
- assertTrue(elements.length > 0); // may not be true someday if things go "on-demand"
- for (MetaValue element : elements)
- {
- result.add(validateOpenChannelValue(element));
- }
-
- return result;
- }
-
- public static void validateProtocolStackValue(String stack, MetaValue metaValue)
- {
- assertNotNull("null value for " + stack, metaValue);
- log.info(stack + " -- " + metaValue);
-
- assertTrue(metaValue instanceof CompositeValue);
- CompositeValue compVal = (CompositeValue) metaValue;
- assertEquals(stack, getSimpleValue(compVal, "name"));
- Object val = getSimpleValue(compVal, "description");
- if (val != null)
- {
- assertTrue(val instanceof String);
- }
- MetaValue mv = compVal.get("configuration");
- assertTrue(mv instanceof CollectionValue);
- CollectionValue config = (CollectionValue) mv;
- MetaValue[] elements = config.getElements();
- for (MetaValue element : elements)
- {
- validateProtocolStackConfiguration(element);
- }
- }
-
- public static void validateProtocolStackConfiguration(MetaValue metaValue)
- {
- assertNotNull("null protocol stack configuration", metaValue);
- assertTrue(metaValue instanceof CompositeValue);
- CompositeValue compVal = (CompositeValue) metaValue;
- assertNotNull(getSimpleValue(compVal, "name", String.class));
- Object val = getSimpleValue(compVal, "description");
- if (val != null)
- {
- assertTrue(val instanceof String);
- }
- assertNotNull(getSimpleValue(compVal, "className", String.class));
- MetaValue mv = compVal.get("protocolParameters");
- assertTrue(mv instanceof CollectionValue);
- CollectionValue params = (CollectionValue) mv;
- MetaValue[] elements = params.getElements();
- for (MetaValue element : elements)
- {
- validateProtocolParameter(element);
- }
- }
-
- public static void validateProtocolParameter(MetaValue metaValue)
- {
- assertNotNull("null protocol parameter", metaValue);
- assertTrue(metaValue instanceof CompositeValue);
- CompositeValue compVal = (CompositeValue) metaValue;
- assertNotNull(getSimpleValue(compVal, "name", String.class));
- Object val = getSimpleValue(compVal, "description");
- if (val != null)
- {
- assertTrue(val instanceof String);
- }
- assertNotNull(getSimpleValue(compVal, "value", String.class));
- }
-
- public static ChannelIds validateOpenChannelValue(MetaValue metaValue)
- {
- log.info(metaValue);
-
- assertTrue(metaValue instanceof CompositeValue);
-
- ChannelIds result = new ChannelIds();
-
- CompositeValue compVal = (CompositeValue) metaValue;
-
- result.id = getSimpleValue(compVal, "id", String.class);
- result.clusterName = getSimpleValue(compVal, "clusterName", String.class);
- assertNotNull("Channel " + result.id + " has clusterName", result.clusterName);
-
- result.stackName = getSimpleValue(compVal, "stackName", String.class);
-
- MetaValue mv = compVal.get("protocolStackConfiguration");
- assertTrue(mv instanceof CollectionValue);
- CollectionValue config = (CollectionValue) mv;
- MetaValue[] elements = config.getElements();
- for (MetaValue element : elements)
- {
- ManagedObjectTestUtil.validateProtocolStackConfiguration(element);
- }
-
- mv = compVal.get("channelObjectName");
- validateObjectNameMetaValue(mv);
-
- mv = compVal.get("protocolObjectNames");
- assertTrue(mv instanceof CollectionValue);
- CollectionValue protocolNames = (CollectionValue) mv;
- elements = protocolNames.getElements();
- for (MetaValue element : elements)
- {
- validateObjectNameMetaValue(element);
- }
-
- getSimpleValue(compVal, "localAddress", String.class);
-
- mv = compVal.get("currentView");
- validateView(mv);
-
- return result;
- }
-
- public static void validateObjectNameMetaValue(MetaValue mv)
- {
- if (mv != null)
- {
- try
- {
- Object on = MetaValueFactory.getInstance().unwrap(mv);
- assertNotNull(on);
- assertTrue(on instanceof ObjectName);
- }
- catch (RuntimeException e)
- {
- fail(e.getLocalizedMessage());
- }
- }
- }
-
- public static void validateView(MetaValue metaValue)
- {
- assertNotNull(metaValue);
- log.info(metaValue);
- assertTrue(metaValue instanceof CompositeValue);
- CompositeValue compVal = (CompositeValue) metaValue;
- assertNotNull(getSimpleValue(compVal, "id", Long.class));
- assertNotNull(getSimpleValue(compVal, "creator", String.class));
- String coord = getSimpleValue(compVal, "coordinator", String.class);
- assertNotNull(coord);
- MetaValue mv = compVal.get("members");
- assertTrue(mv instanceof CollectionValue);
- CollectionValue protocolNames = (CollectionValue) mv;
- MetaValue[] elements = protocolNames.getElements();
- boolean foundCoord = false;
- for (MetaValue element : elements)
- {
- assertTrue(element instanceof SimpleValue);
- Object val = ((SimpleValue) element).getValue();
- assertTrue(val instanceof String);
- if (coord.equals(val))
- {
- foundCoord = true;
- }
- }
- assertTrue(foundCoord);
- getSimpleValue(compVal, "payload", String.class);
- }
-
- /** Simple data object to pass back aggregated data for test callers */
- public static class ChannelIds
- {
- public String id;
- public String clusterName;
- public String stackName;
- }
-
- public static Object getSimpleValue(MetaValue val, String key)
- {
- return getSimpleValue(val, key, Object.class);
- }
-
- public static <T> T getSimpleValue(MetaValue val, String key, Class<T> type)
- {
- T result = null;
- assertTrue(val instanceof CompositeValue);
- CompositeValue cval = (CompositeValue) val;
- MetaValue mv = cval.get(key);
- if (mv != null)
- {
- assertTrue(mv instanceof SimpleValue);
- Object obj = ((SimpleValue) mv).getValue();
- result = type.cast(obj);
- }
- return result;
- }
-
- /**
- * Prevent instantiation
- */
- private ManagedObjectTestUtil()
- {
- // no-op
- }
-
-}
Copied: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java (from rev 90480, trunk/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java)
===================================================================
--- branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java (rev 0)
+++ branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/channelfactory/managed/ManagedObjectTestUtil.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -0,0 +1,274 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.cluster.channelfactory.managed;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.ObjectName;
+
+import org.jboss.logging.Logger;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.plugins.values.mappers.PropertiesCompositeObjectNameMetaMapper;
+
+/**
+ *
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: $
+ */
+public class ManagedObjectTestUtil
+{
+ private static final Logger log = Logger.getLogger(ManagedObjectTestUtil.class);
+
+ public static void validateProtocolStackConfigurations(MetaValue metaVal, String[] expectedStacks)
+ {
+ assertTrue(metaVal instanceof CompositeValue);
+ CompositeValue compVal = (CompositeValue) metaVal;
+ if (expectedStacks != null)
+ {
+ for (String stack : expectedStacks)
+ {
+ assertTrue("ChannelFactory has stack " + stack, compVal.containsKey(stack));
+ }
+ }
+ for (String stack : compVal.getMetaType().keySet())
+ {
+ validateProtocolStackValue(stack, compVal.get(stack));
+ }
+ }
+
+ public static Set<ChannelIds> validateOpenChannels(MetaValue metaVal)
+ {
+ assertTrue(metaVal instanceof CollectionValue);
+
+ Set<ChannelIds> result = new HashSet<ChannelIds>();
+
+ MetaValue[] elements = ((CollectionValue) metaVal).getElements();
+ assertNotNull(elements);
+ assertTrue(elements.length > 0); // may not be true someday if things go "on-demand"
+ for (MetaValue element : elements)
+ {
+ result.add(validateOpenChannelValue(element));
+ }
+
+ return result;
+ }
+
+ public static void validateProtocolStackValue(String stack, MetaValue metaValue)
+ {
+ assertNotNull("null value for " + stack, metaValue);
+ log.info(stack + " -- " + metaValue);
+
+ assertTrue(metaValue instanceof CompositeValue);
+ CompositeValue compVal = (CompositeValue) metaValue;
+ assertEquals(stack, getSimpleValue(compVal, "name"));
+ Object val = getSimpleValue(compVal, "description");
+ if (val != null)
+ {
+ assertTrue(val instanceof String);
+ }
+ MetaValue mv = compVal.get("configuration");
+ assertTrue(mv instanceof CollectionValue);
+ CollectionValue config = (CollectionValue) mv;
+ MetaValue[] elements = config.getElements();
+ for (MetaValue element : elements)
+ {
+ validateProtocolStackConfiguration(element);
+ }
+ }
+
+ public static void validateProtocolStackConfiguration(MetaValue metaValue)
+ {
+ assertNotNull("null protocol stack configuration", metaValue);
+ assertTrue(metaValue instanceof CompositeValue);
+ CompositeValue compVal = (CompositeValue) metaValue;
+ assertNotNull(getSimpleValue(compVal, "name", String.class));
+ Object val = getSimpleValue(compVal, "description");
+ if (val != null)
+ {
+ assertTrue(val instanceof String);
+ }
+ assertNotNull(getSimpleValue(compVal, "className", String.class));
+ MetaValue mv = compVal.get("protocolParameters");
+ assertTrue(mv instanceof CollectionValue);
+ CollectionValue params = (CollectionValue) mv;
+ MetaValue[] elements = params.getElements();
+ for (MetaValue element : elements)
+ {
+ validateProtocolParameter(element);
+ }
+ }
+
+ public static void validateProtocolParameter(MetaValue metaValue)
+ {
+ assertNotNull("null protocol parameter", metaValue);
+ assertTrue(metaValue instanceof CompositeValue);
+ CompositeValue compVal = (CompositeValue) metaValue;
+ assertNotNull(getSimpleValue(compVal, "name", String.class));
+ Object val = getSimpleValue(compVal, "description");
+ if (val != null)
+ {
+ assertTrue(val instanceof String);
+ }
+ assertNotNull(getSimpleValue(compVal, "value", String.class));
+ }
+
+ public static ChannelIds validateOpenChannelValue(MetaValue metaValue)
+ {
+ log.info(metaValue);
+
+ assertTrue(metaValue instanceof CompositeValue);
+
+ ChannelIds result = new ChannelIds();
+
+ CompositeValue compVal = (CompositeValue) metaValue;
+
+ result.id = getSimpleValue(compVal, "id", String.class);
+ result.clusterName = getSimpleValue(compVal, "clusterName", String.class);
+ assertNotNull("Channel " + result.id + " has clusterName", result.clusterName);
+
+ result.stackName = getSimpleValue(compVal, "stackName", String.class);
+
+ MetaValue mv = compVal.get("protocolStackConfiguration");
+ assertTrue(mv instanceof CollectionValue);
+ CollectionValue config = (CollectionValue) mv;
+ MetaValue[] elements = config.getElements();
+ for (MetaValue element : elements)
+ {
+ ManagedObjectTestUtil.validateProtocolStackConfiguration(element);
+ }
+
+ mv = compVal.get("channelObjectName");
+ validateObjectNameMetaValue(mv);
+
+ mv = compVal.get("protocolObjectNames");
+ assertTrue(mv instanceof CollectionValue);
+ CollectionValue protocolNames = (CollectionValue) mv;
+ elements = protocolNames.getElements();
+ for (MetaValue element : elements)
+ {
+ validateObjectNameMetaValue(element);
+ }
+
+ getSimpleValue(compVal, "localAddress", String.class);
+
+ mv = compVal.get("currentView");
+ validateView(mv);
+
+ return result;
+ }
+
+ public static void validateObjectNameMetaValue(MetaValue mv)
+ {
+ if (mv != null)
+ {
+ try
+ {
+ Object on = MetaValueFactory.getInstance().unwrap(mv);
+ assertNotNull(on);
+ assertTrue(on instanceof ObjectName);
+ }
+ catch (RuntimeException e)
+ {
+ fail(e.getLocalizedMessage());
+ }
+ }
+ }
+
+ public static void validateView(MetaValue metaValue)
+ {
+ assertNotNull(metaValue);
+ log.info(metaValue);
+ assertTrue(metaValue instanceof CompositeValue);
+ CompositeValue compVal = (CompositeValue) metaValue;
+ assertNotNull(getSimpleValue(compVal, "id", Long.class));
+ assertNotNull(getSimpleValue(compVal, "creator", String.class));
+ String coord = getSimpleValue(compVal, "coordinator", String.class);
+ assertNotNull(coord);
+ MetaValue mv = compVal.get("members");
+ assertTrue(mv instanceof CollectionValue);
+ CollectionValue protocolNames = (CollectionValue) mv;
+ MetaValue[] elements = protocolNames.getElements();
+ boolean foundCoord = false;
+ for (MetaValue element : elements)
+ {
+ assertTrue(element instanceof SimpleValue);
+ Object val = ((SimpleValue) element).getValue();
+ assertTrue(val instanceof String);
+ if (coord.equals(val))
+ {
+ foundCoord = true;
+ }
+ }
+ assertTrue(foundCoord);
+ getSimpleValue(compVal, "payload", String.class);
+ }
+
+ /** Simple data object to pass back aggregated data for test callers */
+ public static class ChannelIds
+ {
+ public String id;
+ public String clusterName;
+ public String stackName;
+ }
+
+ public static Object getSimpleValue(MetaValue val, String key)
+ {
+ return getSimpleValue(val, key, Object.class);
+ }
+
+ public static <T> T getSimpleValue(MetaValue val, String key, Class<T> type)
+ {
+ T result = null;
+ assertTrue(val instanceof CompositeValue);
+ CompositeValue cval = (CompositeValue) val;
+ MetaValue mv = cval.get(key);
+ if (mv != null)
+ {
+ assertTrue(mv instanceof SimpleValue);
+ Object obj = ((SimpleValue) mv).getValue();
+ result = type.cast(obj);
+ }
+ return result;
+ }
+
+ /**
+ * Prevent instantiation
+ */
+ private ManagedObjectTestUtil()
+ {
+ // no-op
+ }
+
+}
Copied: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ChannelFactoryManagedObjectsTestCase.java (from rev 90480, trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ChannelFactoryManagedObjectsTestCase.java)
===================================================================
--- branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ChannelFactoryManagedObjectsTestCase.java (rev 0)
+++ branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ChannelFactoryManagedObjectsTestCase.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -0,0 +1,315 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.test.cluster.defaultcfg.test;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.test.JBossClusteredTestCase;
+import org.jboss.test.cluster.channelfactory.managed.ManagedObjectTestUtil;
+import org.jboss.virtual.VFS;
+
+/**
+ * Validates the expected ChannelFactory-related ManagedObjects are there
+ *
+ * @author Brian Stansberry
+ * @version $Revision: 90011 $
+ */
+public class ChannelFactoryManagedObjectsTestCase
+ extends JBossClusteredTestCase
+{
+ protected ManagementView activeView;
+
+ public ChannelFactoryManagedObjectsTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Look at the JGroups ChannelFactory ManagedComponent
+ * @throws Exception
+ */
+ public void testChannelFactory()
+ throws Exception
+ {
+ ManagedComponent mc = getChannelFactoryManagedComponent();
+ assertNotNull(mc);
+ assertEquals("JChannelFactory", mc.getNameType());
+ assertEquals("JChannelFactory", mc.getName());
+
+ for (Map.Entry<String, ManagedProperty> entry : mc.getProperties().entrySet())
+ {
+ getLog().debug(entry.getKey() + " == " + entry.getValue());
+ ManagedObject mo = entry.getValue().getTargetManagedObject();
+ if (mo != null)
+ {
+ getLog().debug(entry.getKey() + " -- ManagedObject == " + mo);
+ }
+ }
+
+ ManagedProperty prop = mc.getProperty("domain");
+ assertNotNull("ChannelFactory has property domain", prop);
+ MetaValue metaVal = prop.getValue();
+ assertTrue(metaVal instanceof SimpleValue);
+ Object val = ((SimpleValue) metaVal).getValue();
+ assertEquals("jboss.jgroups", val);
+
+ prop = mc.getProperty("exposeChannels");
+ assertNotNull("ChannelFactory has property exposeChannels", prop);
+ metaVal = prop.getValue();
+ assertTrue(metaVal instanceof SimpleValue);
+ val = ((SimpleValue) metaVal).getValue();
+ assertEquals(Boolean.TRUE, val);
+
+ prop = mc.getProperty("exposeProtocols");
+ assertNotNull("ChannelFactory has property exposeProtocols", prop);
+ metaVal = prop.getValue();
+ assertTrue(metaVal instanceof SimpleValue);
+ val = ((SimpleValue) metaVal).getValue();
+ assertEquals(Boolean.TRUE, val);
+
+ prop = mc.getProperty("nodeName");
+ assertNotNull("ChannelFactory has property nodeName", prop);
+ metaVal = prop.getValue();
+ assertTrue(metaVal instanceof SimpleValue);
+ val = ((SimpleValue) metaVal).getValue();
+ assertNotNull(val);
+ assertTrue(val instanceof String);
+
+ prop = mc.getProperty("assignLogicalAddresses");
+ assertNotNull("ChannelFactory has property assignLogicalAddresses", prop);
+ metaVal = prop.getValue();
+ assertTrue(metaVal instanceof SimpleValue);
+ val = ((SimpleValue) metaVal).getValue();
+ assertEquals(Boolean.TRUE, val);
+
+ prop = mc.getProperty("manageNewThreadClassLoader");
+ assertNotNull("ChannelFactory has property manageNewThreadClassLoader", prop);
+ metaVal = prop.getValue();
+ assertTrue(metaVal instanceof SimpleValue);
+ val = ((SimpleValue) metaVal).getValue();
+ assertEquals(Boolean.TRUE, val);
+
+ prop = mc.getProperty("manageReleasedThreadClassLoader");
+ assertNotNull("ChannelFactory has property manageReleasedThreadClassLoader", prop);
+ metaVal = prop.getValue();
+ assertTrue(metaVal instanceof SimpleValue);
+ val = ((SimpleValue) metaVal).getValue();
+ assertTrue(val instanceof Boolean);
+
+ prop = mc.getProperty("addMissingSingletonName");
+ assertNotNull("ChannelFactory has property addMissingSingletonName", prop);
+ metaVal = prop.getValue();
+ assertTrue(metaVal instanceof SimpleValue);
+ val = ((SimpleValue) metaVal).getValue();
+ assertEquals(Boolean.TRUE, val);
+
+ prop = mc.getProperty("state");
+ assertNotNull("ChannelFactory has property state", prop);
+
+ // FIXME ProfileService messes with this prop -- figure out how to validate
+// metaVal = prop.getValue();
+// assertNotNull(metaVal);
+// assertTrue(metaVal instanceof SimpleValue);
+// val = ((SimpleValue) metaVal).getValue();
+// assertEquals(ServiceMBean.states[ServiceMBean.STARTED], val);
+
+ prop = mc.getProperty("protocolStackConfigurations");
+ assertNotNull("ChannelFactory has property protocolStackConfigurations", prop);
+ metaVal = prop.getValue();
+ ManagedObjectTestUtil.validateProtocolStackConfigurations(metaVal, new String[]{"udp", "tcp"});
+
+ prop = mc.getProperty("openChannels");
+ assertNotNull("ChannelFactory has property openChannels", prop);
+ try
+ {
+ metaVal = prop.getValue();
+ }
+ catch (UndeclaredThrowableException ute)
+ {
+ log.error("Undeclared throwable: ", ute.getUndeclaredThrowable());
+ }
+ ManagedObjectTestUtil.validateOpenChannels(metaVal);
+ }
+
+ public void testUpdateProtocolStackConfigurations() throws Exception
+ {
+ ManagedComponent component = getChannelFactoryManagedComponent();
+ ManagedProperty prop = component.getProperty("protocolStackConfigurations");
+ MetaValue mapValue = prop.getValue();
+ assertTrue(mapValue instanceof CompositeValue);
+ MetaValue stackValue = ((CompositeValue) mapValue).get("udp-async");
+ assertTrue(stackValue instanceof CompositeValue);
+ MetaValue configurationValue = ((CompositeValue) stackValue).get("configuration");
+ assertTrue(configurationValue instanceof CollectionValue);
+ MetaValue[] protocols = ((CollectionValue) configurationValue).getElements();
+ MetaValue udp = protocols[0];
+ assertTrue(udp instanceof CompositeValue);
+ MetaValue parametersValue = ((CompositeValue) udp).get("protocolParameters");
+ assertTrue(parametersValue instanceof CollectionValue);
+ MetaValue[] params = ((CollectionValue) parametersValue).getElements();
+ boolean updated = false;
+ int maxThreads = -1;
+ for (int i = 0; i < params.length; i++)
+ {
+ CompositeValue param = (CompositeValue) params[i];
+ String name = (String) ((SimpleValue) param.get("name")).getValue();
+ if ("oob_thread_pool.max_threads".equals(name))
+ {
+ String value = (String) ((SimpleValue) param.get("value")).getValue();
+ maxThreads = Integer.parseInt(value);
+ MapCompositeValueSupport newVal = cloneCompositeValue(param);
+ newVal.put("value", SimpleValueSupport.wrap(String.valueOf(maxThreads + 1)));
+ params[i] = newVal;
+ updated = true;
+ break;
+ }
+ }
+ assertTrue("updated max_threads config", updated);
+
+ CollectionValue newParametersValue = new CollectionValueSupport(((CollectionValue) parametersValue).getMetaType(), params);
+ MapCompositeValueSupport newUdp = cloneCompositeValue((CompositeValue) udp);
+ newUdp.put("protocolParameters", newParametersValue);
+ protocols[0] = newUdp;
+ CollectionValue newConfigurationValue =
+ new CollectionValueSupport(((CollectionValue) configurationValue).getMetaType(), protocols);
+ MapCompositeValueSupport updatedStack = cloneCompositeValue((CompositeValue) stackValue);
+ updatedStack.put("configuration", newConfigurationValue);
+ MapCompositeValueSupport newMapValue = cloneCompositeValue((CompositeValue) mapValue);
+ newMapValue.put("udp-async", updatedStack);
+
+ // Add a stack
+ MapCompositeValueSupport newStack = cloneCompositeValue((CompositeValue) stackValue);
+ newStack.put("name", SimpleValueSupport.wrap("new-stack"));
+ newMapValue.put("new-stack", newStack);
+
+ // Remove a stack
+ newMapValue.remove("tcp-async");
+
+ // Store the updates
+ prop.setValue(newMapValue);
+ getManagementView().updateComponent(component);
+
+ // Re-read the component and validate the changes took
+
+ component = getChannelFactoryManagedComponent();
+ prop = component.getProperty("protocolStackConfigurations");
+ mapValue = prop.getValue();
+ assertTrue(mapValue instanceof CompositeValue);
+ stackValue = ((CompositeValue) mapValue).get("udp-async");
+ assertTrue(stackValue instanceof CompositeValue);
+ configurationValue = ((CompositeValue) stackValue).get("configuration");
+ assertTrue(configurationValue instanceof CollectionValue);
+ protocols = ((CollectionValue) configurationValue).getElements();
+ udp = protocols[0];
+ assertTrue(udp instanceof CompositeValue);
+ parametersValue = ((CompositeValue) udp).get("protocolParameters");
+ assertTrue(parametersValue instanceof CollectionValue);
+ params = ((CollectionValue) parametersValue).getElements();
+ for (int i = 0; i < params.length; i++)
+ {
+ CompositeValue param = (CompositeValue) params[i];
+ String name = (String) ((SimpleValue) param.get("name")).getValue();
+ if ("oob_thread_pool.max_threads".equals(name))
+ {
+ String value = (String) ((SimpleValue) param.get("value")).getValue();
+ assertEquals(String.valueOf(maxThreads + 1), value);
+ break;
+ }
+ }
+
+ assertTrue(((CompositeValue) mapValue).containsKey("new-stack"));
+ assertFalse(((CompositeValue) mapValue).containsKey("tcp-async"));
+ }
+
+ private ManagedComponent getChannelFactoryManagedComponent() throws Exception
+ {
+ ManagementView mgtView = getManagementView();
+ ComponentType type = new ComponentType("MCBean", "JGroupsChannelFactory");
+ ManagedComponent mc = mgtView.getComponent("JChannelFactory", type);
+ return mc;
+ }
+
+ /**
+ * Obtain the ProfileService.ManagementView
+ * @return
+ * @throws Exception
+ */
+ protected ManagementView getManagementView()
+ throws Exception
+ {
+ if( activeView == null )
+ {
+ String[] urls = getNamingURLs();
+ Properties env = new Properties();
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ "org.jnp.interfaces.NamingContextFactory");
+ env.setProperty(Context.PROVIDER_URL, urls[0]);
+ Context ctx = new InitialContext(env);
+
+ ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+ activeView = ps.getViewManager();
+ // Init the VFS to setup the vfs* protocol handlers
+ VFS.init();
+ }
+ activeView.load();
+ return activeView;
+ }
+
+ private static MapCompositeValueSupport cloneCompositeValue(CompositeValue toClone)
+ {
+ if (toClone instanceof MapCompositeValueSupport)
+ {
+ return (MapCompositeValueSupport) toClone.clone();
+ }
+ else
+ {
+ CompositeMetaType type = toClone.getMetaType();
+ Map<String, MetaValue> map = new HashMap<String, MetaValue>();
+ for (String key : type.keySet())
+ {
+ map.put(key, toClone.get(key));
+ }
+ return new MapCompositeValueSupport(map, type);
+ }
+ }
+
+}
Copied: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryOverrideUnitTestCase.java (from rev 90480, trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryOverrideUnitTestCase.java)
===================================================================
--- branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryOverrideUnitTestCase.java (rev 0)
+++ branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryOverrideUnitTestCase.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -0,0 +1,231 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.cluster.defaultcfg.test;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.jboss.ha.framework.server.JChannelFactory;
+import org.jboss.ha.framework.server.ProtocolStackConfigInfo;
+import org.jboss.ha.framework.server.managed.ProtocolDataProtocolStackConfigurator;
+import org.jboss.logging.Logger;
+import org.jgroups.Channel;
+import org.jgroups.JChannel;
+import org.jgroups.conf.ProtocolData;
+import org.jgroups.conf.ProtocolParameter;
+
+/**
+ * Tests JChannelFactory's handling of configuration overrides via
+ * @[link {@link JChannelFactory#setProtocolStackConfigurations(java.util.Map)}}
+ *
+ * @author Brian Stansberry
+ */
+public class JChannelFactoryOverrideUnitTestCase extends TestCase
+{
+ private static final Logger log = Logger.getLogger(JChannelFactoryOverrideUnitTestCase.class);
+
+ private JChannelFactory factory;
+ private Channel channel1;
+ private Channel channel2;
+ private String jgroups_bind_addr;
+
+ /**
+ * Create a new JChannelFactoryUnitTestCase.
+ *
+ * @param name
+ */
+ public JChannelFactoryOverrideUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ jgroups_bind_addr = System.getProperty("jgroups.bind_addr");
+ if (jgroups_bind_addr == null)
+ {
+ System.setProperty("jbosstest.cluster.node0", System.getProperty("jbosstest.cluster.node0", "localhost"));
+ }
+
+ factory = new JChannelFactory();
+ factory.setAssignLogicalAddresses(false);
+ factory.setNodeAddress(InetAddress.getByName("localhost"));
+ factory.setNamingServicePort(123);
+ factory.setExposeChannels(false);
+ factory.setManageReleasedThreadClassLoader(true);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ if (jgroups_bind_addr == null)
+ System.clearProperty("jgroups.bind_addr");
+
+ if (channel1 != null && channel1.isOpen())
+ channel1.close();
+
+ if (channel2 != null && channel2.isOpen())
+ channel2.close();
+
+ if (factory != null)
+ {
+ factory.stop();
+ factory.destroy();
+ }
+ }
+
+ public void testOverrideAfterStart() throws Exception
+ {
+ overrideTest(true);
+ }
+
+ public void testOverrideBeforeStart() throws Exception
+ {
+ overrideTest(false);
+ }
+
+ private void overrideTest(boolean startBeforeOverride) throws Exception
+ {
+ factory.setMultiplexerConfig("cluster/channelfactory/stacks.xml");
+ if (startBeforeOverride)
+ {
+ factory.create();
+ factory.start();
+ }
+
+ Map<String, ProtocolStackConfigInfo> origMap = factory.getProtocolStackConfigurations();
+ Set<String> origKeys = new HashSet<String>(origMap.keySet());
+ ProtocolStackConfigInfo unshared1 = origMap.get("unshared1");
+ assertNotNull(unshared1);
+ ProtocolData[] origConfig = unshared1.getConfiguration();
+ assertNotNull(origConfig);
+ // Copy it off so we know it's unchanged for later assertion comparisons
+ origConfig = origConfig.clone();
+ ProtocolData origTransport = origConfig[0];
+ assertNotNull(origTransport);
+ ProtocolParameter[] origParams = origTransport.getParametersAsArray();
+ ProtocolParameter[] newParams = origParams.clone();
+ ProtocolData newTransport = new ProtocolData(origTransport.getProtocolName(), origTransport.getDescription(), origTransport.getClassName(), newParams);
+ ProtocolParameter overrideParam = new ProtocolParameter("max_bundle_size", "50000");
+ newTransport.override(new ProtocolParameter[]{overrideParam});
+ ProtocolData[] newConfig = origConfig.clone();
+ newConfig[0] = newTransport;
+
+ ProtocolStackConfigInfo updated = new ProtocolStackConfigInfo(unshared1.getName(), unshared1.getDescription(), new ProtocolDataProtocolStackConfigurator(newConfig));
+
+ Map<String, ProtocolStackConfigInfo> newMap = new HashMap<String, ProtocolStackConfigInfo>(origMap);
+ newMap.put("unshared1", updated);
+
+ ProtocolData[] addedConfig = origConfig.clone();
+ ProtocolStackConfigInfo added = new ProtocolStackConfigInfo("added", "added", new ProtocolDataProtocolStackConfigurator(addedConfig));
+ newMap.put("added", added);
+
+ assertTrue(newMap.containsKey("shared2"));
+ newMap.remove("shared2");
+
+ factory.setProtocolStackConfigurations(newMap);
+
+ if (startBeforeOverride == false)
+ {
+ factory.create();
+ factory.start();
+ }
+
+ Map<String, ProtocolStackConfigInfo> reread = factory.getProtocolStackConfigurations();
+ origKeys.remove("shared2");
+ origKeys.add("added");
+ assertEquals(origKeys, reread.keySet());
+
+ ProtocolStackConfigInfo addedInfo = reread.get("added");
+ assertEquals("added", addedInfo.getName());
+ assertEquals("added", addedInfo.getDescription());
+ ProtocolData[] readAdded = addedInfo.getConfiguration();
+ assertEquals(addedConfig.length, readAdded.length);
+ for (int i = 0; i < readAdded.length; i++)
+ {
+ assertEquals(addedConfig[i], readAdded[i]);
+ ProtocolParameter[] inputParams = addedConfig[i].getParametersAsArray();
+ ProtocolParameter[] outputParams = readAdded[i].getParametersAsArray();
+ assertEquals(inputParams.length, outputParams.length);
+ @SuppressWarnings("unchecked")
+ Map<String, ProtocolParameter> paramMap = readAdded[i].getParameters();
+ for (int j = 0; j < inputParams.length; j++)
+ {
+ ProtocolParameter param = paramMap.get(inputParams[j].getName());
+ assertNotNull(param);
+ assertEquals(inputParams[j].getValue(), param.getValue());
+ }
+ }
+
+ ProtocolStackConfigInfo updatedInfo = reread.get("unshared1");
+ assertEquals("unshared1", updatedInfo.getName());
+ ProtocolData[] readUpdated = updatedInfo.getConfiguration();
+ assertEquals(origConfig.length, readUpdated.length);
+ for (int i = 0; i < readUpdated.length; i++)
+ {
+ assertEquals(origConfig[i], readUpdated[i]);
+ ProtocolParameter[] inputParams = origConfig[i].getParametersAsArray();
+ ProtocolParameter[] outputParams = readUpdated[i].getParametersAsArray();
+ assertEquals(inputParams.length, outputParams.length);
+ @SuppressWarnings("unchecked")
+ Map<String, ProtocolParameter> paramMap = readUpdated[i].getParameters();
+ for (int j = 0; j < inputParams.length; j++)
+ {
+ String name = inputParams[j].getName();
+ ProtocolParameter param = paramMap.get(name);
+ assertNotNull(param);
+ if ("max_bundle_size".equals(name))
+ {
+ assertEquals("50000", param.getValue());
+ }
+ else
+ {
+ assertEquals(inputParams[j].getValue(), param.getValue());
+ }
+ }
+ }
+
+ // Validate that the overrides actuall affect created channels
+ channel1 = factory.createChannel("unshared1");
+ assertEquals("50000", ((JChannel) channel1).getProtocolStack().findProtocol("UDP").getProperties().get("max_bundle_size"));
+ channel2 = factory.createChannel("added");
+ assertEquals("64000", ((JChannel) channel2).getProtocolStack().findProtocol("UDP").getProperties().get("max_bundle_size"));
+ try
+ {
+ factory.createChannel("shared2");
+ fail("should not be able to create a channel for 'shared2'");
+ }
+ catch (IllegalArgumentException good) {}
+
+ }
+
+
+}
Modified: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryUnitTestCase.java
===================================================================
--- branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryUnitTestCase.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/JChannelFactoryUnitTestCase.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -73,7 +73,7 @@
{
super.setUp();
- String jgroups_bind_addr = System.getProperty("jgroups.bind_addr");
+ jgroups_bind_addr = System.getProperty("jgroups.bind_addr");
if (jgroups_bind_addr == null)
{
System.setProperty("jbosstest.cluster.node0", System.getProperty("jbosstest.cluster.node0", "localhost"));
Copied: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/OpenChannelsMapperUnitTestCase.java (from rev 90480, trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/OpenChannelsMapperUnitTestCase.java)
===================================================================
--- branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/OpenChannelsMapperUnitTestCase.java (rev 0)
+++ branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/OpenChannelsMapperUnitTestCase.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.cluster.defaultcfg.test;
+
+import java.net.InetAddress;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.ha.framework.server.ChannelInfo;
+import org.jboss.ha.framework.server.JChannelFactory;
+import org.jboss.ha.framework.server.managed.OpenChannelsMapper;
+import org.jboss.logging.Logger;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.test.cluster.channelfactory.managed.ManagedObjectTestUtil;
+import org.jboss.test.cluster.channelfactory.managed.ManagedObjectTestUtil.ChannelIds;
+import org.jgroups.Channel;
+
+/**
+ * Unit tests for OpenChannelsMapper
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: $
+ */
+public class OpenChannelsMapperUnitTestCase extends TestCase
+{
+
+ private static final Logger log = Logger.getLogger(OpenChannelsMapperUnitTestCase.class);
+
+ private JChannelFactory factory;
+ private Channel channel1;
+ private Channel channel2;
+ private Channel channel3;
+ private Channel channel4;
+ private String jgroups_bind_addr;
+ private MBeanServer mbeanServer;
+
+ /**
+ * Create a new ProtocolStackConfigurationsMapperUnitTestCase.
+ *
+ * @param name
+ */
+ public OpenChannelsMapperUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ String jgroups_bind_addr = System.getProperty("jgroups.bind_addr");
+ if (jgroups_bind_addr == null)
+ {
+ System.setProperty("jbosstest.cluster.node0", System.getProperty("jbosstest.cluster.node0", "localhost"));
+ }
+
+ mbeanServer = MBeanServerFactory.createMBeanServer("jchannelfactorytest");
+
+ factory = new JChannelFactory();
+ factory.setMultiplexerConfig("cluster/channelfactory/stacks.xml");
+ factory.setAssignLogicalAddresses(false);
+ factory.setNodeAddress(InetAddress.getByName("localhost"));
+ factory.setNamingServicePort(123);
+ factory.setExposeChannels(true);
+ factory.setServer(mbeanServer);
+ factory.setManageReleasedThreadClassLoader(true);
+ factory.create();
+ factory.start();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ if (mbeanServer != null)
+ MBeanServerFactory.releaseMBeanServer(mbeanServer);
+
+ if (jgroups_bind_addr == null)
+ System.clearProperty("jgroups.bind_addr");
+
+ if (channel1 != null && channel1.isOpen())
+ channel1.close();
+
+ if (channel2 != null && channel2.isOpen())
+ channel2.close();
+
+ if (channel3 != null && channel3.isOpen())
+ channel3.close();
+
+ if (channel4 != null && channel4.isOpen())
+ channel4.close();
+
+ if (factory != null)
+ {
+ factory.stop();
+ factory.destroy();
+ }
+ }
+
+ public void testCreateMetaValue() throws Exception
+ {
+ channel1 = factory.createMultiplexerChannel("unshared1", "no1");
+ channel1.connect("channel1");
+ channel2 = factory.createMultiplexerChannel("shared1", "no2");
+ channel2.connect("channel2");
+
+ Set<ChannelInfo> channels = factory.getOpenChannels();
+ OpenChannelsMapper testee = new OpenChannelsMapper();
+ MetaValue val = testee.createMetaValue(testee.getMetaType(), channels);
+ Set<ChannelIds> ids = ManagedObjectTestUtil.validateOpenChannels(val);
+
+ for (ChannelIds cid : ids)
+ {
+ if ("no1".equals(cid.id))
+ {
+ assertEquals("unshared1", cid.stackName);
+ assertEquals("channel1", cid.clusterName);
+ }
+ else if ("no2".equals(cid.id))
+ {
+ assertEquals("shared1", cid.stackName);
+ assertEquals("channel2", cid.clusterName);
+ }
+ else
+ {
+ fail("unknown id " + cid.id);
+ }
+ }
+ }
+}
Copied: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ProtocolStackConfigurationsMapperUnitTestCase.java (from rev 90480, trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ProtocolStackConfigurationsMapperUnitTestCase.java)
===================================================================
--- branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ProtocolStackConfigurationsMapperUnitTestCase.java (rev 0)
+++ branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/ProtocolStackConfigurationsMapperUnitTestCase.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.cluster.defaultcfg.test;
+
+import java.net.InetAddress;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
+import junit.framework.TestCase;
+
+import org.jboss.ha.framework.server.JChannelFactory;
+import org.jboss.ha.framework.server.ProtocolStackConfigInfo;
+import org.jboss.ha.framework.server.managed.ProtocolStackConfigurationsMapper;
+import org.jboss.logging.Logger;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.test.cluster.channelfactory.managed.ManagedObjectTestUtil;
+import org.jgroups.Channel;
+
+/**
+ * Unit tests for ProtocolStackConfigurationsMapper
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: $
+ */
+public class ProtocolStackConfigurationsMapperUnitTestCase extends TestCase
+{
+
+ private static final Logger log = Logger.getLogger(ProtocolStackConfigurationsMapper.class);
+
+ private JChannelFactory factory;
+ private String jgroups_bind_addr;
+ private MBeanServer mbeanServer;
+
+ /**
+ * Create a new ProtocolStackConfigurationsMapperUnitTestCase.
+ *
+ * @param name
+ */
+ public ProtocolStackConfigurationsMapperUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ String jgroups_bind_addr = System.getProperty("jgroups.bind_addr");
+ if (jgroups_bind_addr == null)
+ {
+ System.setProperty("jbosstest.cluster.node0", System.getProperty("jbosstest.cluster.node0", "localhost"));
+ }
+
+ mbeanServer = MBeanServerFactory.createMBeanServer("jchannelfactorytest");
+
+ factory = new JChannelFactory();
+ factory.setMultiplexerConfig("cluster/channelfactory/stacks.xml");
+ factory.setAssignLogicalAddresses(false);
+ factory.setNodeAddress(InetAddress.getByName("localhost"));
+ factory.setNamingServicePort(123);
+ factory.setExposeChannels(true);
+ factory.setServer(mbeanServer);
+ factory.setManageReleasedThreadClassLoader(true);
+ factory.create();
+ factory.start();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ if (mbeanServer != null)
+ MBeanServerFactory.releaseMBeanServer(mbeanServer);
+
+ if (jgroups_bind_addr == null)
+ System.clearProperty("jgroups.bind_addr");
+
+ if (factory != null)
+ {
+ factory.stop();
+ factory.destroy();
+ }
+ }
+
+ public void testRoundTrip() throws Exception
+ {
+ Map<String, ProtocolStackConfigInfo> map = factory.getProtocolStackConfigurations();
+
+ ProtocolStackConfigurationsMapper testee = new ProtocolStackConfigurationsMapper();
+
+ MetaValue metaValue = testee.createMetaValue(ProtocolStackConfigurationsMapper.TYPE, map);
+ ManagedObjectTestUtil.validateProtocolStackConfigurations(metaValue, new String[]{"unshared1", "shared1"});
+
+ Map<String, ProtocolStackConfigInfo> restored = testee.unwrapMetaValue(metaValue);
+ assertEquals(map.keySet(), restored.keySet());
+
+ // FIXME go deeper
+ }
+
+}
Modified: branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2009-06-19 20:06:22 UTC (rev 90480)
+++ branches/dml-log-service-integration/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2009-06-19 20:18:44 UTC (rev 90481)
@@ -694,6 +694,7 @@
propValues.put("xa-datasource-class", SimpleValueSupport.wrap("org.hsqldb.jdbcDriver"));
propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
+ propValues.put("interleaving", SimpleValueSupport.wrap(true));
HashMap<String, String> xaPropValues = new HashMap<String, String>();
xaPropValues.put("URL", "jdbc:hsqldb");
@@ -739,6 +740,7 @@
propValues.put("config-property", metaValue);
propValues.put("xa-transaction", SimpleValueSupport.wrap(Boolean.FALSE));
+ propValues.put("interleaving", SimpleValueSupport.wrap(Boolean.TRUE));
propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
// todo: how to set the specific domain?
@@ -747,6 +749,16 @@
createComponentTest("TxConnectionFactoryTemplate", propValues, "testTxCf",
new ComponentType("ConnectionFactory", "Tx"), jndiName);
+ // Query the interleaving
+ ManagementView mgtView = getManagementView();
+ ComponentType type = new ComponentType("ConnectionFactory", "Tx");
+ ManagedComponent txcf = mgtView.getComponent(jndiName, type);
+ assertNotNull(txcf);
+ ManagedProperty interleaving = txcf.getProperty("interleaving");
+ assertNotNull("interleaving", interleaving);
+ MetaValue interleavingMV = interleaving.getValue();
+ assertNotNull("interleaving.value", interleavingMV);
+
}
/**
@@ -781,6 +793,7 @@
propValues.put("xa-transaction", SimpleValueSupport.wrap(Boolean.TRUE));
propValues.put("xa-resource-timeout", SimpleValueSupport.wrap(new Integer(256)));
+ propValues.put("interleaving", SimpleValueSupport.wrap(Boolean.TRUE));
// todo: how to set the specific domain?
//ApplicationManagedSecurityMetaData secDomain = new ApplicationManagedSecurityMetaData();
@@ -788,6 +801,16 @@
createComponentTest("TxConnectionFactoryTemplate", propValues, "testTxXACf",
new ComponentType("ConnectionFactory", "Tx"), jndiName);
+ // Query the interleaving
+ ManagementView mgtView = getManagementView();
+ ComponentType type = new ComponentType("ConnectionFactory", "Tx");
+ ManagedComponent txcf = mgtView.getComponent(jndiName, type);
+ assertNotNull(txcf);
+ ManagedProperty interleaving = txcf.getProperty("interleaving");
+ assertNotNull("interleaving", interleaving);
+ MetaValue interleavingMV = interleaving.getValue();
+ assertNotNull("interleaving.value", interleavingMV);
+ assertEquals(SimpleValueSupport.wrap(Boolean.TRUE), interleavingMV);
}
/**
@@ -837,7 +860,6 @@
MetaValue metaValue = this.compositeValueMap(xaProps);
propValues.put("config-property", metaValue);
- propValues.put("track-connection-by-tx", SimpleValueSupport.wrap(Boolean.TRUE));
propValues.put("config-property",
new MapCompositeValueSupport(new HashMap<String, MetaValue>(),
new MapCompositeMetaType(SimpleMetaType.STRING)));
@@ -970,7 +992,6 @@
propValues.put("no-tx-separate-pools", SimpleValueSupport.wrap(Boolean.TRUE));
propValues.put("statistics-formatter", SimpleValueSupport.wrap("org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter"));
propValues.put("isSameRM-override-value", SimpleValueSupport.wrap(Boolean.FALSE));
- propValues.put("track-connection-by-tx", SimpleValueSupport.wrap(Boolean.TRUE));
propValues.put("type-mapping", SimpleValueSupport.wrap("Hypersonic SQL"));
// todo: config-property
// todo: security-domain
@@ -1019,8 +1040,8 @@
for(String propName : propValues.keySet())
{
ManagedProperty prop = dsMC.getProperty(propName);
- log.debug("Checking: "+prop);
- assertNotNull(prop);
+ log.debug("Checking: "+propName);
+ assertNotNull(propName, prop);
Object propValue = prop.getValue();
Object expectedValue = propValues.get(propName);
if(propValue instanceof MetaValue)
More information about the jboss-cvs-commits
mailing list