Package com.google.inject

Examples of com.google.inject.ProvisionException


        @Override
        public CommandLine get() {
            try {
                return parser.parse(options, arguments);
            } catch (ParseException e) {
                throw new ProvisionException("Error parsing command line arguments", e);
            }
        }
View Full Code Here


       
        for (Class<? extends PostInjectorAction> action : config.actions()) {
            try {
                binder.bindPostInjectorAction().to(action);
            } catch (Exception e) {
                throw new ProvisionException("Error creating postInjectorAction '" + action.getName() + "'", e);
            }
        }
       
        for (Class<? extends ModuleTransformer> transformer : config.transformers()) {
            try {
                binder.bindModuleTransformer().to(transformer);
            } catch (Exception e) {
                throw new ProvisionException("Error creating postInjectorAction '" + transformer.getName() + "'", e);
            }
        }   
    }
View Full Code Here

                        System.out.println("Adding binding for service : " + service.getClass().getName());
                        ServiceProvider<S> provider = new ServiceProvider<S>(service);
                        binding.addBinding().toProvider(provider).in(Scopes.SINGLETON);
                    }
                } catch (Exception e) {
                    throw new ProvisionException("Failed to load services for '" + type + "'", e);
                }
            }
            else {
                @SuppressWarnings("unchecked")
                TypeLiteral<Set<S>> typeLiteral = (TypeLiteral<Set<S>>) TypeLiteral.get(Types.setOf(type));
View Full Code Here

                for (S obj : loader.call()) {
                    injector.injectMembers(obj);
                    services.add(obj);
                }
            } catch (Exception e) {
                throw new ProvisionException("Failed to laod services", e);
            }
            return services;
        }
View Full Code Here

                                }

                                Object providedOrSentinel = (provided == null) ? NULL : provided;
                                if ( (instance != null) && (instance != providedOrSentinel) )
                                {
                                    throw new ProvisionException("Provider was reentrant while creating a singleton");
                                }

                                instance = providedOrSentinel;
                            }
                        }
View Full Code Here

                protected void configure() {
                    bind(Arguments.class).toInstance(new Arguments(args));
                }
            });
        } catch (Exception e) {
            throw new ProvisionException("Error instantiating main class", e);
        }
    }
View Full Code Here

                protected void configure() {
                    bind(String[].class).annotatedWith(Main.class).toInstance(args);
                }
            });
        } catch (Exception e) {
            throw new ProvisionException("Error instantiating main class", e);
        }
    }
View Full Code Here

                    }
                    injector.injectMembers(instance);
                    return instance;
                }
                catch (Exception e) {
                    throw new ProvisionException("Failed to create module '" + type.getName() + "'", e);
                }
            }
            finally {
                if (instance != null) {
                    registerModule(instance);
View Full Code Here

        // The main class is added last so it can override any bindings from the BootstrapModule's and LifecycleInjectorBuilderSuite's
        if (Module.class.isAssignableFrom(main)) {
            try {
                builder.withAdditionalModuleClasses(main);
            } catch (Exception e) {
                throw new ProvisionException(String.format("Failed to create module for main class '%s'", main.getName()), e);
            }
        }
       
        // Finally, create and return the injector
        return builder.build().createInjector();
View Full Code Here

        this.transformers = injector.getInstance(Key.get(new TypeLiteral<Set<ModuleTransformer>>() {}));
       
        try {
            this.modules = internalBootstrapModule.getModuleListBuilder().build(injector);
        } catch (Exception e) {
            throw new ProvisionException("Unable to resolve list of modules", e);
        }
        lifecycleManager = injector.getInstance(LifecycleManager.class);
        lifecycleManagerRef.set(lifecycleManager);
    }
View Full Code Here

TOP

Related Classes of com.google.inject.ProvisionException

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.