mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALFCOM-2816: Changes for JBoss v5.0.1.GA compatibility
- All code that resolves classpath resources goes through JBossEnabledResourceLoader with VFS support - JBossEnabledResourcePatternResolver can handle recursion within VFS directory structures - Reflection used to avoid runtime dependency on JBoss classes - resource-ref declared in jboss-web.xml - Work around incorrect treatment of env-entry-value tag in web.xml git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14106 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,18 +25,18 @@
|
||||
package org.alfresco.filesys.alfresco;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
import org.alfresco.config.ConfigElement;
|
||||
import org.alfresco.jlan.server.filesys.DiskSharedDevice;
|
||||
import org.alfresco.jlan.server.filesys.pseudo.LocalPseudoFile;
|
||||
import org.alfresco.jlan.server.filesys.pseudo.PseudoFile;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.util.ResourceFinder;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* Desktop Action Class
|
||||
@@ -409,28 +409,31 @@ public abstract class DesktopAction {
|
||||
throw new DesktopActionException("Desktop action executable path not specified");
|
||||
|
||||
// Check that the application exists on the local filesystem
|
||||
|
||||
URL appURL = this.getClass().getClassLoader().getResource(m_path);
|
||||
if ( appURL == null)
|
||||
Resource resource = new ResourceFinder().getResource(m_path);
|
||||
if (!resource.exists())
|
||||
{
|
||||
throw new DesktopActionException("Failed to find drag and drop application, " + m_path);
|
||||
}
|
||||
|
||||
// Decode the URL path, it might contain escaped characters
|
||||
|
||||
String appURLPath = null;
|
||||
try
|
||||
{
|
||||
appURLPath = URLDecoder.decode( appURL.getFile(), "UTF-8");
|
||||
}
|
||||
catch ( UnsupportedEncodingException ex)
|
||||
{
|
||||
throw new DesktopActionException("Failed to decode drag/drop path, " + ex.getMessage());
|
||||
}
|
||||
|
||||
// Check that the drag/drop file exists
|
||||
File appFile;
|
||||
try
|
||||
{
|
||||
appFile = resource.getFile();
|
||||
|
||||
File appFile = new File(appURLPath);
|
||||
if ( appFile.exists() == false)
|
||||
if (!appFile.exists())
|
||||
{
|
||||
throw new DesktopActionException("Drag and drop application not found, " + appFile);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new DesktopActionException("Unable to resolve drag and drop application as a file, "
|
||||
+ resource.getDescription());
|
||||
}
|
||||
|
||||
// Create the pseudo file for the action
|
||||
|
||||
|
@@ -27,9 +27,6 @@ import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
@@ -44,6 +41,8 @@ import org.alfresco.filesys.alfresco.DesktopResponse;
|
||||
import org.alfresco.jlan.server.filesys.DiskSharedDevice;
|
||||
import org.alfresco.scripts.ScriptException;
|
||||
import org.alfresco.service.cmr.repository.ScriptService;
|
||||
import org.alfresco.util.ResourceFinder;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* Javascript Desktop Action Class
|
||||
@@ -155,28 +154,25 @@ public class JavaScriptDesktopAction extends DesktopAction {
|
||||
}
|
||||
|
||||
// Check if the script exists on the classpath
|
||||
|
||||
URL scriptURL = this.getClass().getClassLoader().getResource(m_scriptName);
|
||||
if ( scriptURL == null)
|
||||
Resource resource = new ResourceFinder().getResource(m_scriptName);
|
||||
if (!resource.exists())
|
||||
{
|
||||
throw new DesktopActionException("Failed to find script on classpath, " + getScriptName());
|
||||
|
||||
// Decode the URL path, it might contain escaped characters
|
||||
|
||||
String scriptURLPath = null;
|
||||
try
|
||||
{
|
||||
scriptURLPath = URLDecoder.decode( scriptURL.getFile(), "UTF-8");
|
||||
}
|
||||
catch ( UnsupportedEncodingException ex)
|
||||
{
|
||||
throw new DesktopActionException("Failed to decode script path, " + ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
// Check that the script file exists
|
||||
|
||||
File scriptFile = new File(scriptURLPath);
|
||||
File scriptFile;
|
||||
try
|
||||
{
|
||||
scriptFile = resource.getFile();
|
||||
if (scriptFile.exists() == false)
|
||||
throw new DesktopActionException("Script file not found, " + m_scriptName);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new DesktopActionException("Unable to resolve script as a file, " + resource.getDescription());
|
||||
}
|
||||
|
||||
m_scriptPath = scriptFile.getAbsolutePath();
|
||||
m_lastModified =scriptFile.lastModified();
|
||||
|
@@ -31,8 +31,12 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
|
||||
/**
|
||||
* Initialises Log4j's HierarchyDynamicMBean (refer to core-services-context.xml) and any overriding log4.properties files.
|
||||
@@ -62,10 +66,11 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
* WEB - INF / classes / alfresco / module / org.alfresco.module.avmCompare / log4j.properties
|
||||
* </pre>
|
||||
*/
|
||||
public class Log4JHierarchyInit
|
||||
public class Log4JHierarchyInit implements ApplicationContextAware
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(Log4JHierarchyInit.class);
|
||||
private List<String> extraLog4jUrls;
|
||||
private ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
|
||||
public Log4JHierarchyInit()
|
||||
{
|
||||
@@ -86,6 +91,16 @@ public class Log4JHierarchyInit
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
*/
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
{
|
||||
this.resolver = applicationContext;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void init()
|
||||
{
|
||||
@@ -120,7 +135,6 @@ public class Log4JHierarchyInit
|
||||
|
||||
private void importLogSettings(Method method, String springUrl)
|
||||
{
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
Resource[] resources = null;
|
||||
|
||||
try
|
||||
|
@@ -133,8 +133,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
public static final int DEFAULT_MAX_STRING_LENGTH = 1024;
|
||||
private static volatile int maxStringLength = DEFAULT_MAX_STRING_LENGTH;
|
||||
|
||||
|
||||
|
||||
private ResourcePatternResolver rpr = new PathMatchingResourcePatternResolver(this.getClass().getClassLoader());
|
||||
|
||||
|
||||
/**
|
||||
@@ -838,7 +837,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
// replace the dialect placeholder
|
||||
String dialectScriptUrl = scriptUrl.replaceAll(PLACEHOLDER_SCRIPT_DIALECT, dialectClazz.getName());
|
||||
// get a handle on the resource
|
||||
ResourcePatternResolver rpr = new PathMatchingResourcePatternResolver(this.getClass().getClassLoader());
|
||||
Resource resource = rpr.getResource(dialectScriptUrl);
|
||||
if (!resource.exists())
|
||||
{
|
||||
@@ -1147,6 +1145,9 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
@Override
|
||||
protected synchronized void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
// Use the application context to load resources
|
||||
rpr = (ApplicationContext)event.getSource();
|
||||
|
||||
// do everything in a transaction
|
||||
Session session = getSessionFactory().openSession();
|
||||
Connection connection = null;
|
||||
|
@@ -30,6 +30,7 @@ import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.alfresco.config.JBossEnabledResourcePatternResolver;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
@@ -43,6 +44,7 @@ import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
|
||||
/**
|
||||
* A factory allowing initialization of an entire 'subsystem' in a child application context. As with other
|
||||
@@ -309,7 +311,20 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i
|
||||
+ ChildApplicationContextFactory.CONTEXT_SUFFIX,
|
||||
ChildApplicationContextFactory.EXTENSION_CLASSPATH_PREFIX + getCategory() + '/' + getTypeName() + '/'
|
||||
+ getId() + '/' + ChildApplicationContextFactory.CONTEXT_SUFFIX
|
||||
}, false, this.parent);
|
||||
}, false, this.parent)
|
||||
{
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.context.support.AbstractApplicationContext#getResourcePatternResolver()
|
||||
*/
|
||||
@Override
|
||||
protected ResourcePatternResolver getResourcePatternResolver()
|
||||
{
|
||||
return new JBossEnabledResourcePatternResolver(this);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Add a property placeholder configurer, with the subsystem-scoped default properties
|
||||
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
|
||||
|
@@ -43,8 +43,12 @@ import org.alfresco.service.cmr.module.ModuleService;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
|
||||
/**
|
||||
* This component controls the execution of
|
||||
@@ -63,7 +67,7 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
* @author Derek Hulley
|
||||
* @since 2.0
|
||||
*/
|
||||
public class ModuleServiceImpl implements ModuleService
|
||||
public class ModuleServiceImpl implements ApplicationContextAware, ModuleService
|
||||
{
|
||||
/** Error messages **/
|
||||
private static final String ERR_UNABLE_TO_OPEN_MODULE_PROPETIES = "module.err.unable_to_open_module_properties";
|
||||
@@ -78,6 +82,8 @@ public class ModuleServiceImpl implements ModuleService
|
||||
/** A cache of module details by module ID */
|
||||
private Map<String, ModuleDetails> moduleDetailsById;
|
||||
|
||||
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
|
||||
/** Default constructor */
|
||||
public ModuleServiceImpl()
|
||||
{
|
||||
@@ -109,6 +115,16 @@ public class ModuleServiceImpl implements ModuleService
|
||||
this.moduleComponentHelper.setTenantAdminService(tenantAdminService);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
*/
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||
{
|
||||
this.resolver = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ModuleComponentHelper#registerComponent(ModuleComponent)
|
||||
*/
|
||||
@@ -169,7 +185,6 @@ public class ModuleServiceImpl implements ModuleService
|
||||
{
|
||||
moduleDetailsById = new HashMap<String, ModuleDetails>(13);
|
||||
|
||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
Resource[] resources = resolver.getResources(MODULE_CONFIG_SEARCH_ALL);
|
||||
|
||||
// Read each resource
|
||||
|
@@ -29,33 +29,21 @@ import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.config.JBossEnabledResourcePatternResolver;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
|
||||
/**
|
||||
* Can be used in Spring configuration to search for all resources matching an array of patterns.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class ResourceFinder extends PathMatchingResourcePatternResolver
|
||||
public class ResourceFinder extends JBossEnabledResourcePatternResolver
|
||||
{
|
||||
/**
|
||||
* Instantiates a new resource finder.
|
||||
*/
|
||||
public ResourceFinder()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* The Constructor.
|
||||
*
|
||||
* @param classLoader
|
||||
* the class loader
|
||||
*/
|
||||
public ResourceFinder(ClassLoader classLoader)
|
||||
{
|
||||
super(classLoader);
|
||||
super(new DefaultResourceLoader());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user