Search in sources :

Example 1 with ClasspathDescriptorFileFinder

use of org.glassfish.hk2.utilities.ClasspathDescriptorFileFinder in project Payara by payara.

the class ACCModulesManager method prepareHabitat.

/**
 * Sets up the HK2 habitat.
 * <p>
 * Must be invoked at least once before an AppClientContainerBuilder
 * returns a new AppClientContainer to the caller.
 * @param classLoader
 * @param logger
 * @throws com.sun.enterprise.module.bootstrap.BootException
 * @throws java.net.URISyntaxException
 */
private static ServiceLocator prepareHabitat(final ClassLoader loader) {
    ServiceLocator serviceLocator = ServiceLocatorFactory.getInstance().create("default");
    habitat = serviceLocator;
    ContextDuplicatePostProcessor duplicateProcessor = new ContextDuplicatePostProcessor();
    List<PopulatorPostProcessor> postProcessors = new LinkedList<PopulatorPostProcessor>();
    postProcessors.add(duplicateProcessor);
    try {
        HK2Populator.populate(serviceLocator, new ClasspathDescriptorFileFinder(loader), postProcessors);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return habitat;
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) ClasspathDescriptorFileFinder(org.glassfish.hk2.bootstrap.impl.ClasspathDescriptorFileFinder) ContextDuplicatePostProcessor(com.sun.enterprise.module.bootstrap.ContextDuplicatePostProcessor) PopulatorPostProcessor(org.glassfish.hk2.bootstrap.PopulatorPostProcessor) IOException(java.io.IOException) LinkedList(java.util.LinkedList)

Example 2 with ClasspathDescriptorFileFinder

use of org.glassfish.hk2.utilities.ClasspathDescriptorFileFinder in project Payara by payara.

the class JarManifestModuleRegistry method parseInhabitants.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected List<ActiveDescriptor> parseInhabitants(HK2Module module, String name, ServiceLocator serviceLocator, List<PopulatorPostProcessor> postProcessors) throws IOException {
    ArrayList<PopulatorPostProcessor> allPostProcessors = new ArrayList<PopulatorPostProcessor>();
    allPostProcessors.add(new Hk2LoaderPopulatorPostProcessor(singleClassLoader));
    if (postProcessors != null) {
        allPostProcessors.addAll(postProcessors);
    }
    DynamicConfigurationService dcs = serviceLocator.getService(DynamicConfigurationService.class);
    Populator populator = dcs.getPopulator();
    List<ActiveDescriptor<?>> retVal = populator.populate(new ClasspathDescriptorFileFinder(singleClassLoader, name), allPostProcessors.toArray(new PopulatorPostProcessor[allPostProcessors.size()]));
    return (List<ActiveDescriptor>) ((List) retVal);
}
Also used : DynamicConfigurationService(org.glassfish.hk2.api.DynamicConfigurationService) ActiveDescriptor(org.glassfish.hk2.api.ActiveDescriptor) ClasspathDescriptorFileFinder(org.glassfish.hk2.utilities.ClasspathDescriptorFileFinder) ArrayList(java.util.ArrayList) PopulatorPostProcessor(org.glassfish.hk2.api.PopulatorPostProcessor) Hk2LoaderPopulatorPostProcessor(org.glassfish.hk2.bootstrap.impl.Hk2LoaderPopulatorPostProcessor) Hk2LoaderPopulatorPostProcessor(org.glassfish.hk2.bootstrap.impl.Hk2LoaderPopulatorPostProcessor) ArrayList(java.util.ArrayList) List(java.util.List) Populator(org.glassfish.hk2.api.Populator)

Example 3 with ClasspathDescriptorFileFinder

use of org.glassfish.hk2.utilities.ClasspathDescriptorFileFinder in project Payara by payara.

the class Utils method getNewServiceLocator.

public static ServiceLocator getNewServiceLocator(String name) {
    ServiceLocator habitat = null;
    if (ServiceLocatorFactory.getInstance().find(name) == null) {
        ServiceLocator serviceLocator = ServiceLocatorFactory.getInstance().create(name);
        DynamicConfigurationService dcs = serviceLocator.getService(DynamicConfigurationService.class);
        DynamicConfiguration config = dcs.createDynamicConfiguration();
        config.commit();
        habitat = ServiceLocatorFactory.getInstance().create(name);
        try {
            HK2Populator.populate(serviceLocator, new ClasspathDescriptorFileFinder(Utils.class.getClassLoader()), null);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return (habitat != null) ? habitat : ServiceLocatorFactory.getInstance().create(name);
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) DynamicConfigurationService(org.glassfish.hk2.api.DynamicConfigurationService) DynamicConfiguration(org.glassfish.hk2.api.DynamicConfiguration) ClasspathDescriptorFileFinder(org.glassfish.hk2.bootstrap.impl.ClasspathDescriptorFileFinder) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 DynamicConfigurationService (org.glassfish.hk2.api.DynamicConfigurationService)2 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)2 ClasspathDescriptorFileFinder (org.glassfish.hk2.bootstrap.impl.ClasspathDescriptorFileFinder)2 ContextDuplicatePostProcessor (com.sun.enterprise.module.bootstrap.ContextDuplicatePostProcessor)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ActiveDescriptor (org.glassfish.hk2.api.ActiveDescriptor)1 DynamicConfiguration (org.glassfish.hk2.api.DynamicConfiguration)1 Populator (org.glassfish.hk2.api.Populator)1 PopulatorPostProcessor (org.glassfish.hk2.api.PopulatorPostProcessor)1 PopulatorPostProcessor (org.glassfish.hk2.bootstrap.PopulatorPostProcessor)1 Hk2LoaderPopulatorPostProcessor (org.glassfish.hk2.bootstrap.impl.Hk2LoaderPopulatorPostProcessor)1 ClasspathDescriptorFileFinder (org.glassfish.hk2.utilities.ClasspathDescriptorFileFinder)1