Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 58545 invoked from network); 20 Jan 2006 13:51:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Jan 2006 13:51:01 -0000 Received: (qmail 46450 invoked by uid 500); 20 Jan 2006 13:50:59 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 46369 invoked by uid 500); 20 Jan 2006 13:50:58 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 46271 invoked by uid 99); 20 Jan 2006 13:50:58 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jan 2006 05:50:58 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 20 Jan 2006 05:50:48 -0800 Received: (qmail 58123 invoked by uid 65534); 20 Jan 2006 13:50:27 -0000 Message-ID: <20060120135027.58120.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r370807 [1/22] - in /directory/sandbox/trustin/mina-spi: ./ core/src/main/java/org/apache/mina/common/ core/src/main/java/org/apache/mina/common/support/ core/src/main/java/org/apache/mina/common/support/discovery/ core/src/main/java/org/ap... Date: Fri, 20 Jan 2006 13:48:55 -0000 To: commits@directory.apache.org From: trustin@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: trustin Date: Fri Jan 20 05:47:50 2006 New Revision: 370807 URL: http://svn.apache.org/viewcvs?rev=370807&view=rev Log: Creating a branch for DIRMINA-147 and DIRMINA-148 Added: directory/sandbox/trustin/mina-spi/ - copied from r370796, directory/trunks/mina/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoAddress.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/MINA.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/DiscoveryException.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/Resource.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClass.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassDiscover.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassIterator.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceDiscover.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceIterator.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameDiscover.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameIterator.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ant/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ant/ServiceDiscoveryTask.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/jdk/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/jdk/JDK11Hooks.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/jdk/JDK12Hooks.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/jdk/JDKHooks.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/jdk/PsuedoSystemClassLoader.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/package.html (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/ClassLoaders.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/DiscoverResources.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/ResourceDiscoverImpl.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/classes/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/classes/DiscoverClasses.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/classes/ResourceClassDiscoverImpl.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/names/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/names/DiscoverMappedNames.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/names/DiscoverNamesInAlternateManagedProperties.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/names/DiscoverNamesInDictionary.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/names/DiscoverNamesInFile.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/names/DiscoverNamesInManagedProperties.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/names/DiscoverNamesInSystemProperties.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/names/DiscoverServiceNames.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/names/NameDiscoverers.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/resource/names/ResourceNameDiscoverImpl.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/tools/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/tools/ClassUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/tools/DefaultClassHolder.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/tools/DiscoverClass.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/tools/DiscoverSingleton.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/tools/EnvironmentCache.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/tools/ManagedProperties.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/tools/PropertiesHolder.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/tools/ResourceUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/tools/SPInterface.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/tools/Service.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/ArrayUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/BitField.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/BooleanUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/CharEncoding.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/CharRange.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/CharSet.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/CharSetUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/CharUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/ClassUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/Entities.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/IllegalClassException.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/IncompleteArgumentException.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/IntHashMap.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/NotImplementedException.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/NullArgumentException.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/NumberRange.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/NumberUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/ObjectUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/RandomStringUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/SerializationException.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/SerializationUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/StringEscapeUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/StringPrintWriter.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/StringUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/SystemUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/UnhandledException.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/Validate.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/WordUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/builder/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/builder/CompareToBuilder.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/builder/EqualsBuilder.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/builder/HashCodeBuilder.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/builder/ReflectionToStringBuilder.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/builder/StandardToStringStyle.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/builder/ToStringBuilder.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/builder/ToStringStyle.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/builder/package.html (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/enums/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/enums/Enum.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/enums/EnumUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/enums/ValuedEnum.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/enums/package.html (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/exception/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/exception/ExceptionUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/exception/Nestable.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/exception/NestableDelegate.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/exception/NestableError.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/exception/NestableException.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/exception/NestableRuntimeException.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/exception/package.html (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/DoubleRange.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/FloatRange.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/Fraction.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/IntRange.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/JVMRandom.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/LongRange.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/NumberRange.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/NumberUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/RandomUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/Range.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/math/package.html (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/mutable/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/mutable/Mutable.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/mutable/MutableByte.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/mutable/MutableDouble.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/mutable/MutableFloat.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/mutable/MutableInt.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/mutable/MutableLong.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/mutable/MutableObject.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/mutable/MutableShort.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/mutable/package.html (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/overview.html (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/package.html (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/time/ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/time/DateFormatUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/time/DateUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/time/DurationFormatUtils.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/time/FastDateFormat.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/time/StopWatch.java (with props) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/lang/time/package.html (with props) directory/sandbox/trustin/mina-spi/core/src/main/resources/ directory/sandbox/trustin/mina-spi/core/src/main/resources/META-INF/ directory/sandbox/trustin/mina-spi/core/src/main/resources/META-INF/services/ directory/sandbox/trustin/mina-spi/core/src/main/resources/META-INF/services/org.apache.mina.common.IoServiceProvider directory/sandbox/trustin/mina-spi/core/src/test/java/org/apache/mina/common/IoAddressTest.java (with props) Modified: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java (contents, props changed) directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/package.html (props changed) Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoAddress.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoAddress.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoAddress.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoAddress.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,114 @@ +/* + * @(#) $Id$ + * + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.mina.common; + +/** + * Represents the address of the location where I/O occurs. + * + * @author The Apache Directory Project (dev@directory.apache.org) + * @version $Rev$, $Date$ + */ +public class IoAddress +{ + private final String provider; + private final String transportType; + private final String address; + + public IoAddress( String provider, String transportType, String address ) + { + if( provider == null ) + { + throw new NullPointerException( "provider" ); + } + if( transportType == null ) + { + throw new NullPointerException( "transportType" ); + } + if( address == null ) + { + throw new NullPointerException( "address" ); + } + + provider = provider.trim(); + transportType = transportType.trim(); + address = address.trim(); + + if( provider.indexOf( ':' ) >= 0 ) + { + throw new IllegalArgumentException( "provider: " + provider ); + } + if( transportType.indexOf( ':' ) >= 0 ) + { + throw new IllegalArgumentException( "transportType: " + transportType ); + } + + this.provider = provider; + this.transportType = transportType; + this.address = address; + } + + public IoAddress( String uri ) + { + if( uri == null ) + { + throw new NullPointerException( "uri" ); + } + + int startPos; + int colonPos = uri.indexOf( ':' ); + checkColonPos( uri, colonPos ); + provider = uri.substring( 0, colonPos ).trim(); + startPos = colonPos + 1; + + colonPos = uri.indexOf( ':', startPos ); + checkColonPos( uri, colonPos ); + transportType = uri.substring( startPos, colonPos ).trim(); + startPos = colonPos + 1; + + address = uri.substring( startPos ).trim(); + } + + private void checkColonPos( String uri, int colonIdx ) + { + if( colonIdx < 0 ) + { + throw new IllegalArgumentException( "uri: " + uri ); + } + } + + public String getProvider() + { + return provider; + } + + public String getTransportType() + { + return transportType; + } + + public String getAddress() + { + return address; + } + + public String toString() + { + return provider + ':' + transportType + ':' + address; + } +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoAddress.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,9 @@ +package org.apache.mina.common; + + +public interface IoServiceProvider +{ + String getName(); + IoAcceptor getAcceptor( IoAddress address ); + IoConnector getConnector( IoAddress address ); +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/IoServiceProvider.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/MINA.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/MINA.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/MINA.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/MINA.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,80 @@ +/* + * @(#) $Id$ + * + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.mina.common; + +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import org.apache.mina.common.support.discovery.tools.Service; + +public class MINA +{ + private static final Map providers = new HashMap(); + + static + { + registerServiceProviders(); + } + + /** + * Registers all {@link Converter}s and {@link ConverterPack}s + * found using SPI. + */ + private static void registerServiceProviders() { + for( Enumeration e = Service.providers( IoServiceProvider.class ); + e.hasMoreElements(); ) + { + IoServiceProvider p = ( IoServiceProvider ) e.nextElement(); + registerProvider( p ); + } + } + + public static void registerProvider( IoServiceProvider provider ) + { + if( provider == null ) + { + throw new NullPointerException(); + } + + synchronized( providers ) + { + if( providers.get( provider.getName() ) != null ) + { + throw new IllegalArgumentException( "Provider '" + provider.getName() + "' is already registered." ); + } + providers.put( provider.getName(), provider ); + } + } + + public static IoServiceProvider deregisterProvider( String providerName ) + { + if( providerName == null ) + { + throw new NullPointerException( "providerName" ); + } + + synchronized( providers ) + { + return ( IoServiceProvider ) providers.remove( providerName ); + } + } + + +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/MINA.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Modified: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java?rev=370807&r1=370796&r2=370807&view=diff ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java (original) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java Fri Jan 20 05:47:50 2006 @@ -1,5 +1,5 @@ /* - * @(#) $Id: IoFilterLifeCycleManager.java 350148 2005-12-01 04:13:18Z trustin $ + * @(#) $Id$ * * Copyright 2004 The Apache Software Foundation * @@ -30,7 +30,7 @@ * Manages the life cycle of {@link IoFilter}s globally. * * @author The Apache Directory Project (dev@directory.apache.org) - * @version $Rev: 350148 $, $Date: 2005-12-01 13:13:18 +0900 $ + * @version $Rev$, $Date$ */ public class IoFilterLifeCycleManager { Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/DiscoveryException.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/DiscoveryException.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/DiscoveryException.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/DiscoveryException.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,144 @@ +/* + * $Header$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.mina.common.support.discovery; + + +/** + *

