All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.sisu.wire.package-info Maven / Gradle / Ivy

There is a newer version: 3.0.0-alpha-3
Show newest version
/*******************************************************************************
 * Copyright (c) 2010-present Sonatype, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Stuart McCulloch (Sonatype, Inc.) - initial API and implementation
 *******************************************************************************/
/**
 * Customizable wiring of unresolved dependencies. Use this to share components across injectors, apply configuration, and form on-demand collections.
 * 

* The {@link org.eclipse.sisu.wire.WireModule} should enclose all modules in your application: * *

 * Guice.createInjector( new WireModule( bootModule, configModule, mainModule ) );
* * Use the {@link org.eclipse.sisu.wire.ChildWireModule} when you want to wire child injectors: * *
 * injector.createChildInjector( new ChildWireModule( serviceModule, subModule ) );
*
* The default wiring strategy is to use {@link org.eclipse.sisu.wire.LocatorWiring} which can supply the following bindings via the {@link org.eclipse.sisu.inject.BeanLocator}: * *

Instances

*
 * @Inject MyType bean
 * 
 * @Inject @Named("hint") MyType namedBean
 * 
 * @Inject @MyQualifier MyType qualifiedBean
 * 
 * @Inject Provider<MyType> beanProvider
* *

Configuration

*
 * @Inject @Named("${my.property.name}") File file                      // supports basic type conversion
 * 
 * @Inject @Named("${my.property.name:-http://example.org/}") URL url   // can give default in case property is not set
 * 
 * @Inject @Named("${my.property.name:-development}") MyType bean       // can be used to pick specific @Named beans
 * 
 * @Inject @Named("my.property.name") int port                          // shorthand syntax
*

* You can bind your configuration at runtime as follows: *

 * bind( {@link org.eclipse.sisu.wire.ParameterKeys#PROPERTIES ParameterKeys.PROPERTIES} ).toInstance( myConfiguration );      // multiple bindings are merged into one view
* *

Collections

* The following collections are both dynamic and thread-safe, elements may come and go as injectors are added or removed from the {@link org.eclipse.sisu.inject.BeanLocator}. *

* They are also lazy, meaning instances are created as you access elements of the collection; the elements are then re-used for the same collection. * *

 * @Inject List<MyType> list
 * 
 * @Inject List<Provider<MyType>> providers
 * 
 * @Inject Iterable<{@link org.eclipse.sisu.BeanEntry}<MyQualifier, MyType>> entries             // gives access to additional metadata
* *
 * @Inject Map<String, MyType> stringMap                                // strings are taken from @Named values
 * 
 * @Inject Map<Named, MyType> namedMap
 * 
 * @Inject Map<MyQualifier, MyType> qualifiedMap
 * 
 * @Inject Map<String, Provider<MyType>> providerMap
*/ package org.eclipse.sisu.wire;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy