use of org.glassfish.hk2.utilities.DescriptorImpl in project Payara by payara.
the class Dom method createDescriptor.
private static DescriptorImpl createDescriptor(String typeName, HK2Loader cl, Map<String, List<String>> metadata) {
DescriptorImpl retVal = new DescriptorImpl();
retVal.setImplementation(typeName);
retVal.addAdvertisedContract(typeName);
retVal.setLoader(cl);
retVal.setMetadata(metadata);
return retVal;
}
use of org.glassfish.hk2.utilities.DescriptorImpl in project Payara by payara.
the class HK2DomConfigUtilities method addIfNotThere.
private static boolean addIfNotThere(ServiceLocator locator, DynamicConfiguration config, DescriptorImpl desc, HK2Loader loader) {
IndexedFilter filter = BuilderHelper.createContractFilter(desc.getImplementation());
if (locator.getBestDescriptor(filter) != null)
return false;
if (loader != null) {
desc.setLoader(loader);
}
config.bind(desc);
return true;
}
use of org.glassfish.hk2.utilities.DescriptorImpl 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);
}
Aggregations