throw new AttributeNotFoundException(
"getAttribute failed: ModelMBeanInfo not found for "+
attrName);
ModelMBeanAttributeInfo attrInfo = modelMBeanInfo.getAttribute(attrName);
Descriptor mmbDesc = modelMBeanInfo.getMBeanDescriptor();
if (attrInfo == null)
throw new AttributeNotFoundException("getAttribute failed:"+
" ModelMBeanAttributeInfo not found for " + attrName);
Descriptor attrDescr = attrInfo.getDescriptor();
if (attrDescr != null) {
if (!attrInfo.isReadable())
throw new AttributeNotFoundException(
"getAttribute failed: " + attrName +
" is not readable ");
response = resolveForCacheValue(attrDescr);
/* return current cached value */
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(), mth,
"*** cached value is " + response);
}
if (response == null) {
/* no cached value, run getMethod */
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(), mth,
"**** cached value is null - getting getMethod");
}
String attrGetMethod =
(String)(attrDescr.getFieldValue("getMethod"));
if (attrGetMethod != null) {
/* run method from operations descriptor */
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
mth, "invoking a getMethod for " + attrName);
}
Object getResponse =
invoke(attrGetMethod, new Object[] {},
new String[] {});
if (getResponse != null) {
// error/validity check return value here
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
mth, "got a non-null response " +
"from getMethod\n");
}
response = getResponse;
// change cached value in attribute descriptor
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;
}
if ((ctl != null) && !(ctl.equals("-1"))) {
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
mth,
"setting cached value and " +
"lastUpdatedTime in descriptor");
}
attrDescr.setField("value", response);
final String stamp = String.valueOf(
(new Date()).getTime());
attrDescr.setField("lastUpdatedTimeStamp",
stamp);
attrInfo.setDescriptor(attrDescr);
modelMBeanInfo.setDescriptor(attrDescr,
"attribute");
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
mth,"new descriptor is " +attrDescr);
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
mth,"AttributeInfo descriptor is " +
attrInfo.getDescriptor());
final String attStr = modelMBeanInfo.
getDescriptor(attrName,"attribute").
toString();
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
mth,
"modelMBeanInfo: AttributeInfo " +
"descriptor is " + attStr);
}
}
} else {
// response was invalid or really returned null
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(), mth,
"got a null response from getMethod\n");
}
response = null;
}
} else {
// not getMethod so return descriptor (default) value
String qualifier="";
response = attrDescr.getFieldValue("value");
if (response == null) {
qualifier="default ";
response = attrDescr.getFieldValue("default");
}
if (tracing) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(), mth,
"could not find getMethod for " +attrName +