[jboss-cvs] JBossAS SVN: r85668 - in projects/ejb3/trunk/nointerface: src/main/java/org/jboss/ejb3/nointerface and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 10 05:44:50 EDT 2009


Author: jaikiran
Date: 2009-03-10 05:44:50 -0400 (Tue, 10 Mar 2009)
New Revision: 85668

Added:
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/NoInterfaceViewJNDIBinder.java
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/StatefulNoInterfaceJNDIBinder.java
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/StatelessNoInterfaceJNDIBinder.java
Removed:
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/NoInterfaceViewInvocationHandler.java
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/StatefulNoInterfaceViewInvocationHandler.java
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/StatelessNoInterfaceViewInvocationHandler.java
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/jndi/
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/NoInterfaceViewMCBean.java
Modified:
   projects/ejb3/trunk/nointerface/pom.xml
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/NoInterfaceEJBViewCreator.java
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/deployers/EJB3NoInterfaceDeployer.java
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/factory/StatefulNoInterfaceViewFactory.java
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/NoInterfaceViewInvocationHandler.java
   projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/objectfactory/StatefulNoInterfaceViewObjectFactory.java
   projects/ejb3/trunk/nointerface/src/test/resources/log4j.xml
Log:
EJBTHREE-1727 Refactored the implementation to incorporate some of the review comments 1) NonSerializableFactory from jboss.util.naming 2) @Start for binding the view, instead of @InstallMethod 3) No need to differentiate between a stateless/stateful invocation handler, and other minor changes

Modified: projects/ejb3/trunk/nointerface/pom.xml
===================================================================
--- projects/ejb3/trunk/nointerface/pom.xml	2009-03-10 09:38:17 UTC (rev 85667)
+++ projects/ejb3/trunk/nointerface/pom.xml	2009-03-10 09:44:50 UTC (rev 85668)
@@ -191,5 +191,11 @@
       <scope>test</scope>
     </dependency>
 
+    <dependency>
+      <groupId>org.jboss.naming</groupId>
+      <artifactId>jnp-client</artifactId>
+      <version>5.0.0.GA</version>
+    </dependency>
+
     </dependencies>
 </project>

Modified: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/NoInterfaceEJBViewCreator.java
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/NoInterfaceEJBViewCreator.java	2009-03-10 09:38:17 UTC (rev 85667)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/NoInterfaceEJBViewCreator.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -78,16 +78,16 @@
     * which handles the actual call.
     *
     * @param <T>
-    * @param container The container correpsonding to the bean class
+    * @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 container, Class<T> beanClass) 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 " + container);
+         logger.trace("Creating nointerface view for beanClass: " + beanClass + " with container " + invocationHandler);
       }
       //TODO: Validation as per section 4.9.8 of EJB 3.1 PR spec needs to be implemented.
       // Instead of accepting a bean class, maybe we should accept the JBossSessionBeanMetadata.
@@ -134,7 +134,7 @@
          // then it will be changed in the proxy to
          // public String sayHi(String name) { java.lang.reflect.Method currentMethod = beanClass.getName() + ".class.getMethod(theMethodName,params);
          // return container.invoke(this,currentMethod,args); }
-         proxyPublicMethod = overridePublicMethod(container, beanClass, beanPublicMethod, proxyPublicMethod);
+         proxyPublicMethod = overridePublicMethod(invocationHandler, beanClass, beanPublicMethod, proxyPublicMethod);
          // We have now created the overriden method. We need to add it to the proxy
          proxyCtClass.addMethod(proxyPublicMethod);
          if (logger.isTraceEnabled())
@@ -154,7 +154,7 @@
       Object proxyInstance = proxyClass.newInstance();
       Field containerInProxy = proxyClass.getDeclaredField("invocationHandler");
       containerInProxy.setAccessible(true);
-      containerInProxy.set(proxyInstance, container);
+      containerInProxy.set(proxyInstance, invocationHandler);
 
       // return the proxy instance
       return beanClass.cast(proxyInstance);

