KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > server > core > mbean > config > Resource


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.admin.server.core.mbean.config;
25
26 import java.util.Vector JavaDoc;
27 import java.util.Properties JavaDoc;
28
29 import com.sun.enterprise.config.serverbeans.ElementProperty;
30
31 /**
32  * Class which represents the Resource.
33  */

34 public class Resource
35 {
36     public final static int BEGIN_INDEX = 0;
37     public final static int JMS_RESOURCE = BEGIN_INDEX + 1;
38     public final static int MAIL_RESOURCE = BEGIN_INDEX + 2;
39     public final static int PERSISTENCE_RESOURCE = BEGIN_INDEX + 3;
40     public final static int JDBC_RESOURCE = BEGIN_INDEX + 4;
41     public final static int JDBC_CONN_POOL = BEGIN_INDEX + 5;
42     public final static int CUSTOM_RESOURCE = BEGIN_INDEX + 6;
43     public final static int EXT_JNDI_RESOURCE = BEGIN_INDEX + 7;
44
45     private int resType = 0;
46     private Properties JavaDoc attributes = new Properties JavaDoc();
47     private Vector JavaDoc vProperty = new Vector JavaDoc();
48     private String JavaDoc sDescription = null;
49
50     public Resource()
51     {
52     }
53     
54     public Resource(int type)
55     {
56        resType = type;
57     }
58     
59     public int getType()
60     {
61         return resType;
62     }
63     
64     public void setType(int type)
65     {
66         resType = type;
67     }
68     
69     public Properties JavaDoc getAttributes()
70     {
71         return attributes;
72     }
73     
74     public void setAttribute(String JavaDoc name, String JavaDoc value)
75     {
76         attributes.setProperty(name, value);
77     }
78
79     public void setDescription(String JavaDoc sDescription)
80     {
81         this.sDescription = sDescription;
82     }
83     
84     public String JavaDoc getDescription()
85     {
86        return sDescription;
87     }
88     
89     public void setElementProperty(String JavaDoc name, String JavaDoc value)
90     {
91         ElementProperty ep = new ElementProperty();
92         ep.setName(name);
93         ep.setValue(value);
94         vProperty.add(ep);
95     }
96
97     public void setElementProperty(String JavaDoc name, String JavaDoc value, String JavaDoc sDesc)
98     {
99         ElementProperty ep = new ElementProperty();
100         ep.setName(name);
101         ep.setValue(value);
102         ep.setDescription(sDesc);
103         vProperty.add(ep);
104     }
105
106     public ElementProperty[] getElementProperty()
107     {
108         Object JavaDoc[] arrayObj = vProperty.toArray();
109         //convert vector to array
110
ElementProperty [] epArray = new ElementProperty[arrayObj.length];
111         for (int ii=0; ii<arrayObj.length; ii++) {
112            epArray[ii] = (ElementProperty)arrayObj[ii];
113         }
114         return epArray;
115     }
116 }
117
Popular Tags