use of com.weibo.api.motan.transport.Client in project motan by weibocom.
the class HeartbeatClientEndpointManager method addEndpoint.
@Override
public void addEndpoint(Endpoint endpoint) {
if (!(endpoint instanceof Client)) {
throw new MotanFrameworkException("HeartbeatClientEndpointManager addEndpoint Error: class not support " + endpoint.getClass());
}
Client client = (Client) endpoint;
URL url = endpoint.getUrl();
String heartbeatFactoryName = url.getParameter(URLParamType.heartbeatFactory.getName(), URLParamType.heartbeatFactory.getValue());
HeartbeatFactory heartbeatFactory = ExtensionLoader.getExtensionLoader(HeartbeatFactory.class).getExtension(heartbeatFactoryName);
if (heartbeatFactory == null) {
throw new MotanFrameworkException("HeartbeatFactory not exist: " + heartbeatFactoryName);
}
endpoints.put(client, heartbeatFactory);
}
use of com.weibo.api.motan.transport.Client in project motan by weibocom.
the class BaseTest method before.
@Before
public void before() {
mockery = new JUnit4Mockery() {
{
setImposteriser(ClassImposteriser.INSTANCE);
}
};
final Server mockServer = mockery.mock(Server.class);
final Client mockClient = mockery.mock(Client.class);
mockery.checking(new Expectations() {
{
allowing(mockClient).open();
will(returnValue(true));
allowing(mockClient).close();
will(returnValue(null));
allowing(mockClient).isAvailable();
will(returnValue(true));
allowing(mockServer).open();
will(returnValue(true));
allowing(mockServer).close();
will(returnValue(null));
allowing(mockServer).isAvailable();
will(returnValue(true));
}
});
ExtensionLoader loader = ExtensionLoader.getExtensionLoader(EndpointFactory.class);
endpointFactory = (MockEndpointFactory) loader.getExtension("mockEndpoint");
if (endpointFactory == null) {
loader.addExtensionClass(MockEndpointFactory.class);
endpointFactory = (MockEndpointFactory) loader.getExtension("mockEndpoint");
}
loader = ExtensionLoader.getExtensionLoader(RegistryFactory.class);
MockRegistryFactory registryFactory = (MockRegistryFactory) loader.getExtension("mockRegistry");
if (registryFactory == null) {
loader.addExtensionClass(MockRegistryFactory.class);
}
endpointFactory.setClient(mockClient);
endpointFactory.setServer(mockServer);
cp = new ClassPathXmlApplicationContext("classpath:schemaTestContext.xml");
}
use of com.weibo.api.motan.transport.Client in project motan by weibocom.
the class AbstractEndpointFactory method createClient.
private Client createClient(URL url, EndpointManager endpointManager) {
Client client = innerCreateClient(url);
endpointManager.addEndpoint(client);
return client;
}
Aggregations