[jboss-cvs] JBossAS SVN: r102383 - in projects/ejb3/components/nointerface/trunk/impl: src/main/java/org/jboss/ejb3/nointerface/impl/invocationhandler and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Mar 14 15:28:45 EDT 2010


Author: jaikiran
Date: 2010-03-14 15:28:44 -0400 (Sun, 14 Mar 2010)
New Revision: 102383

Added:
   projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/SessionAwareNoInterfaceViewJNDIBinder.java
   projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/SessionlessNoInterfaceViewJNDIBinder.java
Removed:
   projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/StatefulNoInterfaceJNDIBinder.java
   projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/StatelessNoInterfaceJNDIBinder.java
   projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/JavassistInvocationHandlerAdapter.java
   projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/NoInterfaceViewMethodFilter.java
   projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/factory/JavassistNoInterfaceViewFactory.java
   projects/ejb3/components/nointerface/trunk/impl/src/test/java/org/jboss/ejb3/nointerface/impl/test/factory/unit/NoInterfaceViewFactoryTestCase.java
Modified:
   projects/ejb3/components/nointerface/trunk/impl/pom.xml
   projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/invocationhandler/NoInterfaceViewInvocationHandler.java
   projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/NoInterfaceViewJNDIBinderFacade.java
   projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/factory/StatefulNoInterfaceViewFacade.java
Log:
EJBTHREE-2044 EJBTHREE-2043 [1] nointerface view implementation will now handle singleton beans too. [2] Proxy creation will be done through the external proxy component implementation

Modified: projects/ejb3/components/nointerface/trunk/impl/pom.xml
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/pom.xml	2010-03-14 17:41:20 UTC (rev 102382)
+++ projects/ejb3/components/nointerface/trunk/impl/pom.xml	2010-03-14 19:28:44 UTC (rev 102383)
@@ -24,6 +24,7 @@
         <version.org.jboss.microcontainer>2.0.8.GA</version.org.jboss.microcontainer>
         <version.org.jboss_jbossxb>2.0.1.GA</version.org.jboss_jbossxb>
         <version.javassist>3.7.1.GA</version.javassist>
+        <version.ejb3.javassist.proxy>0.1.0-SNAPSHOT</version.ejb3.javassist.proxy>
         <version.org.jboss.ejb3_jboss-ejb3-test>1.0.0</version.org.jboss.ejb3_jboss-ejb3-test>
         <version.metadata_ejb>2.0.0-alpha-5</version.metadata_ejb>
         <version.metadata_ear>2.0.0.Alpha</version.metadata_ear>
@@ -76,11 +77,11 @@
         </dependency>
 
 
-        <!-- Javassist  -->
+        <!-- javassist proxy factory  -->
         <dependency>
-            <groupId>javassist</groupId>
-            <artifactId>javassist</artifactId>
-            <version>${version.javassist}</version>
+            <groupId>org.jboss.ejb3.proxy</groupId>
+            <artifactId>proxy-javassist</artifactId>
+            <version>${version.ejb3.javassist.proxy}</version>
         </dependency>
 
         <!-- JBoss logging -->
@@ -190,9 +191,9 @@
 
         <!-- The EJB3.1 API support (ex: @LocalBean) -->
         <dependency>
-            <groupId>org.jboss.javaee</groupId>
-            <artifactId>jboss-ejb-api_3.1</artifactId>
-            <version>1.0-alpha-1</version>
+            <groupId>org.jboss.spec.javax.ejb</groupId>
+            <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+            <version>1.0.0.Beta1</version>
         </dependency>
 
 

Modified: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/invocationhandler/NoInterfaceViewInvocationHandler.java
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/invocationhandler/NoInterfaceViewInvocationHandler.java	2010-03-14 17:41:20 UTC (rev 102382)
+++ projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/invocationhandler/NoInterfaceViewInvocationHandler.java	2010-03-14 19:28:44 UTC (rev 102383)
@@ -24,6 +24,7 @@
 import java.io.Serializable;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.ejb3.endpoint.Endpoint;
@@ -117,6 +118,14 @@
     */
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
    {
+      // check to see if this method is expected to be handled
+      // by the nointerface view (for ex: only public methods of bean are allowed
+      // on nointerface view)
+      if (!isHandled(method))
+      {
+         throw new javax.ejb.EJBException("Cannot invoke method " + method.getName() + " on nointerface view");
+      }
+
       // handle equals() and hashCode() in this InvocationHandler
       try
       {
@@ -343,4 +352,119 @@
    {
    }
 
+   /**
+    * 
+    * @param m
+    * @return
+    */
+   public boolean isHandled(Method m)
+   {
+      // We handle only public, non-static, non-final methods
+      if (!isPublic(m))
+      {
+         if (logger.isTraceEnabled())
+         {
+            logger.trace("Method " + m.getName() + " is *not* public");
+         }
+         // it's not a public method
+         return false;
+      }
+      if (isFinal(m))
+      {
+         if (logger.isTraceEnabled())
+         {
+            logger.trace("Method " + m.getName() + " is final");
+         }
+         // it's a final method
+         return false;
+      }
+      if (isStatic(m))
+      {
+         if (logger.isTraceEnabled())
+         {
+            logger.trace("Method " + m.getName() + " is static");
+         }
+         // it's a static method
+         return false;
+      }
+      if (isNative(m))
+      {
+         if (logger.isTraceEnabled())
+         {
+            logger.trace("Method " + m.getName() + " is native");
+         }
+         // it's a native method
+         return false;
+      }
+      // we handle rest of the methods
+      return true;
+   }
+
+   /**
+    * Returns true if the {@link Method} <code>m</code> is a public method.
+    * Else returns false
+    * 
+    * @param m The method
+    * @return
+    */
+   private boolean isPublic(Method m)
+   {
+      int modifiers = m.getModifiers();
+      if ((Modifier.PUBLIC & modifiers) == Modifier.PUBLIC)
+      {
+         return true;
+      }
+      return false;
+   }
+
+   /**
+    * Returns true if the {@link Method} <code>m</code> is a final method.
+    * Else returns false
+    * 
+    * @param m The method
+    * @return
+    */
+   private boolean isFinal(Method m)
+   {
+      int modifiers = m.getModifiers();
+      if ((Modifier.FINAL & modifiers) == Modifier.FINAL)
+      {
+         return true;
+      }
+      return false;
+   }
+
+   /**
+    * Returns true if the {@link Method} <code>m</code> is a static method.
+    * Else returns false
+    * 
+    * @param m The method
+    * @return
+    */
+   private boolean isStatic(Method m)
+   {
+      int modifiers = m.getModifiers();
+      if ((Modifier.STATIC & modifiers) == Modifier.STATIC)
+      {
+         return true;
+      }
+      return false;
+   }
+
+   /**
+    * Returns true if the {@link Method} <code>m</code> is a native method.
+    * Else returns false
+    * 
+    * @param m The method
+    * @return
+    */
+   private boolean isNative(Method m)
+   {
+      int modifiers = m.getModifiers();
+      if ((Modifier.NATIVE & modifiers) == Modifier.NATIVE)
+      {
+         return true;
+      }
+      return false;
+   }
 }

Modified: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/NoInterfaceViewJNDIBinderFacade.java
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/NoInterfaceViewJNDIBinderFacade.java	2010-03-14 17:41:20 UTC (rev 102382)
+++ projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/NoInterfaceViewJNDIBinderFacade.java	2010-03-14 19:28:44 UTC (rev 102383)
@@ -182,15 +182,12 @@
    {
       if (this.sessionBeanMetadata.isStateful())
       {
-         return new StatefulNoInterfaceJNDIBinder(this.endpointContext);
+         return new SessionAwareNoInterfaceViewJNDIBinder(this.endpointContext);
       }
-      else if (this.sessionBeanMetadata.isStateless())
+      else 
       {
-         return new StatelessNoInterfaceJNDIBinder(this.endpointContext);
+         return new SessionlessNoInterfaceViewJNDIBinder(this.endpointContext);
       }
-      throw new RuntimeException("Cannot get a jndi binder for bean " + this.sessionBeanMetadata.getEjbName()
-            + " since it's neither a stateful nor a stateless bean");
    }
 
-
 }

