Search in sources :

Example 1 with Context

use of org.glassfish.hk2.api.Context in project jersey by jersey.

the class RequestResponseWrapperProvider method getRequestScopedInitializerProvider.

@Override
public RequestScopedInitializerProvider getRequestScopedInitializerProvider() {
    return new RequestScopedInitializerProvider() {

        @Override
        public RequestScopedInitializer get(final RequestContextProvider context) {
            return new RequestScopedInitializer() {

                @Override
                public void initialize(InjectionManager injectionManager) {
                    ServiceLocator locator = ((HK2InjectionManager) injectionManager).getServiceLocator();
                    locator.<Ref<HttpServletRequest>>getService(REQUEST_TYPE).set(finalWrap(context.getHttpServletRequest()));
                    locator.<Ref<HttpServletResponse>>getService(RESPONSE_TYPE).set(finalWrap(context.getHttpServletResponse()));
                }
            };
        }
    };
}
Also used : RequestScopedInitializer(org.glassfish.jersey.server.spi.RequestScopedInitializer) ServiceLocator(org.glassfish.hk2.api.ServiceLocator) HttpServletRequest(javax.servlet.http.HttpServletRequest) RequestScopedInitializerProvider(org.glassfish.jersey.servlet.internal.spi.RequestScopedInitializerProvider) HttpServletResponse(javax.servlet.http.HttpServletResponse) HK2InjectionManager(org.glassfish.jersey.hk2.HK2InjectionManager) RequestContextProvider(org.glassfish.jersey.servlet.internal.spi.RequestContextProvider) InjectionManager(org.glassfish.jersey.internal.inject.InjectionManager) HK2InjectionManager(org.glassfish.jersey.hk2.HK2InjectionManager)

Example 2 with Context

use of org.glassfish.hk2.api.Context in project Payara by payara.

the class GetRequestTracingConfiguration method execute.

