* @param attrs the attributes
* @throws Exception for any error
*/
public static void configure(MBeanServer server, ServiceController controller, ObjectName objectName, ClassLoader cl, Collection<ServiceAttributeMetaData> attrs) throws Exception
{
ServiceValueContext valueContext = new ServiceValueContext(server, controller, cl);
server = checkMBeanServer(server, controller);
HashMap<String, MBeanAttributeInfo> attributeMap = getAttributeMap(server, objectName);
for (ServiceAttributeMetaData attribute : attrs)
{
String attributeName = attribute.getName();
if (attributeName == null || attributeName.length() == 0)
throw new RuntimeException("No or empty attribute name for " + objectName);
MBeanAttributeInfo attributeInfo = attributeMap.get(attributeName);
if (attributeInfo == null)
{
throw new RuntimeException("No Attribute found with name: " + attributeName + " for " + objectName
+", attributes: "+attributeMap.keySet());
}
valueContext.setAttributeInfo(attributeInfo);
Object value = null;
ClassLoader previous = SecurityActions.setContextClassLoader(cl);
try
{
value = attribute.getValue(valueContext);