/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A RegistryContext is a context representing a remote RMI registry.
*
* @author Scott Seligman
*/
private int port;
// Environment property that, if set, indicates that a security
// manager should be installed (if none is already in place).
"java.naming.rmi.security.manager";
/**
* Returns a context for the registry at a given host and port.
* If "host" is null, uses default host.
* If "port" is non-positive, uses default port.
* Cloning of "env" is handled by caller; see comments within
* RegistryContextFactory.getObjectInstance(), for example.
*/
throws NamingException
{
}
// chop off '[' and ']' in an IPv6 literal address
}
}
/**
* Returns a clone of a registry context. The context's private state
* is independent of the original's (so closing one context, for example,
* won't close the other).
*/
// %%% Alternatively, this could be done with a clone() method.
}
protected void finalize() {
close();
}
return (new RegistryContext(this));
}
try {
} catch (NotBoundException e) {
} catch (RemoteException e) {
}
}
}
/**
* If the object to be bound is both Remote and Referenceable, binds the
* object itself, not its Reference.
*/
throw (new InvalidNameException(
"RegistryContext: Cannot bind empty name"));
}
try {
} catch (AlreadyBoundException e) {
ne.setRootCause(e);
throw ne;
} catch (RemoteException e) {
}
}
}
throw (new InvalidNameException(
"RegistryContext: Cannot rebind empty name"));
}
try {
} catch (RemoteException e) {
}
}
}
throw (new InvalidNameException(
"RegistryContext: Cannot unbind empty name"));
}
try {
} catch (NotBoundException e) {
// method is idempotent
} catch (RemoteException e) {
}
}
}
/**
* Rename is implemented by this sequence of operations:
* lookup, bind, unbind. The sequence is not performed atomically.
*/
}
}
throw (new InvalidNameException(
"RegistryContext: can only list \"\""));
}
try {
return (new NameClassPairEnumeration(names));
} catch (RemoteException e) {
}
}
}
throws NamingException
{
throw (new InvalidNameException(
"RegistryContext: can only list \"\""));
}
try {
return (new BindingEnumeration(this, names));
} catch (RemoteException e) {
}
}
}
throw (new OperationNotSupportedException());
}
throw (new OperationNotSupportedException());
}
throw (new OperationNotSupportedException());
}
throw (new OperationNotSupportedException());
}
}
}
return nameParser;
}
return nameParser;
}
}
throws NamingException
{
}
throws NamingException
{
}
throws NamingException
{
}
}
}
public void close() {
environment = null;
// &&& If we were caching registry connections, we would probably
// uncache this one now.
}
return ""; // Registry has an empty name
}
/**
* Returns an RMI registry reference for this context.
*<p>
* If this context was created from a reference, that reference is
* returned. Otherwise, an exception is thrown if the registry's
* host is "localhost" or the default (null). Although this could
* possibly make for a valid reference, it's far more likely to be
* an easily made error.
*
* @see RegistryContextFactory
*/
}
throw (new ConfigurationException(
"Cannot create a reference for an RMI registry whose " +
"host was unspecified or specified as \"localhost\""));
}
// Enclose IPv6 literal address in '[' and ']'
if (port > 0) {
}
url);
addr,
RegistryContextFactory.class.getName(),
null));
}
/**
* Wrap a RemoteException inside a NamingException.
*/
if (re instanceof ConnectException) {
ne = new ServiceUnavailableException();
} else if (re instanceof AccessException) {
ne = new NoPermissionException();
} else if (re instanceof StubNotFoundException ||
re instanceof UnknownHostException ||
re instanceof SocketSecurityException) {
ne = new ConfigurationException();
} else if (re instanceof ExportException ||
re instanceof ConnectIOException ||
re instanceof MarshalException ||
re instanceof UnmarshalException ||
re instanceof NoSuchObjectException) {
ne = new CommunicationException();
} else if (re instanceof ServerException &&
} else {
ne = new NamingException();
}
return ne;
}
/**
* Returns the registry at a given host, port and socket factory.
* If "host" is null, uses default host.
* If "port" is non-positive, uses default port.
* If "socketFactory" is null, uses the default socket.
*/
throws NamingException
{
// %%% We could cache registry connections here. The transport layer
// may already reuse connections.
try {
if (socketFactory == null) {
} else {
}
} catch (RemoteException e) {
}
}
/**
* Attempts to install a security manager if none is currently in
* place.
*/
private static void installSecurityMgr() {
try {
} catch (Exception e) {
}
}
/**
* Encodes an object prior to binding it in the registry. First,
* NamingManager.getStateToBind() is invoked. If the resulting
* object is Remote, it is returned. If it is a Reference or
* Referenceable, the reference is wrapped in a Remote object.
* Otherwise, an exception is thrown.
*
* @param name The object's name relative to this context.
*/
throws NamingException, RemoteException
{
}
}
if (obj instanceof Referenceable) {
}
throw (new IllegalArgumentException(
"RegistryContext: " +
"object to bind must be Remote, Reference, or Referenceable"));
}
/**
* Decodes an object that has been retrieved from the registry.
* First, if the object is a RemoteReference, the Reference is
* unwrapped. Then, NamingManager.getObjectInstance() is invoked.
*
* @param name The object's name relative to this context.
*/
try {
? ((RemoteReference)r).getReference()
: (Object)r;
} catch (NamingException e) {
throw e;
} catch (RemoteException e) {
throw (NamingException)
} catch (Exception e) {
ne.setRootCause(e);
throw ne;
}
}
}
/**
* A name parser for case-sensitive atomic names.
*/
}
}
/**
* An enumeration of name / class-name pairs. Since we don't know anything
* about the classes, each class name is returned as the generic
* "java.lang.Object".
*/
nextName = 0;
}
public boolean hasMore() {
}
if (!hasMore()) {
}
// Convert name to a one-element composite name, so embedded
// meta-characters are properly escaped.
"java.lang.Object");
return ncp;
}
public boolean hasMoreElements() {
return hasMore();
}
try {
return next();
} catch (NamingException e) { // should never happen
"javax.naming.NamingException was thrown"));
}
}
public void close() {
}
}
/**
* An enumeration of Bindings.
*
* The actual registry lookups are performed when next() is called. It would
* be nicer to defer this until the object (or its class name) is actually
* requested. The problem with that approach is that Binding.getObject()
* cannot throw NamingException.
*/
// Clone ctx in case someone closes it before we're through.
nextName = 0;
}
protected void finalize() {
}
public boolean hasMore() {
}
}
if (!hasMore()) {
}
// Convert name to a one-element composite name, so embedded
// meta-characters are properly escaped.
return binding;
}
public boolean hasMoreElements() {
return hasMore();
}
try {
return next();
} catch (NamingException e) {
"javax.naming.NamingException was thrown"));
}
}
public void close () {
finalize();
}
}