|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object issrg.utils.repository.DefaultRepository issrg.utils.repository.MultiRepository
public class MultiRepository
This class is the implementation of the Attribute Repository for multithreaded access to a cluster of repositories. It can be built out of an array of Repositories. Each of these repositories constitutes a root for searches.
The object can be used for retrieving similar information from multiple directories simultaneously. For example, it is useful when retrieving X.509 Attribute Certificates for PMI entities that possess ACs issued by different issuers (therefore, stored in different repositories available to them).
The object creates multiple threads (one per repository) when attributes are requested and performs the searches simultaneously. This improves efficiency, since most of the time the repositories are waiting for a reply. The object waits till all of the contexts return anything or report an error, so the result is always complete.
Field Summary |
---|
Fields inherited from interface issrg.utils.repository.AttributeRepository |
---|
FAILURE_STATUS, INHERENT_FAILURE_STATUS, PARTIAL_SUCCESS_STATUS, SUCCESS_STATUS |
Constructor Summary | |
---|---|
protected |
MultiRepository()
|
|
MultiRepository(AttributeRepository repository)
This creates a MultiRepository with a single root repository |
|
MultiRepository(AttributeRepository[] repositories)
This constructor builds the MultiRepository with a number of roots. |
Method Summary | |
---|---|
javax.naming.directory.Attribute |
getAttribute(TokenLocator locator,
java.lang.String AttributeName)
This is method searches for a single attribute. |
protected javax.naming.directory.Attributes |
getAttributes(java.security.Principal[] DN,
AttributeRepository[] repositories,
java.lang.String[] AttributeNames)
This is the root method called by any other getAttributes that gets the set of named attributes from the entries with the DNs. |
javax.naming.directory.Attributes |
getAttributes(java.security.Principal DN,
java.lang.String[] AttributeNames)
This method searches for the given attributes in the repositories provided at construction time. |
javax.naming.directory.Attributes |
getAttributes(TokenLocator locator,
java.lang.String[] AttributeNames)
This method will collect attributes from all the entries identified by the TokenLocator. |
java.lang.Throwable |
getDiagnosis()
This method returns the Throwable, representing the error, or null, if no error has been encountered (only if the repository is in SUCCESS_STATUS). |
AttributeRepository[] |
getRepositories()
This method returns the array of repositories used by the MultiRepository by default (when TokenLocators do not refer to a specific repository). |
int |
getStatus()
This method returns the status of the repository. |
Methods inherited from class issrg.utils.repository.DefaultRepository |
---|
getAllAttributes, getAttribute |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected MultiRepository()
public MultiRepository(AttributeRepository[] repositories)
repositories
- An array of AttributeRepositories to be used as the
search rootspublic MultiRepository(AttributeRepository repository)
repository
- A AttributeRepositoryMethod Detail |
---|
public javax.naming.directory.Attributes getAttributes(java.security.Principal DN, java.lang.String[] AttributeNames) throws RepositoryException
DN
- - the Principal naming the entry in the repositoriesAttributeNames
- - the names of the attributes to be retrieved; if
null, all available attributes will be returned
RepositoryException
public javax.naming.directory.Attributes getAttributes(TokenLocator locator, java.lang.String[] AttributeNames) throws RepositoryException
locator
- - the locator of the entries with the attributesAttributeNames
- - the names of the attributes
RepositoryException
public javax.naming.directory.Attribute getAttribute(TokenLocator locator, java.lang.String AttributeName) throws RepositoryException
locator
- - the TokenLocator identifying multiple locations of the
attributeAttributeName
- - the name of the attribute to retrieve
RepositoryException
protected javax.naming.directory.Attributes getAttributes(java.security.Principal[] DN, AttributeRepository[] repositories, java.lang.String[] AttributeNames) throws RepositoryException
The list of entry names DN is synchronised with the list of repositories so that each entry name is used only for the corresponding repository, but the whole list of attributes is requested from each repository. When other getAttributes methods use this method, they simply construct such synchronous lists of entry names and repositories. These methods do not update the status or diagnosis set by this method, and they propagate the exceptions thrown by this method.
Effectively, this method constructs a new MultiThreadSearch and invokes a getAttributes method on it. Because this may cause recursive invocation of this method from different threads, this method is NOT synchronized. For example, a search for attributes in two chained TokenLocators with no repository specified constructs one MultiThreadSearch, which spawns two threads, each attempting to invoke getAttributes method on this very MultiRepository object; this should be allowed (no mutex on the method), and in its turn creates two other MultiThreadSearches, each spawning one thread for each initial repository passed to the MultiRepository at construction time. The side effect of this is that during the call to getAttributes the status and diagnosis values are undetermined, since the calls to multiple MultiThreadSearch will temporarily set the status and diagnosis of this MultiRepository, until the recursion unwinds back, and the MultiThreadSearch at the root of this recursion will set the ultimate diagnosis and status of invocation of getAttributes method. Note also that if the getAttributes method on the corresponding repositories is synchronized, this will only slow down the multithreaded search, but will not block the process (unless by some bad design they use the same MultiRepository that invoked them).
After calling the method the repository will be set into one of the states: FAILURE_STATUS, SUCCESS_STATUS or PARTIAL_SUCCESS_STATUS. Failure means there were no roots that succeeded. Success means that all of the roots succeeded (the entries were found and some or no attributes were retrieved). Partial success means that some of the roots failed, but some have succeeded, which may be in case some of the roots do not contain the required entry. The caller must find out himself what the cause is, and decide if the results are sufficiently successful.
DN
- The distinguished names of the entry from which the attributes
are requestedrepositories
- The repositories to be searched; must have the same number
of elements, as DN; each DN must have a non-null repository correspondingAttributeNames
- The array of LDAP names for the attributes; can be
null, if all available attributes and their values are to be retrieved
RepositoryException,
- if all of the repositories failed, in which case the
embedded exception will be the Throwable returned by getDiagnosis
method; FAILURE_STATUS will also be set
RepositoryException
MultiThreadSearch.getAttributes(java.security.Principal[], issrg.utils.repository.AttributeRepository[], java.lang.String[])
public int getStatus()
getAttributes(java.security.Principal,String[])
public java.lang.Throwable getDiagnosis()
AttributeRepository.getStatus()
public AttributeRepository[] getRepositories()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |