本文整理汇总了Java中org.jboss.as.network.SocketBinding类的典型用法代码示例。如果您正苦于以下问题:Java SocketBinding类的具体用法?Java SocketBinding怎么用?Java SocketBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SocketBinding类属于org.jboss.as.network包,在下文中一共展示了SocketBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: install
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
public static ServiceController<Void> install(ServiceTarget target,
String serviceName,
String socketBindingName,
Collection<String> userDefinedTags) {
List<String> tags = new ArrayList<>(userDefinedTags);
tags.add(socketBindingName);
ServiceName socketBinding = ServiceName.parse("org.wildfly.network.socket-binding." + socketBindingName);
RegistrationAdvertiser advertiser = new RegistrationAdvertiser(serviceName, tags.toArray(new String[tags.size()]));
return target.addService(ServiceName.of("swarm", "topology", "register", serviceName, socketBindingName), advertiser)
.addDependency(CONNECTOR_SERVICE_NAME, TopologyConnector.class, advertiser.getTopologyConnectorInjector())
.addDependency(socketBinding, SocketBinding.class, advertiser.getSocketBindingInjector())
.setInitialMode(ServiceController.Mode.PASSIVE)
.install();
}
示例2: installConnectorServicesForSocketBinding
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
public static void installConnectorServicesForSocketBinding(ServiceTarget serviceTarget,
final ServiceName endpointName,
final String connectorName,
final ServiceName socketBindingName,
final OptionMap connectorPropertiesOptionMap,
final ServiceName securityRealm,
final ServiceName saslAuthenticationFactory,
final ServiceName sslContext,
final ServiceName socketBindingManager) {
final InjectedSocketBindingStreamServerService streamServerService = new InjectedSocketBindingStreamServerService(connectorPropertiesOptionMap);
final ServiceBuilder<AcceptingChannel<StreamConnection>> serviceBuilder = serviceTarget.addService(serverServiceName(connectorName), streamServerService)
.addDependency(socketBindingName, SocketBinding.class, streamServerService.getSocketBindingInjector())
.addDependency(socketBindingManager, SocketBindingManager.class, streamServerService.getSocketBindingManagerInjector());
installConnectorServices(serviceBuilder, streamServerService, endpointName, securityRealm, saslAuthenticationFactory, sslContext);
}
示例3: launchServices
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
void launchServices(OperationContext context, String connectorName, ModelNode fullModel) throws OperationFailedException {
OptionMap optionMap = ConnectorUtils.getFullOptions(context, fullModel);
final ServiceTarget target = context.getServiceTarget();
final String socketName = ConnectorResource.SOCKET_BINDING.resolveModelAttribute(context, fullModel).asString();
final ServiceName socketBindingName = context.getCapabilityServiceName(ConnectorResource.SOCKET_CAPABILITY_NAME, socketName, SocketBinding.class);
ModelNode securityRealmModel = ConnectorResource.SECURITY_REALM.resolveModelAttribute(context, fullModel);
final ServiceName securityRealmName = securityRealmModel.isDefined() ? SecurityRealm.ServiceUtil.createServiceName(securityRealmModel.asString()) : null;
ModelNode saslAuthenticationFactoryModel = ConnectorResource.SASL_AUTHENTICATION_FACTORY.resolveModelAttribute(context, fullModel);
final ServiceName saslAuthenticationFactoryName = saslAuthenticationFactoryModel.isDefined()
? context.getCapabilityServiceName(SASL_AUTHENTICATION_FACTORY_CAPABILITY, saslAuthenticationFactoryModel.asString(), SaslAuthenticationFactory.class)
: null;
ModelNode sslContextModel = ConnectorResource.SSL_CONTEXT.resolveModelAttribute(context, fullModel);
final ServiceName sslContextName = sslContextModel.isDefined()
? context.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY, sslContextModel.asString(), SSLContext.class) : null;
final ServiceName sbmName = context.getCapabilityServiceName(SOCKET_BINDING_MANAGER_CAPABILTIY, SocketBindingManager.class);
RemotingServices.installConnectorServicesForSocketBinding(target, RemotingServices.SUBSYSTEM_ENDPOINT, connectorName,
socketBindingName, optionMap, securityRealmName, saslAuthenticationFactoryName, sslContextName, sbmName);
}
示例4: applyUpdateToRuntime
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
@Override
protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue,
final ModelNode currentValue, final HandbackHolder<RollbackInfo> handbackHolder) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
final PathElement element = address.getLastElement();
final String bindingName = element.getValue();
final ModelNode bindingModel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
final ServiceName serviceName = SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(bindingName, SocketBinding.class);
final ServiceController<?> controller = context.getServiceRegistry(true).getRequiredService(serviceName);
final SocketBinding binding = controller.getState() == ServiceController.State.UP ? SocketBinding.class.cast(controller.getValue()) : null;
final boolean bound = binding != null && binding.isBound();
if (binding == null) {
// existing is not started, so can't update it. Instead reinstall the service
handleBindingReinstall(context, bindingName, bindingModel, serviceName);
} else if (bound) {
// Cannot edit bound sockets
return true;
} else {
handleRuntimeChange(context, operation, attributeName, resolvedValue, binding);
}
handbackHolder.setHandback(new RollbackInfo(bindingName, bindingModel, binding));
return requiresRestart();
}
示例5: installBindingService
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
static void installBindingService(OperationContext context, ModelNode config, String name)
throws UnknownHostException, OperationFailedException {
final CapabilityServiceTarget serviceTarget = context.getCapabilityServiceTarget();
final ModelNode intfNode = AbstractSocketBindingResourceDefinition.INTERFACE.resolveModelAttribute(context, config);
final String intf = intfNode.isDefined() ? intfNode.asString() : null;
final int port = AbstractSocketBindingResourceDefinition.PORT.resolveModelAttribute(context, config).asInt();
final boolean fixedPort = AbstractSocketBindingResourceDefinition.FIXED_PORT.resolveModelAttribute(context, config).asBoolean();
final ModelNode mcastNode = AbstractSocketBindingResourceDefinition.MULTICAST_ADDRESS.resolveModelAttribute(context, config);
final String mcastAddr = mcastNode.isDefined() ? mcastNode.asString() : null;
final int mcastPort = AbstractSocketBindingResourceDefinition.MULTICAST_PORT.resolveModelAttribute(context, config).asInt(0);
final InetAddress mcastInet = mcastAddr == null ? null : InetAddress.getByName(mcastAddr);
final ModelNode mappingsNode = config.get(CLIENT_MAPPINGS);
final List<ClientMapping> clientMappings = mappingsNode.isDefined() ? parseClientMappings(context, mappingsNode) : null;
final SocketBindingService service = new SocketBindingService(name, port, fixedPort, mcastInet, mcastPort, clientMappings);
final CapabilityServiceBuilder<SocketBinding> builder = serviceTarget.addCapability(SOCKET_BINDING_CAPABILITY, service);
if (intf != null) {
builder.addCapabilityRequirement("org.wildfly.network.interface", NetworkInterfaceBinding.class, service.getInterfaceBinding(), intf);
}
builder.addCapabilityRequirement("org.wildfly.management.socket-binding-manager", SocketBindingManager.class, service.getSocketBindings())
.addAliases(SocketBinding.JBOSS_BINDING_NAME.append(name))
.setInitialMode(Mode.ON_DEMAND)
.install();
}
示例6: validateEndpointPort
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
private void validateEndpointPort(URI httpURI) {
// Camel HTTP endpoint port defaults are 0 or -1
boolean portMatched = httpURI.getPort() == 0 || httpURI.getPort() == -1;
// If a port was specified, verify that undertow has a listener configured for it
if (!portMatched) {
for (UndertowListener listener : defaultHost.getServer().getListeners()) {
SocketBinding binding = listener.getSocketBinding();
if (binding != null) {
if (binding.getPort() == httpURI.getPort()) {
portMatched = true;
break;
}
}
}
}
if (!"localhost".equals(httpURI.getHost())) {
LOGGER.debug("Cannot bind to host other than 'localhost': {}", httpURI);
}
if (!portMatched) {
LOGGER.debug("Cannot bind to specific port: {}", httpURI);
}
}
示例7: installAdvertiser
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
private void installAdvertiser(ServiceTarget target, String serviceName, String socketBindingName) {
ServiceName socketBinding = ServiceName.parse("org.wildfly.network.socket-binding." + socketBindingName);
RegistrationAdvertiser advertiser = new RegistrationAdvertiser(serviceName, socketBindingName);
target.addService(ServiceName.of("swarm", "topology", "register", serviceName, socketBindingName), advertiser)
.addDependency(TopologyConnector.SERVICE_NAME, TopologyConnector.class, advertiser.getTopologyConnectorInjector())
.addDependency(socketBinding, SocketBinding.class, advertiser.getSocketBindingInjector())
.setInitialMode(ServiceController.Mode.PASSIVE)
.install();
}
开发者ID:wildfly-swarm-archive,项目名称:wildfly-swarm-topology,代码行数:11,代码来源:RegistrationAdvertiserActivator.java
示例8: unadvertise
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
public synchronized void unadvertise(String appName, SocketBinding binding) {
Registration registration = this.registrations.remove(appName + ":" + binding.getName());
if (registration != null) {
try {
this.dispatcher.submitOnCluster(new UnadvertiseCommand(registration));
} catch (Exception e) {
e.printStackTrace();
}
}
}
开发者ID:wildfly-swarm-archive,项目名称:wildfly-swarm-topology-jgroups,代码行数:11,代码来源:JGroupsTopologyConnector.java
示例9: testPorts
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testPorts() throws Exception {
ServiceController<SocketBinding> statusManagerService = (ServiceController<SocketBinding>) registry.getService(ServiceName.parse("org.wildfly.network.socket-binding.txn-status-manager"));
SocketBinding statusManager = statusManagerService.getValue();
assertEquals(9876, statusManager.getAbsolutePort());
ServiceController<SocketBinding> recoveryService = (ServiceController<SocketBinding>) registry.getService(ServiceName.parse("org.wildfly.network.socket-binding.txn-recovery-environment"));
SocketBinding recovery = recoveryService.getValue();
assertEquals(4567, recovery.getAbsolutePort());
}
示例10: installAdvertiser
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
private void installAdvertiser(ServiceTarget target, String serviceName, String socketBindingName) {
ServiceName socketBinding = ServiceName.parse("org.wildfly.network.socket-binding." + socketBindingName );
RegistrationAdvertiser advertiser = new RegistrationAdvertiser( serviceName, socketBindingName );
target.addService(ServiceName.of("swarm", "topology", "register", serviceName, socketBindingName), advertiser)
.addDependency(TopologyConnector.SERVICE_NAME, TopologyConnector.class, advertiser.getTopologyConnectorInjector())
.addDependency( socketBinding, SocketBinding.class, advertiser.getSocketBindingInjector() )
.setInitialMode(ServiceController.Mode.PASSIVE)
.install();
}
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:11,代码来源:RegistrationAdvertiserActivator.java
示例11: start
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
@Override
public void start(StartContext context) throws StartException {
for (String key : _socketBindings.keySet()) {
SocketBinding binding = _socketBindings.get(key).getValue();
SocketAddr addr = new SocketAddr(binding.getAddress().getHostAddress(), binding.getPort());
LOG.trace("Injecting socket binding '" + addr + "'");
_injectedValues.put(key, addr.toString());
}
}
示例12: getSocketBinding
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
/**
* Injection point for SocketBindings.
*
* @param name the name of the SocketBinding
* @return the SocketBinding
*/
public InjectedValue<SocketBinding> getSocketBinding(String name) {
InjectedValue<SocketBinding> binding = _socketBindings.get(name);
if (binding == null) {
binding = new InjectedValue<SocketBinding>();
_socketBindings.put(name, binding);
}
return binding;
}
示例13: getAddress
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
/**
* Return the address.
*
* @return An address string
*/
public String getAddress() {
String schema = "http";
String hostAddress = "127.0.0.1";
int port = 8080;
ListenerService listener = ServerUtil.getDefaultListener();
if (listener != null) {
if (listener instanceof HttpsListenerService) {
schema = "https";
} else if (listener instanceof HttpListenerService) {
schema = "http";
} else {
ExtensionLogger.ROOT_LOGGER.defaultListenerIsNotHttpListener(listener.getClass().getName());
schema = "http";
}
InjectedValue<SocketBinding> inject = listener.getBinding();
if (inject != null) {
SocketBinding binding = inject.getValue();
InetAddress address = binding.getAddress();
hostAddress = address.getHostAddress();
port = binding.getAbsolutePort();
}else {
Set<String> aliases = ServerUtil.getDefaultHostAliases();
if (aliases != null && !aliases.isEmpty()) {
hostAddress = aliases.iterator().next();
}
ExtensionLogger.ROOT_LOGGER.noSocketBindingDefinitionFound(hostAddress, Integer.toString(port));
}
} else {
ExtensionLogger.ROOT_LOGGER.noDefaultListenerDefined(schema, hostAddress, Integer.toString(port));
}
return schema + "://" + hostAddress + ":" + port + "/" + _contextName;
}
示例14: performRuntime
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource)
throws OperationFailedException {
boolean hasSocketBinding = resource.getModel().hasDefined(SOCKET_BINDING.getName());
TestService service = new TestService(hasSocketBinding);
ServiceBuilder<TestService> serviceBuilder = context.getServiceTarget().addService(createServiceName(context.getCurrentAddress()), service);
if (hasSocketBinding) {
final String socketName = SOCKET_BINDING.resolveModelAttribute(context, resource.getModel()).asString();
final ServiceName socketBindingName = context.getCapabilityServiceName(RootResourceDefinition.SOCKET_CAPABILITY_NAME, socketName, SocketBinding.class);
serviceBuilder.addDependency(socketBindingName, SocketBinding.class, service.socketBindingInjector);
}
serviceBuilder.install();
}
示例15: start
import org.jboss.as.network.SocketBinding; //导入依赖的package包/类
@Override
public void start(StartContext context) throws StartException {
if (hasSocketBinding) {
SocketBinding binding = socketBindingInjector.getValue();
try {
serverSocket = binding.createServerSocket();
} catch (IOException e) {
throw new StartException(e);
}
}
}