/* run method from operations descriptor */
if (attrSetMethod == null) {
if (attrValue != null) {
try {
final Class<?> clazz = loadClass(attrType);
if (! clazz.isInstance(attrValue)) throw new
InvalidAttributeValueException(clazz.getName() +
" expected, " +
attrValue.getClass().getName() +
" received.");
} catch (ClassNotFoundException x) {
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
"setAttribute(Attribute)","Class " +
attrType + " for attribute "
+ attrName + " not found: ", x);
}
}
}
updateDescriptor = true;
} else {
invoke(attrSetMethod,
(new Object[] {attrValue}),
(new String[] {attrType}) );
}
/* change cached value */
Object objctl = attrDescr.getFieldValue("currencyTimeLimit");
String ctl;
if (objctl != null) ctl = objctl.toString();
else ctl = null;
if ((ctl == null) && (mmbDesc != null)) {
objctl = mmbDesc.getFieldValue("currencyTimeLimit");
if (objctl != null) ctl = objctl.toString();
else ctl = null;
}
final boolean updateCache = ((ctl != null) && !(ctl.equals("-1")));
if(attrSetMethod == null && !updateCache && attrGetMethod != null)
throw new MBeanException(new ServiceNotFoundException("No " +
"setMethod field is defined in the descriptor for " +
attrName + " attribute and caching is not enabled " +
"for it"));
if (updateCache || updateDescriptor) {
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
"setAttribute(Attribute)",
"setting cached value of " +
attrName + " to " + attrValue);
}
attrDescr.setField("value", attrValue);
if (updateCache) {
final String currtime = String.valueOf(
(new Date()).getTime());
attrDescr.setField("lastUpdatedTimeStamp", currtime);
}
attrInfo.setDescriptor(attrDescr);
modelMBeanInfo.setDescriptor(attrDescr,"attribute");
if (tracing) {
final StringBuilder strb = new StringBuilder()
.append("new descriptor is ").append(attrDescr)
.append(". AttributeInfo descriptor is ")
.append(attrInfo.getDescriptor())
.append(". AttributeInfo descriptor is ")
.append(modelMBeanInfo.getDescriptor(attrName,"attribute"));
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
"setAttribute(Attribute)",strb.toString());
}
}
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
"setAttribute(Attribute)","sending sendAttributeNotification");
}
sendAttributeChangeNotification(oldAttr,attribute);
} else { // if descriptor ... else no descriptor
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
"setAttribute(Attribute)","setMethod failed "+attrName+
" not in attributeDescriptor\n");
}
throw new InvalidAttributeValueException(
"Unable to resolve attribute value, "+
"no defined in descriptor for attribute");
} // else no descriptor
if (tracing) {