当前位置: 首页>>代码示例>>Java>>正文


Java URL.getPort方法代码示例

本文整理汇总了Java中com.alibaba.dubbo.common.URL.getPort方法的典型用法代码示例。如果您正苦于以下问题:Java URL.getPort方法的具体用法?Java URL.getPort怎么用?Java URL.getPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.alibaba.dubbo.common.URL的用法示例。


在下文中一共展示了URL.getPort方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: subscribe

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public void subscribe(URL url, NotifyListener listener) {
    if (getUrl().getPort() == 0) {
        URL registryUrl = RpcContext.getContext().getUrl();
        if (registryUrl != null && registryUrl.getPort() > 0
        		&& RegistryService.class.getName().equals(registryUrl.getPath())) {
            super.setUrl(registryUrl);
            super.register(registryUrl);
        }
    }
    String client = RpcContext.getContext().getRemoteAddressString();
    ConcurrentMap<URL, Set<NotifyListener>> clientListeners = remoteSubscribed.get(client);
    if (clientListeners == null) {
        remoteSubscribed.putIfAbsent(client, new ConcurrentHashMap<URL, Set<NotifyListener>>());
        clientListeners = remoteSubscribed.get(client);
    }
    Set<NotifyListener> listeners = clientListeners.get(url);
    if (listeners == null) {
        clientListeners.putIfAbsent(url, new ConcurrentHashSet<NotifyListener>());
        listeners = clientListeners.get(url);
    }
    listeners.add(listener);
    super.subscribe(url, listener);
    subscribed(url, listener);
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:25,代码来源:SimpleRegistryService.java

示例2: isClientSide

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
protected boolean isClientSide(Channel channel) {
    String side = (String) channel.getAttribute(Constants.SIDE_KEY);
    if ("client".equals(side)) {
        return true;
    } else if ("server".equals(side)) {
        return false;
    } else {
        InetSocketAddress address = channel.getRemoteAddress();
        URL url = channel.getUrl();
        boolean client = url.getPort() == address.getPort()
            && NetUtils.filterLocalHost(url.getIp()).equals(
            NetUtils.filterLocalHost(address.getAddress()
                                         .getHostAddress()));
        channel.setAttribute(Constants.SIDE_KEY, client ? "client"
            : "server");
        return client;
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:19,代码来源:DeprecatedTelnetCodec.java

示例3: isProviderSide

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
/**
 * is provider side.
 * 
 * @return provider side.
 */
public boolean isProviderSide() {
    URL url = getUrl();
    if (url == null) {
        return false;
    }
    InetSocketAddress address = getRemoteAddress();
    if (address == null) {
        return false;
    }
    String host;
    if (address.getAddress() == null) {
        host = address.getHostName();
    } else {
        host = address.getAddress().getHostAddress();
    }
    return url.getPort() != address.getPort() || 
            ! NetUtils.filterLocalHost(url.getIp()).equals(NetUtils.filterLocalHost(host));
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:24,代码来源:RpcContext.java

示例4: doExport

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
protected <T> Runnable doExport(T impl, Class<T> type, URL url) throws RpcException {
	String addr = url.getIp() + ":" + url.getPort();
    HttpServer httpServer = serverMap.get(addr);
    if (httpServer == null) {
        httpServer = httpBinder.bind(url, new WebServiceHandler());
        serverMap.put(addr, httpServer);
    }
    final ServerFactoryBean serverFactoryBean = new ServerFactoryBean();
    serverFactoryBean.setAddress(url.getAbsolutePath());
	serverFactoryBean.setServiceClass(type);
	serverFactoryBean.setServiceBean(impl);
	serverFactoryBean.setBus(bus);
    serverFactoryBean.setDestinationFactory(transportFactory);
	serverFactoryBean.create();
    return new Runnable() {
        public void run() {
        	serverFactoryBean.destroy();
        }
    };
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:21,代码来源:WebServiceProtocol.java

示例5: isConsumerSide

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
/**
 * is consumer side.
 * 
 * @return consumer side.
 */
public boolean isConsumerSide() {
    URL url = getUrl();
    if (url == null) {
        return false;
    }
    InetSocketAddress address = getRemoteAddress();
    if (address == null) {
        return false;
    }
    String host;
    if (address.getAddress() == null) {
        host = address.getHostName();
    } else {
        host = address.getAddress().getHostAddress();
    }
    return url.getPort() == address.getPort() && 
            NetUtils.filterLocalHost(url.getIp()).equals(NetUtils.filterLocalHost(host));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:24,代码来源:RpcContext.java

示例6: configure

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public URL configure(URL url) {
    if (configuratorUrl == null || configuratorUrl.getHost() == null
            || url == null || url.getHost() == null) {
        return url;
    }
    if (configuratorUrl.getPort() != 0) {// override输入提供端地址,意图是控制提供者机器。可能在提供端生效 也可能在消费端生效
        if (url.getPort() == configuratorUrl.getPort()) {
            return configureIfMatch(url.getHost(), url);
        }
    } else {// 没有端口,override输入消费端地址 或者 0.0.0.0
        // 1.如果是消费端地址,则意图是控制消费者机器,必定在消费端生效,提供端忽略;
        // 2.如果是0.0.0.0可能是控制提供端,也可能是控制提供端
        if (url.getParameter(Constants.SIDE_KEY, Constants.PROVIDER).equals(Constants.CONSUMER)) {
            return configureIfMatch(NetUtils.getLocalHost(), url);// NetUtils.getLocalHost是消费端注册到zk的消费者地址
        } else if (url.getParameter(Constants.SIDE_KEY, Constants.CONSUMER).equals(Constants.PROVIDER)) {
            return configureIfMatch(Constants.ANYHOST_VALUE, url);//控制所有提供端,地址必定是0.0.0.0,否则就要配端口从而执行上面的if分支了
        }
    }
    return url;
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:21,代码来源:AbstractConfigurator.java

示例7: isClientSide

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
protected boolean isClientSide(Channel channel) {
	String side = (String) channel.getAttribute(Constants.SIDE_KEY);
	if ("client".equals(side)) {
		return true;
	} else if ("server".equals(side)) {
		return false;
	} else {
		InetSocketAddress address = channel.getRemoteAddress();
		URL url = channel.getUrl();
		boolean client = url.getPort() == address.getPort()
				&& NetUtils.filterLocalHost(url.getIp()).equals(
						NetUtils.filterLocalHost(address.getAddress()
								.getHostAddress()));
		channel.setAttribute(Constants.SIDE_KEY, client ? "client"
				: "server");
		return client;
	}
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:19,代码来源:AbstractCodec.java

示例8: doExport

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
protected <T> Runnable doExport(final T impl, Class<T> type, URL url) throws RpcException {
    String addr = url.getIp() + ":" + url.getPort();
    HttpServer server = serverMap.get(addr);
    if (server == null) {
        server = httpBinder.bind(url, new InternalHandler());
        serverMap.put(addr, server);
    }
    final HttpInvokerServiceExporter httpServiceExporter = new HttpInvokerServiceExporter();
    httpServiceExporter.setServiceInterface(type);
    httpServiceExporter.setService(impl);
    try {
        httpServiceExporter.afterPropertiesSet();
    } catch (Exception e) {
        throw new RpcException(e.getMessage(), e);
    }
    final String path = url.getAbsolutePath();
    skeletonMap.put(path, httpServiceExporter);
    return new Runnable() {
        public void run() {
            skeletonMap.remove(path);
        }
    };
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:24,代码来源:HttpProtocol.java

示例9: getExchangeChannel

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Override
public ExchangeChannel getExchangeChannel(InetSocketAddress remoteAddress) {
    String host = remoteAddress.getAddress() != null ? remoteAddress.getAddress().getHostAddress() : remoteAddress.getHostName();
    int port = remoteAddress.getPort();
    ExchangeChannel channel = super.getExchangeChannel(remoteAddress);
    if (channel == null) {
        for (Map.Entry<URL, ExchangeClient> entry : clients.entrySet()) {
            URL url = entry.getKey();
            if (url.getIp().equals(host) && url.getPort() == port) {
                return entry.getValue();
            }
        }
    }
    return channel;
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:16,代码来源:ExchangeServerPeer.java

示例10: getChannel

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Override
public Channel getChannel(InetSocketAddress remoteAddress) {
    String host = remoteAddress.getAddress() != null ? remoteAddress.getAddress().getHostAddress() : remoteAddress.getHostName();
    int port = remoteAddress.getPort();
    Channel channel = super.getChannel(remoteAddress);
    if (channel == null) {
        for (Map.Entry<URL, Client> entry : clients.entrySet()) {
            URL url = entry.getKey();
            if (url.getIp().equals(host) && url.getPort() == port) {
                return entry.getValue();
            }
        }
    }
    return channel;
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:16,代码来源:ServerPeer.java

示例11: isClientSide

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
private boolean isClientSide(Channel channel) {
    InetSocketAddress address = channel.getRemoteAddress();
    URL url = channel.getUrl();
    return url.getPort() == address.getPort() && 
                NetUtils.filterLocalHost(channel.getUrl().getIp())
                .equals(NetUtils.filterLocalHost(address.getAddress().getHostAddress()));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:8,代码来源:DubboProtocol.java

示例12: configure

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public URL configure(URL url) {
    if (configuratorUrl == null || configuratorUrl.getHost() == null
            || url == null || url.getHost() == null) {
        return url;
    }
    if (Constants.ANYHOST_VALUE.equals(configuratorUrl.getHost()) 
            || url.getHost().equals(configuratorUrl.getHost())) {
        String configApplication = configuratorUrl.getParameter(Constants.APPLICATION_KEY, configuratorUrl.getUsername());
        String currentApplication = url.getParameter(Constants.APPLICATION_KEY, url.getUsername());
        if (configApplication == null || Constants.ANY_VALUE.equals(configApplication) 
                || configApplication.equals(currentApplication)) {
            if (configuratorUrl.getPort() == 0 || url.getPort() == configuratorUrl.getPort()) {
                Set<String> condtionKeys = new HashSet<String>();
                condtionKeys.add(Constants.CATEGORY_KEY);
                condtionKeys.add(Constants.CHECK_KEY);
                condtionKeys.add(Constants.DYNAMIC_KEY);
                condtionKeys.add(Constants.ENABLED_KEY);
                for (Map.Entry<String, String> entry : configuratorUrl.getParameters().entrySet()) {
                    String key = entry.getKey();
                    String value = entry.getValue();
                    if (key.startsWith("~") || Constants.APPLICATION_KEY.equals(key) 
                            || Constants.SIDE_KEY.equals(key)) {
                        condtionKeys.add(key);
                        if (value != null && ! Constants.ANY_VALUE.equals(value)
                                && ! value.equals(url.getParameter(key.startsWith("~") ? key.substring(1) : key))) {
                            return url;
                        }
                    }
                }
                return doConfigure(url, configuratorUrl.removeParameters(condtionKeys));
            }
        }
    }
    return url;
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:36,代码来源:AbstractConfigurator.java


注:本文中的com.alibaba.dubbo.common.URL.getPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。