Index: src/test/java/org/jboss/ejb3/test/ejbthree1950/unit/RemoteInvocationJoinpointTestCase.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/ejbthree1950/unit/RemoteInvocationJoinpointTestCase.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/ejbthree1950/unit/RemoteInvocationJoinpointTestCase.java	(revision 0)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ejbthree1950.unit;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.jboss.ejb3.test.ejbthree1950.CountingRemoteBusiness;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * RemoteInvocationJoinpointTestCase
+ * 
+ * EJBTHREE-1950
+ * 
+ * Ensures AOP joinpoints are honored from remote invocations upon
+ * an EJB.
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class RemoteInvocationJoinpointTestCase extends JBossTestCase
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------|| 
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(RemoteInvocationJoinpointTestCase.class);
+
+   // --------------------------------------------------------------------------------||
+   // Constructors -------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------|| 
+
+   public RemoteInvocationJoinpointTestCase(final String name)
+   {
+      super(name);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Suite --------------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------|| 
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(RemoteInvocationJoinpointTestCase.class,
+            "../tests-classes/test/ejbthree1950/jboss-aop.xml,ejbthree1950.jar");
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Tests --------------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * The control; the counter should be incremented when invoked 
+    * from inside the EJB
+    * 
+    * TODO This one currently fails too, though AOP picks up the registration:
+    *
+    *  2009-11-11 15:14:15,951 DEBUG [org.jboss.aop.microcontainer.beans.Aspect] (RMI TCP Connection(4)-127.0.0.1) Bound aspect CountIncrementingInterceptor; deployed:true
+    *  2009-11-11 15:14:15,984 DEBUG [org.jboss.aop.microcontainer.beans.AspectBinding] (RMI TCP Connection(4)-127.0.0.1) Bound binding 3j001-g3wo27-g1wj26z1-1-g1wj4nyr-9s
+    */
+   public void testCounterFromLocalInvocation() throws Exception
+   {
+      // Log
+      log.info("testCounterFromLocalInvocation");
+
+      // Obtain EJB
+      final CountingRemoteBusiness bean = this.lookupBean();
+
+      // Ensure we're at 0
+      int current = bean.getCounter();
+      final int expectedBeforeInvoke = 0;
+      TestCase.assertEquals("Counter should start at 0", expectedBeforeInvoke, current);
+      log.info("Counter before increment request: " + current);
+
+      // Invoke to increment manually
+      bean.incrementCounterManually();
+
+      // Ensure we were incremented
+      current = bean.getCounter();
+      log.info("Counter after increment request: " + current);
+      final int expectedAfterInvoke = 1;
+      TestCase.assertEquals("Counter should be 1 after call to increment manually", expectedAfterInvoke, current);
+
+      // Reset
+      bean.resetCounter();
+   }
+
+   /**
+    * Tests that the counter may be incremented from an aspect
+    * triggered by a joinpoint during remote method invocation
+    */
+   public void testCounterFromRemoteInvocation() throws Exception
+   {
+      // Log
+      log.info("testCounterFromRemoteInvocation");
+
+      // Obtain EJB
+      final CountingRemoteBusiness bean = this.lookupBean();
+
+      // Ensure we're at 0
+      int current = bean.getCounter();
+      final int expectedBeforeInvoke = 0;
+      TestCase.assertEquals("Counter should start at 0", expectedBeforeInvoke, current);
+      log.info("Counter before increment request: " + current);
+
+      // Invoke to increment via the interceptor
+      bean.incrementCounterViaInterceptor();
+
+      // Ensure we were incremented
+      current = bean.getCounter();
+      log.info("Counter after increment request: " + current);
+      final int expectedAfterInvoke = 1;
+      TestCase
+            .assertEquals("Counter should be 1 after call to increment via interceptor", expectedAfterInvoke, current);
+
+      // Reset
+      bean.resetCounter();
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Internal Helper Methods --------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Looks up the EJB for invocation
+    * @throws Exception
+    */
+   private CountingRemoteBusiness lookupBean() throws Exception
+   {
+      return (CountingRemoteBusiness) this.getInitialContext().lookup(CountingRemoteBusiness.JNDI_NAME);
+   }
+
+}
Index: src/test/java/org/jboss/ejb3/test/ejbthree1950/Increment.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/ejbthree1950/Increment.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/ejbthree1950/Increment.java	(revision 0)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ejbthree1950;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Increment
+ * 
+ * Annotation denoting that invocations should increment the
+ * global {@link GlobalThreadsafeCounter}
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Increment {
+
+}
Index: src/test/java/org/jboss/ejb3/test/ejbthree1950/GlobalThreadsafeCounter.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/ejbthree1950/GlobalThreadsafeCounter.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/ejbthree1950/GlobalThreadsafeCounter.java	(revision 0)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ejbthree1950;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.jboss.logging.Logger;
+
+/**
+ * ThreadsafeCountingImpl
+ *
+ * Threadsafe counter, for this test will be 
+ * incremented when methods marked with
+ * {@link Increment} are invoked.
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public final class GlobalThreadsafeCounter
+{
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(GlobalThreadsafeCounter.class);
+
+   /**
+    * Counter
+    */
+   private static final AtomicInteger counter = new AtomicInteger();
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * No instantiation
+    */
+   private GlobalThreadsafeCounter()
+   {
+      throw new UnsupportedOperationException("No instances allowed");
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Functional Methods -----------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the counter's current value
+    */
+   public static int getCounter()
+   {
+      return counter.get();
+   }
+
+   /**
+    * Increments the counter
+    */
+   public static void incrementCounter()
+   {
+      final int newValue = counter.incrementAndGet();
+      log.info("Incrementing to: " + newValue);
+   }
+
+   /**
+    * Resets the counter
+    */
+   public static void reset()
+   {
+      counter.set(0);
+      log.info("Counter reset");
+   }
+}
Index: src/test/java/org/jboss/ejb3/test/ejbthree1950/CountIncrementingInterceptor.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/ejbthree1950/CountIncrementingInterceptor.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/ejbthree1950/CountIncrementingInterceptor.java	(revision 0)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ejbthree1950;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+
+/**
+ * CountIncrementingInterceptor
+ * 
+ * Aspect which, when invoked, will increment the global counter once
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class CountIncrementingInterceptor implements Interceptor
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(CountIncrementingInterceptor.class);
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   public CountIncrementingInterceptor()
+   {
+      final Exception e = new Exception("Printing stack trace only");
+      log.info(e.getMessage(), e);
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * @see org.jboss.aop.advice.Interceptor#getName()
+    */
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+
+   /**
+    * @see org.jboss.aop.advice.Interceptor#invoke(org.jboss.aop.joinpoint.Invocation)
+    */
+   public Object invoke(final Invocation invocation) throws Throwable
+   {
+      // Increment
+      GlobalThreadsafeCounter.incrementCounter();
+
+      // Keep going
+      return invocation.invokeNext();
+   }
+
+}
Index: src/test/java/org/jboss/ejb3/test/ejbthree1950/CountingBean.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/ejbthree1950/CountingBean.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/ejbthree1950/CountingBean.java	(revision 0)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ejbthree1950;
+
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.logging.Logger;
+
+/**
+ * CountingBean
+ * 
+ * SLSB able to count and report the current counter
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+@Stateless
+@RemoteBinding(jndiBinding = CountingRemoteBusiness.JNDI_NAME)
+public class CountingBean implements CountingRemoteBusiness
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(CountingBean.class);
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * {@inheritDoc}
+    * @see org.jboss.ejb3.test.ejbthree1950.Countable#getCounter()
+    */
+   public int getCounter()
+   {
+      // Delegate
+      return GlobalThreadsafeCounter.getCounter();
+   }
+
+   /**
+    * {@inheritDoc}
+    * @see org.jboss.ejb3.test.ejbthree1950.Countable#incrementCounterViaInterceptor()
+    */
+   @Increment
+   public void incrementCounterViaInterceptor()
+   {
+      // NOOP, the Interceptor should handle this due to the @Increment annotation
+      log.info("Invoked to increment counter via interceptor, but this is a NOOP itself");
+      return;
+
+   }
+
+   /**
+    * @see org.jboss.ejb3.test.ejbthree1950.CountingRemoteBusiness#incrementCounterManually()
+    */
+   public void incrementCounterManually()
+   {
+      log.info("Invoked to increment counter manually");
+      this.incrementCounterViaInterceptor();
+   }
+
+   /**
+    * {@inheritDoc}
+    * @see org.jboss.ejb3.test.ejbthree1950.CountingRemoteBusiness#resetCounter()
+    */
+   public void resetCounter()
+   {
+      GlobalThreadsafeCounter.reset();
+
+   }
+
+}
Index: src/test/java/org/jboss/ejb3/test/ejbthree1950/CountingRemoteBusiness.java
===================================================================
--- src/test/java/org/jboss/ejb3/test/ejbthree1950/CountingRemoteBusiness.java	(revision 0)
+++ src/test/java/org/jboss/ejb3/test/ejbthree1950/CountingRemoteBusiness.java	(revision 0)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.ejbthree1950;
+
+import javax.ejb.Remote;
+
+/**
+ * CountingRemoteBusiness
+ *
+ * Remote business interface of an EJB able to count
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+@Remote
+public interface CountingRemoteBusiness
+{
+   //-------------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Name into which we'll bind in JNDI
+    */
+   String JNDI_NAME = "ejbthree1950/remote";
+
+   /**
+    * Obtains the counter's current value
+    */
+   int getCounter();
+
+   /**
+    * Increments the counter by nature of an interceptor
+    * binding
+    */
+   void incrementCounterViaInterceptor();
+
+   /**
+    * Increments the counter by manually calling 
+    * a method with an interceptor binding
+    */
+   void incrementCounterManually();
+
+   /**
+    * Resets the counter
+    */
+   void resetCounter();
+}
Index: src/test/resources/test/ejbthree1950/jboss-aop.xml
===================================================================
--- src/test/resources/test/ejbthree1950/jboss-aop.xml	(revision 0)
+++ src/test/resources/test/ejbthree1950/jboss-aop.xml	(revision 0)
@@ -0,0 +1,10 @@
+<aop xmlns="urn:jboss:aop-beans:1.0">
+
+    <!-- Declare an incrementing counter interceptor -->
+    <interceptor name="CountIncrementingInterceptor" class="org.jboss.ejb3.test.ejbthree1950.CountIncrementingInterceptor1" scope="PER_VM"/>
+
+    <!-- For all methods annotated with @Increment, execute the CountIncrementingInterceptor -->    
+    <bind pointcut="all(@org.jboss.ejb3.test.ejbthree1950.Increment)">
+        <interceptor-ref name="CountIncrementingInterceptor" />
+    </bind>
+</aop> 
\ No newline at end of file
Index: build-test.xml
===================================================================
--- build-test.xml	(revision 96263)
+++ build-test.xml	(working copy)
@@ -4241,6 +4241,19 @@
 	<target name="ejbthree1926">
 	      <build-simple-jar name="ejbthree1926"/>
 	</target>