Added: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/SessionAwareNoInterfaceViewJNDIBinder.java
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/SessionAwareNoInterfaceViewJNDIBinder.java	                        (rev 0)
+++ projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/SessionAwareNoInterfaceViewJNDIBinder.java	2010-03-14 19:28:44 UTC (rev 102383)
@@ -0,0 +1,142 @@
+/*
+ * 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.nointerface.impl.jndi;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+
+import org.jboss.ejb3.nointerface.impl.objectfactory.NoInterfaceViewProxyFactoryRefAddrTypes;
+import org.jboss.ejb3.nointerface.impl.objectfactory.StatefulNoInterfaceViewObjectFactory;
+import org.jboss.ejb3.nointerface.impl.view.factory.StatefulNoInterfaceViewFacade;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+import org.jboss.util.naming.NonSerializableFactory;
+import org.jboss.util.naming.Util;
+
+/**
+ * 
+ * Responsible for creating and binding nointerface view proxy (and any
+ * other relevant objects like session creating proxy factory) into jndi,
+ * for beans which are session aware (ex: Stateful session beans)
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class SessionAwareNoInterfaceViewJNDIBinder extends AbstractNoInterfaceViewJNDIBinder
+{
+
+   /**
+    * Logger
+    */
+   private static Logger logger = Logger.getLogger(SessionAwareNoInterfaceViewJNDIBinder.class);
+
+   /**
+    * Suffix to be added to the ejb-name to form the jndi name of no-interface stateful proxyfactory
+    */
+   private static final String NO_INTERFACE_STATEFUL_PROXY_FACTORY_JNDI_NAME_SUFFIX = "/no-interface-stateful-proxyfactory";
+
+   /**
+    * Constructor
+    * @param beanClass The bean class
+    * @param sessionBeanMetadata Metadata of the bean
+    */
+   public SessionAwareNoInterfaceViewJNDIBinder(KernelControllerContext endPointCtx)
+   {
+      super(endPointCtx);
+   }
+
+   /**
+    * 1) Creates a {@link StatefulNoInterfaceViewFacade} and binds it to JNDI (let's call
+    * this jndi-name "A")
+    *
+    * 2) Creates a {@link StatefulNoInterfaceViewObjectFactory} objectfactory and binds a {@link Reference}
+    * to this objectfactory into the JNDI (let's call it jndi-name "B").
+    *
+    * The objectfactory will have a reference to the jndi-name of the stateful factory (created in step#1).
+    * This will then be used by the object factory to lookup the stateful factory for creating the no-interface
+    * view when the client does a lookup.
+    *
+    *
+    */
+   @Override
+   public String bindNoInterfaceView(Context jndiCtx, Class<?> beanClass, JBossSessionBean31MetaData beanMetaData)
+         throws NamingException, IllegalStateException
+   {
+      // ensure it has a no-interface view
+      this.ensureNoInterfaceViewExists(beanMetaData);
+
+      // This factory will be bound to JNDI and will be invoked (through an objectfactory) to create
+      // the no-interface view for a SFSB
+      StatefulNoInterfaceViewFacade statefulNoInterfaceViewFactory = new StatefulNoInterfaceViewFacade(beanClass,
+            this.endpointContext);
+
+      // TODO - Needs to be a proper jndi name for the factory
+      String statefulProxyFactoryJndiName = beanMetaData.getEjbName()
+            + NO_INTERFACE_STATEFUL_PROXY_FACTORY_JNDI_NAME_SUFFIX;
+      // Bind the proxy factory to jndi
+      NonSerializableFactory.rebind(jndiCtx, statefulProxyFactoryJndiName, statefulNoInterfaceViewFactory, true);
+
+      // Create an Reference which will hold the jndi-name of the statefulproxyfactory which will
+      // be responsible for creating the no-interface view for the stateful bean upon lookup
+      Reference reference = new Reference(
+            NoInterfaceViewProxyFactoryRefAddrTypes.STATEFUL_NO_INTERFACE_VIEW_OBJECT_FACTORY_KEY,
+            StatefulNoInterfaceViewObjectFactory.class.getName(), null);
+      RefAddr refAddr = new StringRefAddr(
+            NoInterfaceViewProxyFactoryRefAddrTypes.STATEFUL_NO_INTERFACE_VIEW_PROXY_FACTORY_JNDI_LOCATION,
+            statefulProxyFactoryJndiName);
+      // add this refaddr to the reference which will be bound to jndi
+      reference.add(refAddr);
+
+      String noInterfaceJndiName = this.getJNDINameResolver(beanMetaData).resolveNoInterfaceJNDIName(beanMetaData);
+      // log the jndi binding information 
+      this.prettyPrintJNDIBindingInfo(beanMetaData, noInterfaceJndiName);
+      // bind to jndi
+      Util.bind(jndiCtx, noInterfaceJndiName, reference);
+
+      return noInterfaceJndiName;
+
+   }
+
+   /**
+    * Unbind the {@link StatefulNoInterfaceViewFacade} and the {@link StatefulNoInterfaceViewObjectFactory}
+    * from the jndi
+    * 
+    * @see org.jboss.ejb3.nointerface.impl.jndi.NoInterfaceViewJNDIBinderFacade#unbindNoInterfaceView()
+    */
+   @Override
+   public void unbindNoInterfaceView(Context jndiCtx, Class<?> beanClass, JBossSessionBean31MetaData beanMetaData)
+         throws NamingException, IllegalStateException
+   {
+      // ensure it has a no-interface view
+      this.ensureNoInterfaceViewExists(beanMetaData);
+
+      String noInterfaceJndiName = this.getJNDINameResolver(beanMetaData).resolveNoInterfaceJNDIName(beanMetaData);
+      jndiCtx.unbind(noInterfaceJndiName);
+      jndiCtx.unbind(beanMetaData.getEjbName() + NO_INTERFACE_STATEFUL_PROXY_FACTORY_JNDI_NAME_SUFFIX);
+
+   }
+
+}


