本文整理汇总了Java中org.jboss.remoting3.Channel类的典型用法代码示例。如果您正苦于以下问题:Java Channel类的具体用法?Java Channel怎么用?Java Channel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Channel类属于org.jboss.remoting3包,在下文中一共展示了Channel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getChannel
import org.jboss.remoting3.Channel; //导入依赖的package包/类
private static Channel getChannel ( ConnectionProviderContextImpl context, ConnectionHandler ch, OptionMap options ) throws IOException {
Channel c;
FutureResult<Channel> chResult = new FutureResult<Channel>(context.getExecutor());
ch.open("jmx", chResult, options);
IoFuture<Channel> cFuture = chResult.getIoFuture();
Status s2 = cFuture.await();
if ( s2 == Status.FAILED ) {
System.err.println("Cannot connect");
if ( cFuture.getException() != null ) {
throw new IOException("Connect failed", cFuture.getException());
}
}
else if ( s2 != Status.DONE ) {
cFuture.cancel();
throw new IOException("Connect timeout");
}
c = cFuture.get();
return c;
}
开发者ID:hucheat,项目名称:APacheSynapseSimplePOC,代码行数:22,代码来源:JBoss.java
示例2: getChannel
import org.jboss.remoting3.Channel; //导入依赖的package包/类
@Override
public Channel getChannel() throws IOException {
Channel channel = super.getChannel();
if(channel != null) {
return channel;
}
// Try to connect and wait for the channel
synchronized (connectionManager) {
deadline = System.currentTimeMillis() + timeout; // read in openChannel below
connectionManager.connect();
deadline = null;
}
// In case connect did not succeed the next getChannel() call needs to try to reconnect
channel = super.getChannel();
if(channel == null) {
throw ProtocolLogger.ROOT_LOGGER.channelClosed();
}
return channel;
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:ManagementClientChannelStrategy.java
示例3: awaitChannel
import org.jboss.remoting3.Channel; //导入依赖的package包/类
/**
* Get the underlying channel. This may block until the channel is set.
*
* @return the channel
* @throws IOException for any error
*/
protected Channel awaitChannel() throws IOException {
Channel channel = this.channel;
if(channel != null) {
return channel;
}
synchronized (lock) {
for(;;) {
if(state == State.CLOSED) {
throw ProtocolLogger.ROOT_LOGGER.channelClosed();
}
channel = this.channel;
if(channel != null) {
return channel;
}
if(state == State.CLOSING) {
throw ProtocolLogger.ROOT_LOGGER.channelClosed();
}
try {
lock.wait();
} catch (InterruptedException e) {
throw new IOException(e);
}
}
}
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:32,代码来源:FutureManagementChannel.java
示例4: setChannel
import org.jboss.remoting3.Channel; //导入依赖的package包/类
/**
* Set the channel. This will return whether the channel could be set successfully or not.
*
* @param newChannel the channel
* @return whether the operation succeeded or not
*/
protected boolean setChannel(final Channel newChannel) {
if(newChannel == null) {
return false;
}
synchronized (lock) {
if(state != State.OPEN || channel != null) {
return false;
}
this.channel = newChannel;
this.channel.addCloseHandler(new CloseHandler<Channel>() {
@Override
public void handleClose(final Channel closed, final IOException exception) {
synchronized (lock) {
if(FutureManagementChannel.this.channel == closed) {
FutureManagementChannel.this.channel = null;
}
lock.notifyAll();
}
}
});
lock.notifyAll();
return true;
}
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:31,代码来源:FutureManagementChannel.java
示例5: executeRequest
import org.jboss.remoting3.Channel; //导入依赖的package包/类
/**
* Execute a request.
*
* @param request the request
* @param channel the channel
* @param support the request support
* @return the future result
*/
protected <T, A> AsyncFuture<T> executeRequest(final ManagementRequest<T, A> request, final Channel channel, final ActiveOperation<T, A> support) {
assert support != null;
updateChannelRef(support, channel);
final Integer requestId = this.requestID.incrementAndGet();
final ActiveRequest<T, A> ar = new ActiveRequest<T, A>(support, request);
requests.put(requestId, ar);
final ManagementRequestHeader header = new ManagementRequestHeader(ManagementProtocol.VERSION, requestId, support.getOperationId(), request.getOperationType());
final ActiveOperation.ResultHandler<T> resultHandler = support.getResultHandler();
try {
request.sendRequest(resultHandler, new ManagementRequestContextImpl<T, A>(support, channel, header, getExecutor()));
} catch (Exception e) {
resultHandler.failed(e);
requests.remove(requestId);
}
return support.getResult();
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:25,代码来源:AbstractMessageHandler.java
示例6: addChannelOpenListener
import org.jboss.remoting3.Channel; //导入依赖的package包/类
public Registration addChannelOpenListener(final String channelName, final OpenListener openListener) throws ServiceRegistrationException {
return endpoint.registerService(channelName, new OpenListener() {
public void channelOpened(final Channel channel) {
if (openListener != null) {
openListener.channelOpened(channel);
}
}
public void registrationTerminated() {
if (openListener != null) {
openListener.registrationTerminated();
}
}
}, OptionMap.EMPTY);
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:ChannelServer.java
示例7: openChannel
import org.jboss.remoting3.Channel; //导入依赖的package包/类
Channel openChannel(final Connection connection) throws IOException {
final IoFuture<Channel> future = connection.openChannel(DEFAULT_CHANNEL_SERVICE_TYPE, OptionMap.EMPTY);
future.await(10L, TimeUnit.SECONDS);
if (future.getStatus() == IoFuture.Status.WAITING) {
future.cancel();
throw ProtocolLogger.ROOT_LOGGER.channelTimedOut();
}
final Channel channel = future.get();
channel.addCloseHandler(new CloseHandler<Channel>() {
@Override
public void handleClose(final Channel old, final IOException e) {
synchronized (ChannelStrategy.this) {
if(ChannelStrategy.this.channel == old) {
ChannelStrategy.this.handler.handleClose(old, e);
ChannelStrategy.this.channel = null;
}
}
handler.handleChannelClosed(old, e);
}
});
return channel;
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:23,代码来源:DomainTestConnection.java
示例8: connectionOpened
import org.jboss.remoting3.Channel; //导入依赖的package包/类
@Override
public void connectionOpened(final Connection connection) throws IOException {
final Channel channel = openChannel(connection, CHANNEL_SERVICE_TYPE, configuration.getOptionMap());
if(setChannel(channel)) {
channel.receiveMessage(channelHandler.getReceiver());
channel.addCloseHandler(channelHandler);
try {
if (runningMode == RunningMode.ADMIN_ONLY) {
// Fetch the domain configuration
channelHandler.executeRequest(new FetchDomainConfigurationRequest(), null).getResult().get();
} else {
// Start the registration process
channelHandler.executeRequest(new RegisterHostControllerRequest(), null).getResult().get();
}
} catch (Exception e) {
if(e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
}
throw new IOException(e);
}
// Registered
registered();
} else {
channel.closeAsync();
}
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:27,代码来源:RemoteDomainConnection.java
示例9: addChannelOpenListener
import org.jboss.remoting3.Channel; //导入依赖的package包/类
public void addChannelOpenListener(final String channelName, final OpenListener openListener) throws ServiceRegistrationException {
registration = endpoint.registerService(channelName, new OpenListener() {
public void channelOpened(final Channel channel) {
if (openListener != null) {
openListener.channelOpened(channel);
}
}
public void registrationTerminated() {
if (openListener != null) {
openListener.registrationTerminated();
}
}
}, OptionMap.EMPTY);
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:ChannelServer.java
示例10: setupRemoting
import org.jboss.remoting3.Channel; //导入依赖的package包/类
public void setupRemoting(final ManagementChannelInitialization initialization) throws IOException {
//executorService = Executors.newCachedThreadPool();
final ThreadFactory threadFactory = new JBossThreadFactory(new ThreadGroup("Remoting"), Boolean.FALSE, null, "Remoting %f thread %t", null, null);
executorService = new QueueExecutor(EXECUTOR_MAX_THREADS / 4 + 1, EXECUTOR_MAX_THREADS, EXECUTOR_KEEP_ALIVE_TIME, TimeUnit.MILLISECONDS, 500, threadFactory, true, null);
final ChannelServer.Configuration configuration = new ChannelServer.Configuration();
configuration.setEndpointName(ENDPOINT_NAME);
configuration.setUriScheme(URI_SCHEME);
configuration.setBindAddress(new InetSocketAddress("127.0.0.1", PORT));
configuration.setExecutor(executorService);
channelServer = ChannelServer.create(configuration);
channelServer.addChannelOpenListener(TEST_CHANNEL, new OpenListener() {
@Override
public void registrationTerminated() {
}
@Override
public void channelOpened(Channel channel) {
serverChannel = channel;
initialization.startReceiving(channel);
clientConnectedLatch.countDown();
}
});
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:27,代码来源:RemoteChannelPairSetup.java
示例11: createReceiving
import org.jboss.remoting3.Channel; //导入依赖的package包/类
/**
* Create a model controller client which is exclusively receiving messages on an existing channel.
*
* @param channel the channel
* @param executorService an executor
* @return the created client
*/
public static ModelControllerClient createReceiving(final Channel channel, final ExecutorService executorService) {
final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
final ManagementChannelHandler handler = new ManagementChannelHandler(strategy, executorService);
final ExistingChannelModelControllerClient client = new ExistingChannelModelControllerClient(handler);
handler.addHandlerFactory(client);
channel.addCloseHandler(new CloseHandler<Channel>() {
@Override
public void handleClose(Channel closed, IOException exception) {
handler.shutdown();
try {
handler.awaitCompletion(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
handler.shutdownNow();
}
}
});
channel.receiveMessage(handler.getReceiver());
return client;
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:29,代码来源:ExistingChannelModelControllerClient.java
示例12: connectUsingRemoting
import org.jboss.remoting3.Channel; //导入依赖的package包/类
private boolean connectUsingRemoting(CommandContext cmdCtx, RemotingMBeanServerConnection rmtMBeanSvrConn)
throws IOException, CliInitializationException {
Connection conn = rmtMBeanSvrConn.getConnection();
Channel channel;
final IoFuture<Channel> futureChannel = conn.openChannel("management", OptionMap.EMPTY);
IoFuture.Status result = futureChannel.await(5, TimeUnit.SECONDS);
if (result == IoFuture.Status.DONE) {
channel = futureChannel.get();
} else {
futureChannel.cancel();
return false;
}
ModelControllerClient modelCtlrClient = ExistingChannelModelControllerClient.createReceiving(channel, createExecutor());
cmdCtx.bindClient(modelCtlrClient);
return true;
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:JConsoleCLIPlugin.java
示例13: doRun
import org.jboss.remoting3.Channel; //导入依赖的package包/类
private static void doRun ( URI u, final Object payloadObject, String username, String password ) {
ConnectionProvider instance = null;
ConnectionProviderContextImpl context = null;
ConnectionHandler ch = null;
Channel c = null;
VersionedConnection vc = null;
try {
Logger logger = LogManager.getLogManager().getLogger("");
logger.addHandler(new ConsoleLogHandler());
logger.setLevel(Level.INFO);
OptionMap options = OptionMap.builder().set(Options.SSL_ENABLED, u.getScheme().equals("https")).getMap();
context = new ConnectionProviderContextImpl(options, "endpoint");
instance = new HttpUpgradeConnectionProviderFactory().createInstance(context, options);
String host = u.getHost();
int port = u.getPort() > 0 ? u.getPort() : 9990;
SocketAddress destination = new InetSocketAddress(host, port);
ConnectionHandlerFactory chf = getConnection(destination, username, password, context, instance, options);
ch = chf.createInstance(new ConnectionHandlerContextImpl(context));
c = getChannel(context, ch, options);
System.err.println("Connected");
vc = makeVersionedConnection(c);
MBeanServerConnection mbc = vc.getMBeanServerConnection(null);
doExploit(payloadObject, mbc);
System.err.println("DONE");
}
catch ( Throwable e ) {
e.printStackTrace(System.err);
}
finally {
cleanup(instance, context, ch, c, vc);
}
}
开发者ID:hucheat,项目名称:APacheSynapseSimplePOC,代码行数:33,代码来源:JBoss.java
示例14: getRemoteAddress
import org.jboss.remoting3.Channel; //导入依赖的package包/类
/**
* Get the remote address.
*
* @return the remote address, {@code null} if not available
*/
public InetAddress getRemoteAddress() {
final Channel channel;
try {
channel = strategy.getChannel();
} catch (IOException e) {
return null;
}
final Connection connection = channel.getConnection();
final InetSocketAddress peerAddress = connection.getPeerAddress(InetSocketAddress.class);
return peerAddress == null ? null : peerAddress.getAddress();
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:ManagementChannelHandler.java
示例15: Establishing
import org.jboss.remoting3.Channel; //导入依赖的package包/类
private Establishing(final ProtocolConnectionConfiguration configuration, final Channel.Receiver receiver, final CloseHandler<Channel> closeHandler) {
this.receiver = receiver;
this.channelOptions = configuration.getOptionMap();
this.connectionManager = ProtocolConnectionManager.create(configuration, this);
this.closeHandler = closeHandler;
this.timeout = configuration.getConnectionTimeout();
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:8,代码来源:ManagementClientChannelStrategy.java
示例16: connectionOpened
import org.jboss.remoting3.Channel; //导入依赖的package包/类
@Override
public void connectionOpened(final Connection connection) throws IOException {
final Channel channel = openChannel(connection, serviceType, channelOptions);
if(setChannel(channel)) {
channel.receiveMessage(receiver);
} else {
channel.closeAsync();
}
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:10,代码来源:ManagementClientChannelStrategy.java
示例17: openChannel
import org.jboss.remoting3.Channel; //导入依赖的package包/类
@Override
protected Channel openChannel(final Connection connection, final String serviceType, final OptionMap options) throws IOException {
// This is only called as part of the connectionManager.connect() handling in getChannel() above.
// So, we should hold the connectionManager lock. We want to ensure that so we know we have the right deadline.
// We could synchronize again on connectionManager to ensure that, but then if there is some corner case
// the analysis missed where this gets called asynchronously during connectionManager.connect() handling
// we would deadlock. Better to fail than to deadlock. Use an ISE instead of an assert because if this
// fails, we don't want an Error; we want something that should eventually be caught and handled.
if (!Thread.holdsLock(connectionManager)) {
throw new IllegalStateException();
}
final Channel channel = openChannel(connection, serviceType, options, deadline);
channel.addCloseHandler(closeHandler);
return channel;
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:16,代码来源:ManagementClientChannelStrategy.java
示例18: handleError
import org.jboss.remoting3.Channel; //导入依赖的package包/类
@Override
public void handleError(final Channel channel, final IOException error) {
ProtocolLogger.ROOT_LOGGER.tracef(error, "%s error handling incoming data", this);
try {
channel.close();
} catch (IOException e) {
ProtocolLogger.ROOT_LOGGER.errorClosingChannel(e.getMessage());
}
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:10,代码来源:ManagementChannelReceiver.java
示例19: handleEnd
import org.jboss.remoting3.Channel; //导入依赖的package包/类
@Override
public void handleEnd(final Channel channel) {
try {
channel.close();
} catch (IOException e) {
ProtocolLogger.ROOT_LOGGER.errorClosingChannel(e.getMessage());
}
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:9,代码来源:ManagementChannelReceiver.java
示例20: handlePing
import org.jboss.remoting3.Channel; //导入依赖的package包/类
/**
* Handle a simple ping request.
*
* @param channel the channel
* @param header the protocol header
* @throws IOException for any error
*/
private static void handlePing(final Channel channel, final ManagementProtocolHeader header) throws IOException {
final ManagementProtocolHeader response = new ManagementPongHeader(header.getVersion());
final MessageOutputStream output = channel.writeMessage();
try {
writeHeader(response, output);
output.close();
} finally {
StreamUtils.safeClose(output);
}
}
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:ManagementChannelReceiver.java
注:本文中的org.jboss.remoting3.Channel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论