final Method[] methods = c.getMethods();
final SProcProxy proxy = new SProcProxy(d);
final SProcService serviceAnnotation = c.getAnnotation(SProcService.class);
VirtualShardKeyStrategy keyStrategy = VIRTUAL_SHARD_KEY_STRATEGY_DEFAULT;
String prefix = "";
if (serviceAnnotation != null) {
try {
keyStrategy = (VirtualShardKeyStrategy) serviceAnnotation.shardStrategy().newInstance();
} catch (final InstantiationException | IllegalAccessException ex) {
LOG.error("ShardKey strategy for service can not be instantiated", ex);
return null;
}
if (!"".equals(serviceAnnotation.namespace())) {
prefix = serviceAnnotation.namespace() + "_";
}
}
for (final Method method : methods) {
final SProcCall scA = method.getAnnotation(SProcCall.class);
if (scA == null) {
continue;
}
String name = scA.name();
if ("".equals(name)) {
name = getSqlNameForMethod(method.getName());
}
name = prefix + name;
VirtualShardKeyStrategy sprocStrategy = keyStrategy;
if (scA.shardStrategy() != Void.class) {
try {
sprocStrategy = (VirtualShardKeyStrategy) scA.shardStrategy().newInstance();
} catch (final InstantiationException | IllegalAccessException ex) {
LOG.error("Shard strategy for sproc can not be instantiated", ex);