Deleted: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/NoInterfaceViewInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/NoInterfaceViewInvocationHandler.java	2009-03-10 09:38:17 UTC (rev 85667)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/NoInterfaceViewInvocationHandler.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -1,87 +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;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.proxy.container.InvokableContext;
-
-/**
- * NoInterfaceViewInvocationHandler
- *
- * An {@link InvocationHandler} which corresponds to the
- * no-interface view of a {@link EJBContainer}. All calls on the no-interface
- * view are routed through this {@link InvocationHandler} to the container.
- *
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class NoInterfaceViewInvocationHandler implements InvocationHandler
-{
-
-   /**
-    * The container to which this invocation handler corresponds to.
-    * All calls to this invocation handler will be forwarded to this
-    * container.
-    *
-    */
-   private InvokableContext container;
-
-   /**
-    * Constructor
-    * @param container
-    */
-   public NoInterfaceViewInvocationHandler(InvokableContext container)
-   {
-      assert container != null : "Container is null for no-interface view invocation handler";
-      this.container = container;
-   }
-
-   /**
-    * The calls to the no-interface view of the {@link EJBContainer}
-    * are routed through this {@link InvocationHandler}
-    *
-    * @param proxy TODO: RIght now we pass null for the Stateless bean and sessionId for the stateful bean
-    *               Needs more thought/work for this param
-    *
-    * @param method The invoked method
-    * @param args The arguments to the method
-    */
-   public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
-   {
-      // TODO: Some methods like toString() can be handled locally.
-      // But as of now let's just pass it on to the container.
-      assert this.container != null : "Container not yet available to the no-interface view invocation handler";
-      SerializableMethod serializableMethod = new SerializableMethod(method);
-      return this.container.invoke(proxy, serializableMethod, args);
-
-   }
-
-   public InvokableContext getContainer()
-   {
-      return this.container;
-   }
-}

Modified: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/deployers/EJB3NoInterfaceDeployer.java
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/deployers/EJB3NoInterfaceDeployer.java	2009-03-10 09:38:17 UTC (rev 85667)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/deployers/EJB3NoInterfaceDeployer.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -38,7 +38,7 @@
 import org.jboss.ejb3.javaee.JavaEEComponentHelper;
 import org.jboss.ejb3.javaee.JavaEEModule;
 import org.jboss.ejb3.javaee.SimpleJavaEEModule;
-import org.jboss.ejb3.nointerface.mc.NoInterfaceViewMCBean;
+import org.jboss.ejb3.nointerface.mc.NoInterfaceViewJNDIBinder;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
@@ -135,7 +135,8 @@
 
          // The no-interface view needs to be a MC bean so that it can "depend" on the container, so let's
          // make the no-interface view a MC bean
-         NoInterfaceViewMCBean bean = new NoInterfaceViewMCBean(beanClass, sessionBeanMetaData);
+         NoInterfaceViewJNDIBinder bean = NoInterfaceViewJNDIBinder.getNoInterfaceViewJndiBinder(beanClass,
+               sessionBeanMetaData);
          String noInterfaceViewMCBeanName = sessionBeanMetaData.getEjbName() + "@" + ((Object) bean).toString();
          BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(noInterfaceViewMCBeanName, bean.getClass()
                .getName());

Modified: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/factory/StatefulNoInterfaceViewFactory.java
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/factory/StatefulNoInterfaceViewFactory.java	2009-03-10 09:38:17 UTC (rev 85667)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/factory/StatefulNoInterfaceViewFactory.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -22,10 +22,9 @@
 package org.jboss.ejb3.nointerface.factory;
 
 import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
 
 import org.jboss.ejb3.nointerface.NoInterfaceEJBViewCreator;
-import org.jboss.ejb3.nointerface.invocationhandler.StatefulNoInterfaceViewInvocationHandler;
+import org.jboss.ejb3.nointerface.invocationhandler.NoInterfaceViewInvocationHandler;
 import org.jboss.ejb3.proxy.container.InvokableContext;
 import org.jboss.ejb3.proxy.container.StatefulSessionInvokableContext;
 import org.jboss.logging.Logger;
