diff --git a/config/alfresco/mimetype/mimetype-map-openoffice.xml b/config/alfresco/mimetype/mimetype-map-openoffice.xml deleted file mode 100644 index a9d1a766a0..0000000000 --- a/config/alfresco/mimetype/mimetype-map-openoffice.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - odt - - - ott - - - oth - - - odm - - - odg - - - otg - - - odp - - - otp - - - ods - - - ots - - - odc - - - odf - - - odb - - - odi - - - - - sxc - - - sxd - - - sxi - - - sxw - - - - - sda - - - sdc - - - sdd - - - sdp - - - sds - - - sdw - - - sgl - - - smf - - - - - diff --git a/config/alfresco/mimetype/mimetype-map.xml b/config/alfresco/mimetype/mimetype-map.xml deleted file mode 100644 index 1cb541745c..0000000000 --- a/config/alfresco/mimetype/mimetype-map.xml +++ /dev/null @@ -1,406 +0,0 @@ - - - - - - - json - - - - eps - - - - jp2 - jpx - jpm - jpc - j2k - jpf - - - - mpp - - - - psd - - - - fm - - - - pmd - pm6 - p65 - pm - - - - prn - - - - txt - csv - java - jsp - sql - properties - ftl - ini - bat - sh - logS - - - - html - htm - shtml - body - xsd - - - mw - - - xhtml - - - - ai - ps - - - aiff - aif - aifc - - - acp - - - vsd - - - xdp - - - au - snd - - - avi - qvi - - - asf - asx - - - wmv - - - wma - - - avx - - - bcpio - - - bin - exe - - - cdf - nc - - - cer - - - cgm - - - class - - - cpio - - - csh - - - css - - - doc - dot - - - wpd - - - xml - dtd - xslt - xsl - xsd - - - dvi - - - etx - - - gif - - - gml - - - gtar - - - gzip - - - hdf - - - hqx - - - ics - - - ief - - - bmp - - - jpg - jpeg - jpe - - - svg - - - js - - - latex - - - man - - - me - - - ms - - - mif - - - mpg - mpeg - mpe - - - mp3 - mp2 - - - mp4 - - - mpeg2 - - - mov - qt - - - movie - mpv2 - - - oda - - - pbm - - - pdf - - - pgm - - - png - - - pnm - rpnm - - - ppm - - - ppt - pps - pot - - - ppt - pps - pot - - - ras - - - rgb - - - tr - t - roff - - - rtf - - - rtx - - - sgml - sgm - - - sh - - - shar - - - src - - - sv4cpio - - - sv4crc - - - air - - - swf - - - flv - - - tar - - - tcl - - - tex - - - texinfo - texi - - - tiff - tif - - - tsv - - - ustar - - - wav - - - wrl - - - xbm - - - xls - xlt - xlm - - - xls - - - xpm - - - xwd - - - z - - - zip - war - jar - ear - - - dwg - - - dwg - - - dwt - - - eml - - - msg - - - docx - - - xlsx - - - pptx - - - xltx - - - xltm - - - dotx - - - - - diff --git a/config/alfresco/model/dataTypeAnalyzers.properties b/config/alfresco/model/dataTypeAnalyzers.properties deleted file mode 100644 index 7c3d7f9511..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_any.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser -d_dictionary.datatype.d_text.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser -d_dictionary.datatype.d_content.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser -d_dictionary.datatype.d_int.analyzer=org.alfresco.repo.search.impl.lucene.analysis.IntegerAnalyser -d_dictionary.datatype.d_long.analyzer=org.alfresco.repo.search.impl.lucene.analysis.LongAnalyser -d_dictionary.datatype.d_float.analyzer=org.alfresco.repo.search.impl.lucene.analysis.FloatAnalyser -d_dictionary.datatype.d_double.analyzer=org.alfresco.repo.search.impl.lucene.analysis.DoubleAnalyser -d_dictionary.datatype.d_date.analyzer=org.alfresco.repo.search.impl.lucene.analysis.DateAnalyser -d_dictionary.datatype.d_datetime.analyzer=org.alfresco.repo.search.impl.lucene.analysis.DateAnalyser -d_dictionary.datatype.d_boolean.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser -d_dictionary.datatype.d_qname.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser -d_dictionary.datatype.d_guid.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser -d_dictionary.datatype.d_category.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser -d_dictionary.datatype.d_noderef.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser -d_dictionary.datatype.d_path.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser -d_dictionary.datatype.d_locale.analyzer=org.alfresco.repo.search.impl.lucene.analysis.LowerCaseVerbatimAnalyser diff --git a/config/alfresco/model/dataTypeAnalyzers_cs.properties b/config/alfresco/model/dataTypeAnalyzers_cs.properties deleted file mode 100644 index bd4f99b085..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_cs.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.apache.lucene.analysis.cz.CzechAnalyzer -d_dictionary.datatype.d_content.analyzer=org.apache.lucene.analysis.cz.CzechAnalyzer diff --git a/config/alfresco/model/dataTypeAnalyzers_da.properties b/config/alfresco/model/dataTypeAnalyzers_da.properties deleted file mode 100644 index eba2d37c18..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_da.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.alfresco.repo.search.impl.lucene.analysis.DanishSnowballAnalyser -d_dictionary.datatype.d_content.analyzer=org.alfresco.repo.search.impl.lucene.analysis.DanishSnowballAnalyser diff --git a/config/alfresco/model/dataTypeAnalyzers_de.properties b/config/alfresco/model/dataTypeAnalyzers_de.properties deleted file mode 100644 index 51a0c3dc20..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_de.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.apache.lucene.analysis.de.GermanAnalyzer -d_dictionary.datatype.d_content.analyzer=org.apache.lucene.analysis.de.GermanAnalyzer diff --git a/config/alfresco/model/dataTypeAnalyzers_el.properties b/config/alfresco/model/dataTypeAnalyzers_el.properties deleted file mode 100644 index e76fb3c77f..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_el.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.apache.lucene.analysis.el.GreekAnalyzer -d_dictionary.datatype.d_content.analyzer=org.apache.lucene.analysis.el.GreekAnalyzer diff --git a/config/alfresco/model/dataTypeAnalyzers_en.properties b/config/alfresco/model/dataTypeAnalyzers_en.properties deleted file mode 100644 index 49ce516535..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_en.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser -d_dictionary.datatype.d_content.analyzer=org.alfresco.repo.search.impl.lucene.analysis.AlfrescoStandardAnalyser diff --git a/config/alfresco/model/dataTypeAnalyzers_es.properties b/config/alfresco/model/dataTypeAnalyzers_es.properties deleted file mode 100644 index a808ef9f11..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_es.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.alfresco.repo.search.impl.lucene.analysis.SpanishSnowballAnalyser -d_dictionary.datatype.d_content.analyzer=org.alfresco.repo.search.impl.lucene.analysis.SpanishSnowballAnalyser diff --git a/config/alfresco/model/dataTypeAnalyzers_fi.properties b/config/alfresco/model/dataTypeAnalyzers_fi.properties deleted file mode 100644 index 6320710a65..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_fi.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.alfresco.repo.search.impl.lucene.analysis.FinnishSnowballAnalyser -d_dictionary.datatype.d_content.analyzer=org.alfresco.repo.search.impl.lucene.analysis.FinnishSnowballAnalyser diff --git a/config/alfresco/model/dataTypeAnalyzers_fr.properties b/config/alfresco/model/dataTypeAnalyzers_fr.properties deleted file mode 100644 index 2e73d811fa..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_fr.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.apache.lucene.analysis.fr.FrenchAnalyzer -d_dictionary.datatype.d_content.analyzer=org.apache.lucene.analysis.fr.FrenchAnalyzer diff --git a/config/alfresco/model/dataTypeAnalyzers_it.properties b/config/alfresco/model/dataTypeAnalyzers_it.properties deleted file mode 100644 index 55f492167d..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_it.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.alfresco.repo.search.impl.lucene.analysis.ItalianSnowballAnalyser -d_dictionary.datatype.d_content.analyzer=org.alfresco.repo.search.impl.lucene.analysis.ItalianSnowballAnalyser diff --git a/config/alfresco/model/dataTypeAnalyzers_ja.properties b/config/alfresco/model/dataTypeAnalyzers_ja.properties deleted file mode 100644 index 58a04cb7e6..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_ja.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.apache.lucene.analysis.cjk.CJKAnalyzer -d_dictionary.datatype.d_content.analyzer=org.apache.lucene.analysis.cjk.CJKAnalyzer diff --git a/config/alfresco/model/dataTypeAnalyzers_ko.properties b/config/alfresco/model/dataTypeAnalyzers_ko.properties deleted file mode 100644 index 58a04cb7e6..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_ko.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.apache.lucene.analysis.cjk.CJKAnalyzer -d_dictionary.datatype.d_content.analyzer=org.apache.lucene.analysis.cjk.CJKAnalyzer diff --git a/config/alfresco/model/dataTypeAnalyzers_nl.properties b/config/alfresco/model/dataTypeAnalyzers_nl.properties deleted file mode 100644 index f4cfcf826e..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_nl.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.apache.lucene.analysis.nl.DutchAnalyzer -d_dictionary.datatype.d_content.analyzer=org.apache.lucene.analysis.nl.DutchAnalyzer diff --git a/config/alfresco/model/dataTypeAnalyzers_no.properties b/config/alfresco/model/dataTypeAnalyzers_no.properties deleted file mode 100644 index 386ab258f5..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_no.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.alfresco.repo.search.impl.lucene.analysis.NorwegianSnowballAnalyser -d_dictionary.datatype.d_content.analyzer=org.alfresco.repo.search.impl.lucene.analysis.NorwegianSnowballAnalyser diff --git a/config/alfresco/model/dataTypeAnalyzers_pt.properties b/config/alfresco/model/dataTypeAnalyzers_pt.properties deleted file mode 100644 index 522bad3dff..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_pt.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.alfresco.repo.search.impl.lucene.analysis.PortugueseSnowballAnalyser -d_dictionary.datatype.d_content.analyzer=org.alfresco.repo.search.impl.lucene.analysis.PortugueseSnowballAnalyser diff --git a/config/alfresco/model/dataTypeAnalyzers_pt_BR.properties b/config/alfresco/model/dataTypeAnalyzers_pt_BR.properties deleted file mode 100644 index a792c4bb32..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_pt_BR.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.apache.lucene.analysis.br.BrazilianAnalyzer -d_dictionary.datatype.d_content.analyzer=org.apache.lucene.analysis.br.BrazilianAnalyzer diff --git a/config/alfresco/model/dataTypeAnalyzers_ru.properties b/config/alfresco/model/dataTypeAnalyzers_ru.properties deleted file mode 100644 index 8a8340215b..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_ru.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.apache.lucene.analysis.ru.RussianAnalyzer -d_dictionary.datatype.d_content.analyzer=org.apache.lucene.analysis.ru.RussianAnalyzer diff --git a/config/alfresco/model/dataTypeAnalyzers_sv.properties b/config/alfresco/model/dataTypeAnalyzers_sv.properties deleted file mode 100644 index 0bfd347223..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_sv.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.alfresco.repo.search.impl.lucene.analysis.SwedishSnowballAnalyser -d_dictionary.datatype.d_content.analyzer=org.alfresco.repo.search.impl.lucene.analysis.SwedishSnowballAnalyser diff --git a/config/alfresco/model/dataTypeAnalyzers_zh.properties b/config/alfresco/model/dataTypeAnalyzers_zh.properties deleted file mode 100644 index 7d3b6bfa36..0000000000 --- a/config/alfresco/model/dataTypeAnalyzers_zh.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Data Type Index Analyzers - -d_dictionary.datatype.d_text.analyzer=org.apache.lucene.analysis.cn.ChineseAnalyzer -d_dictionary.datatype.d_content.analyzer=org.apache.lucene.analysis.cn.ChineseAnalyzer diff --git a/source/java/org/alfresco/repo/content/MimetypeMapTest.java b/source/java/org/alfresco/repo/content/MimetypeMapTest.java deleted file mode 100644 index 460becc5c4..0000000000 --- a/source/java/org/alfresco/repo/content/MimetypeMapTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.content; - -import java.util.Map; - -import junit.framework.TestCase; - -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.MimetypeService; -import org.alfresco.util.ApplicationContextHelper; -import org.springframework.context.ApplicationContext; - -/** - * @see org.alfresco.repo.content.MimetypeMap - * - * @author Derek Hulley - */ -public class MimetypeMapTest extends TestCase -{ - private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); - - private MimetypeService mimetypeService; - - @Override - public void setUp() throws Exception - { - ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); - mimetypeService = serviceRegistry.getMimetypeService(); - } - - public void testExtensions() throws Exception - { - Map extensionsByMimetype = mimetypeService.getExtensionsByMimetype(); - Map mimetypesByExtension = mimetypeService.getMimetypesByExtension(); - - // plain text - assertEquals("txt", extensionsByMimetype.get("text/plain")); - assertEquals("text/plain", mimetypesByExtension.get("txt")); - assertEquals("text/plain", mimetypesByExtension.get("csv")); - assertEquals("text/plain", mimetypesByExtension.get("java")); - - // JPEG - assertEquals("jpg", extensionsByMimetype.get("image/jpeg")); - assertEquals("image/jpeg", mimetypesByExtension.get("jpg")); - assertEquals("image/jpeg", mimetypesByExtension.get("jpeg")); - assertEquals("image/jpeg", mimetypesByExtension.get("jpe")); - - // MS Word - assertEquals("doc", extensionsByMimetype.get("application/msword")); - assertEquals("application/msword", mimetypesByExtension.get("doc")); - - // Star Office - assertEquals("sds", extensionsByMimetype.get("application/vnd.stardivision.chart")); - } - - public void testIsText() throws Exception - { - assertTrue(mimetypeService.isText(MimetypeMap.MIMETYPE_HTML)); - } - - public void testGetContentCharsetFinder() throws Exception - { - assertNotNull("No charset finder", mimetypeService.getContentCharsetFinder()); - } - - public void testMimetypeFromExtension() throws Exception - { - // test known mimetype - assertEquals("application/msword", mimetypeService.getMimetype("doc")); - // test case insensitivity - assertEquals("application/msword", mimetypeService.getMimetype("DOC")); - - // test fallback for unknown and missing - assertEquals(MimetypeMap.MIMETYPE_BINARY, mimetypeService.getMimetype(null)); - assertEquals(MimetypeMap.MIMETYPE_BINARY, mimetypeService.getMimetype("unknownext")); - } - - public void testGuessMimetypeForFilename() throws Exception - { - assertEquals("application/msword", mimetypeService.guessMimetype("something.doc")); - assertEquals("application/msword", mimetypeService.guessMimetype("SOMETHING.DOC")); - assertEquals(MimetypeMap.MIMETYPE_BINARY, mimetypeService.guessMimetype("noextension")); - assertEquals(MimetypeMap.MIMETYPE_BINARY, mimetypeService.guessMimetype("file.unknownext")); - } -} diff --git a/source/java/org/alfresco/repo/content/encoding/CharsetFinderTest.java b/source/java/org/alfresco/repo/content/encoding/CharsetFinderTest.java deleted file mode 100644 index 50c7a5d66c..0000000000 --- a/source/java/org/alfresco/repo/content/encoding/CharsetFinderTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.content.encoding; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.nio.charset.Charset; - -import junit.framework.TestCase; - -import org.alfresco.encoding.CharactersetFinder; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.content.transform.AbstractContentTransformerTest; -import org.alfresco.util.ApplicationContextHelper; -import org.springframework.context.ApplicationContext; - -/** - * @see CharsetFinderTest - * @see CharactersetFinder - * - * @author Derek Hulley - */ -public class CharsetFinderTest extends TestCase -{ - private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); - - private ContentCharsetFinder charsetFinder; - - @Override - public void setUp() throws Exception - { - charsetFinder = (ContentCharsetFinder) ctx.getBean("charset.finder"); - } - - public void testPlainText() throws Exception - { - File file = AbstractContentTransformerTest.loadQuickTestFile("txt"); - InputStream is = new BufferedInputStream(new FileInputStream(file)); - Charset charset = charsetFinder.getCharset(is, MimetypeMap.MIMETYPE_TEXT_PLAIN); - assertNotNull(charset); - } -} diff --git a/source/java/org/alfresco/util/ApplicationContextHelper.java b/source/java/org/alfresco/util/ApplicationContextHelper.java index 890d695f9f..426da08a55 100644 --- a/source/java/org/alfresco/util/ApplicationContextHelper.java +++ b/source/java/org/alfresco/util/ApplicationContextHelper.java @@ -18,10 +18,6 @@ */ package org.alfresco.util; -import java.util.Arrays; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -31,13 +27,8 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; * * @author Derek Hulley */ -public class ApplicationContextHelper -{ - private static ClassPathXmlApplicationContext instance; - private static String[] usedConfiguration; - private static boolean useLazyLoading = false; - private static boolean noAutoStart = false; - +public class ApplicationContextHelper extends BaseApplicationContextHelper +{ /** location of required configuration files */ public static final String[] CONFIG_LOCATIONS = new String[] { "classpath:alfresco/application-context.xml" }; @@ -52,99 +43,10 @@ public class ApplicationContextHelper */ public synchronized static ApplicationContext getApplicationContext() { - return getApplicationContext(CONFIG_LOCATIONS); - } - - /** - * Provides a static, single instance of the application context. This method can be - * called repeatedly. - *

- * If the configuration requested differs from one used previously, then the previously-created - * context is shut down. - * - * @return Returns an application context for the given configuration - */ - public synchronized static ApplicationContext getApplicationContext(String[] configLocations) - { - if (configLocations == null) - { - throw new IllegalArgumentException("configLocations argument is mandatory."); - } - if (usedConfiguration != null && Arrays.deepEquals(configLocations, usedConfiguration)) - { - // The configuration was used to create the current context - return instance; - } - // The config has changed so close the current context (if any) - closeApplicationContext(); - - if(useLazyLoading || noAutoStart) { - instance = new VariableFeatureClassPathXmlApplicationContext(configLocations); - } else { - instance = new ClassPathXmlApplicationContext(configLocations); - } - - usedConfiguration = configLocations; - - return instance; - } - - /** - * Closes and releases the application context. On the next call to - * {@link #getApplicationContext()}, a new context will be given. - */ - public static synchronized void closeApplicationContext() - { - if (instance == null) - { - // Nothing to do - return; - } - instance.close(); - instance = null; - usedConfiguration = null; - } - - /** - * Should the Spring beans be initilised in a lazy manner, or - * all in one go? - * Normally lazy loading/intialising shouldn't be used when - * running with the full context, but it may be appropriate - * to reduce startup times when using a small, cut down context. - */ - public static void setUseLazyLoading(boolean lazyLoading) { - useLazyLoading = lazyLoading; - } - /** - * Will the Spring beans be initilised in a lazy manner, or - * all in one go? The default it to load everything in one - * go, as spring normally does. - */ - public static boolean isUsingLazyLoading() { - return useLazyLoading; - } - - /** - * Should the autoStart=true property on subsystems - * be honoured, or should this property be ignored - * and the auto start prevented? - * Normally we will use the spring configuration to - * decide what to start, but when running tests, - * you can use this to prevent the auto start. - */ - public static void setNoAutoStart(boolean noAutoStart) { - ApplicationContextHelper.noAutoStart = noAutoStart; - } - /** - * Will Subsystems with the autoStart=true property set - * on them be allowed to auto start? The default is to - * honour the spring configuration and allow them to, - * but they can be prevented if required. - */ - public static boolean isNoAutoStart() { - return noAutoStart; + return BaseApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS); } + public static void main(String ... args) { ClassPathXmlApplicationContext ctx = (ClassPathXmlApplicationContext) getApplicationContext(); @@ -154,27 +56,4 @@ public class ApplicationContextHelper } ctx.close(); } - - - /** - * A wrapper around {@link ClassPathXmlApplicationContext} which - * allows us to enable lazy loading or prevent Subsystem - * autostart as requested. - */ - protected static class VariableFeatureClassPathXmlApplicationContext extends ClassPathXmlApplicationContext { - protected VariableFeatureClassPathXmlApplicationContext(String[] configLocations) throws BeansException { - super(configLocations); - } - - protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) { - super.initBeanDefinitionReader(reader); - - if(useLazyLoading) { - LazyClassPathXmlApplicationContext.postInitBeanDefinitionReader(reader); - } - if(noAutoStart) { - NoAutoStartClassPathXmlApplicationContext.postInitBeanDefinitionReader(reader); - } - } - } } diff --git a/source/java/org/alfresco/util/LazyClassPathXmlApplicationContext.java b/source/java/org/alfresco/util/LazyClassPathXmlApplicationContext.java deleted file mode 100644 index b379feae72..0000000000 --- a/source/java/org/alfresco/util/LazyClassPathXmlApplicationContext.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.util; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate; -import org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader; -import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.factory.xml.XmlReaderContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.w3c.dom.Element; - -/** - * A wrapper around {@link ClassPathXmlApplicationContext} which forces - * all beans to be loaded lazily. - * You shouldn't do this in production, but it can be handy with - * unit tests, as it allows a quicker startup when you don't touch - * much of the application. - * - * @author Nick Burch - */ -public class LazyClassPathXmlApplicationContext extends - ClassPathXmlApplicationContext { - - public LazyClassPathXmlApplicationContext(String[] configLocations) - throws BeansException { - super(configLocations); - } - - protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) { - super.initBeanDefinitionReader(reader); - - postInitBeanDefinitionReader(reader); - } - - /** - * Does the work of enabling Lazy Init on the xml bean reader - */ - protected static void postInitBeanDefinitionReader(XmlBeanDefinitionReader reader) { - reader.setDocumentReaderClass(AlwaysLazyInitBeanDefinitionDocumentReader.class); - } - - protected static class AlwaysLazyInitBeanDefinitionDocumentReader extends DefaultBeanDefinitionDocumentReader { - @Override - protected BeanDefinitionParserDelegate createHelper( - XmlReaderContext readerContext, Element root) { - BeanDefinitionParserDelegate helper = super.createHelper(readerContext, root); - helper.getDefaults().setLazyInit("true"); - return helper; - } - } -} diff --git a/source/java/org/alfresco/util/NoAutoStartClassPathXmlApplicationContext.java b/source/java/org/alfresco/util/NoAutoStartClassPathXmlApplicationContext.java deleted file mode 100644 index ceb125989c..0000000000 --- a/source/java/org/alfresco/util/NoAutoStartClassPathXmlApplicationContext.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.util; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate; -import org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader; -import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; -import org.springframework.beans.factory.xml.XmlReaderContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.w3c.dom.Element; - -/** - * A wrapper around {@link ClassPathXmlApplicationContext} which - * stops Alfresco Subsystem (abstractPropertyBackedBean based) - * beans from being AutoStarted by tweaking their property definitions. - * You shouldn't do this in production, but it can be handy with - * unit tests, as it allows a quicker startup by preventing - * subsystems from starting up - * - * @author Nick Burch - */ -public class NoAutoStartClassPathXmlApplicationContext extends - ClassPathXmlApplicationContext { - - public NoAutoStartClassPathXmlApplicationContext(String[] configLocations) - throws BeansException { - super(configLocations); - } - - protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) { - super.initBeanDefinitionReader(reader); - - postInitBeanDefinitionReader(reader); - } - - /** - * Does the work of disabling the autostart of the - * Subsystem (abstractPropertyBackedBean) beans - * on the xml bean reader - */ - protected static void postInitBeanDefinitionReader(XmlBeanDefinitionReader reader) { - reader.setDocumentReaderClass(NoAutoStartBeanDefinitionDocumentReader.class); - } - - protected static class NoAutoStartBeanDefinitionDocumentReader extends DefaultBeanDefinitionDocumentReader { - @Override - protected BeanDefinitionParserDelegate createHelper( - XmlReaderContext readerContext, Element root) { - BeanDefinitionParserDelegate delegate = new NoAutoStartBeanDefinitionParserDelegate(readerContext); - delegate.initDefaults(root); - return delegate; - } - } - - protected static class NoAutoStartBeanDefinitionParserDelegate extends BeanDefinitionParserDelegate { - protected NoAutoStartBeanDefinitionParserDelegate(XmlReaderContext readerContext) { - super(readerContext); - } - - @Override - public void parsePropertyElement(Element ele, BeanDefinition bd) { - String propertyName = ele.getAttribute("name"); - if("autoStart".equals(propertyName)) { - if("abstractPropertyBackedBean".equals(bd.getParentName())) { - String id = ele.getParentNode().getAttributes().getNamedItem("id").getTextContent(); - System.out.println("Preventing the autostart of Subsystem " + id); - return; - } - } - - super.parsePropertyElement(ele, bd); - } - } -}