开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
forked from Stefan/Java8Source
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (2)
master
develop
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (2)
master
develop
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (2)
master
develop
Java8Source
/
src
/
javax
/
naming
/
Reference.java
Java8Source
/
src
/
javax
/
naming
/
Reference.java
Reference.java 13.22 KB
一键复制 编辑 原始数据 按行查看 历史
Stefan 提交于 2020年08月11日 23:17 +08:00 . 初始化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
/*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package javax.naming;
import java.util.Vector;
import java.util.Enumeration;
/**
* This class represents a reference to an object that is found outside of
* the naming/directory system.
*<p>
* Reference provides a way of recording address information about
* objects which themselves are not directly bound to the naming/directory system.
*<p>
* A Reference consists of an ordered list of addresses and class information
* about the object being referenced.
* Each address in the list identifies a communications endpoint
* for the same conceptual object. The "communications endpoint"
* is information that indicates how to contact the object. It could
* be, for example, a network address, a location in memory on the
* local machine, another process on the same machine, etc.
* The order of the addresses in the list may be of significance
* to object factories that interpret the reference.
*<p>
* Multiple addresses may arise for
* various reasons, such as replication or the object offering interfaces
* over more than one communication mechanism. The addresses are indexed
* starting with zero.
*<p>
* A Reference also contains information to assist in creating an instance
* of the object to which this Reference refers. It contains the class name
* of that object, and the class name and location of the factory to be used
* to create the object.
* The class factory location is a space-separated list of URLs representing
* the class path used to load the factory. When the factory class (or
* any class or resource upon which it depends) needs to be loaded,
* each URL is used (in order) to attempt to load the class.
*<p>
* A Reference instance is not synchronized against concurrent access by multiple
* threads. Threads that need to access a single Reference concurrently should
* synchronize amongst themselves and provide the necessary locking.
*
* @author Rosanna Lee
* @author Scott Seligman
*
* @see RefAddr
* @see StringRefAddr
* @see BinaryRefAddr
* @since 1.3
*/
/*<p>
* The serialized form of a Reference object consists of the class
* name of the object being referenced (a String), a Vector of the
* addresses (each a RefAddr), the name of the class factory (a
* String), and the location of the class factory (a String).
*/
public class Reference implements Cloneable, java.io.Serializable {
/**
* Contains the fully-qualified name of the class of the object to which
* this Reference refers.
* @serial
* @see java.lang.Class#getName
*/
protected String className;
/**
* Contains the addresses contained in this Reference.
* Initialized by constructor.
* @serial
*/
protected Vector<RefAddr> addrs = null;
/**
* Contains the name of the factory class for creating
* an instance of the object to which this Reference refers.
* Initialized to null.
* @serial
*/
protected String classFactory = null;
/**
* Contains the location of the factory class.
* Initialized to null.
* @serial
*/
protected String classFactoryLocation = null;
/**
* Constructs a new reference for an object with class name 'className'.
* Class factory and class factory location are set to null.
* The newly created reference contains zero addresses.
*
* @param className The non-null class name of the object to which
* this reference refers.
*/
public Reference(String className) {
this.className = className;
addrs = new Vector<>();
}
/**
* Constructs a new reference for an object with class name 'className' and
* an address.
* Class factory and class factory location are set to null.
*
* @param className The non-null class name of the object to
* which this reference refers.
* @param addr The non-null address of the object.
*/
public Reference(String className, RefAddr addr) {
this.className = className;
addrs = new Vector<>();
addrs.addElement(addr);
}
/**
* Constructs a new reference for an object with class name 'className',
* and the class name and location of the object's factory.
*
* @param className The non-null class name of the object to which
* this reference refers.
* @param factory The possibly null class name of the object's factory.
* @param factoryLocation
* The possibly null location from which to load
* the factory (e.g. URL)
* @see javax.naming.spi.ObjectFactory
* @see javax.naming.spi.NamingManager#getObjectInstance
*/
public Reference(String className, String factory, String factoryLocation) {
this(className);
classFactory = factory;
classFactoryLocation = factoryLocation;
}
/**
* Constructs a new reference for an object with class name 'className',
* the class name and location of the object's factory, and the address for
* the object.
*
* @param className The non-null class name of the object to
* which this reference refers.
* @param factory The possibly null class name of the object's factory.
* @param factoryLocation The possibly null location from which
* to load the factory (e.g. URL)
* @param addr The non-null address of the object.
* @see javax.naming.spi.ObjectFactory
* @see javax.naming.spi.NamingManager#getObjectInstance
*/
public Reference(String className, RefAddr addr,
String factory, String factoryLocation) {
this(className, addr);
classFactory = factory;
classFactoryLocation = factoryLocation;
}
/**
* Retrieves the class name of the object to which this reference refers.
*
* @return The non-null fully-qualified class name of the object.
* (e.g. "java.lang.String")
*/
public String getClassName() {
return className;
}
/**
* Retrieves the class name of the factory of the object
* to which this reference refers.
*
* @return The possibly null fully-qualified class name of the factory.
* (e.g. "java.lang.String")
*/
public String getFactoryClassName() {
return classFactory;
}
/**
* Retrieves the location of the factory of the object
* to which this reference refers.
* If it is a codebase, then it is an ordered list of URLs,
* separated by spaces, listing locations from where the factory
* class definition should be loaded.
*
* @return The possibly null string containing the
* location for loading in the factory's class.
*/
public String getFactoryClassLocation() {
return classFactoryLocation;
}
/**
* Retrieves the first address that has the address type 'addrType'.
* String.compareTo() is used to test the equality of the address types.
*
* @param addrType The non-null address type for which to find the address.
* @return The address in this reference with address type 'addrType;
* null if no such address exist.
*/
public RefAddr get(String addrType) {
int len = addrs.size();
RefAddr addr;
for (int i = 0; i < len; i++) {
addr = addrs.elementAt(i);
if (addr.getType().compareTo(addrType) == 0)
return addr;
}
return null;
}
/**
* Retrieves the address at index posn.
* @param posn The index of the address to retrieve.
* @return The address at the 0-based index posn. It must be in the
* range [0,getAddressCount()).
* @exception ArrayIndexOutOfBoundsException If posn not in the specified
* range.
*/
public RefAddr get(int posn) {
return addrs.elementAt(posn);
}
/**
* Retrieves an enumeration of the addresses in this reference.
* When addresses are added, changed or removed from this reference,
* its effects on this enumeration are undefined.
*
* @return An non-null enumeration of the addresses
* (<tt>RefAddr</tt>) in this reference.
* If this reference has zero addresses, an enumeration with
* zero elements is returned.
*/
public Enumeration<RefAddr> getAll() {
return addrs.elements();
}
/**
* Retrieves the number of addresses in this reference.
*
* @return The nonnegative number of addresses in this reference.
*/
public int size() {
return addrs.size();
}
/**
* Adds an address to the end of the list of addresses.
*
* @param addr The non-null address to add.
*/
public void add(RefAddr addr) {
addrs.addElement(addr);
}
/**
* Adds an address to the list of addresses at index posn.
* All addresses at index posn or greater are shifted up
* the list by one (away from index 0).
*
* @param posn The 0-based index of the list to insert addr.
* @param addr The non-null address to add.
* @exception ArrayIndexOutOfBoundsException If posn not in the specified
* range.
*/
public void add(int posn, RefAddr addr) {
addrs.insertElementAt(addr, posn);
}
/**
* Deletes the address at index posn from the list of addresses.
* All addresses at index greater than posn are shifted down
* the list by one (towards index 0).
*
* @param posn The 0-based index of in address to delete.
* @return The address removed.
* @exception ArrayIndexOutOfBoundsException If posn not in the specified
* range.
*/
public Object remove(int posn) {
Object r = addrs.elementAt(posn);
addrs.removeElementAt(posn);
return r;
}
/**
* Deletes all addresses from this reference.
*/
public void clear() {
addrs.setSize(0);
}
/**
* Determines whether obj is a reference with the same addresses
* (in same order) as this reference.
* The addresses are checked using RefAddr.equals().
* In addition to having the same addresses, the Reference also needs to
* have the same class name as this reference.
* The class factory and class factory location are not checked.
* If obj is null or not an instance of Reference, null is returned.
*
* @param obj The possibly null object to check.
* @return true if obj is equal to this reference; false otherwise.
*/
public boolean equals(Object obj) {
if ((obj != null) && (obj instanceof Reference)) {
Reference target = (Reference)obj;
// ignore factory information
if (target.className.equals(this.className) &&
target.size() == this.size()) {
Enumeration<RefAddr> mycomps = getAll();
Enumeration<RefAddr> comps = target.getAll();
while (mycomps.hasMoreElements())
if (!(mycomps.nextElement().equals(comps.nextElement())))
return false;
return true;
}
}
return false;
}
/**
* Computes the hash code of this reference.
* The hash code is the sum of the hash code of its addresses.
*
* @return A hash code of this reference as an int.
*/
public int hashCode() {
int hash = className.hashCode();
for (Enumeration<RefAddr> e = getAll(); e.hasMoreElements();)
hash += e.nextElement().hashCode();
return hash;
}
/**
* Generates the string representation of this reference.
* The string consists of the class name to which this reference refers,
* and the string representation of each of its addresses.
* This representation is intended for display only and not to be parsed.
*
* @return The non-null string representation of this reference.
*/
public String toString() {
StringBuffer buf = new StringBuffer("Reference Class Name: " +
className + "\n");
int len = addrs.size();
for (int i = 0; i < len; i++)
buf.append(get(i).toString());
return buf.toString();
}
/**
* Makes a copy of this reference using its class name
* list of addresses, class factory name and class factory location.
* Changes to the newly created copy does not affect this Reference
* and vice versa.
*/
public Object clone() {
Reference r = new Reference(className, classFactory, classFactoryLocation);
Enumeration<RefAddr> a = getAll();
r.addrs = new Vector<>();
while (a.hasMoreElements())
r.addrs.addElement(a.nextElement());
return r;
}
/**
* Use serialVersionUID from JNDI 1.1.1 for interoperability
*/
private static final long serialVersionUID = -1673475790065791735L;
};
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/yxljava/Java8Source.git
git@gitee.com:yxljava/Java8Source.git
yxljava
Java8Source
Java8Source
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /