Package restx.common

Examples of restx.common.RestxConfig


            // wrap in hot reloading or hoy compile router if needed.
            // this must be the last wrapping so that the classloader is used for the full request, including
            // for recording
            if (useHotCompile()) {
                final RestxConfig config = settingsFactory.getComponent(RestxConfig.class);
                router = new CompilationManagerRouter(router, factory.getComponent(EventBus.class),
                        getColdClasses(factory),
                        new CompilationSettings() {
                    @Override
                    public int autoCompileCoalescePeriod() {
                        return config.getInt("restx.fs.watch.coalesce.period").get();
                    }

                    @Override
                    public Predicate<Path> classpathResourceFilter() {
                        return CompilationManager.DEFAULT_CLASSPATH_RESOURCE_FILTER;
View Full Code Here


                // now fetch elements coming from ConfigSuppliers
                for (NamedComponent<ConfigSupplier> supplier : satisfiedBOM.get(configSupplierQuery)) {
                    addAll(elements, supplier.getComponent().get().elements());
                }
                RestxConfig config = StdRestxConfig.of(elements);

                // and now String components
                List<ConfigElement> factoryElements = new ArrayList<>();
                for (NamedComponent<String> s : satisfiedBOM.get(stringsQuery)) {
                    Optional<ConfigElement> element = config.getElement(s.getName().getName());
                    if (element.isPresent() && element.get().getValue().equals(s.getComponent())) {
                        // we don't add values from factory with the same value as the one found in config:
                        // it's probably because config elements are provided as String components too.
                        continue;
                    }
View Full Code Here

            private Factory.Query<RestxConfig> restxConfigQuery = Factory.Query.byClass(RestxConfig.class).mandatory();

            @Override
            protected FactoryMachine doNewComponent(SatisfiedBOM satisfiedBOM) {
                final RestxConfig config = satisfiedBOM.getOneAsComponent(restxConfigQuery).get();
                return new FactoryMachine() {
                    @Override
                    public boolean canBuild(Name<?> name) {
                        Optional<ConfigElement> configElement = config.getElement(name.getName());
                        return configElement.isPresent()
                            && (name.getClazz() == ConfigElement.class
                                || (name.getClazz() == String.class
                                    && !Strings.isNullOrEmpty(configElement.get().getValue()))
                              );
                    }

                    @Override
                    public <T> MachineEngine<T> getEngine(final Name<T> name) {
                        return new NoDepsMachineEngine<T>(name, BoundlessComponentBox.FACTORY) {
                            @Override
                            @SuppressWarnings("unchecked")
                            protected T doNewComponent(SatisfiedBOM satisfiedBOM) {
                                if (name.getClazz() == String.class) {
                                    return (T) config.getString(name.getName()).get();
                                }
                                if (name.getClazz() == ConfigElement.class) {
                                    return (T) config.getElement(name.getName()).get();
                                }
                                throw new IllegalArgumentException("can't satisfy name " + name);
                            }
                        };
                    }

                    @Override
                    @SuppressWarnings("unchecked")
                    public <T> Set<Name<T>> nameBuildableComponents(Class<T> componentClass) {
                        if (String.class == componentClass) {
                            return (Set) Sets.newHashSet(Iterables.transform(config.elements(),
                                    new Function<ConfigElement, Name<String>>() {
                                @Override
                                public Name<String> apply(ConfigElement input) {
                                    return Name.of(String.class, input.getKey());
                                }
                            }));
                        } else if (ConfigElement.class == componentClass) {
                            return (Set) Sets.newHashSet(Iterables.transform(config.elements(),
                                    new Function<ConfigElement, Name<ConfigElement>>() {
                                @Override
                                public Name<ConfigElement> apply(ConfigElement input) {
                                    return Name.of(ConfigElement.class, input.getKey());
                                }
View Full Code Here

TOP

Related Classes of restx.common.RestxConfig

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.