Merged V3.1 to HEAD

13037: PostgreSQL upgrade scripts from 2.1.6, 2.2.0, and 2.2.1
   12995: Fix build: account for change of path to log4j jar in 3rd party project
   12981: Added support for monitoring of installed modules via JMX
   12971: Correction to 12970 - better handle case when log4j not available.
   12970: Work around log4j bug to allow editing of the "threshold" property of HierarchyDynamicBean through JMX
   12926: Merged V3.0 to V3.1
      Merged V2.2 to V3.0
         12861: ETHREEOH-19, ETHREEOH-24, ETHREEOH-113, ETHREEOH-115, ETHREEOH-449, ETHREEOH-537, ETHREEOH-561, ETHREEOH-566, ETHREEOH-572, ETHREEOH-1072: Retry failed transactions from MS SQL Server in snapshot mode 
   12924: Avoid direct log4j dependencies
   12918: Avoided Log4J imports by using introspection


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13516 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2009-03-10 13:17:24 +00:00
parent 352e065b07
commit b60eb95e1b
4 changed files with 34 additions and 28 deletions

View File

@@ -86,8 +86,6 @@
<property name="server" ref="alfrescoMBeanServer"/>
<property name="beans">
<map>
<!-- MBeans to register with alfrescoMBeanServer -->
<entry key="Alfresco:Name=Log4jHierarchy,Type=Log4JHierarchy" value-ref="log4jHierarchy"/>
<!-- Used by Alfresco WCM Virtualisation server -->
<entry key="Alfresco:Name=VirtServerRegistry,Type=VirtServerRegistry" value-ref="VirtServerRegistry"/>
</map>
@@ -130,9 +128,6 @@
<property name="nfsServer"><ref bean="nfsServer"/></property>
</bean>
<!-- Log4J Hierarchy -->
<bean id="log4jHierarchy" class="org.apache.log4j.jmx.HierarchyDynamicMBean"/>
<!-- This bean will attempt to export extra beans to log4jHierarchy's MBeanServer, so it's vital that the exporter has been initialised -->
<bean id="log4JHierarchyInit" class="org.alfresco.repo.admin.Log4JHierarchyInit" depends-on="exporter" init-method="init">
<property name="log4jHierarchy" ref="log4jHierarchy"/>

View File

@@ -38,10 +38,13 @@ import net.sf.acegisecurity.providers.dao.User;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.util.EqualsHelper;
import org.alfresco.util.log.NDC;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.NDC;
/**
* Utility helper methods to change the authenticated context for threads.
*/
public abstract class AuthenticationUtil
{
static Log s_logger = LogFactory.getLog(AuthenticationUtil.class);
@@ -59,7 +62,7 @@ public abstract class AuthenticationUtil
public static final String SYSTEM_USER_NAME = "System";
private static boolean mtEnabled = false;
public static void setMtEnabled(boolean mtEnabled)
{
if (!AuthenticationUtil.mtEnabled)
@@ -523,23 +526,23 @@ public abstract class AuthenticationUtil
public static void logNDC(String userName)
{
NDC.remove();
if (isMtEnabled())
NDC.remove();
if (isMtEnabled())
{
int idx = userName.indexOf(TenantService.SEPARATOR);
if ((idx != -1) && (idx < (userName.length() - 1)))
int idx = userName.indexOf(TenantService.SEPARATOR);
if ((idx != -1) && (idx < (userName.length() - 1)))
{
NDC.push("Tenant:" + userName.substring(idx + 1) + " User:" + userName.substring(0, idx));
NDC.push("Tenant:" + userName.substring(idx + 1) + " User:" + userName.substring(0, idx));
}
else
{
NDC.push("User:" + userName);
NDC.push("User:" + userName);
}
}
else
else
{
NDC.push("User:" + userName);
NDC.push("User:" + userName);
}
}
}

View File

@@ -48,6 +48,7 @@ import org.hibernate.StaleStateException;
import org.hibernate.cache.CacheException;
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.LockAcquisitionException;
import org.hibernate.exception.SQLGrammarException;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.dao.ConcurrencyFailureException;
@@ -101,7 +102,8 @@ public class RetryingTransactionHelper
StaleStateException.class,
ObjectNotFoundException.class,
CacheException.class, // Usually a cache replication issue
RemoteCacheException.class // A cache replication issue
RemoteCacheException.class, // A cache replication issue
SQLGrammarException.class // Actually specific to MS SQL Server 2005 - we check for this
};
}
@@ -456,15 +458,13 @@ public class RetryingTransactionHelper
public static Throwable extractRetryCause(Throwable cause)
{
Throwable retryCause = ExceptionStackUtil.getCause(cause, RETRY_EXCEPTIONS);
if (retryCause == null)
if (retryCause == null || retryCause instanceof SQLGrammarException
&& ((SQLGrammarException) retryCause).getErrorCode() != 3960)
{
return null;
}
else
{
// A simple match
return retryCause;
}
// A simple match
return retryCause;
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -80,6 +80,8 @@ public class Main
/**
* Creates a new instance of this tool..
*
* @param contextPath
* path to the context xml file
* @throws SQLException
* the SQL exception
* @throws IOException
@@ -94,12 +96,12 @@ public class Main
* the no such field exception
*/
@SuppressWarnings("unchecked")
public Main() throws SQLException, IOException, InstantiationException, IllegalAccessException,
public Main(final String contextPath) throws SQLException, IOException, InstantiationException, IllegalAccessException,
ClassNotFoundException, NoSuchFieldException
{
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]
{
"classpath:/org/alfresco/extension/dump-context.xml"
"file:" + contextPath
});
final DataSource datasource = (DataSource) context.getBean("dataSource");
this.con = datasource.getConnection();
@@ -142,7 +144,13 @@ public class Main
*/
public static void main(final String[] args) throws Exception
{
final NamedElementCollection result = new Main().execute();
if (args.length != 2)
{
System.out.println("Usage:");
System.out.println("java " + Main.class.getName() + " <context.xml> <output.xml>");
System.exit(1);
}
final NamedElementCollection result = new Main(args[0]).execute();
// Set up a SAX TransformerHandler for outputting XML
final SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory.newInstance();
@@ -157,7 +165,7 @@ public class Main
// It was worth a try
}
t.setOutputProperty(OutputKeys.INDENT, "yes");
xmlOut.setResult(new StreamResult(args[0]));
xmlOut.setResult(new StreamResult(args[1]));
xmlOut.startDocument();
result.output(xmlOut);