User: docodan
Date: 01/06/03 10:11:03
Modified:src/main/org/jboss/ejb/plugins/local
BaseLocalContainerInvoker.java LocalProxy.java
Added: src/main/org/jboss/ejb/plugins/local LocalHomeProxy.java
Log:
Added home local proxy (already had component local proxy).
Revision ChangesPath
1.2 +82 -7
jboss/src/main/org/jboss/ejb/plugins/local/BaseLocalContainerInvoker.java
Index: BaseLocalContainerInvoker.java
===
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/local/BaseLocalContainerInvoker.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseLocalContainerInvoker.java2001/06/03 16:28:48 1.1
+++ BaseLocalContainerInvoker.java2001/06/03 17:11:02 1.2
@@ -136,7 +136,10 @@
// ContainerInvoker implementation ---
public EJBLocalHome getEJBLocalHome()
{
- throw new UnsupportedOperationException();
+ ContainerInvokerContainer cic = (ContainerInvokerContainer) container;
+ return (EJBLocalHome) Proxy.newProxyInstance(
+ cic.getLocalHomeClass().getClassLoader(),
+ new Class[]{cic.getLocalHomeClass()}, new HomeProxy() );
}
public EJBLocalObject getStatelessSessionEJBLocalObject()
@@ -177,8 +180,7 @@
/**
* Invoke a Home interface method.
*/
- public Object invokeHome(Method m, Object[] args, Transaction tx,
- Principal identity, Object credential)
+ public Object invokeHome(Method m, Object[] args)
throws Exception
{
// Set the right context classloader
@@ -187,8 +189,8 @@
try
{
- return container.invokeHome(new MethodInvocation(null, m, args, tx,
-identity, credential));
+ return container.invokeHome(new MethodInvocation(null, m, args,
+getTransaction(), getPrincipal(), getCredential()));
} finally
{
Thread.currentThread().setContextClassLoader(oldCl);
@@ -242,6 +244,47 @@
Thread.currentThread().setContextClassLoader(oldCl);
}
}
+
+
+ class HomeProxy extends LocalHomeProxy
+ implements InvocationHandler
+ {
+ protected String getJndiName()
+ {
+ return jndiName;
+ }
+
+ protected Object getId()
+ {
+ return jndiName;
+ }
+
+ public final Object invoke(final Object proxy,
+ final Method m,
+ Object[] args)
+throws Throwable
+ {
+ if (args == null)
+ args = EMPTY_ARGS;
+
+ Object retValue = super.invoke( proxy, m, args );
+ if (retValue != null)
+ return retValue;
+
+else if (m.equals(REMOVE_BY_PRIMARY_KEY)) {
+// The trick is simple we trick the container in believe it
+// is a remove() on the instance
+Object id = new CacheKey(args[0]);
+return BaseLocalContainerInvoker.this.invoke(
+ id, REMOVE_OBJECT, EMPTY_ARGS);
+}
+ // If not taken care of, go on and call the container
+ else {
+ return BaseLocalContainerInvoker.this.invokeHome(
+ m, args);
+ }
+ }
+ }
class EntityProxy extends LocalProxy
implements InvocationHandler
@@ -255,6 +298,17 @@
cacheKey = (CacheKey) id;
}
+ protected String getJndiName()
+ {
+ return jndiName;
+ }
+
+ protected Object getId()
+ {
+ return cacheKey.id;
+ }
+
+
public final Object invoke(final Object proxy,
final Method m,
Object[] args)
@@ -263,7 +317,7 @@
if (args == null)
args = EMPTY_ARGS;
- Object retValue = super.invoke( proxy, m, args, jndiName, cacheKey.id );
+ Object retValue = super.invoke( proxy, m, args );
if (retValue != null)
return retValue;
// If not taken care of, go on and call the container
@@ -284,6 +338,16 @@
{
this.id = id;
}
+
+ protected String getJndiName()
+ {
+ return jndiName;
+ }
+
+ protected Object getId()
+ {
+ return id;
+ }
public final Object invoke(final Object proxy,
final Method m,
@@ -293,7 +357,7 @@
if (args == null)
args = EMPTY_ARGS;
- Object retValue =