Class BasicDependencyManager
- java.lang.Object
-
- org.apache.derby.impl.sql.depend.BasicDependencyManager
-
- All Implemented Interfaces:
- DependencyManager
public class BasicDependencyManager extends java.lang.Object implements DependencyManager
The dependency manager tracks needs that dependents have of providers.A dependency can be either persistent or non-persistent. Persistent dependencies are stored in the data dictionary, and non-persistent dependencies are stored within the dependency manager itself (in memory).
Synchronization: The need for synchronization is different depending on whether the dependency is an in-memory dependency or a stored dependency. When accessing and modifying in-memory dependencies, Java synchronization must be used (specifically, we synchronize on
this). When accessing and modifying stored dependencies, which are stored in the data dictionary, we expect that the locking protocols will provide the synchronization needed. Note that stored dependencies should not be accessed while holding the monitor ofthis, as this may result in deadlocks. So far the need for synchronization across both in-memory and stored dependencies hasn't occurred.
-
-
Field Summary
-
Fields inherited from interface org.apache.derby.iapi.sql.depend.DependencyManager
ALTER_TABLE, BULK_INSERT, CHANGED_CURSOR, COMPILE_FAILED, COMPRESS_TABLE, CREATE_CONSTRAINT, CREATE_INDEX, CREATE_TRIGGER, CREATE_VIEW, DROP_AGGREGATE, DROP_COLUMN, DROP_COLUMN_RESTRICT, DROP_CONSTRAINT, DROP_INDEX, DROP_JAR, DROP_METHOD_ALIAS, DROP_SCHEMA, DROP_SEQUENCE, DROP_SPS, DROP_STATISTICS, DROP_SYNONYM, DROP_TABLE, DROP_TRIGGER, DROP_UDT, DROP_VIEW, INTERNAL_RECOMPILE_REQUEST, MAX_ACTION_CODE, MODIFY_COLUMN_DEFAULT, PREPARED_STATEMENT_RELEASE, RECHECK_PRIVILEGES, RENAME, RENAME_INDEX, REPLACE_JAR, REVOKE_PRIVILEGE, REVOKE_PRIVILEGE_RESTRICT, REVOKE_ROLE, ROLLBACK, SET_CONSTRAINTS_DISABLE, SET_CONSTRAINTS_ENABLE, SET_TRIGGERS_DISABLE, SET_TRIGGERS_ENABLE, TRUNCATE_TABLE, UPDATE_STATISTICS, USER_RECOMPILE_REQUEST
-
-
Constructor Summary
Constructors Constructor and Description BasicDependencyManager(DataDictionary dd)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddDependency(Dependent d, Provider p, ContextManager cm)adds a dependency from the dependent on the provider.voidclearColumnInfoInProviders(ProviderList pl)Clear the in memory column bit map information in any table descriptor provider in a provider list.voidclearDependencies(LanguageConnectionContext lcc, Dependent d)Erases all of the dependencies the dependent has, be they valid or invalid, of any dependency type.voidclearDependencies(LanguageConnectionContext lcc, Dependent d, TransactionController tc)Erases all of the dependencies the dependent has, be they valid or invalid, of any dependency type.voidclearInMemoryDependency(Dependency dy)Clear the specified in memory dependency.voidcopyDependencies(Dependent copy_From, Dependent copyTo, boolean persistentOnly, ContextManager cm)Copy dependencies from one dependent to another.voidcopyDependencies(Dependent copy_From, Dependent copyTo, boolean persistentOnly, ContextManager cm, TransactionController tc)Copy dependencies from one dependent to another.intcountDependencies()Count the number of active dependencies, both stored and in memory, in the system.java.lang.StringgetActionString(int action)Returns a string representation of the SQL action, hence no need to internationalize, which is causing the invokation of the Dependency Manager.ProviderInfo[]getPersistentProviderInfos(Dependent dependent)Get a new array of ProviderInfos representing all the persistent providers for the given dependent.ProviderInfo[]getPersistentProviderInfos(ProviderList pl)Get a new array of ProviderInfos representing all the persistent providers from the given list of providers.voidinvalidateFor(Provider p, int action, LanguageConnectionContext lcc)mark all dependencies on the named provider as invalid.
-
-
-
Constructor Detail
-
BasicDependencyManager
public BasicDependencyManager(DataDictionary dd)
-
-
Method Detail
-
addDependency
public void addDependency(Dependent d, Provider p, ContextManager cm) throws StandardException
adds a dependency from the dependent on the provider. This will be considered to be the default type of dependency, when dependency types show up.Implementations of addDependency should be fast -- performing alot of extra actions to add a dependency would be a detriment.
- Specified by:
addDependencyin interfaceDependencyManager- Parameters:
d- the dependentp- the providercm- Current ContextManager- Throws:
StandardException- thrown if something goes wrong
-
invalidateFor
public void invalidateFor(Provider p, int action, LanguageConnectionContext lcc) throws StandardException
mark all dependencies on the named provider as invalid. When invalidation types show up, this will use the default invalidation type. The dependencies will still exist once they are marked invalid; clearDependencies should be used to remove dependencies that a dependent has or provider gives.Implementations of this can take a little time, but are not really expected to recompile things against any changes made to the provider that caused the invalidation. The dependency system makes no guarantees about the state of the provider -- implementations can call this before or after actually changing the provider to its new state.
Implementations should throw StandardException if the invalidation should be disallowed.
- Specified by:
invalidateForin interfaceDependencyManager- Parameters:
p- the provideraction- The action causing the invalidatelcc- The LanguageConnectionContext- Throws:
StandardException- thrown if unable to make it invalid
-
clearDependencies
public void clearDependencies(LanguageConnectionContext lcc, Dependent d) throws StandardException
Erases all of the dependencies the dependent has, be they valid or invalid, of any dependency type. This action is usually performed as the first step in revalidating a dependent; it first erases all the old dependencies, then revalidates itself generating a list of new dependencies, and then marks itself valid if all its new dependencies are valid.There might be a future want to clear all dependencies for a particular provider, e.g. when destroying the provider. However, at present, they are assumed to stick around and it is the responsibility of the dependent to erase them when revalidating against the new version of the provider.
clearDependencies will delete dependencies if they are stored; the delete is finalized at the next commit.
- Specified by:
clearDependenciesin interfaceDependencyManager- Parameters:
d- the dependentlcc- Compiler state- Throws:
StandardException- Thrown on failure
-
clearDependencies
public void clearDependencies(LanguageConnectionContext lcc, Dependent d, TransactionController tc) throws StandardException
Description copied from interface:DependencyManagerErases all of the dependencies the dependent has, be they valid or invalid, of any dependency type. This action is usually performed as the first step in revalidating a dependent; it first erases all the old dependencies, then revalidates itself generating a list of new dependencies, and then marks itself valid if all its new dependencies are valid.There might be a future want to clear all dependencies for a particular provider, e.g. when destroying the provider. However, at present, they are assumed to stick around and it is the responsibility of the dependent to erase them when revalidating against the new version of the provider.
clearDependencies will delete dependencies if they are stored; the delete is finalized at the next commit.
- Specified by:
clearDependenciesin interfaceDependencyManager- Parameters:
lcc- Compiler stated- the dependenttc- transaction controller- Throws:
StandardException- Thrown on failure
-
clearInMemoryDependency
public void clearInMemoryDependency(Dependency dy)
Clear the specified in memory dependency. This is useful for clean-up when an exception occurs. (We clear all in-memory dependencies added in the current StatementContext.)- Specified by:
clearInMemoryDependencyin interfaceDependencyManager
-
getPersistentProviderInfos
public ProviderInfo[] getPersistentProviderInfos(Dependent dependent) throws StandardException
Description copied from interface:DependencyManagerGet a new array of ProviderInfos representing all the persistent providers for the given dependent.- Specified by:
getPersistentProviderInfosin interfaceDependencyManager- Throws:
StandardException- Thrown on error- See Also:
DependencyManager.getPersistentProviderInfos(org.apache.derby.iapi.sql.depend.Dependent)
-
getPersistentProviderInfos
public ProviderInfo[] getPersistentProviderInfos(ProviderList pl) throws StandardException
Description copied from interface:DependencyManagerGet a new array of ProviderInfos representing all the persistent providers from the given list of providers.- Specified by:
getPersistentProviderInfosin interfaceDependencyManager- Throws:
StandardException- Thrown on error- See Also:
DependencyManager.getPersistentProviderInfos(org.apache.derby.iapi.sql.depend.Dependent)
-
clearColumnInfoInProviders
public void clearColumnInfoInProviders(ProviderList pl) throws StandardException
Description copied from interface:DependencyManagerClear the in memory column bit map information in any table descriptor provider in a provider list. This function needs to be called before the table descriptor is reused as provider in column dependency. For example, this happens in "create publication" statement with target-only DDL where more than one views are defined and they all reference one table.- Specified by:
clearColumnInfoInProvidersin interfaceDependencyManager- Parameters:
pl- provider list- Throws:
StandardException- Thrown on error- See Also:
DependencyManager.clearColumnInfoInProviders(org.apache.derby.iapi.sql.depend.ProviderList)
-
copyDependencies
public void copyDependencies(Dependent copy_From, Dependent copyTo, boolean persistentOnly, ContextManager cm) throws StandardException
Copy dependencies from one dependent to another.- Specified by:
copyDependenciesin interfaceDependencyManager- Parameters:
copy_From- the dependent to copy fromcopyTo- the dependent to copy topersistentOnly- only copy persistent dependenciescm- Current ContextManager- Throws:
StandardException- Thrown on error.
-
copyDependencies
public void copyDependencies(Dependent copy_From, Dependent copyTo, boolean persistentOnly, ContextManager cm, TransactionController tc) throws StandardException
Description copied from interface:DependencyManagerCopy dependencies from one dependent to another.- Specified by:
copyDependenciesin interfaceDependencyManager- Parameters:
copy_From- the dependent to copy fromcopyTo- the dependent to copy topersistentOnly- only copy persistent dependenciescm- Current ContextManagertc- Transaction Controller- Throws:
StandardException- Thrown on error.
-
getActionString
public java.lang.String getActionString(int action)
Returns a string representation of the SQL action, hence no need to internationalize, which is causing the invokation of the Dependency Manager.- Specified by:
getActionStringin interfaceDependencyManager- Parameters:
action- The action- Returns:
- String The String representation
-
countDependencies
public int countDependencies() throws StandardExceptionCount the number of active dependencies, both stored and in memory, in the system.- Specified by:
countDependenciesin interfaceDependencyManager- Returns:
- int The number of active dependencies in the system.
- Throws:
StandardException- thrown if something goes wrong
-
-
DataMelt 3.0 © DataMelt by jWork.ORG