|
|
@ -1,18 +1,38 @@ |
|
|
|
package org.pqh.core.annotation; |
|
|
|
package org.pqh.core.annotation; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.pqh.core.util.LogManger; |
|
|
|
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.context.annotation.ImportSelector; |
|
|
|
import org.springframework.context.annotation.ImportSelector; |
|
|
|
import org.springframework.core.type.AnnotationMetadata; |
|
|
|
import org.springframework.core.type.AnnotationMetadata; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Created by reborn on 2017/9/20. |
|
|
|
* Created by reborn on 2017/9/20. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class ConfigurationSelector implements ImportSelector{ |
|
|
|
public class ConfigurationSelector implements ImportSelector,LogManger{ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String[] selectImports(AnnotationMetadata annotationMetadata) { |
|
|
|
public String[] selectImports(AnnotationMetadata annotationMetadata) { |
|
|
|
String path=this.getClass().getResource("").getPath(); |
|
|
|
String appPath=this.getClass().getResource("").getPath(); |
|
|
|
if(path.contains("core")){ |
|
|
|
log.info("appPath="+appPath); |
|
|
|
return new String[]{EnableWebCrawlerConfiguration.class.getName()}; |
|
|
|
//根据配置类判断
|
|
|
|
}else{ |
|
|
|
if(annotationMetadata.getClassName().equals("org.pqh.config.SpringConfig")){ |
|
|
|
|
|
|
|
return new String[]{"org.pqh.config.WebCrawlerConfig"}; |
|
|
|
|
|
|
|
}//根据配置类已有注解判断
|
|
|
|
|
|
|
|
else if(annotationMetadata.getAnnotationTypes().contains(Configuration.class.getName())){ |
|
|
|
|
|
|
|
return new String[]{"org.pqh.aaaaaaaaaaaa"}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//根据配置类路径判断
|
|
|
|
|
|
|
|
else if(appPath!=null&&appPath.contains("/web/WEB-INF")){ |
|
|
|
|
|
|
|
return new String[]{"org.pqh.bbbbbbbbbb"}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//根据系统信息
|
|
|
|
|
|
|
|
else if("XXXX".equals(System.getProperty("XXXX"))){ |
|
|
|
|
|
|
|
return new String[]{"org.pqh.cccccccccc"}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//根据环境变量
|
|
|
|
|
|
|
|
else if("XXX".equals(System.getenv("XXXX"))){ |
|
|
|
|
|
|
|
return new String[]{"org.pqh.ddddddddddd"}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else{ |
|
|
|
return new String[0]; |
|
|
|
return new String[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|