KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > model > ResourceAdapterMdl


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.management.model;
25
26 import javax.management.ObjectName JavaDoc;
27 import java.util.Set JavaDoc;
28
29 public class ResourceAdapterMdl extends J2EEManagedObjectMdl {
30     private static String JavaDoc MANAGED_OBJECT_TYPE = "ResourceAdapter";
31     
32     private String JavaDoc raModuleName = null;
33     private String JavaDoc applicationName = null;
34     private String JavaDoc resourceAdapterName = null;
35     
36     public ResourceAdapterMdl(String JavaDoc name, String JavaDoc rarName, String JavaDoc appName) {
37         super(name, false, false, false);
38         raModuleName = rarName;
39         if(appName != null){
40             this.applicationName = appName;
41             if(J2EEModuleMdl.isStandAloneModule(applicationName))
42                 this.applicationName = "null";
43         }
44         else {
45             //standalone
46
this.applicationName = "null";
47         }
48         resourceAdapterName = name;
49     }
50
51     public ResourceAdapterMdl(String JavaDoc name, String JavaDoc rarName, String JavaDoc appName, String JavaDoc serverName) {
52         super(name, serverName, false, false, false);
53         raModuleName = rarName;
54         if(appName != null){
55             this.applicationName = appName;
56             if(J2EEModuleMdl.isStandAloneModule(applicationName))
57                 this.applicationName = "null";
58         }
59         else {
60             //standalone
61
this.applicationName = "null";
62         }
63         resourceAdapterName = name;
64     }
65     
66     /**
67      * The type of the J2EEManagedObject as specified by JSR77. The class that implements a specific type must override this method and return the appropriate type string.
68      */

69     public String JavaDoc getj2eeType() {
70         return MANAGED_OBJECT_TYPE;
71     }
72     
73     /**
74      * The name of the J2EEManagedObject. All managed objects must have a unique name within the context of the management
75      * domain. The name must not be null.
76      */

77     public String JavaDoc getobjectName() {
78         Set JavaDoc s = findNames("j2eeType="+getj2eeType()+",name="+this.resourceAdapterName+",ResourceAdapterModule="+this.getResourceAdapterModule()+",J2EEApplication="+this.getJ2EEApplication()+",J2EEServer="+this.getJ2EEServer());
79         Object JavaDoc [] objs = s.toArray();
80         if (objs.length > 0) {
81             String JavaDoc name = ((ObjectName JavaDoc)objs[0]).toString();
82             return name;
83         } else {
84             return null;
85         }
86     }
87
88     /**
89      * returns the OBJECT_NAME of the JCAResource implemented by this resource adapter
90      */

91     public String JavaDoc getjcaResource() {
92         Set JavaDoc s = findNames("j2eeType=JCAResource,ResourceAdapter="+this.resourceAdapterName+",J2EEServer="+this.getJ2EEServer());
93         Object JavaDoc [] objs = s.toArray();
94         if (objs.length > 0) {
95             String JavaDoc name = ((ObjectName JavaDoc)objs[0]).toString();
96             return name;
97         } else {
98             return null;
99         }
100     }
101
102     /**
103      * Accessor method for the parent key
104      */

105     public String JavaDoc getResourceAdapterModule(){
106         return raModuleName;
107     }
108     
109     /**
110      * Accessor method for the parent key
111      */

112     public String JavaDoc getJ2EEApplication(){
113        return this.applicationName;
114     }
115 }
116
Popular Tags