@Override
public void execute(AdminCommandContext context) {
    Config config = targetUtil.getConfig(target);
    if (config == null) {
        context.getActionReport().setMessage("No such config named: " + target);
        context.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    ActionReport mainActionReport = context.getActionReport();
    RequestTracingServiceConfiguration configuration = config.getExtensionByType(RequestTracingServiceConfiguration.class);
    writeVariableToActionReport(mainActionReport, "Enabled?", configuration.getEnabled());
    if (Boolean.parseBoolean(configuration.getEnabled())) {
        writeVariableToActionReport(mainActionReport, "Sample Rate", configuration.getSampleRate());
        // Print adaptive sampling details
        writeVariableToActionReport(mainActionReport, "Adaptive Sampling Enabled?", configuration.getAdaptiveSamplingEnabled());
        if (Boolean.parseBoolean(configuration.getAdaptiveSamplingEnabled())) {
            writeVariableToActionReport(mainActionReport, "Adaptive Sampling Target Count", configuration.getAdaptiveSamplingTargetCount());
            writeVariableToActionReport(mainActionReport, "Adaptive Sampling Time Value", configuration.getAdaptiveSamplingTimeValue());
            writeVariableToActionReport(mainActionReport, "Adaptive Sampling Time Unit", configuration.getAdaptiveSamplingTimeUnit());
        }
        // Print filter details
        writeVariableToActionReport(mainActionReport, "Application Only?", configuration.getApplicationsOnlyEnabled());
        writeVariableToActionReport(mainActionReport, "Threshold Value", configuration.getThresholdValue());
        writeVariableToActionReport(mainActionReport, "Threshold Unit", configuration.getThresholdUnit());
        writeVariableToActionReport(mainActionReport, "Sample Rate First?", configuration.getSampleRateFirstEnabled());
        // Print trace store details
        writeVariableToActionReport(mainActionReport, "Reservoir Sampling Enabled?", configuration.getReservoirSamplingEnabled());
        writeVariableToActionReport(mainActionReport, "Trace Store Size", configuration.getTraceStoreSize());
        if (!Strings.isNullOrEmpty(configuration.getTraceStoreTimeout())) {
            writeVariableToActionReport(mainActionReport, "Trace Store Timeout (secs)", configuration.getTraceStoreTimeout());
        }
        // Print historic trace store details
        writeVariableToActionReport(mainActionReport, "Historic Trace Store Enabled?", configuration.getHistoricTraceStoreEnabled());
        if (Boolean.parseBoolean(configuration.getHistoricTraceStoreEnabled())) {
            writeVariableToActionReport(mainActionReport, "Historic Trace Store Size", configuration.getHistoricTraceStoreSize());
            if (!Strings.isNullOrEmpty(configuration.getHistoricTraceStoreTimeout())) {
                writeVariableToActionReport(mainActionReport, "Historic Trace Store Timeout (secs)", configuration.getHistoricTraceStoreTimeout());
            }
        }
    }
    // Create the extraProps for the general request tracing configuration
    Properties mainExtraProps = new Properties();
    Map<String, Object> mainExtraPropsMap = new HashMap<>();
    mainExtraPropsMap.put("enabled", configuration.getEnabled());
    mainExtraPropsMap.put("sampleRate", configuration.getSampleRate());
    mainExtraPropsMap.put("adaptiveSamplingEnabled", configuration.getAdaptiveSamplingEnabled());
    mainExtraPropsMap.put("adaptiveSamplingTargetCount", configuration.getAdaptiveSamplingTargetCount());
    mainExtraPropsMap.put("adaptiveSamplingTimeValue", configuration.getAdaptiveSamplingTimeValue());
    mainExtraPropsMap.put("adaptiveSamplingTimeUnit", configuration.getAdaptiveSamplingTimeUnit());
    mainExtraPropsMap.put("applicationsOnlyEnabled", configuration.getApplicationsOnlyEnabled());
    mainExtraPropsMap.put("thresholdValue", configuration.getThresholdValue());
    mainExtraPropsMap.put("thresholdUnit", configuration.getThresholdUnit());
    mainExtraPropsMap.put("sampleRateFirstEnabled", configuration.getSampleRateFirstEnabled());
    mainExtraPropsMap.put("traceStoreSize", configuration.getTraceStoreSize());
    mainExtraPropsMap.put("traceStoreTimeout", configuration.getTraceStoreTimeout());
    mainExtraPropsMap.put("reservoirSamplingEnabled", configuration.getReservoirSamplingEnabled());
    mainExtraPropsMap.put("historicTraceStoreEnabled", configuration.getHistoricTraceStoreEnabled());
    mainExtraPropsMap.put("historicTraceStoreSize", configuration.getHistoricTraceStoreSize());
    mainExtraPropsMap.put("historicTraceStoreTimeout", configuration.getHistoricTraceStoreTimeout());
    mainExtraProps.put("requestTracingConfiguration", mainExtraPropsMap);
    mainActionReport.setExtraProperties(mainExtraProps);
    mainActionReport.appendMessage("Below are the configuration details of each notifier listed by its name.");
    mainActionReport.appendMessage(StringUtils.EOL);
    ActionReport notifiersActionReport = mainActionReport.addSubActionsReport();
    List<ServiceHandle<BaseNotifierService>> allServiceHandles = habitat.getAllServiceHandles(BaseNotifierService.class);
    if (configuration.getNotifierList().isEmpty()) {
        notifiersActionReport.setMessage("No notifier defined");
    } else {
        String[] headers = { "Notifier Name", "Notifier Enabled" };
        ColumnFormatter columnFormatter = new ColumnFormatter(headers);
        List<Class<Notifier>> notifierClassList = Lists.transform(configuration.getNotifierList(), new Function<Notifier, Class<Notifier>>() {

            @Override
            public Class<Notifier> apply(Notifier input) {
                return resolveNotifierClass(input);
            }
        });
        Properties notifierExtraProps = new Properties();
        for (ServiceHandle<BaseNotifierService> serviceHandle : allServiceHandles) {
            Notifier notifier = configuration.getNotifierByType(serviceHandle.getService().getNotifierType());
            if (notifier != null) {
                ConfigView view = ConfigSupport.getImpl(notifier);
                NotifierConfigurationType annotation = view.getProxyType().getAnnotation(NotifierConfigurationType.class);
                if (notifierClassList.contains(view.<Notifier>getProxyType())) {
                    Object[] values = new Object[2];
                    values[0] = serviceHandle.getActiveDescriptor().getName();
                    values[1] = notifier.getEnabled();
                    columnFormatter.addRow(values);
                    Map<String, Object> notifierExtraPropsMap = new HashMap<>();
                    notifierExtraPropsMap.put("notifierName", values[0]);
                    notifierExtraPropsMap.put("notifierEnabled", values[1]);
                    notifierExtraProps.put("getRequesttracingConfiguration" + annotation.type(), notifierExtraPropsMap);
                    notifiersActionReport.setExtraProperties(notifierExtraProps);
                }
            }
        }
        notifiersActionReport.setMessage(columnFormatter.toString());
    }
    mainActionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : NotifierConfigurationType(fish.payara.nucleus.notification.configuration.NotifierConfigurationType) HashMap(java.util.HashMap) ConfigView(org.jvnet.hk2.config.ConfigView) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties) BaseNotifierService(fish.payara.nucleus.notification.service.BaseNotifierService) ServiceHandle(org.glassfish.hk2.api.ServiceHandle) RequestTracingServiceConfiguration(fish.payara.nucleus.requesttracing.configuration.RequestTracingServiceConfiguration) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter) Notifier(fish.payara.nucleus.notification.configuration.Notifier)