@@ -85,12 +84,12 @@
       Serializable session = statefulContainer.createSession();
       logger.debug("Created session " + session + " for " + this.beanClass);
 
-      // create an invocation handler and associate it with the newly created session
-      InvocationHandler invocationHandler = this.createInvocationHandlerForSession(statefulContainer, session);
-
+      NoInterfaceViewInvocationHandler invocationHandler = new NoInterfaceViewInvocationHandler(container);
+      invocationHandler.setProxy(session);
       // Now create the view for this bean class and the newly created invocation handler
       NoInterfaceEJBViewCreator noInterfaceViewCreator = new NoInterfaceEJBViewCreator();
-      Object noInterfaceView = noInterfaceViewCreator.createView(invocationHandler, beanClass);
+      Object noInterfaceView = noInterfaceViewCreator.createView(new NoInterfaceViewInvocationHandler(container),
+            beanClass);
 
       if (logger.isTraceEnabled())
       {
@@ -99,20 +98,4 @@
       return noInterfaceView;
    }
 
-   /**
-    * Creates an {@link StatefulNoInterfaceViewInvocationHandler} and associates it with
-    * the <code>session</code>
-    *
-    * @param container
-    * @param session
-    * @return
-    */
-   protected InvocationHandler createInvocationHandlerForSession(InvokableContext container, Serializable session)
-   {
-      StatefulNoInterfaceViewInvocationHandler invocationHandler = new StatefulNoInterfaceViewInvocationHandler(
-            container);
-      invocationHandler.setSessionId(session);
-      return invocationHandler;
-   }
-
 }

Modified: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/NoInterfaceViewInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/NoInterfaceViewInvocationHandler.java	2009-03-10 09:38:17 UTC (rev 85667)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/NoInterfaceViewInvocationHandler.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -25,6 +25,7 @@
 import java.lang.reflect.Method;
 
 import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.common.lang.SerializableMethod;
 import org.jboss.ejb3.proxy.container.InvokableContext;
 
 /**
@@ -38,7 +39,7 @@
  * @author Jaikiran Pai
  * @version $Revision: $
  */
