Search in sources :

Example 16 with Service

use of org.jvnet.hk2.annotations.Service in project Payara by payara.

the class HttpServiceStatsProviderBootstrap method postConstruct.

@Override
public void postConstruct() {
    if (config == null) {
        Object[] params = { VirtualServerInfoStatsProvider.class.getName(), HttpServiceStatsProvider.class.getName(), "http service", "virtual server" };
        logger.log(Level.SEVERE, LogFacade.UNABLE_TO_REGISTER_STATS_PROVIDERS, params);
        throw new ConfigurationException(rb.getString(LogFacade.NULL_CONFIG));
    }
    HttpService httpService = config.getHttpService();
    for (VirtualServer vs : httpService.getVirtualServer()) {
        String id = vs.getId();
        StatsProviderManager.register("http-service", PluginPoint.SERVER, "http-service/" + id, new VirtualServerInfoStatsProvider(vs));
        HttpServiceStatsProvider httpServiceStatsProvider = new HttpServiceStatsProvider(id, vs.getNetworkListeners(), config.getNetworkConfig());
        httpServiceStatsProviders.put(id, httpServiceStatsProvider);
        StatsProviderManager.register("http-service", PluginPoint.SERVER, "http-service/" + id + "/request", httpServiceStatsProvider);
    }
}
Also used : ConfigurationException(org.jvnet.hk2.config.ConfigurationException) HttpService(com.sun.enterprise.config.serverbeans.HttpService) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer)

Example 17 with Service

use of org.jvnet.hk2.annotations.Service in project Payara by payara.

the class VirtualServer method configureAuthRealm.

/**
 * Configures this virtual server with its authentication realm.
 *
 * Checks if this virtual server specifies any authRealm property, and if so, ensures that its value identifies a valid
 * realm.
 *
 * @param securityService The security-service element from domain.xml
 */
void configureAuthRealm(SecurityService securityService) {
    _logger.finest(() -> String.format("configureAuthRealm(securityService=%s)", securityService));
    List<Property> properties = vsBean.getProperty();
    if (properties != null && !properties.isEmpty()) {
        for (Property property : properties) {
            if (property != null && "authRealm".equals(property.getName())) {
                authRealmName = property.getValue();
                if (authRealmName != null) {
                    AuthRealm validAuthRealm = null;
                    List<AuthRealm> authRealms = securityService.getAuthRealm();
                    if (authRealms != null && authRealms.size() > 0) {
                        for (AuthRealm authRealm : authRealms) {
                            if (authRealm != null && authRealm.getName().equals(authRealmName)) {
                                _logger.config(() -> "Using realm '" + authRealmName + "' for the security service '" + securityService + "'");
                                validAuthRealm = authRealm;
                                break;
                            }
                        }
                    }
                    if (validAuthRealm == null) {
                        _logger.log(SEVERE, INVALID_AUTH_REALM, new Object[] { getID(), authRealmName });
                    }
                }
                break;
            }
        }
    }
}
Also used : AuthRealm(com.sun.enterprise.config.serverbeans.AuthRealm) Property(org.jvnet.hk2.config.types.Property)

Example 18 with Service

use of org.jvnet.hk2.annotations.Service in project Payara by payara.

the class WebContainer method createHost.

/**
 * Creates a Host from a virtual-server config bean.
 *
 * @param vsBean The virtual-server configuration bean
 * @param httpService The http-service element.
 * @param securityService The security-service element
 * @return
 */
public VirtualServer createHost(com.sun.enterprise.config.serverbeans.VirtualServer vsBean, HttpService httpService, SecurityService securityService) {
    String virtualServerId = vsBean.getId();
    String docroot = vsBean.getPropertyValue("docroot");
    if (docroot == null) {
        docroot = vsBean.getDocroot();
    }
    validateDocroot(docroot, virtualServerId, vsBean.getDefaultWebModule());
    VirtualServer virtualServer = createHost(virtualServerId, vsBean, docroot, null);
    // cache control
    Property cacheProp = vsBean.getProperty("setCacheControl");
    if (cacheProp != null) {
        virtualServer.configureCacheControl(cacheProp.getValue());
    }
    PEAccessLogValve accessLogValve = virtualServer.getAccessLogValve();
    boolean startAccessLog = accessLogValve.configure(virtualServerId, vsBean, httpService, domain, serviceLocator, webContainerFeatureFactory, globalAccessLogBufferSize, globalAccessLogWriteInterval, globalAccessLogPrefix);
    if (startAccessLog && virtualServer.isAccessLoggingEnabled(globalAccessLoggingEnabled)) {
        virtualServer.addValve((GlassFishValve) accessLogValve);
    }
    logger.log(FINEST, VIRTUAL_SERVER_CREATED, virtualServerId);
    /*
         * We must configure the Host with its associated port numbers and alias names before adding it as an engine child and
         * thereby starting it, because a MapperListener, which is associated with an HTTP listener and receives notifications
         * about Host registrations, relies on these Host properties in order to determine whether a new Host needs to be added
         * to the HTTP listener's Mapper.
         */
    configureHost(virtualServer, securityService);
    virtualServer.setDomain(domain);
    virtualServer.setServices(serviceLocator);
    virtualServer.setClassLoaderHierarchy(classLoaderHierarchy);
    // Add Host to Engine
    engine.addChild(virtualServer);
    ObservableBean virtualServerBean = (ObservableBean) ConfigSupport.getImpl(vsBean);
    virtualServerBean.addListener(configListener);
    return virtualServer;
}
Also used : ObservableBean(org.jvnet.hk2.config.ObservableBean) Property(org.jvnet.hk2.config.types.Property) SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty)

