Added Web Initializer to Cafe Address application
This commit is contained in:
parent
a47564a0c9
commit
f2ed42bcd2
|
@ -1,52 +1,20 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
contributor license agreements. See the NOTICE file distributed with
|
|
||||||
this work for additional information regarding copyright ownership.
|
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
(the "License"); you may not use this file except in compliance with
|
|
||||||
the License. You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung.wicket.examples.cafeaddress</groupId>
|
<groupId>com.baeldung.wicket.examples</groupId>
|
||||||
<artifactId>CafeAddress</artifactId>
|
<artifactId>cafe-address</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<!-- TODO project name -->
|
<name>CafeAddress</name>
|
||||||
<name>quickstart</name>
|
|
||||||
<description></description>
|
|
||||||
<!--
|
|
||||||
<organization>
|
|
||||||
<name>company name</name>
|
|
||||||
<url>company url</url>
|
|
||||||
</organization>
|
|
||||||
-->
|
|
||||||
<licenses>
|
|
||||||
<license>
|
|
||||||
<name>The Apache Software License, Version 2.0</name>
|
|
||||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
|
||||||
<distribution>repo</distribution>
|
|
||||||
</license>
|
|
||||||
</licenses>
|
|
||||||
<properties>
|
<properties>
|
||||||
<wicket.version>7.4.0</wicket.version>
|
<wicket.version>7.4.0</wicket.version>
|
||||||
<jetty9.version>9.2.13.v20150730</jetty9.version>
|
<jetty9.version>9.2.13.v20150730</jetty9.version>
|
||||||
<log4j.version>2.5</log4j.version>
|
<log4j.version>2.5</log4j.version>
|
||||||
<junit.version>4.12</junit.version>
|
<junit.version>4.12</junit.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<!-- allowed values: R7, 1.0, 1.5, 2.0 or none -->
|
|
||||||
<wtp.version>none</wtp.version>
|
<wtp.version>none</wtp.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -64,6 +32,24 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<!-- SPRING DEPENDENCIES -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-web</artifactId>
|
||||||
|
<version>4.1.1.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.wicket</groupId>
|
||||||
|
<artifactId>wicket-spring</artifactId>
|
||||||
|
<version>8.0.0-M1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- LOGGING DEPENDENCIES - LOG4J -->
|
<!-- LOGGING DEPENDENCIES - LOG4J -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
@ -93,6 +79,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
<finalName>CafeAddress</finalName>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<filtering>false</filtering>
|
<filtering>false</filtering>
|
||||||
|
@ -130,15 +117,23 @@
|
||||||
<inherited>true</inherited>
|
<inherited>true</inherited>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<showWarnings>true</showWarnings>
|
<showWarnings>true</showWarnings>
|
||||||
<showDeprecation>true</showDeprecation>
|
<showDeprecation>true</showDeprecation>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<configuration>
|
||||||
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-maven-plugin</artifactId>
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.baeldung.wicket.examples.cafeaddress;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ComponentScan
|
||||||
|
public class ApplicationConfiguration {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.baeldung.wicket.examples.cafeaddress;
|
||||||
|
|
||||||
|
import javax.servlet.FilterRegistration;
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
|
import org.apache.wicket.protocol.http.WicketFilter;
|
||||||
|
import org.springframework.web.WebApplicationInitializer;
|
||||||
|
import org.springframework.web.context.ContextLoaderListener;
|
||||||
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||||
|
|
||||||
|
public class WebAppInitializer implements WebApplicationInitializer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartup(ServletContext container) throws ServletException {
|
||||||
|
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
|
||||||
|
container.addListener(new ContextLoaderListener(context));
|
||||||
|
context.register(ApplicationConfiguration.class);
|
||||||
|
|
||||||
|
FilterRegistration filter = container.addFilter("CafeAddressApplication", WicketFilter.class);
|
||||||
|
filter.setInitParameter("applicationClassName", CafeAddressApplication.class.getName());
|
||||||
|
filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*");
|
||||||
|
filter.addMappingForUrlPatterns(null, false, "/*");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,32 +0,0 @@
|
||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
||||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_0.xsd"
|
|
||||||
version="3.0">
|
|
||||||
|
|
||||||
<display-name>CafeAddress</display-name>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
There are three means to configure Wickets configuration mode and they
|
|
||||||
are tested in the order given.
|
|
||||||
|
|
||||||
1) A system property: -Dwicket.configuration
|
|
||||||
2) servlet specific <init-param>
|
|
||||||
3) context specific <context-param>
|
|
||||||
|
|
||||||
The value might be either "development" (reloading when templates change) or
|
|
||||||
"deployment". If no configuration is found, "development" is the default. -->
|
|
||||||
|
|
||||||
<filter>
|
|
||||||
<filter-name>wicket.CafeAddress</filter-name>
|
|
||||||
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
|
|
||||||
<init-param>
|
|
||||||
<param-name>applicationClassName</param-name>
|
|
||||||
<param-value>com.baeldung.wicket.examples.cafeaddress.CafeAddressApplication</param-value>
|
|
||||||
</init-param>
|
|
||||||
</filter>
|
|
||||||
|
|
||||||
<filter-mapping>
|
|
||||||
<filter-name>wicket.CafeAddress</filter-name>
|
|
||||||
<url-pattern>/*</url-pattern>
|
|
||||||
</filter-mapping>
|
|
||||||
</web-app>
|
|
|
@ -1,26 +1,60 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung.wicket.examples.helloworld</groupId>
|
<groupId>com.baeldung.wicket.examples</groupId>
|
||||||
<artifactId>HelloWorld</artifactId>
|
<artifactId>hello-world</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>HelloWorld Maven Webapp</name>
|
<name>HelloWorld</name>
|
||||||
<url>http://maven.apache.org</url>
|
<dependencies>
|
||||||
<dependencies>
|
<dependency>
|
||||||
<dependency>
|
<groupId>junit</groupId>
|
||||||
<groupId>junit</groupId>
|
<artifactId>junit</artifactId>
|
||||||
<artifactId>junit</artifactId>
|
<version>3.8.1</version>
|
||||||
<version>3.8.1</version>
|
<scope>test</scope>
|
||||||
<scope>test</scope>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
<dependency>
|
<groupId>org.apache.wicket</groupId>
|
||||||
<groupId>org.apache.wicket</groupId>
|
<artifactId>wicket-core</artifactId>
|
||||||
<artifactId>wicket-core</artifactId>
|
<version>8.0.0-M1</version>
|
||||||
<version>8.0.0-M1</version>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
</dependencies>
|
<groupId>org.springframework</groupId>
|
||||||
<build>
|
<artifactId>spring-web</artifactId>
|
||||||
<finalName>HelloWorld</finalName>
|
<version>4.1.1.RELEASE</version>
|
||||||
</build>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.wicket</groupId>
|
||||||
|
<artifactId>wicket-spring</artifactId>
|
||||||
|
<version>8.0.0-M1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<finalName>HelloWorld</finalName>
|
||||||
|
<plugins>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.5.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<configuration>
|
||||||
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.baeldung.wicket.examples.helloworld;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ComponentScan
|
||||||
|
public class ApplicationConfiguration {
|
||||||
|
|
||||||
|
}
|
|
@ -3,10 +3,20 @@ package com.baeldung.wicket.examples.helloworld;
|
||||||
|
|
||||||
import org.apache.wicket.Page;
|
import org.apache.wicket.Page;
|
||||||
import org.apache.wicket.protocol.http.WebApplication;
|
import org.apache.wicket.protocol.http.WebApplication;
|
||||||
|
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
public class HelloWorldApplication extends WebApplication {
|
public class HelloWorldApplication extends WebApplication {
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Page> getHomePage() {
|
public Class<? extends Page> getHomePage() {
|
||||||
return HelloWorld.class;
|
return HelloWorld.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
super.init();
|
||||||
|
getComponentInstantiationListeners().add(new SpringComponentInjector(this));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.baeldung.wicket.examples.helloworld;
|
||||||
|
|
||||||
|
import javax.servlet.FilterRegistration;
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
|
import org.apache.wicket.protocol.http.WicketFilter;
|
||||||
|
import org.springframework.web.WebApplicationInitializer;
|
||||||
|
import org.springframework.web.context.ContextLoaderListener;
|
||||||
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||||
|
|
||||||
|
public class WebAppInitializer implements WebApplicationInitializer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartup(ServletContext container) throws ServletException {
|
||||||
|
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
|
||||||
|
container.addListener(new ContextLoaderListener(context));
|
||||||
|
context.register(ApplicationConfiguration.class);
|
||||||
|
|
||||||
|
FilterRegistration filter = container.addFilter("HelloWorldApplication", WicketFilter.class);
|
||||||
|
filter.setInitParameter("applicationClassName", HelloWorldApplication.class.getName());
|
||||||
|
filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*");
|
||||||
|
filter.addMappingForUrlPatterns(null, false, "/*");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,19 +0,0 @@
|
||||||
<!DOCTYPE web-app PUBLIC
|
|
||||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
|
||||||
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
|
||||||
|
|
||||||
<web-app>
|
|
||||||
<display-name>Hello World</display-name>
|
|
||||||
<filter>
|
|
||||||
<filter-name>HelloWorldApplication</filter-name>
|
|
||||||
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
|
|
||||||
<init-param>
|
|
||||||
<param-name>applicationClassName</param-name>
|
|
||||||
<param-value>com.baeldung.wicket.examples.helloworld.HelloWorldApplication</param-value>
|
|
||||||
</init-param>
|
|
||||||
</filter>
|
|
||||||
<filter-mapping>
|
|
||||||
<filter-name>HelloWorldApplication</filter-name>
|
|
||||||
<url-pattern>/*</url-pattern>
|
|
||||||
</filter-mapping>
|
|
||||||
</web-app>
|
|
Loading…
Reference in New Issue