Package org.apache.qpid.server.model

Examples of org.apache.qpid.server.model.Port


        _attributes = new HashMap<String, Object>();
        _attributes.put(Port.PROTOCOLS, nonAmqpStringSet);
        _attributes.put(Port.AUTHENTICATION_PROVIDER, _authProviderName);
        _attributes.put(Port.PORT, _portNumber);

        Port port = _portFactory.createPort(_portId, _broker, _attributes);

        assertNotNull(port);
        assertFalse("Port should be a PortAdapter, not its AMQP-specific subclass", port instanceof AmqpPortAdapter);
        assertEquals(_portId, port.getId());
        assertEquals(_portNumber, port.getPort());
        assertEquals(Collections.singleton(PortFactory.DEFAULT_TRANSPORT), port.getTransports());
        assertEquals(nonAmqpProtocolSet, port.getProtocols());
        assertNull("Unexpected send buffer size", port.getAttribute(Port.SEND_BUFFER_SIZE));
        assertNull("Unexpected receive buffer size", port.getAttribute(Port.RECEIVE_BUFFER_SIZE));
        assertNull("Unexpected need client auth", port.getAttribute(Port.NEED_CLIENT_AUTH));
        assertNull("Unexpected want client auth", port.getAttribute(Port.WANT_CLIENT_AUTH));
        assertNull("Unexpected tcp no delay", port.getAttribute(Port.TCP_NO_DELAY));
        assertNull("Unexpected binding", port.getAttribute(Port.BINDING_ADDRESS));
    }