-public abstract class NoInterfaceViewInvocationHandler implements InvocationHandler
+public class NoInterfaceViewInvocationHandler implements InvocationHandler
 {
 
    /**
@@ -47,8 +48,10 @@
     * container.
     *
     */
-   protected InvokableContext container;
+   private InvokableContext container;
 
+   private Object proxy;
+
    /**
     * Constructor
     * @param container
@@ -60,34 +63,22 @@
    }
 
    /**
-    * Each type of {@link NoInterfaceViewInvocationHandler} are responsible for
-    * handling the invocation through the no-interface view appropriately.
-    *
-    * @see StatelessNoInterfaceViewInvocationHandler#doInvoke(Object, Method, Object[])
-    * @see StatefulNoInterfaceViewInvocationHandler#doInvoke(Object, Method, Object[])
-    *
-    * @param proxy The proxy/no-interface view through which the call was triggered
-    * @param method The invoked method
-    * @param args The arguments to the method
-    */
-   public abstract Object doInvoke(Object proxy, Method method, Object[] args) throws Throwable;
-
-   /**
     * The entry point when a client calls any methods on the no-interface view of a bean,
     * returned through JNDI.
     *
     * This method will do the common steps (common for SLSB and SFSB) before passing on the
     * call to {@link #doInvoke(Object, Method, Object[])}
     *
-    * @param proxy The proxy/no-interface view through which the call was triggered
+    * @param obj
     * @param method The invoked method
     * @param args The arguments to the method
     */
-   public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+   public Object invoke(Object obj, Method method, Object[] args) throws Throwable
    {
       // TODO: Some methods like toString() can be handled locally.
       // But as of now let's just pass it on to the container.
-      return doInvoke(proxy, method, args);
+      SerializableMethod serializableMethod = new SerializableMethod(method);
+      return getContainer().invoke(this.proxy, serializableMethod, args);
    }
 
    /**
@@ -100,4 +91,14 @@
       return this.container;
    }
 
+   public void setProxy(Object proxy)
+   {
+      this.proxy = proxy;
+   }
+
+   public Object getProxy()
+   {
+      return this.proxy;
+   }
+
 }

Deleted: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/StatefulNoInterfaceViewInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/StatefulNoInterfaceViewInvocationHandler.java	2009-03-10 09:38:17 UTC (rev 85667)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/StatefulNoInterfaceViewInvocationHandler.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -1,102 +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.invocationhandler;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.proxy.container.InvokableContext;
-import org.jboss.logging.Logger;
-
-/**
- * StatefulNoInterfaceViewInvocationHandler
- *
- * Responsible for handling invocations to a stateful bean through the no-interface
- * view of the bean
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class StatefulNoInterfaceViewInvocationHandler extends NoInterfaceViewInvocationHandler
-{
-
-   /**
-    * Logger
-    */
-   private static Logger logger = Logger.getLogger(StatefulNoInterfaceViewInvocationHandler.class);
-
-   /**
-    * A stateful bean is invoked within a session. This represents the
-    * session id.
-    */
-   private Serializable sessionId;
-
-   /**
-    * Constructor
-    *
-    * @param container
-    */
-   public StatefulNoInterfaceViewInvocationHandler(InvokableContext container)
-   {
-      super(container);
-   }
-
-   /**
-    * Associates a session with this invocation handler
-    *
-    * @param session
-    */
-   public void setSessionId(Serializable session)
-   {
-      this.sessionId = session;
-   }
-
-   /**
-    * Returns the session id corresponds to this invocation handler
-    * @return
-    */
-   public Serializable getSessionId()
-   {
-      return this.sessionId;
-   }
-
-   /**
-    * This is where the invocation to the container takes place.
-    */
-   @Override
-   public Object doInvoke(Object proxy, Method method, Object[] args) throws Throwable
-   {
-
-      assert this.container != null : "Container not yet available to the no-interface view invocation handler";
-
-      SerializableMethod serializableMethod = new SerializableMethod(method);
-      if (logger.isTraceEnabled())
-      {
-         logger.trace("Invoking container method " + serializableMethod + " for session " + this.getSessionId());
-      }
-
-      return this.container.invoke(this.getSessionId(), serializableMethod, args);
-
-   }
-
-}

Deleted: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/StatelessNoInterfaceViewInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/StatelessNoInterfaceViewInvocationHandler.java	2009-03-10 09:38:17 UTC (rev 85667)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/invocationhandler/StatelessNoInterfaceViewInvocationHandler.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -1,69 +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.invocationhandler;
-
-import java.lang.reflect.Method;
-
-import org.apache.log4j.Logger;
-import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.proxy.container.InvokableContext;
-
-/**
- * StatelessNoInterfaceViewInvocationHandler
- *
- * Responsible for handling invocations to a stateless session bean
- * through the no-interface view of the bean
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class StatelessNoInterfaceViewInvocationHandler extends NoInterfaceViewInvocationHandler
-{
-
-   /**
-    * Logger
-    */
-   private static Logger logger = Logger.getLogger(StatelessNoInterfaceViewInvocationHandler.class);
-
-   /**
-    * Constructor
-    *
-    * @param container
-    */
-   public StatelessNoInterfaceViewInvocationHandler(InvokableContext container)
-   {
-      super(container);
-   }
-
-   /**
-    * This is where the invocation on the container is done
-    */
-   @Override
-   public Object doInvoke(Object proxy, Method method, Object[] args) throws Throwable
-   {
-      assert this.container != null : "Container not yet available to the no-interface view invocation handler";
-
-      SerializableMethod serializableMethod = new SerializableMethod(method);
-
-      return this.container.invoke(null, serializableMethod, args);
-   }
-}

