Package com.byteslounge.cdi.annotation

Examples of com.byteslounge.cdi.annotation.Property


     */
    @Override
    public void inject(T instance, CreationalContext<T> ctx) {
        injectionTarget.inject(instance, ctx);
        for (Field field : annotatedType.getJavaClass().getDeclaredFields()) {
            Property annotation = field.getAnnotation(Property.class);
            if (annotation != null) {
                String key = annotation.value();
                String bundleName = annotation.resourceBundleBaseName().length() > 0 ? annotation.resourceBundleBaseName() : ExtensionConfiguration.INSTANCE
                        .getResourceBundleDefaultBaseName();
                if (bundleName == null) {
                    String errorMessage = "Property bundle name must have a configured default value (see github project instructions) or it must be configured in @"
                            + Property.class.getSimpleName() + " annotation.";
                    logger.error(errorMessage);
                    throw new PropertyResolverException(errorMessage);
                }
                field.setAccessible(true);
                try {
                    Object value = propertyResolverBean.resolveProperty(key, bundleName, ctx);
                    if (logger.isDebugEnabled()) {
                        logger.debug("Resolved property with key " + key + " to " + value);
                    }
                    if (annotation.parameters().length > 0) {
                        if (field.getType().equals(String.class)) {
                            value = MessageUtils.formatMessage((String) value, (Object[]) annotation.parameters());
                        } else {
                            logger.warn("Found property with defined parameters for formatting but property type is not of type "
                                    + String.class.getSimpleName() + ". Skipping message format... [" + field.getDeclaringClass().getSimpleName() + "."
                                    + field.getName() + "]");
                        }
View Full Code Here

TOP

Related Classes of com.byteslounge.cdi.annotation.Property

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.