From cd2542df80f0e9f6e4c6175beec732f35ece45e4 Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Thu, 24 Jan 2013 08:36:13 +0100 Subject: [PATCH] STS-3172: performance improvements for BeansCoreUtils.isBeansConfig (heavily used in builds) --- .../beans/core/tests/AllBeansCoreTests.java | 26 +++---- .../beans/core/tests/BeansCoreUtilsTest.java | 69 +++++++++++++++++++ .../workspace/isconfigtests/.classpath | 7 ++ .../workspace/isconfigtests/.project | 23 +++++++ ...ringframework.ide.eclipse.beans.core.prefs | 2 + ...org.springframework.ide.eclipse.core.prefs | 51 ++++++++++++++ .../workspace/isconfigtests/.springBeans | 14 ++++ .../isconfigtests/src/import-one.xml | 13 ++++ .../isconfigtests/src/test1/TestClass.java | 9 +++ .../isconfigtests/src/test1/import-two.xml | 12 ++++ .../src2/test1/not-configured-config.xml | 12 ++++ .../workspace/isconfigtests2/.classpath | 6 ++ .../workspace/isconfigtests2/.project | 23 +++++++ ...ringframework.ide.eclipse.beans.core.prefs | 2 + ...org.springframework.ide.eclipse.core.prefs | 37 ++++++++++ .../workspace/isconfigtests2/.springBeans | 13 ++++ .../isconfigtests2/src/test1/TestAspect.java | 9 +++ .../src/test1/anotherconfig.xml | 11 +++ .../eclipse/beans/core/BeansCoreUtils.java | 12 ++-- .../beans/core/internal/model/BeansModel.java | 33 ++++++++- .../core/internal/model/BeansProject.java | 48 ++++++++++++- .../eclipse/beans/core/model/IBeansModel.java | 57 +++++++++++---- .../beans/core/model/IBeansProject.java | 10 ++- 23 files changed, 463 insertions(+), 36 deletions(-) create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/src/org/springframework/ide/eclipse/beans/core/tests/BeansCoreUtilsTest.java create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.classpath create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.project create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.settings/org.springframework.ide.eclipse.beans.core.prefs create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.settings/org.springframework.ide.eclipse.core.prefs create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.springBeans create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/import-one.xml create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/test1/TestClass.java create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/test1/import-two.xml create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src2/test1/not-configured-config.xml create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.classpath create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.project create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.settings/org.springframework.ide.eclipse.beans.core.prefs create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.settings/org.springframework.ide.eclipse.core.prefs create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.springBeans create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/src/test1/TestAspect.java create mode 100644 plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/src/test1/anotherconfig.xml diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/src/org/springframework/ide/eclipse/beans/core/tests/AllBeansCoreTests.java b/plugins/org.springframework.ide.eclipse.beans.core.tests/src/org/springframework/ide/eclipse/beans/core/tests/AllBeansCoreTests.java index 7c852bd2d1..051f66dd71 100644 --- a/plugins/org.springframework.ide.eclipse.beans.core.tests/src/org/springframework/ide/eclipse/beans/core/tests/AllBeansCoreTests.java +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/src/org/springframework/ide/eclipse/beans/core/tests/AllBeansCoreTests.java @@ -34,18 +34,20 @@ * @since 2.0.3 */ @RunWith(Suite.class) -@SuiteClasses({ BeanClassRuleTest.class, // - BeanConstructorArgumentRuleTest.class, // - BeanPropertyRuleTest.class, // - BeanInitDestroyMethodRuleTest.class, // - RequiredPropertyRuleTest.class, // - NamespaceElementsRuleTest.class, // - IntrospectorTest.class, // - AutowiredAnnotationInjectionMetadataProviderTests.class, // - CommonAnnotationInjectionMetadataProviderTests.class, // - JdtAnnotationMetadataTest.class, // - JdtBasedAnnotationMetadataTest.class, // - JdtClassMetadataTest.class // +@SuiteClasses({ + BeansCoreUtilsTest.class, + BeanClassRuleTest.class, + BeanConstructorArgumentRuleTest.class, + BeanPropertyRuleTest.class, + BeanInitDestroyMethodRuleTest.class, + RequiredPropertyRuleTest.class, + NamespaceElementsRuleTest.class, + IntrospectorTest.class, + AutowiredAnnotationInjectionMetadataProviderTests.class, + CommonAnnotationInjectionMetadataProviderTests.class, + JdtAnnotationMetadataTest.class, + JdtBasedAnnotationMetadataTest.class, + JdtClassMetadataTest.class }) public class AllBeansCoreTests { // goofy junit4, no class body needed diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/src/org/springframework/ide/eclipse/beans/core/tests/BeansCoreUtilsTest.java b/plugins/org.springframework.ide.eclipse.beans.core.tests/src/org/springframework/ide/eclipse/beans/core/tests/BeansCoreUtilsTest.java new file mode 100644 index 0000000000..c72a180db3 --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/src/org/springframework/ide/eclipse/beans/core/tests/BeansCoreUtilsTest.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2013 Spring IDE Developers + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Spring IDE Developers - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.eclipse.beans.core.tests; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.junit.Before; +import org.junit.Test; +import org.springframework.ide.eclipse.beans.core.BeansCoreUtils; + +/** + * @author Martin Lippert + */ +public class BeansCoreUtilsTest extends BeansCoreTestCase { + + private IProject project1; + private IProject project2; + + @Before + public void setUp() throws Exception { + project2 = createPredefinedProject("isconfigtests2"); + project1 = createPredefinedProject("isconfigtests"); + } + + @Test + public void testSimpleBeansConfigLookup() { + IResource configResource1 = project1.findMember("src/import-one.xml"); + IResource configResource2 = project1.findMember("src/test1/import-two.xml"); + IResource configResource3 = project1.findMember("src2/test1/not-configured-config.xml"); + IResource configResource4 = project2.findMember("src/test1/anotherconfig.xml"); + + IResource javaResource1 = project1.findMember("src/test1/TestClass.java"); + IResource javaResource2 = project2.findMember("src/test1/TestAspect.java"); + + assertNotNull(configResource1); + assertNotNull(configResource2); + assertNotNull(configResource3); + assertNotNull(configResource4); + assertTrue(configResource1.exists()); + assertTrue(configResource2.exists()); + assertTrue(configResource3.exists()); + assertTrue(configResource4.exists()); + + assertTrue(BeansCoreUtils.isBeansConfig(configResource1, true)); + assertTrue(BeansCoreUtils.isBeansConfig(configResource2, true)); + assertFalse(BeansCoreUtils.isBeansConfig(configResource3, true)); + assertTrue(BeansCoreUtils.isBeansConfig(configResource4, true)); + + assertNotNull(javaResource1); + assertNotNull(javaResource1); + assertTrue(javaResource1.exists()); + assertTrue(javaResource2.exists()); + assertFalse(BeansCoreUtils.isBeansConfig(javaResource1, true)); + assertFalse(BeansCoreUtils.isBeansConfig(javaResource2, true)); + } + +} diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.classpath b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.classpath new file mode 100644 index 0000000000..3829adb67a --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.project b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.project new file mode 100644 index 0000000000..b375ddc886 --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.project @@ -0,0 +1,23 @@ + + + isconfigtests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + + diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.settings/org.springframework.ide.eclipse.beans.core.prefs b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.settings/org.springframework.ide.eclipse.beans.core.prefs new file mode 100644 index 0000000000..b0a7cb9992 --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.settings/org.springframework.ide.eclipse.beans.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.settings/org.springframework.ide.eclipse.core.prefs b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.settings/org.springframework.ide.eclipse.core.prefs new file mode 100644 index 0000000000..38e5f7c74d --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.settings/org.springframework.ide.eclipse.core.prefs @@ -0,0 +1,51 @@ +eclipse.preferences.version=1 +org.springframework.ide.eclipse.core.builders.enable.aopreferencemodelbuilder=true +org.springframework.ide.eclipse.core.builders.enable.beanmetadatabuilder=true +org.springframework.ide.eclipse.core.builders.enable.osgibundleupdater=false +org.springframework.ide.eclipse.core.builders.enable.target-definition.builder1=true +org.springframework.ide.eclipse.core.enable.project.preferences=false +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.bestpractices.beansvalidator=false +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.core.springvalidator=false +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.autowire.autowire-org.springframework.ide.eclipse.beans.core.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanAlias-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanClass-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanConstructorArgument-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinition-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinitionHolder-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanFactory-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanInitDestroyMethod-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanReference-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.methodOverride-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.parsingProblems-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.requiredProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.toolAnnotation-org.springframework.ide.eclipse.beans.core.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.AvoidDriverManagerDataSource-org.springframework.ide.eclipse.bestpractices.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.ImportElementsAtTopRulee-org.springframework.ide.eclipse.bestpractices.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.ParentBeanSpecifiesAbstractClassRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.RefElementRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.TooManyBeansInFileRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.UnnecessaryValueElementRule-org.springframework.ide.eclipse.bestpractices.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.com.springsource.sts.bestpractices.UseBeanInheritance-org.springframework.ide.eclipse.bestpractices.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.bestpractices.legacyxmlusage.jndiobjectfactory-org.springframework.ide.eclipse.bestpractices.beansvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.core.springClasspath-org.springframework.ide.eclipse.core.springvalidator=false +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.action-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.actionstate-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attributemapper-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.beanaction-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationaction-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationresult-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.exceptionhandler-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.import-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.inputattribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.mapping-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.outputattribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.set-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.state-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.subflowstate-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.transition-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.variable-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.webflowstate-org.springframework.ide.eclipse.webflow.core.validator=true diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.springBeans b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.springBeans new file mode 100644 index 0000000000..f5adde63cc --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/.springBeans @@ -0,0 +1,14 @@ + + + 1 + + + + + + + src/import-one.xml + + + + diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/import-one.xml b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/import-one.xml new file mode 100644 index 0000000000..0093e7ceee --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/import-one.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/test1/TestClass.java b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/test1/TestClass.java new file mode 100644 index 0000000000..f4acbb2dc2 --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/test1/TestClass.java @@ -0,0 +1,9 @@ +package test1; + +public class TestClass { + + public void before() { + + } + +} diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/test1/import-two.xml b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/test1/import-two.xml new file mode 100644 index 0000000000..146b557bec --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src/test1/import-two.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src2/test1/not-configured-config.xml b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src2/test1/not-configured-config.xml new file mode 100644 index 0000000000..ae833b9dac --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests/src2/test1/not-configured-config.xml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.classpath b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.classpath new file mode 100644 index 0000000000..fb5011632c --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.project b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.project new file mode 100644 index 0000000000..573c4affc5 --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.project @@ -0,0 +1,23 @@ + + + isconfigtests2 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.springframework.ide.eclipse.core.springbuilder + + + + + + org.springframework.ide.eclipse.core.springnature + org.eclipse.jdt.core.javanature + + diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.settings/org.springframework.ide.eclipse.beans.core.prefs b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.settings/org.springframework.ide.eclipse.beans.core.prefs new file mode 100644 index 0000000000..b0a7cb9992 --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.settings/org.springframework.ide.eclipse.beans.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.settings/org.springframework.ide.eclipse.core.prefs b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.settings/org.springframework.ide.eclipse.core.prefs new file mode 100644 index 0000000000..a91d4e8bed --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.settings/org.springframework.ide.eclipse.core.prefs @@ -0,0 +1,37 @@ +#Thu Jan 10 19:11:34 PST 2008 +eclipse.preferences.version=1 +org.springframework.ide.eclipse.core.builders.enable.aopreferencemodelbuilder=true +org.springframework.ide.eclipse.core.builders.enable.target-definition.builder1=true +org.springframework.ide.eclipse.core.enable.project.preferences=false +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.enable.org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanAlias-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanClass-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanConstructorArgument-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinition-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanDefinitionHolder-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanFactory-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanInitDestroyMethod-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.beanReference-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.methodOverride-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.parsingProblems-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.beans.core.requiredProperty-org.springframework.ide.eclipse.beans.core.beansvalidator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.action-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.actionstate-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.attributemapper-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.beanaction-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationaction-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.evaluationresult-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.exceptionhandler-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.import-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.inputattribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.mapping-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.outputattribute-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.set-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.state-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.subflowstate-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.transition-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.variable-org.springframework.ide.eclipse.webflow.core.validator=true +org.springframework.ide.eclipse.core.validator.rule.enable.org.springframework.ide.eclipse.webflow.core.validation.webflowstate-org.springframework.ide.eclipse.webflow.core.validator=true diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.springBeans b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.springBeans new file mode 100644 index 0000000000..031e15f86c --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/.springBeans @@ -0,0 +1,13 @@ + + + 1 + + + + + + + + + + diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/src/test1/TestAspect.java b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/src/test1/TestAspect.java new file mode 100644 index 0000000000..2331bab3bc --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/src/test1/TestAspect.java @@ -0,0 +1,9 @@ +package test1; + +public class TestAspect { + + public void before() { + + } + +} diff --git a/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/src/test1/anotherconfig.xml b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/src/test1/anotherconfig.xml new file mode 100644 index 0000000000..cbd9dac034 --- /dev/null +++ b/plugins/org.springframework.ide.eclipse.beans.core.tests/workspace/isconfigtests2/src/test1/anotherconfig.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/BeansCoreUtils.java b/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/BeansCoreUtils.java index 2e34d52861..6f6e70ffa2 100644 --- a/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/BeansCoreUtils.java +++ b/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/BeansCoreUtils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 Spring IDE Developers + * Copyright (c) 2004, 2013 Spring IDE Developers * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,8 +15,10 @@ /** * Some helper methods for the Spring IDE core model. + * * @author Torsten Juergeleit * @author Christian Dupuis + * @author Martin Lippert */ public class BeansCoreUtils { @@ -35,13 +37,13 @@ public static boolean isBeansConfig(IResource resource) { * Returns true if given resource is a Spring bean factory * config file. If includeImported is provided as * true the imported configs are queried as well. + * * @since 2.0.3 */ - public static boolean isBeansConfig(IResource resource, - boolean includeImported) { + public static boolean isBeansConfig(IResource resource, boolean includeImported) { if (resource instanceof IFile) { - return BeansCorePlugin.getModel().getConfig((IFile) resource, - includeImported) != null; +// return BeansCorePlugin.getModel().getConfig((IFile) resource, includeImported) != null; + return BeansCorePlugin.getModel().isConfig((IFile) resource, includeImported); } return false; } diff --git a/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/internal/model/BeansModel.java b/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/internal/model/BeansModel.java index 23b5e5faa9..e0416c8b22 100644 --- a/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/internal/model/BeansModel.java +++ b/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/internal/model/BeansModel.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 Spring IDE Developers + * Copyright (c) 2004, 2013 Spring IDE Developers * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,6 +45,7 @@ import org.springframework.ide.eclipse.beans.core.model.IImportedBeansConfig; import org.springframework.ide.eclipse.core.SpringCore; import org.springframework.ide.eclipse.core.SpringCoreUtils; +import org.springframework.ide.eclipse.core.io.ExternalFile; import org.springframework.ide.eclipse.core.model.AbstractModel; import org.springframework.ide.eclipse.core.model.IModelElement; import org.springframework.ide.eclipse.core.model.IModelElementVisitor; @@ -241,6 +242,36 @@ public IBeansConfig getConfig(IFile configFile, boolean includeImported) { return null; } + public boolean isConfig(IFile configFile, boolean includeImported) { + if (configFile != null) { + IBeansProject project = getProject(configFile.getProject()); + + // check the project of the file itself first + String configName = null; + if (project != null) { + if (!(configFile instanceof ExternalFile)) { + configName = configFile.getProjectRelativePath().toString(); + } + else { + configName = configFile.getFullPath().toString(); + } + + if (project.hasConfig(configFile, configName, includeImported)) { + return true; + } + } + + // then check all the other projects + configName = configFile.getFullPath().toString(); + for (IBeansProject p : getProjects()) { + if (p.hasConfig(configFile, configName, includeImported)) { + return true; + } + } + } + return false; + } + public Set getConfigs(IFile configFile, boolean includeImported) { Set beansConfigs = new LinkedHashSet(); if (configFile != null) { diff --git a/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/internal/model/BeansProject.java b/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/internal/model/BeansProject.java index 825b0d8e91..2e1e0e8f66 100644 --- a/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/internal/model/BeansProject.java +++ b/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/internal/model/BeansProject.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 Spring IDE Developers + * Copyright (c) 2004, 2013 Spring IDE Developers * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,13 +34,13 @@ import org.springframework.ide.eclipse.beans.core.internal.project.BeansProjectDescriptionWriter; import org.springframework.ide.eclipse.beans.core.model.IBean; import org.springframework.ide.eclipse.beans.core.model.IBeansConfig; +import org.springframework.ide.eclipse.beans.core.model.IBeansConfig.Type; import org.springframework.ide.eclipse.beans.core.model.IBeansConfigEventListener; import org.springframework.ide.eclipse.beans.core.model.IBeansConfigSet; import org.springframework.ide.eclipse.beans.core.model.IBeansImport; import org.springframework.ide.eclipse.beans.core.model.IBeansModel; import org.springframework.ide.eclipse.beans.core.model.IBeansModelElementTypes; import org.springframework.ide.eclipse.beans.core.model.IBeansProject; -import org.springframework.ide.eclipse.beans.core.model.IBeansConfig.Type; import org.springframework.ide.eclipse.beans.core.model.locate.BeansConfigLocatorDefinition; import org.springframework.ide.eclipse.beans.core.model.locate.BeansConfigLocatorFactory; import org.springframework.ide.eclipse.beans.core.model.process.IBeansConfigPostProcessor; @@ -62,6 +62,7 @@ * @author Torsten Juergeleit * @author Dave Watkins * @author Christian Dupuis + * @author Martin Lippert */ public class BeansProject extends AbstractResourceModelElement implements IBeansProject, ILazyInitializedModelElement { @@ -408,6 +409,27 @@ public boolean hasConfig(String configName) { r.unlock(); } } + + public boolean hasConfig(IFile configFile, String configName, boolean includeImported) { + if (hasConfig(configName)) { + return true; + } + + if (isImportsEnabled() && includeImported) { + try { + r.lock(); + for (IBeansConfig bc : getConfigs()) { + if (hasImportedBeansConfig(configFile, bc)) { + return true; + } + } + } + finally { + r.unlock(); + } + } + return false; + } public IBeansConfig getConfig(IFile configFile, boolean includeImported) { Set beansConfigs = getConfigs(configFile, includeImported); @@ -461,6 +483,28 @@ private void checkForImportedBeansConfig(IFile file, IBeansConfig bc, Set * The single instance of {@link IBeansModel} is available from the static * method {@link BeansCorePlugin#getModel()}. + * * @author Torsten Juergeleit * @author Christian Dupuis + * @author Martin Lippert */ public interface IBeansModel extends IBeansModelElement, IModel, ILazyInitializedModelElement { @@ -36,7 +38,9 @@ public interface IBeansModel extends IBeansModelElement, IModel, ILazyInitialize /** * Returns the beans project for given project. - * @param project the project a beans project is requested for + * + * @param project + * the project a beans project is requested for */ IBeansProject getProject(IProject project); @@ -44,7 +48,9 @@ public interface IBeansModel extends IBeansModelElement, IModel, ILazyInitialize * Returns the beans project for given project name or full-qualified config * file name (including project name).
* External config files (with a leading '/') are handled too. - * @param name the name of a project or a full-qualified config file name + * + * @param name + * the name of a project or a full-qualified config file name */ IBeansProject getProject(String name); @@ -55,7 +61,9 @@ public interface IBeansModel extends IBeansModelElement, IModel, ILazyInitialize /** * Returns the beans config for given config file. - * @param configFile the config file a beans config is requested for + * + * @param configFile + * the config file a beans config is requested for */ IBeansConfig getConfig(IFile configFile); @@ -63,20 +71,24 @@ public interface IBeansModel extends IBeansModelElement, IModel, ILazyInitialize * Returns the beans config for given config file. Includes imported * {@link IImportedBeansConfig} in the search if * includeImported is true. - * @param configFile the config file a beans config is requested for - * @param includeImported true if imported configs should be queried as - * well. + * + * @param configFile + * the config file a beans config is requested for + * @param includeImported + * true if imported configs should be queried as well. * @since 2.0.3 */ IBeansConfig getConfig(IFile configFile, boolean includeImported); - + /** * Returns all beans configs for given config file. Includes imported * {@link IImportedBeansConfig} in the search if * includeImported is true. - * @param configFile the config file a beans config is requested for - * @param includeImported true if imported configs should be queried as - * well. + * + * @param configFile + * the config file a beans config is requested for + * @param includeImported + * true if imported configs should be queried as well. * @since 2.0.3 */ Set getConfigs(IFile configFile, boolean includeImported); @@ -85,7 +97,9 @@ public interface IBeansModel extends IBeansModelElement, IModel, ILazyInitialize * Returns the beans config for given full-qualified config file name * (including project name).
* External config files (with a leading '/') are handled too. - * @param name the name of a config file a beans config is requested for + * + * @param name + * the name of a config file a beans config is requested for */ IBeansConfig getConfig(String configName); @@ -93,5 +107,18 @@ public interface IBeansModel extends IBeansModelElement, IModel, ILazyInitialize * Returns a list of all configs which contain a bean with given bean class. */ Set getConfigs(String className); - + + /** + * Returns true if the given resource is a config file. Includes imported + * {@link IImportedBeansConfig} in the search if + * includeImported is true. + * + * @param configFile + * the config file a beans config is requested for + * @param includeImported + * true if imported configs should be queried as well. + * @since 3.2.0 + */ + boolean isConfig(IFile resource, boolean includeImported); + } diff --git a/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/model/IBeansProject.java b/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/model/IBeansProject.java index 09abd6b556..f4fb1f0404 100644 --- a/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/model/IBeansProject.java +++ b/plugins/org.springframework.ide.eclipse.beans.core/src/org/springframework/ide/eclipse/beans/core/model/IBeansProject.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 Spring IDE Developers + * Copyright (c) 2004, 2013 Spring IDE Developers * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,6 +21,7 @@ * @author Torsten Juergeleit * @author Dave Watkins * @author Christian Dupuis + * @author Martin Lippert */ public interface IBeansProject extends IBeansModelElement, IResourceModelElement, IBeanClassAware { @@ -81,6 +82,13 @@ public interface IBeansProject extends IBeansModelElement, IResourceModelElement */ boolean hasConfig(String configName); + /** + * Returns true if given file belongs to the list of Spring bean config files which are stored in the project + * description, including imported beans, if includeImported is set to true. + * @since 3.2.0 + */ + boolean hasConfig(IFile configFile, String configName, boolean includeImported); + /** * Returns IBeansConfig for given config file. */