View Full Code Here


        attributes.put(Port.PORT, 1);
        attributes.put(Port.NAME, getTestName());
        attributes.put(Port.TRANSPORTS, Collections.singleton(Transport.TCP));
        attributes.put(Port.PROTOCOLS, Collections.singleton(Protocol.RMI));

        Port rmiPort = mock(Port.class);
        when(rmiPort.getProtocols()).thenReturn(Collections.singleton(Protocol.RMI));
        when(_broker.getPorts()).thenReturn(Collections.singletonList(rmiPort));

        try
        {
            _portFactory.createPort(_portId, _broker, attributes);
View Full Code Here

    }

    private void start() throws JMException, IOException
    {
        Broker broker = getBroker();
        Port connectorPort = null;
        Port registryPort = null;
        Collection<Port> ports = broker.getPorts();
        for (Port port : ports)
        {
            if (State.QUIESCED.equals(port.getActualState()))
            {
View Full Code Here

    }

    public void testCreateBrokerWithPorts()
    {
        ConfigurationEntry portEntry = mock(ConfigurationEntry.class);
        Port port = mock(Port.class);
        _brokerEntryChildren.put(Port.class.getSimpleName(), Arrays.asList(portEntry));

        RecovererProvider recovererProvider = createRecoveryProvider(new ConfigurationEntry[]{portEntry, _authenticationProviderEntry1},
                                                                     new ConfiguredObject[]{port, _authenticationProvider1});
View Full Code Here

        ConfigurationEntry authenticationProviderEntry2 = mock(ConfigurationEntry.class);
        _brokerEntryChildren.put(AuthenticationProvider.class.getSimpleName(), Arrays.asList(_authenticationProviderEntry1, authenticationProviderEntry2));

        //Add a couple ports
        ConfigurationEntry portEntry1 = mock(ConfigurationEntry.class);
        Port port1 = mock(Port.class);
        when(port1.getId()).thenReturn(UUIDGenerator.generateRandomUUID());
        when(port1.getName()).thenReturn("port1");
        when(port1.getPort()).thenReturn(5671);
        when(port1.getAttribute(Port.AUTHENTICATION_PROVIDER)).thenReturn("authenticationProvider1");
        ConfigurationEntry portEntry2 = mock(ConfigurationEntry.class);
        Port port2 = mock(Port.class);
        when(port2.getId()).thenReturn(UUIDGenerator.generateRandomUUID());
        when(port2.getName()).thenReturn("port2");
        when(port2.getPort()).thenReturn(5672);
        when(port2.getAttribute(Port.AUTHENTICATION_PROVIDER)).thenReturn("authenticationProvider2");
        _brokerEntryChildren.put(Port.class.getSimpleName(), Arrays.asList(portEntry1, portEntry2));

        RecovererProvider recovererProvider = createRecoveryProvider(
                new ConfigurationEntry[]{portEntry1, portEntry2, authenticationProviderEntry2, _authenticationProviderEntry1},
                new ConfiguredObject[]{port1, port2, authenticationProvider2, _authenticationProvider1});
View Full Code Here

        _defaultProtocols = Collections.unmodifiableCollection(defaultProtocols);
    }

    public Port createPort(UUID id, Broker broker, Map<String, Object> attributes)
    {
        final Port port;
        Map<String, Object> defaults = new HashMap<String, Object>();
        defaults.put(Port.TRANSPORTS, Collections.singleton(DEFAULT_TRANSPORT));
        Object portValue = attributes.get(Port.PORT);
        if (portValue == null)
        {
            throw new IllegalConfigurationException("Port attribute is not specified for port: " + attributes);
        }
        Set<Protocol> protocols = MapValueConverter.getEnumSetAttribute(Port.PROTOCOLS, attributes, Protocol.class);
        if (isAmqpProtocol(protocols, attributes))
        {
            Object binding = attributes.get(Port.BINDING_ADDRESS);
            if (binding == null)
            {
                binding = DEFAULT_AMQP_BINDING;
                defaults.put(Port.BINDING_ADDRESS, DEFAULT_AMQP_BINDING);
            }
            defaults.put(Port.NAME, binding + ":" + portValue);
            defaults.put(Port.PROTOCOLS, _defaultProtocols);
            defaults.put(Port.TCP_NO_DELAY, DEFAULT_AMQP_TCP_NO_DELAY);
            defaults.put(Port.WANT_CLIENT_AUTH, DEFAULT_AMQP_WANT_CLIENT_AUTH);
            defaults.put(Port.NEED_CLIENT_AUTH, DEFAULT_AMQP_NEED_CLIENT_AUTH);
            defaults.put(Port.RECEIVE_BUFFER_SIZE, DEFAULT_AMQP_RECEIVE_BUFFER_SIZE);
            defaults.put(Port.SEND_BUFFER_SIZE, DEFAULT_AMQP_SEND_BUFFER_SIZE);
            port = new AmqpPortAdapter(id, broker, attributes, defaults, broker.getTaskExecutor());

            boolean useClientAuth = (Boolean) port.getAttribute(Port.NEED_CLIENT_AUTH) || (Boolean) port.getAttribute(Port.WANT_CLIENT_AUTH);
            if(useClientAuth && port.getTrustStores().isEmpty())
            {
                throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but has no trust stores configured.");
            }

            if(useClientAuth && !(port.getTransports().contains(Transport.SSL) || port.getTransports().contains(Transport.WSS)))
            {
                throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but doesn't use SSL transport.");
            }
        }
        else
        {
            if (protocols.size() > 1)
            {
                throw new IllegalConfigurationException("Only one protocol can be used on non AMQP port");
            }
            Protocol protocol = protocols.iterator().next();

            if(!broker.isManagementMode() && protocol.getProtocolType() != ProtocolType.HTTP)
            {
                //ManagementMode needs this relaxed to allow its overriding management ports to be inserted.

                //Enforce only a single port of each management protocol, as the plugins will only use one.
                Collection<Port> existingPorts = broker.getPorts();
                for (Port existingPort : existingPorts)
                {
                    Collection<Protocol> portProtocols = existingPort.getProtocols();
                    if (portProtocols != null && portProtocols.contains(protocol))
                    {
                        throw new IllegalConfigurationException("Port for protocol " + protocol + " already exists. Only one management port per protocol can be created.");
                    }
                }
            }

            defaults.put(Port.NAME, portValue + "-" + protocol.name());
            port = new NonAmqpPortAdapter(id, broker, attributes, defaults, broker.getTaskExecutor());

            boolean rmiPort = port.getProtocols().contains(Protocol.RMI);
            if (rmiPort && port.getTransports().contains(Transport.SSL))
            {
                throw new IllegalConfigurationException("Can't create RMI registry port which requires SSL");
            }
        }

        if(port.getTransports().contains(Transport.SSL))
        {
            if(port.getKeyStore() == null)
            {
                throw new IllegalConfigurationException("Can't create port which requires SSL but has no key store configured.");
            }
        }
View Full Code Here

        attributes.put(Port.PORT, 1);
        attributes.put(Port.NAME, getName());
        attributes.put(Port.TRANSPORTS, Collections.singleton(Transport.TCP));
        attributes.put(Port.PROTOCOLS, Collections.singleton(Protocol.RMI));

        Port rmiPort = mock(Port.class);
        when(rmiPort.getProtocols()).thenReturn(Collections.singleton(Protocol.RMI));
        when(_broker.getPorts()).thenReturn(Collections.singletonList(rmiPort));

        try
        {
            Port<?> port = _factory.create(Port.class, attributes, _broker);
View Full Code Here

        attributes.put(Port.PORT, 1);
        attributes.put(Port.NAME, getName());
        attributes.put(Port.TRANSPORTS, Collections.singleton(Transport.TCP));
        attributes.put(Port.PROTOCOLS, Collections.singleton(Protocol.RMI));

        Port rmiPort = mock(Port.class);
        when(rmiPort.getProtocols()).thenReturn(Collections.singleton(Protocol.RMI));
        when(_broker.getPorts()).thenReturn(Collections.singletonList(rmiPort));

        try
        {
            _port = _factory.create(Port.class, attributes, _broker);
View Full Code Here

TOP

Related Classes of org.apache.qpid.server.model.Port

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.