KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mx > metadata > xb > ModelMBeanOperationInfoContainer


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22
23 package org.jboss.mx.metadata.xb;
24
25 import java.util.ArrayList JavaDoc;
26
27 import javax.management.Descriptor JavaDoc;
28 import javax.management.MBeanParameterInfo JavaDoc;
29 import javax.management.MBeanOperationInfo JavaDoc;
30 import javax.management.modelmbean.ModelMBeanOperationInfo JavaDoc;
31 import javax.xml.namespace.QName JavaDoc;
32
33 import org.jboss.xb.binding.GenericValueContainer;
34 import org.jboss.logging.Logger;
35 import org.jboss.mx.modelmbean.ModelMBeanConstants;
36
37 /**
38  * The ModelMBeanOperationInfo JBossXB container
39  * @author Scott.Stark@jboss.org
40  * @version $Revision: 42809 $
41  */

42 public class ModelMBeanOperationInfoContainer
43    implements GenericValueContainer
44 {
45    private static final Logger log = Logger.getLogger(ModelMBeanOperationInfoContainer.class);
46    private String JavaDoc name;
47    private String JavaDoc returnType = "void";
48    private String JavaDoc impact;
49    private String JavaDoc description;
50    private ArrayList JavaDoc params = new ArrayList JavaDoc();
51    private Descriptor JavaDoc descriptor;
52
53    public String JavaDoc getName()
54    {
55       return name;
56    }
57
58    public void setName(String JavaDoc name)
59    {
60       this.name = name;
61    }
62
63    public String JavaDoc getReturnType()
64    {
65       return returnType;
66    }
67
68    public void setReturnType(String JavaDoc returnType)
69    {
70       this.returnType = returnType;
71    }
72
73    public String JavaDoc getImpact()
74    {
75       return impact;
76    }
77
78    public void setImpact(String JavaDoc impact)
79    {
80       this.impact = impact;
81    }
82
83    public String JavaDoc getDescription()
84    {
85       return description;
86    }
87
88    public void setDescription(String JavaDoc description)
89    {
90       this.description = description;
91    }
92
93    public Descriptor JavaDoc getDescriptors()
94    {
95       return descriptor;
96    }
97    public void setDescriptors(Descriptor JavaDoc descriptor)
98    {
99       this.descriptor = descriptor;
100    }
101
102    public void addParameter(MBeanParameterInfo JavaDoc param)
103    {
104       params.add(param);
105    }
106
107    public Object JavaDoc instantiate()
108    {
109       MBeanParameterInfo JavaDoc[] sig = new MBeanParameterInfo JavaDoc[params.size()];
110       params.toArray(sig);
111       if( descriptor != null )
112       {
113          if( descriptor.getFieldValue(ModelMBeanConstants.NAME) == null )
114             descriptor.setField(ModelMBeanConstants.NAME, name);
115          if( descriptor.getFieldValue(ModelMBeanConstants.DESCRIPTOR_TYPE) == null )
116             descriptor.setField(ModelMBeanConstants.DESCRIPTOR_TYPE, ModelMBeanConstants.OPERATION_DESCRIPTOR);
117          if( descriptor.getFieldValue(ModelMBeanConstants.ROLE) == null )
118             descriptor.setField(ModelMBeanConstants.ROLE, ModelMBeanConstants.ROLE_OPERATION);
119       }
120       int operImpact = MBeanOperationInfo.ACTION_INFO;
121
122       if (impact != null)
123       {
124          if (impact.equals(ModelMBeanConstants.INFO))
125             operImpact = MBeanOperationInfo.INFO;
126          else if (impact.equals(ModelMBeanConstants.ACTION))
127             operImpact = MBeanOperationInfo.ACTION;
128          else if (impact.equals(ModelMBeanConstants.ACTION_INFO))
129             operImpact = MBeanOperationInfo.ACTION_INFO;
130       }
131
132       ModelMBeanOperationInfo JavaDoc info = new ModelMBeanOperationInfo JavaDoc(name,
133          description, sig, returnType, operImpact, descriptor);
134       return info;
135    }
136    public void addChild(QName JavaDoc name, Object JavaDoc value)
137    {
138       ModelMBeanOperationInfoContainer.log.debug("addChild, " + name + "," + value);
139       if("name".equals(name.getLocalPart()))
140       {
141          this.name = (String JavaDoc) value;
142       }
143       if("description".equals(name.getLocalPart()))
144       {
145          this.description = (String JavaDoc) value;
146       }
147    }
148    public Class JavaDoc getTargetClass()
149    {
150       return ModelMBeanOperationInfo JavaDoc.class;
151    }
152
153 }
154
Popular Tags