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);
}
}
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;
}
}
}
}
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;
}
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()));
}
}
}
}
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());
}
Aggregations