User: dsundstrom
Date: 02/02/26 15:24:53
Modified: src/main/org/jboss/ejb/plugins/cmp/bridge
EntityBridgeInvocationHandler.java
Log:
Cleaned up exception handling.
Revision Changes Path
1.14 +52 -37
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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- EntityBridgeInvocationHandler.java 12 Feb 2002 22:35:11 -0000 1.13
+++ EntityBridgeInvocationHandler.java 26 Feb 2002 23:24:53 -0000 1.14
@@ -37,7 +37,7 @@
* One per cmp entity bean instance, including beans in pool.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
- * @version $Revision: 1.13 $
+ * @version $Revision: 1.14 $
*/
public class EntityBridgeInvocationHandler implements InvocationHandler {
private final EntityContainer container;
@@ -57,7 +57,7 @@
public EntityBridgeInvocationHandler(
EntityContainer container,
EntityBridge entityBridge,
- Class beanClass) throws Exception {
+ Class beanClass) throws DeploymentException {
this.container = container;
this.entityBridge = entityBridge;
@@ -74,47 +74,62 @@
this.ctx = ctx;
}
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws FinderException {
String methodName = method.getName();
-
- SelectorBridge selector = (SelectorBridge) selectorMap.get(method);
- if(selector != null) {
- Transaction tx;
- if(ctx != null) {
- // it is probably safer to get the tx from the context if we have
- // one (ejbHome methods don't have a context)
- tx = ctx.getTransaction();
- } else {
- tx = container.getTransactionManager().getTransaction();
+
+ try {
+ SelectorBridge selector = (SelectorBridge) selectorMap.get(method);
+ if(selector != null) {
+ Transaction tx;
+ if(ctx != null) {
+ // it is probably safer to get the tx from the context if we have
+ // one (ejbHome methods don't have a context)
+ tx = ctx.getTransaction();
+ } else {
+ tx = container.getTransactionManager().getTransaction();
+ }
+ EntityContainer.synchronizeEntitiesWithinTransaction(tx);
+ return selector.execute(args);
}
- EntityContainer.synchronizeEntitiesWithinTransaction(tx);
- return selector.execute(args);
+ } catch(RuntimeException e) {
+ throw e;
+ } catch(FinderException e) {
+ throw e;
+ } catch(Exception e) {
+ throw new EJBException("Internal error", e);
}
-
- // get the field object
- FieldBridge field = (FieldBridge) fieldMap.get(method);
-
- if(field == null) {
- throw new EJBException("Method is not a known CMP field accessor, " +
- "CMR field accessor, or ejbSelect method: " +
- "methodName=" + methodName);
- }
-
- // In the case of ejbHome methods there is no context, but ejb home
- // methods are only allowed to call selectors.
- if(ctx == null) {
- throw new EJBException("EJB home methods are not allowed to access " +
- "CMP or CMR fields: methodName=" + methodName);
+
+ try {
+ // get the field object
+ FieldBridge field = (FieldBridge) fieldMap.get(method);
+
+ if(field == null) {
+ throw new EJBException("Method is not a known CMP field " +
+ "accessor, CMR field accessor, or ejbSelect method: " +
+ "methodName=" + methodName);
+ }
+
+ // In the case of ejbHome methods there is no context, but ejb home
+ // methods are only allowed to call selectors.
+ if(ctx == null) {
+ throw new EJBException("EJB home methods are not allowed to " +
+ "access CMP or CMR fields: methodName=" + methodName);
+ }
+
+ if(methodName.startsWith("get")) {
+ return field.getValue(ctx);
+ } else if(methodName.startsWith("set")) {
+ field.setValue(ctx, args[0]);
+ return null;
+ }
+ } catch(RuntimeException e) {
+ throw e;
+ } catch(Exception e) {
+ throw new EJBException("Internal error", e);
}
- if(methodName.startsWith("get")) {
- return field.getValue(ctx);
- } else if(methodName.startsWith("set")) {
- field.setValue(ctx, args[0]);
- return null;
- }
// Should never get here, but it's better to be safe then sorry.
throw new EJBException("Unknown field accessor method: " +
"methodName=" + methodName);
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development