Property changes on: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/SessionAwareNoInterfaceViewJNDIBinder.java
___________________________________________________________________
Name: svn:executable
   + *

Added: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/SessionlessNoInterfaceViewJNDIBinder.java
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/SessionlessNoInterfaceViewJNDIBinder.java	                        (rev 0)
+++ projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/SessionlessNoInterfaceViewJNDIBinder.java	2010-03-14 19:28:44 UTC (rev 102383)
@@ -0,0 +1,114 @@
+/*
+ * 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.nointerface.impl.jndi;
+
+import java.lang.reflect.InvocationHandler;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.jboss.ejb3.nointerface.impl.invocationhandler.NoInterfaceViewInvocationHandler;
+import org.jboss.ejb3.proxy.javassist.JavassistProxyFactory;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+import org.jboss.util.naming.NonSerializableFactory;
+
+/**
+ * Responsible for binding a nointerface view proxy into jndi, for
+ * EJBs which are *not* session aware (ex: Stateless beans and Singleton beans)
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class SessionlessNoInterfaceViewJNDIBinder extends AbstractNoInterfaceViewJNDIBinder
+{
+
+   /**
+    * Logger
+    */
+   private static Logger logger = Logger.getLogger(SessionlessNoInterfaceViewJNDIBinder.class);
+
+   /**
+    * Constructor
+    * 
+    * @param ctx
+    * @param beanClass
+    * @param sessionBeanMetadata
+    */
+   public SessionlessNoInterfaceViewJNDIBinder(KernelControllerContext endPointCtx)
+   {
+      super(endPointCtx);
+   }
+
+   /**
+    * Creates the no-interface view for the bean and binds it to the JNDI
+    * under the no-interface view jndi name obtained from <code>sessionBeanMetadata</code>.
+    *
+    * @see JavassistNoInterfaceViewFactory#createView(java.lang.reflect.InvocationHandler, Class)
+    */
+   @Override
+   public String bindNoInterfaceView(Context jndiCtx, Class<?> beanClass, JBossSessionBean31MetaData beanMetaData)
+         throws NamingException, IllegalStateException
+   {
+      // ensure no-interface view exists
+      this.ensureNoInterfaceViewExists(beanMetaData);
+
+
+      InvocationHandler invocationHandler = new NoInterfaceViewInvocationHandler(this.endpointContext, null);
+
+      Object noInterfaceView;
+      try
+      {
+         noInterfaceView = new JavassistProxyFactory().createProxy(new Class<?>[] {beanClass}, invocationHandler);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Could not create no-interface view for bean class: " + beanClass, e);
+      }
+      // get no-interface view jndi name
+      String noInterfaceJndiName = this.getJNDINameResolver(beanMetaData).resolveNoInterfaceJNDIName(beanMetaData);
+      // log the no-interface view jndi binding info
+      this.prettyPrintJNDIBindingInfo(beanMetaData, noInterfaceJndiName);
+      // bind to jndi
+      NonSerializableFactory.rebind(jndiCtx, noInterfaceJndiName, noInterfaceView, true);
+      
+      return noInterfaceJndiName;
+   }
+
+   /**
+    * Unbinds the no-interface view proxy from the JNDI
+    * 
+    * @see org.jboss.ejb3.nointerface.impl.jndi.NoInterfaceViewJNDIBinderFacade#unbindNoInterfaceView()
+    */
+   @Override
+   public void unbindNoInterfaceView(Context jndiCtx, Class<?> beanClass, JBossSessionBean31MetaData beanMetaData)
+         throws NamingException, IllegalStateException
+   {
+      // ensure no-interface view exists
+      this.ensureNoInterfaceViewExists(beanMetaData);
+
+      String noInterfaceJndiName = this.getJNDINameResolver(beanMetaData).resolveNoInterfaceJNDIName(beanMetaData);
+      jndiCtx.unbind(noInterfaceJndiName);
+
+   }
+}


Property changes on: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/SessionlessNoInterfaceViewJNDIBinder.java
___________________________________________________________________
Name: svn:executable
   + *

