[jboss-cvs] JBossAS SVN: r79272 - in projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3: util and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Oct 8 09:59:12 EDT 2008


Author: wolfc
Date: 2008-10-08 09:59:11 -0400 (Wed, 08 Oct 2008)
New Revision: 79272

Added:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/util/CollectionHelper.java
Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
Log:
EJBTHREE-1520: fixed NPE

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	2008-10-08 13:59:03 UTC (rev 79271)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	2008-10-08 13:59:11 UTC (rev 79272)
@@ -55,7 +55,6 @@
 import org.jboss.ejb3.annotation.Clustered;
 import org.jboss.ejb3.annotation.LocalBinding;
 import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.cache.ClusteredStatefulCache;
 import org.jboss.ejb3.common.lang.SerializableMethod;
 import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
@@ -68,10 +67,7 @@
 import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
 import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionProxyFactoryBase;
 import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionRemoteProxyFactory;
-import org.jboss.ejb3.proxy.factory.stateless.BaseStatelessRemoteProxyFactory;
-import org.jboss.ejb3.proxy.factory.stateless.StatelessClusterProxyFactory;
 import org.jboss.ejb3.proxy.factory.stateless.StatelessLocalProxyFactory;
-import org.jboss.ejb3.proxy.factory.stateless.StatelessRemoteProxyFactory;
 import org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase;
 import org.jboss.ejb3.proxy.objectstore.ObjectStoreBindings;
 import org.jboss.ejb3.proxy.remoting.SessionSpecRemotingMetadata;
@@ -79,6 +75,7 @@
 import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.ejb3.timerservice.TimedObjectInvoker;
 import org.jboss.ejb3.timerservice.TimerServiceFactory;
+import org.jboss.ejb3.util.CollectionHelper;
 import org.jboss.injection.WebServiceContextProxy;
 import org.jboss.injection.lang.reflect.BeanProperty;
 import org.jboss.logging.Logger;
@@ -695,7 +692,7 @@
    }
 
    @Override
-   public Object getBusinessObject(BeanContext ctx, Class intf)
+   public <T> T getBusinessObject(BeanContext<?> ctx, Class<T> intf)
    {
       assert intf != null : "intf is null";
       
@@ -707,8 +704,8 @@
           */
          Set<String> businessInterfaceNames = new HashSet<String>();
          JBossSessionBeanMetaData smd= (JBossSessionBeanMetaData)this.getXml();
-         businessInterfaceNames.addAll(smd.getBusinessRemotes());
-         businessInterfaceNames.addAll(smd.getBusinessLocals());
+         CollectionHelper.addAllIfSet(businessInterfaceNames, smd.getBusinessRemotes());
+         CollectionHelper.addAllIfSet(businessInterfaceNames, smd.getBusinessLocals());
          
          String interfaceName = intf.getName();
          
@@ -716,7 +713,7 @@
             throw new IllegalStateException("Cannot find BusinessObject for interface: " + interfaceName);
          
          String jndiName = this.getXml().determineResolvedJndiName(interfaceName);
-         return getInitialContext().lookup(jndiName);
+         return intf.cast(getInitialContext().lookup(jndiName));
       }
       catch (NamingException e)
       {

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/util/CollectionHelper.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/util/CollectionHelper.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/util/CollectionHelper.java	2008-10-08 13:59:11 UTC (rev 79272)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.util;
+
+import java.util.Collection;
+
+/**
+ * Provide helpful functions for Collection objects.
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CollectionHelper
+{
+   /**
+    * Adds all of the elements in the specified collection to the target collection if
+    * a collection is specified.
+    * 
+    * @param <E>
+    * @param target
+    * @param c collection containing elements to be added to this collection, may be null
+    * @return <tt>true</tt> if this collection changed as a result of the call
+    */
+   public static <E> boolean addAllIfSet(Collection<E> target, Collection<? extends E> c)
+   {
+      if(c == null)
+         return false;
+      return target.addAll(c);
+   }
+}




More information about the jboss-cvs-commits mailing list