public RemoteNamingProvider createProvider(final FastHashtable<String, Object> env, final ProviderEnvironment providerEnvironment) throws NamingException { return new RemoteNamingProvider(getEndpoint(env), providerEnvironment, env); }
protected void unbindNative(final Name name) throws NamingException { Name realName = getRealName(name); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; performWithRetry((context_, name_, ignored) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); getRemoteTransport(peerIdentity).unbind(name_, peerIdentity); return null; }, environment, context, realName, null); }
protected CloseableNamingEnumeration<NameClassPair> listNative(final Name name) throws NamingException { Name realName = getRealName(name); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; return performWithRetry((context_, name_, ignored) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); return getRemoteTransport(peerIdentity).list(name_, peerIdentity); }, environment, context, realName, null); }
protected Object lookupNative(final Name name) throws NamingException { Name realName = getRealName(name); if (realName.isEmpty()) { return new RemoteContext(provider, scheme, getEnvironment()); } ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; return performWithRetry((context_, name_, ignored) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); return getRemoteTransport(peerIdentity).lookup(this, name_, peerIdentity, false); }, environment, context, realName, null); }
protected Context createSubcontextNative(final Name name) throws NamingException { Name realName = getRealName(name); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; return performWithRetry((context_, name_, ignored) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); final CompositeName compositeName = NamingUtils.toCompositeName(name_); getRemoteTransport(peerIdentity).createSubcontext(compositeName, peerIdentity); return new RelativeFederatingContext(getEnvironment(), this, compositeName); }, environment, context, realName, null); }
protected void bindNative(final Name name, final Object obj) throws NamingException { Name realName = getRealName(name); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; performWithRetry((context_, name_, obj_) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); getRemoteTransport(peerIdentity).bind(name_, obj_, peerIdentity, false); return null; }, environment, context, realName, obj); }
protected void renameNative(final Name oldName, final Name newName) throws NamingException { Name realOldName = getRealName(oldName); Name realNewName = getRealName(newName); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; performWithRetry((context_, oldName_, newName_) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); getRemoteTransport(peerIdentity).rename(oldName_, newName_, peerIdentity); return null; }, environment, context, realOldName, realNewName); }
protected CloseableNamingEnumeration<Binding> listBindingsNative(final Name name) throws NamingException { Name realName = getRealName(name); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; return performWithRetry((context_, name_, ignored) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); return getRemoteTransport(peerIdentity).listBindings(name_, this, peerIdentity); }, environment, context, realName, null); }
protected void destroySubcontextNative(final Name name) throws NamingException { Name realName = getRealName(name); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; performWithRetry((context_, name_, ignored) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); getRemoteTransport(peerIdentity).destroySubcontext(name_, peerIdentity); return null; }, environment, context, realName, null); }
public ObjectResolver getObjectResolver(final Transport transport, final boolean request) { if (transport instanceof RemoteTransport) { final RemoteTransport remoteTransport = (RemoteTransport) transport; if (remoteTransport.getVersion() == 1) { // naming version is 1, EJB version is 1 or 2 (same resolver either way) return new ProtocolV1ObjectResolver(remoteTransport.getConnection(), true); } else if (remoteTransport.getVersion() == 2) { // this refers to the naming version, not the EJB version // naming version is 2, EJB version is 3 return new ProtocolV3ObjectResolver(remoteTransport.getConnection(), true); } } return null; } }
/** * Get the future connection peer identity. If the connection is not configured as {@code immediate}, then the connection * will not actually be established until this method is called. The resultant connection should be closed and * discarded in the event of an error, in order to facilitate automatic reconnection. * * @param location a location from {@link ProviderEnvironment#getProviderUris()} (must not be {@code null}) * @return the future connection peer identity (not {@code null}) */ public IoFuture<ConnectionPeerIdentity> getFuturePeerIdentity(final URI location) { return doPrivileged((PrivilegedAction<IoFuture<ConnectionPeerIdentity>>) () -> getFuturePeerIdentityPrivileged(location)); }
public Context createRootContext(final NamingProvider namingProvider, final String nameScheme, final FastHashtable<String, Object> env, final ProviderEnvironment providerEnvironment) throws NamingException { // [WNFC-22] treat the java scheme as null return new RemoteContext((RemoteNamingProvider) namingProvider, "java".equals(nameScheme) ? null : nameScheme, env); } }
private void sendException(final Exception e, final int messageId, final int id) { try { writeExceptionResponse(e, messageId, id); } catch (IOException ioe) { Messages.log.failedToSendExceptionResponse(ioe); } }
public boolean supportsUriScheme(final String providerScheme, final FastHashtable<String, Object> env) { final Endpoint endpoint = getEndpoint(env); return endpoint != null && endpoint.isValidUriScheme(providerScheme); }
public void start(final Endpoint endpoint) throws IOException { registration = endpoint.registerService(ProtocolUtils.NAMING, new ChannelOpenListener(), OptionMap.EMPTY); }
/** * Get the connection peer identity. If the connection is not configured as {@code immediate}, then the connection * will not actually be established until this method is called. The resultant connection should be closed and * discarded in the event of an error, in order to facilitate automatic reconnection. * * @param location a location from {@link ProviderEnvironment#getProviderUris()} (must not be {@code null}) * @return the connection peer identity (not {@code null}) * @throws AuthenticationException if authenticating or re-authenticating the peer failed * @throws IOException if connecting the peer failed */ public ConnectionPeerIdentity getPeerIdentity(final URI location) throws IOException { Assert.checkNotNullParam("location", location); return getFuturePeerIdentity(location).get(); }
private void writeSuccessResponse(final int messageId, final int id) throws IOException { try (MessageOutputStream mos = messageTracker.openMessageUninterruptibly()) { mos.writeByte(messageId); writeId(mos, version, id); mos.writeByte(Protocol.SUCCESS); } }
public synchronized void stop(StopContext context) { try { remoteNamingService.stop(); } catch (IOException e) { throw new IllegalStateException("Failed to stop remote naming service", e); } }
protected Object lookupLinkNative(final Name name) throws NamingException { Name realName = getRealName(name); if (realName.isEmpty()) { return new RemoteContext(provider, scheme, getEnvironment()); } ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; return performWithRetry((context_, name_, ignored) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); return getRemoteTransport(peerIdentity).lookup(this, name_, peerIdentity, true); }, environment, context, realName, null); }
protected void rebindNative(final Name name, final Object obj) throws NamingException { Name realName = getRealName(name); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; performWithRetry((context_, name_, obj_) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); getRemoteTransport(peerIdentity).bind(name_, obj_, peerIdentity, true); return null; }, environment, context, realName, obj); }