Package de.zalando.sprocwrapper

Examples of de.zalando.sprocwrapper.SProcService


    public static <T> T build(final DataSourceProvider d, final Class<T> c) {
        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);
                    return null;
                }
            }

            RowMapper<?> resultMapper = null;

            if (scA.resultMapper() != Void.class) {
                try {
                    resultMapper = (RowMapper<?>) scA.resultMapper().newInstance();
                } catch (final InstantiationException | IllegalAccessException ex) {
                    LOG.error("Result mapper for sproc can not be instantiated", ex);
                    return null;
                }
            }

            boolean useValidation;
            if (serviceAnnotation != null) {

                // take validation settings from SProcService annotation:
                useValidation = serviceAnnotation.validate();
            } else {
                useValidation = false;
            }

            // overwrite if explicitly set in SprocCall:
View Full Code Here

TOP

Related Classes of de.zalando.sprocwrapper.SProcService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.