Example 3 with Context

use of org.glassfish.hk2.api.Context in project Payara by payara.

the class GetHealthCheckConfiguration method execute.

@Override
public void execute(AdminCommandContext context) {
    Config config = targetUtil.getConfig(target);
    if (config == null) {
        context.getActionReport().setMessage("No such config named: " + target);
        context.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    ActionReport mainActionReport = context.getActionReport();
    // subReport(0)
    ActionReport baseActionReport = mainActionReport.addSubActionsReport();
    // subReport(1)
    ActionReport hoggingThreadsActionReport = mainActionReport.addSubActionsReport();
    // subReport(2)
    ActionReport thresholdDiagnosticsActionReport = mainActionReport.addSubActionsReport();
    // subReport(3)
    ActionReport stuckThreadsActionReport = mainActionReport.addSubActionsReport();
    ColumnFormatter baseColumnFormatter = new ColumnFormatter(baseHeaders);
    ColumnFormatter hoggingThreadsColumnFormatter = new ColumnFormatter(hoggingThreadsHeaders);
    ColumnFormatter stuckThreadsColumnFormatter = new ColumnFormatter(stuckThreadsHeaders);
    ColumnFormatter thresholdDiagnosticsColumnFormatter = new ColumnFormatter(thresholdDiagnosticsHeaders);
    ColumnFormatter notifiersColumnFormatter = new ColumnFormatter(notifierHeaders);
    HealthCheckServiceConfiguration configuration = config.getExtensionByType(HealthCheckServiceConfiguration.class);
    List<ServiceHandle<BaseHealthCheck>> allServiceHandles = habitat.getAllServiceHandles(BaseHealthCheck.class);
    List<ServiceHandle<BaseNotifierService>> allNotifierServiceHandles = habitat.getAllServiceHandles(BaseNotifierService.class);
    mainActionReport.appendMessage("Health Check Service Configuration is enabled?: " + configuration.getEnabled() + "\n");
    if (Boolean.parseBoolean(configuration.getEnabled())) {
        mainActionReport.appendMessage("Historical Tracing Enabled?: " + configuration.getHistoricalTraceEnabled() + "\n");
        if (Boolean.parseBoolean(configuration.getHistoricalTraceEnabled())) {
            mainActionReport.appendMessage("Historical Tracing Store Size: " + configuration.getHistoricalTraceStoreSize() + "\n");
        }
        if (!Strings.isNullOrEmpty(configuration.getHistoricalTraceStoreTimeout())) {
            mainActionReport.appendMessage("Health Check Historical Tracing Store Timeout in Seconds: " + configuration.getHistoricalTraceStoreTimeout() + "\n");
        }
    }
    // Create the extraProps map for the general healthcheck configuration
    Properties mainExtraProps = new Properties();
    Map<String, Object> mainExtraPropsMap = new HashMap<>();
    mainExtraPropsMap.put("enabled", configuration.getEnabled());
    mainExtraPropsMap.put("historicalTraceEnabled", configuration.getHistoricalTraceEnabled());
    mainExtraPropsMap.put("historicalTraceStoreSize", configuration.getHistoricalTraceStoreSize());
    mainExtraPropsMap.put("historicalTraceStoreTimeout", configuration.getHistoricalTraceStoreTimeout());
    mainExtraProps.put("healthcheckConfiguration", mainExtraPropsMap);
    mainActionReport.setExtraProperties(mainExtraProps);
    if (!configuration.getNotifierList().isEmpty()) {
        List<Class<Notifier>> notifierClassList = Lists.transform(configuration.getNotifierList(), new Function<Notifier, Class<Notifier>>() {

            @Override
            public Class<Notifier> apply(Notifier input) {
                return resolveNotifierClass(input);
            }
        });
        Properties extraProps = new Properties();
        for (ServiceHandle<BaseNotifierService> serviceHandle : allNotifierServiceHandles) {
            Notifier notifier = configuration.getNotifierByType(serviceHandle.getService().getNotifierType());
            if (notifier != null) {
                ConfigView view = ConfigSupport.getImpl(notifier);
                NotifierConfigurationType annotation = view.getProxyType().getAnnotation(NotifierConfigurationType.class);
                if (notifierClassList.contains(view.<Notifier>getProxyType())) {
                    Object[] values = new Object[2];
                    values[0] = annotation.type();
                    values[1] = notifier.getEnabled();
                    notifiersColumnFormatter.addRow(values);
                    Map<String, Object> map = new HashMap<>(2);
                    map.put("notifierName", values[0]);
                    map.put("notifierEnabled", values[1]);
                    extraProps.put("notifierList" + annotation.type(), map);
                }
            }
        }
        mainActionReport.getExtraProperties().putAll(extraProps);
        mainActionReport.appendMessage(notifiersColumnFormatter.toString());
        mainActionReport.appendMessage(StringUtils.EOL);
    }
    mainActionReport.appendMessage("Below are the list of configuration details of each checker listed by its name.");
    mainActionReport.appendMessage(StringUtils.EOL);
    Properties baseExtraProps = new Properties();
    Properties hoggingThreadsExtraProps = new Properties();
    Properties stuckThreadsExtrasProps = new Properties();
    Properties thresholdDiagnosticsExtraProps = new Properties();
    for (ServiceHandle<BaseHealthCheck> serviceHandle : allServiceHandles) {
        Checker checker = configuration.getCheckerByType(serviceHandle.getService().getCheckerType());
        if (checker instanceof HoggingThreadsChecker) {
            HoggingThreadsChecker hoggingThreadsChecker = (HoggingThreadsChecker) checker;
            Object[] values = new Object[6];
            values[0] = hoggingThreadsChecker.getName();
            values[1] = hoggingThreadsChecker.getEnabled();
            values[2] = hoggingThreadsChecker.getTime();
            values[3] = hoggingThreadsChecker.getUnit();
            values[4] = hoggingThreadsChecker.getThresholdPercentage();
            values[5] = hoggingThreadsChecker.getRetryCount();
            hoggingThreadsColumnFormatter.addRow(values);
            // Create the extra props map for a hogging thread checker
            addHoggingThreadsCheckerExtraProps(hoggingThreadsExtraProps, hoggingThreadsChecker);
        } else if (checker instanceof ThresholdDiagnosticsChecker) {
            ThresholdDiagnosticsChecker thresholdDiagnosticsChecker = (ThresholdDiagnosticsChecker) checker;
            Object[] values = new Object[7];
            values[0] = thresholdDiagnosticsChecker.getName();
            values[1] = thresholdDiagnosticsChecker.getEnabled();
            values[2] = thresholdDiagnosticsChecker.getTime();
            values[3] = thresholdDiagnosticsChecker.getUnit();
            Property thresholdCriticalProperty = thresholdDiagnosticsChecker.getProperty(THRESHOLD_CRITICAL);
            values[4] = thresholdCriticalProperty != null ? thresholdCriticalProperty.getValue() : "-";
            Property thresholdWarningProperty = thresholdDiagnosticsChecker.getProperty(THRESHOLD_WARNING);
            values[5] = thresholdWarningProperty != null ? thresholdWarningProperty.getValue() : "-";
            Property thresholdGoodProperty = thresholdDiagnosticsChecker.getProperty(THRESHOLD_GOOD);
            values[6] = thresholdGoodProperty != null ? thresholdGoodProperty.getValue() : "-";
            thresholdDiagnosticsColumnFormatter.addRow(values);
            // Create the extra props map for a checker with thresholds
            addThresholdDiagnosticsCheckerExtraProps(thresholdDiagnosticsExtraProps, thresholdDiagnosticsChecker);
        } else if (checker instanceof StuckThreadsChecker) {
            StuckThreadsChecker stuckThreadsChecker = (StuckThreadsChecker) checker;
            Object[] values = new Object[6];
            values[0] = stuckThreadsChecker.getName();
            values[1] = stuckThreadsChecker.getEnabled();
            values[2] = stuckThreadsChecker.getTime();
            values[3] = stuckThreadsChecker.getUnit();
            values[4] = stuckThreadsChecker.getThreshold();
            values[5] = stuckThreadsChecker.getThresholdTimeUnit();
            stuckThreadsColumnFormatter.addRow(values);
            addStuckThreadsCheckerExtrasProps(stuckThreadsExtrasProps, stuckThreadsChecker);
        } else if (checker != null) {
            Object[] values = new Object[4];
            values[0] = checker.getName();
            values[1] = checker.getEnabled();
            values[2] = checker.getTime();
            values[3] = checker.getUnit();
            baseColumnFormatter.addRow(values);
            // Create the extra props map for a base checker
            addBaseCheckerExtraProps(baseExtraProps, checker);
        }
    }
    if (!baseColumnFormatter.getContent().isEmpty()) {
        baseActionReport.setMessage(baseColumnFormatter.toString());
        baseActionReport.appendMessage(StringUtils.EOL);
    }
    if (!hoggingThreadsColumnFormatter.getContent().isEmpty()) {
        hoggingThreadsActionReport.setMessage(hoggingThreadsColumnFormatter.toString());
        hoggingThreadsActionReport.appendMessage(StringUtils.EOL);
    }
    if (!thresholdDiagnosticsColumnFormatter.getContent().isEmpty()) {
        thresholdDiagnosticsActionReport.setMessage(thresholdDiagnosticsColumnFormatter.toString());
        thresholdDiagnosticsActionReport.appendMessage(StringUtils.EOL);
    }
    if (!stuckThreadsColumnFormatter.getContent().isEmpty()) {
        stuckThreadsActionReport.setMessage(stuckThreadsColumnFormatter.toString());
        stuckThreadsActionReport.appendMessage(StringUtils.EOL);
    }
    // Populate the extraProps with defaults for any checker that isn't present
    baseExtraProps = checkCheckerPropertyPresence(thresholdDiagnosticsExtraProps, garbageCollectorPropertyName);
    hoggingThreadsExtraProps = checkCheckerPropertyPresence(hoggingThreadsExtraProps, hoggingThreadsPropertyName);
    stuckThreadsExtrasProps = checkCheckerPropertyPresence(stuckThreadsExtrasProps, stuckThreadsPropertyName);
    thresholdDiagnosticsExtraProps = checkCheckerPropertyPresence(thresholdDiagnosticsExtraProps, cpuUsagePropertyName);
    thresholdDiagnosticsExtraProps = checkCheckerPropertyPresence(thresholdDiagnosticsExtraProps, connectionPoolPropertyName);
    thresholdDiagnosticsExtraProps = checkCheckerPropertyPresence(thresholdDiagnosticsExtraProps, heapMemoryUsagePropertyName);
    thresholdDiagnosticsExtraProps = checkCheckerPropertyPresence(thresholdDiagnosticsExtraProps, machineMemoryUsagePropertyName);
    // Add the extra props to their respective action reports
    baseActionReport.setExtraProperties(baseExtraProps);
    hoggingThreadsActionReport.setExtraProperties(hoggingThreadsExtraProps);
    thresholdDiagnosticsActionReport.setExtraProperties(thresholdDiagnosticsExtraProps);
    stuckThreadsActionReport.setExtraProperties(stuckThreadsExtrasProps);
    mainActionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : HashMap(java.util.HashMap) ConfigView(org.jvnet.hk2.config.ConfigView) Config(com.sun.enterprise.config.serverbeans.Config) HealthCheckServiceConfiguration(fish.payara.nucleus.healthcheck.configuration.HealthCheckServiceConfiguration) ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties) Property(org.jvnet.hk2.config.types.Property) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter) Notifier(fish.payara.nucleus.notification.configuration.Notifier) HoggingThreadsChecker(fish.payara.nucleus.healthcheck.configuration.HoggingThreadsChecker) StuckThreadsChecker(fish.payara.nucleus.healthcheck.configuration.StuckThreadsChecker) Checker(fish.payara.nucleus.healthcheck.configuration.Checker) ThresholdDiagnosticsChecker(fish.payara.nucleus.healthcheck.configuration.ThresholdDiagnosticsChecker) NotifierConfigurationType(fish.payara.nucleus.notification.configuration.NotifierConfigurationType) BaseHealthCheck(fish.payara.nucleus.healthcheck.preliminary.BaseHealthCheck) ThresholdDiagnosticsChecker(fish.payara.nucleus.healthcheck.configuration.ThresholdDiagnosticsChecker) BaseNotifierService(fish.payara.nucleus.notification.service.BaseNotifierService) HoggingThreadsChecker(fish.payara.nucleus.healthcheck.configuration.HoggingThreadsChecker) StuckThreadsChecker(fish.payara.nucleus.healthcheck.configuration.StuckThreadsChecker) ServiceHandle(org.glassfish.hk2.api.ServiceHandle)

