User: olegnitz
Date: 01/09/01 15:03:15
Modified: src/main/org/jboss/ejb/plugins/cmp/bridge
CMPFieldBridge.java CMRFieldBridge.java
EntityBridge.java
EntityBridgeInvocationHandler.java
SelectorBridge.java
Log:
converted tabs to spaces
Revision Changes Path
1.4 +23 -23
jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/CMPFieldBridge.java
Index: CMPFieldBridge.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/CMPFieldBridge.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CMPFieldBridge.java 2001/08/03 17:15:45 1.3
+++ CMPFieldBridge.java 2001/09/01 22:03:14 1.4
@@ -13,38 +13,38 @@
* CMPFieldBridge represents one cmp field for one entity.
*
* Life-cycle:
- * Tied to the EntityBridge.
+ * Tied to the EntityBridge.
*
- * Multiplicity:
- * One for each entity bean cmp field.
+ * Multiplicity:
+ * One for each entity bean cmp field.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public interface CMPFieldBridge {
- public String getFieldName();
- public Class getFieldType();
- public boolean isPrimaryKeyMember();
- public boolean isReadOnly();
-
- public Object getInstanceValue(EntityEnterpriseContext ctx);
+ public String getFieldName();
+ public Class getFieldType();
+ public boolean isPrimaryKeyMember();
+ public boolean isReadOnly();
+
+ public Object getInstanceValue(EntityEnterpriseContext ctx);
public void setInstanceValue(EntityEnterpriseContext ctx, Object value);
- public Object getPrimaryKeyValue(Object primaryKey) throws
IllegalArgumentException;
+ public Object getPrimaryKeyValue(Object primaryKey) throws
IllegalArgumentException;
public Object setPrimaryKeyValue(Object primaryKey, Object value) throws
IllegalArgumentException;
- /**
- * Set CMPFieldValue to Java default value (i.e., 0 or null).
- */
- public void initInstance(EntityEnterpriseContext ctx);
+ /**
+ * Set CMPFieldValue to Java default value (i.e., 0 or null).
+ */
+ public void initInstance(EntityEnterpriseContext ctx);
- /**
- * Has the value of this field changes since the last time clean was called.
- */
- public boolean isDirty(EntityEnterpriseContext ctx);
+ /**
+ * Has the value of this field changes since the last time clean was called.
+ */
+ public boolean isDirty(EntityEnterpriseContext ctx);
- /**
- * Mark this field as clean.
- */
- public void setClean(EntityEnterpriseContext ctx);
+ /**
+ * Mark this field as clean.
+ */
+ public void setClean(EntityEnterpriseContext ctx);
}
1.4 +9 -9
jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/CMRFieldBridge.java
Index: CMRFieldBridge.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/CMRFieldBridge.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CMRFieldBridge.java 2001/08/03 17:15:45 1.3
+++ CMRFieldBridge.java 2001/09/01 22:03:14 1.4
@@ -13,19 +13,19 @@
* CMRFieldBridge a bean relationship.
*
* Life-cycle:
- * Haven't decided yet.
+ * Haven't decided yet.
*
- * Multiplicity:
- * Haven't decided yet. Will be either one per bean relationship role, or
- * one per relationship (shared between two beans).
+ * Multiplicity:
+ * Haven't decided yet. Will be either one per bean relationship role, or
+ * one per relationship (shared between two beans).
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public interface CMRFieldBridge {
- public String getFieldName();
-// public Class getFieldType();
-
- public Object getValue(EntityEnterpriseContext ctx);
+ public String getFieldName();
+// public Class getFieldType();
+
+ public Object getValue(EntityEnterpriseContext ctx);
public void setValue(EntityEnterpriseContext ctx, Object value);
}
1.3 +22 -22
jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/EntityBridge.java
Index: EntityBridge.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/EntityBridge.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EntityBridge.java 2001/08/03 17:15:45 1.2
+++ EntityBridge.java 2001/09/01 22:03:14 1.3
@@ -17,32 +17,32 @@
* should create a store specifiec implementaion of the bridge.
*
* Life-cycle:
- * Undefined. Should be tied to CMPStoreManager.
+ * Undefined. Should be tied to CMPStoreManager.
*
- * Multiplicity:
- * One per cmp entity bean type.
+ * Multiplicity:
+ * One per cmp entity bean type.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public interface EntityBridge {
- public String getEntityName();
-
- public Class getPrimaryKeyClass();
- public CMPFieldBridge[] getPrimaryKeyFields();
-
- public CMPFieldBridge[] getCMPFields();
- public CMRFieldBridge[] getCMRFields();
- public SelectorBridge[] getSelectors();
-
- /**
- * Mark each field every as clean.
- */
- public void setClean(EntityEnterpriseContext ctx);
-
- /**
- * Get every field that isDirty
- */
- public CMPFieldBridge[] getDirtyFields(EntityEnterpriseContext ctx);
+ public String getEntityName();
+
+ public Class getPrimaryKeyClass();
+ public CMPFieldBridge[] getPrimaryKeyFields();
+
+ public CMPFieldBridge[] getCMPFields();
+ public CMRFieldBridge[] getCMRFields();
+ public SelectorBridge[] getSelectors();
+
+ /**
+ * Mark each field every as clean.
+ */
+ public void setClean(EntityEnterpriseContext ctx);
+
+ /**
+ * Get every field that isDirty
+ */
+ public CMPFieldBridge[] getDirtyFields(EntityEnterpriseContext ctx);
}
1.5 +163 -163
jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
Index: EntityBridgeInvocationHandler.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- EntityBridgeInvocationHandler.java 2001/08/26 19:37:10 1.4
+++ EntityBridgeInvocationHandler.java 2001/09/01 22:03:14 1.5
@@ -27,176 +27,176 @@
* appropriate EntityBridge method.
*
* Life-cycle:
- * Tied to the life-cycle of an entity bean instance.
+ * Tied to the life-cycle of an entity bean instance.
*
- * Multiplicity:
- * One per cmp entity bean instance, including beans in pool.
+ * Multiplicity:
+ * One per cmp entity bean instance, including beans in pool.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class EntityBridgeInvocationHandler implements InvocationHandler {
- protected EntityContainer container;
- protected EntityBridge entityBridge;
- protected Class beanClass;
- protected EntityEnterpriseContext ctx;
- protected Map cmpFieldMap;
- protected Map cmrFieldMap;
- protected Map selectorMap;
-
- public EntityBridgeInvocationHandler(EntityContainer container, EntityBridge
entityBridge, Class beanClass) throws Exception {
- this.container = container;
- this.entityBridge = entityBridge;
- this.beanClass = beanClass;
- Map abstractAccessors = getAbstractAccessors();
- setupCMPFieldMap(abstractAccessors);
- setupCMRFieldMap(abstractAccessors);
-
- setupSelectorMap();
- }
-
- public void setContext(EntityEnterpriseContext ctx) {
- if(ctx != null && !beanClass.isInstance(ctx.getInstance())) {
- throw new EJBException("Instance must be an instance of
beanClass");
- }
- this.ctx = ctx;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws
Throwable {
- String methodName = method.getName();
-
- // is this a cmp field accessor
- CMPFieldBridge cmpField = (CMPFieldBridge) cmpFieldMap.get(method);
- if(cmpField != null) {
- if(methodName.startsWith("get")) {
- return cmpField.getInstanceValue(ctx);
- } else if(methodName.startsWith("set")) {
- if(cmpField.isReadOnly()) {
- throw new EJBException("Field is read-only: "
+ cmpField.getFieldName());
- }
- cmpField.setInstanceValue(ctx, args[0]);
- return null;
- }
- Exception e = new EJBException("Unknown cmp field method: " +
methodName);
- e.printStackTrace();
- throw e;
- }
+ protected EntityContainer container;
+ protected EntityBridge entityBridge;
+ protected Class beanClass;
+ protected EntityEnterpriseContext ctx;
+ protected Map cmpFieldMap;
+ protected Map cmrFieldMap;
+ protected Map selectorMap;
+
+ public EntityBridgeInvocationHandler(EntityContainer container, EntityBridge
entityBridge, Class beanClass) throws Exception {
+ this.container = container;
+ this.entityBridge = entityBridge;
+ this.beanClass = beanClass;
+ Map abstractAccessors = getAbstractAccessors();
+ setupCMPFieldMap(abstractAccessors);
+ setupCMRFieldMap(abstractAccessors);
+
+ setupSelectorMap();
+ }
+
+ public void setContext(EntityEnterpriseContext ctx) {
+ if(ctx != null && !beanClass.isInstance(ctx.getInstance())) {
+ throw new EJBException("Instance must be an instance of beanClass");
+ }
+ this.ctx = ctx;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws
Throwable {
+ String methodName = method.getName();
+
+ // is this a cmp field accessor
+ CMPFieldBridge cmpField = (CMPFieldBridge) cmpFieldMap.get(method);
+ if(cmpField != null) {
+ if(methodName.startsWith("get")) {
+ return cmpField.getInstanceValue(ctx);
+ } else if(methodName.startsWith("set")) {
+ if(cmpField.isReadOnly()) {
+ throw new EJBException("Field is read-only: " +
cmpField.getFieldName());
+ }
+ cmpField.setInstanceValue(ctx, args[0]);
+ return null;
+ }
+ Exception e = new EJBException("Unknown cmp field method: " + methodName);
+ e.printStackTrace();
+ throw e;
+ }
- CMRFieldBridge cmrField = (CMRFieldBridge) cmrFieldMap.get(method);
- if(cmrField != null) {
- if(methodName.startsWith("get")) {
- return cmrField.getValue(ctx);
- } else if(methodName.startsWith("set")) {
- cmrField.setValue(ctx, args[0]);
- return null;
- }
- throw new EJBException("Unknown cmr field method: " +
methodName);
- }
-
- SelectorBridge selector = (SelectorBridge) selectorMap.get(method);
- if(selector != null) {
-
container.synchronizeEntitiesWithinTransaction(ctx.getTransaction());
- return selector.execute(args);
- }
-
- Exception e = new EJBException("Unknown method type: " + methodName);
- e.printStackTrace();
- throw e;
- }
-
- protected Map getAbstractAccessors() {
- Method[] methods = beanClass.getMethods();
- Map abstractAccessors = new HashMap(methods.length);
-
- for(int i=0; i<methods.length; i++) {
- if(Modifier.isAbstract(methods[i].getModifiers())) {
- String methodName = methods[i].getName();
- if(methodName.startsWith("get") ||
methodName.startsWith("set")) {
- abstractAccessors.put(methodName, methods[i]);
- }
- }
- }
- return abstractAccessors;
- }
-
- protected void setupCMPFieldMap(Map abstractAccessors) throws
DeploymentException {
- CMPFieldBridge[] cmpFields = entityBridge.getCMPFields();
- cmpFieldMap = new HashMap(cmpFields.length * 2);
-
- for(int i=0; i<cmpFields.length; i++) {
- setupCMPFieldGetter(abstractAccessors, cmpFields[i]);
- setupCMPFieldSetter(abstractAccessors, cmpFields[i]);
- }
- }
+ CMRFieldBridge cmrField = (CMRFieldBridge) cmrFieldMap.get(method);
+ if(cmrField != null) {
+ if(methodName.startsWith("get")) {
+ return cmrField.getValue(ctx);
+ } else if(methodName.startsWith("set")) {
+ cmrField.setValue(ctx, args[0]);
+ return null;
+ }
+ throw new EJBException("Unknown cmr field method: " + methodName);
+ }
+
+ SelectorBridge selector = (SelectorBridge) selectorMap.get(method);
+ if(selector != null) {
+ container.synchronizeEntitiesWithinTransaction(ctx.getTransaction());
+ return selector.execute(args);
+ }
+
+ Exception e = new EJBException("Unknown method type: " + methodName);
+ e.printStackTrace();
+ throw e;
+ }
+
+ protected Map getAbstractAccessors() {
+ Method[] methods = beanClass.getMethods();
+ Map abstractAccessors = new HashMap(methods.length);
+
+ for(int i=0; i<methods.length; i++) {
+ if(Modifier.isAbstract(methods[i].getModifiers())) {
+ String methodName = methods[i].getName();
+ if(methodName.startsWith("get") || methodName.startsWith("set")) {
+ abstractAccessors.put(methodName, methods[i]);
+ }
+ }
+ }
+ return abstractAccessors;
+ }
+
+ protected void setupCMPFieldMap(Map abstractAccessors) throws
DeploymentException {
+ CMPFieldBridge[] cmpFields = entityBridge.getCMPFields();
+ cmpFieldMap = new HashMap(cmpFields.length * 2);
+
+ for(int i=0; i<cmpFields.length; i++) {
+ setupCMPFieldGetter(abstractAccessors, cmpFields[i]);
+ setupCMPFieldSetter(abstractAccessors, cmpFields[i]);
+ }
+ }
- protected void setupCMPFieldGetter(Map abstractAccessors, CMPFieldBridge
cmpField) throws DeploymentException {
- String fieldName = cmpField.getFieldName();
- String getterName = "get" + Character.toUpperCase(fieldName.charAt(0))
+ fieldName.substring(1);
-
- Method getterMethod = (Method)abstractAccessors.get(getterName);
- if(getterMethod != null) {
- cmpFieldMap.put(getterMethod, cmpField);
- abstractAccessors.remove(getterName);
- } else {
- throw new DeploymentException("No getter found for cmp field:
" + fieldName);
- }
- }
-
- protected void setupCMPFieldSetter(Map abstractAccessors, CMPFieldBridge
cmpField) throws DeploymentException {
- String fieldName = cmpField.getFieldName();
- String setterName = "set" + Character.toUpperCase(fieldName.charAt(0))
+ fieldName.substring(1);
-
- Method setterMethod = (Method)abstractAccessors.get(setterName);
- if(setterMethod != null) {
- cmpFieldMap.put(setterMethod, cmpField);
- abstractAccessors.remove(setterName);
- } else {
- throw new DeploymentException("No setter found for cmp field:
" + fieldName);
- }
- }
-
- protected void setupCMRFieldMap(Map abstractAccessors) throws
DeploymentException {
- CMRFieldBridge[] cmrFields = entityBridge.getCMRFields();
- cmrFieldMap = new HashMap(cmrFields.length * 2);
-
- for(int i=0; i<cmrFields.length; i++) {
- // in unidirectional relationships only one side has
- // a field name
- if(cmrFields[i].getFieldName() != null) {
- setupCMRFieldGetter(abstractAccessors, cmrFields[i]);
- setupCMRFieldSetter(abstractAccessors, cmrFields[i]);
- }
- }
- }
+ protected void setupCMPFieldGetter(Map abstractAccessors, CMPFieldBridge
cmpField) throws DeploymentException {
+ String fieldName = cmpField.getFieldName();
+ String getterName = "get" + Character.toUpperCase(fieldName.charAt(0)) +
fieldName.substring(1);
+
+ Method getterMethod = (Method)abstractAccessors.get(getterName);
+ if(getterMethod != null) {
+ cmpFieldMap.put(getterMethod, cmpField);
+ abstractAccessors.remove(getterName);
+ } else {
+ throw new DeploymentException("No getter found for cmp field: " +
fieldName);
+ }
+ }
+
+ protected void setupCMPFieldSetter(Map abstractAccessors, CMPFieldBridge
cmpField) throws DeploymentException {
+ String fieldName = cmpField.getFieldName();
+ String setterName = "set" + Character.toUpperCase(fieldName.charAt(0)) +
fieldName.substring(1);
+
+ Method setterMethod = (Method)abstractAccessors.get(setterName);
+ if(setterMethod != null) {
+ cmpFieldMap.put(setterMethod, cmpField);
+ abstractAccessors.remove(setterName);
+ } else {
+ throw new DeploymentException("No setter found for cmp field: " +
fieldName);
+ }
+ }
+
+ protected void setupCMRFieldMap(Map abstractAccessors) throws
DeploymentException {
+ CMRFieldBridge[] cmrFields = entityBridge.getCMRFields();
+ cmrFieldMap = new HashMap(cmrFields.length * 2);
+
+ for(int i=0; i<cmrFields.length; i++) {
+ // in unidirectional relationships only one side has
+ // a field name
+ if(cmrFields[i].getFieldName() != null) {
+ setupCMRFieldGetter(abstractAccessors, cmrFields[i]);
+ setupCMRFieldSetter(abstractAccessors, cmrFields[i]);
+ }
+ }
+ }
- protected void setupCMRFieldGetter(Map abstractAccessors, CMRFieldBridge
cmrField) throws DeploymentException {
- String fieldName = cmrField.getFieldName();
- String getterName = "get" + Character.toUpperCase(fieldName.charAt(0))
+ fieldName.substring(1);
-
- Method getterMethod = (Method)abstractAccessors.get(getterName);
- if(getterMethod != null) {
- cmrFieldMap.put(getterMethod, cmrField);
- abstractAccessors.remove(getterName);
- }
- }
-
- protected void setupCMRFieldSetter(Map abstractAccessors, CMRFieldBridge
cmrField) throws DeploymentException {
- String fieldName = cmrField.getFieldName();
- String setterName = "set" + Character.toUpperCase(fieldName.charAt(0))
+ fieldName.substring(1);
-
- Method setterMethod = (Method)abstractAccessors.get(setterName);
- if(setterMethod != null) {
- cmrFieldMap.put(setterMethod, cmrField);
- abstractAccessors.remove(setterName);
- }
- }
-
- protected void setupSelectorMap() {
- SelectorBridge[] selectors = entityBridge.getSelectors();
- selectorMap = new HashMap(selectors.length);
+ protected void setupCMRFieldGetter(Map abstractAccessors, CMRFieldBridge
cmrField) throws DeploymentException {
+ String fieldName = cmrField.getFieldName();
+ String getterName = "get" + Character.toUpperCase(fieldName.charAt(0)) +
fieldName.substring(1);
+
+ Method getterMethod = (Method)abstractAccessors.get(getterName);
+ if(getterMethod != null) {
+ cmrFieldMap.put(getterMethod, cmrField);
+ abstractAccessors.remove(getterName);
+ }
+ }
+
+ protected void setupCMRFieldSetter(Map abstractAccessors, CMRFieldBridge
cmrField) throws DeploymentException {
+ String fieldName = cmrField.getFieldName();
+ String setterName = "set" + Character.toUpperCase(fieldName.charAt(0)) +
fieldName.substring(1);
+
+ Method setterMethod = (Method)abstractAccessors.get(setterName);
+ if(setterMethod != null) {
+ cmrFieldMap.put(setterMethod, cmrField);
+ abstractAccessors.remove(setterName);
+ }
+ }
+
+ protected void setupSelectorMap() {
+ SelectorBridge[] selectors = entityBridge.getSelectors();
+ selectorMap = new HashMap(selectors.length);
- for(int i=0; i<selectors.length; i++) {
- selectorMap.put(selectors[i].getMethod(), selectors[i]);
- }
- }
+ for(int i=0; i<selectors.length; i++) {
+ selectorMap.put(selectors[i].getMethod(), selectors[i]);
+ }
+ }
}
1.4 +9 -9
jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/SelectorBridge.java
Index: SelectorBridge.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/bridge/SelectorBridge.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SelectorBridge.java 2001/08/26 19:37:10 1.3
+++ SelectorBridge.java 2001/09/01 22:03:14 1.4
@@ -14,18 +14,18 @@
* SelectorBridge represents one ejbSelect method.
*
* Life-cycle:
- * Tied to the EntityBridge.
+ * Tied to the EntityBridge.
*
- * Multiplicity:
- * One for each entity bean ejbSelect method.
+ * Multiplicity:
+ * One for each entity bean ejbSelect method.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public interface SelectorBridge {
- public String getSelectorName();
- public Method getMethod();
- public Class getReturnType();
-
- public Object execute(Object[] args) throws FinderException;
+ public String getSelectorName();
+ public Method getMethod();
+ public Class getReturnType();
+
+ public Object execute(Object[] args) throws FinderException;
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development