Deleted: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/StatefulNoInterfaceJNDIBinder.java
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/StatefulNoInterfaceJNDIBinder.java	2010-03-14 17:41:20 UTC (rev 102382)
+++ projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/StatefulNoInterfaceJNDIBinder.java	2010-03-14 19:28:44 UTC (rev 102383)
@@ -1,142 +0,0 @@
-/*
- * 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.nointerface.impl.jndi;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
-
-import org.jboss.ejb3.nointerface.impl.objectfactory.NoInterfaceViewProxyFactoryRefAddrTypes;
-import org.jboss.ejb3.nointerface.impl.objectfactory.StatefulNoInterfaceViewObjectFactory;
-import org.jboss.ejb3.nointerface.impl.view.factory.StatefulNoInterfaceViewFacade;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
-import org.jboss.util.naming.NonSerializableFactory;
-import org.jboss.util.naming.Util;
-
-/**
- * StatefulNoInterfaceJNDIBinder
- *
- * Responsible for creating and binding the appropriate objects
- * corresponding to the no-interface view of a stateful session bean
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class StatefulNoInterfaceJNDIBinder extends AbstractNoInterfaceViewJNDIBinder
-{
-
-   /**
-    * Logger
-    */
-   private static Logger logger = Logger.getLogger(StatefulNoInterfaceJNDIBinder.class);
-
-   /**
-    * Suffix to be added to the ejb-name to form the jndi name of no-interface stateful proxyfactory
-    */
-   private static final String NO_INTERFACE_STATEFUL_PROXY_FACTORY_JNDI_NAME_SUFFIX = "/no-interface-stateful-proxyfactory";
-
-   /**
-    * Constructor
-    * @param beanClass The bean class
-    * @param sessionBeanMetadata Metadata of the bean
-    */
-   public StatefulNoInterfaceJNDIBinder(KernelControllerContext endPointCtx)
-   {
-      super(endPointCtx);
-   }
-
-   /**
-    * 1) Creates a {@link StatefulNoInterfaceViewFacade} and binds it to JNDI (let's call
-    * this jndi-name "A")
-    *
-    * 2) Creates a {@link StatefulNoInterfaceViewObjectFactory} objectfactory and binds a {@link Reference}
-    * to this objectfactory into the JNDI (let's call it jndi-name "B").
-    *
-    * The objectfactory will have a reference to the jndi-name of the stateful factory (created in step#1).
-    * This will then be used by the object factory to lookup the stateful factory for creating the no-interface
-    * view when the client does a lookup.
-    *
-    *
-    */
-   @Override
-   public String bindNoInterfaceView(Context jndiCtx, Class<?> beanClass, JBossSessionBean31MetaData beanMetaData)
-         throws NamingException, IllegalStateException
-   {
-      // ensure it has a no-interface view
-      this.ensureNoInterfaceViewExists(beanMetaData);
-
-      // This factory will be bound to JNDI and will be invoked (through an objectfactory) to create
-      // the no-interface view for a SFSB
-      StatefulNoInterfaceViewFacade statefulNoInterfaceViewFactory = new StatefulNoInterfaceViewFacade(beanClass,
-            this.endpointContext);
-
-      // TODO - Needs to be a proper jndi name for the factory
-      String statefulProxyFactoryJndiName = beanMetaData.getEjbName()
-            + NO_INTERFACE_STATEFUL_PROXY_FACTORY_JNDI_NAME_SUFFIX;
-      // Bind the proxy factory to jndi
-      NonSerializableFactory.rebind(jndiCtx, statefulProxyFactoryJndiName, statefulNoInterfaceViewFactory, true);
-
-      // Create an Reference which will hold the jndi-name of the statefulproxyfactory which will
-      // be responsible for creating the no-interface view for the stateful bean upon lookup
-      Reference reference = new Reference(
-            NoInterfaceViewProxyFactoryRefAddrTypes.STATEFUL_NO_INTERFACE_VIEW_OBJECT_FACTORY_KEY,
-            StatefulNoInterfaceViewObjectFactory.class.getName(), null);
-      RefAddr refAddr = new StringRefAddr(
-            NoInterfaceViewProxyFactoryRefAddrTypes.STATEFUL_NO_INTERFACE_VIEW_PROXY_FACTORY_JNDI_LOCATION,
-            statefulProxyFactoryJndiName);
-      // add this refaddr to the reference which will be bound to jndi
-      reference.add(refAddr);
-
-      String noInterfaceJndiName = this.getJNDINameResolver(beanMetaData).resolveNoInterfaceJNDIName(beanMetaData);
-      // log the jndi binding information 
-      this.prettyPrintJNDIBindingInfo(beanMetaData, noInterfaceJndiName);
-      // bind to jndi
-      Util.bind(jndiCtx, noInterfaceJndiName, reference);
-
-      return noInterfaceJndiName;
-
-   }
-
-   /**
-    * Unbind the {@link StatefulNoInterfaceViewFacade} and the {@link StatefulNoInterfaceViewObjectFactory}
-    * from the jndi
-    * 
-    * @see org.jboss.ejb3.nointerface.impl.jndi.NoInterfaceViewJNDIBinderFacade#unbindNoInterfaceView()
-    */
-   @Override
-   public void unbindNoInterfaceView(Context jndiCtx, Class<?> beanClass, JBossSessionBean31MetaData beanMetaData)
-         throws NamingException, IllegalStateException
-   {
-      // ensure it has a no-interface view
-      this.ensureNoInterfaceViewExists(beanMetaData);
-
-      String noInterfaceJndiName = this.getJNDINameResolver(beanMetaData).resolveNoInterfaceJNDIName(beanMetaData);
-      jndiCtx.unbind(noInterfaceJndiName);
-      jndiCtx.unbind(beanMetaData.getEjbName() + NO_INTERFACE_STATEFUL_PROXY_FACTORY_JNDI_NAME_SUFFIX);
-
-   }
-
-}

