User: oberg
Date: 00/05/31 07:37:24
Modified: src/main/org/jboss/ejb ContainerFactory.java
EntityContainer.java StatelessSessionContainer.java
Log:
Added synchronization option to singleton pool, and fixed stateless session method
mapping procedure
Revision Changes Path
1.12 +7 -7 jboss/src/main/org/jboss/ejb/ContainerFactory.java
Index: ContainerFactory.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/ContainerFactory.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ContainerFactory.java 2000/05/31 07:24:05 1.11
+++ ContainerFactory.java 2000/05/31 14:37:23 1.12
@@ -59,7 +59,7 @@
* @see Container
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
*/
public class ContainerFactory
implements ContainerFactoryMBean, MBeanRegistration
@@ -217,10 +217,10 @@
con.setInstancePool((InstancePool)cl.loadClass(conf.getInstancePool()).newInstance());
// Create interceptors
- con.addInterceptor(new LogInterceptor());
- con.addInterceptor(new TxInterceptor());
+// con.addInterceptor(new LogInterceptor());
+// con.addInterceptor(new SecurityInterceptor());
+// con.addInterceptor(new TxInterceptor());
con.addInterceptor(new StatelessSessionInstanceInterceptor());
- con.addInterceptor(new SecurityInterceptor());
con.addInterceptor(con.createContainerInterceptor());
@@ -280,10 +280,10 @@
// Create interceptors
- con.addInterceptor(new LogInterceptor());
- con.addInterceptor(new TxInterceptor());
+// con.addInterceptor(new LogInterceptor());
+// con.addInterceptor(new SecurityInterceptor());
+// con.addInterceptor(new TxInterceptor());
con.addInterceptor(new
EntityInstanceInterceptor());
- con.addInterceptor(new SecurityInterceptor());
con.addInterceptor(new
EntitySynchronizationInterceptor());
con.addInterceptor(con.createContainerInterceptor());
1.5 +2 -2 jboss/src/main/org/jboss/ejb/EntityContainer.java
Index: EntityContainer.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/EntityContainer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- EntityContainer.java 2000/05/30 18:32:16 1.4
+++ EntityContainer.java 2000/05/31 14:37:24 1.5
@@ -32,7 +32,7 @@
* @see Container
* @see EntityEnterpriseContext
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class EntityContainer
extends Container
@@ -392,7 +392,7 @@
Method m = (Method)beanMapping.get(method);
// Select instance to invoke (container or bean)
- if (m.getDeclaringClass().equals(EntityContainer.this.getClass()))
+ if (m.getDeclaringClass().equals(EntityContainer.class))
{
// Invoke and handle exceptions
try
1.4 +83 -48 jboss/src/main/org/jboss/ejb/StatelessSessionContainer.java
Index: StatelessSessionContainer.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/StatelessSessionContainer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StatelessSessionContainer.java 2000/05/30 18:32:16 1.3
+++ StatelessSessionContainer.java 2000/05/31 14:37:24 1.4
@@ -15,6 +15,7 @@
import javax.ejb.Handle;
import javax.ejb.HomeHandle;
import javax.ejb.EJBObject;
+import javax.ejb.EJBHome;
import javax.ejb.EJBMetaData;
import javax.ejb.CreateException;
import javax.ejb.RemoveException;
@@ -24,7 +25,7 @@
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class StatelessSessionContainer
extends Container
@@ -153,12 +154,37 @@
}
// EJBObject implementation --------------------------------------
- public void remove()
+ public void remove(Method m, Object[] args, StatelessSessionEnterpriseContext
ctx)
throws java.rmi.RemoteException, RemoveException
{
+ // Do nothing
+ }
+
+ public Handle getHandle(Method m, Object[] args,
StatelessSessionEnterpriseContext ctx)
+ throws java.rmi.RemoteException
+ {
// TODO
+ throw new Error("Not yet implemented");
}
+ public Object getPrimaryKey(Method m, Object[] args,
StatelessSessionEnterpriseContext ctx)
+ throws java.rmi.RemoteException
+ {
+ throw new java.rmi.RemoteException("Sessions do not have primary
keys");
+ }
+
+ public EJBHome getEJBHome(Method m, Object[] args,
StatelessSessionEnterpriseContext ctx)
+ throws java.rmi.RemoteException
+ {
+ return containerInvoker.getEJBHome();
+ }
+
+ public boolean isIdentical(Method m, Object[] args,
StatelessSessionEnterpriseContext ctx)
+ throws java.rmi.RemoteException
+ {
+ throw new Error("Not yet implemented");
+ }
+
// EJBHome implementation ----------------------------------------
public EJBObject create()
throws java.rmi.RemoteException, CreateException
@@ -170,20 +196,19 @@
public void remove(Handle handle)
throws java.rmi.RemoteException, RemoveException
{
- // TODO
+ throw new Error("Not yet implemented");
}
public void remove(java.lang.Object primaryKey)
throws java.rmi.RemoteException, RemoveException
{
- // TODO
+ throw new Error("Not yet implemented");
}
public EJBMetaData getEJBMetaData()
throws java.rmi.RemoteException
{
- // TODO
- return null;
+ throw new Error("Not yet implemented");
}
public HomeHandle getHomeHandle()
@@ -195,46 +220,49 @@
// Protected ----------------------------------------------------
protected void setupHomeMapping()
- throws NoSuchMethodException
+ throws DeploymentException
{
Map map = new HashMap();
Method[] m = homeInterface.getMethods();
for (int i = 0; i < m.length; i++)
{
- // Implemented by container
-// System.out.println("Mapping "+m[i].getName());
- map.put(m[i], getClass().getMethod(m[i].getName(),
m[i].getParameterTypes()));
+ try
+ {
+ // Implemented by container
+ map.put(m[i], getClass().getMethod(m[i].getName(),
m[i].getParameterTypes()));
+ } catch (NoSuchMethodException e)
+ {
+ throw new DeploymentException("Could not find matching method for
"+m[i], e);
+ }
}
homeMapping = map;
}
protected void setupBeanMapping()
- throws NoSuchMethodException
+ throws DeploymentException
{
Map map = new HashMap();
Method[] m = remoteInterface.getMethods();
for (int i = 0; i < m.length; i++)
{
- if (!m[i].getDeclaringClass().equals(EJBObject.class))
- {
- // Implemented by bean
- map.put(m[i], beanClass.getMethod(m[i].getName(),
m[i].getParameterTypes()));
-// System.out.println("Mapped "+m[i].getName()+" "+m[i].hashCode());
-// System.out.println("to "+map.get(m[i]));
- }
- else
- {
- try
- {
+ try
+ {
+ if (!m[i].getDeclaringClass().equals(EJBObject.class))
+ {
+ // Implemented by bean
+ map.put(m[i], beanClass.getMethod(m[i].getName(),
m[i].getParameterTypes()));
+ }
+ else
+ {
// Implemented by container
- map.put(m[i], getClass().getMethod(m[i].getName(),
m[i].getParameterTypes()));
- } catch (NoSuchMethodException e)
- {
-// System.out.println(m[i].getName() + " in bean has not been
mapped");
- }
- }
+ map.put(m[i], getClass().getMethod(m[i].getName(), new Class[] {
Method.class, Object[].class , StatelessSessionEnterpriseContext.class}));
+ }
+ } catch (NoSuchMethodException e)
+ {
+ throw new DeploymentException("Could not find matching method for
"+m[i], e);
+ }
}
beanMapping = map;
@@ -271,29 +299,36 @@
{
// Get method and instance to invoke upon
Method m = (Method)beanMapping.get(method);
- Object instance;
- if
(m.getDeclaringClass().equals(StatelessSessionContainer.this.getClass()))
+
+ // Select instance to invoke (container or bean)
+ if (m.getDeclaringClass().equals(StatelessSessionContainer.class))
{
- instance = StatelessSessionContainer.this;
+ // Invoke and handle exceptions
+ try
+ {
+ return m.invoke(StatelessSessionContainer.this, new Object[] {
method, args, ctx });
+ } catch (InvocationTargetException e)
+ {
+ Throwable ex = e.getTargetException();
+ if (ex instanceof Exception)
+ throw (Exception)ex;
+ else
+ throw (Error)ex;
+ }
} else
- {
- instance = ctx.getInstance();
- }
-
- // Invoke and handle exceptions
- try
{
- Object res = m.invoke(instance, args);
-
- // Return result
- return res;
- } catch (InvocationTargetException e)
- {
- Throwable ex = e.getTargetException();
- if (ex instanceof Exception)
- throw (Exception)ex;
- else
- throw (Error)ex;
+ // Invoke and handle exceptions
+ try
+ {
+ return m.invoke(ctx.getInstance(), args);
+ } catch (InvocationTargetException e)
+ {
+ Throwable ex = e.getTargetException();
+ if (ex instanceof Exception)
+ throw (Exception)ex;
+ else
+ throw (Error)ex;
+ }
}
}
}