Copied: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/NoInterfaceViewJNDIBinder.java (from rev 85161, projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/NoInterfaceViewMCBean.java)
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/NoInterfaceViewJNDIBinder.java	                        (rev 0)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/NoInterfaceViewJNDIBinder.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -0,0 +1,129 @@
+/*
+ * 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.mc;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.beans.metadata.api.annotations.Start;
+import org.jboss.beans.metadata.api.annotations.Stop;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * NoInterfaceViewMCBean
+ *
+ * A {@link NoInterfaceViewJNDIBinder} corresponds to a EJB which is eligible
+ * for a no-interface view
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public abstract class NoInterfaceViewJNDIBinder
+{
+
+   /**
+    * Logger
+    */
+   private static Logger logger = Logger.getLogger(NoInterfaceViewJNDIBinder.class);
+
+   /**
+    * The container for which this {@link NoInterfaceViewJNDIBinder} holds
+    * an no-interface view
+    */
+   protected InvokableContext container;
+
+   /**
+    * The bean class for which the no-interface view corresponds
+    */
+   protected Class<?> beanClass;
+
+   /**
+    * The bean metadata
+    */
+   protected JBossSessionBeanMetaData sessionBeanMetadata;
+
+   public static NoInterfaceViewJNDIBinder getNoInterfaceViewJndiBinder(Class<?> beanClass,
+         JBossSessionBeanMetaData sessionBeanMetadata)
+   {
+      return sessionBeanMetadata.isStateful()
+            ? new StatefulNoInterfaceJNDIBinder(beanClass, sessionBeanMetadata)
+            : new StatelessNoInterfaceJNDIBinder(beanClass, sessionBeanMetadata);
+   }
+
+   /**
+    * Constructor
+    *
+    * @param beanClass
+    * @param sessionBeanMetadata
+    */
+   protected NoInterfaceViewJNDIBinder(Class<?> beanClass, JBossSessionBeanMetaData sessionBeanMetadata)
+   {
+      this.beanClass = beanClass;
+      this.sessionBeanMetadata = sessionBeanMetadata;
+
+   }
+
+   public abstract void bindNoInterfaceView() throws Exception;
+
+   /**
+    * Will be called when the dependencies of this {@link NoInterfaceViewJNDIBinder} are
+    * resolved and this MC bean reaches the START state.
+    *
+    * At this point, the <code>container</code> associated with this {@link NoInterfaceViewJNDIBinder}
+    * is injected and is at a minimal of DESCRIBED state. We now create a no-interface view
+    * for the corresponding bean.
+    * Note: No validations (like whether the bean is eligible for no-interface view) is done at this
+    * stage. It's assumed that the presence of a {@link NoInterfaceViewJNDIBinder} indicates that the
+    * corresponding bean is eligible for no-interface view.
+    *
+    * @throws Exception
+    */
+   @Start
+   public void onStart() throws Exception
+   {
+      if (logger.isTraceEnabled())
+      {
+         logger.trace("Creating no-interface view for container " + this.container);
+      }
+
+      this.bindNoInterfaceView();
+   }
+
+   @Stop
+   public void onStop() throws Exception
+   {
+
+      //TODO need to unbind
+   }
+
+   // Bean name will be added to this Inject by the deployer.
+   // We need not use the annotation here at all, since the deployer adds this
+   // dynamically. But having this here provides a better understanding about how
+   // this field is used
+   @Inject(dependentState = "Described")
+   public void setContainer(InvokableContext container) throws Exception
+   {
+      this.container = container;
+
+   }
+
+}

