/jboss-as-7.1.1.Final/transactions/src/main/java/org/jboss/as/txn/subsystem/Element.java

# · Java · 79 lines · 35 code · 11 blank · 33 comment · 4 complexity · ffcb40e8dc4e7e33ccc23d33f8ddb58f MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2010, Red Hat, Inc., and individual contributors
  4. * as indicated by the @author tags. See the copyright.txt file in the
  5. * distribution for a 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. package org.jboss.as.txn.subsystem;
  23. import java.util.HashMap;
  24. import java.util.Map;
  25. /**
  26. * Enumeration of elements used in the transactions subsystem.
  27. *
  28. * @author John E. Bailey
  29. * @author Scott Stark (sstark@redhat.com) (C) 2011 Red Hat Inc.
  30. */
  31. enum Element {
  32. // must be first
  33. UNKNOWN(null),
  34. RECOVERY_ENVIRONMENT("recovery-environment"),
  35. CORE_ENVIRONMENT("core-environment"),
  36. COORDINATOR_ENVIRONMENT("coordinator-environment"),
  37. OBJECT_STORE("object-store"),
  38. PROCESS_ID("process-id"),
  39. SOCKET("socket"),
  40. UUID("uuid"),
  41. JTS("jts"),
  42. ;
  43. private final String name;
  44. Element(final String name) {
  45. this.name = name;
  46. }
  47. /**
  48. * Get the local name of this element.
  49. *
  50. * @return the local name
  51. */
  52. public String getLocalName() {
  53. return name;
  54. }
  55. private static final Map<String, Element> MAP;
  56. static {
  57. final Map<String, Element> map = new HashMap<String, Element>();
  58. for (Element element : values()) {
  59. final String name = element.getLocalName();
  60. if (name != null) map.put(name, element);
  61. }
  62. MAP = map;
  63. }
  64. public static Element forName(String localName) {
  65. final Element element = MAP.get(localName);
  66. return element == null ? UNKNOWN : element;
  67. }
  68. }