User: dsundstrom
Date: 01/12/03 22:30:54
Modified: src/main/org/jboss/ejb/plugins/cmp/jdbc
JDBCCommandFactory.java JDBCStoreManager.java
Added: src/main/org/jboss/ejb/plugins/cmp/jdbc
JDBCCreateBeanClassInstanceCommand.java
Log:
Moved createBeanClassInstance code into a seperate command class.
Revision Changes Path
1.13 +9 -3
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
Index: JDBCCommandFactory.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- JDBCCommandFactory.java 2001/12/03 23:00:16 1.12
+++ JDBCCommandFactory.java 2001/12/04 06:30:53 1.13
@@ -17,7 +17,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Justin Forder</a>
* @author <a href="[EMAIL PROTECTED]">danch (Dan Christopherson</a>
- * @version $Revision: 1.12 $
+ * @version $Revision: 1.13 $
*/
public class JDBCCommandFactory {
private JDBCStoreManager manager;
@@ -92,11 +92,17 @@
return new JDBCDestroyCommand(manager);
}
+ // entity life cycle commands
+
+ public JDBCCreateBeanClassInstanceCommand
+ createCreateBeanClassInstanceCommand() throws Exception {
+
+ return new JDBCCreateBeanClassInstanceCommand(manager);
+ }
+
public JDBCInitEntityCommand createInitEntityCommand() {
return new JDBCInitEntityCommand(manager);
}
-
- // entity persistence-related commands
public JDBCFindEntityCommand createFindEntityCommand() {
return new JDBCFindEntityCommand(manager);
1.20 +5 -37
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
Index: JDBCStoreManager.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- JDBCStoreManager.java 2001/12/04 02:45:01 1.19
+++ JDBCStoreManager.java 2001/12/04 06:30:53 1.20
@@ -30,7 +30,6 @@
import org.jboss.ejb.EntityPersistenceStore;
import org.jboss.ejb.EntityEnterpriseContext;
import org.jboss.ejb.ListCacheKey;
-import org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler;
import org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMPFieldBridge;
import org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge;
import org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge;
@@ -39,13 +38,10 @@
import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader;
import org.jboss.logging.Logger;
import org.jboss.metadata.ApplicationMetaData;
-import org.jboss.proxy.Proxy;
import org.jboss.util.CachePolicy;
import org.jboss.util.FinderResults;
import org.jboss.util.LRUCachePolicy;
-import java.lang.reflect.Constructor;
-import org.jboss.proxy.InvocationHandler;
/**
* JDBCStoreManager manages storage of persistence data into a table.
* Other then loading the initial jbosscmp-jdbc.xml file this class
@@ -61,7 +57,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
* @see org.jboss.ejb.EntityPersistenceStore
- * @version $Revision: 1.19 $
+ * @version $Revision: 1.20 $
*/
public class JDBCStoreManager implements EntityPersistenceStore {
@@ -71,8 +67,6 @@
*/
private static final Object NULL_VALUE = new Object();
- private Constructor beanProxyConstructor;
-
private EntityContainer container;
private Logger log;
@@ -91,6 +85,7 @@
private JDBCDestroyCommand destroyCommand;
// Entity life cycle commands
+ private JDBCCreateBeanClassInstanceCommand createBeanClassInstanceCommand;
private JDBCInitEntityCommand initEntityCommand;
private JDBCFindEntityCommand findEntityCommand;
private JDBCFindEntitiesCommand findEntitiesCommand;
@@ -194,6 +189,8 @@
destroyCommand = commandFactory.createDestroyCommand();
/// Create ejb life cycle commands
+ createBeanClassInstanceCommand =
+ commandFactory.createCreateBeanClassInstanceCommand();
initEntityCommand = commandFactory.createInitEntityCommand();
findEntityCommand = commandFactory.createFindEntityCommand();
findEntitiesCommand = commandFactory.createFindEntitiesCommand();
@@ -243,27 +240,6 @@
if(readAheadCache != null) {
readAheadCache.start();
}
-
- //
- // get the bean proxy constructor
- //
-
- // use proxy generator to create one implementation
- Class beanClass = container.getBeanClass();
- Class[] classes = new Class[] { beanClass };
- EntityBridgeInvocationHandler handler = new EntityBridgeInvocationHandler(
- container,
- entityBridge,
- beanClass);
- ClassLoader classLoader = beanClass.getClassLoader();
- Object o = Proxy.newProxyInstance(classLoader, classes, handler);
-
- // steal the constructor from the object
- beanProxyConstructor =
- o.getClass().getConstructor(new Class[]{InvocationHandler.class});
-
- // now create one to make sure everything is cool
- createBeanClassInstance();
}
public void stop() {
@@ -296,18 +272,10 @@
/**
* Returns a new instance of a class which implemnts the bean class.
*
- * @see java.lang.Class#newInstance
* @return the new instance
*/
public Object createBeanClassInstance() throws Exception {
- Class beanClass = container.getBeanClass();
-
- EntityBridgeInvocationHandler handler = new EntityBridgeInvocationHandler(
- container,
- entityBridge,
- beanClass);
-
- return beanProxyConstructor.newInstance(new Object[]{handler});
+ return createBeanClassInstanceCommand.execute();
}
public void initEntity(EntityEnterpriseContext ctx) {
1.1
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCCreateBeanClassInstanceCommand.java
Index: JDBCCreateBeanClassInstanceCommand.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.ejb.plugins.cmp.jdbc;
import java.lang.reflect.Constructor;
import org.jboss.ejb.EntityContainer;
import org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge;
import org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler;
import org.jboss.proxy.Proxy;
import org.jboss.proxy.InvocationHandler;
/**
* JDBCBeanClassInstanceCommand creates instance of the bean class. For
* CMP 2.0 it creates an instance of a subclass of the bean class, as the
* bean class is abstract.
*
* <FIX-ME>should not generat a subclass for ejb 1.1</FIX-ME>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
* @version $Revision: 1.1 $
*/
public class JDBCCreateBeanClassInstanceCommand {
private EntityContainer container;
private JDBCEntityBridge entityBridge;
private Class beanClass;
private Constructor beanProxyConstructor;
public JDBCCreateBeanClassInstanceCommand(JDBCStoreManager manager)
throws Exception {
container = manager.getContainer();
entityBridge = manager.getEntityBridge();
beanClass = container.getBeanClass();
// use proxy generator to create one implementation
EntityBridgeInvocationHandler handler = new EntityBridgeInvocationHandler(
container,
entityBridge,
beanClass);
Class[] classes = new Class[] { beanClass };
ClassLoader classLoader = beanClass.getClassLoader();
Object o = Proxy.newProxyInstance(classLoader, classes, handler);
// steal the constructor from the object
beanProxyConstructor =
o.getClass().getConstructor(new Class[]{InvocationHandler.class});
// now create one to make sure everything is cool
execute();
}
public Object execute() throws Exception {
EntityBridgeInvocationHandler handler = new EntityBridgeInvocationHandler(
container,
entityBridge,
beanClass);
return beanProxyConstructor.newInstance(new Object[]{handler});
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development