use of org.jvnet.hk2.config.Configured in project Payara by payara.
the class BasePersistenceStrategyBuilder method readInstanceLevelParams.
public void readInstanceLevelParams(ServerConfigLookup serverConfigLookup) {
org.glassfish.web.config.serverbeans.SessionManager smBean = serverConfigLookup.getInstanceSessionManager();
if (smBean != null) {
// The persistence-type controls what properties of the
// session manager can be configured
org.glassfish.web.config.serverbeans.ManagerProperties mgrBean = smBean.getManagerProperties();
if (mgrBean != null) {
// manager reap-interval-in-seconds
String reapIntervalInSecondsString = mgrBean.getReapIntervalInSeconds();
if (reapIntervalInSecondsString != null) {
try {
reapInterval = Integer.parseInt(reapIntervalInSecondsString);
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, LogFacade.MANAGER_REAP_INTERVAL_SET, reapInterval);
}
} catch (NumberFormatException e) {
// XXX need error message
}
} else {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, LogFacade.NO_INSTANCE_LEVEL_VALUE_SET_MGR_REAP_INTERVAL);
}
}
// max-sessions
String maxSessionsString = mgrBean.getMaxSessions();
if (maxSessionsString != null) {
try {
maxSessions = Integer.parseInt(maxSessionsString);
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, LogFacade.MAX_SESSIONS_SET, maxSessions);
}
} catch (NumberFormatException e) {
// XXX need error message
}
} else {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, LogFacade.NO_INSTANCE_LEVEL_VALUE_SET_MAX_SESSIONS);
}
}
// session-file-name
String sessionFilenameString = mgrBean.getSessionFileName();
if (sessionFilenameString != null) {
sessionFilename = sessionFilenameString;
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, LogFacade.SESSION_FILENAME_SET, sessionFilename);
}
}
// START CR 6275709
sessionIdGeneratorClassname = mgrBean.getSessionIdGeneratorClassname();
if (sessionIdGeneratorClassname != null && _logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, LogFacade.SESSION_ID_GENERATOR_CLASSNAME_SET, sessionIdGeneratorClassname);
}
// END CR 6275709
// Now do properties under <manager-properties> element
List<Property> props = mgrBean.getProperty();
if (props != null) {
for (Property prop : props) {
String name = prop.getName();
String value = prop.getValue();
// maxIdleBackupSeconds
if (name.equalsIgnoreCase("maxIdleBackupSeconds")) {
try {
maxIdleBackup = Integer.parseInt(value);
} catch (NumberFormatException e) {
// XXX need error message
}
} else if (name.equalsIgnoreCase(MIN_IDLE_SWAP_PROPERTY)) {
try {
minIdleSwap = Integer.parseInt(value);
} catch (NumberFormatException e) {
// XXX need error message
}
} else if (name.equalsIgnoreCase(MAX_IDLE_SWAP_PROPERTY)) {
try {
maxIdleSwap = Integer.parseInt(value);
} catch (NumberFormatException e) {
// XXX need error message
}
}
}
}
}
org.glassfish.web.config.serverbeans.StoreProperties storeBean = smBean.getStoreProperties();
if (storeBean != null) {
// Store reap-interval-in-seconds
String reapIntervalInSecondsString = storeBean.getReapIntervalInSeconds();
if (reapIntervalInSecondsString != null) {
try {
storeReapInterval = Integer.parseInt(reapIntervalInSecondsString);
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, LogFacade.STORE_REAP_INTERVAL_SET, storeReapInterval);
}
} catch (NumberFormatException e) {
// XXX need error message
}
}
// Directory
String directoryString = storeBean.getDirectory();
if (directoryString != null) {
directory = directoryString;
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, LogFacade.DIRECTORY_SET, directoryString);
}
}
}
}
SessionProperties spBean = serverConfigLookup.getInstanceSessionProperties();
if (spBean != null) {
// session timeout-in-seconds
String timeoutSecondsString = spBean.getTimeoutInSeconds();
if (timeoutSecondsString != null) {
try {
sessionMaxInactiveInterval = Integer.parseInt(timeoutSecondsString);
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, LogFacade.SESSION_MAX_INACTIVE_INTERVAL_SET, sessionMaxInactiveInterval);
}
} catch (NumberFormatException e) {
// XXX need error message
}
} else {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, LogFacade.NO_INSTANCE_LEVEL_VALUE_SET_SESSION_MAX_INACTIVE_INTERVAL);
}
}
}
}
use of org.jvnet.hk2.config.Configured in project Payara by payara.
the class ConfigApiTest method getHabitat.
/**
* Returns a configured Habitat with the configuration.
*
* @return a configured Habitat
*/
public ServiceLocator getHabitat() {
ServiceLocator habitat = Utils.instance.getHabitat(this);
assertNotNull("Transactions service from Configuration subsystem is null", habitat.getService(Transactions.class));
return habitat;
}
use of org.jvnet.hk2.config.Configured in project Payara by payara.
the class LDAPAdminAccessConfigurator method pingLDAP.
private boolean pingLDAP(StringBuilder sb) {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, url);
if (url != null && url.startsWith(LDAPS_URL)) {
env.put(LDAP_SOCKET_FACTORY, DEFAULT_SSL_LDAP_SOCKET_FACTORY);
}
try {
new InitialContext(env);
appendNL(sb, lsm.getString("ldap.ok", url));
return true;
} catch (AuthenticationNotSupportedException anse) {
// CR 6944776
// If the server throws this error, it is up
// and is configured with Anonymous bind disabled.
// Ignore this error while configuring ldap for admin
appendNL(sb, lsm.getString("ldap.ok", url));
return true;
} catch (Exception e) {
appendNL(sb, lsm.getString("ldap.na", url, e.getClass().getName(), e.getMessage()));
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, StringUtils.getStackTrace(e));
}
return false;
}
}
use of org.jvnet.hk2.config.Configured in project Payara by payara.
the class ConfigBeanJMXSupport method getTypesImplementing.
/**
* works only for @Configured types
*/
public static Class[] getTypesImplementing(final Class<?> clazz) {
final DomDocument domDoc = new DomDocument(InjectedValues.getInstance().getHabitat());
try {
final List<ConfigModel> models = domDoc.getAllModelsImplementing(clazz);
final Class[] interfaces = new Class[models == null ? 0 : models.size()];
if (models != null) {
int i = 0;
for (final ConfigModel model : models) {
final String classname = model.targetTypeName;
final Class<?> intf = model.classLoaderHolder.loadClass(classname);
interfaces[i] = intf;
++i;
}
}
return interfaces;
} catch (final Exception e) {
AMXLoggerInfo.getLogger().log(Level.INFO, AMXLoggerInfo.cantGetTypesImplementing, new Object[] { clazz, e.getLocalizedMessage() });
throw new RuntimeException(e);
}
}
use of org.jvnet.hk2.config.Configured in project Payara by payara.
the class ListFileGroup method getFileRealm.
private FileRealm getFileRealm(final SecurityService securityService, AuthRealm fileAuthRealm, ActionReport report) {
// Get FileRealm class name, match it with what is expected.
String fileRealmClassName = fileAuthRealm.getClassname();
// Report error if provided impl is not the one expected
if (fileRealmClassName != null && !fileRealmClassName.equals("com.sun.enterprise.security.auth.realm.file.FileRealm")) {
report.setMessage(localStrings.getLocalString("list.file.user.realmnotsupported", "Configured file realm {0} is not supported.", fileRealmClassName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return null;
}
// ensure we have the file associated with the authrealm
String keyFile = null;
for (Property fileProp : fileAuthRealm.getProperty()) {
if (fileProp.getName().equals("file"))
keyFile = fileProp.getValue();
}
if (keyFile == null) {
report.setMessage(localStrings.getLocalString("list.file.user.keyfilenotfound", "There is no physical file associated with this file realm {0} ", authRealmName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return null;
}
// We have the right impl so let's try to remove one
FileRealm fr = null;
try {
realmsManager.createRealms(config);
fr = (FileRealm) realmsManager.getFromLoadedRealms(config.getName(), authRealmName);
if (fr == null) {
throw new NoSuchRealmException(authRealmName);
}
} catch (NoSuchRealmException e) {
report.setMessage(localStrings.getLocalString("list.file.user.realmnotsupported", "Configured file realm {0} is not supported.", authRealmName) + " " + e.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
return fr;
}
Aggregations