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


Java DubboExporter类代码示例

本文整理汇总了Java中com.alibaba.dubbo.rpc.protocol.dubbo.DubboExporter的典型用法代码示例。如果您正苦于以下问题:Java DubboExporter类的具体用法?Java DubboExporter怎么用?Java DubboExporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DubboExporter类属于com.alibaba.dubbo.rpc.protocol.dubbo包,在下文中一共展示了DubboExporter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: export

import com.alibaba.dubbo.rpc.protocol.dubbo.DubboExporter; //导入依赖的package包/类
public <T> Exporter<T> export( Invoker<T> invoker ) throws RpcException {

        // 只能使用 thrift codec
        URL url = invoker.getUrl().addParameter(Constants.CODEC_KEY, ThriftCodec.NAME);
        // find server.
        String key = url.getAddress();
        //client 也可以暴露一个只有server可以调用的服务。
        boolean isServer = url.getParameter(Constants.IS_SERVER_KEY,true);
        if (isServer && ! serverMap.containsKey(key)) {
            serverMap.put(key, getServer(url));
        }
        // export service.
        key = serviceKey(url);
        DubboExporter<T> exporter = new DubboExporter<T>(invoker, key, exporterMap);
        exporterMap.put(key, exporter);

        return exporter;
    }
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:ThriftProtocol.java

示例2: export

import com.alibaba.dubbo.rpc.protocol.dubbo.DubboExporter; //导入依赖的package包/类
public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {

        // 只能使用 thrift codec
        URL url = invoker.getUrl().addParameter(Constants.CODEC_KEY, ThriftCodec.NAME);
        // find server.
        String key = url.getAddress();
        //client 也可以暴露一个只有server可以调用的服务。
        boolean isServer = url.getParameter(Constants.IS_SERVER_KEY, true);
        if (isServer && !serverMap.containsKey(key)) {
            serverMap.put(key, getServer(url));
        }
        // export service.
        key = serviceKey(url);
        DubboExporter<T> exporter = new DubboExporter<T>(invoker, key, exporterMap);
        exporterMap.put(key, exporter);

        return exporter;
    }
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:19,代码来源:ThriftProtocol.java

示例3: reply

