Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/mobicents/slee/container/management/jmx/ComponentIDPropertyEditor.java


1   /*
2    * Created on Oct 27, 2004
3    *
4    *
5    *  Author: M. Ranganathan
6    * 
7    * The software was developed by employees of the National Institute of
8    * Standards and Technology (NIST), an agency of the Federal Government.
9    * Pursuant to title 15 Untied States Code Section 105, works of NIST
10   * employees are not subject to copyright protection in the United States
11   * and are considered to be in the public domain.  As a result, a formal
12   * license is not needed to use the software.
13   *
14   * The software is provided by NIST as a service and is expressly
15   * provided "AS IS."  NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
16   * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
17   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
18   * AND DATA ACCURACY.  NIST does not warrant or make any representations
19   * regarding the use of the software or the results thereof, including but
20   * not limited to the correctness, accuracy, reliability or usefulness of
21   * the software.
22   * 
23   */
24  package org.mobicents.slee.container.management.jmx;
25  
26  import java.util.NoSuchElementException;
27  import java.util.StringTokenizer;
28  import org.mobicents.slee.container.management.ComponentIDImpl;
29  import org.mobicents.slee.container.management.ComponentKey;
30  import org.mobicents.slee.container.management.EventTypeIDImpl;
31  import org.mobicents.slee.container.management.ProfileSpecificationIDImpl;
32  import org.mobicents.slee.container.management.ResourceAdaptorIDImpl;
33  import org.mobicents.slee.container.management.SbbIDImpl;
34  import org.mobicents.slee.container.management.ServiceIDImpl;
35  import org.mobicents.slee.resource.ResourceAdaptorTypeIDImpl;
36  
37  import javax.slee.ComponentID;
38  
39  import org.jboss.util.propertyeditor.TextPropertyEditorSupport;
40  
41  /**
42   * Property Editor for ComponentID. 
43   * 
44   * @author M. Ranganathan
45   * 
46   */
47  public class ComponentIDPropertyEditor extends TextPropertyEditorSupport {
48  
49      public void setAsText(String key) throws IllegalArgumentException {
50          try {
51              StringTokenizer stringTokenizer = new StringTokenizer(key, "[",
52                      true);
53              ComponentIDImpl value;
54              ComponentKey ckey;
55              String componentType = stringTokenizer.nextToken();
56  
57              stringTokenizer.nextToken();
58              String ckeyStr = stringTokenizer.nextToken("]");
59              if (ckeyStr.equals(""))
60                  throw new IllegalArgumentException("bad component ID ");
61              ckey = new ComponentKey(ckeyStr);
62              if (componentType.equalsIgnoreCase(ComponentIDImpl.SBB_ID)) {
63                  value = new SbbIDImpl(ckey);
64              } else if (componentType
65                      .equalsIgnoreCase(ComponentIDImpl.RESOURCE_ADAPTOR_TYPE_ID)) {
66                  value = new ResourceAdaptorTypeIDImpl(ckey);
67              } else if (componentType
68                      .equalsIgnoreCase(ComponentIDImpl.RESOURCE_ADAPTOR_ID)) {
69                  value = new ResourceAdaptorIDImpl(ckey);
70              } else if (componentType
71                      .equalsIgnoreCase(ComponentIDImpl.PROFILE_SPECIFICATION_ID)) {
72                  value = new ProfileSpecificationIDImpl(ckey);
73              } else if (componentType.equalsIgnoreCase(ComponentIDImpl.SERVICE_ID)) {
74                  value = new ServiceIDImpl(ckey);
75              } else if ( componentType.equalsIgnoreCase(ComponentIDImpl.EVENT_TYPE_ID)) {
76                  value = new EventTypeIDImpl( ckey);
77              } else
78                  throw new IllegalArgumentException("bad component type! "
79                          + componentType);
80              super.setValue(value);
81          } catch (NoSuchElementException ex) {
82              throw new IllegalArgumentException(ex.getMessage());
83          }
84      }
85      
86      public String getAsText() {
87          return this.getValue().toString();
88      }
89  
90  }