0

I want to load spring 4.0 resources conditionally, so below code can do the job (How to achieve conditional resource import in a Spring XML context?):

@Configuration
@Conditional(MyConditionalConfiguration.Condition)
@ImportResource("/com/example/context-fragment.xml")
public class MyConditionalConfiguration {
    static class Condition implements ConfigurationCondition {
         @Override
         public ConfigurationPhase getConfigurationPhase() {
             return ConfigurationPhase.PARSE_CONFIGURATION;
         }
         @Override
         public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
             // only load context-fragment.xml if the system property is defined
             return System.getProperty("com.example.context-fragment") != null;
         }
    }
}

How ever this code can not be weaved with AspectJ, the problem supposed to be for @Conditional

The trace is

org.aspectj.weaver.BCException
at org.aspectj.ajdt.internal.core.builder.AjState.recordClassFile(AjState.java:1519)
at org.aspectj.ajdt.internal.core.builder.AjState.noteResult(AjState.java:1325)
at org.aspectj.ajdt.internal.core.builder.AjBuildManager$3.acceptResult(AjBuildManager.java:1061)
at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterProcessing(AjPipeliningCompilerAdapter.java:426)
at org.aspectj.ajdt.intern ... .0_21-64\jre\lib\ext\sunmscapi.jar;E:\jdk1.7.0_21-64\jre\lib\ext\zipfs.jar;D:\eclipse\\plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar;
Community
  • 1
  • 1
Alireza Fattahi
  • 42,517
  • 14
  • 123
  • 173
  • possible duplicate of [Aspectj for anotations with classes not working](http://stackoverflow.com/questions/27498660/aspectj-for-anotations-with-classes-not-working) – kriegaex Dec 18 '14 at 12:22
  • 1
    I have already answered this duplicate question at http://stackoverflow.com/a/27545593/1082681 – kriegaex Dec 18 '14 at 12:23

0 Answers0