Example 19 with Service

use of org.jvnet.hk2.annotations.Service in project Payara by payara.

the class WebContainer method configureHttpServiceProperties.

/**
 * Configure http-service properties.
 *
 * @param httpService
 * @param connector
 * @deprecated most of these properties are handled elsewhere. validate and remove outdated properties checks
 */
@Deprecated
public void configureHttpServiceProperties(HttpService httpService, PECoyoteConnector connector) {
    // Configure Connector with <http-service> properties
    List<Property> httpServiceProps = httpService.getProperty();
    // Set default ProxyHandler impl, may be overriden by
    // proxyHandler property
    connector.setProxyHandler(new ProxyHandlerImpl());
    globalSSOEnabled = ConfigBeansUtilities.toBoolean(httpService.getSsoEnabled());
    globalAccessLoggingEnabled = ConfigBeansUtilities.toBoolean(httpService.getAccessLoggingEnabled());
    globalAccessLogWriteInterval = httpService.getAccessLog().getWriteIntervalSeconds();
    globalAccessLogBufferSize = httpService.getAccessLog().getBufferSizeBytes();
    globalAccessLogPrefix = httpService.getAccessLog().getPropertyValue(Constants.ACCESS_LOG_PREFIX);
    if (httpServiceProps != null) {
        for (Property httpServiceProp : httpServiceProps) {
            String propName = httpServiceProp.getName();
            String propValue = httpServiceProp.getValue();
            if (connector.configureHttpListenerProperty(propName, propValue)) {
                continue;
            }
            if ("connectionTimeout".equals(propName)) {
                connector.setConnectionTimeout(Integer.parseInt(propValue));
            } else if ("tcpNoDelay".equals(propName)) {
                connector.setTcpNoDelay(ConfigBeansUtilities.toBoolean(propValue));
            } else if ("traceEnabled".equals(propName)) {
                connector.setAllowTrace(ConfigBeansUtilities.toBoolean(propValue));
            } else if ("ssl-session-timeout".equals(propName)) {
                connector.setSslSessionTimeout(propValue);
            } else if ("ssl3-session-timeout".equals(propName)) {
                connector.setSsl3SessionTimeout(propValue);
            } else if ("ssl-cache-entries".equals(propName)) {
                connector.setSslSessionCacheSize(propValue);
            } else if ("proxyHandler".equals(propName)) {
                connector.setProxyHandler(propValue);
            } else {
                String msg = rb.getString(LogFacade.INVALID_HTTP_SERVICE_PROPERTY);
                logger.log(Level.WARNING, MessageFormat.format(msg, httpServiceProp.getName()));
            }
        }
    }
}
Also used : Property(org.jvnet.hk2.config.types.Property) SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty)

Example 20 with Service

use of org.jvnet.hk2.annotations.Service in project Payara by payara.

the class ParentTest method parents.

@Test
public void parents() {
    NetworkListeners service = getHabitat().getService(NetworkListeners.class);
    assertNotNull(service);
    NetworkListener listener = service.getNetworkListener().get(0);
    assertNotNull(listener);
    ConfigBeanProxy parent = service.getParent();
    assertNotNull(parent);
    NetworkListeners myService = listener.getParent(NetworkListeners.class);
    assertNotNull(myService);
    assertNotNull(myService.getNetworkListener().get(0).getName());
}
Also used : ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) NetworkListeners(org.glassfish.grizzly.config.dom.NetworkListeners) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener) Test(org.junit.Test)

Aggregations

TransactionFailure (org.jvnet.hk2.config.TransactionFailure)34 PropertyVetoException (java.beans.PropertyVetoException)26 ActionReport (org.glassfish.api.ActionReport)25 Config (com.sun.enterprise.config.serverbeans.Config)21 Property (org.jvnet.hk2.config.types.Property)17 ArrayList (java.util.ArrayList)9 Properties (java.util.Properties)9 HealthCheckServiceConfiguration (fish.payara.nucleus.healthcheck.configuration.HealthCheckServiceConfiguration)7 Service (org.jvnet.hk2.annotations.Service)7 File (java.io.File)6 HashMap (java.util.HashMap)6 List (java.util.List)6 PropertyChangeEvent (java.beans.PropertyChangeEvent)5 StuckThreadsChecker (fish.payara.nucleus.healthcheck.configuration.StuckThreadsChecker)4 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)4 ObservableBean (org.jvnet.hk2.config.ObservableBean)4 SingleConfigCode (org.jvnet.hk2.config.SingleConfigCode)4 Transactions (org.jvnet.hk2.config.Transactions)4 UnprocessedChangeEvent (org.jvnet.hk2.config.UnprocessedChangeEvent)4 UnprocessedChangeEvents (org.jvnet.hk2.config.UnprocessedChangeEvents)4