Deleted: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/StatelessNoInterfaceJNDIBinder.java
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/StatelessNoInterfaceJNDIBinder.java	2010-03-14 17:41:20 UTC (rev 102382)
+++ projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/jndi/StatelessNoInterfaceJNDIBinder.java	2010-03-14 19:28:44 UTC (rev 102383)
@@ -1,116 +0,0 @@
-/*
- * 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.nointerface.impl.jndi;
-
-import java.lang.reflect.InvocationHandler;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.ejb3.nointerface.impl.invocationhandler.NoInterfaceViewInvocationHandler;
-import org.jboss.ejb3.nointerface.impl.view.factory.JavassistNoInterfaceViewFactory;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
-import org.jboss.util.naming.NonSerializableFactory;
-
-/**
- * StatelessNoInterfaceJNDIBinder
- *
- *  Responsible for binding the appropriate objects corresponding to the
- *  no-interface view of a stateless session bean
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class StatelessNoInterfaceJNDIBinder extends AbstractNoInterfaceViewJNDIBinder
-{
-
-   /**
-    * Logger
-    */
-   private static Logger logger = Logger.getLogger(StatelessNoInterfaceJNDIBinder.class);
-
-   /**
-    * Constructor
-    * 
-    * @param ctx
-    * @param beanClass
-    * @param sessionBeanMetadata
-    */
-   public StatelessNoInterfaceJNDIBinder(KernelControllerContext endPointCtx)
-   {
-      super(endPointCtx);
-   }
-
-   /**
-    * Creates the no-interface view for the bean and binds it to the JNDI
-    * under the no-interface view jndi name obtained from <code>sessionBeanMetadata</code>.
-    *
-    * @see JavassistNoInterfaceViewFactory#createView(java.lang.reflect.InvocationHandler, Class)
-    */
-   @Override
-   public String bindNoInterfaceView(Context jndiCtx, Class<?> beanClass, JBossSessionBean31MetaData beanMetaData)
-         throws NamingException, IllegalStateException
-   {
-      // ensure no-interface view exists
-      this.ensureNoInterfaceViewExists(beanMetaData);
-
-
-      InvocationHandler invocationHandler = new NoInterfaceViewInvocationHandler(this.endpointContext, null);
-
-      Object noInterfaceView;
-      try
-      {
-         noInterfaceView = new JavassistNoInterfaceViewFactory().createView(invocationHandler, beanClass);
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("Could not create no-interface view for bean class: " + beanClass, e);
-      }
-      // get no-interface view jndi name
-      String noInterfaceJndiName = this.getJNDINameResolver(beanMetaData).resolveNoInterfaceJNDIName(beanMetaData);
-      // log the no-interface view jndi binding info
-      this.prettyPrintJNDIBindingInfo(beanMetaData, noInterfaceJndiName);
-      // bind to jndi
-      NonSerializableFactory.rebind(jndiCtx, noInterfaceJndiName, noInterfaceView, true);
-      
-      return noInterfaceJndiName;
-   }
-
-   /**
-    * Unbinds the no-interface view proxy from the JNDI
-    * 
-    * @see org.jboss.ejb3.nointerface.impl.jndi.NoInterfaceViewJNDIBinderFacade#unbindNoInterfaceView()
-    */
-   @Override
-   public void unbindNoInterfaceView(Context jndiCtx, Class<?> beanClass, JBossSessionBean31MetaData beanMetaData)
-         throws NamingException, IllegalStateException
-   {
-      // ensure no-interface view exists
-      this.ensureNoInterfaceViewExists(beanMetaData);
-
-      String noInterfaceJndiName = this.getJNDINameResolver(beanMetaData).resolveNoInterfaceJNDIName(beanMetaData);
-      jndiCtx.unbind(noInterfaceJndiName);
-
-   }
-}

Deleted: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/JavassistInvocationHandlerAdapter.java
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/JavassistInvocationHandlerAdapter.java	2010-03-14 17:41:20 UTC (rev 102382)
+++ projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/JavassistInvocationHandlerAdapter.java	2010-03-14 19:28:44 UTC (rev 102383)
@@ -1,74 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.nointerface.impl.view;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-import javassist.util.proxy.MethodHandler;
-
-/**
- * {@link JavassistInvocationHandlerAdapter} is an implementation of Javassist {@link MethodHandler}
- * and is responsible for forwarding the method invocations to a instance of {@link java.lang.reflect.InvocationHandler}
- *
- * @see MethodHandler
- * @see InvocationHandler
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class JavassistInvocationHandlerAdapter implements MethodHandler
-{
-
-   /**
-    * The invocation handler to which the method invocations will be forwarded to
-    */
-   private InvocationHandler invocationHandler;
-
-   /**
-    * Creates a {@link JavassistInvocationHandlerAdapter} for an {@link InvocationHandler}
-    * @param invocationHandler The invocation handler
-    * @throws IllegalArgumentException If the passed <code>invocationHandler</code> is null
-    */
-   public JavassistInvocationHandlerAdapter(InvocationHandler invocationHandler)
-   {
-      if (invocationHandler == null)
-      {
-         throw new IllegalArgumentException(this.getClass().getName() + " cannot be created out of a null "
-               + InvocationHandler.class.getName());
-      }
-      this.invocationHandler = invocationHandler;
-   }
-
-   /**
-    * Lets the {@link InvocationHandler} instance, which was passed to {@link #JavassistInvocationHandlerAdapter(InvocationHandler)} 
-    * handle the method invocation.
-    * 
-    * @see javassist.util.proxy.MethodHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.reflect.Method, java.lang.Object[])
-    */
-   @Override
-   public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
-   {
-      // let the invocation handler take care of the call
-      return this.invocationHandler.invoke(self, thisMethod, args);
-   }
-
-}