Deleted: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/NoInterfaceViewMCBean.java
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/NoInterfaceViewMCBean.java	2009-03-10 09:38:17 UTC (rev 85667)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/NoInterfaceViewMCBean.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -1,126 +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.mc;
-
-import org.jboss.beans.metadata.api.annotations.Inject;
-import org.jboss.beans.metadata.api.annotations.InstallMethod;
-import org.jboss.beans.metadata.api.annotations.UninstallMethod;
-import org.jboss.ejb3.nointerface.jndi.NoInterfaceViewJNDIBinder;
-import org.jboss.ejb3.proxy.container.InvokableContext;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-
-/**
- * NoInterfaceViewMCBean
- *
- * A {@link NoInterfaceViewMCBean} corresponds to a EJB which is eligible
- * for a no-interface view
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class NoInterfaceViewMCBean
-{
-
-   /**
-    * Logger
-    */
-   private static Logger logger = Logger.getLogger(NoInterfaceViewMCBean.class);
-
-   /**
-    * The container for which this {@link NoInterfaceViewMCBean} holds
-    * an no-interface view
-    */
-   private InvokableContext container;
-
-   /**
-    * The bean class for which the no-interface view corresponds
-    */
-   private Class<?> beanClass;
-
-   /**
-    * The bean metadata
-    */
-   private JBossSessionBeanMetaData sessionBeanMetadata;
-
-   /**
-    * The {@link NoInterfaceViewJNDIBinder} which will be used for binding
-    * the no-interface view/stateful factory for the corresponding bean
-    */
-   private NoInterfaceViewJNDIBinder jndiBinder;
-
-   /**
-    * Constructor
-    *
-    * @param beanClass
-    * @param sessionBeanMetadata
-    */
-   public NoInterfaceViewMCBean(Class<?> beanClass, JBossSessionBeanMetaData sessionBeanMetadata)
-   {
-      this.beanClass = beanClass;
-      this.sessionBeanMetadata = sessionBeanMetadata;
-      this.jndiBinder = NoInterfaceViewJNDIBinder.getJNDIBinder(sessionBeanMetadata);
-   }
-
-   /**
-    * Will be called when the dependencies of this {@link NoInterfaceViewMCBean} are
-    * resolved and this MC bean reaches the INSTALL state.
-    *
-    * At this point, the <code>container</code> associated with this {@link NoInterfaceViewMCBean}
-    * is injected and is at a minimal of DESCRIBED state. We now create a no-interface view
-    * for the corresponding bean.
-    * Note: No validations (like whether the bean is eligible for no-interface view) is done at this
-    * stage. It's assumed that the presence of a {@link NoInterfaceViewMCBean} indicates that the
-    * corresponding bean is eligible for no-interface view.
-    *
-    * @throws Exception
-    */
-   @InstallMethod
-   public void onInstall() throws Exception
-   {
-      if (logger.isTraceEnabled())
-      {
-         logger.trace("Creating no-interface view for container " + this.container);
-      }
-
-      this.jndiBinder.bindNoInterfaceView(this.beanClass, this.container, this.sessionBeanMetadata);
-   }
-
-   @UninstallMethod
-   public void onUnInstall() throws Exception
-   {
-
-      //TODO need to unbind
-   }
-
-   // Bean name will be added to this Inject by the deployer.
-   // We need not use the annotation here at all, since the deployer adds this
-   // dynamically. But having this here provides a better understanding about how
-   // this field is used
-   @Inject(dependentState = "Described")
-   public void setContainer(InvokableContext container) throws Exception
-   {
-      this.container = container;
-
-   }
-
-}

