KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > ComponentInvocation


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 package com.sun.enterprise;
24
25 import javax.transaction.Transaction JavaDoc;
26 import javax.transaction.SystemException JavaDoc;
27 import org.apache.catalina.Context;
28 import com.sun.ejb.Container;
29 import com.sun.enterprise.security.SecurityContext;
30 // IASRI 4660742 START
31
import java.util.logging.*;
32 import com.sun.logging.*;
33 // IASRI 4660742 END
34

35 import java.lang.reflect.Method JavaDoc;
36 import com.sun.xml.rpc.spi.runtime.Tie;
37
38 import com.sun.ejb.ComponentContext;
39
40 /**
41  * represents a general component invocation
42  *
43  * @author Tony Ng
44  */

45 public class ComponentInvocation {
46 // IASRI 4660742 START
47
private static Logger _logger=null;
48     static{
49        _logger=LogDomains.getLogger(LogDomains.ROOT_LOGGER);
50         }
51 // IASRI 4660742 END
52

53     static final public int SERVLET_INVOCATION = 0;
54     static final public int EJB_INVOCATION = 1;
55     static final public int APP_CLIENT_INVOCATION = 2;
56     static final public int UN_INITIALIZED = 3;
57     static final public int SERVICE_STARTUP = 4;
58
59     private int invocationType = UN_INITIALIZED;
60
61
62     // the component instance, type Servlet, Filter or EnterpriseBean
63
public Object JavaDoc instance;
64
65     // ServletContext for servlet, Container for EJB
66
public Object JavaDoc container;
67
68     public Transaction JavaDoc transaction;
69
70     // EJB Context for txn mgr. TODO: rename context as ejbContext
71
public ComponentContext context = null;
72
73     // security context coming in on a call
74
// security context changes on a runas call - on a run as call
75
// the old logged in security context is stored in here.
76
public SecurityContext oldSecurityContext;
77
78     public Boolean JavaDoc auth = null;
79     public boolean preInvokeDone = false;
80
81     // true if transaction commit or rollback is
82
// happening for this invocation context
83
private boolean transactionCompleting = false;
84
85     /**
86      * Used by container within handler processing code.
87      */

88     private Tie webServiceTie;
89     private Method JavaDoc webServiceMethod;
90     
91     public ComponentInvocation()
92     {}
93
94     public ComponentInvocation(int invocationType)
95     {
96         this.invocationType = invocationType;
97     }
98
99     public ComponentInvocation(Object JavaDoc instance, Object JavaDoc container)
100     {
101     this.instance = instance;
102     this.container = container;
103     }
104     
105     public ComponentInvocation(Object JavaDoc instance, Object JavaDoc container, ComponentContext context)
106     {
107         this.instance = instance;
108         this.container = container;
109         this.context = context;
110     }
111     
112
113     public int getInvocationType() {
114         if (invocationType == UN_INITIALIZED) {
115             if (container instanceof Context) {
116                 invocationType = SERVLET_INVOCATION;
117                 return SERVLET_INVOCATION;
118             } else if (container instanceof Container) {
119                 invocationType = EJB_INVOCATION;
120                 return EJB_INVOCATION;
121             } else {
122                 invocationType = APP_CLIENT_INVOCATION;
123                 return APP_CLIENT_INVOCATION;
124             }
125         }
126         else
127             return invocationType;
128     }
129
130
131     public Object JavaDoc getInstance() {
132         return instance;
133     }
134
135     /**
136      * Return the Container/ServletContext
137      */

138     public Object JavaDoc getContainerContext() {
139         return container;
140     }
141
142     public Transaction JavaDoc getTransaction() {
143         return transaction;
144     }
145
146     public void setTransaction(Transaction JavaDoc tran) {
147         this.transaction = tran;
148     }
149     /**
150      * Sets the security context of the call coming in
151      */

152     public void setOldSecurityContext (SecurityContext sc){
153     this.oldSecurityContext = sc;
154     }
155     /**
156      * gets the security context of the call that came in
157      * before a new context for runas is made
158      */

159     public SecurityContext getOldSecurityContext (){
160     return oldSecurityContext;
161     }
162
163     public boolean isTransactionCompleting() {
164         return transactionCompleting;
165     }
166
167     public void setTransactionCompeting(boolean value) {
168         transactionCompleting = value;
169     }
170
171     
172     public void setWebServiceTie(Tie tie) {
173         webServiceTie = tie;
174     }
175
176     public Tie getWebServiceTie() {
177         return webServiceTie;
178     }
179
180     public void setWebServiceMethod(Method JavaDoc method) {
181         webServiceMethod = method;
182     }
183
184     public Method JavaDoc getWebServiceMethod() {
185         return webServiceMethod;
186     }
187     
188     public String JavaDoc toString() {
189         String JavaDoc str = instance + "," + container;
190         if (transaction != null) {
191             try {
192                 str += "," + transaction.getStatus();
193             } catch (SystemException JavaDoc ex) {
194 // IASRI 4660742 ex.printStackTrace();
195
// START OF IASRI 4660742
196
_logger.log(Level.SEVERE,"enterprise.system_exception",ex);
197 // END OF IASRI 4660742
198
}
199         } else {
200             str += ",no transaction";
201         }
202         return str;
203     }
204 }
205
Popular Tags