use of com.sun.jmx.mbeanserver.MXBeanMappingFactory in project spf4j by zolyfarkas.
the class Spf4jJMXBeanMapping method defaultHandler.
@SuppressFBWarnings("LEST_LOST_EXCEPTION_STACK_TRACE")
public static JMXBeanMapping defaultHandler(final Type javaType, final JMXBeanMappingSupplier mappings) throws NotSerializableException {
// falling back to MXBeanMappingFactory.DEFAULT
try {
MXBeanMapping mapping = MXBeanMappingFactory.DEFAULT.mappingForType(javaType, new MXBeanMappingFactory() {
@Override
public MXBeanMapping mappingForType(final Type t, final MXBeanMappingFactory f) throws OpenDataException {
JMXBeanMapping m;
try {
m = mappings.get(t);
} catch (NotSerializableException ex) {
OpenDataException tex = new OpenDataException(t + " is not seriablizable ");
tex.initCause(ex);
throw tex;
}
if (m != null) {
return MXBeanMappings.convert(m);
}
return MXBeanMappingFactory.DEFAULT.mappingForType(t, f);
}
});
return MXBeanMappings.convert(mapping);
} catch (OpenDataException ex) {
NotSerializableException nsex = Throwables.first(ex, NotSerializableException.class);
if (nsex != null) {
throw nsex;
} else {
throw new IllegalArgumentException("No type mapping for " + javaType, ex);
}
}
}
use of com.sun.jmx.mbeanserver.MXBeanMappingFactory in project spf4j by zolyfarkas.
the class DefaultMXBeanMappingFactoryOpenTypeMapper method getMXBeanMappingInternal.
/**
* returns MXBeanMapping or null if type is not mappable to a OpenType.
*/
@Nullable
private synchronized JMXBeanMapping getMXBeanMappingInternal(final Type type) throws NotSerializableException {
try {
MXBeanMapping mapping = MXBeanMappingFactory.DEFAULT.mappingForType(type, new MXBeanMappingFactory() {
@Override
public MXBeanMapping mappingForType(final Type t, final MXBeanMappingFactory f) throws OpenDataException {
try {
return MXBeanMappings.convert(appenderMap.get(t).get(t));
} catch (NotSerializableException ex) {
OpenDataException tex = new OpenDataException(t + " is not serializable");
tex.initCause(ex);
throw tex;
}
}
});
return MXBeanMappings.convert(mapping);
} catch (OpenDataException ex) {
return null;
}
}
Aggregations