Return-Path: X-Original-To: apmail-struts-commits-archive@minotaur.apache.org Delivered-To: apmail-struts-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B1C0296C3 for ; Wed, 29 Feb 2012 15:14:45 +0000 (UTC) Received: (qmail 85320 invoked by uid 500); 29 Feb 2012 15:14:45 -0000 Delivered-To: apmail-struts-commits-archive@struts.apache.org Received: (qmail 85246 invoked by uid 500); 29 Feb 2012 15:14:44 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 85237 invoked by uid 99); 29 Feb 2012 15:14:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Feb 2012 15:14:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Feb 2012 15:14:43 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5224B23889BB for ; Wed, 29 Feb 2012 15:14:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1295146 - /struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Bean.java Date: Wed, 29 Feb 2012 15:14:23 -0000 To: commits@struts.apache.org From: lukaszlenart@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120229151423.5224B23889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: lukaszlenart Date: Wed Feb 29 15:14:22 2012 New Revision: 1295146 URL: http://svn.apache.org/viewvc?rev=1295146&view=rev Log: WW-3748 s:bean shouldn't load class, just delegate that to ObjectFactory Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Bean.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Bean.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Bean.java?rev=1295146&r1=1295145&r2=1295146&view=diff ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Bean.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Bean.java Wed Feb 29 15:14:22 2012 @@ -21,18 +21,16 @@ package org.apache.struts2.components; -import java.io.Writer; - -import org.apache.struts2.views.annotations.StrutsTag; -import org.apache.struts2.views.annotations.StrutsTagAttribute; - import com.opensymphony.xwork2.ObjectFactory; import com.opensymphony.xwork2.inject.Inject; -import com.opensymphony.xwork2.util.ClassLoaderUtil; import com.opensymphony.xwork2.util.ValueStack; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory; import com.opensymphony.xwork2.util.reflection.ReflectionProvider; +import org.apache.struts2.views.annotations.StrutsTag; +import org.apache.struts2.views.annotations.StrutsTagAttribute; + +import java.io.Writer; /** * @@ -94,8 +92,8 @@ import com.opensymphony.xwork2.util.refl * * @see Param */ -@StrutsTag(name="bean", tldTagClass="org.apache.struts2.views.jsp.BeanTag", - description="Instantiate a JavaBean and place it in the context") +@StrutsTag(name = "bean", tldTagClass = "org.apache.struts2.views.jsp.BeanTag", + description = "Instantiate a JavaBean and place it in the context") public class Bean extends ContextBean { protected static final Logger LOG = LoggerFactory.getLogger(Bean.class); @@ -107,12 +105,12 @@ public class Bean extends ContextBean { public Bean(ValueStack stack) { super(stack); } - + @Inject public void setObjectFactory(ObjectFactory objectFactory) { this.objectFactory = objectFactory; } - + @Inject public void setReflectionProvider(ReflectionProvider prov) { this.reflectionProvider = prov; @@ -124,11 +122,10 @@ public class Bean extends ContextBean { ValueStack stack = getStack(); try { - String beanName = findString(name, "name", "Bean name is required. Example: com.acme.FooBean"); - bean = objectFactory.buildBean(ClassLoaderUtil.loadClass(beanName, getClass()), stack.getContext()); + String beanName = findString(name, "name", "Bean name is required. Example: com.acme.FooBean or proper Spring bean ID"); + bean = objectFactory.buildBean(beanName, stack.getContext(), false); } catch (Exception e) { LOG.error("Could not instantiate bean", e); - return false; } @@ -152,9 +149,9 @@ public class Bean extends ContextBean { reflectionProvider.setProperty(key, value, bean, getStack().getContext()); } - @StrutsTagAttribute(description="The class name of the bean to be instantiated (must respect JavaBean specification)", - required=true) + @StrutsTagAttribute(description = "The class name of the bean to be instantiated (must respect JavaBean specification)", required = true) public void setName(String name) { this.name = name; } + }