KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > util > TracerVisitor


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.enterprise.deployment.util;
25
26 import java.util.Iterator JavaDoc;
27
28 import com.sun.enterprise.deployment.Descriptor;
29 import com.sun.enterprise.deployment.Application;
30 import com.sun.enterprise.deployment.EjbBundleDescriptor;
31 import com.sun.enterprise.deployment.EjbDescriptor;
32 import com.sun.enterprise.deployment.MethodPermission;
33 import com.sun.enterprise.deployment.MethodDescriptor;
34 import com.sun.enterprise.deployment.RoleReference;
35 import com.sun.enterprise.deployment.ContainerTransaction;
36 import com.sun.enterprise.deployment.EnvironmentProperty;
37 import com.sun.enterprise.deployment.ApplicationClientDescriptor;
38 import com.sun.enterprise.deployment.RunAsIdentityDescriptor;
39 import com.sun.enterprise.deployment.FieldDescriptor;
40 import com.sun.enterprise.deployment.WebService;
41 import com.sun.enterprise.deployment.QueryDescriptor;
42 import com.sun.enterprise.deployment.types.EjbReference;
43 import com.sun.enterprise.deployment.types.MessageDestinationReferencer;
44 import com.sun.enterprise.deployment.ServiceReferenceDescriptor;
45 import com.sun.enterprise.deployment.RelationshipDescriptor;
46 import com.sun.enterprise.deployment.MessageListener;
47 import com.sun.enterprise.deployment.AuthMechanism;
48 import com.sun.enterprise.deployment.SecurityPermission;
49 import com.sun.enterprise.deployment.WebBundleDescriptor;
50 import com.sun.enterprise.deployment.WebComponentDescriptor;
51
52 import com.sun.enterprise.deployment.util.DOLUtils;
53 import com.sun.enterprise.deployment.ConnectorDescriptor;
54
55 /**
56  *
57  * @author dochez
58  * @version
59  */

