Package org.jboss.as.network

Examples of org.jboss.as.network.SocketBinding


        return channel;
    }

    private void init(TP transport) {
        TransportConfiguration transportConfig = this.configuration.getTransport();
        SocketBinding binding = transportConfig.getSocketBinding();
        if (binding != null) {
            SocketFactory factory = transport.getSocketFactory();
            if (!(factory instanceof ManagedSocketFactory)) {
                transport.setSocketFactory(new ManagedSocketFactory(factory, binding.getSocketBindings()));
            }
        }
        ThreadFactory threadFactory = transportConfig.getThreadFactory();
        if (threadFactory != null) {
            if (!(transport.getThreadFactory() instanceof ThreadFactoryAdapter)) {
View Full Code Here


        if (transport.isShared()) {
            properties.put(Global.SINGLETON_NAME, this.configuration.getName());
        }

        SocketBinding binding = transport.getSocketBinding();
        if (binding != null) {
            this.configureBindAddress(transport, config, binding);
            this.configureServerSocket(transport, config, "bind_port", binding);
            this.configureMulticastSocket(transport, config, "mcast_addr", "mcast_port", binding);
        }

        SocketBinding diagnosticsSocketBinding = transport.getDiagnosticsSocketBinding();
        boolean diagnostics = (diagnosticsSocketBinding != null);
        properties.put("enable_diagnostics", String.valueOf(diagnostics));
        if (diagnostics) {
            this.configureMulticastSocket(transport, config, "diagnostics_addr", "diagnostics_port", diagnosticsSocketBinding);
        }
View Full Code Here

        Assert.assertEquals(345, group.require(SOCKET_BINDING).require("test3").require(PORT).asInt());

        ServiceController<?> controller = services.getContainer().getService(SocketBindingUserService.NAME);
        Assert.assertNotNull(controller);
        SocketBindingUserService service = (SocketBindingUserService)controller.getValue();
        SocketBinding socketBinding = service.socketBindingValue.getValue();
        Assert.assertEquals(234, socketBinding.getPort());
        Assert.assertEquals("127.0.0.1", socketBinding.getAddress().getHostAddress());
    }
View Full Code Here

        config.setExcludedContexts("ROOT,invoker,jbossws,juddi,console");

        // Read node to set configuration.
        if (modelconf.hasDefined(CommonAttributes.ADVERTISE_SOCKET)) {
            // There should be a socket-binding....
            final SocketBinding binding = this.binding.getValue();
            if (binding != null) {
                config.setAdvertisePort(binding.getMulticastPort());
                config.setAdvertiseGroupAddress(binding.getMulticastSocketAddress().getHostName());
                config.setAdvertiseInterface(binding.getSocketAddress().getAddress().getHostAddress());
                if (!this.isMulticastEnabled(binding.getNetworkInterfaceBinding().getNetworkInterfaces())) {
                    ROOT_LOGGER.multicastInterfaceNotAvailable();
                }
                config.setAdvertise(true);
            }
        }
View Full Code Here

    @Override
    public synchronized void start(StartContext context) throws StartException {
        ROOT_LOGGER.debug("Starting remote JMX connector");
        setRmiServerProperty(serverPortBinding.getValue().getAddress().getHostAddress());
        try {
            SocketBinding registryBinding = registryPortBinding.getValue();
            RMIServerSocketFactory registrySocketFactory = new JMXServerSocketFactory(registryBinding);
            SocketBinding rmiServerBinding = serverPortBinding.getValue();
            RMIServerSocketFactory serverSocketFactory = new JMXServerSocketFactory(rmiServerBinding);

            registry = LocateRegistry.createRegistry(getRmiRegistryPort(), null, registrySocketFactory);
            HashMap<String, Object> env = new HashMap<String, Object>();
View Full Code Here

     *
     * @param context the start context
     * @throws StartException if the connector cannot be started
     */
    public synchronized void start(StartContext context) throws StartException {
        final SocketBinding binding = this.binding.getValue();
        final InetSocketAddress address = binding.getSocketAddress();
        final Executor executor = this.executor.getOptionalValue();
        try {
            // Create connector
            final Connector connector = new Connector(protocol);
            connector.setPort(address.getPort());
            connector.setScheme(scheme);
            if(enableLookups != null) connector.setEnableLookups(enableLookups);
            if(maxPostSize != null) connector.setMaxPostSize(maxPostSize);
            if(maxSavePostSize != null) connector.setMaxSavePostSize(maxSavePostSize);
            if(proxyName != null) connector.setProxyName(proxyName);
            if(proxyPort != null) connector.setProxyPort(proxyPort);
            if(redirectPort != null) connector.setRedirectPort(redirectPort);
            if(secure != null) connector.setSecure(secure);
            boolean nativeProtocolHandler = false;
            if (connector.getProtocolHandler() instanceof Http11AprProtocol
                    || connector.getProtocolHandler() instanceof AjpAprProtocol) {
                nativeProtocolHandler = true;
            }
            if (executor != null) {
                Method m = connector.getProtocolHandler().getClass().getMethod("setExecutor", Executor.class);
                m.invoke(connector.getProtocolHandler(), executor);
            }
            if (address != null && address.getAddress() != null)  {
                Method m = connector.getProtocolHandler().getClass().getMethod("setAddress", InetAddress.class);
                m.invoke(connector.getProtocolHandler(), address.getAddress());
            }
            if (maxConnections != null) {
                try {
                    Method m = connector.getProtocolHandler().getClass().getMethod("setPollerSize", Integer.TYPE);
                    m.invoke(connector.getProtocolHandler(), maxConnections);
                } catch (NoSuchMethodException e) {
                 // Not all connectors will have this
                }
                if (nativeProtocolHandler) {
                    try {
                        Method m = connector.getProtocolHandler().getClass().getMethod("setSendfileSize", Integer.TYPE);
                        m.invoke(connector.getProtocolHandler(), maxConnections);
                    } catch (NoSuchMethodException e) {
                     // Not all connectors will have this
                    }
                } else {
                    Method m = connector.getProtocolHandler().getClass().getMethod("setMaxThreads", Integer.TYPE);
                    m.invoke(connector.getProtocolHandler(), maxConnections);
                }
            }
            if (virtualServers != null) {
                HashSet<String> virtualServersList = new HashSet<String>();
                for (final ModelNode virtualServer : virtualServers.asList()) {
                    virtualServersList.add(virtualServer.asString());
                }
                connector.setAllowedHosts(virtualServersList);
            }
            if (ssl != null) {
                boolean nativeSSL = false;
                if (connector.getProtocolHandler() instanceof Http11AprProtocol) {
                    nativeSSL = true;
                } else if ((connector.getProtocolHandler() instanceof AjpProtocol) || (connector.getProtocolHandler() instanceof AjpAprProtocol)) {
                    throw new StartException(MESSAGES.noSSLWithNonHTTPConnectors());
                }
                // Enable SSL
                try {
                    Method m = connector.getProtocolHandler().getClass().getMethod("setSSLEnabled", Boolean.TYPE);
                    m.invoke(connector.getProtocolHandler(), true);
                } catch (NoSuchMethodException e) {
                    // No SSL support
                    throw new StartException(MESSAGES.failedSSLConfiguration(), e);
                }
                if (nativeSSL) {
                    // OpenSSL configuration
                    try {
                        if (ssl.hasDefined(Constants.PASSWORD)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setSSLPassword", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.PASSWORD).asString());
                        }
                        if (ssl.hasDefined(Constants.CERTIFICATE_KEY_FILE)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setSSLCertificateKeyFile", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.CERTIFICATE_KEY_FILE).asString());
                        }
                        if (ssl.hasDefined(Constants.CIPHER_SUITE)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setSSLCipherSuite", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.CIPHER_SUITE).asString());
                        }
                        if (ssl.hasDefined(Constants.PROTOCOL)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setSSLProtocol", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.PROTOCOL).asString());
                        }
                        if (ssl.hasDefined(Constants.VERIFY_CLIENT)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setSSLVerifyClient", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.VERIFY_CLIENT).asString());
                        }
                        if (ssl.hasDefined(Constants.VERIFY_DEPTH)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setSSLVerifyDepth", Integer.TYPE);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.VERIFY_DEPTH).asInt());
                        }
                        if (ssl.hasDefined(Constants.CERTIFICATE_FILE)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setSSLCertificateFile", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.CERTIFICATE_FILE).asString());
                        }
                        if (ssl.hasDefined(Constants.CA_CERTIFICATE_FILE)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setSSLCACertificateFile", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.CA_CERTIFICATE_FILE).asString());
                        }
                        if (ssl.hasDefined(Constants.CA_REVOCATION_URL)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setSSLCARevocationFile", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.CA_REVOCATION_URL).asString());
                        }
                   } catch (NoSuchMethodException e) {
                       throw new StartException(MESSAGES.failedSSLConfiguration(), e);
                    }
                } else {
                    // JSSE configuration
                    try {
                        if (ssl.hasDefined(Constants.KEY_ALIAS)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setKeyAlias", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.KEY_ALIAS).asString());
                        }
                        if (ssl.hasDefined(Constants.PASSWORD)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setKeypass", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.PASSWORD).asString());
                        }
                        if (ssl.hasDefined(Constants.CERTIFICATE_KEY_FILE)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setKeystore", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.CERTIFICATE_KEY_FILE).asString());
                        }
                        if (ssl.hasDefined(Constants.CIPHER_SUITE)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setCiphers", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.CIPHER_SUITE).asString());
                        }
                        if (ssl.hasDefined(Constants.PROTOCOL)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setProtocols", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.PROTOCOL).asString());
                        }
                        if (ssl.hasDefined(Constants.VERIFY_CLIENT)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setClientauth", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.VERIFY_CLIENT).asString());
                        }
                        if (ssl.hasDefined(Constants.SESSION_CACHE_SIZE)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setAttribute", String.class, Object.class);
                            m.invoke(connector.getProtocolHandler(), "sessionCacheSize", ssl.get(Constants.SESSION_CACHE_SIZE).asString());
                        }
                        if (ssl.hasDefined(Constants.SESSION_TIMEOUT)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setAttribute", String.class, Object.class);
                            m.invoke(connector.getProtocolHandler(), "sessionCacheTimeout", ssl.get(Constants.SESSION_TIMEOUT).asString());
                        }
                        /* possible attributes that apply to ssl socket factory
                            keystoreType -> PKCS12
                            keystore -> path/to/keystore.p12
                            keypass -> key password
                            truststorePass -> trustPassword
                            truststoreFile -> path/to/truststore.jks
                            truststoreType -> JKS
                         */
                        if (ssl.hasDefined(Constants.CA_CERTIFICATE_FILE)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setAttribute", String.class, Object.class);
                            m.invoke(connector.getProtocolHandler(), "truststoreFile", ssl.get(Constants.CA_CERTIFICATE_FILE).asString());

                        }
                        if (ssl.hasDefined(Constants.CA_CERTIFICATE_PASSWORD)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setAttribute", String.class, Object.class);
                            m.invoke(connector.getProtocolHandler(), "truststorePass",ssl.get(Constants.CA_CERTIFICATE_PASSWORD).asString());
                        }
                        if (ssl.hasDefined(Constants.TRUSTSTORE_TYPE)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setAttribute", String.class, Object.class);
                            m.invoke(connector.getProtocolHandler(), "truststoreType",ssl.get(Constants.TRUSTSTORE_TYPE).asString());
                        }
                        if (ssl.hasDefined(Constants.KEYSTORE_TYPE)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setKeytype", String.class);
                            m.invoke(connector.getProtocolHandler(), ssl.get(Constants.KEYSTORE_TYPE).asString());
                        }
                        if (ssl.hasDefined(Constants.CA_REVOCATION_URL)) {
                            Method m = connector.getProtocolHandler().getClass().getMethod("setAttribute", String.class, Object.class);
                            m.invoke(connector.getProtocolHandler(), "crlFile", ssl.get(Constants.CA_REVOCATION_URL).asString());
                        }

                    } catch (NoSuchMethodException e) {
                        throw new StartException(MESSAGES.failedSSLConfiguration(), e);
                    }
                }
            }
            getWebServer().addConnector(connector);
            connector.init();
            connector.start();
            this.connector = connector;
        } catch (Exception e) {
            throw new StartException(MESSAGES.connectorStartError(), e);
        }
        // Register the binding after the connector is started
        binding.getSocketBindings().getNamedRegistry().registerBinding(new ConnectorBinding(binding));
    }
View Full Code Here



    /** {@inheritDoc} */
    public synchronized void stop(StopContext context) {
        final SocketBinding binding = this.binding.getValue();
        binding.getSocketBindings().getNamedRegistry().unregisterBinding(binding.getName());
        final Connector connector = this.connector;
        try {
            connector.pause();
        } catch (Exception e) {
        }
View Full Code Here

                    final InetAddress inet = localAddress != null ? InetAddress.getByName(localAddress) : InetAddressUtil.getLocalHost();
                    final NetworkInterface intf = NetworkInterface.getByInetAddress(inet);
                    final NetworkInterfaceBinding b = new NetworkInterfaceBinding(Collections.singleton(intf), inet);
                    final InetAddress group = InetAddress.getByName(groupAddress);

                    final SocketBinding socketBinding = new SocketBinding(name, localBindPort, false, group, groupPort, b, null, null);

                    final GroupBindingService bindingService = new GroupBindingService();
                    target.addService(GroupBindingService.getBroadcastBaseServiceName(hqServiceName).append(name), bindingService)
                            .addInjectionValue(bindingService.getBindingRef(), new ImmediateValue<SocketBinding>(socketBinding))
                            .install();
View Full Code Here

                    final InetAddress inet = localAddress != null ? InetAddress.getByName(localAddress) : InetAddressUtil.getLocalHost();
                    final NetworkInterface intf = NetworkInterface.getByInetAddress(inet);
                    final NetworkInterfaceBinding b = new NetworkInterfaceBinding(Collections.singleton(intf), inet);
                    final InetAddress group = InetAddress.getByName(groupAddress);

                    final SocketBinding socketBinding = new SocketBinding(name, -1, false, group, groupPort, b, null, null);

                    final GroupBindingService bindingService = new GroupBindingService();
                    target.addService(GroupBindingService.getDiscoveryBaseServiceName(hqServiceName).append(name), bindingService)
                            .addInjectionValue(bindingService.getBindingRef(), new ImmediateValue<SocketBinding>(socketBinding))
                            .install();
View Full Code Here

    public synchronized void start(StartContext context) throws StartException {

        // Recovery env bean
        final RecoveryEnvironmentBean recoveryEnvironmentBean = recoveryPropertyManager.getRecoveryEnvironmentBean();
        final SocketBinding recoveryBinding = recoveryBindingInjector.getValue();
        recoveryEnvironmentBean.setRecoveryInetAddress(recoveryBinding.getSocketAddress().getAddress());
        recoveryEnvironmentBean.setRecoveryPort(recoveryBinding.getSocketAddress().getPort());
        final SocketBinding statusBinding = statusBindingInjector.getValue();
        recoveryEnvironmentBean.setTransactionStatusManagerInetAddress(statusBinding.getSocketAddress().getAddress());
        recoveryEnvironmentBean.setTransactionStatusManagerPort(statusBinding.getSocketAddress().getPort());
        recoveryEnvironmentBean.setRecoveryListener(recoveryListener);

        final List<String> recoveryExtensions = new ArrayList<String>();
        recoveryExtensions.add(AtomicActionRecoveryModule.class.getName());
        recoveryExtensions.add(TORecoveryModule.class.getName());
View Full Code Here

TOP

Related Classes of org.jboss.as.network.SocketBinding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.