Example 4 with Context

use of org.glassfish.hk2.api.Context in project Payara by payara.

the class HealthCheckServiceLister method execute.

@Override
public void execute(AdminCommandContext context) {
    ColumnFormatter serviceListerColumnFormatter = new ColumnFormatter(serviceHeaders);
    final ActionReport report = context.getActionReport();
    List<ServiceHandle<BaseHealthCheck>> allServiceHandles = habitat.getAllServiceHandles(BaseHealthCheck.class);
    if (allServiceHandles.isEmpty()) {
        report.appendMessage(strings.getLocalString("healthcheck.list.services.warning", "No registered health check service found."));
        report.setActionExitCode(ActionReport.ExitCode.WARNING);
    } else {
        StringBuffer sb = new StringBuffer();
        sb.append(strings.getLocalString("healthcheck.list.services.availability.info", "Available Health Check Services") + ":\n");
        for (ServiceHandle<BaseHealthCheck> serviceHandle : allServiceHandles) {
            Object[] values = new Object[2];
            values[0] = serviceHandle.getActiveDescriptor().getName();
            values[1] = serviceHandle.getService().resolveDescription();
            serviceListerColumnFormatter.addRow(values);
        }
        sb.append(serviceListerColumnFormatter.toString());
        report.setMessage(sb.toString());
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    }
}
Also used : ServiceHandle(org.glassfish.hk2.api.ServiceHandle) BaseHealthCheck(fish.payara.nucleus.healthcheck.preliminary.BaseHealthCheck) ActionReport(org.glassfish.api.ActionReport) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 5 with Context