+	
+	<target name="ejbthree1950">
+		<!-- <mkdir dir="${build.lib}"/>
+		  <jar jarfile="${build.lib}/ejbthree1950.jar">
+		  <fileset dir="${build.classes}">
+		    <include name="org/jboss/ejb3/test/ejbthree1950/*.class"/>
+		  </fileset>
+		  <fileset dir="${resources}/test/ejbthree1950">
+		    <include name="**/*.*"/>
+		  </fileset>
+	  </jar> -->
+		<build-simple-jar name="ejbthree1950"/>
+	</target>
     	
    <target name="jars" depends="statefulproxyfactoryoverride, removedislocal, statelesscreation, defaultremotebindings, localfromremote, clusteredjms, concurrentnaming, propertyreplacement, persistenceunits, appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
       concurrent,
@@ -4273,7 +4286,7 @@
       composite, composite2, entitycallback, relationships, ssl, ssladvanced, clusteredsession, strictpool, jacc,
       localcall, interceptors, interceptors2, interceptors3, iiop, clientinterceptor,
       statelesscreation, changexml, externalrefscoped, singleton, ejbthree1671, ejbthree1677, ejbthree1629, 
-      ejbthree1807, ejbthree1346, ejbthree1823, ejbthree1858, ejbthree1876, ejbthree1926"/>
+      ejbthree1807, ejbthree1346, ejbthree1823, ejbthree1858, ejbthree1876, ejbthree1926, ejbthree1950"/>
 
    <target name="test" depends="init" if="test"
       description="Execute all tests in the given test directory.">
@@ -5101,6 +5114,9 @@
          <param name="test" value="ejbthree1889"/>
       </antcall>
       <antcall target="test" inheritRefs="true">
+         <param name="test" value="ejbthree1950"/>
+      </antcall>
+      <antcall target="test" inheritRefs="true">
          <param name="test" value="statelesscreation"/>
       </antcall>
       <antcall target="test" inheritRefs="true">
