Search in sources :

Example 1 with RpcModule

use of org.opennms.core.rpc.api.RpcModule in project opennms by OpenNMS.

the class CamelRpcServerRouteManager method bind.

@SuppressWarnings({ "rawtypes", "unchecked" })
public void bind(RpcModule module) throws Exception {
    if (module != null) {
        final RpcModule<RpcRequest, RpcResponse> rpcModule = (RpcModule<RpcRequest, RpcResponse>) module;
        final String routeId = getRouteId(rpcModule);
        final Route existingRoute = context.getRoute(routeId);
        if (routeIdsByModule.containsKey(rpcModule)) {
            if (existingRoute == null) {
                LOG.error("RpcModule {} ({}) was marked as registered but its route {} cannot be found in the Camel context", rpcModule.getId(), Integer.toHexString(rpcModule.hashCode()), routeId);
            } else {
                LOG.warn("RpcModule {} ({}) was already registered on route {}: {}", rpcModule.getId(), Integer.toHexString(rpcModule.hashCode()), routeId, existingRoute);
            }
        } else {
            if (existingRoute == null) {
                final RouteBuilder routeBuilder = getRouteBuilder(context, identity, module);
                context.addRoutes(routeBuilder);
                routeIdsByModule.put(rpcModule, routeId);
                LOG.info("Registered RpcModule {} ({}) on route {} with builder {}", rpcModule.getId(), Integer.toHexString(rpcModule.hashCode()), routeId, routeBuilder);
            } else {
                LOG.warn("RpcModule {} ({}) cannot be registered, route {} is already present: {}", rpcModule.getId(), Integer.toHexString(rpcModule.hashCode()), routeId, existingRoute);
            }
        }
    }
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) RpcRequest(org.opennms.core.rpc.api.RpcRequest) RpcModule(org.opennms.core.rpc.api.RpcModule) RpcResponse(org.opennms.core.rpc.api.RpcResponse) Route(org.apache.camel.Route)

Aggregations

Route (org.apache.camel.Route)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 RpcModule (org.opennms.core.rpc.api.RpcModule)1 RpcRequest (org.opennms.core.rpc.api.RpcRequest)1 RpcResponse (org.opennms.core.rpc.api.RpcResponse)1