Expand logging.

This commit is contained in:
Ben Alex 2004-11-15 01:41:45 +00:00
parent 9972c69408
commit d639e5c02f
2 changed files with 48 additions and 4 deletions

View File

@ -78,12 +78,13 @@ public class AclProviderManager implements AclManager, InitializingBean {
return null; return null;
} }
public AclEntry[] getAcls(Object domainInstance, public AclEntry[] getAcls(Object domainInstance,
Authentication authentication) { Authentication authentication) {
if (domainInstance == null) { if (domainInstance == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"domainInstance is null - violating interface contract"); "domainInstance is null - violating interface contract");
} }
if (authentication == null) { if (authentication == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"authentication is null - violating interface contract"); "authentication is null - violating interface contract");
@ -101,6 +102,11 @@ public class AclProviderManager implements AclManager, InitializingBean {
} }
return provider.getAcls(domainInstance, authentication); return provider.getAcls(domainInstance, authentication);
} else {
if (logger.isDebugEnabled()) {
logger.debug("Provider " + provider.toString()
+ " does not support " + domainInstance);
}
} }
} }
@ -110,8 +116,8 @@ public class AclProviderManager implements AclManager, InitializingBean {
} }
return null; return null;
} }
/** /**
* Sets the {@link AclProvider} objects to be used for ACL determinations. * Sets the {@link AclProvider} objects to be used for ACL determinations.
* *

View File

@ -299,18 +299,36 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
*/ */
public boolean supports(Object domainInstance) { public boolean supports(Object domainInstance) {
if (domainInstance == null) { if (domainInstance == null) {
if (logger.isDebugEnabled()) {
logger.debug("domainInstance is null");
}
return false; return false;
} }
if ((restrictSupportToClass != null) if ((restrictSupportToClass != null)
&& !restrictSupportToClass.isAssignableFrom( && !restrictSupportToClass.isAssignableFrom(
domainInstance.getClass())) { domainInstance.getClass())) {
if (logger.isDebugEnabled()) {
logger.debug("domainInstance not instance of "
+ restrictSupportToClass);
}
return false; return false;
} }
if (obtainIdentity(domainInstance) == null) { if (obtainIdentity(domainInstance) == null) {
if (logger.isDebugEnabled()) {
logger.debug("obtainIdentity returned null");
}
return false; return false;
} else { } else {
if (logger.isDebugEnabled()) {
logger.debug("obtainIdentity returned "
+ obtainIdentity(domainInstance));
}
return true; return true;
} }
} }
@ -338,6 +356,11 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
if (domainInstance instanceof AclObjectIdentityAware) { if (domainInstance instanceof AclObjectIdentityAware) {
AclObjectIdentityAware aclObjectIdentityAware = (AclObjectIdentityAware) domainInstance; AclObjectIdentityAware aclObjectIdentityAware = (AclObjectIdentityAware) domainInstance;
if (logger.isDebugEnabled()) {
logger.debug("domainInstance: " + domainInstance
+ " cast to AclObjectIdentityAware");
}
return aclObjectIdentityAware.getAclObjectIdentity(); return aclObjectIdentityAware.getAclObjectIdentity();
} }
@ -345,8 +368,23 @@ public class BasicAclProvider implements AclProvider, InitializingBean {
Constructor constructor = defaultAclObjectIdentityClass Constructor constructor = defaultAclObjectIdentityClass
.getConstructor(new Class[] {Object.class}); .getConstructor(new Class[] {Object.class});
if (logger.isDebugEnabled()) {
logger.debug("domainInstance: " + domainInstance
+ " attempting to pass to constructor: " + constructor);
}
return (AclObjectIdentity) constructor.newInstance(new Object[] {domainInstance}); return (AclObjectIdentity) constructor.newInstance(new Object[] {domainInstance});
} catch (Exception ex) { } catch (Exception ex) {
if (logger.isDebugEnabled()) {
logger.debug("Error attempting construction of "
+ defaultAclObjectIdentityClass + ": " + ex.getMessage(), ex);
if (ex.getCause() != null) {
logger.debug("Cause: " + ex.getCause().getMessage(),
ex.getCause());
}
}
return null; return null;
} }
} }