本文整理汇总了Java中com.speedment.common.injector.Injector类的典型用法代码示例。如果您正苦于以下问题:Java Injector类的具体用法?Java Injector怎么用?Java Injector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Injector类属于com.speedment.common.injector包,在下文中一共展示了Injector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: defaultPackageNameProperty
import com.speedment.common.injector.Injector; //导入依赖的package包/类
/**
* Returns the default value for the package name
*
* @param injector the injector, in case an implementing class needs it
* @return the default package name
*/
default ObservableStringValue defaultPackageNameProperty(Injector injector) {
final TranslatorSupport<?> support = new TranslatorSupport<>(injector, this);
if (this instanceof ProjectProperty) {
final ProjectProperty project = (ProjectProperty) this;
return createStringBinding(
support::defaultPackageName,
project.nameProperty(),
project.companyNameProperty()
);
} else if (this instanceof HasAliasProperty) {
final HasAliasProperty alias = (HasAliasProperty) this;
return createStringBinding(support::defaultPackageName, alias.aliasProperty());
} else {
return createStringBinding(support::defaultPackageName, nameProperty());
}
}
开发者ID:speedment,项目名称:speedment,代码行数:24,代码来源:HasPackageNameProperty.java
示例2: findIn
import com.speedment.common.injector.Injector; //导入依赖的package包/类
public static <T> T findIn(
Class<T> type,
Injector injector,
List<Object> instances,
boolean required) {
final Optional<T> found = findAll(type, injector, instances)
.findFirst(); // Order is important.
if (required) {
return found.orElseThrow(() ->
new IllegalArgumentException(
"Could not find any installed implementation of " +
type.getName() + "."
)
);
} else {
return found.orElse(null);
}
}
开发者ID:speedment,项目名称:speedment,代码行数:21,代码来源:InjectorUtil.java
示例3: with
import com.speedment.common.injector.Injector; //导入依赖的package包/类
@Override
public <C extends Document & HasEnabled> BUILDER with(
final Class<C> type,
final String name,
final BiConsumer<Injector, C> consumer
) {
requireNonNulls(type, name, consumer);
injectorBuilder.before(resolved(ProjectComponent.class)
.withStateInitialized(Injector.class)
.withExecute((projComp, injector) ->
DocumentDbUtil.traverseOver(projComp.getProject(), type)
.filter(doc -> DocumentUtil.relativeName(
HasName.of(doc),
Dbms.class,
DATABASE_NAME
).equals(name))
.forEach(doc -> consumer.accept(injector, doc))
)
);
return self();
}
开发者ID:speedment,项目名称:speedment,代码行数:24,代码来源:AbstractApplicationBuilder.java
示例4: build
import com.speedment.common.injector.Injector; //导入依赖的package包/类
@Override
public final APP build() {
final Injector inj;
try {
inj = injectorBuilder.build();
} catch (final InstantiationException | CyclicReferenceException ex) {
throw new SpeedmentException("Error in dependency injection.", ex);
}
printWelcomeMessage(inj);
if (!skipValidateRuntimeConfig) {
validateRuntimeConfig(inj);
}
if (!skipCheckDatabaseConnectivity) {
checkDatabaseConnectivity(inj);
}
return build(inj);
}
开发者ID:speedment,项目名称:speedment,代码行数:22,代码来源:AbstractApplicationBuilder.java
示例5: checkDatabaseConnectivity
import com.speedment.common.injector.Injector; //导入依赖的package包/类
protected void checkDatabaseConnectivity(Injector injector) {
LOGGER.debug("Checking Database Connectivity");
final Project project = injector.getOrThrow(ProjectComponent.class)
.getProject();
project.dbmses().forEachOrdered(dbms -> {
final DbmsHandlerComponent dbmsHandlerComponent = injector
.getOrThrow(DbmsHandlerComponent.class);
final DbmsType dbmsType = DatabaseUtil
.dbmsTypeOf(dbmsHandlerComponent, dbms);
final DbmsMetadataHandler handler = dbmsType.getMetadataHandler();
try {
LOGGER.info(handler.getDbmsInfoString(dbms));
} catch (final SQLException sqle) {
throw new SpeedmentException("Unable to establish initial " +
"connection with the database named " +
dbms.getName() + ".", sqle);
}
});
}
开发者ID:speedment,项目名称:speedment,代码行数:25,代码来源:AbstractApplicationBuilder.java
示例6: installDecorators
import com.speedment.common.injector.Injector; //导入依赖的package包/类
@ExecuteBefore(RESOLVED)
void installDecorators(Injector injector,
@WithState(INITIALIZED) TypeMapperComponent typeMappers,
@WithState(INITIALIZED) CodeGenerationComponent codeGen,
@WithState(RESOLVED) PropertyEditorComponent editors) {
typeMappers.install(String.class, StringToEnumTypeMapper::new);
typeMappers.install(Integer.class, IntegerToEnumTypeMapper::new);
codeGen.add(
Table.class,
StandardTranslatorKey.GENERATED_ENTITY,
new GeneratedEntityDecorator(injector)
);
editors.install(
HasEnumConstantsProperty.class,
Column.ENUM_CONSTANTS,
CommaSeparatedStringEditor::new
);
}
开发者ID:speedment,项目名称:speedment,代码行数:22,代码来源:EnumGeneratorComponent.java
示例7: injectFields
import com.speedment.common.injector.Injector; //导入依赖的package包/类
private <T> void injectFields(T instance) {
requireNonNull(instance);
traverseFields(instance.getClass())
.filter(f -> f.isAnnotationPresent(Inject.class))
.distinct()
.forEachOrdered(field -> {
final Object value;
if (Injector.class.isAssignableFrom(field.getType())) {
value = this;
} else {
value = find(
field.getType(),
field.getAnnotation(WithState.class) != null
);
}
field.setAccessible(true);
try {
field.set(instance, value);
} catch (final IllegalAccessException ex) {
final String err = "Could not access field '" +
field.getName() +
"' in class '" + value.getClass().getName() +
"' of type '" + field.getType() + "'.";
LOGGER.error(ex, err);
throw new RuntimeException(err, ex);
}
});
}
开发者ID:speedment,项目名称:speedment,代码行数:33,代码来源:InjectorImpl.java
示例8: findAll
import com.speedment.common.injector.Injector; //导入依赖的package包/类
public static <T> Stream<T> findAll(
Class<T> type,
Injector injector,
List<Object> instances) {
if (Injector.class.isAssignableFrom(type)) {
@SuppressWarnings("unchecked")
final T casted = (T) injector;
return Stream.of(casted);
}
return instances.stream()
.filter(inst -> type.isAssignableFrom(inst.getClass()))
.map(type::cast);
}
开发者ID:speedment,项目名称:speedment,代码行数:16,代码来源:InjectorUtil.java
示例9: AbstractApplicationBuilder
import com.speedment.common.injector.Injector; //导入依赖的package包/类
protected AbstractApplicationBuilder(
Class<? extends APP> applicationImplClass,
Class<? extends ApplicationMetadata> metadataClass) {
this(Injector.builder()
.withBundle(RuntimeBundle.class)
.withComponent(applicationImplClass)
.withComponent(metadataClass)
);
}
开发者ID:speedment,项目名称:speedment,代码行数:11,代码来源:AbstractApplicationBuilder.java
示例10: withLogging
import com.speedment.common.injector.Injector; //导入依赖的package包/类
@Override
public BUILDER withLogging(HasLogglerName namer) {
LoggerManager.getLogger(namer.getLoggerName()).setLevel(Level.DEBUG);
if (LogType.APPLICATION_BUILDER.getLoggerName()
.equals(namer.getLoggerName())) {
// Special case becaues its in a common module
Injector.logger().setLevel(Level.DEBUG);
InjectorBuilder.logger().setLevel(Level.DEBUG);
}
return self();
}
开发者ID:speedment,项目名称:speedment,代码行数:15,代码来源:AbstractApplicationBuilder.java
示例11: validateRuntimeConfig
import com.speedment.common.injector.Injector; //导入依赖的package包/类
protected void validateRuntimeConfig(Injector injector) {
LOGGER.debug("Validating Runtime Configuration");
final Project project = injector.getOrThrow(ProjectComponent.class)
.getProject();
if (project == null) {
throw new SpeedmentException("No project defined");
}
project.dbmses().forEach(d -> {
final String typeName = d.getTypeName();
final Optional<DbmsType> oDbmsType = injector.getOrThrow(
DbmsHandlerComponent.class).findByName(typeName);
if (!oDbmsType.isPresent()) {
throw new SpeedmentException("The database type " + typeName +
" is not registered with the " +
DbmsHandlerComponent.class.getSimpleName());
}
final DbmsType dbmsType = oDbmsType.get();
if (!dbmsType.isSupported()) {
LOGGER.error("The database driver class " + dbmsType.getDriverName() +
" is not available. Make sure to include it in your " +
"class path (e.g. in the POM file)"
);
}
});
}
开发者ID:speedment,项目名称:speedment,代码行数:31,代码来源:AbstractApplicationBuilder.java
示例12: execute
import com.speedment.common.injector.Injector; //导入依赖的package包/类
@Override
public void execute(Speedment speedment) throws MojoExecutionException, MojoFailureException {
final Injector injector = speedment.getOrThrow(Injector.class);
MainApp.setInjector(injector);
if (hasConfigFile()) {
Application.launch(MainApp.class, configLocation().toAbsolutePath().toString());
} else {
Application.launch(MainApp.class);
}
}
开发者ID:speedment,项目名称:speedment,代码行数:12,代码来源:AbstractToolMojo.java
示例13: start
import com.speedment.common.injector.Injector; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
requireNonNull(stage);
InjectorBuilder.logger().setLevel(DEBUG);
if (INJECTOR == null) {
LOGGER.warn("Creating new Speedment instance for UI session.");
INJECTOR = new DefaultApplicationBuilder(
getClass().getClassLoader(),
DefaultApplicationMetadata.class
)
.withComponent(CodeGenerationComponentImpl.class)
.withComponent(UserInterfaceComponentImpl.class)
.build().getOrThrow(Injector.class);
}
final UserInterfaceComponentImpl ui = INJECTOR.getOrThrow(UserInterfaceComponentImpl.class);
final ProjectComponent projects = INJECTOR.getOrThrow(ProjectComponent.class);
final InjectionLoader loader = INJECTOR.getOrThrow(InjectionLoader.class);
ui.start(this, stage);
if (projects.getProject().dbmses().noneMatch(dbms -> true)) {
if (InternalEmailUtil.hasEmail()) {
loader.loadAndShow("Connect");
} else {
loader.loadAndShow("MailPrompt");
}
} else {
loader.loadAndShow("Scene");
ui.showNotification(
"Metadata has been loaded from an offline file. Click here to reload from database.",
FontAwesome.REFRESH,
Palette.INFO,
ui::reload
);
}
}
开发者ID:speedment,项目名称:speedment,代码行数:40,代码来源:MainApp.java
示例14: applyBrand
import com.speedment.common.injector.Injector; //导入依赖的package包/类
public static void applyBrand(Injector injector, Stage stage, Scene scene) {
applyBrandToStage(injector, stage);
final Brand brand = injector.getOrThrow(Brand.class);
final InfoComponent info = injector.getOrThrow(InfoComponent.class);
apply(brand, info, stage, scene);
}
开发者ID:speedment,项目名称:speedment,代码行数:9,代码来源:BrandUtil.java
示例15: applyBrandToStage
import com.speedment.common.injector.Injector; //导入依赖的package包/类
public static void applyBrandToStage(Injector injector, Stage stage) {
final InfoComponent info = injector.getOrThrow(InfoComponent.class);
final Brand brand = injector.getOrThrow(Brand.class);
stage.setTitle(info.getTitle());
brand.logoSmall()
.map(Image::new)
.ifPresent(stage.getIcons()::add);
}
开发者ID:speedment,项目名称:speedment,代码行数:10,代码来源:BrandUtil.java
示例16: applyBrandToScene
import com.speedment.common.injector.Injector; //导入依赖的package包/类
public static void applyBrandToScene(Injector injector, Scene scene) {
final Brand brand = injector.getOrThrow(Brand.class);
final UserInterfaceComponent ui = injector.getOrThrow(UserInterfaceComponent.class);
final InfoComponent info = injector.getOrThrow(InfoComponent.class);
final Stage stage = scene.getWindow() == null
? ui.getStage()
: (Stage) scene.getWindow();
apply(brand, info, stage, scene);
}
开发者ID:speedment,项目名称:speedment,代码行数:12,代码来源:BrandUtil.java
示例17: init
import com.speedment.common.injector.Injector; //导入依赖的package包/类
@ExecuteBefore(State.INITIALIZED)
void init(Injector injector) {
// Since we created the instance of 'helper' manually, we have to
// invoke the injector manually. We can do this in the "INITIALIZED"
// phase since we don't need access to any components and we want to
// simulate that this happends on construction.
injector.inject(helper);
}
开发者ID:speedment,项目名称:speedment,代码行数:9,代码来源:AbstractTranslatorManager.java
示例18: testShortTableName
import com.speedment.common.injector.Injector; //导入依赖的package包/类
@Test
public void testShortTableName() {
final TranslatorSupport<Table> support = new TranslatorSupport<>(
speedment.getOrThrow(Injector.class), table2
);
assertEquals("sP", support.variableName());
}
开发者ID:speedment,项目名称:speedment,代码行数:9,代码来源:TranslatorSupportTest.java
示例19: FkHolder
import com.speedment.common.injector.Injector; //导入依赖的package包/类
public FkHolder(Injector injector, ForeignKey fk) {
requireNonNull(fk);
this.codeGenerationComponent = injector.getOrThrow(CodeGenerationComponent.class);
this.fk = fk;
this.fkc = fk.foreignKeyColumns().findFirst().orElseThrow(this::noEnabledForeignKeyException);
this.column = fkc.findColumn().orElseThrow(this::couldNotFindLocalColumnException);
this.table = ancestor(column, Table.class).get();
this.foreignColumn = fkc.findForeignColumn().orElseThrow(this::foreignKeyWasNullException);
this.foreignTable = fkc.findForeignTable().orElseThrow(this::foreignKeyWasNullException);
}
开发者ID:speedment,项目名称:speedment,代码行数:13,代码来源:FkHolder.java
示例20: createDecorated
import com.speedment.common.injector.Injector; //导入依赖的package包/类
public JavaClassTranslator<DOC, T> createDecorated(Injector injector, DOC document) {
@SuppressWarnings("unchecked")
final JavaClassTranslator<DOC, T> translator
= (JavaClassTranslator<DOC, T>) getConstructor().apply(document);
injector.inject(translator);
decorators.stream()
.map(injector::inject)
.forEachOrdered(dec -> dec.apply(translator));
return translator;
}
开发者ID:speedment,项目名称:speedment,代码行数:14,代码来源:CodeGenerationComponentImpl.java
注:本文中的com.speedment.common.injector.Injector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论