+ public boolean canReuseDependency(ObjectName objectName, JmxAttribute jmxAttribute) {
+ Preconditions.checkNotNull(objectName);
+ Preconditions.checkNotNull(jmxAttribute);
+
+ Module currentModule = resolveModuleInstance(objectName, jmxAttribute);
+ ModuleIdentifier identifier = currentModule.getIdentifier();
+ ModuleInternalTransactionalInfo moduleInternalTransactionalInfo = modulesHolder.findModuleInternalTransactionalInfo(identifier);
+
+ if(moduleInternalTransactionalInfo.hasOldModule()) {
+ Module oldModule = moduleInternalTransactionalInfo.getOldInternalInfo().getReadableModule().getModule();
+ return currentModule.canReuse(oldModule);
+ }
+ return false;
+ }
+
+ @Override
+ public <T extends BaseIdentity> Class<? extends T> resolveIdentity(IdentityAttributeRef identityRef, Class<T> expectedBaseClass) {
+ final QName qName = QName.create(identityRef.getqNameOfIdentity());
+ Class<?> deserialized = bindingContextProvider.getBindingContext().getIdentityClass(qName);
+ if (deserialized == null) {
+ throw new IllegalStateException("Unable to retrieve identity class for " + qName + ", null response from "
+ + bindingContextProvider.getBindingContext());
+ }
+ if (expectedBaseClass.isAssignableFrom(deserialized)) {
+ return (Class<T>) deserialized;
+ } else {
+ LOG.error("Cannot resolve class of identity {} : deserialized class {} is not a subclass of {}.",
+ identityRef, deserialized, expectedBaseClass);
+ throw new IllegalArgumentException("Deserialized identity " + deserialized + " cannot be cast to " + expectedBaseClass);
+ }
+ }
+
+ @Override
+ public <T extends BaseIdentity> void validateIdentity(IdentityAttributeRef identityRef, Class<T> expectedBaseClass, JmxAttribute jmxAttribute) {
+ try {
+ resolveIdentity(identityRef, expectedBaseClass);
+ } catch (Exception e) {
+ throw JmxAttributeValidationException.wrap(e, jmxAttribute);
+ }