Switches to Log4j2 and uses more convenient name for action
Project: http://git-wip-us.apache.org/repos/asf/struts-examples/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-examples/commit/4b04a073 Tree: http://git-wip-us.apache.org/repos/asf/struts-examples/tree/4b04a073 Diff: http://git-wip-us.apache.org/repos/asf/struts-examples/diff/4b04a073 Branch: refs/heads/master Commit: 4b04a0731890583391610dac4bb01673d2972b45 Parents: a0e01e9 Author: Lukasz Lenart <lukasz.len...@gmail.com> Authored: Fri May 12 09:07:00 2017 +0200 Committer: Lukasz Lenart <lukasz.len...@gmail.com> Committed: Fri May 12 16:47:29 2017 +0200 ---------------------------------------------------------------------- .../java/org/apache/struts/example/Theme.java | 56 -------------------- .../org/apache/struts/example/ThemeAction.java | 56 ++++++++++++++++++++ .../example/ThemeDescriptorConverter.java | 6 +-- .../java/org/apache/struts/model/Themes.java | 2 +- type-conversion/src/main/resources/example.xml | 2 +- 5 files changed, 61 insertions(+), 61 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts-examples/blob/4b04a073/type-conversion/src/main/java/org/apache/struts/example/Theme.java ---------------------------------------------------------------------- diff --git a/type-conversion/src/main/java/org/apache/struts/example/Theme.java b/type-conversion/src/main/java/org/apache/struts/example/Theme.java deleted file mode 100644 index 198830f..0000000 --- a/type-conversion/src/main/java/org/apache/struts/example/Theme.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * $Id$ - * - * 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.struts.example; - -import com.opensymphony.xwork2.ActionSupport; -import com.opensymphony.xwork2.util.logging.Logger; -import com.opensymphony.xwork2.util.logging.LoggerFactory; -import org.apache.struts.model.ThemeDescriptor; -import org.apache.struts.model.Themes; - -import java.util.Map; - -public class Theme extends ActionSupport { - - private static final Logger LOG = LoggerFactory.getLogger(Theme.class); - - private Map<String, ThemeDescriptor> themes = Themes.list(); - private ThemeDescriptor selectedTheme = Themes.get("simple"); - - public String execute() throws Exception { - return SUCCESS; - } - - public Map<String, ThemeDescriptor> getThemes() { - return themes; - } - - public ThemeDescriptor getSelectedTheme() { - LOG.info("Existing theme: #0", String.valueOf(selectedTheme)); - return selectedTheme; - } - - public void setSelectedTheme(ThemeDescriptor selectedTheme) { - LOG.info("Selected theme: #0", String.valueOf(selectedTheme)); - this.selectedTheme = selectedTheme; - } -} http://git-wip-us.apache.org/repos/asf/struts-examples/blob/4b04a073/type-conversion/src/main/java/org/apache/struts/example/ThemeAction.java ---------------------------------------------------------------------- diff --git a/type-conversion/src/main/java/org/apache/struts/example/ThemeAction.java b/type-conversion/src/main/java/org/apache/struts/example/ThemeAction.java new file mode 100644 index 0000000..c3c9bfe --- /dev/null +++ b/type-conversion/src/main/java/org/apache/struts/example/ThemeAction.java @@ -0,0 +1,56 @@ +/* + * $Id$ + * + * 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.struts.example; + +import com.opensymphony.xwork2.ActionSupport; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.struts.model.ThemeDescriptor; +import org.apache.struts.model.Themes; + +import java.util.Map; + +public class ThemeAction extends ActionSupport { + + private static final Logger LOG = LogManager.getLogger(ThemeAction.class); + + private Map<String, ThemeDescriptor> themes = Themes.list(); + private ThemeDescriptor selectedTheme = Themes.get("simple"); + + public String execute() throws Exception { + return SUCCESS; + } + + public Map<String, ThemeDescriptor> getThemes() { + return themes; + } + + public ThemeDescriptor getSelectedTheme() { + LOG.info("Existing theme: #0", String.valueOf(selectedTheme)); + return selectedTheme; + } + + public void setSelectedTheme(ThemeDescriptor selectedTheme) { + LOG.info("Selected theme: #0", String.valueOf(selectedTheme)); + this.selectedTheme = selectedTheme; + } +} http://git-wip-us.apache.org/repos/asf/struts-examples/blob/4b04a073/type-conversion/src/main/java/org/apache/struts/example/ThemeDescriptorConverter.java ---------------------------------------------------------------------- diff --git a/type-conversion/src/main/java/org/apache/struts/example/ThemeDescriptorConverter.java b/type-conversion/src/main/java/org/apache/struts/example/ThemeDescriptorConverter.java index 78fcbb4..388495f 100644 --- a/type-conversion/src/main/java/org/apache/struts/example/ThemeDescriptorConverter.java +++ b/type-conversion/src/main/java/org/apache/struts/example/ThemeDescriptorConverter.java @@ -1,8 +1,8 @@ package org.apache.struts.example; import com.opensymphony.xwork2.conversion.TypeConversionException; -import com.opensymphony.xwork2.util.logging.Logger; -import com.opensymphony.xwork2.util.logging.LoggerFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.struts.model.ThemeDescriptor; import org.apache.struts.model.Themes; import org.apache.struts2.util.StrutsTypeConverter; @@ -11,7 +11,7 @@ import java.util.Map; public class ThemeDescriptorConverter extends StrutsTypeConverter { - private static final Logger LOG = LoggerFactory.getLogger(ThemeDescriptorConverter.class); + private static final Logger LOG = LogManager.getLogger(ThemeDescriptorConverter.class); @SuppressWarnings("rawtypes") @Override http://git-wip-us.apache.org/repos/asf/struts-examples/blob/4b04a073/type-conversion/src/main/java/org/apache/struts/model/Themes.java ---------------------------------------------------------------------- diff --git a/type-conversion/src/main/java/org/apache/struts/model/Themes.java b/type-conversion/src/main/java/org/apache/struts/model/Themes.java index 84cbefa..28d08af 100644 --- a/type-conversion/src/main/java/org/apache/struts/model/Themes.java +++ b/type-conversion/src/main/java/org/apache/struts/model/Themes.java @@ -9,7 +9,7 @@ public class Themes { private static Map<String, ThemeDescriptor> themes; static { - themes = new HashMap<String, ThemeDescriptor>(); + themes = new HashMap<>(); themes.put("simple", new ThemeDescriptor("simple", "Simple Theme", "themes/simple")); themes.put("extended", new ThemeDescriptor("extended", "Extended Theme", "themes/extended")); } http://git-wip-us.apache.org/repos/asf/struts-examples/blob/4b04a073/type-conversion/src/main/resources/example.xml ---------------------------------------------------------------------- diff --git a/type-conversion/src/main/resources/example.xml b/type-conversion/src/main/resources/example.xml index f255867..0cf1640 100644 --- a/type-conversion/src/main/resources/example.xml +++ b/type-conversion/src/main/resources/example.xml @@ -11,7 +11,7 @@ <default-action-ref name="Theme" /> - <action name="Theme" class="org.apache.struts.example.Theme"> + <action name="Theme" class="org.apache.struts.example.ThemeAction"> <result>/WEB-INF/example/Theme.jsp</result> </action>