KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > ejb > containers > EJBObjectInvocationHandlerDelegate


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.ejb.containers;
25
26 import java.io.IOException JavaDoc;
27 import java.lang.reflect.InvocationHandler JavaDoc;
28 import java.lang.reflect.Method JavaDoc;
29
30 import com.sun.ejb.containers.EJBLocalObjectImpl.SerializableLocalObject;
31 import com.sun.ejb.spi.io.IndirectlySerializable;
32 import com.sun.ejb.spi.io.SerializableObjectFactory;
33 import com.sun.enterprise.Switch;
34
35 /**
36  * This class is used as a "proxy" or adapter between the remote business
37  * interface proxy and the EJBObjectInvocationHandler. An instance of this
38  * class is created for each remote business interface of a bean. All
39  * java.lang.Object methods are handled by this InvocationHandler itself
40  * while the business interface methods are delegated to the delegate
41  * (which is the EJBObjectInvocaionHandler).
42  *
43  * @author Kenneth Saks
44  *
45  */

46 public class EJBObjectInvocationHandlerDelegate
47     implements InvocationHandler JavaDoc {
48
49     private Class JavaDoc remoteBusinessIntfClass;
50     private EJBObjectInvocationHandler delegate;
51     
52     EJBObjectInvocationHandlerDelegate(Class JavaDoc intfClass,
53                                        EJBObjectInvocationHandler delegate) {
54         this.remoteBusinessIntfClass = intfClass;
55         this.delegate = delegate;
56     }
57     
58     public Object JavaDoc invoke(Object JavaDoc proxy, Method JavaDoc method, Object JavaDoc[] args)
59         throws Throwable JavaDoc {
60         
61         Class JavaDoc methodClass = method.getDeclaringClass();
62         Object JavaDoc result = null;
63         if( methodClass == java.lang.Object JavaDoc.class ) {
64             result = InvocationHandlerUtil.invokeJavaObjectMethod
65                 (this, method, args);
66         } else {
67             result = delegate.invoke(remoteBusinessIntfClass, method, args);
68         }
69         
70         return result;
71     }
72     
73     
74
75 }
76
Popular Tags