refined #BAEL-100 and remove Java EE app for simplicity (#1168)
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
491d36e745
commit
cf87412c42
@@ -1,28 +0,0 @@
|
||||
package com.baeldung.annotation.servletcomponentscan;
|
||||
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
import javax.enterprise.context.Initialized;
|
||||
import javax.enterprise.event.Observes;
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
@ApplicationScoped
|
||||
public class JavaEEApp {
|
||||
|
||||
private ServletContext context;
|
||||
|
||||
/**
|
||||
* act as a servletContext provider
|
||||
*/
|
||||
private void setContext(@Observes @Initialized(ApplicationScoped.class) final ServletContext context) {
|
||||
if (this.context != null) {
|
||||
throw new IllegalStateException("app context started twice");
|
||||
}
|
||||
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public ServletContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -9,13 +9,13 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
* <ul><li>
|
||||
* <code>@ServletComponentScan</code>
|
||||
* </li><li>
|
||||
* <code>@ServletComponentScan(basePackages = "com.baeldung.annotation.servletcomponentscan.javaee")</code>
|
||||
* <code>@ServletComponentScan(basePackages = "com.baeldung.annotation.servletcomponentscan.components")</code>
|
||||
* </li><li>
|
||||
* <code>@ServletComponentScan(basePackageClasses = {AttrListener.class, HelloFilter.class, HelloServlet.class, EchoServlet.class})</code>
|
||||
* </li></ul>
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@ServletComponentScan("com.baeldung.annotation.servletcomponentscan.javaee")
|
||||
@ServletComponentScan("com.baeldung.annotation.servletcomponentscan.components")
|
||||
public class SpringBootAnnotatedApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = "com.baeldung.annotation.servletcomponentscan.javaee")
|
||||
@ComponentScan(basePackages = "com.baeldung.annotation.servletcomponentscan.components")
|
||||
public class SpringBootPlainApp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.annotation.servletcomponentscan.javaee;
|
||||
package com.baeldung.annotation.servletcomponentscan.components;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.annotation.servletcomponentscan.javaee;
|
||||
package com.baeldung.annotation.servletcomponentscan.components;
|
||||
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
@@ -6,7 +6,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.CopyOption;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.baeldung.annotation.servletcomponentscan.javaee;
|
||||
package com.baeldung.annotation.servletcomponentscan.components;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package com.baeldung.annotation.servletcomponentscan.javaee;
|
||||
package com.baeldung.annotation.servletcomponentscan.components;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebInitParam;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
Reference in New Issue
Block a user