KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > j2ee > AVKLayerUtil


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * AVKLayerUtil.java
21  *
22  * Created on September 19, 2005, 9:53 AM
23  *
24  */

25
26 package org.netbeans.modules.j2ee.sun.ide.j2ee;
27
28 import org.openide.filesystems.*;
29 import org.openide.*;
30 import org.openide.util.Lookup;
31 import org.openide.loaders.*;
32 import org.openide.cookies.InstanceCookie;
33
34 import org.netbeans.modules.j2ee.sun.api.InstrumentAVK;
35
36 /**
37  *
38  * @author Nitya Doraisamy
39  */

40 public class AVKLayerUtil {
41     
42     public static final String JavaDoc DIR_EXTENSION = "/J2EE/SunAppServer/AVKImplementation"; //NOI18N
43
/**
44      * Creates a new instance of AVKLayerUtil
45      */

46     public AVKLayerUtil() {
47     
48     }
49     public static InstrumentAVK getAVKImplemenation() {
50         InstrumentAVK avkSupport = null;
51         Repository rep = (Repository) Lookup.getDefault().lookup(Repository.class);
52         FileObject dir = rep.getDefaultFileSystem().findResource(DIR_EXTENSION);
53         
54         FileObject[] ch =null;
55         
56         if(dir!=null){
57             ch = dir.getChildren();
58         }
59         if(ch != null){
60             for(int i = 0; i < ch.length; i++) {
61                 try{
62                     DataObject dobj = DataObject.find(ch[i]);
63                     InstanceCookie cookie = (InstanceCookie) dobj.getCookie(InstanceCookie.class);
64                     if(cookie != null) {
65                         avkSupport = (InstrumentAVK)cookie.instanceCreate();
66                     }
67                 } catch (Exception JavaDoc e){
68                     //Unable to find AVK
69
}
70             }
71         }
72         return avkSupport;
73     }
74     
75 }
76
Popular Tags