An exception that is thrown only if a suitable service + * instance cannot be created by ServiceFactory

+ * + *

Copied from LogConfigurationException

+ * + * @author Craig R. McClanahan + * @version $Revision$ $Date$ + */ +public class DiscoveryException extends RuntimeException { + + + /** + * Construct a new exception with null as its detail message. + */ + public DiscoveryException() { + super(); + } + + /** + * Construct a new exception with the specified detail message. + * + * @param message The detail message + */ + public DiscoveryException(String message) { + super(message); + } + + /** + * Construct a new exception with the specified cause and a derived + * detail message. + * + * @param cause The underlying cause + */ + public DiscoveryException(Throwable cause) { + this((cause == null) ? null : cause.toString(), cause); + } + + /** + * Construct a new exception with the specified detail message and cause. + * + * @param message The detail message + * @param cause The underlying cause + */ + public DiscoveryException(String message, Throwable cause) { + super(message); + this.cause = cause; // Two-argument version requires JDK 1.4 or later + } + + /** + * The underlying cause of this exception. + */ + protected Throwable cause = null; + + /** + * Return the underlying cause of this exception (if any). + */ + public Throwable getCause() { + return this.cause; + } + + public String toString() { + String ls = System.getProperty("line.separator"); + String str = super.toString(); + if (cause != null) { + str = str + ls + + "*****" + ls + + stackToString(cause); + } + return str; + } + + private static String stackToString(Throwable e){ + java.io.StringWriter sw= new java.io.StringWriter(1024); + java.io.PrintWriter pw= new java.io.PrintWriter(sw); + e.printStackTrace(pw); + pw.close(); + return sw.toString(); + } +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/DiscoveryException.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/Resource.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/Resource.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/Resource.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/Resource.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,155 @@ +/* + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.mina.common.support.discovery; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Vector; + + +/** + * 'Resource' located by discovery. + * Naming of methods becomes a real pain ('getClass()') + * so I've patterned this after ClassLoader... + * + * I think it works well as it will give users a point-of-reference. + * + * @author Craig R. McClanahan + * @author Costin Manolache + * @author Richard A. Sitze + */ +public class Resource +{ + protected final String name; + protected final URL resource; + protected final ClassLoader loader; + + public Resource(String resourceName, URL resource, ClassLoader loader) { + this.name = resourceName; + this.resource = resource; + this.loader = loader; + } + + /** + * Get the value of resourceName. + * @return value of resourceName. + */ + public String getName() { + return name; + } + +// /** +// * Set the value of URL. +// * @param v Value to assign to URL. +// */ +// public void setResource(URL resource) { +// this.resource = resource; +// } + + /** + * Get the value of URL. + * @return value of URL. + */ + public URL getResource() { + return resource; + } + + /** + * Get the value of URL. + * @return value of URL. + */ + public InputStream getResourceAsStream() { + try { + return resource.openStream(); + } catch (IOException e) { + return null; // ignore + } + } + + /** + * Get the value of loader. + * @return value of loader. + */ + public ClassLoader getClassLoader() { + return loader ; + } + +// /** +// * Set the value of loader. +// * @param v Value to assign to loader. +// */ +// public void setClassLoader(ClassLoader loader) { +// this.loader = loader; +// } + + public String toString() { + return "Resource[" + getName() + ", " + getResource() + ", " + getClassLoader() + "]"; + } + + public static Resource[] toArray(ResourceIterator iterator) { + Vector vector = new Vector(); + while (iterator.hasNext()) { + vector.add(iterator.nextResource()); + } + Resource[] resources = new Resource[vector.size()]; + vector.copyInto(resources); + + return resources; + } +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/Resource.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClass.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClass.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClass.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClass.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,122 @@ +/* + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.mina.common.support.discovery; + +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; + + +/** + * 'Resource' located by discovery. + * Naming of methods becomes a real pain ('getClass()') + * so I've patterned this after ClassLoader... + * + * I think it works well as it will give users a point-of-reference. + * + * @author Richard A. Sitze + */ +public class ResourceClass extends Resource +{ + protected Class resourceClass; + + public ResourceClass(Class resourceClass, URL resource) { + super(resourceClass.getName(), resource, resourceClass.getClassLoader()); + this.resourceClass = resourceClass; + } + + public ResourceClass(String resourceName, URL resource, ClassLoader loader) { + super(resourceName, resource, loader); + } + + /** + * Get the value of resourceClass. + * Loading the class does NOT guarentee that the class can be + * instantiated. Go figure. + * The class can be instantiated when the class is linked/resolved, + * and all dependencies are resolved. + * Various JDKs do this at different times, so beware: + * java.lang.NoClassDefFoundError when + * calling Class.getDeclaredMethod() (JDK14), + * java.lang.reflect.InvocationTargetException + * (wrapping java.lang.NoClassDefFoundError) when calling + * java.lang.newInstance (JDK13), + * and who knows what else.. + * + * @return value of resourceClass. + */ + public Class loadClass() { + if (resourceClass == null && getClassLoader() != null) { + resourceClass = (Class)AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + try { + return getClassLoader().loadClass(getName()); + } catch (ClassNotFoundException e) { + return null; + } + } + }); + } + return resourceClass; + } + + public String toString() { + return "ResourceClass[" + getName() + ", " + getResource() + ", " + getClassLoader() + "]"; + } +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClass.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassDiscover.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassDiscover.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassDiscover.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassDiscover.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,79 @@ +/* + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.mina.common.support.discovery; + + +/** + * @author Richard A. Sitze + */ +public interface ResourceClassDiscover extends ResourceDiscover +{ + /** + * Locate class resources that are bound to className. + * + * @return ResourceClassIterator + */ + public ResourceClassIterator findResourceClasses(String className); + + /** + * Locate class resources that are bound to resourceNames. + * + * @return ResourceIterator + */ + public ResourceClassIterator findResourceClasses(ResourceNameIterator className); +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassDiscover.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassIterator.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassIterator.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassIterator.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassIterator.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,77 @@ +/* + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.mina.common.support.discovery; + + +/** + * @author Richard A. Sitze + */ +public abstract class ResourceClassIterator extends ResourceIterator +{ + /** + */ + public abstract ResourceClass nextResourceClass(); + + public Resource nextResource() { + return nextResourceClass(); + } + + public String nextResourceName() { + return nextResourceClass().getName(); + } +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceClassIterator.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceDiscover.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceDiscover.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceDiscover.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceDiscover.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,79 @@ +/* + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.mina.common.support.discovery; + + +/** + * @author Richard A. Sitze + */ +public interface ResourceDiscover extends ResourceNameDiscover +{ + /** + * Locate resources that are bound to resourceName. + * + * @return ResourceIterator + */ + public ResourceIterator findResources(String resourceName); + + /** + * Locate resources that are bound to resourceNames. + * + * @return ResourceIterator + */ + public ResourceIterator findResources(ResourceNameIterator resourceNames); +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceDiscover.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceIterator.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceIterator.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceIterator.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceIterator.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,73 @@ +/* + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.mina.common.support.discovery; + + +/** + * @author Richard A. Sitze + */ +public abstract class ResourceIterator implements ResourceNameIterator +{ + /** + */ + public abstract Resource nextResource(); + + public String nextResourceName() { + return nextResource().getName(); + } +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceIterator.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameDiscover.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameDiscover.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameDiscover.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameDiscover.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,84 @@ +/* + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.mina.common.support.discovery; + + +/** + * Interface representing a mapping + * from a set of source resource names + * to a resultant set of resource names. + * + * @author Richard A. Sitze + * @author Costin Manolache + */ +public interface ResourceNameDiscover +{ + /** + * Locate names of resources that are bound to resourceName. + * + * @return ResourceNameIterator + */ + public ResourceNameIterator findResourceNames(String resourceName); + + /** + * Locate names of resources that are bound to resourceNames. + * + * @return ResourceNameIterator + */ + public ResourceNameIterator findResourceNames(ResourceNameIterator resourceNames); +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameDiscover.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameIterator.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameIterator.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameIterator.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameIterator.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,73 @@ +/* + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.mina.common.support.discovery; + + +/** + * @author Richard A. Sitze + */ +public interface ResourceNameIterator +{ + /** + */ + public boolean hasNext(); + + /** + */ + public String nextResourceName(); +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ResourceNameIterator.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ant/ServiceDiscoveryTask.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ant/ServiceDiscoveryTask.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ant/ServiceDiscoveryTask.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ant/ServiceDiscoveryTask.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,115 @@ +/* + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.mina.common.support.discovery.ant; + +import java.util.Vector; + +import org.apache.mina.common.support.discovery.ResourceNameIterator; +import org.apache.mina.common.support.discovery.jdk.JDKHooks; +import org.apache.mina.common.support.discovery.resource.DiscoverResources; + + +/** + * Small ant task that will use discovery to locate a particular impl. + * and display all values. + * + * You can execute this and save it with an id, then other classes can use it. + * + * @author Costin Manolache + */ +public class ServiceDiscoveryTask +{ + String name; + int debug=0; + String[] drivers = null; + + public void setServiceName(String name ) { + this.name=name; + } + + public void setDebug(int i) { + this.debug=i; + } + + public String[] getServiceInfo() { + return drivers; + } + + public void execute() throws Exception { + System.out.println("XXX "); + + DiscoverResources disc = new DiscoverResources(); + disc.addClassLoader( JDKHooks.getJDKHooks().getThreadContextClassLoader() ); + disc.addClassLoader( this.getClass().getClassLoader() ); + + ResourceNameIterator iterator = disc.findResources(name); + + Vector vector = new Vector(); + while (iterator.hasNext()) { + String resourceInfo = iterator.nextResourceName(); + vector.add(resourceInfo); + if( debug > 0 ) { + System.out.println("Found " + resourceInfo); + } + } + + drivers = new String[vector.size()]; + vector.copyInto(drivers); + } + +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/ant/ServiceDiscoveryTask.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision Added: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/jdk/JDK11Hooks.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/jdk/JDK11Hooks.java?rev=370807&view=auto ============================================================================== --- directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/jdk/JDK11Hooks.java (added) +++ directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/jdk/JDK11Hooks.java Fri Jan 20 05:47:50 2006 @@ -0,0 +1,186 @@ +/* + * $Header$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +package org.apache.mina.common.support.discovery.jdk; + +import java.io.IOException; +import java.net.URL; +import java.util.Enumeration; + + +/** + * @author Richard A. Sitze + */ +class JDK11Hooks extends JDKHooks { + private static final ClassLoader systemClassLoader + = new PsuedoSystemClassLoader(); + + + /** + * The thread context class loader is available for JDK 1.2 + * or later, if certain security conditions are met. + * + * @return The thread context class loader, if available. + * Otherwise return null. + */ + public ClassLoader getThreadContextClassLoader() { + return null; + } + + /** + * The system class loader is available for JDK 1.2 + * or later, if certain security conditions are met. + * + * @return The system class loader, if available. + * Otherwise return null. + */ + public ClassLoader getSystemClassLoader() { + return systemClassLoader; + } + + /** + * Implement ClassLoader.getResources for JDK 1.1 + * + * On JDK1.1 there is no getResources() method. We emulate this by + * using introspection and doing the lookup ourself, using the list + * of URLs, via getURLs(). + */ + public Enumeration getResources(ClassLoader loader, + String resourceName) + throws IOException + { + /** + * The simple answer is/was: + * return loader.getResources(resourceName); + * + * However, some classloaders overload the behavior of getResource + * (loadClass, etc) such that the order of returned results changes + * from normally expected behavior. + * + * Example: locate classes/resources from child ClassLoaders first, + * parents last (in some J2EE environs). + * + * The resource returned by getResource() should be the same as the + * first resource returned by getResources(). Unfortunately, this + * is not, and cannot be: getResources() is 'final' in the current + * JDK's (1.2, 1.3, 1.4). + * + * To address this, the implementation of this method will + * return an Enumeration such that the first element is the + * results of getResource, and all trailing elements are + * from getResources. On each iteration, we check so see + * if the resource (from getResources) matches the first resource, + * and eliminate the redundent element. + */ + + final URL first = (URL)loader.getResource(resourceName); + final Enumeration rest = loader.getResources(resourceName); + + return new Enumeration() { + private boolean firstDone = (first == null); + private URL next = getNext(); + + public Object nextElement() { + URL o = next; + next = getNext(); + return o; + } + + public boolean hasMoreElements() { + return next != null; + } + + private URL getNext() { + URL n; + + if (!firstDone) { + /** + * First time through, use results of getReference() + * if they were non-null. + */ + firstDone = true; + n = first; + } else { + /** + * Subsequent times through, + * use results of getReferences() + * but take out anything that matches 'first'. + * + * Iterate through list until we find one that + * doesn't match 'first'. + */ + n = null; + while (rest.hasMoreElements() && n == null) { + n = (URL)rest.nextElement(); + if (first != null && + n != null && + n.equals(first)) + { + n = null; + } + } + } + + return n; + } + }; + } +} Propchange: directory/sandbox/trustin/mina-spi/core/src/main/java/org/apache/mina/common/support/discovery/jdk/JDK11Hooks.java ------------------------------------------------------------------------------ svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision