PageRenderTime 40ms CodeModel.GetById 6ms RepoModel.GetById 0ms app.codeStats 0ms

/jboss-as-7.1.1.Final/ee/src/main/java/org/jboss/as/ee/component/BindingConfiguration.java

#
Java | 88 lines | 31 code | 11 blank | 46 comment | 6 complexity | 690a27d459d90da831006e2d9fdb5347 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2011, 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.ee.component;
  23. import static org.jboss.as.ee.EeMessages.MESSAGES;
  24. /**
  25. * A binding into JNDI. This class contains the mechanism to construct the binding service. In particular
  26. * it represents <b>only</b> the description of the binding; it does not represent injection or any other parameters
  27. * of a JNDI resource.
  28. *
  29. * @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
  30. */
  31. public final class BindingConfiguration {
  32. private final String name;
  33. private final InjectionSource source;
  34. /**
  35. * Construct a new instance.
  36. *
  37. * @param name the binding name
  38. * @param source The source which will be used to resolve a value to be bound in the JNDI
  39. * @throws IllegalArgumentException If either of the passed <code>name</code> or <code>source</code> is null
  40. */
  41. public BindingConfiguration(final String name, final InjectionSource source) {
  42. if (name == null) {
  43. throw MESSAGES.nullVar("name");
  44. }
  45. if (source == null) {
  46. throw MESSAGES.nullVar("source");
  47. }
  48. this.name = name;
  49. this.source = source;
  50. }
  51. /**
  52. * The name into which this binding should be made. The meaning of relative names depends on where this
  53. * binding description is used. For component bindings, relative names are generally relative to {@code java:comp/env}.
  54. *
  55. * @return the name into which this binding should be made
  56. */
  57. public String getName() {
  58. return name;
  59. }
  60. /**
  61. * Get the source for this binding.
  62. *
  63. * @return the binding's injection source
  64. */
  65. public InjectionSource getSource() {
  66. return source;
  67. }
  68. public boolean equals(Object other) {
  69. if (!(other instanceof BindingConfiguration))
  70. return false;
  71. BindingConfiguration config = (BindingConfiguration)other;
  72. return name.equals(config.name) && source.equals(config.source);
  73. }
  74. public int hashCode() {
  75. return name.hashCode() * 31 + source.hashCode();
  76. }
  77. }