use of org.apache.derby.iapi.services.monitor.ModuleFactory in project derby by apache.
the class DataValueFactoryImpl method boot.
/*
** ModuleControl methods.
*/
/* (non-Javadoc)
* @see org.apache.derby.iapi.services.monitor.ModuleControl#boot(boolean, java.util.Properties)
*/
public void boot(boolean create, Properties properties) throws StandardException {
ModuleFactory monitor = getMonitor();
// The Locale on monitor has already been set by the boot code in
// BasicDatabase so we can simply do a get here.
// This Locale will be either the Locale obtained from the territory
// attribute supplied by the user on the JDBC url at database create
// time or if user didn't provide the territory attribute at database
// create time, then it will be set to the default JVM locale. The
// Locale object will be used to construct the Collator object which
// will be used if user has requested territory based collation.
databaseLocale = monitor.getLocale(this);
// user has executed a SQL which requires collation operation.
if (create) {
// Get the collation property from the JDBC url(this will be
// available only during database create time). It can only have
// one of the 2 possible values - UCS_BASIC or TERRITORY_BASED.
// This property can only be specified at database create time.
// If the user has requested for territory based database, then
// verify that JVM has Collator support for the database locale.
String userDefinedCollation = properties.getProperty(Attribute.COLLATION);
if (userDefinedCollation != null) {
// Invalid value handling
int collationType = DataTypeDescriptor.getCollationType(userDefinedCollation);
if (collationType != StringDataValue.COLLATION_TYPE_UCS_BASIC) {
if (collationType >= StringDataValue.COLLATION_TYPE_TERRITORY_BASED && collationType < StringDataValue.COLLATION_TYPE_TERRITORY_BASED_IDENTICAL) {
int strength = collationType - StringDataValue.COLLATION_TYPE_TERRITORY_BASED_PRIMARY;
collatorForCharacterTypes = verifyCollatorSupport(strength);
} else
throw StandardException.newException(SQLState.INVALID_COLLATION, userDefinedCollation);
}
}
}
}
use of org.apache.derby.iapi.services.monitor.ModuleFactory in project derby by apache.
the class BasicDaemon method yield.
/* let everybody else run first */
private void yield() {
Thread currentThread = Thread.currentThread();
int oldPriority = currentThread.getPriority();
if (oldPriority <= Thread.MIN_PRIORITY) {
Thread.yield();
} else {
ModuleFactory mf = getMonitor();
setThreadPriority(mf, Thread.MIN_PRIORITY);
Thread.yield();
setThreadPriority(mf, oldPriority);
}
}
use of org.apache.derby.iapi.services.monitor.ModuleFactory in project derby by apache.
the class BasicDatabase method boot.
public void boot(boolean create, Properties startParams) throws StandardException {
ModuleFactory monitor = getMonitor();
if (create) {
if (startParams.getProperty(Property.CREATE_WITH_NO_LOG) == null)
startParams.put(Property.CREATE_WITH_NO_LOG, "true");
String localeID = startParams.getProperty(org.apache.derby.shared.common.reference.Attribute.TERRITORY);
if (localeID == null) {
localeID = Locale.getDefault().toString();
}
databaseLocale = monitor.setLocale(startParams, localeID);
} else {
databaseLocale = monitor.getLocale(this);
}
setLocale(databaseLocale);
// boot the validation needed to do property validation, now property
// validation is separated from AccessFactory, therefore from store
bootValidation(create, startParams);
// boot the type factory before store to ensure any dynamically
// registered types (DECIMAL) are there before logical undo recovery
// might need them.
DataValueFactory dvf = (DataValueFactory) bootServiceModule(create, this, org.apache.derby.shared.common.reference.ClassName.DataValueFactory, startParams);
bootStore(create, startParams);
// create a database ID if one doesn't already exist
myUUID = makeDatabaseID(create, startParams);
// Add the database properties read from disk (not stored
// in service.properties) into the set seen by booting modules.
Properties allParams = new DoubleProperties(getAllDatabaseProperties(), startParams);
if (pf != null)
pf.addPropertySetNotification(this);
// Boot the ClassFactory, will be per-database or per-system.
// reget the tc in case someone inadverdently destroyed it
bootClassFactory(create, allParams);
dd = (DataDictionary) bootServiceModule(create, this, DataDictionary.MODULE, allParams);
lcf = (LanguageConnectionFactory) bootServiceModule(create, this, LanguageConnectionFactory.MODULE, allParams);
lf = (LanguageFactory) bootServiceModule(create, this, LanguageFactory.MODULE, allParams);
bootResourceAdapter(create, allParams);
// may also want to set up a check that we are a singleton,
// or that there isn't already a database object in the system
// for the same database?
//
// We boot the authentication service. There should at least be one
// per database (even if authentication is turned off) .
//
authenticationService = bootAuthenticationService(create, allParams);
if (SanityManager.DEBUG) {
SanityManager.ASSERT(authenticationService != null, "Failed to set the Authentication service for the database");
}
// on logging
if (create && lastToBoot && (startParams.getProperty(Property.CREATE_WITH_NO_LOG) != null)) {
createFinished();
}
active = true;
// Create an index statistics update daemon.
if (dd.doCreateIndexStatsRefresher()) {
dd.createIndexStatsRefresher(this, allParams.getProperty(Property.PROPERTY_RUNTIME_PREFIX + "serviceDirectory"));
}
}
use of org.apache.derby.iapi.services.monitor.ModuleFactory in project derby by apache.
the class PropertyUtil method systemPropertiesExistsBuiltinUser.
/**
* Return true if username is defined as a system property
* i.e. there exists a property {@code derby.user.}<userid>
* in the system properties. Note that <userid> will be
* normalized to case normal form before comparison is performed
* against username, which is presumed normalized already.
* @param username Normalized authorization identifier
* @return {@code true} if match found
*/
private static boolean systemPropertiesExistsBuiltinUser(String username) {
ModuleFactory monitor = getMonitorLite();
try {
Properties JVMProperties = System.getProperties();
if (propertiesContainsBuiltinUser(JVMProperties, username)) {
return true;
}
} catch (SecurityException e) {
// Running with security manager and we can't get at all
// JVM properties, to try to map the back the authid to
// how the user may have specified a matching id (1->many,
// since userids are subject to SQL up-casing).
String key = Property.USER_PROPERTY_PREFIX + IdUtil.SQLIdentifier2CanonicalPropertyUsername(username);
if (monitor.getJVMProperty(key) != null) {
return true;
}
}
Properties applicationProperties = monitor.getApplicationProperties();
return propertiesContainsBuiltinUser(applicationProperties, username);
}
use of org.apache.derby.iapi.services.monitor.ModuleFactory in project derby by apache.
the class PropertyUtil method getSystemProperty.
/**
* Find a system wide property with a default. Search order is
*
* <OL>
* <LI> JVM property
* <LI> derby.properties
* </OL>
*
* <P>
* This method can be used by a system that is not running Derby,
* just to maintain the same lookup logic and security manager concerns
* for finding derby.properties and reading system properties.
*
* @return the value of the property or defaultValue if it does not exist.
*/
public static String getSystemProperty(String key, String defaultValue) {
ModuleFactory monitor = getMonitorLite();
String value = monitor.getJVMProperty(key);
if (value == null) {
Properties applicationProperties = monitor.getApplicationProperties();
if (applicationProperties != null)
value = applicationProperties.getProperty(key);
}
return value == null ? defaultValue : value;
}
Aggregations