Deleted: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/NoInterfaceViewMethodFilter.java
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/NoInterfaceViewMethodFilter.java	2010-03-14 17:41:20 UTC (rev 102382)
+++ projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/NoInterfaceViewMethodFilter.java	2010-03-14 19:28:44 UTC (rev 102383)
@@ -1,158 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.nointerface.impl.view;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import javassist.util.proxy.MethodFilter;
-import javassist.util.proxy.MethodHandler;
-
-/**
- * A {@link NoInterfaceViewMethodFilter} is responsible for deciding whether
- * a method invoked on a nointerface view proxy is to be handled by the 
- * underlying invocation handler. 
- * <p>
- *  The {@link NoInterfaceViewMethodFilter#isHandled(Method)} checks for the method attributes to
- *  decide whether the method should be skipped by the proxy's {@link MethodHandler} or whether it should be handled
- *  by the proxy's {@link MethodHandler}
- * </p>
- *
- * @see MethodHandler
- * @see MethodFilter
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class NoInterfaceViewMethodFilter implements MethodFilter
-{
-
-   /**
-    * Returns true if the {@link Method} <code>m</code> should be handled 
-    * by the nointerface view proxy's invocation handler.
-    * 
-    * <p>
-    *   Returns false if 
-    *   <ul>
-    *       <li><code>m</code> is *not* public</li>
-    *       <li><code>m</code> is static</li>
-    *       <li><code>m</code> is final</li>
-    *       <li><code>m</code> is native</li> 
-    *   </ul>
-    * </p>
-    * @see javassist.util.proxy.MethodFilter#isHandled(java.lang.reflect.Method)
-    */
-   @Override
-   public boolean isHandled(Method m)
-   {
-      // We handle only public, non-static, non-final methods
-      if (!isPublic(m))
-      {
-         // it's not a public method
-         return false;
-      }
-      if (isFinal(m))
-      {
-         // it's a final method
-         return false;
-      }
-      if (isStatic(m))
-      {
-         // it's a static method
-         return false;
-      }
-      if (isNative(m))
-      {
-         // it's a native method
-         return false;
-      }
-      // we handle rest of the methods
-      return true;
-   }
-
-   /**
-    * Returns true if the {@link Method} <code>m</code> is a public method.
-    * Else returns false
-    * 
-    * @param m The method
-    * @return
-    */
-   private boolean isPublic(Method m)
-   {
-      int modifiers = m.getModifiers();
-      if ((Modifier.PUBLIC & modifiers) == Modifier.PUBLIC)
-      {
-         return true;
-      }
-      return false;
-   }
-
-   /**
-    * Returns true if the {@link Method} <code>m</code> is a final method.
-    * Else returns false
-    * 
-    * @param m The method
-    * @return
-    */
-   private boolean isFinal(Method m)
-   {
-      int modifiers = m.getModifiers();
-      if ((Modifier.FINAL & modifiers) == Modifier.FINAL)
-      {
-         return true;
-      }
-      return false;
-   }
-
-   /**
-    * Returns true if the {@link Method} <code>m</code> is a static method.
-    * Else returns false
-    * 
-    * @param m The method
-    * @return
-    */
-   private boolean isStatic(Method m)
-   {
-      int modifiers = m.getModifiers();
-      if ((Modifier.STATIC & modifiers) == Modifier.STATIC)
-      {
-         return true;
-      }
-      return false;
-   }
-
-   /**
-    * Returns true if the {@link Method} <code>m</code> is a native method.
-    * Else returns false
-    * 
-    * @param m The method
-    * @return
-    */
-   private boolean isNative(Method m)
-   {
-      int modifiers = m.getModifiers();
-      if ((Modifier.NATIVE & modifiers) == Modifier.NATIVE)
-      {
-         return true;
-      }
-      return false;
-   }
-}

Deleted: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/factory/JavassistNoInterfaceViewFactory.java
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/factory/JavassistNoInterfaceViewFactory.java	2010-03-14 17:41:20 UTC (rev 102382)
+++ projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/factory/JavassistNoInterfaceViewFactory.java	2010-03-14 19:28:44 UTC (rev 102383)
@@ -1,86 +0,0 @@
-/*
- * 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.nointerface.impl.view.factory;
-
-import java.lang.reflect.InvocationHandler;
-
-import javassist.util.proxy.ProxyFactory;
-
-import org.jboss.ejb3.nointerface.impl.view.JavassistInvocationHandlerAdapter;
-import org.jboss.ejb3.nointerface.impl.view.NoInterfaceViewMethodFilter;
-import org.jboss.ejb3.nointerface.spi.view.factory.NoInterfaceViewFactory;
-import org.jboss.logging.Logger;
-
-/**
- * {@link JavassistNoInterfaceViewFactory} uses Javassist to create
- * nointerface view proxies for a EJB which exposes the nointerface view
- *
- * 
- * @see NoInterfaceViewFactory
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class JavassistNoInterfaceViewFactory implements NoInterfaceViewFactory
-{
-
-   /**
-    * Logger
-    */
-   private static Logger logger = Logger.getLogger(JavassistNoInterfaceViewFactory.class);
-
-   /**
-    * Inspects the bean class for all public methods and creates a proxy (sub-class)
-    * out of it with overriden implementation of the public methods. The overriden
-    * implementation will just give a call to <code>container</code>'s invoke(...) method
-    * which handles the actual call.
-    *
-    * @param <T>
-    * @param invocationHandler The container correpsonding to the bean class
-    * @param beanClass The bean class (currently assumed)
-    * @return Returns the no-interface view for the <code>beanClass</code>
-    * @throws Exception
-    */
-   public <T> T createView(InvocationHandler invocationHandler, Class<T> beanClass) throws Exception
-   {
-      if (logger.isTraceEnabled())
-      {
-         logger.trace("Creating nointerface view for beanClass: " + beanClass + " with container " + invocationHandler);
-      }
-
-      ProxyFactory javassistProxyFactory = new ProxyFactory();
-      // set the bean class for which we need a proxy
-      javassistProxyFactory.setSuperclass(beanClass);
-      // set a method filter so that we can filter out invocations on methods
-      // which are *not* to be handled by a nointerface view 
-      javassistProxyFactory.setFilter(new NoInterfaceViewMethodFilter());
-      // Set our method handler which is responsible for handling the method invocations
-      // on the proxy
-      javassistProxyFactory.setHandler(new JavassistInvocationHandlerAdapter(invocationHandler));
-
-      // create the proxy
-      Object proxy = javassistProxyFactory.create(new Class[0], new Object[0]);
-      // cast to the bean type and return
-      return beanClass.cast(proxy);
-
-   }
-
-}

Modified: projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/factory/StatefulNoInterfaceViewFacade.java
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/factory/StatefulNoInterfaceViewFacade.java	2010-03-14 17:41:20 UTC (rev 102382)
+++ projects/ejb3/components/nointerface/trunk/impl/src/main/java/org/jboss/ejb3/nointerface/impl/view/factory/StatefulNoInterfaceViewFacade.java	2010-03-14 19:28:44 UTC (rev 102383)
@@ -29,6 +29,7 @@
 import org.jboss.ejb3.nointerface.impl.invocationhandler.NoInterfaceViewInvocationHandler;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.logging.Logger;
