+ private Module resolveModuleInstance(ObjectName dependentReadOnlyON,
+ JmxAttribute jmxAttribute) {
+ Preconditions.checkArgument(dependentReadOnlyON != null ,"dependentReadOnlyON");
+ Preconditions.checkArgument(jmxAttribute != null, "jmxAttribute");
+ ObjectName translatedDependentReadOnlyON = translateServiceRefIfPossible(dependentReadOnlyON);
+ transactionStatus.checkCommitStarted();
+ transactionStatus.checkNotCommitted();
+
+ ModuleIdentifier dependentModuleIdentifier = ObjectNameUtil.fromON(
+ translatedDependentReadOnlyON, ObjectNameUtil.TYPE_MODULE);
+
+ return Preconditions.checkNotNull(modulesHolder.findModule(dependentModuleIdentifier, jmxAttribute));
+ }
+
+ @Override
+ 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());
+ IdentityCodec<?> identityCodec = codecRegistry.getIdentityCodec();
+ Class<? extends BaseIdentity> deserialized = identityCodec.deserialize(qName);
+ if (deserialized == null) {
+ throw new IllegalStateException("Unable to retrieve identity class for " + qName + ", null response from "
+ + codecRegistry);
+ }
+ 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);
+ }
+ }
+