Copied: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/StatefulNoInterfaceJNDIBinder.java (from rev 85161, projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/jndi/StatefulNoInterfaceJNDIBinder.java)
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/StatefulNoInterfaceJNDIBinder.java	                        (rev 0)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/StatefulNoInterfaceJNDIBinder.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -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.mc;
+
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+
+import org.jboss.ejb3.nointerface.factory.StatefulNoInterfaceViewFactory;
+import org.jboss.ejb3.nointerface.objectfactory.NoInterfaceViewProxyFactoryRefAddrTypes;
+import org.jboss.ejb3.nointerface.objectfactory.StatefulNoInterfaceViewObjectFactory;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.util.naming.NonSerializableFactory;
+import org.jnp.interfaces.NamingParser;
+
+/**
+ * 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 NoInterfaceViewJNDIBinder
+{
+
+   /**
+    * Logger
+    */
+   private static Logger logger = Logger.getLogger(StatefulNoInterfaceJNDIBinder.class);
+
+   protected StatefulNoInterfaceJNDIBinder(Class<?> beanClass, JBossSessionBeanMetaData sessionBeanMetadata)
+   {
+      super(beanClass, sessionBeanMetadata);
+
+   }
+
+   /**
+    * 1) Creates a {@link StatefulNoInterfaceViewFactory} 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 void bindNoInterfaceView() throws Exception
+   {
+      logger.debug("Binding no-interface view statefulproxyfactory and the objectfactory for bean " + this.beanClass);
+
+      // This factory will be bound to JNDI and will be invoked (through an objectfactory) to create
+      // the no-interface view for a SFSB
+      StatefulNoInterfaceViewFactory statefulNoInterfaceViewFactory = new StatefulNoInterfaceViewFactory(
+            this.beanClass, this.container);
+
+      // TODO - Needs to be a proper jndi name for the factory
+      String statefulProxyFactoryJndiName = sessionBeanMetadata.getEjbName() + "/no-interface-stateful-proxyfactory";
+      // Bind the proxy factory to jndi
+      // Bind a reference to nonserializable using NonSerializableFactory as the ObjectFactory
+      NamingParser namingParser = new NamingParser();
+      Name jndiName = namingParser.parse(statefulProxyFactoryJndiName);
+      NonSerializableFactory.rebind(jndiName, 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);
+
+      // TODO: Again, the jndi-names for the no-interface view are a mess now. They need to come from
+      // the metadata. Let's just go ahead temporarily
+      String noInterfaceJndiName = sessionBeanMetadata.getEjbName() + "/no-interface";
+      // TODO : This is not right - i guess there is some way to get hold of the initial context
+      // for a given deployment. Need to look more into this
+      new InitialContext().bind(noInterfaceJndiName, reference);
+
+      logger.info("Bound the no-interface view for bean " + beanClass + " to jndi at " + noInterfaceJndiName);
+
+   }
+
+}

Copied: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/StatelessNoInterfaceJNDIBinder.java (from rev 85161, projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/jndi/StatelessNoInterfaceJNDIBinder.java)
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/StatelessNoInterfaceJNDIBinder.java	                        (rev 0)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/StatelessNoInterfaceJNDIBinder.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -0,0 +1,83 @@
+/*
+ * 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.mc;
+
+import javax.naming.Name;
+
+import org.jboss.ejb3.nointerface.NoInterfaceEJBViewCreator;
+import org.jboss.ejb3.nointerface.invocationhandler.NoInterfaceViewInvocationHandler;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.util.naming.NonSerializableFactory;
+import org.jnp.interfaces.NamingParser;
+
+/**
+ * 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 NoInterfaceViewJNDIBinder
+{
+
+   /**
+    * Logger
+    */
+   private static Logger logger = Logger.getLogger(StatelessNoInterfaceJNDIBinder.class);
+
+   protected StatelessNoInterfaceJNDIBinder(Class<?> beanClass, JBossSessionBeanMetaData sessionBeanMetadata)
+   {
+      super(beanClass, sessionBeanMetadata);
+   }
+
+   /**
+    * 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 NoInterfaceEJBViewCreator#createView(java.lang.reflect.InvocationHandler, Class)
+    */
+   @Override
+   public void bindNoInterfaceView() throws Exception
+   {
+      logger.debug("Creating no-interface view for bean " + this.beanClass);
+
+      // Create the view and bind to jndi
+      NoInterfaceEJBViewCreator noInterfaceViewCreator = new NoInterfaceEJBViewCreator();
+      Object noInterfaceView = noInterfaceViewCreator.createView(new NoInterfaceViewInvocationHandler(this.container),
+            beanClass);
+      // bind
+      // TODO: Again, the jndi-names for the no-interface view are a mess now. They need to come from
+      // the metadata. Let's just go ahead temporarily
+      String noInterfaceJndiName = sessionBeanMetadata.getEjbName() + "/no-interface";
+      // Bind a reference to nonserializable using NonSerializableFactory as the ObjectFactory
+      NamingParser namingParser = new NamingParser();
+      Name jndiName = namingParser.parse(noInterfaceJndiName);
+      NonSerializableFactory.rebind(jndiName, noInterfaceView, true);
+
+      logger.info("Bound the no-interface view for bean " + beanClass + " to jndi at " + noInterfaceJndiName);
+
+   }
+
+}