+import org.jboss.ejb3.proxy.javassist.*;
 
 /**
  * StatefulNoInterfaceViewFacade
@@ -117,8 +118,8 @@
       // create an invocation handler
       InvocationHandler invocationHandler = new NoInterfaceViewInvocationHandler(this.endpointContext, session);
 
-      // Now create the view for this bean class and the newly created invocation handler
-      Object noInterfaceView = new JavassistNoInterfaceViewFactory().createView(invocationHandler, beanClass);
+      // Now create the proxy
+      Object noInterfaceView = new JavassistProxyFactory().createProxy(new Class<?>[] {beanClass}, invocationHandler);
       return noInterfaceView;
    }
 

Deleted: projects/ejb3/components/nointerface/trunk/impl/src/test/java/org/jboss/ejb3/nointerface/impl/test/factory/unit/NoInterfaceViewFactoryTestCase.java
===================================================================
--- projects/ejb3/components/nointerface/trunk/impl/src/test/java/org/jboss/ejb3/nointerface/impl/test/factory/unit/NoInterfaceViewFactoryTestCase.java	2010-03-14 17:41:20 UTC (rev 102382)
+++ projects/ejb3/components/nointerface/trunk/impl/src/test/java/org/jboss/ejb3/nointerface/impl/test/factory/unit/NoInterfaceViewFactoryTestCase.java	2010-03-14 19:28:44 UTC (rev 102383)
@@ -1,256 +0,0 @@
-/*
- * 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.nointerface.impl.test.factory.unit;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-import org.jboss.ejb3.nointerface.impl.test.factory.SimpleSFSBeanWithoutInterfaces;
-import org.jboss.ejb3.nointerface.impl.test.factory.SimpleSLSBWithoutInterface;
-import org.jboss.ejb3.nointerface.impl.view.factory.JavassistNoInterfaceViewFactory;
-import org.jboss.ejb3.nointerface.spi.view.factory.NoInterfaceViewFactory;
-import org.jboss.logging.Logger;
-import org.junit.Test;
-
-/**
- * NoInterfaceBeansTestCase
- *
- * Tests the no-inteface view for beans. 
- * 
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class NoInterfaceViewFactoryTestCase 
-{
-
-   /**
-    * Logger
-    */
-   private static Logger logger = Logger.getLogger(NoInterfaceViewFactoryTestCase.class);
-
-   private class DummyInvocationHandler implements InvocationHandler
-   {
-
-      private Object target;
-      
-      public DummyInvocationHandler(Object target)
-      {
-         if (target == null)
-         {
-            throw new IllegalArgumentException("Target object cannot be null, for invocation handler");
-         }
-         this.target = target;
-      }
-      
-      /**
-       * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
-       */
-      @Override
-      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
-      {
-         // just pass on the call to the target
-         return method.invoke(target, args);
-      }
-      
-   }
-
-   /**
-    * Test to ensure that the no-interface view instance does NOT consider
-    * a final method on the bean while creating the view
-    *
-    * @throws Exception
-    */
-   @Test
-   public void testFinalMethodsAreNotConsideredInView() throws Exception
-   {
-      NoInterfaceViewFactory noInterfaceBeanFactory = new JavassistNoInterfaceViewFactory();
-      SimpleSLSBWithoutInterface beanInstance = new SimpleSLSBWithoutInterface();
-      Object proxy = noInterfaceBeanFactory.createView(new DummyInvocationHandler(beanInstance), beanInstance.getClass());
-      // ensure that the returned object is not null and is of expected type
-      assertNotNull("No-interface view factory returned a null view for " + beanInstance.getClass(), proxy);
-      assertTrue("No-interface view factory returend an unexpected object type: " + proxy.getClass(), (proxy instanceof SimpleSLSBWithoutInterface));
-      
-      SimpleSLSBWithoutInterface noInterfaceView = (SimpleSLSBWithoutInterface) proxy;
-
-      // Nothing fancy to test - just ensure that the declared methods in the proxy does
-      // NOT contain a "final" method. Just check on method name, should be enough
-      Method[] declaredMethods = noInterfaceView.getClass().getDeclaredMethods();
-      for (Method declaredMethod : declaredMethods)
-      {
-         if (declaredMethod.getName().equals("someFinalMethod"))
-         {
-            fail("No-interface view has overriden a final method. It shouldn't have.");
-         }
-      }
-
-   }
-
-   /**
-   * Test to ensure that the no-interface view instance does NOT consider
-   * a static method on the bean while creating the view
-   *
-   * @throws Exception
-   */
-   @Test
-   public void testStaticMethodsAreNotConsideredInView() throws Exception
-   {
-      NoInterfaceViewFactory noInterfaceBeanFactory = new JavassistNoInterfaceViewFactory();
-      SimpleSFSBeanWithoutInterfaces beanInstance = new SimpleSFSBeanWithoutInterfaces();
-      Object proxy = noInterfaceBeanFactory.createView(new DummyInvocationHandler(beanInstance), beanInstance.getClass());
-      // ensure that the returned object is not null and is of expected type
-      assertNotNull("No-interface view factory returned a null view for " + beanInstance.getClass(), proxy);
-      assertTrue("No-interface view factory returend an unexpected object type: " + proxy.getClass(), (proxy instanceof SimpleSFSBeanWithoutInterfaces));
-      
-      SimpleSFSBeanWithoutInterfaces noInterfaceView = (SimpleSFSBeanWithoutInterfaces) proxy;
-      
-
-      // Nothing fancy to test - just ensure that the declared methods in the proxy does
-      // NOT contain a "static" method. Just check on method name, should be enough
-      Method[] declaredMethods = noInterfaceView.getClass().getDeclaredMethods();
-      for (Method declaredMethod : declaredMethods)
-      {
-         if (declaredMethod.getName().equals("someStaticMethod"))
-         {
-            fail("No-interface view has overriden a static method. It shouldn't have.");
-         }
-      }
-   }
-
-//   /**
-//    * Test to ensure that a no-interface view is NOT created for session beans
-//    * which implement an interface (and do not explicitly mark themselves @LocalBean)
-//    *
-//    * @throws Exception
-//    */
-//   @Test
-//   public void testBeanWithInterfacesIsNotEligibleForNoInterfaceView() throws Exception
-//   {
-//      JBossSessionBeanMetaData slsbMetadata = MetaDataHelper
-//            .getMetadataFromBeanImplClass(StatelessBeanWithInterfaces.class);
-//      String slsbNoInterfaceViewJNDIName = slsbMetadata.getEjbName() + "/no-interface";
-//
-//      JBossSessionBeanMetaData sfsbMetadata = MetaDataHelper
-//            .getMetadataFromBeanImplClass(StatefulBeanWithInterfaces.class);
-//      String sfsbNoInterfaceViewJNDIName = sfsbMetadata.getEjbName() + "/no-interface";
-//      String sfsbNoInterfaceViewFactoryJNDIName = sfsbMetadata.getEjbName() + "/no-interface-stateful-proxyfactory";
-//
-//      Context ctx = new InitialContext();
-//      // we have to ensure that there is NO no-interface view for these beans (because they are not eligible)
-//      try
-//      {
-//         Object obj = ctx.lookup(slsbNoInterfaceViewJNDIName);
-//         // this is a failure because there should not be a no-interface view for these beans
-//         fail("A SLSB with interfaces was marked as eligible for no-interface view. Shouldn't have been. Found object of type "
-//               + obj.getClass() + " in the jndi for jndiname " + slsbNoInterfaceViewJNDIName);
-//      }
-//      catch (NameNotFoundException nnfe)
-//      {
-//         // expected
-//      }
-//
-//      // now for sfsb, test that neither the factory nor the view are NOT bound
-//
-//      // test factory binding
-//      try
-//      {
-//         Object obj = ctx.lookup(sfsbNoInterfaceViewFactoryJNDIName);
-//         // this is a failure because there should not be a no-interface view for these beans
-//         fail("A SFSB factory for no-interface view was created for a bean implementing interfaces. Shouldn't have been. Found object of type "
-//               + obj.getClass() + " in the jndi for jndiname " + sfsbNoInterfaceViewFactoryJNDIName);
-//      }
-//      catch (NameNotFoundException nnfe)
-//      {
-//         // expected
-//      }
-//      // sfsb no-interface view
-//      try
-//      {
-//         Object obj = ctx.lookup(sfsbNoInterfaceViewJNDIName);
-//         // this is a failure because there should not be a no-interface view for these beans
-//         fail("A no-interface view for SFSB was created for a bean implementing interfaces. Shouldn't have been. Found object of type "
-//               + obj.getClass() + " in the jndi for jndiname " + sfsbNoInterfaceViewJNDIName);
-//      }
-//      catch (NameNotFoundException nnfe)
-//      {
-//         // expected
-//      }
-//
-//   }
-//
-//   /**
-//    * Test that sessions are created as expected for stateful session beans
-//    *
-//    * @throws Exception
-//    */
-//   @Test
-//   public void testSessionCreationForSFSBNoInterfaceViews() throws Exception
-//   {
-//      JBossSessionBeanMetaData sessionBeanMetadata = MetaDataHelper
-//            .getMetadataFromBeanImplClass(SimpleSFSBeanWithoutInterfaces.class);
-//      String jndiName = sessionBeanMetadata.getEjbName() + "/no-interface";
-//
-//      Context ctx = new InitialContext();
-//      // let's assume the lookup returns the correct type.
-//      // there are other test cases to ensure it does return the correct type
-//      SimpleSFSBeanWithoutInterfaces firstSFSB = (SimpleSFSBeanWithoutInterfaces) ctx.lookup(jndiName);
-//      // ensure this is a clean bean
-//      int initQty = firstSFSB.getQtyPurchased();
-//      assertEquals("SFSB instance is not new", initQty, SimpleSFSBeanWithoutInterfaces.INITIAL_QTY);
-//      // now change the state of the sfsb instance
-//      firstSFSB.incrementPurchaseQty();
-//      int incrementedValueForFirstSFSB = firstSFSB.getQtyPurchased();
-//      assertEquals("SFSB instance's value not incremented", incrementedValueForFirstSFSB,
-//            SimpleSFSBeanWithoutInterfaces.INITIAL_QTY + 1);
-//
-//      // now lookup another bean
-//      SimpleSFSBeanWithoutInterfaces secondSFSB = (SimpleSFSBeanWithoutInterfaces) ctx.lookup(jndiName);
-//      // ensure this is a clean bean
-//      int initQtyForSecondBeanInstance = secondSFSB.getQtyPurchased();
-//      assertEquals("Second instance of SFSB is not new", initQtyForSecondBeanInstance,
-//            SimpleSFSBeanWithoutInterfaces.INITIAL_QTY);
-//      // now change the state of the sfsb instance by some x amount
-//      int incrementBy = 10;
-//      secondSFSB.incrementPurchaseQty(incrementBy);
-//      int incrementedValueForSecondSFSB = secondSFSB.getQtyPurchased();
-//      assertEquals("Second SFSB instance's value not incremented", incrementedValueForSecondSFSB,
-//            SimpleSFSBeanWithoutInterfaces.INITIAL_QTY + incrementBy);
-//
-//      // let's also (again) check that the first SFSB still has it's own values and hasn't been
-//      // affected by changes made to second SFSB
-//      assertEquals("Value in first SFSB was changed when second SFSB was being modified", incrementedValueForFirstSFSB,
-//            SimpleSFSBeanWithoutInterfaces.INITIAL_QTY + 1);
-//
-//      // also check equality of two sfsb instances - they should not be equal
-//      assertFalse("Both the instances of the SFSB are the same", firstSFSB.equals(secondSFSB));
-//
-//      // let's also check whether the bean is equal to itself
-//      assertTrue("Incorrect equals implementation - returns false for the same sfsb instance", firstSFSB
-//            .equals(firstSFSB));
-//      assertTrue("equals returned false for the same sfsb instance", secondSFSB.equals(secondSFSB));
-//
-//   }
-
-}




More information about the jboss-cvs-commits mailing list