[jboss-cvs] JBossAS SVN: r65714 - in trunk/spring-int/src/main/org/jboss: spring/support and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 1 10:44:10 EDT 2007
Author: alesj
Date: 2007-10-01 10:44:10 -0400 (Mon, 01 Oct 2007)
New Revision: 65714
Modified:
trunk/spring-int/src/main/org/jboss/annotation/spring/Spring.java
trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java
Log:
Exposing BeanFactory jndiName as optional.
Modified: trunk/spring-int/src/main/org/jboss/annotation/spring/Spring.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/annotation/spring/Spring.java 2007-10-01 14:10:44 UTC (rev 65713)
+++ trunk/spring-int/src/main/org/jboss/annotation/spring/Spring.java 2007-10-01 14:44:10 UTC (rev 65714)
@@ -36,7 +36,7 @@
public @interface Spring
{
- String jndiName();
+ String jndiName() default "";
String bean() default "";
Modified: trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java
===================================================================
--- trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java 2007-10-01 14:10:44 UTC (rev 65713)
+++ trunk/spring-int/src/main/org/jboss/spring/support/SpringInjectionSupport.java 2007-10-01 14:44:10 UTC (rev 65714)
@@ -112,9 +112,25 @@
return m.getName().startsWith("set") && m.getParameterTypes().length == 1;
}
+ /**
+ * Get jndi name for bean factory.
+ * Simple check for null or empty string is applied.
+ * You can override this in subclasses for any extra
+ * jndi name handling.
+ *
+ * @param jndiName the current jndi name
+ * @return jndiName parameter
+ */
+ protected String getJndiName(String jndiName)
+ {
+ if (jndiName == null || jndiName.length() == 0)
+ throw new IllegalArgumentException("Empty BeanFactory jndi name.");
+ return jndiName;
+ }
+
private Object getObjectFromBeanFactory(Spring spring, String defaultBeanName, Class beanType) throws Exception
{
- BeanFactory beanFactory = (BeanFactory) Util.lookup(spring.jndiName(), BeanFactory.class);
+ BeanFactory beanFactory = (BeanFactory) Util.lookup(getJndiName(spring.jndiName()), BeanFactory.class);
String beanName = spring.bean();
if (beanName != null && beanName.length() > 0)
{
More information about the jboss-cvs-commits
mailing list