Property changes on: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/mc/StatelessNoInterfaceJNDIBinder.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/objectfactory/StatefulNoInterfaceViewObjectFactory.java
===================================================================
--- projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/objectfactory/StatefulNoInterfaceViewObjectFactory.java	2009-03-10 09:38:17 UTC (rev 85667)
+++ projects/ejb3/trunk/nointerface/src/main/java/org/jboss/ejb3/nointerface/objectfactory/StatefulNoInterfaceViewObjectFactory.java	2009-03-10 09:44:50 UTC (rev 85668)
@@ -21,7 +21,6 @@
  */
 package org.jboss.ejb3.nointerface.objectfactory;
 
-import java.util.Enumeration;
 import java.util.Hashtable;
 
 import javax.naming.Context;
@@ -74,22 +73,13 @@
 
    protected String getProxyFactoryJNDINameFromReference(Reference ref)
    {
-      Enumeration<RefAddr> refAddrs = ref.getAll();
-      while (refAddrs.hasMoreElements())
-      {
-         RefAddr refAddr = refAddrs.nextElement();
-         String type = refAddr.getType();
-         if (type
-               .equals(NoInterfaceViewProxyFactoryRefAddrTypes.STATEFUL_NO_INTERFACE_VIEW_PROXY_FACTORY_JNDI_LOCATION))
-         {
-            Object jndiNameOfStatefulProxyFactory = refAddr.getContent();
-            assert jndiNameOfStatefulProxyFactory instanceof String : "Unexpected type for "
-                  + NoInterfaceViewProxyFactoryRefAddrTypes.STATEFUL_NO_INTERFACE_VIEW_PROXY_FACTORY_JNDI_LOCATION;
+      RefAddr refAddr = ref
+            .get(NoInterfaceViewProxyFactoryRefAddrTypes.STATEFUL_NO_INTERFACE_VIEW_PROXY_FACTORY_JNDI_LOCATION);
+      Object jndiNameOfStatefulProxyFactory = refAddr.getContent();
+      assert jndiNameOfStatefulProxyFactory instanceof String : "Unexpected type for "
+            + NoInterfaceViewProxyFactoryRefAddrTypes.STATEFUL_NO_INTERFACE_VIEW_PROXY_FACTORY_JNDI_LOCATION;
 
-            return (String) jndiNameOfStatefulProxyFactory;
-         }
-      }
-      return null;
+      return (String) jndiNameOfStatefulProxyFactory;
    }
 
 }

Modified: projects/ejb3/trunk/nointerface/src/test/resources/log4j.xml
===================================================================
--- projects/ejb3/trunk/nointerface/src/test/resources/log4j.xml	2009-03-10 09:38:17 UTC (rev 85667)
+++ projects/ejb3/trunk/nointerface/src/test/resources/log4j.xml	2009-03-10 09:44:50 UTC (rev 85668)
@@ -23,7 +23,7 @@
   <!-- A time/date based rolling appender -->
   <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
     <param name="File" value="target/test.log"/>
-    <param name="Threshold" value="TRACE"/>
+    <param name="Threshold" value="DEBUG"/>
     <param name="Append" value="false"/>
 
     <!-- Rollover at midnight each day -->




More information about the jboss-cvs-commits mailing list