Repository: wicket Updated Branches: refs/heads/master 10207bfcc -> edeb2ccd8
WICKET-5697 Rework Spring application to use annotations based configuration Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/edeb2ccd Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/edeb2ccd Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/edeb2ccd Branch: refs/heads/master Commit: edeb2ccd8ad665ac4447f3cb9ef75b2dbbf78b37 Parents: 10207bf Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Wed Sep 10 14:55:35 2014 +0300 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Wed Sep 10 14:55:35 2014 +0300 ---------------------------------------------------------------------- wicket-examples/pom.xml | 10 +++++ .../examples/spring/common/SpringConfig.java | 46 ++++++++++++++++++++ .../src/main/resources/applicationContext.xml | 29 ------------ wicket-examples/src/main/webapp/WEB-INF/web.xml | 26 ++++++----- 4 files changed, 72 insertions(+), 39 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/edeb2ccd/wicket-examples/pom.xml ---------------------------------------------------------------------- diff --git a/wicket-examples/pom.xml b/wicket-examples/pom.xml index a1e2dc6..3345a19 100644 --- a/wicket-examples/pom.xml +++ b/wicket-examples/pom.xml @@ -113,6 +113,16 @@ <dependency> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>jetty-all-server</artifactId> + <exclusions> + <exclusion> + <!-- exclude because the same jar comes from JBoss Weld and the following error occurs: + class "javax.annotation.ManagedBean"'s signer information does not match signer + information of other classes in the same package + --> + <groupId>org.eclipse.jetty.orbit</groupId> + <artifactId>javax.annotation</artifactId> + </exclusion> + </exclusions> </dependency> <!-- EL impl for bean validation demo --> <dependency> http://git-wip-us.apache.org/repos/asf/wicket/blob/edeb2ccd/wicket-examples/src/main/java/org/apache/wicket/examples/spring/common/SpringConfig.java ---------------------------------------------------------------------- diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/spring/common/SpringConfig.java b/wicket-examples/src/main/java/org/apache/wicket/examples/spring/common/SpringConfig.java new file mode 100644 index 0000000..3d9b6e3 --- /dev/null +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/spring/common/SpringConfig.java @@ -0,0 +1,46 @@ +/* + * 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. + */ +package org.apache.wicket.examples.spring.common; + +import org.apache.wicket.examples.spring.common.web.ExampleApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Spring application context + */ +@Configuration +public class SpringConfig +{ + /** + * @return the Wicket application + */ + @Bean + public ExampleApplication application() + { + return new ExampleApplication(); + } + + /** + * @return the contacts DAO + */ + @Bean + public ContactDao contactDao() + { + return new ContactDaoImpl(); + } +} http://git-wip-us.apache.org/repos/asf/wicket/blob/edeb2ccd/wicket-examples/src/main/resources/applicationContext.xml ---------------------------------------------------------------------- diff --git a/wicket-examples/src/main/resources/applicationContext.xml b/wicket-examples/src/main/resources/applicationContext.xml deleted file mode 100644 index 89d7e58..0000000 --- a/wicket-examples/src/main/resources/applicationContext.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?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. ---> -<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> - -<beans> - <!-- - setup contact dao - --> - <bean id="contactDao" class="org.apache.wicket.examples.spring.common.ContactDaoImpl"/> - - <!-- setup wicket application --> - <bean id="wicketApplication" class="org.apache.wicket.examples.spring.common.web.ExampleApplication"/> - -</beans> http://git-wip-us.apache.org/repos/asf/wicket/blob/edeb2ccd/wicket-examples/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/wicket-examples/src/main/webapp/WEB-INF/web.xml b/wicket-examples/src/main/webapp/WEB-INF/web.xml index fb30dc0..f7d1c7b 100644 --- a/wicket-examples/src/main/webapp/WEB-INF/web.xml +++ b/wicket-examples/src/main/webapp/WEB-INF/web.xml @@ -45,15 +45,6 @@ <param-value>deployment</param-value> </context-param> - <!-- - Parameter used by Spring to locate its context configuration used for creating - a WebApplicationContext. - --> - <context-param> - <param-name>contextConfigLocation</param-name> - <param-value>classpath:applicationContext.xml</param-value> - </context-param> - <filter> <filter-name>HomePageApplication</filter-name> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> @@ -804,7 +795,22 @@ <filter-mapping> <filter-name>BeanValidation</filter-name> <url-pattern>/bean-validation/*</url-pattern> - </filter-mapping> + </filter-mapping> + + <!-- + Parameter used by Spring to locate its context configuration used for creating + a WebApplicationContext. + --> + <context-param> + <param-name>contextClass</param-name> + <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value> + </context-param> + + <context-param> + <param-name>contextConfigLocation</param-name> + <param-value>org.apache.wicket.examples.spring.common.SpringConfig</param-value> + </context-param> + <!-- LISTENER --> <listener>
