use of javax.inject.Named in project Payara by payara.
the class AppServerStartupTest method bindService.
private void bindService(DynamicConfiguration configurator, Class<?> service) {
final DescriptorBuilder descriptorBuilder = BuilderHelper.link(service);
final RunLevel rla = service.getAnnotation(RunLevel.class);
if (rla != null) {
descriptorBuilder.to(RunLevel.class).has(RunLevel.RUNLEVEL_VAL_META_TAG, Collections.singletonList(((Integer) rla.value()).toString())).has(RunLevel.RUNLEVEL_MODE_META_TAG, Collections.singletonList(((Integer) rla.mode()).toString()));
descriptorBuilder.in(RunLevel.class);
}
Class clazz = service;
while (clazz != null) {
Class<?>[] interfaces = clazz.getInterfaces();
for (int j = 0; j < interfaces.length; j++) {
descriptorBuilder.to(interfaces[j]);
}
clazz = clazz.getSuperclass();
}
final Named named = service.getAnnotation(Named.class);
if (named != null) {
descriptorBuilder.named(named.value());
}
configurator.bind(descriptorBuilder.build());
}
use of javax.inject.Named in project Payara by payara.
the class HK2DomConfigTypesUtilities method enableHK2DomConfigurationConfigTypes.
/**
* This method enables the HK2 Dom based XML configuration parsing for
* systems that do not use HK2 metadata files or use a non-default
* name for HK2 metadata files, along with support for the types
* provided in this module. This method is idempotent, so that
* if the services already are available in the locator they will
* not get added again
*
* @param locator The non-null locator to add the hk2 dom based
* configuration services to
* @param loader The loader to use to classload the services added
*/
public static void enableHK2DomConfigurationConfigTypes(ServiceLocator locator, HK2Loader loader) {
if (locator.getBestDescriptor(BuilderHelper.createContractFilter(PROPERTY_GENERATED_INJECTOR_CLASS)) != null)
return;
HK2DomConfigUtilities.enableHK2DomConfiguration(locator, loader);
LinkedList<String> namedList = new LinkedList<String>();
namedList.add(REQUIRED);
namedList.add(STRING_DATATYPE);
namedList.add(LEAF);
LinkedList<String> valueList = new LinkedList<String>();
valueList.add(REQUIRED);
valueList.add(STRING_DATATYPE);
valueList.add(LEAF);
LinkedList<String> keyedAsList = new LinkedList<String>();
keyedAsList.add(PROPERTY_CLASS);
LinkedList<String> targetList = new LinkedList<String>();
targetList.add(PROPERTY_CLASS);
LinkedList<String> descriptionList = new LinkedList<String>();
descriptionList.add(OPTIONAL);
descriptionList.add(STRING_DATATYPE);
descriptionList.add(LEAF);
DescriptorImpl injectorDescriptor = BuilderHelper.link(PROPERTY_GENERATED_INJECTOR_CLASS).to(CONFIG_INJECTOR_CLASS).in(Singleton.class.getName()).named(NAME).qualifiedBy(INJECTION_TARGET_QUALIFIER).has(NAME_FIELD, namedList).has(VALUE_FIELD, valueList).has(KEYED_AS, keyedAsList).has(TARGET, targetList).has(DESCRIPTION_FIELD, descriptionList).has(KEY, NAME_FIELD).build();
// A strangeness of using name from @Service
injectorDescriptor.removeQualifier(Named.class.getName());
if (loader != null) {
injectorDescriptor.setLoader(loader);
}
ServiceLocatorUtilities.addOneDescriptor(locator, injectorDescriptor);
}
use of javax.inject.Named in project DevRing by LJYcoder.
the class MovieActivityModule method playingMovieFragment.
@ActivityScope
@Provides
@Named("playing")
MovieFragment playingMovieFragment() {
Bundle bundle = new Bundle();
bundle.putInt("type", MovieFragment.TYPE_PLAYING);
MovieFragment fragment = new MovieFragment();
fragment.setArguments(bundle);
return fragment;
}
Aggregations