import com.alibaba.dubbo.rpc.protocol.dubbo.DubboExporter; //导入依赖的package包/类
@Override
public Object reply( ExchangeChannel channel, Object msg ) throws RemotingException {

    if ( msg instanceof Invocation ) {
        Invocation inv = ( Invocation ) msg;
        String serviceName = inv.getAttachments().get(Constants.INTERFACE_KEY);
        String serviceKey = serviceKey( channel.getLocalAddress().getPort(),
                                        serviceName, null, null );
        DubboExporter<?> exporter = (DubboExporter<?>) exporterMap.get( serviceKey );
        if (exporter == null) {
            throw new RemotingException(channel,
                                        "Not found exported service: "
                                                + serviceKey
                                                + " in "
                                                + exporterMap.keySet()
                                                + ", may be version or group mismatch "
                                                + ", channel: consumer: "
                                                + channel.getRemoteAddress()
                                                + " --> provider: "
                                                + channel.getLocalAddress()
                                                + ", message:"+ msg);
        }

        RpcContext.getContext().setRemoteAddress(channel.getRemoteAddress());
        return exporter.getInvoker().invoke( inv );

    }

    throw new RemotingException(channel,
                                "Unsupported request: "
                                        + (msg.getClass().getName() + ": " + msg)
                                        + ", channel: consumer: "
                                        + channel.getRemoteAddress()
                                        + " --> provider: "
                                        + channel.getLocalAddress());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:37,代码来源:ThriftProtocol.java

示例4: getInvoker

import com.alibaba.dubbo.rpc.protocol.dubbo.DubboExporter; //导入依赖的package包/类
public Invoker<?> getInvoker(Channel channel, Invocation inv) throws RemotingException {
	boolean isCallBackServiceInvoke = false;
	boolean isStubServiceInvoke = false;
	int port = channel.getLocalAddress().getPort();
	String path = inv.getAttachments().get(Constants.PATH_KEY);
	// 如果是客户端的回调服务.
	isStubServiceInvoke = Boolean.TRUE.toString().equals(inv.getAttachments().get(Constants.STUB_EVENT_KEY));
	if (isStubServiceInvoke) {
		port = channel.getRemoteAddress().getPort();
	}
	// callback
	isCallBackServiceInvoke = isClientSide(channel) && !isStubServiceInvoke;
	if (isCallBackServiceInvoke) {
		path = inv.getAttachments().get(Constants.PATH_KEY) + "."
				+ inv.getAttachments().get(Constants.CALLBACK_SERVICE_KEY);
		inv.getAttachments().put(IS_CALLBACK_SERVICE_INVOKE, Boolean.TRUE.toString());
	}
	String serviceKey = serviceKey(port, path, inv.getAttachments().get(Constants.VERSION_KEY),
			inv.getAttachments().get(Constants.GROUP_KEY));

	DubboExporter<?> exporter = (DubboExporter<?>) exporterMap.get(serviceKey);

	if (exporter == null)
		throw new RemotingException(channel, "Not found exported service: " + serviceKey + " in "
				+ exporterMap.keySet() + ", may be version or group mismatch " + ", channel: consumer: "
				+ channel.getRemoteAddress() + " --> provider: " + channel.getLocalAddress() + ", message:" + inv);

	return exporter.getInvoker();
}
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:30,代码来源:DubboProtocol.java

示例5: export

import com.alibaba.dubbo.rpc.protocol.dubbo.DubboExporter; //导入依赖的package包/类
public <T> Exporter<T> export(Invoker<T> invoker) throws JahhanException {
	URL url = invoker.getUrl();

	// export service.
	String key = serviceKey(url);
	DubboExporter<T> exporter = new DubboExporter<T>(invoker, key, exporterMap);
	exporterMap.put(key, exporter);

	// export an stub service for dispaching event
	Boolean isStubSupportEvent = url.getParameter(Constants.STUB_EVENT_KEY, Constants.DEFAULT_STUB_EVENT);
	Boolean isCallbackservice = url.getParameter(Constants.IS_CALLBACK_SERVICE, false);
	if (isStubSupportEvent && !isCallbackservice) {
		String stubServiceMethods = url.getParameter(Constants.STUB_EVENT_METHODS_KEY);
		if (stubServiceMethods == null || stubServiceMethods.length() == 0) {
			if (log.isWarnEnabled()) {
				log.warn("", new IllegalStateException("consumer [" + url.getParameter(Constants.INTERFACE_KEY)
						+ "], has set stubproxy support event ,but no stub methods founded."));
			}
		} else {
			stubServiceMethodsMap.put(url.getServiceKey(), stubServiceMethods);
		}
	}

	openServer(url);

	// modified by lishen
	optimizeSerialization(url);

	return exporter;
}
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:31,代码来源:DubboProtocol.java

示例6: reply

import com.alibaba.dubbo.rpc.protocol.dubbo.DubboExporter; //导入依赖的package包/类
@Override
public Object reply(ExchangeChannel channel, Object msg) throws RemotingException {

    if (msg instanceof Invocation) {
        Invocation inv = (Invocation) msg;
        String serviceName = inv.getAttachments().get(Constants.INTERFACE_KEY);
        String serviceKey = serviceKey(channel.getLocalAddress().getPort(),
                serviceName, null, null);
        DubboExporter<?> exporter = (DubboExporter<?>) exporterMap.get(serviceKey);
        if (exporter == null) {
            throw new RemotingException(channel,
                    "Not found exported service: "
                            + serviceKey
                            + " in "
                            + exporterMap.keySet()
                            + ", may be version or group mismatch "
                            + ", channel: consumer: "
                            + channel.getRemoteAddress()
                            + " --> provider: "
                            + channel.getLocalAddress()
                            + ", message:" + msg);
        }

        RpcContext.getContext().setRemoteAddress(channel.getRemoteAddress());
        return exporter.getInvoker().invoke(inv);

    }

    throw new RemotingException(channel,
            "Unsupported request: "
                    + (msg.getClass().getName() + ": " + msg)
                    + ", channel: consumer: "
                    + channel.getRemoteAddress()
                    + " --> provider: "
                    + channel.getLocalAddress());
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:37,代码来源:ThriftProtocol.java


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