use of org.glassfish.hk2.api.Context in project Payara by payara.

the class MicroGlassFishRuntime method newGlassFish.

@Override
public GlassFish newGlassFish(GlassFishProperties glassfishProperties) throws GlassFishException {
    System.setProperty("com.sun.aas.installRoot", System.getProperty("com.sun.aas.instanceRoot"));
    System.setProperty("com.sun.aas.installRootURI", System.getProperty("com.sun.aas.instanceRootURI"));
    glassfishProperties.setProperty("com.sun.aas.installRoot", System.getProperty("com.sun.aas.instanceRoot"));
    glassfishProperties.setProperty("com.sun.aas.installRootURI", System.getProperty("com.sun.aas.instanceRootURI"));
    StartupContext context = new StartupContext(glassfishProperties.getProperties());
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    SingleHK2Factory.initialize(tccl);
    registry = new SingleModulesRegistry(tccl);
    registry.setParentClassLoader(tccl);
    habitat = registry.newServiceLocator();
    DynamicConfigurationService dcs = habitat.getService(DynamicConfigurationService.class);
    DynamicConfiguration config = dcs.createDynamicConfiguration();
    config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(context));
    config.commit();
    registry.populateServiceLocator("default", habitat, Arrays.asList(new PayaraMicroInhabitantsParser(), new EmbeddedInhabitantsParser(), new DuplicatePostProcessor()));
    registry.populateConfig(habitat);
    ModuleStartup kernel = habitat.getService(ModuleStartup.class);
    gf = new MicroGlassFish(kernel, habitat, glassfishProperties.getProperties());
    return gf;
}
Also used : StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) DynamicConfigurationService(org.glassfish.hk2.api.DynamicConfigurationService) SingleModulesRegistry(com.sun.enterprise.module.single.SingleModulesRegistry) DynamicConfiguration(org.glassfish.hk2.api.DynamicConfiguration) DuplicatePostProcessor(org.glassfish.hk2.utilities.DuplicatePostProcessor) EmbeddedInhabitantsParser(com.sun.enterprise.glassfish.bootstrap.EmbeddedInhabitantsParser) ModuleStartup(com.sun.enterprise.module.bootstrap.ModuleStartup)

Aggregations

ActionReport (org.glassfish.api.ActionReport)12 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)12 IOException (java.io.IOException)11 Properties (java.util.Properties)8 ArrayList (java.util.ArrayList)7 MultiException (org.glassfish.hk2.api.MultiException)7 ServiceHandle (org.glassfish.hk2.api.ServiceHandle)7 Config (com.sun.enterprise.config.serverbeans.Config)6 PropertyVetoException (java.beans.PropertyVetoException)6 VersioningSyntaxException (org.glassfish.deployment.versioning.VersioningSyntaxException)6 Types (org.glassfish.hk2.classmodel.reflect.Types)6 RetryableException (org.jvnet.hk2.config.RetryableException)6 Logger (java.util.logging.Logger)5 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)5 ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)4 ServletContext (javax.servlet.ServletContext)4 TargetType (org.glassfish.config.support.TargetType)4 Notifier (fish.payara.nucleus.notification.configuration.Notifier)3 NotifierConfigurationType (fish.payara.nucleus.notification.configuration.NotifierConfigurationType)3 BaseNotifierService (fish.payara.nucleus.notification.service.BaseNotifierService)3