Performance tweaks after profiling HEAD code. Audit interceptor shortcut to avoid calling auditImpl at all when auditing disabled in config.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6700 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-09-07 14:27:17 +00:00
parent a03df08f5e
commit e22575b74e
4 changed files with 76 additions and 63 deletions

View File

@@ -31,6 +31,7 @@ import java.net.UnknownHostException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.alfresco.repo.audit.model.AuditEntry;
import org.alfresco.repo.audit.model.TrueFalseUnset; import org.alfresco.repo.audit.model.TrueFalseUnset;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
@@ -159,6 +160,8 @@ public class AuditComponentImpl implements AuditComponent
public Object audit(MethodInvocation mi) throws Throwable public Object audit(MethodInvocation mi) throws Throwable
{ {
if ((auditFlag.get() == null) || (!auditFlag.get().booleanValue())) if ((auditFlag.get() == null) || (!auditFlag.get().booleanValue()))
{
if (auditModel instanceof AuditEntry && ((AuditEntry)auditModel).getEnabled() == TrueFalseUnset.TRUE)
{ {
boolean auditInternal = (auditModel.getAuditInternalServiceMethods(mi) == TrueFalseUnset.TRUE); boolean auditInternal = (auditModel.getAuditInternalServiceMethods(mi) == TrueFalseUnset.TRUE);
try try
@@ -238,6 +241,11 @@ public class AuditComponentImpl implements AuditComponent
return mi.proceed(); return mi.proceed();
} }
} }
else
{
return mi.proceed();
}
}
/** /**
* Internal audit of a method invocation * Internal audit of a method invocation

View File

@@ -222,12 +222,16 @@ public abstract class AuthenticationUtil
*/ */
private static String getUserName(Authentication authentication) private static String getUserName(Authentication authentication)
{ {
String username = authentication.getPrincipal().toString(); String username;
if (authentication.getPrincipal() instanceof UserDetails) if (authentication.getPrincipal() instanceof UserDetails)
{ {
username = ((UserDetails) authentication.getPrincipal()).getUsername(); username = ((UserDetails) authentication.getPrincipal()).getUsername();
} }
else
{
username = authentication.getPrincipal().toString();
}
return username; return username;
} }

View File

@@ -35,6 +35,7 @@ import org.alfresco.repo.security.permissions.PermissionReference;
public abstract class AbstractPermissionReference implements PermissionReference public abstract class AbstractPermissionReference implements PermissionReference
{ {
private int hashcode = 0; private int hashcode = 0;
private String str = null;
public AbstractPermissionReference() public AbstractPermissionReference()
{ {
@@ -69,6 +70,10 @@ public abstract class AbstractPermissionReference implements PermissionReference
@Override @Override
public String toString() public String toString()
{ {
return getQName()+ "." + getName(); if (str == null)
{
str = getQName() + "." + getName();
}
return str;
} }
} }

View File

@@ -296,10 +296,6 @@ public final class QName implements QNamePattern, Serializable, Cloneable
{ {
return true; return true;
} }
else if (object == null)
{
return false;
}
if (object instanceof QName) if (object instanceof QName)
{ {
QName other = (QName)object; QName other = (QName)object;
@@ -307,11 +303,8 @@ public final class QName implements QNamePattern, Serializable, Cloneable
return (this.localName.equals(other.localName) && return (this.localName.equals(other.localName) &&
this.namespaceURI.equals(other.namespaceURI)); this.namespaceURI.equals(other.namespaceURI));
} }
else
{
return false; return false;
} }
}
/** /**
* Performs a direct comparison between qnames. * Performs a direct comparison between qnames.
@@ -347,7 +340,10 @@ public final class QName implements QNamePattern, Serializable, Cloneable
*/ */
public String toString() public String toString()
{ {
return NAMESPACE_BEGIN + namespaceURI + NAMESPACE_END + localName; return new StringBuffer(80).append(NAMESPACE_BEGIN)
.append(namespaceURI)
.append(NAMESPACE_END)
.append(localName).toString();
} }