Add RpcAddressable to allow upper layer adding address mapping logic for its business object

This commit is contained in:
Kelven Yang 2012-12-04 11:52:29 -08:00
parent 1688919218
commit eee58d7804
6 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.framework.messaging;
public interface RpcAddressable {
String getAddress();
}

View File

@ -27,8 +27,11 @@ public interface RpcProvider extends TransportMultiplexier {
void registerRpcServiceEndpoint(RpcServiceEndpoint rpcEndpoint);
void unregisteRpcServiceEndpoint(RpcServiceEndpoint rpcEndpoint);
RpcClientCall newCall(TransportEndpoint sourceEndpoint, RpcAddressable targetAddress);
RpcClientCall newCall(TransportEndpoint sourceEndpoint, String targetAddress);
RpcClientCall newCall(String targetAddress);
RpcClientCall newCall(RpcAddressable targetAddress);
void registerCall(RpcClientCall call);
void cancelCall(RpcClientCall call);

View File

@ -92,6 +92,17 @@ public class RpcProviderImpl implements RpcProvider {
return call;
}
@Override
public RpcClientCall newCall(TransportEndpoint sourceEndpoint, RpcAddressable targetAddress) {
long callTag = getNextCallTag();
RpcClientCallImpl call = new RpcClientCallImpl(this);
call.setSourceAddress(sourceEndpoint.getEndpointAddress());
call.setTargetAddress(targetAddress.getAddress());
call.setCallTag(callTag);
return call;
}
@Override
public RpcClientCall newCall(String targetAddress) {
@ -100,6 +111,12 @@ public class RpcProviderImpl implements RpcProvider {
return null;
}
@Override
public RpcClientCall newCall(RpcAddressable targetAddress) {
return newCall(targetAddress.getAddress());
}
@Override
public void registerCall(RpcClientCall call) {
assert(call != null);

View File

@ -1,3 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.framework.messaging;
public class ClientOnlyEventDrivenStyle {

View File

@ -1,3 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.framework.messaging;
public class ClientOnlyListenerStyle {

View File

@ -1,3 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.framework.messaging;
@OnwireName(name="TestCommand")