28 lines
846 B
Java
28 lines
846 B
Java
package hello.container;
|
|
|
|
import jakarta.servlet.ServletContainerInitializer;
|
|
import jakarta.servlet.ServletContext;
|
|
import jakarta.servlet.ServletException;
|
|
import jakarta.servlet.annotation.HandlesTypes;
|
|
|
|
import java.util.Set;
|
|
|
|
@HandlesTypes(AppInit.class)
|
|
public class MyContainerInitV2 implements ServletContainerInitializer {
|
|
@Override
|
|
public void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletException {
|
|
System.out.println("MyContainerInitV2.onStartup");
|
|
System.out.println("c = " + c);
|
|
|
|
|
|
for (Class<?> appInitClass : c) {
|
|
try {
|
|
AppInit appInit = (AppInit) appInitClass.getDeclaredConstructor().newInstance();
|
|
appInit.onStartup(ctx);
|
|
} catch (Exception e) {
|
|
throw new RuntimeException();
|
|
}
|
|
}
|
|
}
|
|
}
|