60 public class TracerVisitor extends DefaultDOLVisitor {
61
62     /** Creates new TracerVisitor */
63     public TracerVisitor() {
64     }
65     
66     /**
67      * visit an application object
68      * @param the application descriptor
69      */

70     public void accept(Application application) {
71     DOLUtils.getDefaultLogger().info("Application");
72     DOLUtils.getDefaultLogger().info("name " + application.getName());
73     DOLUtils.getDefaultLogger().info("smallIcon " + application.getSmallIconUri());
74     }
75     
76     /**
77      * visits an ejb bundle descriptor
78      * @param an ejb bundle descriptor
79      */

80     public void accept(EjbBundleDescriptor bundleDescriptor) {
81         DOLUtils.getDefaultLogger().info("Ejb Bundle " + bundleDescriptor.getName());
82     }
83     
84     /**
85      * visits an ejb descriptor
86      * @param ejb descriptor
87      */

88     public void accept(EjbDescriptor ejb) {
89         DOLUtils.getDefaultLogger().info("==================");
90         DOLUtils.getDefaultLogger().info(ejb.getType() + " Bean " + ejb.getName());
91     DOLUtils.getDefaultLogger().info("\thomeClassName " + ejb.getHomeClassName());
92     DOLUtils.getDefaultLogger().info("\tremoteClassName " + ejb.getRemoteClassName());
93     DOLUtils.getDefaultLogger().info("\tlocalhomeClassName " +ejb.getLocalHomeClassName());
94     DOLUtils.getDefaultLogger().info("\tlocalClassName " + ejb.getLocalClassName());
95     DOLUtils.getDefaultLogger().info("\tremoteBusinessIntfs " + ejb.getRemoteBusinessClassNames());
96     DOLUtils.getDefaultLogger().info("\tlocalBusinessIntfs " + ejb.getLocalBusinessClassNames());
97
98     DOLUtils.getDefaultLogger().info("\tjndiName " + ejb.getJndiName());
99     DOLUtils.getDefaultLogger().info("\tejbClassName " + ejb.getEjbClassName());
100     DOLUtils.getDefaultLogger().info("\ttransactionType " + ejb.getTransactionType());
101         if (ejb.getUsesCallerIdentity() == false) {
102             DOLUtils.getDefaultLogger().info("\trun-as role " + ejb.getRunAsIdentity());
103         } else {
104             DOLUtils.getDefaultLogger().info("\tuse-caller-identity " + ejb.getUsesCallerIdentity());
105         }
106     }
107
108     /**
109      * visits an ejb reference for the last J2EE component visited
110      * @param the ejb reference
111      */

112     public void accept(EjbReference ejbRef) {
113         DOLUtils.getDefaultLogger().info(ejbRef.toString());
114     }
115     
116     public void accept(MessageDestinationReferencer referencer) {
117         DOLUtils.getDefaultLogger().info
118             (referencer.getMessageDestinationLinkName());
119     }
120     
121     public void accept(WebService webService) {
122         DOLUtils.getDefaultLogger().info(webService.getName());
123     }
124
125     public void accept(ServiceReferenceDescriptor serviceRef) {
126         DOLUtils.getDefaultLogger().info(serviceRef.getName());
127     }
128
129     /**
130      * visits a method permission and permitted methods for the last J2EE component visited
131      * @param ejb descriptor the role is referenced from
132      * @param method permission
133      * @param the methods associated with the above permission
134      */

135     public void accept(MethodPermission pm, Iterator JavaDoc methods) {
136         DOLUtils.getDefaultLogger().info("For method permission : " + pm.toString());
137         while (methods.hasNext()) {
138             DOLUtils.getDefaultLogger().info("\t" + ((MethodDescriptor) methods.next()).prettyPrint());
139         }
140     }
141     
142     /**
143      * visits a role reference for the last J2EE component visited
144      * @param ejb descriptor the role is referenced from*
145      * @param role reference
146      */

147     public void accept(RoleReference roleRef) {
148         DOLUtils.getDefaultLogger().info("Security Role Reference : "
149                                 + roleRef.getName() + " link " + roleRef.getValue());
150     }
151     /**
152      * visists a method transaction for the last J2EE component visited
153      * @param ejb descritptor this method applies to
154      * @param method descriptor the method
155      * @param container transaction
156      */

157     public void accept(MethodDescriptor method, ContainerTransaction ct) {
158             
159         DOLUtils.getDefaultLogger().info( ct.getTransactionAttribute()
160                                 + " Container Transaction for method "
161                                 + method.prettyPrint() );
162             
163     }
164     
165     /**
166      * visists an environment property for the last J2EE component visited
167      * @paren the environment property
168      */

169     public void accept(EnvironmentProperty envEntry) {
170         DOLUtils.getDefaultLogger().info( envEntry.toString());
171     }
172
173     /**
174      * visits a CMP field definition (for CMP entity beans)
175      * @param field descriptor for the CMP field
176      */

177     public void accept(FieldDescriptor fd) {
178         DOLUtils.getDefaultLogger().info("CMP Field " +fd);
179     }
180     
181     /**
182      * visits a query method
183      * @param method descriptor for the method
184      * @param query descriptor
185      */

186     public void accept(MethodDescriptor method, QueryDescriptor qd) {
187         DOLUtils.getDefaultLogger().info(qd.toString());
188     }
189
190     /**
191      * visits an ejb relationship descriptor
192      * @param the relationship descriptor
193      */

194     public void accept(RelationshipDescriptor descriptor) {
195         DOLUtils.getDefaultLogger().info("============ Relationships ===========");
196         DOLUtils.getDefaultLogger().info("From EJB " + descriptor.getSource().getName()
197                                                                     + " cmr field : " + descriptor.getSource().getCMRField()
198                                                                     + "(" + descriptor.getSource().getCMRFieldType() + ") to EJB " + descriptor.getSink().getName()
199                                                                     + " isMany " + descriptor.getSource().getIsMany()
200                                                                     + " cascade-delete " + descriptor.getSource().getCascadeDelete());
201         
202        DOLUtils.getDefaultLogger().info("To EJB " + descriptor.getSink().getName()
203                                                                     + " isMany " + descriptor.getSink().getIsMany()
204                                                                     + " cascade-delete " + descriptor.getSink().getCascadeDelete());
205
206         if (descriptor.getIsBidirectional()) {
207             DOLUtils.getDefaultLogger().info( "Bidirectional cmr field : " + descriptor.getSink().getCMRField()
208                                                                     + "(" + descriptor.getSink().getCMRFieldType() + ")");
209         }
210     }
211     
212     /**
213      * visits a J2EE descriptor
214      * @param the descriptor
215      */

216     public void accept(Descriptor descriptor) {
217         DOLUtils.getDefaultLogger().info(descriptor.toString());
218     }
219
220      /**
221      * visits an app client descriptor
222      * @param app client descriptor
223      */

224     public void accept(ApplicationClientDescriptor appclientDesc) {
225         DOLUtils.getDefaultLogger().info("==================");
226         DOLUtils.getDefaultLogger().info("\tAppClient Description " + appclientDesc.getDescription());
227     DOLUtils.getDefaultLogger().info("\tAppClient Name " + appclientDesc.getName());
228     DOLUtils.getDefaultLogger().info("\tAppClient Small Icon " + appclientDesc.getSmallIconUri());
229     DOLUtils.getDefaultLogger().info("\tAppClient Large Icon " + appclientDesc.getLargeIconUri());
230     DOLUtils.getDefaultLogger().info("\tAppClient Callback Handler " + appclientDesc.getCallbackHandler());
231     //add rest of the tags
232
}
233
234     /**
235      * visits an connector descriptor
236      * @param connector descriptor
237      */

238     public void accept(ConnectorDescriptor conDesc) {
239         DOLUtils.getDefaultLogger().info("==================");
240         DOLUtils.getDefaultLogger().info(conDesc.toString());
241     }
242      
243     /**
244      * visit a web bundle descriptor
245      *
246      * @param the web bundle descriptor
247      */

248     public void accept(WebBundleDescriptor descriptor) {
249         DOLUtils.getDefaultLogger().info(descriptor.toString());
250     }
251     
252     /**
253      * visit a web component descriptor
254      *
255      * @param the web component
256      */

257     public void accept(WebComponentDescriptor descriptor) {
258         DOLUtils.getDefaultLogger().info("==================");
259         DOLUtils.getDefaultLogger().info(descriptor.toString());
260     }
261 }
262
Popular Tags