1 /*
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
37 * a binding dynamically.
38 *<p>
39 * A Binding instance is not synchronized against concurrent access by multiple
40 * threads. Threads that need to access a Binding concurrently should
41 * synchronize amongst themselves and provide the necessary locking.
42 *
43 * @author Rosanna Lee
44 * @author Scott Seligman
45 * @since 1.3
46 */
47
48 public class Binding extends NameClassPair {
49 /**
50 * Contains this binding's object.
51 * It is initialized by the constructor and can be updated using
52 * {@code setObject}.
53 * @serial
54 * @see #getObject
55 * @see #setObject
56 */
57 private Object boundObj;
58
59 /**
60 * Constructs an instance of a Binding given its name and object.
61 *<p>
62 * {@code getClassName()} will return
63 * the class name of {@code obj} (or null if {@code obj} is null)
64 * unless the class name has been explicitly set using {@code setClassName()}
65 *
66 * @param name The non-null name of the object. It is relative
67 * to the <em>target context</em> (which is
68 * named by the first parameter of the <code>listBindings()</code> method)
69 * @param obj The possibly null object bound to name.
70 * @see NameClassPair#setClassName
71 */
72 public Binding(String name, Object obj) {
73 super(name, null);
74 this.boundObj = obj;
75 }
76
|
1 /*
2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
37 * a binding dynamically.
38 *<p>
39 * A Binding instance is not synchronized against concurrent access by multiple
40 * threads. Threads that need to access a Binding concurrently should
41 * synchronize amongst themselves and provide the necessary locking.
42 *
43 * @author Rosanna Lee
44 * @author Scott Seligman
45 * @since 1.3
46 */
47
48 public class Binding extends NameClassPair {
49 /**
50 * Contains this binding's object.
51 * It is initialized by the constructor and can be updated using
52 * {@code setObject}.
53 * @serial
54 * @see #getObject
55 * @see #setObject
56 */
57 @SuppressWarnings("serial") // Not statically typed as Serializable
58 private Object boundObj;
59
60 /**
61 * Constructs an instance of a Binding given its name and object.
62 *<p>
63 * {@code getClassName()} will return
64 * the class name of {@code obj} (or null if {@code obj} is null)
65 * unless the class name has been explicitly set using {@code setClassName()}
66 *
67 * @param name The non-null name of the object. It is relative
68 * to the <em>target context</em> (which is
69 * named by the first parameter of the <code>listBindings()</code> method)
70 * @param obj The possibly null object bound to name.
71 * @see NameClassPair#setClassName
72 */
73 public Binding(String name, Object obj) {
74 super(name, null);
75 this.boundObj = obj;
76 }
77
|