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