Methods Summary |
---|
void | destroyAll()Destroys all interceptors in this list by invoking their destroy()
method.
int numTypes = interceptors.length;
for( int i = 0; i < numTypes; i++ ) {
int numInterceptors = interceptors[i].length;
for( int j = 0; j < numInterceptors; j++ ) {
interceptors[i][j].destroy();
}
}
|
org.omg.PortableInterceptor.Interceptor[] | getInterceptors(int type)Retrieves an array of interceptors of the given type. For efficiency,
the type parameter is assumed to be valid.
return interceptors[type];
|
private void | growInterceptorArray(int type)Grows the given interceptor array by one:
Class classType = classTypes[type];
int currentLength = interceptors[type].length;
Interceptor[] replacementArray;
// Create new array to replace the old one. The new array will be
// one element larger but have the same type as the old one.
replacementArray = (Interceptor[])
Array.newInstance( classType, currentLength + 1 );
System.arraycopy( interceptors[type], 0,
replacementArray, 0, currentLength );
interceptors[type] = replacementArray;
|
boolean | hasInterceptorsOfType(int type)Returns true if there is at least one interceptor of the given type,
or false if not.
return interceptors[type].length > 0;
|
private void | initInterceptorArrays()Initializes all interceptors arrays to zero-length arrays of the
correct type, based on the classTypes list.
for( int type = 0; type < NUM_INTERCEPTOR_TYPES; type++ ) {
Class classType = classTypes[type];
// Create a zero-length array for each type:
interceptors[type] =
(Interceptor[])Array.newInstance( classType, 0 );
}
|
void | lock()Locks this interceptor list so that no more interceptors may be
registered. This method is called after all interceptors are
registered for security reasons.
locked = true;
|
void | register_interceptor(org.omg.PortableInterceptor.Interceptor interceptor, int type)Registers an interceptor of the given type into the interceptor list.
The type is one of:
- INTERCEPTOR_TYPE_CLIENT - ClientRequestInterceptor
- INTERCEPTOR_TYPE_SERVER - ServerRequestInterceptor
- INTERCEPTOR_TYPE_IOR - IORInterceptor
// If locked, deny any further addition of interceptors.
if( locked ) {
throw wrapper.interceptorListLocked() ;
}
// Cache interceptor name:
String interceptorName = interceptor.name();
boolean anonymous = interceptorName.equals( "" );
boolean foundDuplicate = false;
Interceptor[] interceptorList = interceptors[type];
// If this is not an anonymous interceptor,
// search for an interceptor of the same name in this category:
if( !anonymous ) {
int size = interceptorList.length;
// An O(n) search will suffice because register_interceptor is not
// likely to be called often.
for( int i = 0; i < size; i++ ) {
Interceptor in = (Interceptor)interceptorList[i];
if( in.name().equals( interceptorName ) ) {
foundDuplicate = true;
break;
}
}
}
if( !foundDuplicate ) {
growInterceptorArray( type );
interceptors[type][interceptors[type].length-1] = interceptor;
}
else {
throw new DuplicateName( interceptorName );
}
|
void | sortInterceptors()Sort interceptors.
List sorted = null;
List unsorted = null;
int numTypes = interceptors.length;
for( int i = 0; i < numTypes; i++ ) {
int numInterceptors = interceptors[i].length;
if (numInterceptors > 0) {
// Get fresh sorting bins for each non empty type.
sorted = new ArrayList(); // not synchronized like we want.
unsorted = new ArrayList();
}
for( int j = 0; j < numInterceptors; j++ ) {
Interceptor interceptor = interceptors[i][j];
if (interceptor instanceof Comparable) {
sorted.add(interceptor);
} else {
unsorted.add(interceptor);
}
}
if (numInterceptors > 0 && sorted.size() > 0) {
// Let the RuntimeExceptions thrown by sort
// (i.e., ClassCastException and UnsupportedOperationException)
// flow back to the user.
Collections.sort(sorted);
Iterator sortedIterator = sorted.iterator();
Iterator unsortedIterator = unsorted.iterator();
for( int j = 0; j < numInterceptors; j++ ) {
if (sortedIterator.hasNext()) {
interceptors[i][j] =
(Interceptor) sortedIterator.next();
} else if (unsortedIterator.hasNext()) {
interceptors[i][j] =
(Interceptor) unsortedIterator.next();
} else {
throw wrapper.sortSizeMismatch() ;
}
}
}
}
|