log added
This commit is contained in:
parent
a7dcafd4a3
commit
c46ddc6ae0
13
.classpath
13
.classpath
|
@ -11,5 +11,18 @@
|
|||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -3,12 +3,19 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="common-smartgears-app">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -18,4 +25,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
</project-modules>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v3.0.1-SNAPSHOT] - [2024-02-02]
|
||||
|
||||
## [v3.0.0] - [2022-05-13]
|
||||
|
||||
porting to new IAM
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -12,7 +12,7 @@
|
|||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-smartgears-app</artifactId>
|
||||
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.1-SNAPSHOT</version>
|
||||
<name>Smartgears Application</name>
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-smartgears-bom</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.1-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -50,8 +50,8 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<groupId>io.github.classgraph</groupId>
|
||||
<artifactId>classgraph</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package org.gcube.smartgears;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import javax.servlet.annotation.WebListener;
|
||||
|
@ -11,14 +11,14 @@ import javax.servlet.annotation.WebListener;
|
|||
import org.gcube.smartgears.annotations.ManagedBy;
|
||||
import org.gcube.smartgears.application.manager.AppManagerObserver;
|
||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.SubTypesScanner;
|
||||
import org.reflections.scanners.TypeAnnotationsScanner;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.github.classgraph.ClassGraph;
|
||||
import io.github.classgraph.ClassInfo;
|
||||
import io.github.classgraph.ClassInfoList;
|
||||
import io.github.classgraph.ScanResult;
|
||||
|
||||
@WebListener
|
||||
public class ContextListener implements ServletContextListener {
|
||||
|
||||
|
@ -38,26 +38,36 @@ public class ContextListener implements ServletContextListener {
|
|||
|
||||
log.info("configuring context provider for {}",context.name());
|
||||
ContextProvider.set(context);
|
||||
|
||||
|
||||
retrieveAndRegisterManagers(context);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void retrieveAndRegisterManagers(ApplicationContext context) {
|
||||
ApplicationManagerProvider.init(context);
|
||||
|
||||
Collection<URL> urls = ClasspathHelper.forClassLoader();
|
||||
Set<Class<?>> annotatedManaged;
|
||||
|
||||
try (ScanResult result = new ClassGraph().enableClassInfo().enableAnnotationInfo().scan()) {
|
||||
|
||||
ClassInfoList classInfos = result.getClassesWithAnnotation(ManagedBy.class.getName());
|
||||
|
||||
annotatedManaged = classInfos.stream().map(ClassInfo::loadClass)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
/*
|
||||
Collection<URL> urls = ClasspathHelper.forJavaClassPath();
|
||||
urls.removeIf(url -> url.toString().endsWith(".so") || url.toString().endsWith(".zip") );
|
||||
|
||||
|
||||
ConfigurationBuilder reflectionConf = new ConfigurationBuilder().addUrls(urls).setScanners(new TypeAnnotationsScanner(), new SubTypesScanner());
|
||||
ConfigurationBuilder reflectionConf = new ConfigurationBuilder().addUrls(urls).addClassLoaders(Thread.currentThread().getContextClassLoader()).setScanners(new TypeAnnotationsScanner(), new SubTypesScanner());
|
||||
|
||||
Reflections reflection = new Reflections(reflectionConf);
|
||||
|
||||
Set<Class<?>> toInitialize = reflection.getTypesAnnotatedWith(ManagedBy.class);
|
||||
*/
|
||||
Set<Class<? extends ApplicationManager>> managers = new HashSet<Class<? extends ApplicationManager>>();
|
||||
for (Class<?> initializer: toInitialize ){
|
||||
for (Class<?> initializer: annotatedManaged ){
|
||||
ManagedBy manageBy = initializer.getAnnotation(ManagedBy.class);
|
||||
log.info("ApplicationManager added {} to {} @ {}", manageBy.value().getSimpleName(), initializer.getSimpleName(), context.name());
|
||||
managers.add(manageBy.value());
|
||||
|
|
Loading…
Reference in New Issue