[jboss-svn-commits] JBL Code SVN: r25789 - labs/jbosslabs/labs-3.0-build/integration/cs-hfurl-links/src/main/java/org/apache/struts2/views/freemarker/tags.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Mar 23 08:15:23 EDT 2009
Author: lkrzyzanek
Date: 2009-03-23 08:15:23 -0400 (Mon, 23 Mar 2009)
New Revision: 25789
Added:
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl-links/src/main/java/org/apache/struts2/views/freemarker/tags/URLModel.java
Log:
added
Added: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl-links/src/main/java/org/apache/struts2/views/freemarker/tags/URLModel.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl-links/src/main/java/org/apache/struts2/views/freemarker/tags/URLModel.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl-links/src/main/java/org/apache/struts2/views/freemarker/tags/URLModel.java 2009-03-23 12:15:23 UTC (rev 25789)
@@ -0,0 +1,84 @@
+/*
+ * JBoss.org http://jboss.org/
+ *
+ * Copyright (c) 2009 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.apache.struts2.views.freemarker.tags;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.components.Component;
+import org.apache.struts2.components.URL;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.context.ApplicationContext;
+
+import com.jivesoftware.community.lifecycle.JiveApplication;
+import com.opensymphony.xwork2.util.ValueStack;
+
+/**
+ * Extension of Struts2 URL tag.<br>
+ * Method getBean return spring bean with name 'hfURLComponent' if it's defined.<br>
+ * Otherwise standard Struts2 {@link URL} component is returned.
+ * <p>
+ * hfURLComponent bean must be child of {@link Component} class
+ *
+ * @see URL
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ */
+public class URLModel extends TagModel {
+
+ private static final Log log = LogFactory.getLog(URLModel.class);
+
+ public URLModel(ValueStack stack, HttpServletRequest req,
+ HttpServletResponse res) {
+ super(stack, req, res);
+ log.trace("New URLModel called."
+ + " Bean will be retrieved from spring configuration."
+ + " Bean name: hfURLComponent");
+ }
+
+ protected Component getBean() {
+ try {
+ Object bean = null;
+ ApplicationContext applicationContext = (ApplicationContext) JiveApplication
+ .getContext();
+ if (applicationContext != null) {
+ bean = applicationContext.getBean("hfURLComponent", new Object[] {
+ stack, req, res });
+ }
+
+ if (bean != null && bean instanceof Component) {
+ log.debug("hfURLComponent bean founded");
+ return (Component) bean;
+ }
+ } catch (NoSuchBeanDefinitionException e) {
+ // bean not found - do not log exception, it's not needed.
+ } catch (Exception e) {
+ log.error("Some unknown error occure during"
+ + " instantiation of hfURLComponent component", e);
+ }
+ log.debug("hfURLComponent bean not found."
+ + "Standard URL component is used");
+ return new URL(stack, req, res);
+ }
+
+}
Property changes on: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl-links/src/main/java/org/apache/struts2/views/freemarker/tags/URLModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the jboss-svn-commits
mailing list