[jboss-svn-commits] JBL Code SVN: r21628 - in labs/jbossbuild/buildmagic/trunk: build/etc and 100 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Aug 19 18:06:03 EDT 2008
Author: pgier
Date: 2008-08-19 18:06:02 -0400 (Tue, 19 Aug 2008)
New Revision: 21628
Added:
labs/jbossbuild/buildmagic/trunk/common/build.bat
labs/jbossbuild/buildmagic/trunk/common/build.sh
labs/jbossbuild/buildmagic/trunk/common/build.xml
labs/jbossbuild/buildmagic/trunk/common/dependencies.xml
labs/jbossbuild/buildmagic/trunk/common/src/etc/default.mf
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/Interceptor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InterceptorFactory.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/Invocation.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationFactory.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationResponse.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationType.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValue.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValueInputStream.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValueOutputStream.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MetaDataResolver.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/SimpleMetaData.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/Log4jLoggerPlugin.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/Logger.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/LoggerPlugin.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/NullLoggerPlugin.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/XLevel.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/XPriority.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/DailyRollingFileAppender.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/FileAppender.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/RegexEventEvaluator.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/RollingFileAppender.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/PatternLayout.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/PatternParserEx.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/ThreadMDCConverter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/ThreadNDCConverter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/CategoryStream.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/CategoryWriter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/LoggerStream.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/LoggerWriter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/DelegatingURLConnection.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLLister.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLListerBase.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLListerFactory.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLStreamHandlerFactory.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/FileURLConnection.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/FileURLLister.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/Handler.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/http/DavURLLister.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar/Handler.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/Handler.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/ResourceURLConnection.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/AbstractNestedThrowable.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/BenignError.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CachePolicy.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Classes.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CloneableObject.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Coercible.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CoercionException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Counter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/DataConversionException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/DirectoryBuilder.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Duration.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/EmptyStringException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Executable.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/FieldInstance.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/HashCode.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Heap.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/LRUCachePolicy.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/LongCounter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MethodHashing.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuBoolean.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuByte.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuCharacter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuDouble.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuFloat.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuInteger.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuLong.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuNumber.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuShort.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Mutable.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedError.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedRuntimeException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedSQLException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedThrowable.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NoSuchMethodException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NotCoercibleException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NotImplementedException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Null.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NullArgumentException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Objects.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/PrettyString.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Primitives.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Semaphore.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/SoftObject.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/StackTrace.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/StopWatch.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Strings.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Sync.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TCLStack.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/ThrowableHandler.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/ThrowableListener.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Throwables.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimedCachePolicy.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimerQueue.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimerTask.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/UnexpectedThrowable.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/UnreachableStatementException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WaitSemaphore.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WaitSync.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WeakObject.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WorkerQueue.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/BoundCoercionHandler.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/CharacterHandler.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/ClassHandler.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/CoercionHandler.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/FileHandler.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/AbstractQueue.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ArrayIterator.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CachedCollection.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CachedList.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CollectionException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CompoundIterator.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CompoundKey.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/EmptyCollectionException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/FullCollectionException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/Iterators.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ListQueue.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ListSet.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/Queue.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ReverseListIterator.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/SerializableEnumeration.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/WeakSet.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/WeakValueHashMap.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilePrefixFilter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FileSuffixFilter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilenamePrefixFilter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilenameSuffixFilter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/Files.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/JarUtils.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/GUID.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/ID.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/UID.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/VMID.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/JMXExceptionDecoder.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanProxy.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanProxyInstance.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanServerLocator.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/ObjectNameConverter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/ObjectNameFactory.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming/NonSerializableFactory.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming/Util.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/Constants.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/Java.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/PID.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/BoundPropertyAdapter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/BoundPropertyListener.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/Configurable.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/DefaultPropertyReader.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/FieldBoundPropertyListener.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/FilePropertyReader.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/MethodBoundPropertyListener.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/Property.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyAdapter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyContainer.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyError.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyEvent.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyException.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyGroup.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyListener.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyManager.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyMap.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyReader.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/jmx/SystemPropertyClassValue.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ArrayListEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BigDecimalEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BitSetEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BooleanEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ClassEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/CollectionEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/DOM4JElementEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/DateEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/FileEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/HashSetEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/InetAddressEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/IntegerEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/IteratorEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/LinkedListEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ListEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ListIteratorEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ObjectNameEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/PropertiesEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/PropertyEditors.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/SetEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/StackEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/StringArrayEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/TextPropertyEditorSupport.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/TreeSetEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/URLEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/VectorEditor.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/AcceptableState.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/DefaultStateMachineModel.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/State.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateAdapter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateMachine.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateMapping.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/Test.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AppendObjectOutputStream.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AppendingObjectOutputStream.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AutoResetObjectOutputStream.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/CRLFPrintWriter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/NullInputStream.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/NullOutputStream.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/ObjectOutputStreamAdapter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/Printable.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/Streams.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/Timeout.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/TimeoutFactory.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/TimeoutTarget.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/package.html
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/DOMWriter.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/MIME2Java.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/XmlHelper.java
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/package.html
labs/jbossbuild/buildmagic/trunk/common/src/test/org/jboss/util/propertyeditor/PropertyEditorUnitTestCase.java
labs/jbossbuild/buildmagic/trunk/tasks/dependencies.xml
labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/FetchDependencyTask.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/JarDependency.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/Repository.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Ant.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AppendPath.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ContainerTask.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/FindRoot.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Loop.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ProjectHelp.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Script.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedContainerTask.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedTask.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Set.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Unset.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/VariableTask.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/Library.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/LibrarySet.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/ModuleLibrary.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/AbstractInfo.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInfo.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInit.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ProjectInfo.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Dump.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Puke.java
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-fileupload-1.0-beta-1.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-lang-1.0.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/client/lib/commons-httpclient.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-xjavadoc-uc-jb4.jar
labs/jbossbuild/buildmagic/trunk/tools/.donotremove
labs/jbossbuild/buildmagic/trunk/tools/bin/antRun.pl
labs/jbossbuild/buildmagic/trunk/tools/bin/build.bat
labs/jbossbuild/buildmagic/trunk/tools/bin/build.sh
labs/jbossbuild/buildmagic/trunk/tools/bin/common.shlib
labs/jbossbuild/buildmagic/trunk/tools/bin/complete-ant-cmd.pl
labs/jbossbuild/buildmagic/trunk/tools/bin/runant.pl
labs/jbossbuild/buildmagic/trunk/tools/bin/runant.py
labs/jbossbuild/buildmagic/trunk/tools/bin/ubuild.bat
labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/autoload.properties
labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/buildmagic.ent
labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/common.properties
labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/defaults.ent
labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/libraries.ent
labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/modules.ent
labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/targets.ent
labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/task.properties
labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/tools.ent
labs/jbossbuild/buildmagic/trunk/tools/etc/changelog.xsl
labs/jbossbuild/buildmagic/trunk/tools/etc/checkstyle-frames.xsl
labs/jbossbuild/buildmagic/trunk/tools/etc/coverage-frames.xsl
labs/jbossbuild/buildmagic/trunk/tools/etc/jdepend-frames.xsl
labs/jbossbuild/buildmagic/trunk/tools/etc/jdepend.xsl
labs/jbossbuild/buildmagic/trunk/tools/etc/junit-frames.xsl
labs/jbossbuild/buildmagic/trunk/tools/etc/junit-noframes.xsl
labs/jbossbuild/buildmagic/trunk/tools/etc/log.xsl
labs/jbossbuild/buildmagic/trunk/tools/etc/maudit-frames.xsl
labs/jbossbuild/buildmagic/trunk/tools/etc/mmetrics-frames.xsl
labs/jbossbuild/buildmagic/trunk/tools/etc/tagdiff.xsl
labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/templates/mbean-custom.xdt
labs/jbossbuild/buildmagic/trunk/tools/examples/build.bat
labs/jbossbuild/buildmagic/trunk/tools/examples/build.sh
labs/jbossbuild/buildmagic/trunk/tools/lib/crimson.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/optional.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/remote-mbeanserver.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/saxon.jar
Removed:
labs/jbossbuild/buildmagic/trunk/common/archive-browsing/
labs/jbossbuild/buildmagic/trunk/common/assembly/
labs/jbossbuild/buildmagic/trunk/common/common-source/
labs/jbossbuild/buildmagic/trunk/common/namespace/
labs/jbossbuild/buildmagic/trunk/common/primary-source/
labs/jbossbuild/buildmagic/trunk/common/src/main/javax/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/apache/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/deployment/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/io/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/filter/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/jdk/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/nestedjar/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/sockets/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/ssl/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/cache/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/deadlock/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/loading/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/xml/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/threadpool/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/xb/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/xml/
labs/jbossbuild/buildmagic/trunk/common/target/
labs/jbossbuild/buildmagic/trunk/common/testsuite-support/
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/component-info.xml
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/README.txt
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/component-info.xml
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/jboss.patch.txt
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-codec-1.2.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-digester-1.6.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-fileupload.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-httpclient.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-lang-2.0.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-validator-1.1.3.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-vfs.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/component-info.xml
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/lib/snmpTrapAppender.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/component-info.xml
labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/component-info.xml
labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/lib/jaxen-1.1-beta-4.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-getopt/component-info.xml
labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-regexp/component-info.xml
labs/jbossbuild/buildmagic/trunk/thirdparty/junit-junit/component-info.xml
labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/component-info.xml
labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/LICENSE.txt
labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/README.txt
labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/concurrent-src.zip
labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jaxp/component-info.xml
labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jmx/component-info.xml
labs/jbossbuild/buildmagic/trunk/thirdparty/xml-sax/component-info.xml
labs/jbossbuild/buildmagic/trunk/tools/apache/
labs/jbossbuild/buildmagic/trunk/tools/dreambean/
labs/jbossbuild/buildmagic/trunk/tools/etc/buildmagic/
labs/jbossbuild/buildmagic/trunk/tools/etc/cruisecontrol/
labs/jbossbuild/buildmagic/trunk/tools/etc/jbossbuild/
labs/jbossbuild/buildmagic/trunk/tools/jedit/
labs/jbossbuild/buildmagic/trunk/tools/lib/README
labs/jbossbuild/buildmagic/trunk/tools/lib/ant-javamail.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/ant-junit.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/ant-launcher.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/ant-nodeps.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/ant-trax.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/ant-xslp.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/jbossbuild.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/jdtCompilerAdapter.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/org.eclipse.jdt.core_3.1.0.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/pretty.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/resolver.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/retrotranslator/
labs/jbossbuild/buildmagic/trunk/tools/planet57/
labs/jbossbuild/buildmagic/trunk/tools/sun/
Modified:
labs/jbossbuild/buildmagic/trunk/build/
labs/jbossbuild/buildmagic/trunk/build/.cvsignore
labs/jbossbuild/buildmagic/trunk/build/etc/
labs/jbossbuild/buildmagic/trunk/build/etc/local.properties-example
labs/jbossbuild/buildmagic/trunk/build/etc/local.properties-production
labs/jbossbuild/buildmagic/trunk/common/
labs/jbossbuild/buildmagic/trunk/common/src/
labs/jbossbuild/buildmagic/trunk/common/src/etc/
labs/jbossbuild/buildmagic/trunk/common/src/main/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/http/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/jmx/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/catalog/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/catalog/helpers/
labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/catalog/readers/
labs/jbossbuild/buildmagic/trunk/common/src/test/
labs/jbossbuild/buildmagic/trunk/common/src/test/org/
labs/jbossbuild/buildmagic/trunk/common/src/test/org/jboss/
labs/jbossbuild/buildmagic/trunk/common/src/test/org/jboss/util/
labs/jbossbuild/buildmagic/trunk/common/src/test/org/jboss/util/propertyeditor/
labs/jbossbuild/buildmagic/trunk/tasks/
labs/jbossbuild/buildmagic/trunk/tasks/build.xml
labs/jbossbuild/buildmagic/trunk/tasks/src/
labs/jbossbuild/buildmagic/trunk/tasks/src/bin/
labs/jbossbuild/buildmagic/trunk/tasks/src/etc/
labs/jbossbuild/buildmagic/trunk/tasks/src/etc/default.mf
labs/jbossbuild/buildmagic/trunk/tasks/src/main/
labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/
labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/
labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Property.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ExecuteModules.java
labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/
labs/jbossbuild/buildmagic/trunk/tasks/src/resources/
labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/
labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss/
labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss/tools/
labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss/tools/buildmagic/
labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss/tools/buildmagic/task/
labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss/tools/buildmagic/task/autoload.properties
labs/jbossbuild/buildmagic/trunk/thirdparty/
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/LICENSE
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/VERSION
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/lib/bcel.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-beanutils.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-discovery.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-logging-api.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-logging.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/lib/README
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/lib/log4j.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/LICENSE
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/client/
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/client/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/client/lib/webdavlib.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/
labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/README
labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/lib/dom4j.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-getopt/
labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-getopt/LICENSE.lgpl
labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-getopt/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-regexp/
labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-regexp/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/ibm-bsf/
labs/jbossbuild/buildmagic/trunk/thirdparty/ibm-bsf/VERSION
labs/jbossbuild/buildmagic/trunk/thirdparty/ibm-bsf/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/junit-junit/
labs/jbossbuild/buildmagic/trunk/thirdparty/junit-junit/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/junit-junit/lib/junit.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/
labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/concurrent.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jaxp/
labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jaxp/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jaxp/lib/jaxp.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jmx/
labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jmx/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/commons-logging.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-bea-module-jb4.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-ejb-module-jb4.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-java-module-jb4.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-jb4.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-jboss-module-jb4.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-jdo-module-jb4.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-jmx-module-jb4.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-web-module-jb4.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-xdoclet-module-jb4.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-xjavadoc-jb4.jar
labs/jbossbuild/buildmagic/trunk/thirdparty/xml-sax/
labs/jbossbuild/buildmagic/trunk/thirdparty/xml-sax/lib/
labs/jbossbuild/buildmagic/trunk/tools/
labs/jbossbuild/buildmagic/trunk/tools/.project
labs/jbossbuild/buildmagic/trunk/tools/bin/
labs/jbossbuild/buildmagic/trunk/tools/bin/ant
labs/jbossbuild/buildmagic/trunk/tools/bin/ant.bat
labs/jbossbuild/buildmagic/trunk/tools/bin/antRun
labs/jbossbuild/buildmagic/trunk/tools/bin/antRun.bat
labs/jbossbuild/buildmagic/trunk/tools/bin/lcp.bat
labs/jbossbuild/buildmagic/trunk/tools/etc/
labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/
labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/
labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/templates/
labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/templates/mbean-custom.j
labs/jbossbuild/buildmagic/trunk/tools/examples/
labs/jbossbuild/buildmagic/trunk/tools/lib/
labs/jbossbuild/buildmagic/trunk/tools/lib/ant.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/buildmagic-tasks.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/junit.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/xalan.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/xercesImpl.jar
labs/jbossbuild/buildmagic/trunk/tools/lib/xml-apis.jar
Log:
Merge buildmagic 2.0 into trunk.
Property changes on: labs/jbossbuild/buildmagic/trunk/build
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/build/.cvsignore
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/build/etc
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/build/etc/local.properties-example
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/build/etc/local.properties-production
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/build.bat
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/build.bat (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/build.bat 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,103 @@
+ at echo off
+
+REM ======================================================================
+REM
+REM This is the main entry point for the build system.
+REM
+REM ======================================================================
+REM
+REM $Id$
+REM
+REM Authors:
+REM Jason Dillon <jason at planet57.com>
+REM Sacha Labourey <sacha.labourey at cogito-info.ch>
+REM
+
+REM ******************************************************
+REM Ignore the ANT_HOME variable: we want to use *our*
+REM ANT version and associated JARs.
+REM ******************************************************
+REM Ignore the users classpath, cause it might mess
+REM things up
+REM ******************************************************
+
+SETLOCAL
+
+set CLASSPATH=
+set ANT_HOME=
+set JAXP_DOM_FACTORY=org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
+set JAXP_SAX_FACTORY=org.apache.crimson.jaxp.SAXParserFactoryImpl
+REM set JAXP_DOM_FACTORY=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
+REM set JAXP_SAX_FACTORY=org.apache.xerces.jaxp.SAXParserFactoryImpl
+
+set ANT_OPTS=-Djavax.xml.parsers.DocumentBuilderFactory=%JAXP_DOM_FACTORY% -Djavax.xml.parsers.SAXParserFactory=%JAXP_SAX_FACTORY%
+
+REM ******************************************************
+REM - "for" loops have been unrolled for compatibility
+REM with some WIN32 systems.
+REM ******************************************************
+
+set NAMES=tools;
+set SUBFOLDERS=..;..\..;..\..\..;..\..\..\..
+
+REM ******************************************************
+REM ******************************************************
+
+SET EXECUTED=FALSE
+for %%i in (%NAMES%) do call :subLoop %%i %*
+
+goto :EOF
+
+
+REM ******************************************************
+REM ********* Search for names in the subfolders *********
+REM ******************************************************
+
+:subLoop
+SET SUBDIR=%1
+SHIFT
+
+set OTHER_ARGS=
+:setupArgs
+if %1a==a goto doneSetupArgs
+set OTHER_ARGS=%OTHER_ARGS% %1
+shift
+goto setupArgs
+:doneSetupArgs
+
+for %%j in (%SUBFOLDERS%) do call :testIfExists %%j\%SUBDIR%\bin\ant.bat -logger org.apache.tools.ant.NoBannerLogger %OTHER_ARGS%
+
+goto :EOF
+
+
+REM ******************************************************
+REM ************ Test if ANT Batch file exists ***********
+REM ******************************************************
+
+:testIfExists
+if exist %1 call :BatchFound %*
+
+goto :EOF
+
+
+REM ******************************************************
+REM ************** Batch file has been found *************
+REM ******************************************************
+
+:BatchFound
+if (%EXECUTED%)==(FALSE) call :ExecuteBatch %*
+set EXECUTED=TRUE
+
+goto :EOF
+
+REM ******************************************************
+REM ************* Execute Batch file only once ***********
+REM ******************************************************
+
+:ExecuteBatch
+echo Calling %*
+call %*
+
+:end
+
+pause
Property changes on: labs/jbossbuild/buildmagic/trunk/common/build.bat
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/build.sh
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/build.sh (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/build.sh 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,49 @@
+#!/bin/sh
+##
+## Invokes a script of the same name in the 'tools' module.
+##
+## The 'tools' module is expected to be a peer directory of the directory
+## in which this script lives.
+##
+## @author Jason Dillon <jason at planet57.com>
+##
+
+# $Id$
+
+PROGNAME=`basename $0`
+DIRNAME=`dirname $0`
+
+# Buss it yo
+main() {
+ if [ "x$TOOLS_ROOT" = "x" ]; then
+ TOOLS_ROOT=`cd $DIRNAME/../tools; pwd`
+ fi
+
+ MODULE_ROOT=`cd $DIRNAME; pwd`
+ export TOOLS_ROOT MODULE_ROOT DEBUG TRACE
+
+ # Where is the target script?
+ target="$TOOLS_ROOT/bin/$PROGNAME"
+ if [ ! -f "$target" ]; then
+ echo "${PROGNAME}: *ERROR* The target executable does not exist:"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: $target"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: Please make sure you have checked out the 'tools' module"
+ echo "${PROGNAME}: and make sure it is up to date."
+ exit 2
+ fi
+
+ # Get busy yo!
+ if [ "x$DEBUG" != "x" ]; then
+ echo "${PROGNAME}: Executing: /bin/sh $target $@"
+ fi
+ if [ "x$TRACE" = "x" ]; then
+ exec /bin/sh $target "$@"
+ else
+ exec /bin/sh -x $target "$@"
+ fi
+}
+
+# Lets get ready to rumble!
+main "$@"
Property changes on: labs/jbossbuild/buildmagic/trunk/common/build.sh
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/build.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/build.xml (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/build.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,217 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+ <!ENTITY buildmagic SYSTEM "../tools/etc/buildfragments/buildmagic.ent">
+ <!ENTITY tools SYSTEM "../tools/etc/buildfragments/tools.ent">
+ <!ENTITY libraries SYSTEM "../tools/etc/buildfragments/libraries.ent">
+ <!ENTITY modules SYSTEM "../tools/etc/buildfragments/modules.ent">
+ <!ENTITY defaults SYSTEM "../tools/etc/buildfragments/defaults.ent">
+ <!ENTITY targets SYSTEM "../tools/etc/buildfragments/targets.ent">
+]>
+
+<!-- $Id$ -->
+
+<!--+======================================================================+-->
+<!--| JBoss (The OpenSource J2EE WebOS) Build File |-->
+<!--| |-->
+<!--| Distributable under LGPL license. |-->
+<!--| See terms of license at http://www.gnu.org. |-->
+<!--| |-->
+<!--| This file has been designed to work with the 'tools' module and |-->
+<!--| Buildmagic extentions. |-->
+<!--+======================================================================+-->
+
+<project default="main" name="JBoss/Common">
+
+ <!--+====================================================================+-->
+ <!--| Setup |-->
+ <!--| |-->
+ <!--| Include the common build elements. |-->
+ <!--| |-->
+ <!--| This defines several different targets, properties and paths. |-->
+ <!--| It also sets up the basic extention tasks amoung other things. |-->
+ <!--+====================================================================+-->
+
+ &buildmagic;
+ &libraries;
+ &modules;
+ &defaults;
+ &tools;
+ &targets;
+
+
+ <!--+====================================================================+-->
+ <!--| Initialization |-->
+ <!--| |-->
+ <!--| Initialize the build system. Other targets should depend on |-->
+ <!--| 'init'. |-->
+ <!--+====================================================================+-->
+
+ <target name="init" depends="_default:init">
+ <!-- Add module specific elements here. -->
+ </target>
+
+
+ <!--+====================================================================+-->
+ <!--| Configuration |-->
+ <!--| |-->
+ <!--| This target is invoked by the Buildmagic initialization logic |-->
+ <!--| and should contain module specific configuration elements. |-->
+ <!--+====================================================================+-->
+
+ <target name="configure" unless="configure.disable">
+
+ <!-- Module name(s) & version -->
+ <property name="module.name" value="common"/>
+ <property name="module.Name" value="JBoss/Common"/>
+
+ <!-- Configure thirdparty libraries -->
+ <dependency-manager
+ cacheDir="${project.thirdparty.cache}"
+ metadataFile="${project.root}/build/.metadata/${module.name}.tstamp"
+ dependencyFile="${module.root}/dependencies.xml"
+ offline="${dependency-manager.offline}"
+ pathID="library.classpath">
+ <repository url="http://jboss.sf.net/buildmagic/thirdparty" type="jboss"/>
+ </dependency-manager>
+
+ <!-- Required for XDoclet until tools depends are handled by DM -->
+ <call target="configure-libraries"/>
+
+ <!-- Configure modules -->
+ <call target="configure-modules"/>
+ <path id="dependentmodule.classpath">
+ </path>
+
+ <!--+=======================================+-->
+ <!--| Override any default properties here. |-->
+ <!--+=======================================+-->
+
+ <!-- Configure defaults & build tools -->
+ <call target="configure-defaults"/>
+ <call target="configure-tools"/>
+
+ <!--+=======================================+-->
+ <!--| Define module specific elements here. |-->
+ <!--+=======================================+-->
+
+ </target>
+
+
+ <!--+====================================================================+-->
+ <!--| Compile |-->
+ <!--| |-->
+ <!--| This target should depend on other compile-* targets for each |-->
+ <!--| different type of compile that needs to be performed, short of |-->
+ <!--| documentation compiles. |-->
+ <!--+====================================================================+-->
+
+ <target name="compile"
+ description="Compile all source files."
+ depends="compile-mbean-sources,
+ _default:compile-classes,
+ _default:compile-etc,
+ _default:compile-test-classes">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!-- Compile mbeans with XDoclet -->
+ <target name="compile-mbean-sources" depends="init">
+ <mkdir dir="${build.gen-src}"/>
+ <jmxdoclet destdir="${build.gen-src}" excludedtags="@version, at author">
+ <fileset dir="${source.java}">
+ <include name="**/*.java"/>
+ </fileset>
+
+ <mbeaninterface mergedir="${project.tools}/etc/xdoclet/templates"/>
+ </jmxdoclet>
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| test this module |-->
+ <!--| |-->
+ <!--+====================================================================+-->
+ <target name="tests" depends="_default:tests"/>
+
+
+ <!--+====================================================================+-->
+ <!--| Generate Output |-->
+ <!--| |-->
+ <!--| Generates the target output for this module. Target output is |-->
+ <!--| the output which is ment to be released or used by external |-->
+ <!--| modules. |-->
+ <!--+====================================================================+-->
+
+ <target name="output"
+ description="Generate all target output."
+ depends="_buildmagic:build-bypass-check"
+ unless="build-bypass.on">
+
+ <call target="compile"/>
+
+ <mkdir dir="${build.lib}"/>
+
+ <!-- Build the jboss-common.jar -->
+ <jar destfile="${build.lib}/jboss-common.jar" manifest="${build.etc}/default.mf"
+ update="${jar.update}" index="${jar.index}">
+ <fileset dir="${build.classes}">
+ <include name="**"/>
+ </fileset>
+ </jar>
+
+ <!-- Build the jboss-common-client.jar -->
+ <jar destfile="${build.lib}/jboss-common-client.jar" manifest="${build.etc}/default.mf"
+ update="${jar.update}" index="${jar.index}">
+ <fileset dir="${build.classes}">
+ <include name="**"/>
+ </fileset>
+ </jar>
+
+ <!-- testsuite-support.jar -->
+ <jar destfile="${build.lib}/testsuite-support.jar" manifest="${build.etc}/default.mf"
+ update="${jar.update}" index="${jar.index}">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/logging/**"/>
+ </fileset>
+ </jar>
+
+ <!-- Generate checksums -->
+ <call target="_default:compile-checksums"/>
+
+ <!-- Update the build marker to allow bypassing -->
+ <touch file="${build-bypass.marker}"/>
+
+ </target>
+
+
+ <!--+====================================================================+-->
+ <!--| Documents |-->
+ <!--| |-->
+ <!--| Generate all documentation for this module. |-->
+ <!--+====================================================================+-->
+
+ <target name="docs" depends="_default:docs">
+ <!-- Add module specific elements here. -->
+ </target>
+
+
+ <!--+====================================================================+-->
+ <!--| Misc. |-->
+ <!--| |-->
+ <!--| Standard targets and psuedo-targets. |-->
+ <!--+====================================================================+-->
+
+ <target name="clean" depends="_default:clean">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <target name="clobber" depends="_default:clobber">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!-- main, all, most and help are primary psuedo-targets -->
+ <target name="main" depends="most"/>
+ <target name="all" depends="_default:all"/>
+ <target name="most" depends="_default:most"/>
+ <target name="help" depends="_default:help"/>
+
+</project>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/build.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/dependencies.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/dependencies.xml (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/dependencies.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id$ -->
+
+<!--+======================================================================+-->
+<!--| JBoss (The OpenSource J2EE WebOS) Thirdparty Dependencies |-->
+<!--| |-->
+<!--| Distributable under LGPL license. |-->
+<!--| See terms of license at http://www.gnu.org. |-->
+<!--+======================================================================+-->
+
+<dependencies>
+
+ <dependency>
+ <group-id>apache-log4j</group-id>
+ <id>log4j</id>
+ <version>1.2.4</version>
+ </dependency>
+
+ <dependency>
+ <group-id>apache-slide-client</group-id>
+ <id>webdavlib</id>
+ <version>1.0.16</version>
+ </dependency>
+
+ <dependency>
+ <group-id>apache-slide-client</group-id>
+ <id>commons-httpclient</id>
+ <version>1.0.16</version>
+ </dependency>
+
+ <dependency>
+ <id>junit</id>
+ <version>3.7</version>
+ </dependency>
+
+ <dependency>
+ <group-id>gnu-regexp</group-id>
+ <id>regexp</id>
+ <version>1.0.8</version>
+ </dependency>
+
+ <dependency>
+ <group-id>sun-jmx</group-id>
+ <id>jmx</id>
+ <version>1.0ri</version>
+ </dependency>
+
+ <dependency>
+ <id>dom4j</id>
+ <version>1.3</version>
+ </dependency>
+
+</dependencies>
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/dependencies.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/etc
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/etc/default.mf
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/etc/default.mf (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/etc/default.mf 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/Interceptor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/Interceptor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/Interceptor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,22 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.interception;
+
+/**
+ * The interface <code>Interceptor</code> is the basic jboss
+ * interceptor interface for use in mbeans, aop, ejb, and transport
+ * layers. David Jencks is by no means the original author.
+ *
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @version 1.0
+ */
+public interface Interceptor
+{
+ public String getName();
+ public InvocationResponse invoke(Invocation invocation) throws Throwable;
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/Interceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InterceptorFactory.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InterceptorFactory.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InterceptorFactory.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.interception;
+
+/**
+ * The interface <code>InterceptorFactory</code> is the base jboss
+ * means of obtaining an interceptor for use in an interceptor chain.
+ * The key can typically be an indication of which chain is being
+ * constructed, such as a method. The SimpleMetaData is the default
+ * metdata supplied to each invocation using the returned interceptor.
+ * The interceptor factory should store chain specific metadata in the
+ * SimpleMetadata under the interceptor as group and possibly the key
+ * as attr.
+ *
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @version 1.0
+ */
+public interface InterceptorFactory
+{
+ public Interceptor createInterceptor(Object key, SimpleMetaData metadata);
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InterceptorFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/Invocation.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/Invocation.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/Invocation.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.interception;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * The class <code>Invocation</code> is the jboss basic invocation
+ * object. It carries all information in the metaDataResolvers and
+ * uses the interceptors interator to determine the sequence of
+ * Interceptors to go through. The interceptors iterator can be
+ * replaced to redirect to another chain, transfer to another vm, etc.
+ *
+ * The metadata specific to this instance (method name, arguments,
+ * security info, etc) are held in the metadata instance variable.
+ * The "container specific" metadata that is normally set up by
+ * Interceptor factories on deployment is in the final metadata in the
+ * metaDataResolvers list so it may be overridden by other metadata.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @version $Revision$
+ *
+ */
+public class Invocation
+{
+ protected InvocationType type;
+
+ protected transient Iterator interceptors;
+ protected transient List metaDataResolvers = null;
+
+ protected SimpleMetaData metadata = new SimpleMetaData();
+
+ public Invocation(InvocationType type, Iterator interceptors, List metaDataResolvers)
+ {
+ // We expect a copy of the interceptor chain so that it can't change
+ // in the middle of an invocation. This is so that
+ // we can redeploy interceptor chains, yet not effect
+ // currently running invocations.
+ this.interceptors = interceptors;
+ this.type = type;
+
+ //
+ // We expect a copy
+ //
+ this.metaDataResolvers = metaDataResolvers;
+ this.metaDataResolvers.add(0, metadata);
+ }
+
+
+
+ public InvocationResponse invokeNext() throws Throwable
+ {
+ if (interceptors.hasNext())
+ {
+ Interceptor next = (Interceptor)interceptors.next();
+ return next.invoke(this);
+ }
+ throw new RuntimeException("End of interceptor chain reached!");
+ }
+
+ public InvocationType getType()
+ {
+ return type;
+ }
+
+ public void setInterceptors(Iterator interceptors)
+ {
+ this.interceptors = interceptors;
+ }
+
+ public SimpleMetaData getInstanceMetaData()
+ {
+ return metadata;
+ }
+
+ public Object getMetaData(String group, String attr)
+ {
+ for (Iterator i = metaDataResolvers.iterator(); i.hasNext(); )
+ {
+ MetaDataResolver resolver = (MetaDataResolver)i.next();
+ Object val = resolver.resolve(this, group, attr);
+ if (val != null)
+ {
+ return val;
+ }
+ }
+ return null;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/Invocation.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationFactory.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationFactory.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationFactory.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,143 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.interception;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The class <code>InvocationFactory</code> is the generic factory for
+ * constructing invocation objects using particular chains of
+ * interceptors. This handles multiple chains selected based on a key
+ * such as the method being invoked. Interceptor factories are
+ * expected to store instance specific metadata in the supplied
+ * SimpleMetaData object when a chain is being constructed.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @version $Revision$
+ *
+ */
+public abstract class InvocationFactory
+{
+
+ //This synchronization barrier should be sufficient to assure that,
+ //with copy-on-write, we always get a consistent view of a chain.
+ private final Map chains = Collections.synchronizedMap(new HashMap());
+
+ /**
+ * The field <code>defaultMetaData</code> contains the default
+ * metadata set up by the interceptor chains. It is added last to
+ * the metadatas in each Invocation so it may be overridden.
+ *
+ */
+ protected SimpleMetaData defaultMetaData = new SimpleMetaData();
+
+ protected String name;
+
+ public InvocationFactory(String name)
+ {
+ this.name = name;
+ }
+
+
+ public SimpleMetaData getDefaultMetaData()
+ {
+ return defaultMetaData;
+ }
+
+
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * The <code>newInvocation</code> method constructs a new Invocation
+ * object of the specified type. It uses the key to obtain the
+ * correct chain for constructing the interceptor iterator. It uses
+ * the supplied metadatas for metadata, after inserting the default
+ * metadata as the first element.
+ *
+ * @param type an <code>InvocationType</code> value
+ * @param key an <code>Object</code> value
+ * @param metadatas a <code>List</code> value
+ * @return an <code>Invocation</code> value
+ */
+ protected Invocation newInvocation(InvocationType type, Object key, List metadatas)
+ {
+ List chain = (List)chains.get(key);
+ if (chain == null)
+ {
+ throw new IllegalArgumentException("No chain found for key: " + key);
+ } // end of if ()
+ if (metadatas == null)
+ {
+ metadatas = new LinkedList();
+ } // end of if ()
+ //Add the default metadata last so it may be overridden.
+ //synchronization is necessary to assure we have an accurate
+ //view of the default metadata in case it was constructed or
+ //modified in a different thread. See discussions of
+ //double-checked locking is broken.
+ synchronized (defaultMetaData)
+ {
+ metadatas.add(metadatas.size(), defaultMetaData);
+ }
+ Invocation invocation = new Invocation(type, chain.iterator(), metadatas);
+ return invocation;
+ }
+
+ /**
+ * The <code>setChain</code> method maps the supplied key to the
+ * supplied interceptor chain.
+ *
+ * @param key an <code>Object</code> value
+ * @param chain a <code>List</code> value
+ */
+ public void setChain(Object key, List chain)
+ {
+ chains.put(key, chain);
+ }
+
+ /**
+ * The <code>createChain</code> method constructs an interceptor
+ * chain using the supplied list of InterceptorFactories by asking
+ * each factory in order to supply an interceptor for the key and
+ * metadata. If the factory returns a non-null result, it is added
+ * to the chain. The factory may also add appropriately processed
+ * metadata to the metadata map.
+ *
+ * @param key an <code>Object</code> value
+ * @param metadata a <code>MetaDataResolver</code> value
+ * @param factories a <code>List</code> value
+ */
+ public void createChain(Object key, List factories)
+ {
+ List chain = new ArrayList(factories.size());
+ for (Iterator i = factories.iterator(); i.hasNext(); )
+ {
+ Interceptor interceptor = ((InterceptorFactory)i.next()).createInterceptor(key, defaultMetaData);
+ if (interceptor != null)
+ {
+ chain.add(interceptor);
+ } // end of if ()
+
+ } // end of for ()
+ setChain(key, chain);
+ }
+
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationResponse.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationResponse.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationResponse.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,121 @@
+/*
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
+package org.jboss.interception;
+
+import java.io.DataOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.HashMap;
+
+/**
+ * Allows interceptors to communicate information back up the chain on
+ * return from a call.
+ *
+ * @see <related>
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ *
+ */
+public class InvocationResponse
+ implements java.io.Externalizable
+{
+ // Constants -----------------------------------------------------
+
+ /** Serial Version Identifier. */
+ // REVISIT: need to generate serialVersionUID
+ //static final long serialVersionUID = -718723094688127810L;
+
+ // The Map of methods used by this Invocation
+ protected HashMap contextInfo = null;
+ protected Object response = null;
+
+ // Constructors --------------------------------------------------
+ public InvocationResponse()
+ {
+ }
+ public InvocationResponse(Object obj)
+ {
+ if (obj instanceof InvocationResponse)
+ {
+ System.out.println("***********************");
+ new Exception().printStackTrace();
+ throw new RuntimeException("Stuffing an InvocationResponse within an InvocationResponse!!!!");
+ }
+ this.response = obj;
+ }
+
+ public Object getResponse() { return response; }
+ public void setResponse(Object obj)
+ {
+ if (obj instanceof InvocationResponse)
+ {
+ System.out.println("***********************");
+ new Exception().printStackTrace();
+ throw new RuntimeException("Stuffing an InvocationResponse within an InvocationResponse!!!!");
+ }
+ response = obj;
+ }
+
+ public void addAttachment(Object key, Object val)
+ {
+ if (contextInfo == null) contextInfo = new HashMap(1);
+ contextInfo.put(key, val);
+ }
+
+ public Object getAttachment(Object key)
+ {
+ if (contextInfo == null) return null;
+ return contextInfo.get(key);
+ }
+
+ // Externalizable implementation ---------------------------------
+ public void writeExternal(java.io.ObjectOutput out)
+ throws IOException
+ {
+ out.writeObject(response);
+ if (contextInfo == null)
+ {
+ out.writeInt(0);
+ }
+ else
+ {
+ out.writeInt(contextInfo.size());
+ Iterator keys = contextInfo.keySet().iterator();
+ while (keys.hasNext())
+ {
+ Object currentKey = keys.next();
+ out.writeObject(currentKey);
+ out.writeObject(contextInfo.get(currentKey));
+ }
+ }
+ }
+
+ public void readExternal(java.io.ObjectInput in)
+ throws IOException, ClassNotFoundException
+ {
+ response = in.readObject();
+
+ // contextInfo
+ int size = in.readInt();
+ if (size == 0)
+ {
+ contextInfo = null;
+ }
+ else
+ {
+ contextInfo = new HashMap(size);
+ for (int i = 0; i < size; i++)
+ {
+ Object key = in.readObject();
+ Object value = in.readObject();
+ contextInfo.put(key, value);
+ }
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationResponse.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationType.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationType.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationType.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.interception;
+
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import java.util.ArrayList;
+
+/**
+ * Type safe enumeration used for to identify the invocation types.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public final class InvocationType implements Serializable {
+ // these fields are used for serialization
+ private static int nextOrdinal = 0;
+ private static final ArrayList values = new ArrayList(4);
+
+ public static final InvocationType METHOD =
+ new InvocationType("METHOD", false, false);
+ public static final InvocationType FIELD_READ =
+ new InvocationType("FIELD_READ", false, true);
+ public static final InvocationType FIELD_WRITE =
+ new InvocationType("FIELD_WRITE", true, false);
+ public static final InvocationType CONSTRUCTOR =
+ new InvocationType("CONSTRUCTOR", true, true);
+
+ private final transient String name;
+ private final transient boolean isLocal;
+ private final transient boolean isHome;
+
+ // this is the only value serialized
+ private final int ordinal;
+
+ private InvocationType(String name, boolean isHome, boolean isLocal) {
+ this.name = name;
+ this.isLocal = isLocal;
+ this.isHome = isHome;
+ this.ordinal = nextOrdinal++;
+ values.add(this);
+ }
+
+ public boolean isLocal()
+ {
+ return isLocal;
+ }
+
+ public boolean isHome()
+ {
+ return isHome;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ Object readResolve() throws ObjectStreamException {
+ return values.get(ordinal);
+ }
+}
+
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/InvocationType.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValue.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValue.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValue.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,178 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.interception;
+
+import java.io.DataOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.OutputStream;
+
+import java.util.Arrays;
+
+/**
+ * A simple replacement for the RMI MarshalledObject that uses the thread
+ * context class loader for resolving classes and proxies. This currently does
+ * not support class annotations and dynamic class loading.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class MarshalledValue
+ implements java.io.Externalizable
+{
+ /** Serial Version Identifier. */
+ private static final long serialVersionUID = -1527598981234110311L;
+
+ /**
+ * The serialized form of the value. If <code>serializedForm</code> is
+ * <code>null</code> then the object marshalled was a <code>null</code>
+ * reference.
+ */
+ private byte[] serializedForm = null;
+
+ /**
+ * The RMI MarshalledObject hash of the serializedForm array
+ */
+ private int hashCode;
+ private boolean isHashComputed = false;
+
+ private ByteArrayOutputStream baos = null;
+
+ /**
+ * Exposed for externalization.
+ */
+ public MarshalledValue()
+ {
+ super();
+ }
+
+ public MarshalledValue(Object obj) throws IOException
+ {
+ baos = new ByteArrayOutputStream();
+ MarshalledValueOutputStream mvos = new MarshalledValueOutputStream(baos);
+ mvos.writeObject(obj);
+ mvos.flush();
+
+ isHashComputed = false;
+ }
+
+ public Object get() throws IOException, ClassNotFoundException
+ {
+ if (serializedForm == null)
+ return null;
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(serializedForm);
+ MarshalledValueInputStream mvis = new MarshalledValueInputStream(bais);
+ return mvis.readObject();
+ }
+
+ public byte[] toByteArray()
+ {
+ return serializedForm;
+ }
+
+ public int size()
+ {
+ int size = serializedForm != null ? serializedForm.length : 0;
+ return size;
+ }
+
+ /**
+ * Return a hash code for the serialized form of the value.
+ *
+ * @return the serialized form value hash.
+ */
+ public int hashCode()
+ {
+ // lazy computing of hash: we don't need it most of the time
+ //
+ if (!isHashComputed)
+ {
+ int hash = 0;
+ for (int i = 0; i < serializedForm.length; i++)
+ {
+ hash = 31 * hash + serializedForm[i];
+ }
+
+ hashCode = hash;
+ }
+
+ return hashCode;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if( this == obj )
+ return true;
+
+ boolean equals = false;
+ if( obj instanceof MarshalledValue )
+ {
+ MarshalledValue mv = (MarshalledValue) obj;
+ if( serializedForm == mv.serializedForm )
+ {
+ equals = true;
+ }
+ else
+ {
+ equals = Arrays.equals(serializedForm, mv.serializedForm);
+ }
+ }
+ return equals;
+ }
+
+ /**
+ * The object implements the readExternal method to restore its
+ * contents by calling the methods of DataInput for primitive
+ * types and readObject for objects, strings and arrays. The
+ * readExternal method must read the values in the same sequence
+ * and with the same types as were written by writeExternal.
+ *
+ * @param in the stream to read data from in order to restore the object
+ *
+ * @throws IOException if I/O errors occur
+ * @throws ClassNotFoundException If the class for an object being
+ * restored cannot be found.
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ int length = in.readInt();
+ serializedForm = null;
+ if( length > 0 )
+ {
+ serializedForm = new byte[length];
+ in.readFully(serializedForm);
+ }
+ isHashComputed = false;
+ }
+
+ /**
+ * The object implements the writeExternal method to save its contents
+ * by calling the methods of DataOutput for its primitive values or
+ * calling the writeObject method of ObjectOutput for objects, strings,
+ * and arrays.
+ *
+ * @serialData Overriding methods should use this tag to describe
+ * the data layout of this Externalizable object.
+ * List the sequence of element types and, if possible,
+ * relate the element to a public/protected field and/or
+ * method of this Externalizable class.
+ *
+ * @param out the stream to write the object to
+ *
+ * @throws IOException Includes any I/O exceptions that may occur
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeInt(baos.size());
+ baos.writeTo((OutputStream)out);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValue.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValueInputStream.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValueInputStream.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValueInputStream.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.interception;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+
+import org.jboss.logging.Logger;
+
+/**
+ * An ObjectInputStream subclass used by the MarshalledValue class to
+ * ensure the classes and proxies are loaded using the thread context
+ * class loader.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class MarshalledValueInputStream
+ extends ObjectInputStream
+{
+ private static Logger log = Logger.getLogger(MarshalledValueInputStream.class);
+
+ /**
+ * Creates a new instance of MarshalledValueOutputStream
+ */
+ public MarshalledValueInputStream(InputStream is) throws IOException
+ {
+ super(is);
+ }
+
+ /**
+ * Use the thread context class loader to resolve the class
+ *
+ * @throws IOException Any exception thrown by the underlying OutputStream.
+ */
+ protected Class resolveClass(ObjectStreamClass v)
+ throws IOException, ClassNotFoundException
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ String className = v.getName();
+ return loader.loadClass(className);
+ }
+
+ protected Class resolveProxyClass(String[] interfaces)
+ throws IOException, ClassNotFoundException
+ {
+ if( log.isDebugEnabled() )
+ {
+ StringBuffer tmp = new StringBuffer("[");
+ for(int i = 0; i < interfaces.length; i ++)
+ {
+ if( i > 0 )
+ tmp.append(',');
+ tmp.append(interfaces[i]);
+ }
+ tmp.append(']');
+ log.debug("resolveProxyClass called, ifaces="+tmp.toString());
+ }
+
+ // Load the interfaces from the thread context class loader
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Class[] ifaceClasses = new Class[interfaces.length];
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ ifaceClasses[i] = loader.loadClass(interfaces[i]);
+ }
+
+ return java.lang.reflect.Proxy.getProxyClass(loader, ifaceClasses);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValueInputStream.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValueOutputStream.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValueOutputStream.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValueOutputStream.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.interception;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.ObjectOutputStream;
+import java.rmi.Remote;
+import java.rmi.server.RemoteObject;
+import java.rmi.server.RemoteStub;
+
+/**
+ * An ObjectOutputStream subclass used by the MarshalledValue class to
+ * ensure the classes and proxies are loaded using the thread context
+ * class loader. Currently this does not do anything as neither class or
+ * proxy annotations are used.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class MarshalledValueOutputStream
+ extends ObjectOutputStream
+{
+ /** Creates a new instance of MarshalledValueOutputStream
+ If there is a security manager installed, this method requires a
+ SerializablePermission("enableSubstitution") permission to ensure it's
+ ok to enable the stream to do replacement of objects in the stream.
+ */
+ public MarshalledValueOutputStream(OutputStream os) throws IOException
+ {
+ super(os);
+ enableReplaceObject(true);
+ }
+
+ /**
+ * @throws IOException Any exception thrown by the underlying OutputStream.
+ */
+ protected void annotateClass(Class cl) throws IOException
+ {
+ super.annotateClass(cl);
+ }
+
+ /**
+ * @throws IOException Any exception thrown by the underlying OutputStream.
+ */
+ protected void annotateProxyClass(Class cl) throws IOException
+ {
+ super.annotateProxyClass(cl);
+ }
+
+ /** Override replaceObject to check for Remote objects that are
+ not RemoteStubs.
+ */
+ protected Object replaceObject(Object obj) throws IOException
+ {
+ if( (obj instanceof Remote) && !(obj instanceof RemoteStub) )
+ {
+ Remote remote = (Remote) obj;
+ try
+ {
+ obj = RemoteObject.toStub(remote);
+ }
+ catch(IOException ignore)
+ {
+ // Let the Serialization layer try with the orignal obj
+ }
+ }
+ return obj;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MarshalledValueOutputStream.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MetaDataResolver.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MetaDataResolver.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MetaDataResolver.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,21 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.interception;
+
+/**
+ * Interface to generic metadata framework.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public interface MetaDataResolver
+{
+ public Object resolve(Invocation invocation, Object group, Object attr);
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/MetaDataResolver.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/SimpleMetaData.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/SimpleMetaData.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/SimpleMetaData.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,208 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.interception;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.jboss.util.NestedRuntimeException;
+/**
+ * SimpleMetaData provides hashmap based metadata storage and manages
+ * serializtion of the contents based on the flags supplied.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @version $Revision$
+ *
+ */
+public class SimpleMetaData implements MetaDataResolver
+{
+ public static final byte TRANSIENT = 0x01;
+ public static final byte AS_IS = 0x02;
+ public static final byte MARSHALLED = 0x04;
+
+ protected final Map metaData;
+
+ /**
+ * Creates an empty <code>SimpleMetaData</code>.
+ *
+ */
+ public SimpleMetaData()
+ {
+ metaData = new HashMap();
+ }
+
+
+ public void addMetaData(Object group, Object attr, Object value)
+ {
+ addMetaData(group, attr, value, MARSHALLED);
+ }
+
+ public synchronized void addMetaData(Object group, Object attr, Object value, byte type)
+ {
+ HashMap groupData = (HashMap)metaData.get(group);
+ if (groupData == null)
+ {
+ groupData = new HashMap();
+ metaData.put(group, groupData);
+ }
+ MetaDataValue val = new MetaDataValue(type, value);
+ groupData.put(attr, val);
+ }
+
+ public synchronized Object getMetaData(Object group, Object attr)
+ {
+ try
+ {
+ HashMap groupData = (HashMap)metaData.get(group);
+ if (groupData == null) return null;
+ MetaDataValue val = (MetaDataValue)groupData.get(attr);
+ return val.get();
+ }
+ catch (IOException ioex)
+ {
+ throw new NestedRuntimeException("failed on MarshalledValue", ioex);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ throw new NestedRuntimeException("failed on MarshalledValue", ex);
+ }
+ }
+
+ public synchronized void removeMetaData(Object group, Object attr)
+ {
+ HashMap groupData = (HashMap)metaData.get(group);
+ if (groupData != null)
+ {
+ groupData.remove(attr);
+ }
+ }
+
+ public synchronized void removeGroupData(Object group)
+ {
+ metaData.remove(group);
+ }
+
+ public synchronized void clear()
+ {
+ metaData.clear();
+ }
+
+ public synchronized void mergeIn(SimpleMetaData data)
+ {
+ Iterator it = data.metaData.keySet().iterator();
+ while (it.hasNext())
+ {
+ Object group = (String)it.next();
+ HashMap attrs = (HashMap)data.metaData.get(group);
+ HashMap map = (HashMap)metaData.get(group);
+ if (map == null)
+ {
+ map = new HashMap();
+ this.metaData.put(group, map);
+ }
+ map.putAll(attrs);
+ }
+ }
+
+ public synchronized Object resolve(Invocation invocation, Object group, Object attr)
+ {
+ return getMetaData(group, attr);
+ }
+
+ public synchronized void writeExternal(java.io.ObjectOutput out)
+ throws IOException
+ {
+ for (Iterator it = metaData.keySet().iterator(); it.hasNext(); )
+ {
+ Object group = it.next();
+ HashMap map = (HashMap)metaData.get(group);
+ if (map != null && map.size() > 0)
+ {
+ boolean groupWritten = false;
+ for (Iterator attrs = map.keySet().iterator(); it.hasNext(); )
+ {
+ Object attr = attrs.next();
+ MetaDataValue value = (MetaDataValue)map.get(attr);
+ if (value.type == TRANSIENT) continue;
+ if (!groupWritten)
+ {
+ groupWritten = true;
+ out.writeObject(group);
+ }
+ out.writeObject(attr);
+ if (value.type == AS_IS)
+ {
+ out.writeObject(value.value);
+ }
+ else
+ {
+ out.writeObject(new MarshalledValue(value.value));
+ }
+ }
+ if (groupWritten) out.writeObject(null); // placeholder for end of attributes
+ }
+ }
+ out.writeObject(null); // place holder for end of marshall
+ }
+
+ public synchronized void readExternal(java.io.ObjectInput in)
+ throws IOException, ClassNotFoundException
+ {
+ Object group;
+ while ((group = (String)in.readObject()) != null)
+ {
+ HashMap map = new HashMap();
+ metaData.put(group, map);
+ Object attr;
+ while ((attr = (String)in.readObject()) != null)
+ {
+ Object obj = in.readObject();
+ if (obj instanceof MarshalledValue)
+ {
+ map.put(attr, new MetaDataValue(MARSHALLED, obj));
+ }
+ else
+ {
+ map.put(attr, new MetaDataValue(AS_IS, obj));
+ }
+ }
+ }
+ }
+
+ //Inner classes----------------------
+ protected class MetaDataValue
+ {
+
+ public final byte type;
+ public final Object value;
+
+ public MetaDataValue(byte type, Object value)
+ {
+ this.type = type;
+ this.value = value;
+ }
+
+ public Object get()
+ throws java.io.IOException, ClassNotFoundException
+ {
+ if (value instanceof MarshalledValue)
+ {
+ return ((MarshalledValue)value).get();
+ }
+ return value;
+ }
+
+ }
+
+
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/interception/SimpleMetaData.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/Log4jLoggerPlugin.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/Log4jLoggerPlugin.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/Log4jLoggerPlugin.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,276 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.logging;
+
+import org.apache.log4j.Category;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Priority;
+
+/**
+ * Delegate for org.jboss.logging.Logger logging to log4j. Body of implementation
+ * mainly copied from old Logger implementation.
+ *
+ * @see org.jboss.logging.Logger
+ * @see org.jboss.logging.LoggerPlugin
+ *
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @version $Revision$
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>3. mai 2002 Sacha Labourey:</b>
+ * <ul>
+ * <li> First implementation </li>
+ * </ul>
+ * </p>
+ * <p><b>4. february 2003 Dag Liodden:</b>
+ * <ul>
+ * <li>Fixed Log4J locationinfo by sending the fully qualified classname of <code>Logger</code> to Log4J</li>
+ * </ul>
+ * </p>
+ */
+
+public class Log4jLoggerPlugin implements LoggerPlugin
+{
+
+ // Constants -----------------------------------------------------
+
+ /**
+ * Fully qualified classname for this class so Log4J locationinfo will be
+ * correct
+ */
+ private static final String FQCN = Logger.class.getName();
+
+ // Attributes ----------------------------------------------------
+
+ /** The Log4j delegate logger. */
+ private transient org.apache.log4j.Logger log;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public Log4jLoggerPlugin () { }
+
+ public void init (String name)
+ {
+ log = LogManager.getLogger(name);
+ }
+
+ // Public --------------------------------------------------------
+
+ public Category getCategory()
+ {
+ return log;
+ }
+
+ /**
+ * Exposes the delegate Log4j Logger.
+ */
+ public org.apache.log4j.Logger getLogger()
+ {
+ return log;
+ }
+
+ // LoggerPlugin implementation ----------------------------------------------
+
+ public boolean isTraceEnabled()
+ {
+ if (log.isEnabledFor(XLevel.TRACE) == false)
+ return false;
+ return XLevel.TRACE.isGreaterOrEqual(log.getEffectiveLevel());
+ }
+
+ /**
+ * Issue a log msg with a level of TRACE.
+ * Invokes log.log(XLevel.TRACE, message);
+ */
+ public void trace(Object message)
+ {
+ log.log(FQCN, XLevel.TRACE, message, null);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of TRACE.
+ * Invokes log.log(XLevel.TRACE, message, t);
+ */
+ public void trace(Object message, Throwable t)
+ {
+ log.log(FQCN, XLevel.TRACE, message, t);
+ }
+
+ /**
+ * Check to see if the TRACE level is enabled for this logger.
+ *
+ * @return true if a {@link #trace(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ public boolean isDebugEnabled()
+ {
+ Level l = Level.DEBUG;
+ if (log.isEnabledFor(l) == false)
+ return false;
+ return l.isGreaterOrEqual(log.getEffectiveLevel());
+ }
+
+ /**
+ * Issue a log msg with a level of DEBUG.
+ * Invokes log.log(Level.DEBUG, message);
+ */
+ public void debug(Object message)
+ {
+ log.log(FQCN, Level.DEBUG, message, null);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of DEBUG.
+ * Invokes log.log(Level.DEBUG, message, t);
+ */
+ public void debug(Object message, Throwable t)
+ {
+ log.log(FQCN, Level.DEBUG, message, t);
+ }
+
+ /**
+ * Check to see if the INFO level is enabled for this logger.
+ *
+ * @return true if a {@link #info(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ public boolean isInfoEnabled()
+ {
+ Level l = Level.INFO;
+ if (log.isEnabledFor(l) == false)
+ return false;
+ return l.isGreaterOrEqual(log.getEffectiveLevel());
+ }
+
+ /**
+ * Issue a log msg with a level of INFO.
+ * Invokes log.log(Level.INFO, message);
+ */
+ public void info(Object message)
+ {
+ log.log(FQCN, Level.INFO, message, null);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of INFO.
+ * Invokes log.log(Level.INFO, message, t);
+ */
+ public void info(Object message, Throwable t)
+ {
+ log.log(FQCN, Level.INFO, message, t);
+ }
+
+ /**
+ * Issue a log msg with a level of WARN.
+ * Invokes log.log(Level.WARN, message);
+ */
+ public void warn(Object message)
+ {
+ log.log(FQCN, Level.WARN, message, null);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of WARN.
+ * Invokes log.log(Level.WARN, message, t);
+ */
+ public void warn(Object message, Throwable t)
+ {
+ log.log(FQCN, Level.WARN, message, t);
+ }
+
+ /**
+ * Issue a log msg with a level of ERROR.
+ * Invokes log.log(Level.ERROR, message);
+ */
+ public void error(Object message)
+ {
+ log.log(FQCN, Level.ERROR, message, null);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of ERROR.
+ * Invokes log.log(Level.ERROR, message, t);
+ */
+ public void error(Object message, Throwable t)
+ {
+ log.log(FQCN, Level.ERROR, message, t);
+ }
+
+ /**
+ * Issue a log msg with a level of FATAL.
+ * Invokes log.log(Level.FATAL, message);
+ */
+ public void fatal(Object message)
+ {
+ log.log(FQCN, Level.FATAL, message, null);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of FATAL.
+ * Invokes log.log(Level.FATAL, message, t);
+ */
+ public void fatal(Object message, Throwable t)
+ {
+ log.log(FQCN, Level.FATAL, message, t);
+ }
+
+ /**
+ * Issue a log msg with the given level.
+ * Invokes log.log(p, message);
+ *
+ * @deprecated Use Level versions.
+ */
+ public void log(Priority p, Object message)
+ {
+ log.log(FQCN, p, message, null);
+ }
+
+ /**
+ * Issue a log msg with the given priority.
+ * Invokes log.log(p, message, t);
+ *
+ * @deprecated Use Level versions.
+ */
+ public void log(Priority p, Object message, Throwable t)
+ {
+ log.log(FQCN, p, message, t);
+ }
+
+ /**
+ * Issue a log msg with the given level.
+ * Invokes log.log(l, message);
+ */
+ public void log(Level l, Object message)
+ {
+ log.log(FQCN, l, message, null);
+ }
+
+ /**
+ * Issue a log msg with the given level.
+ * Invokes log.log(l, message, t);
+ */
+ public void log(Level l, Object message, Throwable t)
+ {
+ log.log(FQCN, l, message, t);
+ }
+
+ // Y overrides ---------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/Log4jLoggerPlugin.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/Logger.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/Logger.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/Logger.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,331 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.logging;
+
+/**
+ * Logger wrapper that tries to dynamically load a log4j class to
+ * determine if log4j is available in the VM. If it is the case,
+ * a log4j delegate is built and used. In the contrary, a null
+ * logger is used. This class cannot directly reference log4j
+ * classes otherwise the JVM will try to load it and make it fail.
+ *
+ * A custom Log4j Logger wrapper that adds a trace level and
+ * is serializable.
+ *
+ * <p>Only exposes the relevent factory and logging methods.
+ *
+ * @see #isTraceEnabled
+ * @see #trace(Object)
+ * @see #trace(Object,Throwable)
+ *
+ * @version <tt>$Revision$</tt>
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>30 mai 2002 Sacha Labourey:</b>
+ * <ul>
+ * <li> No more dedicated to log4j: uses a delegate for logging
+ * and only uses log4j delegate if log4j classes are available on classpath</li>
+ * </ul>
+ */
+public class Logger
+ implements java.io.Serializable
+{
+ protected static Class pluginClass = null;
+
+ // We don't directly reference the class so that this class can be loaded
+ // without the JVM to try to load any log4j classes
+ //
+ protected static final String LOG4J_PLUGIN_CLASS_NAME = "org.jboss.logging.Log4jLoggerPlugin";
+ protected static final String LOG4J_DETECTOR_CLASS_NAME = "org.apache.log4j.Logger";
+
+ static
+ {
+ init();
+ }
+
+ /** The logger name. */
+ private final String name;
+
+ protected transient LoggerPlugin loggerDelegate = null;
+
+ /**
+ * Creates new Logger the given logger name.
+ *
+ * @param name the logger name.
+ */
+ protected Logger(final String name)
+ {
+ this.name = name;
+ this.loggerDelegate = getDelegatePlugin (name);
+ }
+
+ /**
+ * Return the name of this logger.
+ *
+ * @return The name of this logger.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ public LoggerPlugin getLoggerPlugin ()
+ {
+ return this.loggerDelegate;
+ }
+ /**
+ * Check to see if the TRACE level is enabled for this logger.
+ *
+ * @return true if a {@link #trace(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ public boolean isTraceEnabled()
+ {
+ return loggerDelegate.isTraceEnabled ();
+ }
+
+ /**
+ * Issue a log msg with a level of TRACE.
+ * Invokes log.log(XLevel.TRACE, message);
+ */
+ public void trace(Object message)
+ {
+ loggerDelegate.trace (message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of TRACE.
+ * Invokes log.log(XLevel.TRACE, message, t);
+ */
+ public void trace(Object message, Throwable t)
+ {
+ loggerDelegate.trace (message, t);
+ }
+
+ /**
+ * Check to see if the TRACE level is enabled for this logger.
+ *
+ * @return true if a {@link #trace(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ public boolean isDebugEnabled()
+ {
+ return loggerDelegate.isDebugEnabled ();
+ }
+
+ /**
+ * Issue a log msg with a level of DEBUG.
+ * Invokes log.log(Level.DEBUG, message);
+ */
+ public void debug(Object message)
+ {
+ loggerDelegate.debug (message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of DEBUG.
+ * Invokes log.log(Level.DEBUG, message, t);
+ */
+ public void debug(Object message, Throwable t)
+ {
+ loggerDelegate.debug (message, t);
+ }
+
+ /**
+ * Check to see if the INFO level is enabled for this logger.
+ *
+ * @return true if a {@link #info(Object)} method invocation would pass
+ * the msg to the configured appenders, false otherwise.
+ */
+ public boolean isInfoEnabled()
+ {
+ return loggerDelegate.isInfoEnabled ();
+ }
+
+ /**
+ * Issue a log msg with a level of INFO.
+ * Invokes log.log(Level.INFO, message);
+ */
+ public void info(Object message)
+ {
+ loggerDelegate.info (message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of INFO.
+ * Invokes log.log(Level.INFO, message, t);
+ */
+ public void info(Object message, Throwable t)
+ {
+ loggerDelegate.info (message, t);
+ }
+
+ /**
+ * Issue a log msg with a level of WARN.
+ * Invokes log.log(Level.WARN, message);
+ */
+ public void warn(Object message)
+ {
+ loggerDelegate.warn (message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of WARN.
+ * Invokes log.log(Level.WARN, message, t);
+ */
+ public void warn(Object message, Throwable t)
+ {
+ loggerDelegate.warn (message, t);
+ }
+
+ /**
+ * Issue a log msg with a level of ERROR.
+ * Invokes log.log(Level.ERROR, message);
+ */
+ public void error(Object message)
+ {
+ loggerDelegate.error (message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of ERROR.
+ * Invokes log.log(Level.ERROR, message, t);
+ */
+ public void error(Object message, Throwable t)
+ {
+ loggerDelegate.error (message, t);
+ }
+
+ /**
+ * Issue a log msg with a level of FATAL.
+ * Invokes log.log(Level.FATAL, message);
+ */
+ public void fatal(Object message)
+ {
+ loggerDelegate.fatal (message);
+ }
+
+ /**
+ * Issue a log msg and throwable with a level of FATAL.
+ * Invokes log.log(Level.FATAL, message, t);
+ */
+ public void fatal(Object message, Throwable t)
+ {
+ loggerDelegate.fatal (message, t);
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Custom Serialization //
+ /////////////////////////////////////////////////////////////////////////
+
+ private void readObject(java.io.ObjectInputStream stream)
+ throws java.io.IOException, ClassNotFoundException
+ {
+ // restore non-transient fields (aka name)
+ stream.defaultReadObject();
+
+ // Restore logging
+ if (pluginClass == null) {
+ init();
+ }
+ this.loggerDelegate = getDelegatePlugin(name);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Factory Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Create a Logger instance given the logger name.
+ *
+ * @param name the logger name
+ */
+ public static Logger getLogger(String name)
+ {
+ return new Logger(name);
+ }
+
+ /**
+ * Create a Logger instance given the logger name with the given suffix.
+ *
+ * <p>This will include a logger seperator between classname and suffix
+ *
+ * @param name The logger name
+ * @param suffix A suffix to append to the classname.
+ */
+ public static Logger getLogger(String name, String suffix)
+ {
+ return new Logger(name + "." + suffix);
+ }
+
+ /**
+ * Create a Logger instance given the logger class. This simply
+ * calls create(clazz.getName()).
+ *
+ * @param clazz the Class whose name will be used as the logger name
+ */
+ public static Logger getLogger(Class clazz)
+ {
+ return new Logger(clazz.getName());
+ }
+
+ /**
+ * Create a Logger instance given the logger class with the given suffix.
+ *
+ * <p>This will include a logger seperator between classname and suffix
+ *
+ * @param clazz The Class whose name will be used as the logger name.
+ * @param suffix A suffix to append to the classname.
+ */
+ public static Logger getLogger(Class clazz, String suffix)
+ {
+ return new Logger(clazz.getName() + "." + suffix);
+ }
+
+ protected static LoggerPlugin getDelegatePlugin (String name)
+ {
+ LoggerPlugin plugin = null;
+ try
+ {
+ plugin = (LoggerPlugin)pluginClass.newInstance ();
+ }
+ catch (Exception ie)
+ {
+ ie.printStackTrace ();
+ plugin = new NullLoggerPlugin ();
+ }
+ plugin.init (name);
+
+ return plugin;
+ }
+
+ protected static void init ()
+ {
+ pluginClass = org.jboss.logging.NullLoggerPlugin.class;
+ try
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+ // try to load the class...
+ //
+ cl.loadClass(LOG4J_DETECTOR_CLASS_NAME);
+
+ // if we arrive here, it means that we can use log4j in this VM (or CL scope)
+ //
+ pluginClass = cl.loadClass(LOG4J_PLUGIN_CLASS_NAME);
+ }
+ catch (ClassNotFoundException cnfe) { /* log4j not present*/ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/Logger.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/LoggerPlugin.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/LoggerPlugin.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/LoggerPlugin.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.logging;
+
+/**
+ * Defines a "pluggable" login module. In fact, this is only used to split between
+ * log4j and /dev/null. Choice is made in org.jboss.logging.Logger
+ *
+ * @see org.jboss.logging.Logger
+ * @see org.jboss.logging.Log4jLoggerPlugin
+ * @see org.jboss.logging.NullLoggerPlugin
+ *
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @version $Revision$
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>30 mai 2002 Sacha Labourey:</b>
+ * <ul>
+ * <li> First implementation </li>
+ * </ul>
+ */
+
+public interface LoggerPlugin
+{
+ // must be called first
+ //
+ public void init (String name);
+
+ public boolean isTraceEnabled();
+ public void trace(Object message);
+ public void trace(Object message, Throwable t);
+
+ public boolean isDebugEnabled();
+ public void debug(Object message);
+ public void debug(Object message, Throwable t);
+
+ public boolean isInfoEnabled();
+ public void info(Object message);
+ public void info(Object message, Throwable t);
+
+ public void warn(Object message);
+ public void warn(Object message, Throwable t);
+
+ public void error(Object message);
+ public void error(Object message, Throwable t);
+
+ public void fatal(Object message);
+ public void fatal(Object message, Throwable t);
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/LoggerPlugin.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/NullLoggerPlugin.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/NullLoggerPlugin.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/NullLoggerPlugin.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.logging;
+
+/**
+ * LoggerPlugin implementation producing no output at all. Used for client
+ * side logging when no log4j.jar is available on the classpath.
+ *
+ * @see org.jboss.logging.Logger
+ * @see org.jboss.logging.LoggerPlugin
+ *
+ * @author <a href="mailto:sacha.labourey at cogito-info.ch">Sacha Labourey</a>.
+ * @version $Revision$
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>30 mai 2002 Sacha Labourey:</b>
+ * <ul>
+ * <li> First implementation </li>
+ * </ul>
+ */
+
+public class NullLoggerPlugin implements LoggerPlugin
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public NullLoggerPlugin () { }
+
+ public void init (String name)
+ { /* don't care */ }
+
+ // Public --------------------------------------------------------
+
+ public boolean isTraceEnabled () { return false; }
+ public void trace (Object message) { }
+ public void trace (Object message, Throwable t) { }
+
+ public boolean isDebugEnabled () { return false; }
+ public void debug (Object message) { }
+ public void debug (Object message, Throwable t) { }
+
+ public boolean isInfoEnabled () { return false; }
+ public void info (Object message) { }
+ public void info (Object message, Throwable t) { }
+
+ public void error (Object message) { }
+ public void error (Object message, Throwable t) { }
+
+ public void fatal (Object message) { }
+ public void fatal (Object message, Throwable t) { }
+
+ public void warn (Object message) { }
+ public void warn (Object message, Throwable t) { }
+
+ // Z implementation ----------------------------------------------
+
+ // Y overrides ---------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/NullLoggerPlugin.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/XLevel.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/XLevel.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/XLevel.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,99 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.logging;
+
+import org.apache.log4j.Level;
+
+/**
+ * Provides custom extention levels for use with the Log4j logging framework.
+ *
+ * <p>
+ * Adds a trace level that is below the standard Log4j <tt>DEBUG</tt> level.
+ *
+ * <p>
+ * This is a custom level that is 100 below the {@link Level#DEBUG_INT}
+ * and represents a lower level useful for logging events that should only
+ * be displayed when deep debugging is required.
+ *
+ * @see org.apache.log4j.Level
+ *
+ * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>
+ * @version $Revision$
+ */
+public class XLevel
+ extends Level
+{
+ /** The integer representation of the level, ({@link Level#DEBUG_INT} - 100) */
+ public static final int TRACE_INT = Level.DEBUG_INT - 100;
+
+ /** The string name of the trace level. */
+ public static final String TRACE_STR = "TRACE";
+
+ /** The TRACE level object singleton */
+ public static final XLevel TRACE = new XLevel(TRACE_INT, TRACE_STR, 7);
+
+ /**
+ * Construct a <tt>XLevel</tt>.
+ */
+ protected XLevel(final int level, final String strLevel, final int syslogEquiv)
+ {
+ super(level, strLevel, syslogEquiv);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Factory Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Convert an integer passed as argument to a level. If the conversion
+ * fails, then this method returns the specified default.
+ *
+ * @return the Level object for name if one exists, defaultLevel otherwize.
+ */
+ public static Level toLevel(final String name, final Level defaultLevel)
+ {
+ if (name == null)
+ return defaultLevel;
+
+ String upper = name.toUpperCase();
+ if (upper.equals(TRACE_STR)) {
+ return TRACE;
+ }
+
+ return Level.toLevel(name, defaultLevel);
+ }
+
+ /**
+ * Convert an integer passed as argument to a level.
+ *
+ * @return the Level object for name if one exists
+ */
+ public static Level toLevel(final String name)
+ {
+ return toLevel(name, TRACE);
+ }
+
+ /**
+ * Convert an integer passed as argument to a level. If the conversion
+ * fails, then this method returns the specified default.
+ *
+ * @return the Level object for i if one exists, defaultLevel otherwize.
+ */
+ public static Level toLevel(final int i, final Level defaultLevel)
+ {
+ Level p;
+ if (i == TRACE_INT)
+ p = TRACE;
+ else
+ p = Level.toLevel(i);
+ return p;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/XLevel.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/XPriority.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/XPriority.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/XPriority.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,98 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.logging;
+
+import org.apache.log4j.Priority;
+
+/**
+ * Provides custom extention priorites for use with the
+ * Log4j logging framework.
+ *
+ * Adds a trace priority that is below the standard log4j DEBUG priority.
+ * This is a custom priority that is 100 below the Priority.DEBUG_INT and
+ * represents a lower priority useful for logging events that should only
+ * be displayed when deep debugging is required.
+ *
+ * @deprecated Use {@link XLevel} instead.
+ *
+ * @see org.apache.log4j.Category
+ * @see org.apache.log4j.Priority
+ *
+ * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>
+ * @version $Revision$
+ */
+public class XPriority
+ extends Priority
+{
+ /** The integer representation of the priority, (Priority.DEBUG_INT - 100) */
+ public static final int TRACE_INT = Priority.DEBUG_INT - 100;
+
+ /** The string name of the trace priority. */
+ public static String TRACE_STR = "TRACE";
+
+ /** The TRACE priority object singleton */
+ public static final XPriority TRACE = new XPriority(TRACE_INT, TRACE_STR, 7);
+
+ /**
+ * Construct a <tt>XPriority</tt>.
+ */
+ protected XPriority(int level, String strLevel, int syslogEquiv)
+ {
+ super(level, strLevel, syslogEquiv);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Factory Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Convert an integer passed as argument to a priority. If the conversion
+ * fails, then this method returns the specified default.
+ * @return the Priority object for name if one exists, defaultPriority otherwize.
+ */
+ public static Priority toPriority(String name, Priority defaultPriority)
+ {
+ if (name == null)
+ return defaultPriority;
+
+ String upper = name.toUpperCase();
+ if (upper.equals(TRACE_STR)) {
+ return TRACE;
+ }
+
+ return Priority.toPriority(name, defaultPriority);
+ }
+
+ /**
+ * Convert an integer passed as argument to a priority.
+ *
+ * @return the Priority object for name if one exists
+ */
+ public static Priority toPriority(String name)
+ {
+ return toPriority(name, TRACE);
+ }
+
+ /**
+ * Convert an integer passed as argument to a priority. If the conversion
+ * fails, then this method returns the specified default.
+ * @return the Priority object for i if one exists, defaultPriority otherwize.
+ */
+ public static Priority toPriority(int i, Priority defaultPriority)
+ {
+ Priority p;
+ if (i == TRACE_INT)
+ p = TRACE;
+ else
+ p = Priority.toPriority(i);
+ return p;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/XPriority.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/DailyRollingFileAppender.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/DailyRollingFileAppender.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/DailyRollingFileAppender.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,27 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.logging.appender;
+
+/**
+ * An extention of the default Log4j DailyRollingFileAppender
+ * which will make the directory structure for the set log file.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class DailyRollingFileAppender
+ extends org.apache.log4j.DailyRollingFileAppender
+{
+ public void setFile(final String filename)
+ {
+ FileAppender.Helper.makePath(filename);
+ super.setFile(filename);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/DailyRollingFileAppender.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/FileAppender.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/FileAppender.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/FileAppender.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,60 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.logging.appender;
+
+import java.io.File;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import org.apache.log4j.helpers.LogLog;
+
+/**
+ * An extention of the default Log4j FileAppender which
+ * will make the directory structure for the set log file.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FileAppender
+ extends org.apache.log4j.FileAppender
+{
+ public void setFile(final String filename)
+ {
+ FileAppender.Helper.makePath(filename);
+ super.setFile(filename);
+ }
+
+ /**
+ * A helper for FileAppenders.
+ */
+ public static class Helper
+ {
+ public static void makePath(final String filename)
+ {
+ File dir;
+
+ try {
+ URL url = new URL(filename.trim());
+ dir = new File(url.getFile()).getParentFile();
+ }
+ catch (MalformedURLException e) {
+ dir = new File(filename.trim()).getParentFile();
+ }
+
+ if (!dir.exists()) {
+ boolean success = dir.mkdirs();
+ if (!success) {
+ LogLog.error("Failed to create directory structure: " + dir);
+ }
+ }
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/FileAppender.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/RegexEventEvaluator.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/RegexEventEvaluator.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/RegexEventEvaluator.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,60 @@
+package org.jboss.logging.appender;
+
+import java.util.HashMap;
+
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.spi.TriggeringEventEvaluator;
+import gnu.regexp.RE;
+import gnu.regexp.REException;
+
+/** An implementation of the log4j TriggeringEventEvaluator that matches the
+ * LoggingEvent message against the MDB{RegexEventEvaluator} regular
+ * expression.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class RegexEventEvaluator implements TriggeringEventEvaluator
+{
+ /** A cache HashMap<String, RE> of previously compiled REs */
+ private HashMap regexMap = new HashMap();
+
+ /** Lookup the current MDC 'RegexEventEvaluator' to determine the regular
+ * expression context that should be applied to determine if the logging
+ * event should be considered a triggering event. If there is no value
+ * for the 'RegexEventEvaluator' key then no comparision is made.
+ *
+ * @param event the logging event to check
+ * @return true if MDC{RegexEventEvaluator} is a regex expression that
+ * matches the event.getRenderedMessage(), false otherwise.
+ */
+ public boolean isTriggeringEvent(LoggingEvent event)
+ {
+ String regex = (String) event.getMDC("RegexEventEvaluator");
+ boolean isTriggeringEvent = false;
+ if( regex != null )
+ {
+ // Look for a cached regex pattern
+ RE re = (RE) regexMap.get(regex);
+ if( re == null )
+ {
+ try
+ {
+ re = new RE(regex);
+ regexMap.put(regex, re);
+ }
+ catch (REException e)
+ {
+ }
+ }
+
+ if( re != null )
+ {
+ String msg = event.getRenderedMessage();
+ if( msg != null )
+ isTriggeringEvent = re.isMatch(msg);
+ }
+ }
+ return isTriggeringEvent;
+ }
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/RegexEventEvaluator.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/RollingFileAppender.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/RollingFileAppender.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/RollingFileAppender.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,27 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.logging.appender;
+
+/**
+ * An extention of the default Log4j RollingFileAppender which
+ * will make the directory structure for the set log file.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class RollingFileAppender
+ extends org.apache.log4j.RollingFileAppender
+{
+ public void setFile(final String filename)
+ {
+ FileAppender.Helper.makePath(filename);
+ super.setFile(filename);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/RollingFileAppender.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Log4j appenders.
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/appender/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/PatternLayout.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/PatternLayout.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/PatternLayout.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, the OpenSource J2EE WebOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.logging.layout;
+
+import org.apache.log4j.helpers.PatternParser;
+
+/** A subclass of the log4j PatternLayout that add the following conversion
+characters:
+
+ <p>
+ <table border="1" CELLPADDING="8">
+ <th>Conversion Character</th>
+ <th>Effect</th>
+
+ <tr>
+ <td align=center><b>z</b></td>
+ <td>Used to output current thread NDC value. This can be used to obtain
+ an NDC to augment any NDC associated with the LoggingEvent. This might
+ be necessary if the LoggingEvent has been serialized between VMs.
+ </td>
+ </tr>
+ <tr>
+ <td align=center><b>Z</b></td>
+ <td>Used to output current thread MDC value. This can be used to obtain
+ an MDC to augment any MDC associated with the LoggingEvent. This might
+ be necessary if the LoggingEvent has been serialized between VMs.
+ The Z conversion character must be followed by the key for the map placed
+ between braces, as in %Z{theKey} where theKey is the key.
+ The value in the MDC corresponding to the key will be output.
+ </td>
+ </tr>
+
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PatternLayout extends org.apache.log4j.PatternLayout
+{
+
+ protected PatternParser createPatternParser(String pattern)
+ {
+ return new PatternParserEx(pattern);
+ }
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/PatternLayout.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/PatternParserEx.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/PatternParserEx.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/PatternParserEx.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, the OpenSource J2EE WebOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.logging.layout;
+
+import org.apache.log4j.helpers.PatternConverter;
+import org.apache.log4j.helpers.PatternParser;
+
+/** A subclass of the log4j PatternParser that add the following conversion
+characters:
+
+ <p>
+ <table border="1" CELLPADDING="8">
+ <th>Conversion Character</th>
+ <th>Effect</th>
+
+ <tr>
+ <td align=center><b>z</b></td>
+ <td>Used to output current thread NDC value. This can be used to obtain
+ an NDC to augment any NDC associated with the LoggingEvent. This might
+ be necessary if the LoggingEvent has been serialized between VMs.
+ </td>
+ </tr>
+ <tr>
+ <td align=center><b>Z</b></td>
+ <td>Used to output current thread MDC value. This can be used to obtain
+ an MDC to augment any MDC associated with the LoggingEvent. This might
+ be necessary if the LoggingEvent has been serialized between VMs.
+ The Z conversion character must be followed by the key for the map placed
+ between braces, as in %Z{theKey} where theKey is the key.
+ The value in the MDC corresponding to the key will be output.
+ </td>
+ </tr>
+
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class PatternParserEx extends PatternParser
+{
+ /** Creates a new instance of PatternParser */
+ public PatternParserEx(String pattern)
+ {
+ super(pattern);
+ }
+
+ protected void finalizeConverter(char c)
+ {
+ PatternConverter pc = null;
+ switch(c)
+ {
+ case 'z':
+ pc = new ThreadNDCConverter(formattingInfo);
+ currentLiteral.setLength(0);
+ break;
+ case 'Z':
+ String key = extractOption();
+ pc = new ThreadMDCConverter(formattingInfo, key);
+ currentLiteral.setLength(0);
+ break;
+ default:
+ super.finalizeConverter(c);
+ return;
+ }
+ addConverter(pc);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/PatternParserEx.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/ThreadMDCConverter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/ThreadMDCConverter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/ThreadMDCConverter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, the OpenSource J2EE WebOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.logging.layout;
+
+import org.apache.log4j.MDC;
+import org.apache.log4j.helpers.FormattingInfo;
+import org.apache.log4j.helpers.PatternConverter;
+import org.apache.log4j.spi.LoggingEvent;
+
+/** A PatternConverter that uses the current thread MDC rather than the
+ * LoggingEvent MDC value.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ThreadMDCConverter extends PatternConverter
+{
+ private String key;
+ /** Creates a new instance of ThreadMDCPatternConverter */
+ public ThreadMDCConverter(FormattingInfo formattingInfo, String key)
+ {
+ super(formattingInfo);
+ this.key = key;
+ }
+
+ protected String convert(LoggingEvent loggingEvent)
+ {
+ Object val = MDC.get(key);
+ String strVal = null;
+ if( val != null )
+ strVal = val.toString();
+ return strVal;
+ }
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/ThreadMDCConverter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/ThreadNDCConverter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/ThreadNDCConverter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/ThreadNDCConverter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, the OpenSource J2EE WebOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.logging.layout;
+
+import org.apache.log4j.NDC;
+import org.apache.log4j.helpers.FormattingInfo;
+import org.apache.log4j.helpers.PatternConverter;
+import org.apache.log4j.spi.LoggingEvent;
+
+/** A PatternConverter that uses the current thread NDC rather than the
+ * LoggingEvent NDC value.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ThreadNDCConverter extends PatternConverter
+{
+ /** Creates a new instance of ThreadMDCPatternConverter */
+ public ThreadNDCConverter(FormattingInfo formattingInfo)
+ {
+ super(formattingInfo);
+ }
+
+ protected String convert(LoggingEvent loggingEvent)
+ {
+ Object val = NDC.get();
+ String strVal = null;
+ if( val != null )
+ strVal = val.toString();
+ return strVal;
+ }
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/layout/ThreadNDCConverter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Common logging infrastructure.
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/CategoryStream.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/CategoryStream.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/CategoryStream.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,145 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.logging.util;
+
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.apache.log4j.Category;
+import org.apache.log4j.Priority;
+
+
+/**
+ * A subclass of PrintStream that redirects its output to a log4j Category.
+ *
+ * <p>This class is used to map PrintStream/PrintWriter oriented logging onto
+ * the log4j Categories. Examples include capturing System.out/System.err
+ *
+ * @deprecated Use {@link LoggerStream} instead.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>.
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class CategoryStream
+ extends PrintStream
+{
+ /**
+ * Default flag to enable/disable tracing println calls.
+ * from the system property <tt>org.jboss.logging.util.CategoryStream.trace</tt>
+ * or if not set defaults to <tt>false</tt>.
+ */
+ public static final boolean TRACE =
+ getBoolean(CategoryStream.class.getName() + ".trace", false);
+
+ /** Helper to get boolean value from system property or use default if not set. */
+ private static boolean getBoolean(String name, boolean defaultValue)
+ {
+ String value = System.getProperty(name, null);
+ if (value == null)
+ return defaultValue;
+ return new Boolean(value).booleanValue();
+ }
+
+ private Category category;
+ private Priority priority;
+ private boolean issuedWarning;
+
+ /**
+ * Redirect logging to the indicated category using Priority.INFO
+ */
+ public CategoryStream(final Category category)
+ {
+ this(category, Priority.INFO, System.out);
+ }
+
+ /**
+ * Redirect logging to the indicated category using the given
+ * priority. The ps is simply passed to super but is not used.
+ */
+ public CategoryStream(final Category category,
+ final Priority priority,
+ final PrintStream ps)
+ {
+ super(ps);
+ this.category = category;
+ this.priority = priority;
+ }
+
+ public void println(String msg)
+ {
+ if( msg == null )
+ msg = "null";
+ byte[] bytes = msg.getBytes();
+ write(bytes, 0, bytes.length);
+ }
+
+ public void println(Object msg)
+ {
+ if( msg == null )
+ msg = "null";
+ byte[] bytes = msg.toString().getBytes();
+ write(bytes, 0, bytes.length);
+ }
+
+ public void write(byte b)
+ {
+ byte[] bytes = {b};
+ write(bytes, 0, 1);
+ }
+
+ private ThreadLocal recursiveCheck = new ThreadLocal();
+ public void write(byte[] b, int off, int len)
+ {
+ Boolean recursed = (Boolean)recursiveCheck.get();
+ if (recursed != null && recursed.equals(Boolean.TRUE))
+ {
+ /* There is a configuration error that is causing looping. Most
+ likely there are two console appenders so just return to prevent
+ spinning.
+ */
+ if( issuedWarning == false )
+ {
+ String msg = "ERROR: invalid console appender config detected, console stream is looping";
+ try
+ {
+ out.write(msg.getBytes());
+ }
+ catch(IOException ignore)
+ {
+ }
+ issuedWarning = true;
+ }
+ return;
+ }
+
+ // Remove the end of line chars
+ while( len > 0 && (b[len-1] == '\n' || b[len-1] == '\r') && len > off )
+ len --;
+
+ // HACK, something is logging exceptions line by line (including
+ // blanks), but I can't seem to find it, so for now just ignore
+ // empty lines... they aren't very useful.
+ if (len != 0)
+ {
+ String msg = new String(b, off, len);
+ recursiveCheck.set(Boolean.TRUE);
+ if (TRACE)
+ {
+ category.log(priority, msg, new Throwable());
+ }
+ else
+ {
+ category.log(priority, msg);
+ }
+ recursiveCheck.set(Boolean.FALSE);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/CategoryStream.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/CategoryWriter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/CategoryWriter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/CategoryWriter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,103 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.logging.util;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Writer;
+
+import org.apache.log4j.Category;
+import org.apache.log4j.Priority;
+
+/**
+ * A subclass of PrintWriter that redirects its output to a log4j Category. <p>
+ *
+ * This class is used to have something to give api methods that require a
+ * PrintWriter for logging. JBoss-owned classes of this nature generally ignore
+ * the PrintWriter and do their own log4j logging.
+ *
+ * @deprecated Use {@link LoggerWriter} instead.
+ *
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * .
+ * @created August 19, 2001
+ * @version $$
+ */
+public class CategoryWriter
+ extends PrintWriter {
+ private Category category;
+ private Priority priority;
+ private boolean inWrite;
+ private boolean issuedWarning;
+
+ /**
+ * Redirect logging to the indicated category using Priority.INFO
+ *
+ * @param category Description of Parameter
+ */
+ public CategoryWriter( final Category category ) {
+ this( category, Priority.INFO );
+ }
+
+ /**
+ * Redirect logging to the indicated category using the given priority. The
+ * ps is simply passed to super but is not used.
+ *
+ * @param category Description of Parameter
+ * @param priority Description of Parameter
+ */
+ public CategoryWriter( final Category category,
+ final Priority priority ) {
+ super( new InternalCategoryWriter( category, priority ), true );
+ }
+
+ /**
+ * @created August 19, 2001
+ */
+ static class InternalCategoryWriter extends Writer {
+ private Category category;
+ private Priority priority;
+ private boolean closed;
+
+ public InternalCategoryWriter( final Category category, final Priority priority ) {
+ lock = category;
+ //synchronize on this category
+ this.category = category;
+ this.priority = priority;
+ }
+
+ public void write( char[] cbuf, int off, int len )
+ throws IOException {
+ if ( closed ) {
+ throw new IOException( "Called write on closed Writer" );
+ }
+ // Remove the end of line chars
+ while ( len > 0 && ( cbuf[len - 1] == '\n' || cbuf[len - 1] == '\r' ) ) {
+ len--;
+ }
+ if ( len > 0 ) {
+ category.log( priority, String.copyValueOf( cbuf, off, len ) );
+ }
+ }
+
+
+ public void flush()
+ throws IOException {
+ if ( closed ) {
+ throw new IOException( "Called flush on closed Writer" );
+ }
+ }
+
+ public void close() {
+ closed = true;
+ }
+ }
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/CategoryWriter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/LoggerStream.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/LoggerStream.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/LoggerStream.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,143 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.logging.util;
+
+import java.io.IOException;
+import java.io.PrintStream;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+
+/**
+ * A subclass of PrintStream that redirects its output to a log4j Logger.
+ *
+ * <p>This class is used to map PrintStream/PrintWriter oriented logging onto
+ * the log4j Categories. Examples include capturing System.out/System.err
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>.
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class LoggerStream
+ extends PrintStream
+{
+ /**
+ * Default flag to enable/disable tracing println calls.
+ * from the system property <tt>org.jboss.logging.util.LoggerStream.trace</tt>
+ * or if not set defaults to <tt>false</tt>.
+ */
+ public static final boolean TRACE =
+ getBoolean(LoggerStream.class.getName() + ".trace", false);
+
+ /** Helper to get boolean value from system property or use default if not set. */
+ private static boolean getBoolean(String name, boolean defaultValue)
+ {
+ String value = System.getProperty(name, null);
+ if (value == null)
+ return defaultValue;
+ return new Boolean(value).booleanValue();
+ }
+
+ private Logger logger;
+ private Level level;
+ private boolean inWrite;
+ private boolean issuedWarning;
+
+ /**
+ * Redirect logging to the indicated logger using Level.INFO
+ */
+ public LoggerStream(final Logger logger)
+ {
+ this(logger, Level.INFO, System.out);
+ }
+
+ /**
+ * Redirect logging to the indicated logger using the given
+ * level. The ps is simply passed to super but is not used.
+ */
+ public LoggerStream(final Logger logger,
+ final Level level,
+ final PrintStream ps)
+ {
+ super(ps);
+ this.logger = logger;
+ this.level = level;
+ }
+
+ public void println(String msg)
+ {
+ if( msg == null )
+ msg = "null";
+ byte[] bytes = msg.getBytes();
+ write(bytes, 0, bytes.length);
+ }
+
+ public void println(Object msg)
+ {
+ if( msg == null )
+ msg = "null";
+ byte[] bytes = msg.toString().getBytes();
+ write(bytes, 0, bytes.length);
+ }
+
+ public void write(byte b)
+ {
+ byte[] bytes = {b};
+ write(bytes, 0, 1);
+ }
+
+ private ThreadLocal recursiveCheck = new ThreadLocal();
+ public void write(byte[] b, int off, int len)
+ {
+ Boolean recursed = (Boolean)recursiveCheck.get();
+ if (recursed != null && recursed.equals(Boolean.TRUE))
+ {
+ /* There is a configuration error that is causing looping. Most
+ likely there are two console appenders so just return to prevent
+ spinning.
+ */
+ if( issuedWarning == false )
+ {
+ String msg = "ERROR: invalid console appender config detected, console stream is looping";
+ try
+ {
+ out.write(msg.getBytes());
+ }
+ catch(IOException ignore)
+ {
+ }
+ issuedWarning = true;
+ }
+ return;
+ }
+
+ // Remove the end of line chars
+ while( len > 0 && (b[len-1] == '\n' || b[len-1] == '\r') && len > off )
+ len --;
+
+ // HACK, something is logging exceptions line by line (including
+ // blanks), but I can't seem to find it, so for now just ignore
+ // empty lines... they aren't very useful.
+ if (len != 0)
+ {
+ String msg = new String(b, off, len);
+ recursiveCheck.set(Boolean.TRUE);
+ if (TRACE)
+ {
+ logger.log(level, msg, new Throwable());
+ }
+ else
+ {
+ logger.log(level, msg);
+ }
+ recursiveCheck.set(Boolean.FALSE);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/LoggerStream.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/LoggerWriter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/LoggerWriter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/LoggerWriter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,102 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.logging.util;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Writer;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+
+/**
+ * A subclass of PrintWriter that redirects its output to a log4j Logger. <p>
+ *
+ * This class is used to have something to give api methods that require a
+ * PrintWriter for logging. JBoss-owned classes of this nature generally ignore
+ * the PrintWriter and do their own log4j logging.
+ *
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * .
+ * @created August 19, 2001
+ * @version $$
+ */
+public class LoggerWriter
+ extends PrintWriter
+{
+ private Logger logger;
+ private Level level;
+ private boolean inWrite;
+ private boolean issuedWarning;
+
+ /**
+ * Redirect logging to the indicated logger using Level.INFO
+ *
+ * @param logger Description of Parameter
+ */
+ public LoggerWriter( final Logger logger ) {
+ this( logger, Level.INFO );
+ }
+
+ /**
+ * Redirect logging to the indicated logger using the given level. The
+ * ps is simply passed to super but is not used.
+ *
+ * @param logger Description of Parameter
+ * @param level Description of Parameter
+ */
+ public LoggerWriter( final Logger logger,
+ final Level level ) {
+ super( new InternalLoggerWriter( logger, level ), true );
+ }
+
+ /**
+ * @created August 19, 2001
+ */
+ static class InternalLoggerWriter extends Writer {
+ private Logger logger;
+ private Level level;
+ private boolean closed;
+
+ public InternalLoggerWriter( final Logger logger, final Level level ) {
+ lock = logger;
+ //synchronize on this logger
+ this.logger = logger;
+ this.level = level;
+ }
+
+ public void write( char[] cbuf, int off, int len )
+ throws IOException {
+ if ( closed ) {
+ throw new IOException( "Called write on closed Writer" );
+ }
+ // Remove the end of line chars
+ while ( len > 0 && ( cbuf[len - 1] == '\n' || cbuf[len - 1] == '\r' ) ) {
+ len--;
+ }
+ if ( len > 0 ) {
+ logger.log( level, String.copyValueOf( cbuf, off, len ) );
+ }
+ }
+
+
+ public void flush()
+ throws IOException {
+ if ( closed ) {
+ throw new IOException( "Called flush on closed Writer" );
+ }
+ }
+
+ public void close() {
+ closed = true;
+ }
+ }
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/LoggerWriter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Logging utilties and helpers.
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/logging/util/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/DelegatingURLConnection.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/DelegatingURLConnection.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/DelegatingURLConnection.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,209 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.net.protocol;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import java.net.URLConnection;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import java.util.Map;
+
+import java.security.Permission;
+
+/**
+ * An delegating URLConnection support class.
+ *
+ * @todo resolve 1.4 specific issues.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class DelegatingURLConnection
+ extends URLConnection
+{
+ protected URL delegateUrl;
+ protected URLConnection delegateConnection;
+
+ public DelegatingURLConnection(final URL url)
+ throws MalformedURLException, IOException
+ {
+ super(url);
+
+ delegateUrl = makeDelegateUrl(url);
+ delegateConnection = makeDelegateUrlConnection(delegateUrl);
+ }
+
+ protected URL makeDelegateUrl(final URL url)
+ throws MalformedURLException, IOException
+ {
+ return url;
+ }
+
+ protected URLConnection makeDelegateUrlConnection(final URL url)
+ throws IOException
+ {
+ return url.openConnection();
+ }
+
+ public void connect() throws IOException
+ {
+ delegateConnection.connect();
+ }
+
+ public URL getURL() {
+ return delegateConnection.getURL();
+ }
+
+ public int getContentLength() {
+ return delegateConnection.getContentLength();
+ }
+
+ public String getContentType() {
+ return delegateConnection.getContentType();
+ }
+
+ public String getContentEncoding() {
+ return delegateConnection.getContentEncoding();
+ }
+
+ public long getExpiration() {
+ return delegateConnection.getExpiration();
+ }
+
+ public long getDate() {
+ return delegateConnection.getDate();
+ }
+
+ public long getLastModified() {
+ return delegateConnection.getLastModified();
+ }
+
+ public String getHeaderField(String name) {
+ return delegateConnection.getHeaderField(name);
+ }
+
+ /* This is specific to 1.4
+ public Map getHeaderFields() {
+ return delegateConnection.getHeaderFields();
+ }
+ */
+
+ public int getHeaderFieldInt(String name, int _default) {
+ return delegateConnection.getHeaderFieldInt(name, _default);
+ }
+
+ public long getHeaderFieldDate(String name, long _default) {
+ return delegateConnection.getHeaderFieldDate(name, _default);
+ }
+
+ public String getHeaderFieldKey(int n) {
+ return delegateConnection.getHeaderFieldKey(n);
+ }
+
+ public String getHeaderField(int n) {
+ return delegateConnection.getHeaderField(n);
+ }
+
+ public Object getContent() throws IOException {
+ return delegateConnection.getContent();
+ }
+
+ public Object getContent(Class[] classes) throws IOException {
+ return delegateConnection.getContent(classes);
+ }
+
+ public Permission getPermission() throws IOException {
+ return delegateConnection.getPermission();
+ }
+
+ public InputStream getInputStream() throws IOException {
+ return delegateConnection.getInputStream();
+ }
+
+ public OutputStream getOutputStream() throws IOException {
+ return delegateConnection.getOutputStream();
+ }
+
+ public String toString() {
+ return super.toString() + "{ " + delegateConnection + " }";
+ }
+
+ public void setDoInput(boolean doinput) {
+ delegateConnection.setDoInput(doinput);
+ }
+
+ public boolean getDoInput() {
+ return delegateConnection.getDoInput();
+ }
+
+ public void setDoOutput(boolean dooutput) {
+ delegateConnection.setDoOutput(dooutput);
+ }
+
+ public boolean getDoOutput() {
+ return delegateConnection.getDoOutput();
+ }
+
+ public void setAllowUserInteraction(boolean allowuserinteraction) {
+ delegateConnection.setAllowUserInteraction(allowuserinteraction);
+ }
+
+ public boolean getAllowUserInteraction() {
+ return delegateConnection.getAllowUserInteraction();
+ }
+
+ public void setUseCaches(boolean usecaches) {
+ delegateConnection.setUseCaches(usecaches);
+ }
+
+ public boolean getUseCaches() {
+ return delegateConnection.getUseCaches();
+ }
+
+ public void setIfModifiedSince(long ifmodifiedsince) {
+ delegateConnection.setIfModifiedSince(ifmodifiedsince);
+ }
+
+ public long getIfModifiedSince() {
+ return delegateConnection.getIfModifiedSince();
+ }
+
+ public boolean getDefaultUseCaches() {
+ return delegateConnection.getDefaultUseCaches();
+ }
+
+ public void setDefaultUseCaches(boolean defaultusecaches) {
+ delegateConnection.setDefaultUseCaches(defaultusecaches);
+ }
+
+ public void setRequestProperty(String key, String value) {
+ delegateConnection.setRequestProperty(key, value);
+ }
+
+ /* This is specific to 1.4
+ public void addRequestProperty(String key, String value) {
+ delegateConnection.addRequestProperty(key, value);
+ }
+ */
+
+ public String getRequestProperty(String key) {
+ return delegateConnection.getRequestProperty(key);
+ }
+
+ /* This is specific to 1.4
+ public Map getRequestProperties() {
+ return delegateConnection.getRequestProperties();
+ }
+ */
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/DelegatingURLConnection.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLLister.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLLister.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLLister.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,53 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.net.protocol;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collection;
+
+/**
+ * Interface defining methods that can be used to list the contents of a URL
+ * collection irrespective of the protocol.
+ */
+public interface URLLister {
+ /**
+ * List the members of the given collection URL that match the patterns
+ * supplied.
+ * @param baseUrl the URL to list; must end in "/"
+ * @param patterns the patterns to match (separated by ',')
+ * @return a Collection of URLs that match
+ * @throws IOException if there was a problem getting the list
+ */
+ Collection listMembers(URL baseUrl, String patterns) throws IOException;
+
+ /**
+ * List the members of the given collection that are accepted by the filter
+ * @param baseUrl the URL to list; must end in "/"
+ * @param filter a filter that is called to determine if a member should
+ * be returned
+ * @return a Collection of URLs that match
+ * @throws IOException if there was a problem getting the list
+ */
+ Collection listMembers(URL baseUrl, URLFilter filter) throws IOException;
+
+ /**
+ * Interface defining a filter for listed members.
+ */
+ public interface URLFilter {
+ /**
+ * Determine whether the supplied memberName should be accepted
+ * @param baseURL the URL of the collection
+ * @param memberName the member of the collection
+ * @return
+ */
+ boolean accept(URL baseURL, String memberName);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLLister.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLListerBase.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLListerBase.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLListerBase.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,63 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+
+package org.jboss.net.protocol;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Collection;
+import java.util.StringTokenizer;
+import java.net.URL;
+import java.io.IOException;
+
+/**
+ * Support class for URLLister's providing protocol independent functionality.
+ */
+public abstract class URLListerBase implements URLLister {
+ public Collection listMembers(URL baseUrl, String patterns) throws IOException {
+ StringTokenizer tokens = new StringTokenizer(patterns, ",");
+ String[] members = new String[tokens.countTokens()];
+ for (int i=0; tokens.hasMoreTokens(); i++) {
+ members[i] = tokens.nextToken();
+ }
+ URLFilter filter = new URLFilterImpl(members);
+ return listMembers(baseUrl, filter);
+ }
+
+ /**
+ * Inner class representing Filter criteria to be applied to the members
+ * of the returned Collection
+ */
+ public static class URLFilterImpl implements URLFilter {
+ protected boolean allowAll;
+ protected HashSet constants;
+
+ public URLFilterImpl(String[] patterns) {
+ constants = new HashSet(Arrays.asList(patterns));
+ allowAll = constants.contains("*");
+ }
+
+ public boolean accept(URL baseUrl, String name) {
+ if (allowAll) {
+ return true;
+ }
+ if (constants.contains(name)) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ protected static final URLFilter acceptAllFilter = new URLFilter() {
+ public boolean accept(URL baseURL, String memberName) {
+ return true;
+ }
+ };
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLListerBase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLListerFactory.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLListerFactory.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLListerFactory.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,76 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.net.protocol;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+
+public class URLListerFactory {
+ private static HashMap defaultClasses = new HashMap();
+ static {
+ defaultClasses.put("file", "org.jboss.net.protocol.file.FileURLLister");
+ defaultClasses.put("http", "org.jboss.net.protocol.http.DavURLLister");
+ defaultClasses.put("https", "org.jboss.net.protocol.http.DavURLLister");
+ }
+
+ private HashMap classes;
+
+ /**
+ * Create a URLLister with default listers defined for file and http
+ * protocols.
+ */
+ public URLListerFactory() {
+ classes = (HashMap) defaultClasses.clone();
+ }
+
+ /**
+ * Create a URL lister using the protocol from the URL
+ * @param url the url defining the protocol
+ * @return a URLLister capable of listing URLs of that protocol
+ * @throws MalformedURLException if no lister could be found for the protocol
+ */
+ public URLLister createURLLister(URL url) throws MalformedURLException {
+ return createURLLister(url.getProtocol());
+ }
+
+ /**
+ * Create a URL lister for the supplied protocol
+ * @param protocol the protocol
+ * @return a URLLister capable of listing URLs of that protocol
+ * @throws MalformedURLException if no lister could be found for the protocol
+ */
+ public URLLister createURLLister(String protocol) throws MalformedURLException {
+ try {
+ String className = (String) classes.get(protocol);
+ if (className == null) {
+ throw new MalformedURLException("No lister class defined for protocol "+protocol);
+ }
+
+ Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+ return (URLLister) clazz.newInstance();
+ } catch (ClassNotFoundException e) {
+ throw new MalformedURLException(e.getMessage());
+ } catch (InstantiationException e) {
+ throw new MalformedURLException(e.getMessage());
+ } catch (IllegalAccessException e) {
+ throw new MalformedURLException(e.getMessage());
+ }
+ }
+
+ /**
+ * Register a URLLister class for a given protocol
+ * @param protocol the protocol this class will handle
+ * @param className the URLLister implementation to instanciate
+ */
+ public void registerListener(String protocol, String className) {
+ classes.put(protocol, className);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLListerFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLStreamHandlerFactory.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLStreamHandlerFactory.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLStreamHandlerFactory.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,200 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.net.protocol;
+
+import java.net.URL;
+import java.net.URLStreamHandler;
+import java.util.Collections;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A factory for loading URL protocol handlers. This is based
+ * on Sun's URL mechanism, in that <tt>Handler</tt> classes will be
+ * searched for in the packages specified by the java.protocol.handler.pkgs
+ * property are searched for classes matching the protocol + ".Handler"
+ * classname. The default JBoss package "org.jboss.net.protocol" is searched
+ * even if not specified in the java.protocol.handler.pkgs property.
+ *
+ * <p>This factory is installed by the default server implementaion
+ * to ensure that protocol handlers not in the system classpath are
+ * located. The thread context class is used first followed by the
+ * Class.forName method.
+ * </p>
+ *
+ * <p>Use {@link preload} to force the URL handler map to load the
+ * handlers for each protocol listed in {@link #PROTOCOLS}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author Scott.Stark at jboss.org
+ */
+public class URLStreamHandlerFactory
+ implements java.net.URLStreamHandlerFactory
+{
+ /** Class logger. */
+ private static final Logger log = Logger.getLogger(URLStreamHandlerFactory.class);
+
+ /** The package prefix where JBoss protocol handlers live. */
+ public static final String PACKAGE_PREFIX = "org.jboss.net.protocol";
+ /** A map of protocol names to handlers. Since there can only be one
+ URLStreamHandlerFactory installed, this is a static map that may be
+ cleared.
+ */
+ private static Map handlerMap = Collections.synchronizedMap(new HashMap());
+ /** The current packages prefixes determined from the java.protocol.handler.pkgs
+ property + the org.jboss.net.protocol default package.
+ */
+ private String[] handlerPkgs = {PACKAGE_PREFIX};
+ /** The last java.protocol.handler.pkgs value. Used to determine if the
+ java.protocol.handler.pkgs property has changed since handlerPkgs was
+ last built.
+ */
+ private String lastHandlerPkgs = PACKAGE_PREFIX;
+
+ /** A list of JBoss specific protocols for preloading. */
+ public static final String PROTOCOLS[] = {
+ "resource",
+ "file"
+ };
+
+ /**
+ * Preload the JBoss specific protocol handlers, so that URL knows about
+ * them even if the handler factory is changed.
+ */
+ public static void preload()
+ {
+ for (int i = 0; i < PROTOCOLS.length; i ++)
+ {
+ try
+ {
+ URL url = new URL(PROTOCOLS[i], "", -1, "");
+ log.trace("Loaded protocol: " + PROTOCOLS[i]);
+ }
+ catch (Exception e)
+ {
+ log.warn("Failed to load protocol: " + PROTOCOLS[i], e);
+ }
+ }
+ }
+
+ /** Clear the current protocol to handler map. The map will be rebuilt
+ as protocol handlers are requested.
+ */
+ public static void clear()
+ {
+ handlerMap.clear();
+ }
+
+ /** Search the handlerPkgs for URLStreamHandler classes matching the
+ * pkg + protocol + ".Handler" naming convention.
+ *
+ * @see #checkHandlerPkgs()
+ * @param protocol The protocol to create a stream handler for
+ * @return The protocol handler or null if not found
+ */
+ public URLStreamHandler createURLStreamHandler(final String protocol)
+ {
+ // Check the
+ URLStreamHandler handler = (URLStreamHandler) handlerMap.get(protocol);
+ if( handler != null )
+ return handler;
+
+ // See if the handler pkgs definition has changed
+ checkHandlerPkgs();
+
+ // Search the handlerPkgs for a matching protocol handler
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ for(int p = 0; p < handlerPkgs.length; p ++)
+ {
+ try
+ {
+ // Form the standard protocol handler class name
+ String classname = handlerPkgs[p] + "." + protocol + ".Handler";
+ Class type = null;
+
+ try
+ {
+ /* Aparently a security mgr causes the getResource call to loop
+ back into this method. Why this occurs still needs to be
+ investigated but this check means that we do not load
+ protocol handlers from the TCL if there is a security mgr.
+ See bug #696633.
+ */
+ if( System.getSecurityManager() != null )
+ {
+ // Trigger the Class.forName call below
+ throw new ClassNotFoundException("SecurityManager bypass");
+ }
+
+ /* First see if the class exists as a resource. This is to work
+ around a bad interaction between the IBM VMs and custom
+ URLStreamHandlerFactory that use the TCL. See bug#669043
+ */
+ String resname = classname.replace('.', '/') + ".class";
+ URL typeURL = ctxLoader.getResource(resname);
+ if( typeURL != null )
+ type = ctxLoader.loadClass(classname);
+ }
+ catch(ClassNotFoundException e)
+ {
+ // Try our class loader
+ type = Class.forName(classname);
+ }
+
+ if( type != null )
+ {
+ handler = (URLStreamHandler) type.newInstance();
+ handlerMap.put(protocol, handler);
+ if( log.isTraceEnabled() )
+ log.trace("Found protocol:"+protocol+" handler:"+handler);
+ }
+ }
+ catch (Exception ignore)
+ {
+ if( log.isTraceEnabled() )
+ log.trace("Failed to find protocol handler:"+protocol, ignore);
+ }
+ }
+
+ return handler;
+ }
+
+ /** See if the java.protocol.handler.pkgs system property has changed
+ and if it has, parse it to update the handlerPkgs array.
+ */
+ private synchronized void checkHandlerPkgs()
+ {
+ String handlerPkgsProp = System.getProperty("java.protocol.handler.pkgs");
+ if( handlerPkgsProp != null && handlerPkgsProp.equals(lastHandlerPkgs) == false )
+ {
+ // Update the handlerPkgs[] from the handlerPkgsProp
+ StringTokenizer tokeninzer = new StringTokenizer(handlerPkgsProp, "|");
+ ArrayList tmp = new ArrayList();
+ while( tokeninzer.hasMoreTokens() )
+ {
+ String pkg = tokeninzer.nextToken().intern();
+ if( tmp.contains(pkg) == false )
+ tmp.add(pkg);
+ }
+ // Include the JBoss default protocol handler pkg
+ if( tmp.contains(PACKAGE_PREFIX) == false )
+ tmp.add(PACKAGE_PREFIX);
+ handlerPkgs = new String[tmp.size()];
+ tmp.toArray(handlerPkgs);
+ lastHandlerPkgs = handlerPkgsProp;
+ }
+ }
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/URLStreamHandlerFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/FileURLConnection.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/FileURLConnection.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/FileURLConnection.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,131 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.net.protocol.file;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+import java.net.URLConnection;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import java.security.Permission;
+import java.io.FilePermission;
+
+/**
+ * Provides local file access via URL semantics, correctly returning
+ * the last modified time of the underlying file.
+ *
+ * @version $Revision$
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author Scott.Stark at jboss.org
+ */
+public class FileURLConnection
+ extends URLConnection
+{
+ protected File file;
+
+ public FileURLConnection(final URL url)
+ throws MalformedURLException, IOException
+ {
+ super(url);
+
+ file = new File(url.getPath().replace('/', File.separatorChar).replace('|', ':'));
+
+ doOutput = false;
+ }
+
+ /**
+ * Returns the underlying file for this connection.
+ */
+ public File getFile()
+ {
+ return file;
+ }
+
+ /**
+ * Checks if the underlying file for this connection exists.
+ *
+ * @throws FileNotFoundException
+ */
+ public void connect() throws IOException
+ {
+ if (connected)
+ return;
+
+ if (!file.exists())
+ {
+ throw new FileNotFoundException(file.getPath());
+ }
+
+ connected = true;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ if (!connected)
+ connect();
+
+ return new FileInputStream(file);
+ }
+
+ public OutputStream getOutputStream() throws IOException
+ {
+ if (!connected)
+ connect();
+
+ return new FileOutputStream(file);
+ }
+
+ /**
+ * Provides support for returning the value for the
+ * <tt>last-modified</tt> header.
+ */
+ public String getHeaderField(final String name)
+ {
+ String headerField = null;
+ if (name.equalsIgnoreCase("last-modified"))
+ headerField = String.valueOf(getLastModified());
+ else if (name.equalsIgnoreCase("content-length"))
+ headerField = String.valueOf(file.length());
+ else if (name.equalsIgnoreCase("content-type"))
+ headerField = getFileNameMap().getContentTypeFor(file.getName());
+ else if (name.equalsIgnoreCase("date"))
+ headerField = String.valueOf(file.lastModified());
+ else
+ {
+ // This always returns null currently
+ headerField = super.getHeaderField(name);
+ }
+ return headerField;
+ }
+
+ /**
+ * Return a permission for both read & write since both
+ * input and output streams are supported.
+ */
+ public Permission getPermission() throws IOException
+ {
+ return new FilePermission(file.getPath(), "read,write");
+ }
+
+ /**
+ * Returns the last modified time of the underlying file.
+ */
+ public long getLastModified()
+ {
+ return file.lastModified();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/FileURLConnection.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/FileURLLister.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/FileURLLister.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/FileURLLister.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,53 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+
+package org.jboss.net.protocol.file;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.jboss.net.protocol.URLListerBase;
+
+public class FileURLLister extends URLListerBase {
+ public Collection listMembers(final URL baseUrl, final URLFilter filter) throws IOException {
+ File directory = new File(baseUrl.getPath());
+ if (directory.exists() == false) {
+ throw new FileNotFoundException(directory.toString());
+ }
+ File[] files = directory.listFiles(new FileFilter() {
+ public boolean accept(File file) {
+ return filter.accept(baseUrl, file.getName());
+ }
+ });
+ return filesToURLs(baseUrl, files);
+ }
+
+ private Collection filesToURLs(URL baseUrl, File[] files) {
+ URL[] urls = new URL[files.length];
+ for (int i = 0; i < files.length; i++) {
+ File file = files[i];
+ try {
+ String name = file.getName();
+ URL url = new URL(baseUrl, file.isDirectory() ? name+"/" : name);
+ urls[i] = url;
+ } catch (MalformedURLException e) {
+ // shouldn't happen
+ throw new IllegalStateException();
+ }
+ }
+ return Arrays.asList(urls);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/FileURLLister.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/Handler.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/Handler.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/Handler.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,37 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.net.protocol.file;
+
+import java.io.IOException;
+
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * A protocol handler for the 'file' protocol.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class Handler
+ extends URLStreamHandler
+{
+ public URLConnection openConnection(final URL url)
+ throws IOException
+ {
+ return new FileURLConnection(url);
+ }
+
+ protected void parseURL(final URL url, final String s, final int i, final int j)
+ {
+ super.parseURL(url, s.replace(java.io.File.separatorChar, '/'), i, j);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/Handler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>A better implementation of the 'file' protocol.
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/file/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/http
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/http/DavURLLister.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/http/DavURLLister.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/http/DavURLLister.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,55 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+
+package org.jboss.net.protocol.http;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.commons.httpclient.HttpException;
+import org.apache.util.HttpURL;
+import org.apache.webdav.lib.WebdavResource;
+import org.jboss.net.protocol.URLListerBase;
+
+public class DavURLLister extends URLListerBase {
+ public Collection listMembers(URL baseUrl, URLFilter filter) throws IOException {
+ WebdavResource resource = null;
+ try {
+ resource = new WebdavResource(baseUrl.toString());
+ WebdavResource[] resources = resource.listWebdavResources();
+ List urls = new ArrayList(resources.length);
+ for (int i = 0; i < resources.length; i++) {
+ WebdavResource member = resources[i];
+ HttpURL httpURL = member.getHttpURL();
+ if (filter.accept(baseUrl, httpURL.getName())) {
+ String url = httpURL.getUnescapedHttpURL();
+ if (member.isCollection() && url.endsWith("/") == false) {
+ url += "/";
+ }
+ urls.add(new URL(url));
+ }
+ }
+ return urls;
+ } catch (HttpException e) {
+ throw new IOException(e.getMessage());
+ } catch (MalformedURLException e) {
+ // should not happen
+ throw new IllegalStateException(e.getMessage());
+ } finally {
+ if (resource != null) {
+ resource.close();
+ }
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/http/DavURLLister.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar/Handler.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar/Handler.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar/Handler.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,164 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.net.protocol.njar;
+
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+
+import org.jboss.util.stream.Streams;
+import org.jboss.util.ThrowableHandler;
+
+/**
+ * A protocol handler for the n(ested)jar protocol.
+ *
+ * <p>
+ * This is class allows you to use the njar: URL protocol. It is very
+ * similar to it's jar: cusin. The difference being that jars can be
+ * nested.
+ *
+ * <p>
+ * An example of how to use this class is:
+ * <pre>
+ *
+ * URL url = new URL("njar:njar:file:c:/test1.zip^/test2.zip^/hello.txt");
+ * url.openStream();
+ *
+ * </pre>
+ *
+ * <p>
+ * Please be aware that the njar protocol caches it's jar in temporary
+ * storage when connections are opened into them. So for the above
+ * example, 2 files would cached a temp files names similar to nested-xxxx.jar
+ *
+ * @todo Add accessors so that the cache can be flushed.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:cojonudo14 at hotmail.com">Hiram Chirino</a>
+ */
+public class Handler
+ extends URLStreamHandler
+{
+ // URL protocol designations
+ public static final String PROTOCOL = "njar";
+ public static final String NJAR_SEPARATOR = "^/";
+ public static final String JAR_SEPARATOR = "!/";
+
+ private static final Logger log = Logger.getLogger(Handler.class);
+
+ protected Map savedJars = new HashMap();
+
+ public URLConnection openConnection(final URL url)
+ throws IOException
+ {
+ String file = url.getFile();
+ String embeddedURL = file;
+ String jarPath = "";
+
+ boolean trace = log.isTraceEnabled();
+
+ int pos = file.lastIndexOf(NJAR_SEPARATOR);
+ if (pos >= 0)
+ {
+ embeddedURL = file.substring(0, pos);
+ if (file.length() > pos + NJAR_SEPARATOR.length())
+ jarPath = file.substring(pos + NJAR_SEPARATOR.length());
+ }
+
+ if (embeddedURL.startsWith(PROTOCOL))
+ {
+ if (trace) log.trace("Opening next nested jar: " + embeddedURL);
+ File tempJar = (File) savedJars.get(embeddedURL);
+ if (tempJar == null)
+ {
+ URLConnection embededDataConnection = new URL(embeddedURL).openConnection();
+ if (trace) log.trace("Content length: " + embededDataConnection.getContentLength());
+
+ InputStream embededData = embededDataConnection.getInputStream();
+ tempJar = File.createTempFile("nested-", ".jar");
+ tempJar.deleteOnExit();
+
+ if (trace) log.trace("temp file location : " + tempJar);
+ OutputStream output = new FileOutputStream(tempJar);
+
+ try {
+ // copyb will buffer the streams for us
+ long bytes = Streams.copyb(embededData, output);
+ if (trace) log.trace("copied " + bytes + " bytes");
+ }
+ finally {
+ Streams.flush(output);
+
+ // close an pass errors to throwable handler (we don't care about them)
+ Streams.close(embededData);
+ Streams.close(output);
+ }
+
+ savedJars.put(embeddedURL, tempJar);
+ }
+
+ String t = tempJar.getCanonicalFile().toURL().toExternalForm();
+ if (trace) log.trace("file URL : " + t);
+
+ t = "njar:" + t + NJAR_SEPARATOR + jarPath;
+ if (trace) log.trace("Opening saved jar: " + t);
+
+ URL u = new URL(t);
+ if (trace) log.trace("Using URL: " + u);
+
+ return u.openConnection();
+ }
+ else
+ {
+ if (trace) log.trace("Opening final nested jar: " + embeddedURL);
+
+ URL u = new URL("jar:" + embeddedURL + JAR_SEPARATOR + jarPath);
+ if (trace) log.trace("Using URL: " + u);
+
+ return u.openConnection();
+ }
+ }
+
+ public static URL njarToFile(URL url)
+ {
+ if (url.getProtocol().equals(PROTOCOL))
+ {
+ try
+ {
+ // force the resource we are after to be unpacked - thanks
+ // Jan & David...!
+ URL dummy=new URL(PROTOCOL+":"+url.toString()+NJAR_SEPARATOR+"dummy.jar");
+ String tmp=dummy.openConnection().getURL().toString();
+ tmp=tmp.substring("jar:".length());
+ tmp=tmp.substring(0, tmp.length()-(JAR_SEPARATOR+"dummy.jar").length());
+ return new URL(tmp);
+ }
+ catch (Exception ignore)
+ {
+ ThrowableHandler.addWarning(ignore);
+ }
+ }
+
+ return url;
+ }
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar/Handler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Provides a nested jar ('njar') protocol handler.
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/njar/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>URL protocol stream helpers.
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/Handler.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/Handler.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/Handler.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,33 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.net.protocol.resource;
+
+import java.io.IOException;
+
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * A protocol handler for the 'resource' protocol. Provides
+ * access to system resources.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class Handler
+ extends URLStreamHandler
+{
+ public URLConnection openConnection(final URL url)
+ throws IOException
+ {
+ return new ResourceURLConnection(url);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/Handler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/ResourceURLConnection.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/ResourceURLConnection.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/ResourceURLConnection.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,71 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.net.protocol.resource;
+
+import java.io.IOException;
+import java.io.FileNotFoundException;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import org.jboss.net.protocol.DelegatingURLConnection;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Provides access to system resources as a URLConnection.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ResourceURLConnection
+ extends DelegatingURLConnection
+{
+ private static final Logger log = Logger.getLogger(ResourceURLConnection.class);
+
+ public ResourceURLConnection(final URL url)
+ throws MalformedURLException, IOException
+ {
+ super(url);
+ }
+
+ protected URL makeDelegateUrl(final URL url)
+ throws MalformedURLException, IOException
+ {
+ String name = url.getHost();
+ String file = url.getFile();
+ if (file != null && !file.equals("")) {
+ name += file;
+ }
+
+ // first try TCL and then SCL
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL target = cl.getResource(name);
+
+ if (target == null) {
+ cl = ClassLoader.getSystemClassLoader();
+ target = cl.getResource(name);
+ }
+
+ if (target == null)
+ throw new FileNotFoundException("Could not locate resource: " + name);
+
+ if (log.isTraceEnabled()) {
+ log.trace("Target resource URL: " + target);
+ try {
+ log.trace("Target resource URL connection: " + target.openConnection());
+ }
+ catch (Exception ignore) {}
+ }
+
+ return target;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/ResourceURLConnection.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Provides a system 'resource' access protocol handler.
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/net/protocol/resource/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/AbstractNestedThrowable.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/AbstractNestedThrowable.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/AbstractNestedThrowable.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,133 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.PrintWriter;
+import java.io.PrintStream;
+
+/**
+ * A common superclass for <tt>Throwable</tt> classes that can contain
+ * a nested <tt>Throwable</tt> detail object.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class AbstractNestedThrowable
+ extends Throwable
+ implements NestedThrowable
+{
+ /** The nested throwable */
+ protected final Throwable nested;
+
+ /**
+ * Construct a <tt>AbstractNestedThrowable</tt> with the specified
+ * detail message.
+ *
+ * @param msg Detail message.
+ */
+ public AbstractNestedThrowable(final String msg) {
+ super(msg);
+ this.nested = null;
+ }
+
+ /**
+ * Construct a <tt>AbstractNestedThrowable</tt> with the specified detail
+ * message and nested <tt>Throwable</tt>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public AbstractNestedThrowable(final String msg, final Throwable nested) {
+ super(msg);
+ this.nested = nested;
+ NestedThrowable.Util.checkNested(this, nested);
+ }
+
+ /**
+ * Construct a <tt>AbstractNestedThrowable</tt> with the specified
+ * nested <tt>Throwable</tt>.
+ *
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public AbstractNestedThrowable(final Throwable nested) {
+ this(nested.getMessage(), nested);
+ }
+
+ /**
+ * Construct a <tt>AbstractNestedThrowable</tt> with no detail.
+ */
+ public AbstractNestedThrowable() {
+ super();
+ this.nested = null;
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ public Throwable getNested() {
+ return nested;
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * <p>For JDK 1.4 compatibility.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ public Throwable getCause() {
+ return nested;
+ }
+
+ /**
+ * Returns the composite throwable message.
+ *
+ * @return The composite throwable message.
+ */
+ public String getMessage() {
+ return NestedThrowable.Util.getMessage(super.getMessage(), nested);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print stream.
+ *
+ * @param stream Stream to print to.
+ */
+ public void printStackTrace(final PrintStream stream) {
+ if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
+ super.printStackTrace(stream);
+ }
+ NestedThrowable.Util.print(nested, stream);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print writer.
+ *
+ * @param writer Writer to print to.
+ */
+ public void printStackTrace(final PrintWriter writer) {
+ if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
+ super.printStackTrace(writer);
+ }
+ NestedThrowable.Util.print(nested, writer);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to
+ * <tt>System.err</tt>.
+ */
+ public void printStackTrace() {
+ printStackTrace(System.err);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/AbstractNestedThrowable.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/BenignError.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/BenignError.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/BenignError.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,59 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * Thrown to indicate to an encapsulated try/catch block that something has
+ * happened and it was not harmfull.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class BenignError
+ extends NestedError
+{
+ /**
+ * Construct a <tt>BenignError</tt> with the specified
+ * detail message.
+ *
+ * @param msg Detail message.
+ */
+ public BenignError(final String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>BenignError</tt> with the specified
+ * detail message and nested <tt>Throwable</tt>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public BenignError(final String msg, final Throwable nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Construct a <tt>BenignError</tt> with the specified
+ * nested <tt>Throwable</tt>.
+ *
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public BenignError(final Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Construct a <tt>BenignError</tt> with no detail.
+ */
+ public BenignError() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/BenignError.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CachePolicy.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CachePolicy.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CachePolicy.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util;
+
+/**
+ * Interface that specifies a policy for caches. <p>
+ * Implementation classes can implement a LRU policy, a random one,
+ * a MRU one, or any other suitable policy.
+ *
+ * @author <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
+ * @version $Revision$
+ */
+public interface CachePolicy
+{
+ /**
+ * Returns the object paired with the specified key if it's
+ * present in the cache, otherwise must return null. <br>
+ * Implementations of this method must have complexity of order O(1).
+ * Differently from {@link #peek} this method not only return whether
+ * the object is present in the cache or not, but also
+ * applies the implemented policy that will "refresh" the cached
+ * object in the cache, because this cached object
+ * was really requested.
+ *
+ * @param key the key paired with the object
+ * @see #peek
+ */
+ Object get(Object key);
+
+ /**
+ * Returns the object paired with the specified key if it's
+ * present in the cache, otherwise must return null. <br>
+ * Implementations of this method must have complexity of order O(1).
+ * This method should not apply the implemented caching policy to the
+ * object paired with the given key, so that a client can
+ * query if an object is cached without "refresh" its cache status. Real
+ * requests for the object must be done using {@link #get}.
+ *
+ * @param key the key paired with the object
+ * @see #get
+ */
+ Object peek(Object key);
+
+ /**
+ * Inserts the specified object into the cache following the
+ * implemented policy. <br>
+ * Implementations of this method must have complexity of order O(1).
+ *
+ * @param key the key paired with the object
+ * @param object the object to cache
+ * @see #remove
+ */
+ void insert(Object key, Object object);
+
+ /**
+ * Remove the cached object paired with the specified key. <br>
+ * Implementations of this method must have complexity of order O(1).
+ *
+ * @param key the key paired with the object
+ * @see #insert
+ */
+ void remove(Object key);
+
+ /**
+ * Flushes the cached objects from the cache.
+ */
+ void flush();
+
+ /**
+ * Get the size of the cache.
+ */
+ int size();
+
+
+
+ /**
+ * create the service, do expensive operations etc
+ */
+ void create() throws Exception;
+
+ /**
+ * start the service, create is already called
+ */
+ void start() throws Exception;
+
+ /**
+ * stop the service
+ */
+ void stop();
+
+ /**
+ * destroy the service, tear down
+ */
+ void destroy();
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CachePolicy.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Classes.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Classes.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Classes.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,352 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Array;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * A collection of <code>Class</code> utilities.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class Classes
+{
+ /** The string used to separator packages */
+ public static final String PACKAGE_SEPARATOR = ".";
+
+ /** The characther used to separator packages */
+ public static final char PACKAGE_SEPARATOR_CHAR = '.';
+
+ /** The default package name. */
+ public static final String DEFAULT_PACKAGE_NAME = "<default>";
+
+ /**
+ * Get the short name of the specified class by striping off the package
+ * name.
+ *
+ * @param classname Class name.
+ * @return Short class name.
+ */
+ public static String stripPackageName(final String classname) {
+ int idx = classname.lastIndexOf(PACKAGE_SEPARATOR);
+
+ if (idx != -1)
+ return classname.substring(idx + 1, classname.length());
+ return classname;
+ }
+
+ /**
+ * Get the short name of the specified class by striping off the package
+ * name.
+ *
+ * @param type Class name.
+ * @return Short class name.
+ */
+ public static String stripPackageName(final Class type) {
+ return stripPackageName(type.getName());
+ }
+
+ /**
+ * Get the package name of the specified class.
+ *
+ * @param classname Class name.
+ * @return Package name or "" if the classname is in the
+ * <i>default</i> package.
+ *
+ * @throws EmptyStringException Classname is an empty string.
+ */
+ public static String getPackageName(final String classname) {
+ if (classname.length() == 0)
+ throw new EmptyStringException();
+
+ int index = classname.lastIndexOf(PACKAGE_SEPARATOR);
+ if (index != -1)
+ return classname.substring(0, index);
+ return "";
+ }
+
+ /**
+ * Get the package name of the specified class.
+ *
+ * @param type Class.
+ * @return Package name.
+ */
+ public static String getPackageName(final Class type) {
+ return getPackageName(type.getName());
+ }
+
+ /**
+ * Force the given class to be loaded fully.
+ *
+ * <p>This method attempts to locate a static method on the given class
+ * the attempts to invoke it with dummy arguments in the hope that
+ * the virtual machine will prepare the class for the method call and
+ * call all of the static class initializers.
+ *
+ * @param type Class to force load.
+ *
+ * @throws NullArgumentException Type is <i>null</i>.
+ */
+ public static void forceLoad(final Class type) {
+ if (type == null)
+ throw new NullArgumentException("type");
+
+ // don't attempt to force primitives to load
+ if (type.isPrimitive()) return;
+
+ // don't attempt to force java.* classes to load
+ String packageName = Classes.getPackageName(type);
+ // System.out.println("package name: " + packageName);
+
+ if (packageName.startsWith("java.") ||
+ packageName.startsWith("javax.")) {
+ return;
+ }
+
+ // System.out.println("forcing class to load: " + type);
+
+ try {
+ Method methods[] = type.getDeclaredMethods();
+ Method method = null;
+ for (int i=0; i<methods.length; i++) {
+ int modifiers = methods[i].getModifiers();
+ if (Modifier.isStatic(modifiers)) {
+ method = methods[i];
+ break;
+ }
+ }
+
+ if (method != null) {
+ method.invoke(null, null);
+ }
+ else {
+ type.newInstance();
+ }
+ }
+ catch (Exception ignore) {
+ ThrowableHandler.add(ignore);
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Primitives //
+ /////////////////////////////////////////////////////////////////////////
+
+ /** Primitive type name -> class map. */
+ private static final Map PRIMITIVE_NAME_TYPE_MAP = new HashMap();
+
+ /** Setup the primitives map. */
+ static
+ {
+ PRIMITIVE_NAME_TYPE_MAP.put("boolean", Boolean.TYPE);
+ PRIMITIVE_NAME_TYPE_MAP.put("byte", Byte.TYPE);
+ PRIMITIVE_NAME_TYPE_MAP.put("char", Character.TYPE);
+ PRIMITIVE_NAME_TYPE_MAP.put("short", Short.TYPE);
+ PRIMITIVE_NAME_TYPE_MAP.put("int", Integer.TYPE);
+ PRIMITIVE_NAME_TYPE_MAP.put("long", Long.TYPE);
+ PRIMITIVE_NAME_TYPE_MAP.put("float", Float.TYPE);
+ PRIMITIVE_NAME_TYPE_MAP.put("double", Double.TYPE);
+ }
+
+ /**
+ * Get the primitive type for the given primitive name.
+ *
+ * <p>
+ * For example, "boolean" returns Boolean.TYPE and so on...
+ *
+ * @param name Primitive type name (boolean, int, byte, ...)
+ * @return Primitive type or null.
+ *
+ * @exception IllegalArgumentException Type is not a primitive class
+ */
+ public static Class getPrimitiveTypeForName(final String name) {
+ return (Class)PRIMITIVE_NAME_TYPE_MAP.get(name);
+ }
+
+ /** Map of primitive types to their wrapper classes */
+ private static final Class[] PRIMITIVE_WRAPPER_MAP = {
+ Boolean.TYPE, Boolean.class,
+ Byte.TYPE, Byte.class,
+ Character.TYPE, Character.class,
+ Double.TYPE, Double.class,
+ Float.TYPE, Float.class,
+ Integer.TYPE, Integer.class,
+ Long.TYPE, Long.class,
+ Short.TYPE, Short.class,
+ };
+
+ /**
+ * Get the wrapper class for the given primitive type.
+ *
+ * @param type Primitive class.
+ * @return Wrapper class for primitive.
+ *
+ * @exception IllegalArgumentException Type is not a primitive class
+ */
+ public static Class getPrimitiveWrapper(final Class type) {
+ if (! type.isPrimitive()) {
+ throw new IllegalArgumentException("type is not a primitive class");
+ }
+
+ for (int i=0; i < PRIMITIVE_WRAPPER_MAP.length; i += 2) {
+ if (type.equals(PRIMITIVE_WRAPPER_MAP[i]))
+ return PRIMITIVE_WRAPPER_MAP[i + 1];
+ }
+
+ // should never get here, if we do then PRIMITIVE_WRAPPER_MAP
+ // needs to be updated to include the missing mapping
+ throw new UnreachableStatementException();
+ }
+
+ /**
+ * Check if the given class is a primitive wrapper class.
+ *
+ * @param type Class to check.
+ * @return True if the class is a primitive wrapper.
+ */
+ public static boolean isPrimitiveWrapper(final Class type) {
+ for (int i=0; i < PRIMITIVE_WRAPPER_MAP.length; i += 2) {
+ if (type.equals(PRIMITIVE_WRAPPER_MAP[i + 1])) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Check if the given class is a primitive class or a primitive
+ * wrapper class.
+ *
+ * @param type Class to check.
+ * @return True if the class is a primitive or primitive wrapper.
+ */
+ public static boolean isPrimitive(final Class type) {
+ if (type.isPrimitive() || isPrimitiveWrapper(type)) {
+ return true;
+ }
+
+ return false;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Class Loading //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * This method acts equivalently to invoking
+ * <code>Thread.currentThread().getContextClassLoader().loadClass(className);</code> but it also
+ * supports primitive types and array classes of object types or primitive types.
+ *
+ * @param className the qualified name of the class or the name of primitive type or
+ * array in the same format as returned by the
+ * <code>java.lang.Class.getName()</code> method.
+ * @return the Class object for the requested className
+ *
+ * @throws ClassNotFoundException when the <code>classLoader</code> can not find the requested class
+ */
+ public static Class loadClass(String className) throws ClassNotFoundException {
+ return loadClass( className, Thread.currentThread().getContextClassLoader() );
+ }
+
+ /**
+ * This method acts equivalently to invoking Thread.currentThread().getContextClassLoader()
+ * @return the ClassLoader
+ */
+ public static ClassLoader getContextClassLoader() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ /**
+ * This method acts equivalently to invoking <code>classLoader.loadClass(className);</code>
+ * but it also supports primitive types and array classes of object types or primitive types.
+ *
+ * @param className the qualified name of the class or the name of primitive type or array
+ * in the same format as returned by the <code>java.lang.Class.getName()</code>
+ * method.
+ * @param classLoader the ClassLoader used to load classes
+ * @return the Class object for the requested className
+ *
+ * @throws ClassNotFoundException when the <code>classLoader</code> can not find the requested class
+ */
+ public static Class loadClass(String className, ClassLoader classLoader)
+ throws ClassNotFoundException
+ {
+ // ClassLoader.loadClass() does not handle primitive types:
+ //
+ // B byte
+ // C char
+ // D double
+ // F float
+ // I int
+ // J long
+ // S short
+ // Z boolean
+ // V void
+ //
+ if (className.length() == 1)
+ {
+ char type = className.charAt(0);
+ if (type == 'B') return Byte.TYPE;
+ if (type == 'C') return Character.TYPE;
+ if (type == 'D') return Double.TYPE;
+ if (type == 'F') return Float.TYPE;
+ if (type == 'I') return Integer.TYPE;
+ if (type == 'J') return Long.TYPE;
+ if (type == 'S') return Short.TYPE;
+ if (type == 'Z') return Boolean.TYPE;
+ if (type == 'V') return Void.TYPE;
+ // else throw...
+ throw new ClassNotFoundException(className);
+ }
+
+ // ...nore does this special notation:
+ //
+ // Lclassname; class or interface
+ //
+ if (className.charAt(0) == 'L' && className.charAt(className.length() - 1) == ';')
+ return classLoader.loadClass(className.substring(1, className.length() - 1));
+
+ // first try - be optimistic
+ // this will succeed for all non-array classes and array classes that have already been resolved
+ //
+ try
+ {
+ return classLoader.loadClass(className);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // if it was non-array class then throw it
+ if (className.charAt(0) != '[')
+ throw e;
+ }
+
+ // we are now resolving array class for the first time
+
+ // count opening braces
+ int arrayDimension = 0;
+ while (className.charAt(arrayDimension) == '[')
+ arrayDimension++;
+
+ // resolve component type - use recursion so that we can resolve primitive types also
+ Class componentType = loadClass(className.substring(arrayDimension), classLoader);
+
+ // construct array class
+ return Array.newInstance(componentType, new int[arrayDimension]).getClass();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Classes.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CloneableObject.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CloneableObject.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CloneableObject.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,46 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * A simple base-class for classes which need to be cloneable.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class CloneableObject
+ implements java.lang.Cloneable
+{
+ /**
+ * Clone the object via {@link Object#clone}. This will return
+ * and object of the correct type, with all fields shallowly
+ * cloned.
+ */
+ public Object clone()
+ {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+ /**
+ * An interface which exposes a <em>public</em> clone method,
+ * unlike {@link Object#clone} which is protected and throws
+ * exceptions... how useless is that?
+ */
+ public static interface Cloneable
+ extends java.lang.Cloneable
+ {
+ Object clone();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CloneableObject.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Coercible.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Coercible.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Coercible.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,30 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * An iterface which an object implements to indicate that it will handle
+ * coercion by itself.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface Coercible
+{
+ /**
+ * Coerce this object into a specified type
+ *
+ * @param type Type to coerce to
+ * @return Coereced object
+ *
+ * @exception CoercionException Failed to coerce
+ */
+ Object coerce(Class type) throws CoercionException;
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Coercible.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CoercionException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CoercionException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CoercionException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,59 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * This exception is thrown to indicate that a problem has occured while
+ * trying to coerce an object.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class CoercionException
+ extends NestedRuntimeException
+{
+ /**
+ * Construct a <tt>CoercionException</tt> with the specified detail
+ * message.
+ *
+ * @param msg Detail message.
+ */
+ public CoercionException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>CoercionException</tt> with the specified detail
+ * message and nested <tt>Throwable</tt>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public CoercionException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Construct a <tt>CoercionException</tt> with the specified
+ * nested <tt>Throwable</tt>.
+ *
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public CoercionException(Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Construct a <tt>CoercionException</tt> with no detail.
+ */
+ public CoercionException() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/CoercionException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Counter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Counter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Counter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,235 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.Serializable;
+
+/**
+ * An integer counter class.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class Counter
+ implements Serializable, Cloneable
+{
+ /** The current count */
+ private int count;
+
+ /**
+ * Construct a Counter with a starting value.
+ *
+ * @param count Starting value for counter.
+ */
+ public Counter(final int count) {
+ this.count = count;
+ }
+
+ /**
+ * Construct a Counter.
+ */
+ public Counter() {}
+
+ /**
+ * Increment the counter. (Optional operation)
+ *
+ * @return The incremented value of the counter.
+ */
+ public int increment() {
+ return ++count;
+ }
+
+ /**
+ * Decrement the counter. (Optional operation)
+ *
+ * @return The decremented value of the counter.
+ */
+ public int decrement() {
+ return --count;
+ }
+
+ /**
+ * Return the current value of the counter.
+ *
+ * @return The current value of the counter.
+ */
+ public int getCount() {
+ return count;
+ }
+
+ /**
+ * Reset the counter to zero. (Optional operation)
+ */
+ public void reset() {
+ this.count = 0;
+ }
+
+ /**
+ * Check if the given object is equal to this.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal to this.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ return ((Counter)obj).count == count;
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a string representation of this.
+ *
+ * @return A string representation of this.
+ */
+ public String toString() {
+ return String.valueOf(count);
+ }
+
+ /**
+ * Return a cloned copy of this object.
+ *
+ * @return A cloned copy of this object.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Wrappers //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Base wrapper class for other wrappers.
+ */
+ private static class Wrapper
+ extends Counter
+ {
+ /** The wrapped counter */
+ protected final Counter counter;
+
+ public Wrapper(final Counter counter) {
+ this.counter = counter;
+ }
+
+ public int increment() {
+ return counter.increment();
+ }
+
+ public int decrement() {
+ return counter.decrement();
+ }
+
+ public int getCount() {
+ return counter.getCount();
+ }
+
+ public void reset() {
+ counter.reset();
+ }
+
+ public boolean equals(final Object obj) {
+ return counter.equals(obj);
+ }
+
+ public String toString() {
+ return counter.toString();
+ }
+
+ public Object clone() {
+ return counter.clone();
+ }
+ }
+
+ /**
+ * Return a synchronized counter.
+ *
+ * @param counter Counter to synchronize.
+ * @return Synchronized counter.
+ */
+ public static Counter makeSynchronized(final Counter counter) {
+ return new Wrapper(counter) {
+ public synchronized int increment() {
+ return this.counter.increment();
+ }
+
+ public synchronized int decrement() {
+ return this.counter.decrement();
+ }
+
+ public synchronized int getCount() {
+ return this.counter.getCount();
+ }
+
+ public synchronized void reset() {
+ this.counter.reset();
+ }
+
+ public synchronized int hashCode() {
+ return this.counter.hashCode();
+ }
+
+ public synchronized boolean equals(final Object obj) {
+ return this.counter.equals(obj);
+ }
+
+ public synchronized String toString() {
+ return this.counter.toString();
+ }
+
+ public synchronized Object clone() {
+ return this.counter.clone();
+ }
+ };
+ }
+
+ /**
+ * Returns a directional counter.
+ *
+ * @param counter Counter to make directional.
+ * @param increasing True to create an increasing only
+ * or false to create a decreasing only.
+ * @return A directional counter.
+ */
+ public static Counter makeDirectional(final Counter counter,
+ final boolean increasing)
+ {
+ Counter temp;
+ if (increasing) {
+ temp = new Wrapper(counter) {
+ public int decrement() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void reset() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ else {
+ temp = new Wrapper(counter) {
+ public int increment() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ return temp;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Counter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/DataConversionException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/DataConversionException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/DataConversionException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,56 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * An exception throw to indicate a problem with some type of data conversion.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class DataConversionException
+ extends NestedRuntimeException
+{
+ /**
+ * Construct a <tt>DataConversionException</tt> with a specified detail message.
+ *
+ * @param msg Detail message
+ */
+ public DataConversionException(final String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>DataConversionException</tt> with a specified detail Throwable
+ * and message.
+ *
+ * @param msg Detail message
+ * @param detail Detail Throwable
+ */
+ public DataConversionException(final String msg, final Throwable detail) {
+ super(msg, detail);
+ }
+
+ /**
+ * Construct a <tt>DataConversionException</tt> with a specified detail Throwable.
+ *
+ * @param detail Detail Throwable
+ */
+ public DataConversionException(final Throwable detail) {
+ super(detail);
+ }
+
+ /**
+ * Construct a <tt>DataConversionException</tt> with no specified detail message.
+ */
+ public DataConversionException() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/DataConversionException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/DirectoryBuilder.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/DirectoryBuilder.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/DirectoryBuilder.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util;
+
+import java.io.File;
+
+/**
+ * A simple utility to make it easier to build File objects for nested
+ * directories based on the command line 'cd' pattern.
+ *
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @version $Revision$
+ */
+public class DirectoryBuilder
+{
+ protected File root;
+
+ public DirectoryBuilder() {
+ // empty
+ }
+
+ public DirectoryBuilder(final File root) {
+ this.root = root;
+ }
+
+ public DirectoryBuilder(final File root, final File child) {
+ this(root);
+ cd(child);
+ }
+
+ public DirectoryBuilder(final String rootname) {
+ this(new File(rootname));
+ }
+
+ public DirectoryBuilder(final String rootname, final String childname) {
+ this(new File(rootname), new File(childname));
+ }
+
+ public DirectoryBuilder cd(final File child) {
+ if (child.isAbsolute()) {
+ root = child;
+ }
+ else {
+ root = new File(root, child.getPath());
+ }
+ return this;
+ }
+
+ public DirectoryBuilder cd(final String childname) {
+ return cd(new File(childname));
+ }
+
+ public File get() {
+ return root;
+ }
+
+ public String toString() {
+ return root.toString();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/DirectoryBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Duration.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Duration.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Duration.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,169 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * An abstraction of the time during which something exists or lasts.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class Duration
+ extends MuLong
+{
+ /**
+ * Default constructor.
+ */
+ public Duration()
+ {
+ super(0);
+ }
+
+ /**
+ * Construct a duration.
+ *
+ * @param time The time value for the duration.
+ */
+ public Duration(final long time)
+ {
+ super(time);
+ }
+
+ /**
+ * Construct a duration.
+ *
+ * @param time The time value for the duration.
+ */
+ public Duration(final Number time)
+ {
+ super(time.longValue());
+ }
+
+ /** jason: eventually fix these
+
+ public long getYears()
+ {
+ return 0;
+ }
+
+ public long getMonths()
+ {
+ return 0;
+ }
+
+ public long getWeeks()
+ {
+ return 0;
+ }
+
+ public long getDays()
+ {
+ return 0;
+ }
+
+ public long getHours()
+ {
+ return 0;
+ }
+
+ public long getMinutes()
+ {
+ return 0;
+ }
+
+ public long getSeconds()
+ {
+ return 0;
+ }
+
+ public long getMilliSeconds()
+ {
+ return 0;
+ }
+ */
+
+ public static final long ONE_YEAR = 2903040000L;
+ public static final long ONE_MONTH = 241920000;
+ public static final long ONE_WEEK = 60480000;
+ public static final long ONE_DAY = 8640000;
+ public static final long ONE_HOUR = 3600000;
+ public static final long ONE_MINUTE = 600000;
+ public static final long ONE_SECOND = 1000;
+ public static final long ONE_MILLISECOND = 1;
+
+ public String toString()
+ {
+ StringBuffer buff = new StringBuffer();
+
+ //
+ // jason: Bah... must be a better way
+ //
+
+ long y = value / ONE_YEAR;
+ long mo = (value - (y * ONE_YEAR)) / ONE_MONTH;
+ long w = (value - (y * ONE_YEAR) - (mo * ONE_MONTH)) / ONE_WEEK;
+ long d = (value - (y * ONE_YEAR) - (mo * ONE_MONTH) - (w * ONE_WEEK)) / ONE_DAY;
+ long h = (value - (y * ONE_YEAR) - (mo * ONE_MONTH) - (w * ONE_WEEK) - (d * ONE_DAY)) / ONE_HOUR;
+ long m = (value - (y * ONE_YEAR) - (mo * ONE_MONTH) - (w * ONE_WEEK) - (d * ONE_DAY) - (h * ONE_HOUR)) / ONE_MINUTE;
+ long s = (value - (y * ONE_YEAR) - (mo * ONE_MONTH) - (w * ONE_WEEK) - (d * ONE_DAY) - (h * ONE_HOUR) - (m * ONE_MINUTE)) / ONE_SECOND;
+ long ms = (value - (y * ONE_YEAR) - (mo * ONE_MONTH) - (w * ONE_WEEK) - (d * ONE_DAY) - (h * ONE_HOUR) - (m * ONE_MINUTE) - (s * ONE_SECOND));
+
+ char spacer = ':';
+
+ if (y != 0) {
+ buff.append(y).append("y");
+ }
+ if (mo != 0) {
+ if (buff.length() != 0) buff.append(spacer);
+ buff.append(mo).append("mo");
+ }
+ if (w != 0) {
+ if (buff.length() != 0) buff.append(spacer);
+ buff.append(w).append("w");
+ }
+ if (d != 0) {
+ if (buff.length() != 0) buff.append(spacer);
+ buff.append(d).append("d");
+ }
+ if (h != 0) {
+ if (buff.length() != 0) buff.append(spacer);
+ buff.append(h).append("h");
+ }
+ if (m != 0) {
+ if (buff.length() != 0) buff.append(spacer);
+ buff.append(m).append("m");
+ }
+ if (s != 0) {
+ if (buff.length() != 0) buff.append(spacer);
+ buff.append(s).append("s");
+ }
+ if (ms != 0) {
+ if (buff.length() != 0) buff.append(spacer);
+ buff.append(ms).append("ms");
+ }
+
+ return buff.toString();
+ }
+
+ public static Duration parseDuration(final String text)
+ {
+ // for now...
+ return new Duration(Long.parseLong(text));
+ }
+
+ public static class PropertyEditor
+ extends java.beans.PropertyEditorSupport
+ {
+ public void setAsText(final String text)
+ {
+ setValue(parseDuration(text));
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Duration.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/EmptyStringException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/EmptyStringException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/EmptyStringException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,37 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * Thrown to indicate that a string was empty (aka. <code>""</code>)
+ * where it must <b>not</b> be.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class EmptyStringException
+ extends IllegalArgumentException
+{
+ /**
+ * Construct a <tt>EmptyStringException</tt>.
+ *
+ * @param msg Exception message.
+ */
+ public EmptyStringException(final String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>EmptyStringException</tt>.
+ */
+ public EmptyStringException() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/EmptyStringException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Executable.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Executable.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Executable.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,24 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util;
+
+/**
+ * Interface for the execution of a task.
+ *
+ * @see WorkerQueue
+ *
+ * @author <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
+ * @version $Revision$
+ */
+public interface Executable
+{
+ /**
+ * Executes the implemented task.
+ */
+ void execute() throws Exception;
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Executable.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/FieldInstance.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/FieldInstance.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/FieldInstance.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,95 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.lang.reflect.Field;
+
+/**
+ * A <tt>FieldInstance</tt> refers to a specific reflected field on an object.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FieldInstance
+{
+ /** Field */
+ protected final Field field;
+
+ /** Instance */
+ protected final Object instance;
+
+ /**
+ * Construct a new field instance.
+ *
+ * @param instance The instance object the given field belongs to.
+ * @param fieldName The name of the field to find in the instance.
+ *
+ * @throws NullArgumentException Instance or fieldName is <tt>null</tt>.
+ * @throws NoSuchFieldException
+ */
+ public FieldInstance(final Object instance, final String fieldName)
+ throws NoSuchFieldException
+ {
+ if (instance == null)
+ throw new NullArgumentException("instance");
+ if (fieldName == null)
+ throw new NullArgumentException("fieldName");
+
+ // Get the field object
+ field = instance.getClass().getField(fieldName);
+
+ // Check if the field is assignable ?
+ if (! field.getDeclaringClass().isAssignableFrom(instance.getClass()))
+ throw new IllegalArgumentException
+ ("field does not belong to instance class");
+
+ this.instance = instance;
+ }
+
+ /**
+ * Get the field.
+ *
+ * @return Field.
+ */
+ public final Field getField() {
+ return field;
+ }
+
+ /**
+ * Get the instance.
+ *
+ * @return Instance.
+ */
+ public final Object getInstance() {
+ return instance;
+ }
+
+ /**
+ * Get the value of the field instance.
+ *
+ * @return Field value.
+ *
+ * @throws IllegalAccessException Failed to get field value.
+ */
+ public final Object get() throws IllegalAccessException {
+ return field.get(instance);
+ }
+
+ /**
+ * Set the value of the field instance
+ *
+ * @param value Field value.
+ *
+ * @throws IllegalAccessException Failed to set field value.
+ */
+ public final void set(final Object value) throws IllegalAccessException {
+ field.set(instance, value);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/FieldInstance.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/HashCode.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/HashCode.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/HashCode.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,336 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.Serializable;
+
+/**
+ * A hash-code generator and a collection of static hash-code generation
+ * methods.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class HashCode
+ implements Serializable, Cloneable, Comparable
+{
+ /** Hashcode for a 'null' value. */
+ private static final int NULL_HASHCODE = 0;
+
+ /** Hashcode for a 'true' boolean */
+ private static final int TRUE_HASHCODE = 1231; // completely arbitrary
+
+ /** Hashcode for a 'false' boolean */
+ private static final int FALSE_HASHCODE = 1237; // completely arbitrary
+
+ /** The hash-code value. */
+ private int value;
+
+ /**
+ * Construct a new <tt>HashCode</tt> using the given <tt>int</tt> as the
+ * base value.
+ *
+ * @param value <tt>int</tt> to use as the base value.
+ */
+ public HashCode(final int value) {
+ this.value = value;
+ }
+
+ /**
+ * Construct a new <tt>HashCode</tt>.
+ */
+ public HashCode() {
+ this(0);
+ }
+
+ /**
+ * Add the hash-code of the given value.
+ *
+ * @param b Value to get hash-code from.
+ * @return <i>This</i> <tt>HashCode</tt>.
+ */
+ public HashCode add(final boolean b) {
+ value ^= generate(b);
+ return this;
+ }
+
+ /**
+ * Add the hash-code of the given value.
+ *
+ * @param n Value to get hash-code from.
+ * @return <i>This</i> <tt>HashCode</tt>.
+ */
+ public HashCode add(final byte n) {
+ value ^= n;
+ return this;
+ }
+
+ /**
+ * Add the hash-code of the given value.
+ *
+ * @param n Value to get hash-code from.
+ * @return <i>This</i> <tt>HashCode</tt>.
+ */
+ public HashCode add(final char n) {
+ value ^= n;
+ return this;
+ }
+
+ /**
+ * Add the hash-code of the given value.
+ *
+ * @param n Value to get hash-code from.
+ * @return <i>This</i> <tt>HashCode</tt>.
+ */
+ public HashCode add(final short n) {
+ value ^= n;
+ return this;
+ }
+
+ /**
+ * Add the hash-code of the given value.
+ *
+ * @param n Value to get hash-code from.
+ * @return <i>This</i> <tt>HashCode</tt>.
+ */
+ public HashCode add(final int n) {
+ value ^= n;
+ return this;
+ }
+
+ /**
+ * Add the hash-code of the given value.
+ *
+ * @param n Value to get hash-code from.
+ * @return <i>This</i> <tt>HashCode</tt>.
+ */
+ public HashCode add(final long n) {
+ value ^= generate(n);
+ return this;
+ }
+
+ /**
+ * Add the hash-code of the given value.
+ *
+ * @param f Value to get hash-code from.
+ * @return <i>This</i> <tt>HashCode</tt>.
+ */
+ public HashCode add(final float f) {
+ value ^= generate(f);
+ return this;
+ }
+
+ /**
+ * Add the hash-code of the given value.
+ *
+ * @param f Value to get hash-code from.
+ * @return <i>This</i> <tt>HashCode</tt>.
+ */
+ public HashCode add(final double f) {
+ value ^= generate(f);
+ return this;
+ }
+
+ /**
+ * Add the hash-code of the given object.
+ *
+ * @param obj Value to get hash-code from.
+ * @return <i>This</i> <tt>HashCode</tt>.
+ */
+ public HashCode add(final Object obj) {
+ value ^= generate(obj);
+ return this;
+ }
+
+ /**
+ * Get the hash-code.
+ *
+ * @return Hash-code.
+ */
+ public int hashCode() {
+ return (int)value;
+ }
+
+ /**
+ * Compares this object with the specified <tt>int</tt> for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ */
+ public int compareTo(final int other) {
+ return (value < other) ? -1 : (value == other) ? 0 : 1;
+ }
+
+ /**
+ * Compares this object with the specified object for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ *
+ * @throws ClassCastException Object is not a <tt>HashCode</tt>.
+ */
+ public int compareTo(final Object obj) throws ClassCastException {
+ HashCode hashCode = (HashCode)obj;
+ return compareTo(hashCode.value);
+ }
+
+ /**
+ * Test the equality of this <tt>HashCode</tt> and another object.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ return value == ((HashCode)obj).value;
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a string representation of this <tt>HashCode</tt>.
+ *
+ * @return A string representation of this <tt>HashCode</tt>.
+ */
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Return a cloned copy of this <tt>HashCode</tt>.
+ *
+ * @return Cloned <tt>HashCode</tt>.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Generation Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Generate a hash code for a boolean value.
+ *
+ * @param value Boolean value to generate hash code from.
+ * @return Hash code.
+ */
+ public static int generate(final boolean value) {
+ return value ? TRUE_HASHCODE : FALSE_HASHCODE;
+ }
+
+ /**
+ * Generate a hash code for a long value.
+ *
+ * @param value Long value to generate hash code from.
+ * @return Hash code.
+ */
+ public static int generate(final long value) {
+ return (int)(value ^ (value >> 32));
+ }
+
+ /**
+ * Generate a hash code for a double value.
+ *
+ * @param value Double value to generate hash code from.
+ * @return Hash code.
+ */
+ public static int generate(final double value) {
+ return generate(Double.doubleToLongBits(value));
+ }
+
+ /**
+ * Generate a hash code for a float value.
+ *
+ * @param value Float value to generate hash code from.
+ * @return Hash code.
+ */
+ public static int generate(final float value) {
+ return Float.floatToIntBits(value);
+ }
+
+ /**
+ * Generate a hash code for a byte array.
+ *
+ * @param bytes An array of bytes to generate a hash code from.
+ * @return Hash code.
+ */
+ public static int generate(final byte[] bytes) {
+ int hashcode = 0;
+
+ for (int i=0; i<bytes.length; i++) {
+ hashcode <<= 1;
+ hashcode ^= bytes[i];
+ }
+
+ return hashcode;
+ }
+
+ /**
+ * Generate a hash code for an object array.
+ *
+ * <p>Does not handle nested primitive array elements.
+ *
+ * @param array Array to generate hashcode for.
+ * @param deep True to traverse elements which are arrays to
+ * determine the elements hash code.
+ * @return Hash code.
+ */
+ public static int generate(final Object array[], final boolean deep) {
+ int hashcode = 0;
+
+ for (int i=0; i<array.length; i++) {
+ if (deep && (array[i] instanceof Object[])) {
+ hashcode ^= generate((Object[])array[i], true);
+ }
+ else {
+ hashcode ^= array[i].hashCode();
+ }
+ }
+
+ return hashcode;
+ }
+
+ /**
+ * Generate a shallow hash code for an object array.
+ *
+ * @param array Array to generate hashcode for.
+ * @return Hash code.
+ */
+ public static int generate(final Object array[]) {
+ return generate(array, false);
+ }
+
+ /**
+ * Generate a hash code for an object.
+ *
+ * @param obj Object to generate hashcode for.
+ * @return Hash code.
+ */
+ public static int generate(final Object obj) {
+ if (obj != null) {
+ return obj.hashCode();
+ }
+
+ return NULL_HASHCODE;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/HashCode.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Heap.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Heap.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Heap.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,196 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util;
+
+import java.util.Comparator;
+
+/**
+ * Data structure that mantains data in a ordered binary tree; each node is
+ * greater (smaller) or equal than its 2 sub-nodes, for all the hierarchy. <p>
+ * Elements of this data structure should either implement Comparable, or a
+ * Comparator should be given as argument to the constructor.
+ *
+ * @author <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
+ * @version $Revision$
+ */
+public class Heap
+{
+ private Comparator m_comparator;
+ private int m_count;
+ private Object[] m_nodes;
+
+ /**
+ * Creates a new Heap whose elements inserted implement the
+ * {@link Comparable} interface.
+ */
+ public Heap()
+ {
+ this(null);
+ }
+
+ /**
+ * Creates a new Heap whose elements are compared using the given
+ * {@link Comparator}.
+ */
+ public Heap(Comparator comparator)
+ {
+ m_comparator = comparator;
+ clear();
+ }
+
+ /**
+ * Inserts the given element in this heap.
+ *
+ * @see #extract
+ */
+ public void insert(Object obj)
+ {
+ int length = m_nodes.length;
+ // Expand if necessary
+ if (m_count == length)
+ {
+ Object[] newNodes = new Object[length + length];
+ System.arraycopy(m_nodes, 0, newNodes, 0, length);
+ m_nodes = newNodes;
+ }
+ // Be cur_slot the first unused slot index; be par_slot its parent index.
+ // Start from cur_slot and walk up the tree comparing the object to
+ // insert with the object at par_slot; if it's smaller move down the object at par_slot,
+ // otherwise cur_slot is the index where insert the object. If not done,
+ // shift up the tree so that now cur_slot is the old par_slot and
+ // par_slot is the parent index of the new cur_slot (so the grand-parent
+ // index of the old cur_slot) and compare again.
+ int k = m_count;
+ while (k > 0)
+ {
+ int par = parent(k);
+ if (compare(obj, m_nodes[par]) < 0)
+ {
+ m_nodes[k] = m_nodes[par];
+ k = par;
+ }
+ else break;
+ }
+ m_nodes[k] = obj;
+ ++m_count;
+ }
+
+ /**
+ * Removes and returns the least element of this heap.
+ *
+ * @see #insert
+ * @see #peek
+ */
+ public Object extract()
+ {
+ if (m_count < 1) {return null;}
+ else
+ {
+ int length = m_nodes.length >> 1;
+ // Shrink if necessary
+ if (length > 5 && m_count < (length >> 1))
+ {
+ Object[] newNodes = new Object[length];
+ System.arraycopy(m_nodes, 0, newNodes, 0, length);
+ m_nodes = newNodes;
+ }
+ //
+ int k = 0;
+ Object ret = m_nodes[k];
+ --m_count;
+ Object last = m_nodes[m_count];
+ for (;;)
+ {
+ int l = left(k);
+ if (l >= m_count) {break;}
+ else
+ {
+ int r = right(k);
+ int child = (r >= m_count || compare(m_nodes[l], m_nodes[r]) < 0) ? l : r;
+ if (compare(last, m_nodes[child]) > 0)
+ {
+ m_nodes[k] = m_nodes[child];
+ k = child;
+ }
+ else {break;}
+ }
+ }
+ m_nodes[k] = last;
+ m_nodes[m_count] = null;
+ return ret;
+ }
+ }
+
+ /**
+ * Returns, without removing it, the least element of this heap.
+ *
+ * @see #extract
+ */
+ public Object peek()
+ {
+ if (m_count < 1) {return null;}
+ else {return m_nodes[0];}
+ }
+
+ /**
+ * Empties this heap
+ */
+ public void clear()
+ {
+ m_count = 0;
+ m_nodes = new Object[10];
+ }
+
+ /**
+ * Compares the given objects using the comparator, if available,
+ * or considering them Comparable objects.
+ *
+ * @throws ClassCastException if nor the comparator is given
+ * and nor both objects implements the Comparable interface
+ */
+ protected int compare(Object o1, Object o2)
+ {
+ if (m_comparator != null)
+ {
+ return m_comparator.compare(o1, o2);
+ }
+ else
+ {
+ if (o1 == null)
+ {
+ if (o2 == null) {return 0;}
+ else {return -((Comparable)o2).compareTo(o1);}
+ }
+ else {return ((Comparable)o1).compareTo(o2);}
+ }
+ }
+
+ /**
+ * Returns the parent index of <code>index</code>.
+ */
+ protected int parent(int index)
+ {
+ return (index - 1) >> 1;
+ }
+
+ /**
+ * Returns the left child index of <code>index</code>.
+ */
+ protected int left(int index)
+ {
+ return index + index + 1;
+ }
+
+ /**
+ * Returns the right child index of <code>index</code>.
+ */
+ protected int right(int index)
+ {
+ return index + index + 2;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Heap.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/LRUCachePolicy.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/LRUCachePolicy.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/LRUCachePolicy.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,456 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util;
+
+import java.util.HashMap;
+
+/**
+ * Implementation of a Least Recently Used cache policy.
+ *
+ * @author <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
+ * @version $Revision$
+ */
+public class LRUCachePolicy
+ implements CachePolicy
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+ /**
+ * The map holding the cached objects
+ */
+ protected HashMap m_map;
+ /**
+ * The linked list used to implement the LRU algorithm
+ */
+ protected LRUList m_list;
+ /**
+ * The maximum capacity of this cache
+ */
+ protected int m_maxCapacity;
+ /**
+ * The minimum capacity of this cache
+ */
+ protected int m_minCapacity;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ /**
+ * Creates a LRU cache policy object with zero cache capacity.
+ *
+ * @see #create
+ */
+ public LRUCachePolicy()
+ {
+ }
+ /**
+ * Creates a LRU cache policy object with the specified minimum
+ * and maximum capacity.
+ *
+ * @see #create
+ */
+ public LRUCachePolicy(int min, int max)
+ {
+ if (min < 2 || min > max) {throw new IllegalArgumentException("Illegal cache capacities");}
+ m_minCapacity = min;
+ m_maxCapacity = max;
+ }
+
+ // Public --------------------------------------------------------
+
+ // Service implementation ----------------------------------------------
+ /**
+ * Initializes the cache, creating all required objects and initializing their
+ * values.
+ * @see #start
+ * @see #destroy
+ */
+ public void create()
+ {
+ m_map = new HashMap();
+ m_list = createList();
+ m_list.m_maxCapacity = m_maxCapacity;
+ m_list.m_minCapacity = m_minCapacity;
+ m_list.m_capacity = m_maxCapacity;
+ }
+ /**
+ * Starts this cache that is now ready to be used.
+ * @see #create
+ * @see #stop
+ */
+ public void start()
+ {
+ }
+ /**
+ * Stops this cache thus {@link #flush}ing all cached objects. <br>
+ * After this method is called, a call to {@link #start} will restart the cache.
+ * @see #start
+ * @see #destroy
+ */
+ public void stop()
+ {
+ if (m_list != null)
+ {
+ flush();
+ }
+ }
+ /**
+ * Destroys the cache that is now unusable. <br>
+ * To have it working again it must be re-{@link #create}ed and
+ * re-{@link #start}ed.
+ *
+ * @see #create
+ */
+ public void destroy()
+ {
+ if( m_map != null )
+ m_map.clear();
+ if( m_list != null )
+ m_list.clear();
+ }
+
+ public Object get(Object key)
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Requesting an object using a null key");
+ }
+
+ LRUCacheEntry value = (LRUCacheEntry)m_map.get(key);
+ if (value != null)
+ {
+ m_list.promote(value);
+ return value.m_object;
+ }
+ else
+ {
+ cacheMiss();
+ return null;
+ }
+ }
+ public Object peek(Object key)
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Requesting an object using a null key");
+ }
+
+ LRUCacheEntry value = (LRUCacheEntry)m_map.get(key);
+ if (value == null)
+ {
+ return null;
+ }
+ else
+ {
+ return value.m_object;
+ }
+ }
+ public void insert(Object key, Object o)
+ {
+ if (o == null) {throw new IllegalArgumentException("Cannot insert a null object in the cache");}
+ if (key == null) {throw new IllegalArgumentException("Cannot insert an object in the cache with null key");}
+ Object obj = m_map.get(key);
+ if (obj == null)
+ {
+ m_list.demote();
+ LRUCacheEntry entry = createCacheEntry(key, o);
+ m_list.promote(entry);
+ m_map.put(key, entry);
+ }
+ else
+ {
+ throw new IllegalStateException("Attempt to put in the cache an object that is already there");
+ }
+ }
+ public void remove(Object key)
+ {
+ if (key == null) {throw new IllegalArgumentException("Removing an object using a null key");}
+
+ Object value = m_map.get(key);
+ if (value != null)
+ {
+ m_list.remove((LRUCacheEntry)value);
+ }
+ else {} // Do nothing, the object isn't in the cache list
+ m_map.remove(key);
+ }
+ public void flush()
+ {
+ LRUCacheEntry entry = null;
+ while ((entry = m_list.m_tail) != null)
+ {
+ ageOut(entry);
+ }
+ }
+
+ public int size() {
+ return m_list.m_count;
+ }
+
+ // Y overrides ---------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+ /**
+ * Factory method for the linked list used by this cache implementation.
+ */
+ protected LRUList createList() {return new LRUList();}
+ /**
+ * Callback method called when the cache algorithm ages out of the cache
+ * the given entry. <br>
+ * The implementation here is removing the given entry from the cache.
+ */
+ protected void ageOut(LRUCacheEntry entry)
+ {
+ remove(entry.m_key);
+ }
+ /**
+ * Callback method called when a cache miss happens.
+ */
+ protected void cacheMiss()
+ {
+ }
+ /**
+ * Factory method for cache entries
+ */
+ protected LRUCacheEntry createCacheEntry(Object key, Object value)
+ {
+ return new LRUCacheEntry(key, value);
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+ /**
+ * Double queued list used to store cache entries.
+ */
+ public class LRUList
+ {
+ /** The maximum capacity of the cache list */
+ public int m_maxCapacity;
+ /** The minimum capacity of the cache list */
+ public int m_minCapacity;
+ /** The current capacity of the cache list */
+ public int m_capacity;
+ /** The number of cached objects */
+ public int m_count;
+ /** The head of the double linked list */
+ public LRUCacheEntry m_head;
+ /** The tail of the double linked list */
+ public LRUCacheEntry m_tail;
+ /** The cache misses happened */
+ public int m_cacheMiss;
+ /**
+ * Creates a new double queued list.
+ */
+ protected LRUList()
+ {
+ m_head = null;
+ m_tail = null;
+ m_count = 0;
+ }
+ /**
+ * Promotes the cache entry <code>entry</code> to the last used position
+ * of the list. <br>
+ * If the object is already there, does nothing.
+ * @param entry the object to be promoted, cannot be null
+ * @see #demote
+ * @throws IllegalStateException if this method is called with a full cache
+ */
+ protected void promote(LRUCacheEntry entry)
+ {
+ if (entry == null) {throw new IllegalArgumentException("Trying to promote a null object");}
+ if (m_capacity < 1) {throw new IllegalStateException("Can't work with capacity < 1");}
+
+ entry.m_time = System.currentTimeMillis();
+ if (entry.m_prev == null)
+ {
+ if (entry.m_next == null)
+ {
+ // entry is new or there is only the head
+ if (m_count == 0) // cache is empty
+ {
+ m_head = entry;
+ m_tail = entry;
+ ++m_count;
+ entryAdded(entry);
+ }
+ else if (m_count == 1 && m_head == entry) {} // there is only the head and I want to promote it, do nothing
+ else if (m_count < m_capacity)
+ {
+ entry.m_prev = null;
+ entry.m_next = m_head;
+ m_head.m_prev = entry;
+ m_head = entry;
+ ++m_count;
+ entryAdded(entry);
+ }
+ else if (m_count < m_maxCapacity)
+ {
+ entry.m_prev = null;
+ entry.m_next = m_head;
+ m_head.m_prev = entry;
+ m_head = entry;
+ ++m_count;
+ int oldCapacity = m_capacity;
+ ++m_capacity;
+ entryAdded(entry);
+ capacityChanged(oldCapacity);
+ }
+ else {throw new IllegalStateException("Attempt to put a new cache entry on a full cache");}
+ }
+ else {} // entry is the head, do nothing
+ }
+ else
+ {
+ if (entry.m_next == null) // entry is the tail
+ {
+ LRUCacheEntry beforeLast = entry.m_prev;
+ beforeLast.m_next = null;
+ entry.m_prev = null;
+ entry.m_next = m_head;
+ m_head.m_prev = entry;
+ m_head = entry;
+ m_tail = beforeLast;
+ }
+ else // entry is in the middle of the list
+ {
+ LRUCacheEntry previous = entry.m_prev;
+ previous.m_next = entry.m_next;
+ entry.m_next.m_prev = previous;
+ entry.m_prev = null;
+ entry.m_next = m_head;
+ m_head.m_prev = entry;
+ m_head = entry;
+ }
+ }
+ }
+ /**
+ * Demotes from the cache the least used entry. <br>
+ * If the cache is not full, does nothing.
+ * @see #promote
+ */
+ protected void demote()
+ {
+ if (m_capacity < 1) {throw new IllegalStateException("Can't work with capacity < 1");}
+ if (m_count > m_maxCapacity) {throw new IllegalStateException("Cache list entries number (" + m_count + ") > than the maximum allowed (" + m_maxCapacity + ")");}
+ if (m_count == m_maxCapacity)
+ {
+ LRUCacheEntry entry = m_tail;
+
+ // the entry will be removed by ageOut
+ ageOut(entry);
+ }
+ else {} // cache is not full, do nothing
+ }
+ /**
+ * Removes from the cache list the specified entry.
+ */
+ protected void remove(LRUCacheEntry entry)
+ {
+ if (entry == null) {throw new IllegalArgumentException("Cannot remove a null entry from the cache");}
+ if (m_count < 1) {throw new IllegalStateException("Trying to remove an entry from an empty cache");}
+
+ entry.m_key = entry.m_object = null;
+ if (m_count == 1)
+ {
+ m_head = m_tail = null;
+ }
+ else
+ {
+ if (entry.m_prev == null) // the head
+ {
+ m_head = entry.m_next;
+ m_head.m_prev = null;
+ entry.m_next = null;
+ }
+ else if (entry.m_next == null) // the tail
+ {
+ m_tail = entry.m_prev;
+ m_tail.m_next = null;
+ entry.m_prev = null;
+ }
+ else // in the middle
+ {
+ entry.m_next.m_prev = entry.m_prev;
+ entry.m_prev.m_next = entry.m_next;
+ entry.m_prev = null;
+ entry.m_next = null;
+ }
+ }
+ --m_count;
+ entryRemoved(entry);
+ }
+ /**
+ * Callback that signals that the given entry has been added to the cache.
+ */
+ protected void entryAdded(LRUCacheEntry entry) {}
+ /**
+ * Callback that signals that the given entry has been removed from the cache.
+ */
+ protected void entryRemoved(LRUCacheEntry entry) {}
+ /**
+ * Callback that signals that the capacity of the cache is changed.
+ * @param oldCapacity the capacity before the change happened
+ */
+ protected void capacityChanged(int oldCapacity) {}
+
+ protected void clear()
+ {
+ m_head = null;
+ m_tail = null;
+ m_count = 0;
+ }
+
+ public String toString()
+ {
+ String s = Integer.toHexString(super.hashCode());
+ s += " size: " + m_count;
+ for (LRUCacheEntry entry = m_head; entry != null; entry = entry.m_next)
+ {
+ s += "\n" + entry;
+ }
+ return s;
+ }
+ }
+
+ /**
+ * Double linked cell used as entry in the cache list.
+ */
+ public class LRUCacheEntry
+ {
+ /** Reference to the next cell in the list */
+ public LRUCacheEntry m_next;
+ /** Reference to the previous cell in the list */
+ public LRUCacheEntry m_prev;
+ /** The key used to retrieve the cached object */
+ public Object m_key;
+ /** The cached object */
+ public Object m_object;
+ /** The timestamp of the creation */
+ public long m_time;
+ /**
+ * Creates a new double linked cell, storing the object we
+ * want to cache and the key that is used to retrieve it.
+ */
+ protected LRUCacheEntry(Object key, Object object)
+ {
+ m_key = key;
+ m_object = object;
+ m_next = null;
+ m_prev = null;
+ m_time = 0; // Set when inserted in the list.
+ }
+ public String toString()
+ {
+ return "key: " + m_key + ", object: " + ( m_object==null ? "null" : Integer.toHexString(m_object.hashCode())) + ", entry: " + Integer.toHexString(super.hashCode());
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/LRUCachePolicy.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/LongCounter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/LongCounter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/LongCounter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,236 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.Serializable;
+
+/**
+ * A long integer counter class.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class LongCounter
+ implements Serializable, Cloneable
+{
+ /** The current count */
+ private long count;
+
+ /**
+ * Construct a LongCounter with a starting value.
+ *
+ * @param count Starting value for counter.
+ */
+ public LongCounter(final long count) {
+ this.count = count;
+ }
+
+ /**
+ * Construct a LongCounter.
+ */
+ public LongCounter() {}
+
+ /**
+ * Increment the counter. (Optional operation)
+ *
+ * @return The incremented value of the counter.
+ */
+ public long increment() {
+ return ++count;
+ }
+
+ /**
+ * Decrement the counter. (Optional operation)
+ *
+ * @return The decremented value of the counter.
+ */
+ public long decrement() {
+ return --count;
+ }
+
+ /**
+ * Return the current value of the counter.
+ *
+ * @return The current value of the counter.
+ */
+ public long getCount() {
+ return count;
+ }
+
+ /**
+ * Reset the counter to zero. (Optional operation)
+ */
+ public void reset() {
+ this.count = 0;
+ }
+
+ /**
+ * Check if the given object is equal to this.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal to this.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ return ((LongCounter)obj).count == count;
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a string representation of this.
+ *
+ * @return A string representation of this.
+ */
+ public String toString() {
+ return String.valueOf(count);
+ }
+
+ /**
+ * Return a cloned copy of this object.
+ *
+ * @return A cloned copy of this object.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Wrappers //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Base wrapper class for other wrappers.
+ */
+ private static class Wrapper
+ extends LongCounter
+ {
+ /** The wrapped counter */
+ protected final LongCounter counter;
+
+ public Wrapper(final LongCounter counter) {
+ this.counter = counter;
+ }
+
+ public long increment() {
+ return counter.increment();
+ }
+
+ public long decrement() {
+ return counter.decrement();
+ }
+
+ public long getCount() {
+ return counter.getCount();
+ }
+
+ public void reset() {
+ counter.reset();
+ }
+
+ public boolean equals(final Object obj) {
+ return counter.equals(obj);
+ }
+
+ public String toString() {
+ return counter.toString();
+ }
+
+ public Object clone() {
+ return counter.clone();
+ }
+ }
+
+ /**
+ * Return a synchronized counter.
+ *
+ * @param counter LongCounter to synchronize.
+ * @return Synchronized counter.
+ */
+ public static LongCounter makeSynchronized(final LongCounter counter)
+ {
+ return new Wrapper(counter) {
+ public synchronized long increment() {
+ return this.counter.increment();
+ }
+
+ public synchronized long decrement() {
+ return this.counter.decrement();
+ }
+
+ public synchronized long getCount() {
+ return this.counter.getCount();
+ }
+
+ public synchronized void reset() {
+ this.counter.reset();
+ }
+
+ public synchronized int hashCode() {
+ return this.counter.hashCode();
+ }
+
+ public synchronized boolean equals(final Object obj) {
+ return this.counter.equals(obj);
+ }
+
+ public synchronized String toString() {
+ return this.counter.toString();
+ }
+
+ public synchronized Object clone() {
+ return this.counter.clone();
+ }
+ };
+ }
+
+ /**
+ * Returns a directional counter.
+ *
+ * @param counter LongCounter to make directional.
+ * @param increasing True to create an increasing only
+ * or false to create a decreasing only.
+ * @return A directional counter.
+ */
+ public static LongCounter makeDirectional(final LongCounter counter,
+ final boolean increasing)
+ {
+ LongCounter temp;
+ if (increasing) {
+ temp = new Wrapper(counter) {
+ public long decrement() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void reset() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ else {
+ temp = new Wrapper(counter) {
+ public long increment() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ return temp;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/LongCounter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MethodHashing.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MethodHashing.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MethodHashing.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,144 @@
+/*
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
+package org.jboss.util;
+
+import java.io.DataOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.WeakHashMap;
+import java.security.DigestOutputStream;
+import java.security.MessageDigest;
+
+/**
+ * Create a unique hash for
+ *
+ * @see <related>
+ * @author <a href="mailto:marc at jboss.org">Marc Fleury</a>
+ * @version $Revision$
+ * Revisions:
+ *
+ */
+public class MethodHashing
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+ static Map hashMap = new WeakHashMap();
+
+ /**
+ * Calculate method hashes. This algo is taken from RMI.
+ *
+ * @param intf
+ * @return
+ */
+ public static Map getInterfaceHashes(Class intf)
+ {
+ // Create method hashes
+ Method[] methods = intf.getDeclaredMethods();
+ HashMap map = new HashMap();
+ for (int i = 0; i < methods.length; i++)
+ {
+ Method method = methods[i];
+ Class[] parameterTypes = method.getParameterTypes();
+ String methodDesc = method.getName()+"(";
+ for(int j = 0; j < parameterTypes.length; j++)
+ {
+ methodDesc += getTypeString(parameterTypes[j]);
+ }
+ methodDesc += ")"+getTypeString(method.getReturnType());
+
+ try
+ {
+ long hash = 0;
+ ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(512);
+ MessageDigest messagedigest = MessageDigest.getInstance("SHA");
+ DataOutputStream dataoutputstream = new DataOutputStream(new DigestOutputStream(bytearrayoutputstream, messagedigest));
+ dataoutputstream.writeUTF(methodDesc);
+ dataoutputstream.flush();
+ byte abyte0[] = messagedigest.digest();
+ for(int j = 0; j < Math.min(8, abyte0.length); j++)
+ hash += (long)(abyte0[j] & 0xff) << j * 8;
+ map.put(method.toString(), new Long(hash));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ return map;
+ }
+
+ static String getTypeString(Class cl)
+ {
+ if (cl == Byte.TYPE)
+ {
+ return "B";
+ } else if (cl == Character.TYPE)
+ {
+ return "C";
+ } else if (cl == Double.TYPE)
+ {
+ return "D";
+ } else if (cl == Float.TYPE)
+ {
+ return "F";
+ } else if (cl == Integer.TYPE)
+ {
+ return "I";
+ } else if (cl == Long.TYPE)
+ {
+ return "J";
+ } else if (cl == Short.TYPE)
+ {
+ return "S";
+ } else if (cl == Boolean.TYPE)
+ {
+ return "Z";
+ } else if (cl == Void.TYPE)
+ {
+ return "V";
+ } else if (cl.isArray())
+ {
+ return "["+getTypeString(cl.getComponentType());
+ } else
+ {
+ return "L"+cl.getName().replace('.','/')+";";
+ }
+ }
+
+ /*
+ * The use of hashCode is not enough to differenciate methods
+ * we override the hashCode
+ *
+ * The hashes are cached in a static for efficiency
+ * RO: WeakHashMap needed to support undeploy
+ */
+ public static long calculateHash(Method method)
+ {
+ Map methodHashes = (Map)hashMap.get(method.getDeclaringClass());
+
+ if (methodHashes == null)
+ {
+ methodHashes = getInterfaceHashes(method.getDeclaringClass());
+
+ // Copy and add
+ WeakHashMap newHashMap = new WeakHashMap();
+ newHashMap.putAll(hashMap);
+ newHashMap.put(method.getDeclaringClass(), methodHashes);
+ hashMap = newHashMap;
+ }
+
+ return ((Long)methodHashes.get(method.toString())).longValue();
+ }
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MethodHashing.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuBoolean.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuBoolean.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuBoolean.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,302 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.Serializable;
+
+/**
+ * A mutable boolean class.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class MuBoolean
+ implements Comparable, Cloneable, Serializable, Mutable
+{
+ /** Boolean value */
+ private boolean value; // = false;
+
+ /**
+ * Construct a new mutable boolean.
+ */
+ public MuBoolean() {}
+
+ /**
+ * Construct a new mutable boolean.
+ *
+ * @param b Boolean value.
+ */
+ public MuBoolean(boolean b) {
+ value = b;
+ }
+
+ /**
+ * Construct a new mutable boolean.
+ *
+ * @param obj Object to convert to a boolean value.
+ */
+ public MuBoolean(Object obj) {
+ setValue(obj);
+ }
+
+ /**
+ * Construct a new mutable boolean.
+ *
+ * @param value String to convert to a boolean value.
+ */
+ public MuBoolean(String value) {
+ set(Boolean.valueOf(value));
+ }
+
+ /**
+ * Return the value of this mutable boolean.
+ *
+ * @return Boolean value.
+ */
+ public boolean booleanValue() {
+ return value;
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param b Boolean value.
+ * @return The previous value.
+ */
+ public boolean set(boolean b) {
+ boolean old = value;
+ value = b;
+ return old;
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param b Boolean value.
+ * @return The previous value.
+ */
+ public boolean set(Boolean b) {
+ boolean old = value;
+ value = b.booleanValue();
+ return old;
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param b Boolean value.
+ * @return The previous value.
+ */
+ public boolean set(MuBoolean b) {
+ boolean old = value;
+ value = b.value;
+ return old;
+ }
+
+ /**
+ * Get the current value.
+ *
+ * @return The current value.
+ */
+ public boolean get() {
+ return value;
+ }
+
+ /**
+ * Set the value to value only if the current value is equal to
+ * the assumed value.
+ *
+ * @param assumed The assumed value.
+ * @param b The new value.
+ * @return True if value was changed.
+ */
+ public boolean commit(boolean assumed, boolean b) {
+ boolean success = (assumed == value);
+ if (success) value = b;
+ return success;
+ }
+
+ /**
+ * Swap values with another mutable boolean.
+ *
+ * @param b Mutable boolean to swap values with.
+ * @return The new value.
+ */
+ public boolean swap(MuBoolean b) {
+ if (b == this) return value;
+
+ boolean temp = value;
+ value = b.value;
+ b.value = temp;
+
+ return value;
+ }
+
+ /**
+ * Set the value to its complement.
+ *
+ * @return The new value.
+ */
+ public boolean complement() {
+ value = !value;
+ return value;
+ }
+
+ /**
+ * <i>AND</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>and</i> with.
+ * @return The new value.
+ */
+ public boolean and(boolean b) {
+ value &= b;
+
+ return value;
+ }
+
+ /**
+ * <i>OR</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>or</i> with.
+ * @return The new value.
+ */
+ public boolean or(boolean b) {
+ value |= b;
+
+ return value;
+ }
+
+ /**
+ * <i>XOR</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>xor</i> with.
+ * @return The new value.
+ */
+ public boolean xor(boolean b) {
+ value ^= b;
+
+ return value;
+ }
+
+ /**
+ * Compares this object with the specified boolean for order.
+ *
+ * @param bool Boolean to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ */
+ public int compareTo(boolean bool) {
+ return (value == bool) ? 0 : (value) ? 1 : -1;
+ }
+
+ /**
+ * Compares this object with the specified object for order.
+ *
+ * @param bool Boolean to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ *
+ * @throws ClassCastException Object is not a MuBoolean.
+ */
+ public int compareTo(Object obj) throws ClassCastException {
+ return compareTo(((MuBoolean)obj).value);
+ }
+
+ /**
+ * Convert to a string.
+ *
+ * @return String value
+ */
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Return the hash code for this mutable boolean.
+ *
+ * @return Hash code
+ */
+ public int hashCode() {
+ return HashCode.generate(value);
+ }
+
+ /**
+ * Test the equality of another object.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal to this.
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ MuBoolean bool = (MuBoolean)obj;
+ return value == bool.value;
+ }
+
+ return false;
+ }
+
+ /**
+ * Clone this mutable boolean.
+ *
+ * @return Cloned mutable boolean.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Mutable Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Set the value of this mutable boolean.
+ *
+ * <p>If value is a <code>java.lang.Boolean</code>, then use
+ * <code>Boolean.booleanValue()</code> to determin value, if
+ * the object is non-null then the value is <i>true</i>, else
+ * it is <i>false</i>.
+ *
+ * @param obj Object to convert to a boolean value.
+ */
+ public void setValue(Object obj) {
+ if (obj instanceof MuBoolean) {
+ value = ((MuBoolean)obj).value;
+ }
+ else if (obj instanceof Boolean) {
+ value = ((Boolean)obj).booleanValue();
+ }
+ else if (obj != null) {
+ value = true;
+ }
+ else {
+ value = false;
+ }
+ }
+
+ /**
+ * Get the boolean value of this mutable boolean.
+ *
+ * @return <code>java.lang.Boolean</code> value.
+ */
+ public Object getValue() {
+ return value ? Boolean.TRUE : Boolean.FALSE;
+ }
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuBoolean.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuByte.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuByte.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuByte.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,402 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * A mutable byte class.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class MuByte
+ extends MuNumber
+{
+ /** Byte value */
+ private byte value; // = 0;
+
+ /**
+ * Construct a new mutable byte.
+ */
+ public MuByte() {}
+
+ /**
+ * Construct a new mutable byte.
+ *
+ * @param b Byte value.
+ */
+ public MuByte(byte b) {
+ value = b;
+ }
+
+ /**
+ * Construct a new mutable byte.
+ *
+ * @param obj Object to convert to a byte value.
+ */
+ public MuByte(Object obj) {
+ setValue(obj);
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param b Byte value.
+ * @return The previous value.
+ */
+ public byte set(byte b) {
+ byte old = value;
+ value = b;
+ return old;
+ }
+
+ /**
+ * Get the value.
+ *
+ * @return Byte value.
+ */
+ public byte get() {
+ return value;
+ }
+
+ /**
+ * Set the value to value only if the current value is equal to
+ * the assumed value.
+ *
+ * @param assumed The assumed value.
+ * @param b The new value.
+ * @return True if value was changed.
+ */
+ public boolean commit(byte assumed, byte b) {
+ boolean success = (assumed == value);
+ if (success) value = b;
+ return success;
+ }
+
+ /**
+ * Swap values with another mutable byte.
+ *
+ * @param b Mutable byte to swap values with.
+ * @return The new value.
+ */
+ public byte swap(MuByte b) {
+ if (b == this) return value;
+
+ byte temp = value;
+ value = b.value;
+ b.value = temp;
+
+ return value;
+ }
+
+ /**
+ * Increment the value of this mutable byte.
+ *
+ * @return Byte value.
+ */
+ public byte increment() {
+ return ++value;
+ }
+
+ /**
+ * Decrement the value of this mutable byte.
+ *
+ * @return Byte value.
+ */
+ public byte decrement() {
+ return --value;
+ }
+
+ /**
+ * Add the specified amount.
+ *
+ * @param amount Amount to add.
+ * @return The new value.
+ */
+ public byte add(byte amount) {
+ return value += amount;
+ }
+
+ /**
+ * Subtract the specified amount.
+ *
+ * @param amount Amount to subtract.
+ * @return The new value.
+ */
+ public byte subtract(byte amount) {
+ return value -= amount;
+ }
+
+ /**
+ * Multiply by the specified factor.
+ *
+ * @param factor Factor to multiply by.
+ * @return The new value.
+ */
+ public byte multiply(byte factor) {
+ return value *= factor;
+ }
+
+ /**
+ * Divide by the specified factor.
+ *
+ * @param factor Factor to divide by.
+ * @return The new value.
+ */
+ public byte divide(byte factor) {
+ return value /= factor;
+ }
+
+ /**
+ * Set the value to the negative of its current value.
+ *
+ * @return The new value.
+ */
+ public byte negate() {
+ value = ((byte)-value);
+ return value;
+ }
+
+ /**
+ * Set the value to its complement.
+ *
+ * @return The new value.
+ */
+ public byte complement() {
+ value = (byte)~value;
+ return value;
+ }
+
+ /**
+ * <i>AND</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>and</i> with.
+ * @return The new value.
+ */
+ public byte and(byte b) {
+ value = (byte)(value & b);
+ return value;
+ }
+
+ /**
+ * <i>OR</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>or</i> with.
+ * @return The new value.
+ */
+ public byte or(byte b) {
+ value = (byte)(value | b);
+ return value;
+ }
+
+ /**
+ * <i>XOR</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>xor</i> with.
+ * @return The new value.
+ */
+ public byte xor(byte b) {
+ value = (byte)(value ^ b);
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>right</i>.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public byte shiftRight(int bits) {
+ value >>= bits;
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>right</i> with a zero extension.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public byte shiftRightZero(int bits) {
+ value >>>= bits;
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>left</i>.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public byte shiftLeft(int bits) {
+ value <<= bits;
+ return value;
+ }
+
+ /**
+ * Compares this object with the specified byte for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ */
+ public int compareTo(byte other) {
+ return (value < other) ? -1 : (value == other) ? 0 : 1;
+ }
+
+ /**
+ * Compares this object with the specified object for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ *
+ * @throws ClassCastException Object is not a MuByte.
+ */
+ public int compareTo(Object obj) throws ClassCastException {
+ return compareTo((MuByte)obj);
+ }
+
+ /**
+ * Convert this mutable byte to a string.
+ *
+ * @return String value.
+ */
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Get the hash code for this mutable byte.
+ *
+ * @return Hash code.
+ */
+ public int hashCode() {
+ return (int)value;
+ }
+
+ /**
+ * Test the equality of this mutable byte and another object.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal.
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ return value == ((MuByte)obj).byteValue();
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a cloned copy of this mutable byte.
+ *
+ * @return Cloned mutable byte.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Number Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return the <code>byte</code> value of this object.
+ *
+ * @return <code>byte</code> value.
+ */
+ public byte byteValue() {
+ return (byte)value;
+ }
+
+ /**
+ * Return the <code>short</code> value of this object.
+ *
+ * @return <code>short</code> value.
+ */
+ public short shortValue() {
+ return (short)value;
+ }
+
+ /**
+ * Return the <code>int</code> value of this object.
+ *
+ * @return <code>int</code> value.
+ */
+ public int intValue() {
+ return (int)value;
+ }
+
+ /**
+ * Return the <code>long</code> value of this object.
+ *
+ * @return <code>long</code> value.
+ */
+ public long longValue() {
+ return (long)value;
+ }
+
+ /**
+ * Return the <code>float</code> value of this object.
+ *
+ * @return <code>float</code> value.
+ */
+ public float floatValue() {
+ return (float)value;
+ }
+
+ /**
+ * Return the <code>double</code> value of this object.
+ *
+ * @return <code>double</code> value.
+ */
+ public double doubleValue() {
+ return (double)value;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Mutable Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Set the value of this mutable byte.
+ *
+ * @param obj Object to convert to a <code>byte</code> value.
+ */
+ public void setValue(Object obj) {
+ if (obj instanceof Number) {
+ value = ((Number)obj).byteValue();
+ }
+ else {
+ value = (byte)obj.hashCode();
+ }
+ }
+
+ /**
+ * Get the byte value of this mutable byte.
+ *
+ * @return <code>java.lang.Byte</code> value.
+ */
+ public Object getValue() {
+ return new Byte(value);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuByte.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuCharacter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuCharacter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuCharacter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,189 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.Serializable;
+
+/**
+ * A mutable character class.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class MuCharacter
+ implements Comparable, Cloneable, Serializable, Mutable
+{
+ /** <code>char</code> value */
+ private char value = 0;
+
+ /**
+ * Construct a new mutable character.
+ */
+ public MuCharacter() {}
+
+ /**
+ * Construct a new mutable character.
+ *
+ * @param c <code>char</code> value.
+ */
+ public MuCharacter(char c) {
+ value = c;
+ }
+
+ /**
+ * Construct a new mutable character.
+ *
+ * @param obj Object to convert to a <code>char</code>.
+ */
+ public MuCharacter(Object obj) {
+ setValue(obj);
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param c <code>char</code> value.
+ * @return The previous value.
+ */
+ public char set(char c) {
+ char old = value;
+ value = c;
+ return old;
+ }
+
+ /**
+ * Get the current value.
+ *
+ * @return The current value.
+ */
+ public char get() {
+ return value;
+ }
+
+ /**
+ * Return the <code>char</code> value of this mutable character.
+ *
+ * @return <code>char</code> value.
+ */
+ public char charValue() {
+ return value;
+ }
+
+ /**
+ * Compares this object with the specified long for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ */
+ public int compareTo(char other) {
+ return (value < other) ? -1 : (value == other) ? 0 : 1;
+ }
+
+ /**
+ * Compares this object with the specified object for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ *
+ * @throws ClassCastException Object is not a MuCharacter.
+ */
+ public int compareTo(Object obj) {
+ return compareTo((MuCharacter)obj);
+ }
+
+ /**
+ * Convert this mutable character to a string.
+ *
+ * @return String value.
+ */
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Get the hash code of this mutable character.
+ *
+ * @return Hash code.
+ */
+ public int hashCode() {
+ return value;
+ }
+
+ /**
+ * Test the equality of this mutable character and another object.
+ *
+ * @param obj Qbject to test equality with.
+ * @return True if object is equal.
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ return value == ((MuCharacter)obj).charValue();
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a cloned copy of this mutable character.
+ *
+ * @return Cloned mutable character.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Mutable Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Set the value of this mutable character.
+ *
+ * @param obj Object to convert to a <code>char</code>.
+ *
+ * @throws NotCoercibleException Can not convert to <code>char</code>.
+ */
+ public void setValue(Object obj) {
+ if (obj instanceof MuCharacter) {
+ value = ((MuCharacter)obj).value;
+ }
+ else if (obj instanceof Character) {
+ value = ((Character)obj).charValue();
+ }
+ else if (obj instanceof Number) {
+ value = (char)((Number)obj).intValue();
+ }
+ else {
+ throw new NotCoercibleException("can not convert to 'char': " + obj);
+ }
+ }
+
+ /**
+ * Return the char value of this mutable character.
+ *
+ * @return <code>java.lang.Character</code> value.
+ */
+ public Object getValue() {
+ return new Character(value);
+ }
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuCharacter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuDouble.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuDouble.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuDouble.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,309 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * A mutable double class.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class MuDouble
+ extends MuNumber
+{
+ /** Double value */
+ private double value = 0;
+
+ /**
+ * Construct a new mutable double.
+ */
+ public MuDouble() {}
+
+ /**
+ * Construct a new mutable double.
+ *
+ * @param d <code>double</code> value.
+ */
+ public MuDouble(double d) {
+ value = d;
+ }
+
+ /**
+ * Construct a new mutable double.
+ *
+ * @param obj Object to convert to a <code>double</code> value.
+ */
+ public MuDouble(Object obj) {
+ setValue(obj);
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param f <code>double</code> value.
+ * @return The previous value.
+ */
+ public double set(double f) {
+ double old = value;
+ value = f;
+ return old;
+ }
+
+ /**
+ * Get the current value.
+ *
+ * @return The current value.
+ */
+ public double get() {
+ return value;
+ }
+
+ /**
+ * Set the value to value only if the current value is equal to
+ * the assumed value.
+ *
+ * @param assumed The assumed value.
+ * @param b The new value.
+ * @return True if value was changed.
+ */
+ public boolean commit(double assumed, double b) {
+ boolean success = Primitives.equals(assumed, value);
+ if (success) value = b;
+ return success;
+ }
+
+ /**
+ * Swap values with another mutable double.
+ *
+ * @param b Mutable double to swap values with.
+ * @return The new value.
+ */
+ public double swap(MuDouble b) {
+ if (b == this) return value;
+
+ double temp = value;
+ value = b.value;
+ b.value = temp;
+
+ return value;
+ }
+
+ /**
+ * Add the specified amount.
+ *
+ * @param amount Amount to add.
+ * @return The new value.
+ */
+ public double add(double amount) {
+ return value += amount;
+ }
+
+ /**
+ * Subtract the specified amount.
+ *
+ * @param amount Amount to subtract.
+ * @return The new value.
+ */
+ public double subtract(double amount) {
+ return value -= amount;
+ }
+
+ /**
+ * Multiply by the specified factor.
+ *
+ * @param factor Factor to multiply by.
+ * @return The new value.
+ */
+ public double multiply(double factor) {
+ return value *= factor;
+ }
+
+ /**
+ * Divide by the specified factor.
+ *
+ * @param factor Factor to divide by.
+ * @return The new value.
+ */
+ public double divide(double factor) {
+ return value /= factor;
+ }
+
+ /**
+ * Set the value to the negative of its current value.
+ *
+ * @return The new value.
+ */
+ public double negate() {
+ value = ((double)-value);
+ return value;
+ }
+
+ /**
+ * Compares this object with the specified double for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ */
+ public int compareTo(double other) {
+ return (value < other) ? -1 : Primitives.equals(value, other) ? 0 : 1;
+ }
+
+ /**
+ * Compares this object with the specified object for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ *
+ * @throws ClassCastException Object is not a MuDouble.
+ */
+ public int compareTo(Object obj) {
+ return compareTo((MuDouble)obj);
+ }
+
+ /**
+ * Convert this mutable double to a string.
+ *
+ * @return String value.
+ */
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Get the hash code for this mutable double.
+ *
+ * @return Hash code.
+ */
+ public int hashCode() {
+ return HashCode.generate(value);
+ }
+
+ /**
+ * Test the equality of this mutable double with another object.
+ *
+ * @param obj Object to test
+ * @return Is equal
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ return Primitives.equals(value, ((MuDouble)obj).doubleValue());
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a cloned copy of this mutable double.
+ *
+ * @return Cloaned mutable double.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Number Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return the <code>byte</code> value of this object.
+ *
+ * @return <code>byte</code> value.
+ */
+ public byte byteValue() {
+ return (byte)value;
+ }
+
+ /**
+ * Return the <code>short</code> value of this object.
+ *
+ * @return <code>short</code> value.
+ */
+ public short shortValue() {
+ return (short)value;
+ }
+
+ /**
+ * Return the <code>int</code> value of this object.
+ *
+ * @return <code>int</code> value.
+ */
+ public int intValue() {
+ return (int)value;
+ }
+
+ /**
+ * Return the <code>long</code> value of this object.
+ *
+ * @return <code>long</code> value.
+ */
+ public long longValue() {
+ return (long)value;
+ }
+
+ /**
+ * Return the <code>float</code> value of this object.
+ *
+ * @return <code>float</code> value.
+ */
+ public float floatValue() {
+ return (float)value;
+ }
+
+ /**
+ * Return the <code>double</code> value of this object.
+ *
+ * @return <code>double</code> value.
+ */
+ public double doubleValue() {
+ return (double)value;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Mutable Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Set the value of this mutable double.
+ *
+ * @param obj Object to convert to a <code>double</code> value.
+ *
+ * @throws NotCoercibleException Can not convert to <code>double</code>.
+ */
+ public void setValue(Object obj) {
+ if (obj instanceof Number) {
+ value = ((Number)obj).doubleValue();
+ }
+ else {
+ throw new NotCoercibleException("can not convert to 'double': " + obj);
+ }
+ }
+
+ /**
+ * Get the value of this mutable double.
+ *
+ * @return <code>java.lang.Double</code> value
+ */
+ public Object getValue() {
+ return new Double(value);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuDouble.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuFloat.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuFloat.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuFloat.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,318 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * A mutable float class.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class MuFloat
+ extends MuNumber
+{
+ /** Float value */
+ private float value; // = 0;
+
+ /**
+ * Construct a new mutable float.
+ */
+ public MuFloat() {}
+
+ /**
+ * Construct a new mutable float.
+ *
+ * @param f <code>float</code> value.
+ */
+ public MuFloat(float f) {
+ value = f;
+ }
+
+ /**
+ * Construct a new mutable float.
+ *
+ * @param obj Object to convert to a <code>float</code> value.
+ */
+ public MuFloat(Object obj) {
+ setValue(obj);
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param f <code>float</code> value.
+ * @return The previous value.
+ */
+ public float set(float f) {
+ float old = value;
+ value = f;
+ return old;
+ }
+
+ /**
+ * Get the current value.
+ *
+ * @return The current value.
+ */
+ public float get() {
+ return value;
+ }
+
+ /**
+ * Set the value to value only if the current value is equal to
+ * the assumed value.
+ *
+ * @param assumed The assumed value.
+ * @param b The new value.
+ * @return True if value was changed.
+ */
+ public boolean commit(float assumed, float b) {
+ boolean success = Primitives.equals(assumed, value);
+ if (success) value = b;
+ return success;
+ }
+
+ /**
+ * Swap values with another mutable float.
+ *
+ * @param b Mutable float to swap values with.
+ * @return The new value.
+ */
+ public float swap(MuFloat b) {
+ if (b == this) return value;
+
+ float temp = value;
+ value = b.value;
+ b.value = temp;
+
+ return value;
+ }
+
+ /**
+ * Add the specified amount.
+ *
+ * @param amount Amount to add.
+ * @return The new value.
+ */
+ public float add(float amount) {
+ return value += amount;
+ }
+
+ /**
+ * Subtract the specified amount.
+ *
+ * @param amount Amount to subtract.
+ * @return The new value.
+ */
+ public float subtract(float amount) {
+ return value -= amount;
+ }
+
+ /**
+ * Multiply by the specified factor.
+ *
+ * @param factor Factor to multiply by.
+ * @return The new value.
+ */
+ public float multiply(float factor) {
+ return value *= factor;
+ }
+
+ /**
+ * Divide by the specified factor.
+ *
+ * @param factor Factor to divide by.
+ * @return The new value.
+ */
+ public float divide(float factor) {
+ return value /= factor;
+ }
+
+ /**
+ * Set the value to the negative of its current value.
+ *
+ * @return The new value.
+ */
+ public float negate() {
+ value = ((float)-value);
+ return value;
+ }
+
+ /**
+ * Compares this object with the specified float for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ */
+ public int compareTo(float other) {
+ return (value < other) ? -1 : Primitives.equals(value, other) ? 0 : 1;
+ }
+
+ /**
+ * Compares this object with the specified object for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ *
+ * @throws ClassCastException Object is not a MuFloat.
+ */
+ public int compareTo(Object obj) {
+ return compareTo((MuFloat)obj);
+ }
+
+ /**
+ * Convert this mutable float to a string.
+ *
+ * @return String value.
+ */
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Get the hash code for this mutable float.
+ *
+ * @return Hash code.
+ */
+ public int hashCode() {
+ return HashCode.generate(value);
+ }
+
+ /**
+ * Test the equality of this mutable double with another object.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal.
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ return Primitives.equals(value, ((MuFloat)obj).floatValue());
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a cloned copy of this mutable float.
+ *
+ * @return Cloaned mutable float.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Number Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return the <code>byte</code> value of this object.
+ *
+ * @return <code>byte</code> value.
+ */
+ public byte byteValue() {
+ return (byte)value;
+ }
+
+ /**
+ * Return the <code>short</code> value of this object.
+ *
+ * @return <code>short</code> value.
+ */
+ public short shortValue() {
+ return (short)value;
+ }
+
+ /**
+ * Return the <code>int</code> value of this object.
+ *
+ * @return <code>int</code> value.
+ */
+ public int intValue() {
+ return (int)value;
+ }
+
+ /**
+ * Return the <code>long</code> value of this object.
+ *
+ * @return <code>long</code> value.
+ */
+ public long longValue() {
+ return (long)value;
+ }
+
+ /**
+ * Return the <code>float</code> value of this object.
+ *
+ * @return <code>float</code> value.
+ */
+ public float floatValue() {
+ return (float)value;
+ }
+
+ /**
+ * Return the <code>double</code> value of this object.
+ *
+ * @return <code>double</code> value.
+ */
+ public double doubleValue() {
+ return (double)value;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Mutable Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Set the value of this mutable float.
+ *
+ * @param obj Object to convert to a <code>float</code> value.
+ *
+ * @throws NotCoercibleException Can not convert to <code>float</code>.
+ */
+ public void setValue(Object obj) {
+ if (obj instanceof Number) {
+ value = ((Number)obj).floatValue();
+ }
+ else if (obj instanceof String) {
+ try {
+ value = Float.parseFloat(String.valueOf(obj));
+ }
+ catch (Exception e) {
+ throw new NotCoercibleException("can not convert to 'float': " + obj);
+ }
+ }
+ else {
+ throw new NotCoercibleException("can not convert to 'float': " + obj);
+ }
+ }
+
+ /**
+ * Get the float value of this mutable float.
+ *
+ * @return <code>java.lang.Float</code> value.
+ */
+ public Object getValue() {
+ return new Float(value);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuFloat.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuInteger.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuInteger.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuInteger.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,382 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * A mutable integer class.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class MuInteger
+ extends MuNumber
+{
+ /** Integer value */
+ private int value;
+
+ /**
+ * Construct a new mutable integer.
+ */
+ public MuInteger() {}
+
+ /**
+ * Construct a new mutable integer.
+ *
+ * @param i Integer value.
+ */
+ public MuInteger(int i) {
+ value = i;
+ }
+
+ /**
+ * Construct a new mutable integer.
+ *
+ * @param obj Object to convert to a <code>int</code> value.
+ */
+ public MuInteger(Object obj) {
+ setValue(obj);
+ }
+
+ /**
+ * Set the value to value only if the current value is equal to
+ * the assumed value.
+ *
+ * @param assumed The assumed value.
+ * @param i The new value.
+ * @return True if value was changed.
+ */
+ public boolean commit(int assumed, int i) {
+ boolean success = (assumed == value);
+ if (success) value = i;
+ return success;
+ }
+
+ /**
+ * Swap values with another mutable integer.
+ *
+ * @param i Mutable integer to swap values with.
+ * @return The new value.
+ */
+ public int swap(MuInteger i) {
+ if (i == this) return i.value;
+
+ int temp = value;
+ value = i.value;
+ i.value = temp;
+
+ return value;
+ }
+
+ /**
+ * Increment the value of this mutable integer.
+ *
+ * @return Int value.
+ */
+ public int increment() {
+ return ++value;
+ }
+
+ /**
+ * Decrement the value of this mutable integer.
+ *
+ * @return Int value.
+ */
+ public int decrement() {
+ return --value;
+ }
+
+ /**
+ * Add the specified amount.
+ *
+ * @param amount Amount to add.
+ * @return The new value.
+ */
+ public int add(int amount) {
+ return value += amount;
+ }
+
+ /**
+ * Subtract the specified amount.
+ *
+ * @param amount Amount to subtract.
+ * @return The new value.
+ */
+ public int subtract(int amount) {
+ return value -= amount;
+ }
+
+ /**
+ * Multiply by the specified factor.
+ *
+ * @param factor Factor to multiply by.
+ * @return The new value.
+ */
+ public int multiply(int factor) {
+ return value *= factor;
+ }
+
+ /**
+ * Divide by the specified factor.
+ *
+ * @param factor Factor to divide by.
+ * @return The new value.
+ */
+ public int divide(int factor) {
+ return value /= factor;
+ }
+
+ /**
+ * Set the value to the negative of its current value.
+ *
+ * @return The new value.
+ */
+ public int negate() {
+ value = ((int)-value);
+ return value;
+ }
+
+ /**
+ * Set the value to its complement.
+ *
+ * @return The new value.
+ */
+ public int complement() {
+ value = (int)~value;
+ return value;
+ }
+
+ /**
+ * <i>AND</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>and</i> with.
+ * @return The new value.
+ */
+ public int and(int b) {
+ value = (int)(value & b);
+ return value;
+ }
+
+ /**
+ * <i>OR</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>or</i> with.
+ * @return The new value.
+ */
+ public int or(int b) {
+ value = (int)(value | b);
+ return value;
+ }
+
+ /**
+ * <i>XOR</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>xor</i> with.
+ * @return The new value.
+ */
+ public int xor(int b) {
+ value = (int)(value ^ b);
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>right</i>.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public int shiftRight(int bits) {
+ value >>= bits;
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>right</i> with a zero extension.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public int shiftRightZero(int bits) {
+ value >>>= bits;
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>left</i>.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public int shiftLeft(int bits) {
+ value <<= bits;
+ return value;
+ }
+
+ /**
+ * Compares this object with the specified int for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ */
+ public int compareTo(int other) {
+ return (value < other) ? -1 : (value == other) ? 0 : 1;
+ }
+
+ /**
+ * Compares this object with the specified object for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ *
+ * @throws ClassCastException Object is not a MuInteger.
+ */
+ public int compareTo(Object obj) {
+ return compareTo((MuInteger)obj);
+ }
+
+ /**
+ * Convert this mutable integer to a string.
+ *
+ * @return String value
+ */
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Get the hash code for this mutable integer.
+ *
+ * @return Hash code.
+ */
+ public int hashCode() {
+ return value;
+ }
+
+ /**
+ * Test the equality of this mutable integer and another object.
+ *
+ * @param obj Qbject to test equality with.
+ * @return True if object is equal.
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ return value == ((MuInteger)obj).intValue();
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a cloned copy of this mutable integer.
+ *
+ * @return Cloned mutable integer.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Number Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return the <code>byte</code> value of this object.
+ *
+ * @return <code>byte</code> value.
+ */
+ public byte byteValue() {
+ return (byte)value;
+ }
+
+ /**
+ * Return the <code>short</code> value of this object.
+ *
+ * @return <code>short</code> value.
+ */
+ public short shortValue() {
+ return (short)value;
+ }
+
+ /**
+ * Return the <code>int</code> value of this object.
+ *
+ * @return <code>int</code> value.
+ */
+ public int intValue() {
+ return (int)value;
+ }
+
+ /**
+ * Return the <code>long</code> value of this object.
+ *
+ * @return <code>long</code> value.
+ */
+ public long longValue() {
+ return (long)value;
+ }
+
+ /**
+ * Return the <code>float</code> value of this object.
+ *
+ * @return <code>float</code> value.
+ */
+ public float floatValue() {
+ return (float)value;
+ }
+
+ /**
+ * Return the <code>double</code> value of this object.
+ *
+ * @return <code>double</code> value.
+ */
+ public double doubleValue() {
+ return (double)value;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Mutable Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Set the value of this mutable integer.
+ *
+ * @param value Object to convert to an integer value.
+ *
+ * @throws NotCoercibleException Can not convert to <code>int</code>.
+ */
+ public void setValue(Object obj) {
+ if (obj instanceof Number) {
+ value = ((Number)obj).intValue();
+ }
+ else {
+ throw new NotCoercibleException("can not convert to 'int': " + obj);
+ }
+ }
+
+ /**
+ * Get the value of this mutable integer.
+ *
+ * @return <code>java.lang.Integer</code> value.
+ */
+ public Object getValue() {
+ return new Integer(value);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuInteger.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuLong.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuLong.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuLong.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,392 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * A mutable long integer class.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class MuLong
+ extends MuNumber
+{
+ /** Long value */
+ protected long value;
+
+ /**
+ * Construct a new mutable long integer.
+ */
+ public MuLong() {}
+
+ /**
+ * Construct a new mutable long integer.
+ *
+ * @param l <code>long</code> value.
+ */
+ public MuLong(long l) {
+ value = l;
+ }
+
+ /**
+ * Construct a new mutable long integer.
+ *
+ * @param obj Object to convert to a <code>long</code> value.
+ */
+ public MuLong(Object obj) {
+ setValue(obj);
+ }
+
+ /**
+ * Set the value to value only if the current value is equal to
+ * the assumed value.
+ *
+ * @param assumed The assumed value.
+ * @param b The new value.
+ * @return True if value was changed.
+ */
+ public boolean commit(long assumed, long b) {
+ boolean success = (assumed == value);
+ if (success) value = b;
+ return success;
+ }
+
+ /**
+ * Swap values with another mutable long.
+ *
+ * @param b Mutable long to swap values with.
+ * @return The new value.
+ */
+ public long swap(MuLong b) {
+ if (b == this) return value;
+
+ long temp = value;
+ value = b.value;
+ b.value = temp;
+
+ return value;
+ }
+
+ /**
+ * Increment the value of this mutable long.
+ *
+ * @return Long value.
+ */
+ public long increment() {
+ return ++value;
+ }
+
+ /**
+ * Decrement the value of this mutable long.
+ *
+ * @return Long value.
+ */
+ public long decrement() {
+ return --value;
+ }
+
+ /**
+ * Add the specified amount.
+ *
+ * @param amount Amount to add.
+ * @return The new value.
+ */
+ public long add(long amount) {
+ return value += amount;
+ }
+
+ /**
+ * Subtract the specified amount.
+ *
+ * @param amount Amount to subtract.
+ * @return The new value.
+ */
+ public long subtract(long amount) {
+ return value -= amount;
+ }
+
+ /**
+ * Multiply by the specified factor.
+ *
+ * @param factor Factor to multiply by.
+ * @return The new value.
+ */
+ public long multiply(long factor) {
+ return value *= factor;
+ }
+
+ /**
+ * Divide by the specified factor.
+ *
+ * @param factor Factor to divide by.
+ * @return The new value.
+ */
+ public long divide(long factor) {
+ return value /= factor;
+ }
+
+ /**
+ * Set the value to the negative of its current value.
+ *
+ * @return The new value.
+ */
+ public long negate() {
+ value = ((long)-value);
+ return value;
+ }
+
+ /**
+ * Set the value to its complement.
+ *
+ * @return The new value.
+ */
+ public long complement() {
+ value = (long)~value;
+ return value;
+ }
+
+ /**
+ * <i>AND</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>and</i> with.
+ * @return The new value.
+ */
+ public long and(long b) {
+ value = (long)(value & b);
+ return value;
+ }
+
+ /**
+ * <i>OR</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>or</i> with.
+ * @return The new value.
+ */
+ public long or(long b) {
+ value = (long)(value | b);
+ return value;
+ }
+
+ /**
+ * <i>XOR</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>xor</i> with.
+ * @return The new value.
+ */
+ public long xor(long b) {
+ value = (long)(value ^ b);
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>right</i>.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public long shiftRight(int bits) {
+ value >>= bits;
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>right</i> with a zero extension.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public long shiftRightZero(int bits) {
+ value >>>= bits;
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>left</i>.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public long shiftLeft(int bits) {
+ value <<= bits;
+ return value;
+ }
+
+ /**
+ * Compares this object with the specified long for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ */
+ public int compareTo(long other) {
+ return (value < other) ? -1 : (value == other) ? 0 : 1;
+ }
+
+ /**
+ * Compares this object with the specified object for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ *
+ * @throws ClassCastException Object is not a MuLong.
+ */
+ public int compareTo(Object obj) {
+ return compareTo((MuLong)obj);
+ }
+
+ /**
+ * Convert this mutable long integer to a string.
+ *
+ * @return String value.
+ */
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Get the hash code of this mutable long integer.
+ *
+ * @return Hash code.
+ */
+ public int hashCode() {
+ return HashCode.generate(value);
+ }
+
+ /**
+ * Test the equality of this mutable long integer and another object.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal.
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ return value == ((MuLong)obj).longValue();
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a cloned copy of this mutable long.
+ *
+ * @return Cloaned mutable long.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Number Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return the <code>byte</code> value of this object.
+ *
+ * @return <code>byte</code> value.
+ */
+ public byte byteValue() {
+ return (byte)value;
+ }
+
+ /**
+ * Return the <code>short</code> value of this object.
+ *
+ * @return <code>short</code> value.
+ */
+ public short shortValue() {
+ return (short)value;
+ }
+
+ /**
+ * Return the <code>int</code> value of this object.
+ *
+ * @return <code>int</code> value.
+ */
+ public int intValue() {
+ return (int)value;
+ }
+
+ /**
+ * Return the <code>long</code> value of this object.
+ *
+ * @return <code>long</code> value.
+ */
+ public long longValue() {
+ return (long)value;
+ }
+
+ /**
+ * Return the <code>float</code> value of this object.
+ *
+ * @return <code>float</code> value.
+ */
+ public float floatValue() {
+ return (float)value;
+ }
+
+ /**
+ * Return the <code>double</code> value of this object.
+ *
+ * @return <code>double</code> value.
+ */
+ public double doubleValue() {
+ return (double)value;
+ }
+
+ /**
+ * Set the value of this mutable long integer.
+ *
+ * @param value The new value.
+ */
+ public void set(long value)
+ {
+ this.value = value;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Mutable Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Set the value of this mutable long integer.
+ *
+ * @param obj Object to convert to a <code>long</code> value.
+ *
+ * @throws NotCoercibleException Can not convert to <code>long</code>.
+ */
+ public void setValue(Object obj) {
+ if (obj instanceof Number) {
+ value = ((Number)obj).longValue();
+ }
+ else {
+ throw new NotCoercibleException("can not convert to 'long': " + obj);
+ }
+ }
+
+ /**
+ * Return the value of this mutable long integer.
+ *
+ * @return <code>java.lang.Long<code> value.
+ */
+ public Object getValue() {
+ return new Long(value);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuLong.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuNumber.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuNumber.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuNumber.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,67 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * An abstract mutable number class.
+ *
+ * <p>This is a base wrapper class for <code>java.lang.Number</code>.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class MuNumber
+ extends Number
+ implements Comparable, Cloneable, Mutable
+{
+ /**
+ * Returns the value of the specified number as a <code>byte</code>.
+ * This may involve rounding or truncation.
+ *
+ * @return The numeric value represented by this object after conversion
+ * to type <code>byte</code>.
+ */
+ public byte byteValue() {
+ return (byte)longValue();
+ }
+
+ /**
+ * Returns the value of the specified number as a <code>short</code>.
+ * This may involve rounding or truncation.
+ *
+ * @return The numeric value represented by this object after conversion
+ * to type <code>short</code>.
+ */
+ public short shortValue() {
+ return (short)longValue();
+ }
+
+ /**
+ * Returns the value of the specified number as a <code>int</code>.
+ * This may involve rounding or truncation.
+ *
+ * @return The numeric value represented by this object after conversion
+ * to type <code>int</code>.
+ */
+ public int intValue() {
+ return (int)longValue();
+ }
+
+ /**
+ * Returns the value of the specified number as a <code>float</code>.
+ * This may involve rounding or truncation.
+ *
+ * @return The numeric value represented by this object after conversion
+ * to type <code>float</code>.
+ */
+ public float floatValue() {
+ return (float)doubleValue();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuNumber.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuShort.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuShort.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuShort.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,404 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * A mutable short class.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class MuShort
+ extends MuNumber
+{
+ /** Short value */
+ private short value;
+
+ /**
+ * Construct a new mutable short integer.
+ */
+ public MuShort() {}
+
+ /**
+ * Construct a new mutable short integer.
+ *
+ * @param s Short value.
+ */
+ public MuShort(short s) {
+ value = s;
+ }
+
+ /**
+ * Construct a new mutable short integer.
+ *
+ * @param obj Object to convert to a <code>short</code> value.
+ */
+ public MuShort(Object obj) {
+ setValue(obj);
+ }
+
+ /**
+ * Set the value.
+ *
+ * @param s <code>short</code> value.
+ * @return The previous value.
+ */
+ public short set(short s) {
+ short old = value;
+ value = s;
+ return old;
+ }
+
+ /**
+ * Get the current value.
+ *
+ * @return The current value.
+ */
+ public short get() {
+ return value;
+ }
+
+ /**
+ * Set the value to value only if the current value is equal to
+ * the assumed value.
+ *
+ * @param assumed The assumed value.
+ * @param b The new value.
+ * @return True if value was changed.
+ */
+ public boolean commit(short assumed, short b) {
+ boolean success = (assumed == value);
+ if (success) value = b;
+ return success;
+ }
+
+ /**
+ * Swap values with another mutable short.
+ *
+ * @param b Mutable short to swap values with.
+ * @return The new value.
+ */
+ public short swap(MuShort b) {
+ if (b == this) return value;
+
+ short temp = value;
+ value = b.value;
+ b.value = temp;
+
+ return value;
+ }
+
+ /**
+ * Increment the value of this mutable short.
+ *
+ * @return Short value.
+ */
+ public short increment() {
+ return ++value;
+ }
+
+ /**
+ * Decrement the value of this mutable short.
+ *
+ * @return Short value.
+ */
+ public short decrement() {
+ return --value;
+ }
+
+ /**
+ * Add the specified amount.
+ *
+ * @param amount Amount to add.
+ * @return The new value.
+ */
+ public short add(short amount) {
+ return value += amount;
+ }
+
+ /**
+ * Subtract the specified amount.
+ *
+ * @param amount Amount to subtract.
+ * @return The new value.
+ */
+ public short subtract(short amount) {
+ return value -= amount;
+ }
+
+ /**
+ * Multiply by the specified factor.
+ *
+ * @param factor Factor to multiply by.
+ * @return The new value.
+ */
+ public short multiply(short factor) {
+ return value *= factor;
+ }
+
+ /**
+ * Divide by the specified factor.
+ *
+ * @param factor Factor to divide by.
+ * @return The new value.
+ */
+ public short divide(short factor) {
+ return value /= factor;
+ }
+
+ /**
+ * Set the value to the negative of its current value.
+ *
+ * @return The new value.
+ */
+ public short negate() {
+ value = ((short)-value);
+ return value;
+ }
+
+ /**
+ * Set the value to its complement.
+ *
+ * @return The new value.
+ */
+ public short complement() {
+ value = (short)~value;
+ return value;
+ }
+
+ /**
+ * <i>AND</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>and</i> with.
+ * @return The new value.
+ */
+ public short and(short b) {
+ value = (short)(value & b);
+ return value;
+ }
+
+ /**
+ * <i>OR</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>or</i> with.
+ * @return The new value.
+ */
+ public short or(short b) {
+ value = (short)(value | b);
+ return value;
+ }
+
+ /**
+ * <i>XOR</i>s the current value with the specified value.
+ *
+ * @param b Value to <i>xor</i> with.
+ * @return The new value.
+ */
+ public short xor(short b) {
+ value = (short)(value ^ b);
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>right</i>.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public short shiftRight(int bits) {
+ value >>= bits;
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>right</i> with a zero extension.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public short shiftRightZero(int bits) {
+ value >>>= bits;
+ return value;
+ }
+
+ /**
+ * Shift the current value to the <i>left</i>.
+ *
+ * @param bits The number of bits to shift.
+ * @return The new value.
+ */
+ public short shiftLeft(int bits) {
+ value <<= bits;
+ return value;
+ }
+
+ /**
+ * Compares this object with the specified short for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ */
+ public int compareTo(short other) {
+ return (value < other) ? -1 : (value == other) ? 0 : 1;
+ }
+
+ /**
+ * Compares this object with the specified object for order.
+ *
+ * @param other Value to compare with.
+ * @return A negative integer, zero, or a positive integer as
+ * this object is less than, equal to, or greater than
+ * the specified object.
+ *
+ * @throws ClassCastException Object is not a MuShort.
+ */
+ public int compareTo(Object obj) {
+ return compareTo((MuShort)obj);
+ }
+
+ /**
+ * Convert this mutable short integer to a string.
+ *
+ * @return String value.
+ */
+ public String toString() {
+ return String.valueOf(value);
+ }
+
+ /**
+ * Get the hash code for this mutable short integer.
+ *
+ * @return Hash code.
+ */
+ public int hashCode() {
+ return (int)value;
+ }
+
+ /**
+ * Test the equality of this mutable short integer and another object.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal.
+ */
+ public boolean equals(Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ return value == ((MuShort)obj).shortValue();
+ }
+
+ return false;
+ }
+
+ /**
+ * Return a cloned copy of this mutable short.
+ *
+ * @return Cloaned mutable short.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Number Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return the <code>byte</code> value of this object.
+ *
+ * @return <code>byte</code> value.
+ */
+ public byte byteValue() {
+ return (byte)value;
+ }
+
+ /**
+ * Return the <code>short</code> value of this object.
+ *
+ * @return <code>short</code> value.
+ */
+ public short shortValue() {
+ return (short)value;
+ }
+
+ /**
+ * Return the <code>int</code> value of this object.
+ *
+ * @return <code>int</code> value.
+ */
+ public int intValue() {
+ return (int)value;
+ }
+
+ /**
+ * Return the <code>long</code> value of this object.
+ *
+ * @return <code>long</code> value.
+ */
+ public long longValue() {
+ return (long)value;
+ }
+
+ /**
+ * Return the <code>float</code> value of this object.
+ *
+ * @return <code>float</code> value.
+ */
+ public float floatValue() {
+ return (float)value;
+ }
+
+ /**
+ * Return the <code>double</code> value of this object.
+ *
+ * @return <code>double</code> value.
+ */
+ public double doubleValue() {
+ return (double)value;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Mutable Support //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Set the value of this mutable short integer.
+ *
+ * @param obj Object to convert to a <code>short</code> value.
+ *
+ * @throws NotCoercibleException Can not convert to <code>short</code>.
+ */
+ public void setValue(Object obj) {
+ if (obj instanceof Number) {
+ value = ((Number)obj).shortValue();
+ }
+ else {
+ throw new NotCoercibleException("can not convert to 'short': " + obj);
+ }
+ }
+
+ /**
+ * Return the value of this mutable short integer.
+ *
+ * @return <code>java.lang.Short</code> value.
+ */
+ public Object getValue() {
+ return new Short(value);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/MuShort.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Mutable.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Mutable.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Mutable.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,33 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * Mutable object interface.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface Mutable
+{
+ /**
+ * Set the value of a mutable object.
+ *
+ * @param value Target value for object.
+ */
+ void setValue(Object value);
+
+ /**
+ * Get the value of a mutable object.
+ *
+ * @return Object value.
+ */
+ Object getValue();
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Mutable.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedError.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedError.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedError.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,133 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.PrintWriter;
+import java.io.PrintStream;
+
+/**
+ * A common superclass for <tt>Error</tt> classes that can
+ * contain a nested <tt>Throwable</tt> detail object.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class NestedError
+ extends Error
+ implements NestedThrowable
+{
+ /** The nested throwable */
+ protected final Throwable nested;
+
+ /**
+ * Construct a <tt>NestedError</tt> with the specified
+ * detail message.
+ *
+ * @param msg Detail message.
+ */
+ public NestedError(final String msg) {
+ super(msg);
+ this.nested = null;
+ }
+
+ /**
+ * Construct a <tt>NestedError</tt> with the specified
+ * detail message and nested <tt>Throwable</tt>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public NestedError(final String msg, final Throwable nested) {
+ super(msg);
+ this.nested = nested;
+ NestedThrowable.Util.checkNested(this, nested);
+ }
+
+ /**
+ * Construct a <tt>NestedError</tt> with the specified
+ * nested <tt>Throwable</tt>.
+ *
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public NestedError(final Throwable nested) {
+ this(nested.getMessage(), nested);
+ }
+
+ /**
+ * Construct a <tt>NestedError</tt> with no detail.
+ */
+ public NestedError() {
+ super();
+ this.nested = null;
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ public Throwable getNested() {
+ return nested;
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * <p>For JDK 1.4 compatibility.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ public Throwable getCause() {
+ return nested;
+ }
+
+ /**
+ * Returns the composite throwable message.
+ *
+ * @return The composite throwable message.
+ */
+ public String getMessage() {
+ return NestedThrowable.Util.getMessage(super.getMessage(), nested);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print stream.
+ *
+ * @param stream Stream to print to.
+ */
+ public void printStackTrace(final PrintStream stream) {
+ if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
+ super.printStackTrace(stream);
+ }
+ NestedThrowable.Util.print(nested, stream);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print writer.
+ *
+ * @param writer Writer to print to.
+ */
+ public void printStackTrace(final PrintWriter writer) {
+ if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
+ super.printStackTrace(writer);
+ }
+ NestedThrowable.Util.print(nested, writer);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to
+ * <tt>System.err</tt>.
+ */
+ public void printStackTrace() {
+ printStackTrace(System.err);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedError.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,133 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.PrintWriter;
+import java.io.PrintStream;
+
+/**
+ * A common superclass for <tt>Exception</tt> classes that can contain
+ * a nested <tt>Throwable</tt> detail object.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class NestedException
+ extends Exception
+ implements NestedThrowable
+{
+ /** The nested throwable */
+ protected final Throwable nested;
+
+ /**
+ * Construct a <tt>NestedException</tt> with the specified detail
+ * message.
+ *
+ * @param msg Detail message.
+ */
+ public NestedException(final String msg) {
+ super(msg);
+ this.nested = null;
+ }
+
+ /**
+ * Construct a <tt>NestedException</tt> with the specified detail
+ * message and nested <tt>Throwable</tt>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public NestedException(final String msg, final Throwable nested) {
+ super(msg);
+ this.nested = nested;
+ NestedThrowable.Util.checkNested(this, nested);
+ }
+
+ /**
+ * Construct a <tt>NestedException</tt> with the specified
+ * nested <tt>Throwable</tt>.
+ *
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public NestedException(final Throwable nested) {
+ this(nested.getMessage(), nested);
+ }
+
+ /**
+ * Construct a <tt>NestedException</tt> with no detail.
+ */
+ public NestedException() {
+ super();
+ this.nested = null;
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ public Throwable getNested() {
+ return nested;
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * <p>For JDK 1.4 compatibility.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ public Throwable getCause() {
+ return nested;
+ }
+
+ /**
+ * Returns the composite throwable message.
+ *
+ * @return The composite throwable message.
+ */
+ public String getMessage() {
+ return NestedThrowable.Util.getMessage(super.getMessage(), nested);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print stream.
+ *
+ * @param stream Stream to print to.
+ */
+ public void printStackTrace(final PrintStream stream) {
+ if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
+ super.printStackTrace(stream);
+ }
+ NestedThrowable.Util.print(nested, stream);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print writer.
+ *
+ * @param writer Writer to print to.
+ */
+ public void printStackTrace(final PrintWriter writer) {
+ if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
+ super.printStackTrace(writer);
+ }
+ NestedThrowable.Util.print(nested, writer);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to
+ * <tt>System.err</tt>.
+ */
+ public void printStackTrace() {
+ printStackTrace(System.err);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedRuntimeException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedRuntimeException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedRuntimeException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,133 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.PrintWriter;
+import java.io.PrintStream;
+
+/**
+ * A common superclass for <tt>RuntimeException</tt> classes that can
+ * contain a nested <tt>Throwable</tt> detail object.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class NestedRuntimeException
+ extends RuntimeException
+ implements NestedThrowable
+{
+ /** The nested throwable */
+ protected final Throwable nested;
+
+ /**
+ * Construct a <tt>NestedRuntimeException</tt> with the specified
+ * detail message.
+ *
+ * @param msg Detail message.
+ */
+ public NestedRuntimeException(final String msg) {
+ super(msg);
+ this.nested = null;
+ }
+
+ /**
+ * Construct a <tt>NestedRuntimeException</tt> with the specified
+ * detail message and nested <tt>Throwable</tt>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public NestedRuntimeException(final String msg, final Throwable nested) {
+ super(msg);
+ this.nested = nested;
+ NestedThrowable.Util.checkNested(this, nested);
+ }
+
+ /**
+ * Construct a <tt>NestedRuntimeException</tt> with the specified
+ * nested <tt>Throwable</tt>.
+ *
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public NestedRuntimeException(final Throwable nested) {
+ this(nested.getMessage(), nested);
+ }
+
+ /**
+ * Construct a <tt>NestedRuntimeException</tt> with no detail.
+ */
+ public NestedRuntimeException() {
+ super();
+ this.nested = null;
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ public Throwable getNested() {
+ return nested;
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * <p>For JDK 1.4 compatibility.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ public Throwable getCause() {
+ return nested;
+ }
+
+ /**
+ * Returns the composite throwable message.
+ *
+ * @return The composite throwable message.
+ */
+ public String getMessage() {
+ return NestedThrowable.Util.getMessage(super.getMessage(), nested);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print stream.
+ *
+ * @param stream Stream to print to.
+ */
+ public void printStackTrace(final PrintStream stream) {
+ if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
+ super.printStackTrace(stream);
+ }
+ NestedThrowable.Util.print(nested, stream);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print writer.
+ *
+ * @param writer Writer to print to.
+ */
+ public void printStackTrace(final PrintWriter writer) {
+ if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
+ super.printStackTrace(writer);
+ }
+ NestedThrowable.Util.print(nested, writer);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to
+ * <tt>System.err</tt>.
+ */
+ public void printStackTrace() {
+ printStackTrace(System.err);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedRuntimeException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedSQLException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedSQLException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedSQLException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,150 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.PrintWriter;
+import java.io.PrintStream;
+
+import java.sql.SQLException;
+
+/**
+ * A common superclass for <tt>SQLException</tt> classes that can contain
+ * a nested <tt>Throwable</tt> detail object.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class NestedSQLException
+ extends SQLException
+ implements NestedThrowable
+{
+ /** The nested throwable */
+ protected final Throwable nested;
+
+ /**
+ * Construct a <tt>NestedSQLException</tt> with the specified detail
+ * message.
+ *
+ * @param msg Detail message.
+ */
+ public NestedSQLException(final String msg) {
+ super(msg);
+ this.nested = null;
+ }
+
+ /**
+ * Construct a <tt>NestedSQLException</tt> with the specified detail
+ * message and nested <tt>Throwable</tt>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public NestedSQLException(final String msg, final Throwable nested) {
+ super(msg);
+ this.nested = nested;
+ NestedThrowable.Util.checkNested(this, nested);
+ }
+
+ /**
+ * Construct a <tt>NestedSQLException</tt> with the specified
+ * nested <tt>Throwable</tt>.
+ *
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public NestedSQLException(final Throwable nested) {
+ this(nested.getMessage(), nested);
+ }
+
+ /**
+ * Construct a <tt>NestedSQLException</tt>.
+ *
+ * @param msg Detail message.
+ * @param state SQL state message.
+ */
+ public NestedSQLException(final String msg, final String state) {
+ super(msg, state);
+ this.nested = null;
+ }
+
+ /**
+ * Construct a <tt>NestedSQLException</tt>.
+ *
+ * @param msg Detail message.
+ * @param state SQL state message.
+ * @param code SQL vendor code.
+ */
+ public NestedSQLException(final String msg, final String state, final int code) {
+ super(msg, state, code);
+ this.nested = null;
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ public Throwable getNested() {
+ return nested;
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * <p>For JDK 1.4 compatibility.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ public Throwable getCause() {
+ return nested;
+ }
+
+ /**
+ * Returns the composite throwable message.
+ *
+ * @return The composite throwable message.
+ */
+ public String getMessage() {
+ return NestedThrowable.Util.getMessage(super.getMessage(), nested);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print stream.
+ *
+ * @param stream Stream to print to.
+ */
+ public void printStackTrace(final PrintStream stream) {
+ if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
+ super.printStackTrace(stream);
+ }
+ NestedThrowable.Util.print(nested, stream);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print writer.
+ *
+ * @param writer Writer to print to.
+ */
+ public void printStackTrace(final PrintWriter writer) {
+ if (nested == null || NestedThrowable.PARENT_TRACE_ENABLED) {
+ super.printStackTrace(writer);
+ }
+ NestedThrowable.Util.print(nested, writer);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to
+ * <tt>System.err</tt>.
+ */
+ public void printStackTrace() {
+ printStackTrace(System.err);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedSQLException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedThrowable.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedThrowable.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedThrowable.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,233 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.PrintWriter;
+import java.io.PrintStream;
+import java.io.Serializable;
+
+import org.jboss.logging.Logger;
+
+import org.jboss.util.platform.Java;
+
+
+/**
+ * Interface which is implemented by all the nested throwable flavors.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface NestedThrowable
+ extends Serializable
+{
+ /**
+ * A system wide flag to enable or disable printing of the
+ * parent throwable traces.
+ *
+ * <p>
+ * This value is set from the system property
+ * <tt>org.jboss.util.NestedThrowable.parentTraceEnabled</tt>
+ * or if that is not set defaults to <tt>true</tt>.
+ */
+ boolean PARENT_TRACE_ENABLED = Util.getBoolean("parentTraceEnabled", true);
+
+ /**
+ * A system wide flag to enable or disable printing of the
+ * nested detail throwable traces.
+ *
+ * <p>
+ * This value is set from the system property
+ * <tt>org.jboss.util.NestedThrowable.nestedTraceEnabled</tt>
+ * or if that is not set defaults to <tt>true</tt> unless
+ * using JDK 1.4 with {@link #PARENT_TRACE_ENABLED} set to false,
+ * then <tt>false</tt> since there is a native mechansim for this there.
+ *
+ * <p>
+ * Note then when running under 1.4 is is not possible to disable
+ * the nested trace output, since that is handled by java.lang.Throwable
+ * which we delegate the parent printing to.
+ */
+ boolean NESTED_TRACE_ENABLED = Util.getBoolean("nestedTraceEnabled",
+ (Java.isCompatible(Java.VERSION_1_4) &&
+ !PARENT_TRACE_ENABLED) ||
+ !Java.isCompatible(Java.VERSION_1_4));
+
+ /**
+ * A system wide flag to enable or disable checking of parent and child
+ * types to detect uneeded nesting
+ *
+ * <p>
+ * This value is set from the system property
+ * <tt>org.jboss.util.NestedThrowable.detectDuplicateNesting</tt>
+ * or if that is not set defaults to <tt>true</tt>.
+ */
+ boolean DETECT_DUPLICATE_NESTING = Util.getBoolean("detectDuplicateNesting", true);
+
+ /**
+ * Return the nested throwable.
+ *
+ * @return Nested throwable.
+ */
+ Throwable getNested();
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * <p>For JDK 1.4 compatibility.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ Throwable getCause();
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Nested Throwable Utilities //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Utilitiy methods for the various flavors of
+ * <code>NestedThrowable</code>.
+ */
+ final class Util
+ {
+ // Can not be final due to init bug, see getLogger() for details
+ private static Logger log = Logger.getLogger(NestedThrowable.class);
+
+ /**
+ * Something is very broken with class nesting, which can sometimes
+ * leave log uninitialized durring one of the following method calls.
+ *
+ * <p>
+ * This is a HACK to keep those methods from NPE until this problem
+ * can be resolved.
+ */
+ private static Logger getLogger()
+ {
+ if (log == null)
+ log = Logger.getLogger(NestedThrowable.class);
+
+ return log;
+ }
+
+ /** A helper to get a boolean property. */
+ protected static boolean getBoolean(String name, boolean defaultValue)
+ {
+ name = NestedThrowable.class.getName() + "." + name;
+ String value = System.getProperty(name, String.valueOf(defaultValue));
+
+ // HACK see getLogger() for details
+ log = getLogger();
+
+ log.debug(name + "=" + value);
+
+ return new Boolean(value).booleanValue();
+ }
+
+ /**
+ * Check and possibly warn if the nested exception type is the same
+ * as the parent type (duplicate nesting).
+ */
+ public static void checkNested(final NestedThrowable parent,
+ final Throwable child)
+ {
+ if (!DETECT_DUPLICATE_NESTING || parent == null || child == null) return;
+
+ Class parentType = parent.getClass();
+ Class childType = child.getClass();
+
+ //
+ // This might be backwards... I always get this confused
+ //
+
+ if (parentType.isAssignableFrom(childType)) {
+ // HACK see getLogger() for details
+ log = getLogger();
+
+ log.warn("Duplicate throwable nesting of same base type: " +
+ parentType + " is assignable from: " + childType);
+ }
+ }
+
+ /**
+ * Returns a formated message for the given detail message
+ * and nested <code>Throwable</code>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <code>Throwable</code>.
+ * @return Formatted message.
+ */
+ public static String getMessage(final String msg,
+ final Throwable nested)
+ {
+ StringBuffer buff = new StringBuffer(msg == null ? "" : msg);
+
+ if (nested != null) {
+ buff.append(msg == null ? "- " : "; - ")
+ .append("nested throwable: (")
+ .append(nested)
+ .append(")");
+ }
+
+ return buff.toString();
+ }
+
+ /**
+ * Prints the nested <code>Throwable</code> to the given stream.
+ *
+ * @param nested Nested <code>Throwable</code>.
+ * @param stream Stream to print to.
+ */
+ public static void print(final Throwable nested,
+ final PrintStream stream)
+ {
+ if (stream == null)
+ throw new NullArgumentException("stream");
+
+ if (NestedThrowable.NESTED_TRACE_ENABLED && nested != null) {
+ synchronized (stream) {
+ if (NestedThrowable.PARENT_TRACE_ENABLED) {
+ stream.print(" + nested throwable: ");
+ }
+ else {
+ stream.print("[ parent trace omitted ]: ");
+ }
+
+ nested.printStackTrace(stream);
+ }
+ }
+ }
+
+ /**
+ * Prints the nested <code>Throwable</code> to the given writer.
+ *
+ * @param nested Nested <code>Throwable</code>.
+ * @param writer Writer to print to.
+ */
+ public static void print(final Throwable nested,
+ final PrintWriter writer)
+ {
+ if (writer == null)
+ throw new NullArgumentException("writer");
+
+ if (NestedThrowable.NESTED_TRACE_ENABLED && nested != null) {
+ synchronized (writer) {
+ if (NestedThrowable.PARENT_TRACE_ENABLED) {
+ writer.print(" + nested throwable: ");
+ }
+ else {
+ writer.print("[ parent trace omitted ]: ");
+ }
+
+ nested.printStackTrace(writer);
+ }
+ }
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NestedThrowable.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NoSuchMethodException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NoSuchMethodException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NoSuchMethodException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,81 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.lang.reflect.Method;
+
+/**
+ * A better NoSuchMethodException which can take a Method object
+ * and formats the detail message based on in.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class NoSuchMethodException
+ extends java.lang.NoSuchMethodException
+{
+ /**
+ * Construct a <tt>NoSuchMethodException</tt> with the specified detail
+ * message.
+ *
+ * @param msg Detail message.
+ */
+ public NoSuchMethodException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>NoSuchMethodException</tt> using the given method
+ * object to construct the detail message.
+ *
+ * @param method Method to determine detail message from.
+ */
+ public NoSuchMethodException(Method method) {
+ super(format(method));
+ }
+
+ /**
+ * Construct a <tt>NoSuchMethodException</tt> using the given method
+ * object to construct the detail message.
+ *
+ * @param msg Detail message prefix.
+ * @param method Method to determine detail message suffix from.
+ */
+ public NoSuchMethodException(String msg, Method method) {
+ super(msg + format(method));
+ }
+
+ /**
+ * Construct a <tt>NoSuchMethodException</tt> with no detail.
+ */
+ public NoSuchMethodException() {
+ super();
+ }
+
+ /**
+ * Return a string representation of the given method object.
+ */
+ public static String format(Method method)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(method.getName()).append("(");
+ Class[] paramTypes = method.getParameterTypes();
+ for (int count = 0; count < paramTypes.length; count++) {
+ if (count > 0) {
+ buffer.append(",");
+ }
+ buffer.
+ append(paramTypes[count].getName().substring(paramTypes[count].getName().lastIndexOf(".")+1));
+ }
+ buffer.append(")");
+
+ return buffer.toString();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NoSuchMethodException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NotCoercibleException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NotCoercibleException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NotCoercibleException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,67 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * This exception is thrown to indicate that an object was not coercible.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class NotCoercibleException
+ extends CoercionException
+{
+ /**
+ * Construct a <tt>NotCoercibleException</tt> with the specified detail
+ * message.
+ *
+ * @param msg Detail message.
+ */
+ public NotCoercibleException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>NotCoercibleException</tt> with the specified detail
+ * message and nested <tt>Throwable</tt>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public NotCoercibleException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Construct a <tt>NotCoercibleException</tt> with the specified
+ * nested <tt>Throwable</tt>.
+ *
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public NotCoercibleException(Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Construct a <tt>NotCoercibleException</tt> with no detail.
+ */
+ public NotCoercibleException() {
+ super();
+ }
+
+ /**
+ * Construct a <tt>NotCoercibleException</tt> with an object detail.
+ *
+ * @param obj Object detail.
+ */
+ public NotCoercibleException(Object obj) {
+ super(String.valueOf(obj));
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NotCoercibleException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NotImplementedException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NotImplementedException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NotImplementedException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,38 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * Thrown to indicate that a method has not been implemented yet.
+ *
+ * <p>This exception is used to help stub out implementations.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class NotImplementedException
+ extends RuntimeException
+{
+ /**
+ * Construct a <tt>NotImplementedException</tt> with a detail message.
+ *
+ * @param msg Detail message.
+ */
+ public NotImplementedException(final String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>NotImplementedException</tt> with no detail.
+ */
+ public NotImplementedException() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NotImplementedException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Null.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Null.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Null.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,63 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.Serializable;
+
+/**
+ * A class that represents <tt>null</tt>.
+ *
+ * <p>{@link Null#VALUE} is used to given an object variable a dual-mode
+ * nullified value, where <tt>null</tt> would indicate that the value is
+ * empty, and {@link Null#VALUE} would idicate that the value has been
+ * set to <tt>null</tt> (or something to that effect).
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class Null
+ implements Serializable
+{
+ /** The primary instance of Null. */
+ public static final Null VALUE = new Null();
+
+ /** Do not allow public construction. */
+ private Null() {}
+
+ /**
+ * Return a string representation.
+ *
+ * @return Null
+ */
+ public String toString() {
+ return null;
+ }
+
+ /**
+ * Returns zero.
+ *
+ * @return Zero.
+ */
+ public int hashCode() {
+ return 0;
+ }
+
+ /**
+ * Check if the given object is a Null instance or <tt>null</tt>.
+ *
+ * @param obj Object to test.
+ * @return True if the given object is a Null instance or <tt>null</tt>.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+ return (obj == null || obj.getClass() == getClass());
+ }
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Null.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NullArgumentException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NullArgumentException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NullArgumentException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,105 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * Thrown to indicate that a method argument was <tt>null</tt> and
+ * should <b>not</b> have been.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class NullArgumentException
+ extends IllegalArgumentException
+{
+ /** The name of the argument that was <tt>null</tt>. */
+ protected final String name;
+
+ /** The index of the argument or null if no index. */
+ protected final Object index;
+
+ /**
+ * Construct a <tt>NullArgumentException</tt>.
+ *
+ * @param name Argument name.
+ */
+ public NullArgumentException(final String name) {
+ super(makeMessage(name));
+
+ this.name = name;
+ this.index = null;
+ }
+
+ /**
+ * Construct a <tt>NullArgumentException</tt>.
+ *
+ * @param name Argument name.
+ * @param index Argument index.
+ */
+ public NullArgumentException(final String name, final long index) {
+ super(makeMessage(name, new Long(index)));
+
+ this.name = name;
+ this.index = new Long(index);
+ }
+
+ /**
+ * Construct a <tt>NullArgumentException</tt>.
+ *
+ * @param name Argument name.
+ * @param index Argument index.
+ */
+ public NullArgumentException(final String name, final Object index) {
+ super(makeMessage(name, index));
+
+ this.name = name;
+ this.index = index;
+ }
+
+ /**
+ * Construct a <tt>NullArgumentException</tt>.
+ */
+ public NullArgumentException() {
+ this.name = null;
+ this.index = null;
+ }
+
+ /**
+ * Get the argument name that was <tt>null</tt>.
+ *
+ * @return The argument name that was <tt>null</tt>.
+ */
+ public final String getArgumentName() {
+ return name;
+ }
+
+ /**
+ * Get the argument index.
+ *
+ * @return The argument index.
+ */
+ public final Object getArgumentIndex() {
+ return index;
+ }
+
+ /**
+ * Make a execption message for the argument name.
+ */
+ private static String makeMessage(final String name) {
+ return "'" + name + "' is null";
+ }
+
+ /**
+ * Make a execption message for the argument name and index
+ */
+ private static String makeMessage(final String name, final Object index) {
+ return "'" + name + "[" + index + "]' is null";
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/NullArgumentException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Objects.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Objects.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Objects.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,346 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Array;
+
+import java.lang.ref.Reference;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.Serializable;
+
+import org.jboss.util.coerce.CoercionHandler;
+import org.jboss.util.stream.Streams;
+
+/**
+ * A collection of <code>Object</code> utilities.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class Objects
+{
+ /////////////////////////////////////////////////////////////////////////
+ // Coercion Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Get a compatible constructor for the given value type
+ *
+ * @param type Class to look for constructor in
+ * @param valueType Argument type for constructor
+ * @return Constructor or null
+ */
+ public static Constructor getCompatibleConstructor(final Class type,
+ final Class valueType)
+ {
+ // first try and find a constructor with the exact argument type
+ try {
+ return type.getConstructor(new Class[] { valueType });
+ }
+ catch (Exception ignore) {
+ // if the above failed, then try and find a constructor with
+ // an compatible argument type
+
+ // get an array of compatible types
+ Class[] types = type.getClasses();
+
+ for (int i=0; i<types.length; i++) {
+ try {
+ return type.getConstructor(new Class[] { types[i] });
+ }
+ catch (Exception ignore2) {}
+ }
+ }
+
+ // if we get this far, then we can't find a compatible constructor
+ return null;
+ }
+
+ /**
+ * Coerce the given value into the specified type.
+ *
+ * @param value Value to coerce.
+ * @param type Class type to coerce to.
+ * @return Coerced object.
+ *
+ * <p>Primative classes will be translated into their respective
+ * wrapper class as needed.
+ *
+ * @exception NotCoercibleException Value is not corecible.
+ * @exception CoercionException Failed to coerce.
+ */
+ public static Object coerce(final Object value, final Class type)
+ throws CoercionException
+ {
+ // get the class for the given value
+ Class valueType = value.getClass();
+
+ // if value typeis assignable (aka castable) from type then return value
+ if (type.isAssignableFrom(valueType)) {
+ return value;
+ }
+
+ // if the object is Coercible, then let it do the work
+ if (value instanceof Coercible) {
+ return ((Coercible)value).coerce(type);
+ }
+
+ // find a handler that can take a type object, let it decide if it
+ // can actually coerce the correct object from value
+ if (CoercionHandler.isInstalled(type)) {
+ CoercionHandler handler = CoercionHandler.create(type);
+ return handler.coerce(value, type);
+ }
+
+ // see if type has a construct that takes a value object
+ //
+ // NOTE: Just because the target type has a compatible constructor
+ // does not nessicarily mean that by creating that object
+ // with the source value will be the proper coercion.
+ //
+ Constructor c = getCompatibleConstructor(type, valueType);
+ if (c != null) {
+ try {
+ return c.newInstance(new Object[] { value });
+ }
+ catch (InvocationTargetException e) {
+ // include the target exception as detail
+ Throwable t = e.getTargetException();
+ if (t instanceof CoercionException)
+ throw (CoercionException)t;
+ throw new CoercionException(t);
+ }
+ catch (Exception e) {
+ if (e instanceof CoercionException)
+ throw (CoercionException)e;
+ throw new CoercionException(e);
+ }
+ }
+
+ // if type is a primitive, then get its wrapper, and recurse
+ if (type.isPrimitive()) {
+ return coerce(value, Classes.getPrimitiveWrapper(type));
+ }
+
+ // if the object was not coerced by now, throw an exception
+ throw new NotCoercibleException(value);
+ }
+
+ /**
+ * Coerce the given values into the specified type.
+ *
+ * <p>If type is an array, then an array of that type is returned
+ * else the first element from values is used.
+ *
+ * <p>Coerce will handle primative array types correctly by using
+ * the reflection mechanism to unwrap primative values from their
+ * wrapper classes.
+ *
+ * @param values Values to coerce.
+ * @param type Class type to coerce object to.
+ * @return Coerced object.
+ *
+ * @exception NotCoercibleException Value is not corecible.
+ * @exception CoercionException Failed to coerce.
+ * @exception IllegalArgumentException Indexed value is <i>null</i>
+ * (values contains a null element).
+ */
+ public static Object coerce(Object values[], Class type)
+ throws CoercionException
+ {
+ // if the desired type is not an array, the use the first element
+ // from the values list
+ if (! type.isArray())
+ return coerce(values[0], type);
+
+ // create a new array that can hold objects of the desired type
+ type = type.getComponentType();
+ Object array = Array.newInstance(type, values.length);
+
+ // coerce each element in the values array into the new array
+ for (int i=0; i<values.length; i++) {
+ // complain if any items in the list are null
+ if (values[i] == null)
+ throw new IllegalArgumentException("values[" + i + "] is null");
+
+ // attempt to coerce the value to the specified type
+ Object coerced = coerce(values[i], type);
+
+ // will unwrap any classes to primatives as needed
+ Array.set(array, i, coerced);
+ }
+
+ return array;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Cloning Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Copy an serializable object deeply.
+ *
+ * @param obj Object to copy.
+ * @return Copied object.
+ *
+ * @throws IOException
+ * @throws ClassCastException
+ */
+ public static Object copy(final Serializable obj)
+ throws IOException, ClassNotFoundException
+ {
+ ObjectOutputStream out = null;
+ ObjectInputStream in = null;
+ Object copy = null;
+
+ try {
+ // write the object
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ out = new ObjectOutputStream(baos);
+ out.writeObject(obj);
+ out.flush();
+
+ // read in the copy
+ byte data[] = baos.toByteArray();
+ ByteArrayInputStream bais = new ByteArrayInputStream(data);
+ in = new ObjectInputStream(bais);
+ copy = in.readObject();
+ }
+ finally {
+ Streams.close(out);
+ Streams.close(in);
+ }
+
+ return copy;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Misc Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Dereference the given object if it is <i>non-null</i> and is an
+ * instance of <code>Reference</code>. If the object is <i>null</i>
+ * then <i>null</i> is returned. If the object is not an instance of
+ * <code>Reference</code>, then the object is returned.
+ *
+ * @param obj Object to dereference.
+ * @return Dereferenced object.
+ */
+ public static Object deref(final Object obj) {
+ if (obj != null && obj instanceof Reference) {
+ Reference ref = (Reference)obj;
+ return ref.get();
+ }
+
+ return obj;
+ }
+
+ /**
+ * Check if the given object is an array (primitve or native).
+ *
+ * @param obj Object to test.
+ * @return True of the object is an array.
+ */
+ public static boolean isArray(final Object obj) {
+ if (obj != null)
+ return obj.getClass().isArray();
+ return false;
+ }
+
+ /**
+ * Return an Object array for the given object.
+ *
+ * @param obj Object to convert to an array. Converts primitive
+ * arrays to Object arrays consisting of their wrapper
+ * classes. If the object is not an array (object or primitve)
+ * then a new array of the given type is created and the
+ * object is set as the sole element.
+ */
+ public static Object[] toArray(final Object obj) {
+ // if the object is an array, the cast and return it.
+ if (obj instanceof Object[]) {
+ return (Object[])obj;
+ }
+
+ // if the object is an array of primitives then wrap the array
+ Class type = obj.getClass();
+ Object array;
+ if (type.isArray()) {
+ int length = Array.getLength(obj);
+ Class componentType = type.getComponentType();
+ array = Array.newInstance(componentType, length);
+ for (int i=0; i<length; i++) {
+ Array.set(array, i, Array.get(obj, i));
+ }
+ }
+ else {
+ array = Array.newInstance(type, 1);
+ Array.set(array, 0, obj);
+ }
+
+ return (Object[])array;
+ }
+
+ /**
+ * Test the equality of two object arrays.
+ *
+ * @param a The first array.
+ * @param b The second array.
+ * @param deep True to traverse elements which are arrays.
+ * @return True if arrays are equal.
+ */
+ public static boolean equals(final Object[] a, final Object[] b,
+ final boolean deep)
+ {
+ if (a == b) return true;
+ if (a == null || b == null) return false;
+ if (a.length != b.length) return false;
+
+ for (int i=0; i<a.length; i++) {
+ Object x = a[i];
+ Object y = b[i];
+
+ if (x != y) return false;
+ if (x == null || y == null) return false;
+ if (deep) {
+ if (x instanceof Object[] && y instanceof Object[]) {
+ if (! equals((Object[])x, (Object[])y, true)) return false;
+ }
+ else {
+ return false;
+ }
+ }
+ if (! x.equals(y)) return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Test the equality of two object arrays.
+ *
+ * @param a The first array.
+ * @param b The second array.
+ * @return True if arrays are equal.
+ */
+ public static boolean equals(final Object[] a, final Object[] b) {
+ return equals(a, b, true);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Objects.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/PrettyString.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/PrettyString.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/PrettyString.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,43 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * A simple interface for objects that can return pretty (ie.
+ * prefixed) string representations of themselves.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface PrettyString
+{
+ /**
+ * Returns a pretty representation of the object.
+ *
+ * @param prefix The string which all lines of the output must be prefixed with.
+ * @return A pretty representation of the object.
+ */
+ String toPrettyString(String prefix);
+
+ /**
+ * Interface for appending the objects pretty string onto a buffer.
+ */
+ interface Appendable
+ {
+ /**
+ * Appends a pretty representation of the object to the given buffer.
+ *
+ * @param buff The buffer to use while making pretty.
+ * @param prefix The string which all lines of the output must be prefixed with.
+ * @return The buffer.
+ */
+ StringBuffer appendPrettyString(StringBuffer buff, String prefix);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/PrettyString.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Primitives.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Primitives.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Primitives.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,120 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * Primitive utilities.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class Primitives
+{
+ /**
+ * Test the equality of two doubles by converting their values into
+ * IEEE 754 floating-point "double format" long values.
+ *
+ * @param a Double to check equality with.
+ * @param b Double to check equality with.
+ * @return True if a equals b.
+ */
+ public static boolean equals(final double a, final double b) {
+ return Double.doubleToLongBits(a) == Double.doubleToLongBits(b);
+ }
+
+ /**
+ * Test the equality of two doubles by converting their values into
+ * IEEE 754 floating-point "single precision" bit layouts.
+ *
+ * @param a Float to check equality with.
+ * @param b Float to check equality with.
+ * @return True if a equals b.
+ */
+ public static boolean equals(final float a, final float b) {
+ return Float.floatToIntBits(a) == Float.floatToIntBits(b);
+ }
+
+ /**
+ * Test the equality of a given sub-section of two byte arrays.
+ *
+ * @param a The first byte array.
+ * @param abegin The begining index of the first byte array.
+ * @param b The second byte array.
+ * @param bbegin The begining index of the second byte array.
+ * @param length The length of the sub-section.
+ * @return True if sub-sections are equal.
+ */
+ public static boolean equals(final byte a[], final int abegin,
+ final byte b[], final int bbegin,
+ final int length)
+ {
+ try {
+ int i=length;
+ while (--i >= 0) {
+ if (a[abegin + i] != b[bbegin + i]) {
+ return false;
+ }
+ }
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Test the equality of two byte arrays.
+ *
+ * @param a The first byte array.
+ * @param b The second byte array.
+ * @return True if the byte arrays are equal.
+ */
+ public static boolean equals(final byte a[], final byte b[]) {
+ if (a == b) return true;
+ if (a == null || b == null) return false;
+ if (a.length != b.length) return false;
+
+ try {
+ for (int i=0; i<a.length; i++) {
+ if (a[i] != b[i]) {
+ return false;
+ }
+ }
+ }
+ catch (ArrayIndexOutOfBoundsException e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Safely convert a <tt>long</tt> into a <tt>int</tt> value.
+ *
+ * <p>If value is > Integer.MAX_VALUE or < Integer.MIN_VALUE
+ * then an exception will be thrown, else the value is cast
+ * down to an <tt>int</tt>.
+ *
+ * @param value The <tt>long</tt> value to convert.
+ * @return The converted value.
+ *
+ * @throws DataConversionException Could not safely convert the value.
+ */
+ public static int toInt(final long value)
+ throws DataConversionException
+ {
+ if (value > Integer.MAX_VALUE || value < Integer.MIN_VALUE)
+ throw new DataConversionException
+ ("can not safly convert to int: " + value);
+
+ return (int)value;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Primitives.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Semaphore.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Semaphore.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Semaphore.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,224 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.io.StringWriter;
+import java.io.PrintWriter;
+
+/**
+ * Semaphore that can allow a specified number of threads to enter, blocking the
+ * others. If the specified number of threads is 1, it acts as an exclusive semaphore
+ * and can be used instead of synchronized blocks
+ *
+ * @author <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
+ * @version $Revision$
+ */
+public class Semaphore
+ implements Sync
+{
+ // Constants -----------------------------------------------------
+ private static final long DEADLOCK_TIMEOUT = 5*60*1000;
+
+ // Attributes ----------------------------------------------------
+ private final static boolean m_debug = false;
+ private int m_users;
+ private int m_allowed;
+ private Map m_logMap;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ public Semaphore(int allowed)
+ {
+ if (allowed < 1) throw new IllegalArgumentException();
+
+ m_users = 0;
+ m_allowed = allowed;
+ m_logMap = new HashMap();
+ }
+
+ // Public --------------------------------------------------------
+ public int getUsers()
+ {
+ synchronized (this)
+ {
+ return m_users;
+ }
+ }
+
+ // Sync implementation ----------------------------------------------
+ public void acquire() throws InterruptedException
+ {
+ synchronized (this)
+ {
+ logAcquire();
+
+ // One user more called acquire, increase users
+ ++m_users;
+ boolean waitSuccessful = false;
+ while (m_allowed <= 0)
+ {
+ waitSuccessful = waitImpl(this);
+ if (!waitSuccessful)
+ {
+ // Dealock was detected, restore status, 'cause it's like a release()
+ // that will probably be never called
+ --m_users;
+ ++m_allowed;
+ }
+ }
+ --m_allowed;
+ }
+ }
+
+ public void release()
+ {
+ synchronized (this)
+ {
+ logRelease();
+
+ --m_users;
+ ++m_allowed;
+ notify();
+ }
+ }
+
+ // Object overrides ---------------------------------------------------
+ public String toString()
+ {
+ return super.toString() + " - " + m_users;
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+ protected boolean waitImpl(Object lock) throws InterruptedException
+ {
+ // Wait (forever) until notified. To discover deadlocks,
+ // turn on debugging of this class
+ long start = System.currentTimeMillis();
+ lock.wait(DEADLOCK_TIMEOUT);
+ long end = System.currentTimeMillis();
+
+ if ((end - start) > (DEADLOCK_TIMEOUT - 1000))
+ {
+ logDeadlock();
+ return false;
+ }
+ return true;
+ }
+
+ protected void logAcquire()
+ {
+ if (m_debug)
+ {
+ // Check if thread is already mapped
+ Thread thread = Thread.currentThread();
+
+ // Create stack trace
+ StringWriter sw = new StringWriter();
+ new Exception().printStackTrace(new PrintWriter(sw));
+ String trace = sw.toString();
+
+ LinkedList list = (LinkedList)m_logMap.get(thread);
+ if (list != null)
+ {
+ // Thread is mapped
+ // Add info
+ Info prevInfo = (Info)list.getLast();
+ Info info = new Info(thread, m_users, trace);
+ list.add(info);
+ }
+ else
+ {
+ // Thread is not mapped, create list and add counter
+ list = new LinkedList();
+ Info info = new Info(thread, m_users, trace);
+ list.add(info);
+ // Map thread
+ m_logMap.put(thread, list);
+ }
+ }
+ }
+ protected void logDeadlock()
+ {
+ System.err.println();
+ System.err.println("DEADLOCK ON SEMAPHORE " + this);
+ if (m_debug)
+ {
+ for (Iterator i = m_logMap.values().iterator(); i.hasNext();)
+ {
+ LinkedList list = (LinkedList)i.next();
+ for (Iterator iter = list.iterator(); iter.hasNext();)
+ {
+ System.err.println(iter.next());
+ }
+ }
+ }
+ System.err.println();
+ }
+ protected void logRelease()
+ {
+ if (m_debug)
+ {
+ // Find a matching thread and remove info for it
+ Thread thread = Thread.currentThread();
+
+ LinkedList list = (LinkedList)m_logMap.get(thread);
+ if (list != null)
+ {
+ Info info = new Info(thread, 0, "");
+ if (!list.remove(info))
+ {
+ System.err.println("LOG INFO SIZE: " + list);
+ new IllegalStateException("BUG: semaphore log list does not contain required info").printStackTrace();
+ }
+
+ // If no info left, remove the mapping
+ int size = list.size();
+ if (size < 1)
+ {
+ m_logMap.remove(thread);
+ }
+ }
+ else
+ {
+ throw new IllegalStateException("Semaphore log failed: release called without acquire");
+ }
+ }
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+ private class Info
+ {
+ private Info(Thread t, int i, String s)
+ {
+ m_thread = t;
+ m_counter = i;
+ m_trace = s;
+ }
+ private Thread m_thread;
+ private int m_counter;
+ private String m_trace;
+ public boolean equals(Object o)
+ {
+ Info other = (Info)o;
+ return m_thread == other.m_thread;
+ }
+ public String toString()
+ {
+ return m_thread + " - " + m_counter + "\n" + m_trace;
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Semaphore.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/SoftObject.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/SoftObject.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/SoftObject.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,111 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.lang.ref.SoftReference;
+import java.lang.ref.ReferenceQueue;
+
+/**
+ * Convenience class to wrap an <tt>Object</tt> into a <tt>SoftReference</tt>.
+ *
+ * <p>Modified from <tt>java.util.WeakHashMap.WeakKey</tt>.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class SoftObject
+ extends SoftReference
+{
+ /** The hash code of the nested object */
+ protected final int hashCode;
+
+ /**
+ * Construct a <tt>SoftObject</tt>.
+ *
+ * @param obj Object to reference.
+ */
+ public SoftObject(final Object obj) {
+ super(obj);
+ hashCode = obj.hashCode();
+ }
+
+ /**
+ * Construct a <tt>SoftObject</tt>.
+ *
+ * @param obj Object to reference.
+ * @param queue Reference queue.
+ */
+ public SoftObject(final Object obj, final ReferenceQueue queue) {
+ super(obj, queue);
+ hashCode = obj.hashCode();
+ }
+
+ /**
+ * Check the equality of an object with this.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ SoftObject soft = (SoftObject)obj;
+
+ Object a = this.get();
+ Object b = soft.get();
+ if (a == null || b == null) return false;
+ if (a == b) return true;
+
+ return a.equals(b);
+ }
+
+ return false;
+ }
+
+ /**
+ * Return the hash code of the nested object.
+ *
+ * @return The hash code of the nested object.
+ */
+ public int hashCode() {
+ return hashCode;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Factory Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Create a <tt>SoftObject</tt> for the given object.
+ *
+ * @param obj Object to reference.
+ * @return <tt>SoftObject</tt> or <tt>null</tt> if object is null.
+ */
+ public static SoftObject create(final Object obj) {
+ if (obj == null) return null;
+ else return new SoftObject(obj);
+ }
+
+ /**
+ * Create a <tt>SoftObject</tt> for the given object.
+ *
+ * @param obj Object to reference.
+ * @param queue Reference queue.
+ * @return <tt>SoftObject</tt> or <tt>null</tt> if object is null.
+ */
+ public static SoftObject create(final Object obj,
+ final ReferenceQueue queue)
+ {
+ if (obj == null) return null;
+ else return new SoftObject(obj, queue);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/SoftObject.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/StackTrace.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/StackTrace.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/StackTrace.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,817 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.io.PrintStream;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+import java.io.Serializable;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+import org.jboss.util.stream.Printable;
+
+/**
+ * Provides access to the current stack trace by parsing the output of
+ * <code>Throwable.printStackTrace()</code>.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class StackTrace
+ implements Serializable, Cloneable, Printable
+{
+ /** Parse all entries */
+ public static final int UNLIMITED = 0;
+
+ /** Empty prefix constant */
+ private static final String EMPTY_PREFIX = "";
+
+ /** List of <tt>StackTrace.Entry</tt> elements */
+ protected final List stack;
+
+ /**
+ * Initialize a <tt>StackTrace</tt>.
+ *
+ * @param detail Detail throwable to determine stack entries from.
+ * @param level Number of levels to go down into the trace.
+ * @param limit The maximum number of entries to parse (does not
+ * include skipped levels or the description).
+ * A value <= zero results in all entries being parsed.
+ *
+ * @throws IllegalArgumentException Invalid level or limit.
+ * @throws NestedRuntimeException Failed to create Parser.
+ * @throws NestedRuntimeException Failed to parse stack trace.
+ */
+ public StackTrace(final Throwable detail,
+ final int level,
+ final int limit)
+ {
+ if (level < 0)
+ throw new IllegalArgumentException("level < 0");
+ if (limit < 0)
+ throw new IllegalArgumentException("limit < 0");
+
+ try {
+ Parser parser = Parser.getInstance();
+ stack = parser.parse(detail, level, limit);
+ }
+ catch (InstantiationException e) {
+ throw new NestedRuntimeException(e);
+ }
+ catch (IOException e) {
+ throw new NestedRuntimeException(e);
+ }
+ }
+
+ /**
+ * Initialize a <tt>StackTrace</tt>.
+ *
+ * @param detail Detail throwable to determine stack entries from.
+ * @param level Number of levels to go down into the trace.
+ *
+ * @throws IllegalArgumentException Invalid level.
+ * @throws NestedRuntimeException Failed to create Parser.
+ * @throws NestedRuntimeException Failed to parse stack trace.
+ */
+ public StackTrace(final Throwable detail, final int level) {
+ this(detail, level, 0);
+ }
+
+ /**
+ * Initialize a <tt>StackTrace</tt>.
+ *
+ * @param detail Detail throwable to determine stack entries from.
+ * @param level Number of levels to go down into the trace.
+ *
+ * @throws NestedRuntimeException Failed to create Parser.
+ * @throws NestedRuntimeException Failed to parse stack trace.
+ */
+ public StackTrace(final Throwable detail) {
+ this(detail, 0, 0);
+ }
+
+ /**
+ * Construct a <tt>StackTrace</tt>.
+ *
+ * @param level Number of levels to go down into the trace.
+ * @param limit The maximum number of entries to parse (does not
+ * include skipped levels or the description).
+ * A value <= zero results in all entries being parsed.
+ */
+ public StackTrace(final int level, final int limit) {
+ this(new Throwable(), level + 1, limit);
+ }
+
+ /**
+ * Construct a <tt>StackTrace</tt>.
+ *
+ * @param level Number of levels to go down into the trace.
+ */
+ public StackTrace(final int level) {
+ this(new Throwable(), level + 1, UNLIMITED);
+ }
+
+ /**
+ * Construct a <tt>StackTrace</tt>.
+ */
+ public StackTrace() {
+ this(new Throwable(), 1, UNLIMITED);
+ }
+
+ /**
+ * Sub-trace constructor.
+ */
+ protected StackTrace(final List stack) {
+ this.stack = stack;
+ }
+
+ /**
+ * Check if the given object is equals to this.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal to this.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ return ((StackTrace)obj).stack.equals(stack);
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns a shallow cloned copy of this object.
+ *
+ * @return A shallow cloned copy of this object.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+ /**
+ * Returns the stack trace entry for the element at the given level.
+ *
+ * @param level Number of levels.
+ * @return Stack trace entry.
+ *
+ * @throws IndexOutOfBoundsException Invalid level index.
+ */
+ public Entry getEntry(final int level) {
+ return (Entry)stack.get(level);
+ }
+
+ /**
+ * Returns the stack trace entry for the calling method.
+ *
+ * @return Stack trace entry for calling method.
+ */
+ public Entry getCallerEntry() {
+ return getEntry(0);
+ }
+
+ /**
+ * Return the root entry for this stack trace.
+ *
+ * @return Stack trace entry for the root calling method.
+ */
+ public Entry getRootEntry() {
+ return getEntry(stack.size() - 1);
+ }
+
+ /**
+ * Returns a sub trace starting at the the given level.
+ *
+ * @param level Number of levels.
+ * @return Sub-trace.
+ */
+ public StackTrace getSubTrace(final int level) {
+ return new StackTrace(stack.subList(level, stack.size()));
+ }
+
+ /**
+ * Returns a sub trace starting at the the given level.
+ *
+ * @param level Number of levels.
+ * @param limit Limit the sub-trace. If there are less entries
+ * than the limit, the limit has no effect.
+ * @return Sub-trace.
+ */
+ public StackTrace getSubTrace(final int level, int limit) {
+ if (limit > 0) {
+ limit = Math.min(level + limit, stack.size());
+ }
+ else {
+ limit = stack.size();
+ }
+ // limit is now the ending index of the stack to return
+
+ return new StackTrace(stack.subList(level, limit));
+ }
+
+ /**
+ * Returns the stack trace starting at the calling method.
+ *
+ * @return Stack trace for calling method.
+ */
+ public StackTrace getCallerTrace() {
+ return getSubTrace(1);
+ }
+
+ /**
+ * Print this stack trace.
+ *
+ * @param writer The writer to print to.
+ * @param prefix Stack trace entry prefix.
+ */
+ public void print(final PrintWriter writer, final String prefix) {
+ Iterator iter = stack.iterator();
+ while (iter.hasNext()) {
+ Entry entry = (Entry)iter.next();
+ entry.print(writer, prefix);
+ }
+ }
+
+ /**
+ * Print this stack trace.
+ *
+ * @param writer The writer to print to.
+ */
+ public void print(final PrintWriter writer) {
+ print(writer, EMPTY_PREFIX);
+ }
+
+ /**
+ * Print this stack trace.
+ *
+ * @param stream The stream to print to.
+ * @param prefix Stack trace entry prefix.
+ */
+ public void print(final PrintStream stream, final String prefix) {
+ Iterator iter = stack.iterator();
+ while (iter.hasNext()) {
+ Entry entry = (Entry)iter.next();
+ entry.print(stream, prefix);
+ }
+ }
+
+ /**
+ * Print this stack trace.
+ *
+ * @param stream The stream to print to.
+ */
+ public void print(final PrintStream stream) {
+ print(stream, EMPTY_PREFIX);
+ }
+
+ /**
+ * Print this stack trace to <code>System.err</code>.
+ *
+ * @param prefix Stack trace entry prefix.
+ */
+ public void print(final String prefix) {
+ print(System.err, prefix);
+ }
+
+ /**
+ * Print this stack trace to <code>System.err</code>.
+ */
+ public void print() {
+ print(System.err);
+ }
+
+ /**
+ * Returns an iterator over all of the entries in the stack trace.
+ *
+ * @return An iterator over all of the entries in the stack trace.
+ */
+ public Iterator iterator() {
+ return stack.iterator();
+ }
+
+ /**
+ * Returns the number of entries (or size) of the stack trace.
+ *
+ * @return The number of entries (or size) of the stack trace.
+ */
+ public int size() {
+ return stack.size();
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Static Access //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Returns a stack trace entry for the current position in the stack.
+ *
+ * <p>The current entry refers to the method that has invoked
+ * {@link #currentEntry()}.
+ *
+ * @return Current position in the stack.
+ */
+ public static final Entry currentEntry() {
+ return new StackTrace().getCallerEntry();
+ }
+
+ /**
+ * Returns a stack trace entry for the calling methods current position
+ * in the stack.
+ *
+ * <p>Calling method in this case refers to the method that has called
+ * the method which invoked {@link #callerEntry()}.
+ *
+ * @return Calling methods current position in the stack.
+ *
+ * @throws IndexOutOfBoundsException The current entry is at bottom
+ * of the stack.
+ */
+ public static final Entry callerEntry() {
+ return new StackTrace(1).getCallerEntry();
+ }
+
+ /**
+ * Returns a stack trace entry for the root calling method of the current
+ * execution thread.
+ *
+ * @return Stack trace entry for the root calling method.
+ */
+ public static final Entry rootEntry() {
+ return new StackTrace().getRootEntry();
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // StackTrace Entry //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * A stack trace entry.
+ */
+ public static final class Entry
+ implements Cloneable, Serializable, Printable
+ {
+ /** Unknown element token */
+ public static final String UNKNOWN = "<unknown>";
+
+ /** Default package token */
+ public static final String DEFAULT = "<default>";
+
+ /** The fully qualified class name for this entry */
+ protected String className = UNKNOWN;
+
+ /** The method name for this entry */
+ protected String methodName = UNKNOWN;
+
+ /** The source file name for this entry */
+ protected String sourceFileName = UNKNOWN;
+
+ /** The source file line number for this entry */
+ protected String lineNumber = UNKNOWN;
+
+ /**
+ * Construct a new StackTrace entry.
+ *
+ * @param className Fully qualified class name.
+ * @param methodName Method name.
+ * @param sourceFileName Source file name.
+ * @param lineNumber Source file line number.
+ */
+ public Entry(final String className,
+ final String methodName,
+ final String sourceFileName,
+ final String lineNumber)
+ {
+ this.className = className;
+ this.methodName = methodName;
+ this.sourceFileName = sourceFileName;
+ this.lineNumber = lineNumber;
+ }
+
+ /**
+ * Construct a new StackTrace entry.
+ *
+ * @param raw The raw stack trace entry.
+ */
+ public Entry(final String raw) {
+ // parse the raw string
+ parse(raw);
+ }
+
+ /**
+ * Parse a raw stack trace entry.
+ *
+ * @param raw Raw stack trace.
+ */
+ protected void parse(final String raw) {
+ // get the class and method names
+ int j = raw.indexOf("at ") + 3;
+ int i = raw.indexOf("(");
+ if (j == -1 || i == -1) return;
+
+ String temp = raw.substring(j, i);
+ i = temp.lastIndexOf(".");
+ if (i == -1) return;
+
+ className = temp.substring(0, i);
+ methodName = temp.substring(i + 1);
+
+ // get the source file name
+ j = raw.indexOf("(") + 1;
+ i = raw.indexOf(":");
+ if (j == -1) return;
+ if (i == -1) {
+ i = raw.indexOf(")");
+ if (i == -1) return;
+ sourceFileName = raw.substring(j, i);
+ }
+ else {
+ sourceFileName = raw.substring(j, i);
+ // get the line number
+ j = i + 1;
+ i = raw.lastIndexOf(")");
+ if (i != -1)
+ lineNumber = raw.substring(j, i);
+ else
+ lineNumber = raw.substring(j);
+ }
+ }
+
+ /**
+ * Get the class name for this entry.
+ *
+ * @return The class name for this entry.
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ /**
+ * Get the short class name for this entry.
+ *
+ * <p>This is a macro for
+ * <code>Classes.stripPackageName(entry.getClassName())</code></p>
+ *
+ * @return The short class name for this entry.
+ */
+ public String getShortClassName() {
+ return Classes.stripPackageName(className);
+ }
+
+ /**
+ * Get the method name for this entry.
+ *
+ * @return The method name for this entry.
+ */
+ public String getMethodName() {
+ return methodName;
+ }
+
+ /**
+ * Get the fully qualified method name for this entry.
+ *
+ * <p>This is a macro for
+ * <code>entry.getClassName() + "." + entry.getMethodName()</code></p>
+ *
+ * @return The fully qualified method name for this entry.
+ */
+ public String getFullMethodName() {
+ return className + "." + methodName;
+ }
+
+ /**
+ * Get the source file name for this entry.
+ *
+ * @return The source file name for this entry.
+ */
+ public String getSourceFileName() {
+ return sourceFileName;
+ }
+
+ /**
+ * Get the source file line number for this entry.
+ *
+ * @return The source file line number for this entry.
+ */
+ public String getLineNumber() {
+ return lineNumber;
+ }
+
+ /**
+ * Return a string representation of this with the given prefix.
+ *
+ * @param prefix Prefix for returned string.
+ * @return A string in the format of
+ * <code>prefixclassName.methodName(sourceFileName:lineNumber)</code>
+ * or <code>prefixclassName.methodName(sourceFileName)</code> if there
+ * is no line number.
+ */
+ public String toString(final String prefix) {
+ StringBuffer buff = new StringBuffer();
+
+ if (prefix != null)
+ buff.append(prefix);
+
+ buff.append(className).append(".").append(methodName)
+ .append("(").append(sourceFileName);
+
+ if (! lineNumber.equals(UNKNOWN))
+ buff.append(":").append(lineNumber);
+
+ buff.append(")");
+
+ return buff.toString();
+ }
+
+ /**
+ * Return a string representation of this.
+ *
+ * @return A string in the format of
+ * <code>className.methodName(sourceFileName:lineNumber)</code>
+ */
+ public String toString() {
+ return toString(EMPTY_PREFIX);
+ }
+
+ /**
+ * Return the hash code of this object.
+ *
+ * @return The hash code of this object.
+ */
+ public int hashCode() {
+ return HashCode.generate(new String[] {
+ className, methodName, sourceFileName, lineNumber,
+ });
+ }
+
+ /**
+ * Check the equality of a given object with this.
+ *
+ * @param obj Object to test equality with.
+ * @return True if the given object is equal to this.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ Entry entry = (Entry)obj;
+ return
+ entry.className.equals(className) &&
+ entry.methodName.equals(methodName) &&
+ entry.sourceFileName.equals(sourceFileName) &&
+ entry.lineNumber.equals(lineNumber);
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns a shallow cloned copy of this object.
+ *
+ * @return A shallow cloned copy of this object.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+ /**
+ * Print this stack trace entry.
+ *
+ * @param writer The writer to print to.
+ * @param prefix Prefix for string conversion.
+ */
+ public void print(final PrintWriter writer, final String prefix) {
+ writer.println(this.toString(prefix));
+ }
+
+ /**
+ * Print this stack trace entry.
+ *
+ * @param writer The writer to print to.
+ */
+ public void print(final PrintWriter writer) {
+ writer.println(this.toString());
+ }
+
+ /**
+ * Print this stack trace entry.
+ *
+ * @param stream The stream to print to.
+ * @param prefix Prefix for string conversion.
+ */
+ public void print(final PrintStream stream, final String prefix) {
+ stream.println(this.toString(prefix));
+ }
+
+ /**
+ * Print this stack trace entry.
+ *
+ * @param stream The stream to print to.
+ */
+ public void print(final PrintStream stream) {
+ stream.println(this.toString());
+ }
+
+ /**
+ * Print this stack trace entry to <code>System.err<code>.
+ *
+ * @param prefix Prefix for string conversion.
+ */
+ public void print(final String prefix) {
+ print(System.err, prefix);
+ }
+
+ /**
+ * Print this stack trace entry to <code>System.err<code>.
+ */
+ public void print() {
+ print(System.err);
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // StackTrace Parser //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * A parser which takes a standard Throwable and produces
+ * {@link StackTrace.Entry} objects.
+ */
+ public static class Parser
+ {
+ /**
+ * Skip the throwable description of the trace.
+ *
+ * @param reader Reader representing the trace.
+ *
+ * @throws IOException
+ */
+ protected void skipDescription(final BufferedReader reader)
+ throws IOException
+ {
+ reader.readLine();
+ }
+
+ /**
+ * Skip to the correct level of the stack (going down into the stack).
+ *
+ * @param reader Reader representing the stack trace.
+ * @param level Number of levels to go down.
+ *
+ * @throws IOException
+ */
+ protected void setLevel(final BufferedReader reader, final int level)
+ throws IOException
+ {
+ for (int i=0; i<level; i++) {
+ reader.readLine();
+ }
+ }
+
+ /**
+ * Read a throwable stack trace as an array of bytes.
+ *
+ * @param detail Throwable to get trace from.
+ * @return Throwable stack trace as an array of bytes.
+ *
+ * @throws IOException
+ */
+ protected byte[] readBytes(final Throwable detail) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(baos);
+
+ try {
+ detail.printStackTrace(ps);
+ }
+ finally {
+ ps.close();
+ }
+
+ return baos.toByteArray();
+ }
+
+ /**
+ * Create a reader for the trace of the given Throwable.
+ *
+ * @param detail Thorwable to get trace from.
+ * @return Reader for the throwable stack trace.
+ *
+ * @throws IOException
+ */
+ protected BufferedReader createReader(final Throwable detail)
+ throws IOException
+ {
+ byte bytes[] = readBytes(detail);
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ InputStreamReader reader = new InputStreamReader(bais);
+
+ return new BufferedReader(reader);
+ }
+
+ /**
+ * Parse a Throwable stack trace.
+ *
+ * @param detail Throwable to get trace from.
+ * @param level Number of levels down to begin parsing.
+ * @param limit The maximum number of entries to parse (does not
+ * include skipped levels or the description).
+ * A value <= zero results in all entries being parsed.
+ * @return List of {@link StackTrace.Entry} objects.
+ *
+ * @throws IOException
+ */
+ public List parse(final Throwable detail,
+ final int level,
+ final int limit)
+ throws IOException
+ {
+ // create an reader the throwable
+ BufferedReader reader = createReader(detail);
+
+ // ignore throwable description
+ skipDescription(reader);
+
+ // set the stack level
+ setLevel(reader, level);
+
+ // read in the stack entrys
+ List list = new ArrayList();
+
+ String raw;
+ int count = 0;
+ while ((raw = reader.readLine()) != null) {
+ Entry entry = createEntry(raw);
+ list.add(entry);
+
+ // if we have reached the limit, then stop parsing
+ if (limit > UNLIMITED && ++count >= limit) break;
+ }
+
+ return list;
+ }
+
+ /**
+ * Create a stack trace entry for the given raw trace entry.
+ *
+ * @param raw Raw stack trace entry.
+ * @return Stack trace entry.
+ *
+ * @throws IOException
+ */
+ protected Entry createEntry(final String raw) throws IOException {
+ return new Entry(raw);
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Singleton Access //
+ //////////////////////////////////////////////////////////////////////
+
+ /** The single instance of StackTrace.Parser */
+ private static Parser instance = null;
+
+ /**
+ * Get the stack trace parser for this virtual machine.
+ *
+ * @return Stack trace parser
+ *
+ * @throws InstantiationException
+ */
+ public static final synchronized Parser getInstance()
+ throws InstantiationException
+ {
+ if (instance == null) {
+ // change to read parser class from a property
+ instance = new Parser();
+ }
+
+ return instance;
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/StackTrace.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/StopWatch.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/StopWatch.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/StopWatch.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,335 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.Serializable;
+
+/**
+ * Simulates a stop watch with a <em>lap</em> counter.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class StopWatch
+ implements Serializable, Cloneable
+{
+ /** Total time */
+ protected long total = 0;
+
+ /** Start time */
+ protected long start = -1;
+
+ /** Stop time */
+ protected long stop = -1;
+
+ /** The <i>lap</i> count */
+ protected int count = 0;
+
+ /** Is the watch started */
+ protected boolean running = false;
+
+ /**
+ * Default constructor.
+ */
+ public StopWatch() {}
+
+ /**
+ * Construct a StopWatch.
+ *
+ * @param running Start the watch
+ */
+ public StopWatch(final boolean running)
+ {
+ if (running) start();
+ }
+
+ /**
+ * Start the watch.
+ *
+ * @param reset True to reset the watch prior to starting.
+ */
+ public void start(final boolean reset)
+ {
+ if (!running) {
+ if (reset) reset();
+ start = System.currentTimeMillis();
+ running = true;
+ }
+ }
+
+ /**
+ * Start the watch.
+ */
+ public void start()
+ {
+ start(false);
+ }
+
+ /**
+ * Stop the watch.
+ *
+ * @return Elapsed time or 0 if the watch was never started.
+ */
+ public long stop()
+ {
+ long lap = 0;
+
+ if (running) {
+ count++;
+ stop = System.currentTimeMillis();
+ lap = stop - start;
+ total += lap;
+ running = false;
+ }
+
+ return lap;
+ }
+
+ /**
+ * Reset the watch.
+ */
+ public void reset()
+ {
+ start = -1;
+ stop = -1;
+ total = 0;
+ count = 0;
+ running = false;
+ }
+
+ /**
+ * Get the <i>lap</i> count.
+ *
+ * @return The <i>lap</i> count.
+ */
+ public int getLapCount()
+ {
+ return count;
+ }
+
+ /**
+ * Get the elapsed <i>lap</i> time since the watch was started.
+ *
+ * @return Elapsed <i>lap</i> time or 0 if the watch was never started
+ */
+ public long getLapTime()
+ {
+ if (start == -1) {
+ return 0;
+ }
+ else if (running) {
+ return System.currentTimeMillis() - start;
+ }
+ else {
+ return stop - start;
+ }
+ }
+
+ /**
+ * Get the average <i>lap</i> time since the watch was started.
+ *
+ * @return Average <i>lap</i> time since the watch was started.
+ */
+ public long getAverageLapTime()
+ {
+ return (count == 0) ? 0 : getLapTime() / getLapCount();
+ }
+
+ /**
+ * Get the elapsed time since the watch was created or last reset.
+ *
+ * @return Elapsed time or 0 if the watch was never started.
+ */
+ public long getTime()
+ {
+ if (start == -1) {
+ return 0;
+ }
+ else if (running) {
+ return total + System.currentTimeMillis() - start;
+ }
+ else {
+ return total;
+ }
+ }
+
+ /**
+ * Check if the watch is running.
+ *
+ * @return True if the watch is running.
+ */
+ public boolean isRunning()
+ {
+ return running;
+ }
+
+ /**
+ * Return a string representation.
+ */
+ public String toString()
+ {
+ StringBuffer buff = new StringBuffer();
+
+ if (running) {
+ // the watch has not been stopped
+ formatElapsedTime(buff, getTime());
+
+ // add the current lap time too if there is more than one lap
+ if (count >= 1) {
+ buff.append(", count=").append(count);
+ buff.append(", current=");
+ formatElapsedTime(buff, getLapTime());
+ }
+ }
+ else {
+ // the watch has been stopped
+ formatElapsedTime(buff, getTime());
+
+ // add extra info if there is more than one lap
+ if (count > 1) {
+ buff.append(", count=").append(count);
+ buff.append(", average=");
+ formatElapsedTime(buff, getAverageLapTime());
+ }
+ }
+
+ return buff.toString();
+ }
+
+ private void formatElapsedTime(final StringBuffer buff, final long lapsed)
+ {
+ buff.append(new Duration(lapsed));
+ }
+
+ /**
+ * Return a cloned copy of this object.
+ *
+ * @return A cloned copy of this object.
+ */
+ public Object clone()
+ {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Wrappers //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Base wrapper class for other wrappers.
+ */
+ private static class Wrapper
+ extends StopWatch
+ {
+ protected StopWatch watch;
+
+ public Wrapper(final StopWatch watch) {
+ this.watch = watch;
+ }
+
+ public void start(final boolean reset) {
+ watch.start(reset);
+ }
+
+ public void start() {
+ watch.start();
+ }
+
+ public long stop() {
+ return watch.stop();
+ }
+
+ public void reset() {
+ watch.reset();
+ }
+
+ public long getLapTime() {
+ return watch.getLapTime();
+ }
+
+ public long getAverageLapTime() {
+ return watch.getAverageLapTime();
+ }
+
+ public int getLapCount() {
+ return watch.getLapCount();
+ }
+
+ public long getTime() {
+ return watch.getTime();
+ }
+
+ public boolean isRunning() {
+ return watch.isRunning();
+ }
+
+ public String toString() {
+ return watch.toString();
+ }
+ }
+
+ /**
+ * Return a synchronized stop watch.
+ *
+ * @param watch StopWatch to synchronize.
+ * @return Synchronized stop watch.
+ */
+ public static StopWatch makeSynchronized(final StopWatch watch)
+ {
+ return new Wrapper(watch)
+ {
+ public synchronized void start(final boolean reset) {
+ this.watch.start(reset);
+ }
+
+ public synchronized void start() {
+ this.watch.start();
+ }
+
+ public synchronized long stop() {
+ return this.watch.stop();
+ }
+
+ public synchronized void reset() {
+ this.watch.reset();
+ }
+
+ public synchronized long getLapTime() {
+ return this.watch.getLapTime();
+ }
+
+ public synchronized long getAverageLapTime() {
+ return this.watch.getAverageLapTime();
+ }
+
+ public synchronized int getLapCount() {
+ return this.watch.getLapCount();
+ }
+
+ public synchronized long getTime() {
+ return this.watch.getTime();
+ }
+
+ public synchronized boolean isRunning() {
+ return this.watch.isRunning();
+ }
+
+ public synchronized String toString() {
+ return this.watch.toString();
+ }
+ };
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/StopWatch.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Strings.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Strings.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Strings.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,772 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.IOException;
+import java.io.File;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.util.Map;
+
+/**
+ * A collection of String utilities.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author Scott.Stark at jboss.org
+ */
+public final class Strings
+{
+ /** An empty string constant */
+ public static final String EMPTY = "";
+
+ /** New line string constant */
+ public static final String NEWLINE = org.jboss.util.platform.Constants.LINE_SEPARATOR;
+
+ // States used in property parsing
+ private static final int NORMAL = 0;
+ private static final int SEEN_DOLLAR = 1;
+ private static final int IN_BRACKET = 2;
+
+ /////////////////////////////////////////////////////////////////////////
+ // Substitution Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Substitute sub-strings in side of a string.
+ *
+ * @param buff Stirng buffer to use for substitution (buffer is not reset)
+ * @param from String to substitute from
+ * @param to String to substitute to
+ * @param string String to look for from in
+ * @return Substituted string
+ */
+ public static String subst(final StringBuffer buff, final String from,
+ final String to, final String string)
+ {
+ int begin = 0, end = 0;
+
+ while ((end = string.indexOf(from, end)) != -1) {
+ // append the first part of the string
+ buff.append(string.substring(begin, end));
+
+ // append the replaced string
+ buff.append(to);
+
+ // update positions
+ begin = end + from.length();
+ end = begin;
+ }
+
+ // append the rest of the string
+ buff.append(string.substring(begin, string.length()));
+
+ return buff.toString();
+ }
+
+ /**
+ * Substitute sub-strings in side of a string.
+ *
+ * @param from String to substitute from
+ * @param to String to substitute to
+ * @param string String to look for from in
+ * @return Substituted string
+ */
+ public static String subst(final String from, final String to,
+ final String string)
+ {
+ return subst(new StringBuffer(), from, to, string);
+ }
+
+ /**
+ * Substitute sub-strings in side of a string.
+ *
+ * @param buff String buffer to use for substitution (buffer is not reset)
+ * @param string String to subst mappings in
+ * @param map Map of from->to strings
+ * @param beginToken Beginning token
+ * @param endToken Ending token
+ * @return Substituted string
+ */
+ public static String subst(final StringBuffer buff, final String string,
+ final Map map, final String beginToken,
+ final String endToken)
+ {
+ int begin = 0, rangeEnd = 0;
+ Range range;
+
+ while ((range = rangeOf(beginToken, endToken, string, rangeEnd)) != null) {
+ // append the first part of the string
+ buff.append(string.substring(begin, range.begin));
+
+ // Get the string to replace from the map
+ String key = string.substring(range.begin + beginToken.length(),
+ range.end);
+ Object value = map.get(key);
+ // if mapping does not exist then use empty;
+ if (value == null) value = EMPTY;
+
+ // append the replaced string
+ buff.append(value);
+
+ // update positions
+ begin = range.end + endToken.length();
+ rangeEnd = begin;
+ }
+
+ // append the rest of the string
+ buff.append(string.substring(begin, string.length()));
+
+ return buff.toString();
+ }
+
+ /**
+ * Substitute sub-strings in side of a string.
+ *
+ * @param string String to subst mappings in
+ * @param map Map of from->to strings
+ * @param beginToken Beginning token
+ * @param endToken Ending token
+ * @return Substituted string
+ */
+ public static String subst(final String string, final Map map,
+ final String beginToken, final String endToken)
+ {
+ return subst(new StringBuffer(), string, map, beginToken, endToken);
+ }
+
+ /**
+ * Substitute index identifiers with the replacement value from the
+ * given array for the corresponding index.
+ *
+ * @param buff The string buffer used for the substitution
+ * (buffer is not reset).
+ * @param string String substitution format.
+ * @param replace Array of strings whose values will be used as
+ * replacements in the given string when a token with
+ * their index is found.
+ * @param token The character token to specify the start of an index
+ * reference.
+ * @return Substituted string.
+ */
+ public static String subst(final StringBuffer buff, final String string,
+ final String replace[], final char token)
+ {
+ int i = string.length();
+ for (int j = 0; j >= 0 && j < i; j++) {
+ char c = string.charAt(j);
+
+ // if the char is the token, then get the index
+ if (c == token) {
+
+ // if we aren't at the end of the string, get the index
+ if (j != i) {
+ int k = Character.digit(string.charAt(j + 1), 10);
+
+ if (k == -1) {
+ buff.append(string.charAt(j + 1));
+ }
+ else if (k < replace.length) {
+ buff.append(replace[k]);
+ }
+
+ j++;
+ }
+ }
+ else {
+ buff.append(c);
+ }
+ }
+
+ return buff.toString();
+ }
+
+ /**
+ * Substitute index identifiers with the replacement value from the
+ * given array for the corresponding index.
+ *
+ * @param string String substitution format.
+ * @param replace Array of strings whose values will be used as
+ * replacements in the given string when a token with
+ * their index is found.
+ * @param token The character token to specify the start of an index
+ * reference.
+ * @return Substituted string.
+ */
+ public static String subst(final String string, final String replace[],
+ final char token)
+ {
+ return subst(new StringBuffer(), string, replace, token);
+ }
+
+ /**
+ * Substitute index identifiers (with <code>%</code> for the index token)
+ * with the replacement value from the given array for the corresponding
+ * index.
+ *
+ * @param string String substitution format.
+ * @param replace Array of strings whose values will be used as
+ * replacements in the given string when a token with
+ * their index is found.
+ * @return Substituted string.
+ */
+ public static String subst(final String string, final String replace[]) {
+ return subst(new StringBuffer(), string, replace, '%');
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Regex Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /** Go through the input string and replace any occurance of ${p} with
+ *the System.getProperty(p) value.
+ *@return the input string with all property references replaced
+ */
+ public static String replaceProperties(final String string)
+ {
+ final char[] chars = string.toCharArray();
+ StringBuffer buffer = new StringBuffer();
+ boolean properties = false;
+ int state = NORMAL;
+ int start = 0;
+ for (int i = 0; i < chars.length; ++i)
+ {
+ char c = chars[i];
+
+ // Dollar sign outside brackets
+ if (c == '$' && state != IN_BRACKET)
+ state = SEEN_DOLLAR;
+
+ // Open bracket immediatley after dollar
+ else if (c == '{' && state == SEEN_DOLLAR)
+ {
+ buffer.append(string.substring(start, i-1));
+ state = IN_BRACKET;
+ start = i-1;
+ }
+
+ // No open bracket after dollar
+ else if (state == SEEN_DOLLAR)
+ state = NORMAL;
+
+ // Closed bracket after open bracket
+ else if (c == '}' && state == IN_BRACKET)
+ {
+ // No content
+ if (start+2 == i)
+ buffer.append("${}"); // REVIEW: Correct?
+
+ // Collect the system property
+ else
+ {
+ properties = true;
+ buffer.append(System.getProperty(string.substring(start+2, i)));
+ }
+ start = i+1;
+ state = NORMAL;
+ }
+ }
+
+ // No properties
+ if (properties == false)
+ return string;
+
+ // Collect the trailing characters
+ if (start != chars.length)
+ buffer.append(string.substring(start, chars.length));
+
+ // Done
+ return buffer.toString();
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Range Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Represents a range between two integers.
+ */
+ public static class Range
+ {
+ /** The beginning of the range. */
+ public int begin;
+
+ /** The end of the range. */
+ public int end;
+
+ /**
+ * Construct a new range.
+ *
+ * @param begin The beginning of the range.
+ * @param end The end of the range.
+ */
+ public Range(int begin, int end) {
+ this.begin = begin;
+ this.end = end;
+ }
+
+ /**
+ * Default constructor.
+ */
+ public Range() {}
+ }
+
+ /**
+ * Return the range from a begining token to an ending token.
+ *
+ * @param beginToken String to indicate begining of range.
+ * @param endToken String to indicate ending of range.
+ * @param string String to look for range in.
+ * @param fromIndex Beginning index.
+ * @return (begin index, end index) or <i>null</i>.
+ */
+ public static Range rangeOf(final String beginToken, final String endToken,
+ final String string, final int fromIndex)
+ {
+ int begin = string.indexOf(beginToken, fromIndex);
+
+ if (begin != -1) {
+ int end = string.indexOf(endToken, begin + 1);
+ if (end != -1) {
+ return new Range(begin, end);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Return the range from a begining token to an ending token.
+ *
+ * @param beginToken String to indicate begining of range.
+ * @param endToken String to indicate ending of range.
+ * @param string String to look for range in.
+ * @return (begin index, end index) or <i>null</i>.
+ */
+ public static Range rangeOf(final String beginToken, final String endToken,
+ final String string)
+ {
+ return rangeOf(beginToken, endToken, string, 0);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Spliting Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Split up a string into multiple strings based on a delimiter.
+ *
+ * @param string String to split up.
+ * @param delim Delimiter.
+ * @param limit Limit the number of strings to split into
+ * (-1 for no limit).
+ * @return Array of strings.
+ */
+ public static String[] split(final String string, final String delim,
+ final int limit)
+ {
+ // get the count of delim in string, if count is > limit
+ // then use limit for count. The number of delimiters is less by one
+ // than the number of elements, so add one to count.
+ int count = count(string, delim) + 1;
+ if (limit > 0 && count > limit) {
+ count = limit;
+ }
+
+ String strings[] = new String[count];
+ int begin = 0;
+
+ for (int i=0; i<count; i++) {
+ // get the next index of delim
+ int end = string.indexOf(delim, begin);
+
+ // if the end index is -1 or if this is the last element
+ // then use the string's length for the end index
+ if (end == -1 || i + 1 == count)
+ end = string.length();
+
+ // if end is 0, then the first element is empty
+ if (end == 0)
+ strings[i] = EMPTY;
+ else
+ strings[i] = string.substring(begin, end);
+
+ // update the begining index
+ begin = end + 1;
+ }
+
+ return strings;
+ }
+
+ /**
+ * Split up a string into multiple strings based on a delimiter.
+ *
+ * @param string String to split up.
+ * @param delim Delimiter.
+ * @return Array of strings.
+ */
+ public static String[] split(final String string, final String delim) {
+ return split(string, delim, -1);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Joining/Concatenation Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Join an array of strings into one delimited string.
+ *
+ * @param buff String buffered used for join (buffer is not reset).
+ * @param array Array of objects to join as strings.
+ * @param delim Delimiter to join strings with or <i>null</i>.
+ * @return Joined string.
+ */
+ public static String join(final StringBuffer buff, final Object array[],
+ final String delim)
+ {
+ boolean haveDelim = (delim != null);
+
+ for (int i=0; i<array.length; i++) {
+ buff.append(array[i]);
+
+ // if this is the last element then don't append delim
+ if (haveDelim && (i + 1) < array.length) {
+ buff.append(delim);
+ }
+ }
+
+ return buff.toString();
+ }
+
+ /**
+ * Join an array of strings into one delimited string.
+ *
+ * @param array Array of objects to join as strings.
+ * @param delim Delimiter to join strings with or <i>null</i>.
+ * @return Joined string.
+ */
+ public static String join(final Object array[], final String delim) {
+ return join(new StringBuffer(), array, delim);
+ }
+
+ /**
+ * Convert and join an array of objects into one string.
+ *
+ * @param array Array of objects to join as strings.
+ * @return Converted and joined objects.
+ */
+ public static String join(final Object array[]) {
+ return join(array, null);
+ }
+
+ /**
+ * Convert and join an array of bytes into one string.
+ *
+ * @param array Array of objects to join as strings.
+ * @return Converted and joined objects.
+ */
+ public static String join(final byte array[]) {
+ Byte bytes[] = new Byte[array.length];
+ for (int i=0; i<bytes.length; i++) {
+ bytes[i] = new Byte(array[i]);
+ }
+
+ return join(bytes, null);
+ }
+
+ /**
+ * Return a string composed of the given array.
+ *
+ * @param buff Buffer used to construct string value (not reset).
+ * @param array Array of objects.
+ * @param prefix String prefix.
+ * @param separator Element sepearator.
+ * @param suffix String suffix.
+ * @return String in the format of:
+ * prefix + n ( + separator + n+i)* + suffix.
+ */
+ public static String join(final StringBuffer buff, final Object[] array,
+ final String prefix, final String separator,
+ final String suffix)
+ {
+ buff.append(prefix);
+ join(buff, array, separator);
+ buff.append(suffix);
+
+ return buff.toString();
+ }
+
+ /**
+ * Return a string composed of the given array.
+ *
+ * @param array Array of objects.
+ * @param prefix String prefix.
+ * @param separator Element sepearator.
+ * @param suffix String suffix.
+ * @return String in the format of:
+ * prefix + n ( + separator + n+i)* + suffix.
+ */
+ public static String join(final Object[] array, final String prefix,
+ final String separator, final String suffix)
+ {
+ return join(new StringBuffer(), array, prefix, separator, suffix);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Counting Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Count the number of instances of substring within a string.
+ *
+ * @param string String to look for substring in.
+ * @param substring Sub-string to look for.
+ * @return Count of substrings in string.
+ */
+ public static int count(final String string, final String substring) {
+ int count = 0;
+ int idx = 0;
+
+ while ((idx = string.indexOf(substring, idx)) != -1) {
+ idx++;
+ count++;
+ }
+
+ return count;
+ }
+
+ /**
+ * Count the number of instances of character within a string.
+ *
+ * @param string String to look for substring in.
+ * @param c Character to look for.
+ * @return Count of substrings in string.
+ */
+ public static int count(final String string, final char c) {
+ return count(string, String.valueOf(c));
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Padding Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return a string padded with the given string for the given count.
+ *
+ * @param buff String buffer used for padding (buffer is not reset).
+ * @param string Pad element.
+ * @param count Pad count.
+ * @return Padded string.
+ */
+ public static String pad(final StringBuffer buff, final String string,
+ final int count)
+ {
+ for (int i=0; i<count; i++) {
+ buff.append(string);
+ }
+
+ return buff.toString();
+ }
+
+ /**
+ * Return a string padded with the given string for the given count.
+ *
+ * @param string Pad element.
+ * @param count Pad count.
+ * @return Padded string.
+ */
+ public static String pad(final String string, final int count) {
+ return pad(new StringBuffer(), string, count);
+ }
+
+ /**
+ * Return a string padded with the given string value of an object
+ * for the given count.
+ *
+ * @param obj Object to convert to a string.
+ * @param count Pad count.
+ * @return Padded string.
+ */
+ public static String pad(final Object obj, final int count) {
+ return pad(new StringBuffer(), String.valueOf(obj), count);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Misc Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * <p>Compare two strings.
+ *
+ * <p>Both or one of them may be null.
+ *
+ * @return true if object equals or intern ==, else false.
+ */
+ public static boolean compare(final String me, final String you) {
+ // If both null or intern equals
+ if (me == you)
+ return true;
+
+ // if me null and you are not
+ if (me == null && you != null)
+ return false;
+
+ // me will not be null, test for equality
+ return me.equals(you);
+ }
+
+ /**
+ * Check if the given string is empty.
+ *
+ * @param string String to check
+ * @return True if string is empty
+ */
+ public static boolean isEmpty(final String string) {
+ return string.equals(EMPTY);
+ }
+
+ /**
+ * Return the <i>nth</i> index of the given token occurring in the given string.
+ *
+ * @param string String to search.
+ * @param token Token to match.
+ * @param index <i>Nth</i> index.
+ * @return Index of <i>nth</i> item or -1.
+ */
+ public static int nthIndexOf(final String string, final String token,
+ final int index)
+ {
+ int j = 0;
+
+ for (int i = 0; i < index; i++) {
+ j = string.indexOf(token, j + 1);
+ if (j == -1) break;
+ }
+
+ return j;
+ }
+
+ /**
+ * Capitalize the first character of the given string.
+ *
+ * @param string String to capitalize.
+ * @return Capitalized string.
+ *
+ * @throws IllegalArgumentException String is <kk>null</kk> or empty.
+ */
+ public static String capitalize(final String string) {
+ if (string == null)
+ throw new NullArgumentException("string");
+ if (string.equals(""))
+ throw new EmptyStringException("string");
+
+ return Character.toUpperCase(string.charAt(0)) + string.substring(1);
+ }
+
+ /**
+ * Trim each string in the given string array.
+ *
+ * <p>This modifies the string array.
+ *
+ * @param strings String array to trim.
+ * @return String array with each element trimmed.
+ */
+ public static String[] trim(final String[] strings) {
+ for (int i=0; i<strings.length; i++) {
+ strings[i] = strings[i].trim();
+ }
+
+ return strings;
+ }
+
+ /**
+ * Make a URL from the given string.
+ *
+ * <p>
+ * If the string is a properly formatted file URL, then the file
+ * portion will be made canonical.
+ *
+ * <p>
+ * If the string is an invalid URL then it will be converted into a
+ * file URL.
+ *
+ * @param urlspec The string to construct a URL for.
+ * @param relativePrefix The string to prepend to relative file
+ * paths, or null to disable prepending.
+ * @return A URL for the given string.
+ *
+ * @throws MalformedURLException Could not make a URL for the given string.
+ */
+ public static URL toURL(String urlspec, final String relativePrefix) throws MalformedURLException
+ {
+ urlspec = urlspec.trim();
+
+ URL url;
+
+ try {
+ url = new URL(urlspec);
+ if (url.getProtocol().equals("file")) {
+ url = makeURLFromFilespec(url.getFile(), relativePrefix);
+ }
+ }
+ catch (Exception e) {
+ // make sure we have a absolute & canonical file url
+ try {
+ url = makeURLFromFilespec(urlspec, relativePrefix);
+ }
+ catch (IOException n) {
+ //
+ // jason: or should we rethrow e?
+ //
+ throw new MalformedURLException(n.toString());
+ }
+ }
+
+ return url;
+ }
+
+ /** A helper to make a URL from a filespec. */
+ private static URL makeURLFromFilespec(final String filespec, final String relativePrefix)
+ throws IOException
+ {
+ // make sure the file is absolute & canonical file url
+ File file = new File(filespec);
+
+ // if we have a prefix and the file is not abs then prepend
+ if (relativePrefix != null && !file.isAbsolute()) {
+ file = new File(relativePrefix, filespec);
+ }
+
+ // make sure it is canonical (no ../ and such)
+ file = file.getCanonicalFile();
+
+ return file.toURL();
+ }
+
+ /**
+ * Make a URL from the given string.
+ *
+ * @see #toURL(String,String)
+ *
+ * @param urlspec The string to construct a URL for.
+ * @return A URL for the given string.
+ *
+ * @throws MalformedURLException Could not make a URL for the given string.
+ */
+ public static URL toURL(final String urlspec) throws MalformedURLException
+ {
+ return toURL(urlspec, null);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Strings.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Sync.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Sync.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Sync.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util;
+
+/**
+ * Interface that gives synchronization semantic to implementors
+ *
+ * @see Semaphore
+ *
+ * @author <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
+ * @version $Revision$
+ */
+public interface Sync
+{
+ /**
+ * Acquires this sync
+ *
+ * @see #release
+ */
+ void acquire() throws InterruptedException;
+
+ /**
+ * Releases this sync
+ *
+ * @see #acquire
+ */
+ void release();
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Sync.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TCLStack.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TCLStack.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TCLStack.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,124 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.util.Stack;
+import java.util.EmptyStackException;
+import java.util.Iterator;
+
+import org.jboss.logging.Logger;
+
+import org.jboss.util.collection.Iterators;
+
+/**
+ * A thread context class loader (TCL) stack.
+ *
+ * <p>
+ * Also provides TRACE level logging for a better view of TCL usage and
+ * provides an immutable view of the stack for inspection.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class TCLStack
+{
+ /** Class logger. */
+ private static final Logger log = Logger.getLogger(TCLStack.class);
+
+ /** The thread local stack of class loaders. */
+ private static final ThreadLocal stackTL = new ThreadLocal()
+ {
+ protected Object initialValue()
+ {
+ return new Stack();
+ }
+ };
+
+ /** Get the stack from the thread lcoal. */
+ private static Stack getStack()
+ {
+ return (Stack)stackTL.get();
+ }
+
+ /**
+ * Push the current TCL and set the given CL to the TCL.
+ *
+ * @param cl The class loader to set as the TCL.
+ */
+ public static void push(final ClassLoader cl)
+ {
+ boolean trace = log.isTraceEnabled();
+
+ // push the old cl and set the new cl
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+
+ Thread.currentThread().setContextClassLoader(cl);
+ getStack().push(oldCL);
+
+ if (log.isTraceEnabled()) {
+ log.trace("Setting TCL to " + cl + "; pushing " + oldCL);
+ log.trace("Stack: " + getStack());
+ }
+ }
+
+ /**
+ * Pop the last CL from the stack and make it the TCL.
+ *
+ * <p>If the stack is empty, then no change is made to the TCL.
+ *
+ * @return The previous CL or null if there was none.
+ */
+ public static ClassLoader pop()
+ {
+ // get the last cl in the stack & make it the current
+ try {
+ ClassLoader cl = (ClassLoader)getStack().pop();
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+
+ Thread.currentThread().setContextClassLoader(cl);
+
+ if (log.isTraceEnabled()) {
+ log.trace("Setting TCL to " + cl + "; popped: " + oldCL);
+ log.trace("Stack: " + getStack());
+ }
+
+ return oldCL;
+ }
+ catch (EmptyStackException ignore) {
+ log.warn("Attempt to pop empty stack ingored", ignore);
+ return null;
+ }
+ }
+
+ /**
+ * Return the size of the TCL stack.
+ */
+ public static int size()
+ {
+ return getStack().size();
+ }
+
+ /**
+ * Return an immutable iterator over the TCL stack elements.
+ */
+ public static Iterator iterator()
+ {
+ return Iterators.makeImmutable(getStack().iterator());
+ }
+
+ /**
+ * Return the CL in the stack at the given index.
+ */
+ public static ClassLoader get(final int index)
+ throws ArrayIndexOutOfBoundsException
+ {
+ return (ClassLoader)getStack().get(index);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TCLStack.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/ThrowableHandler.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/ThrowableHandler.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/ThrowableHandler.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,135 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ * A static singleton that handles processing throwables that otherwise would
+ * be ignored or dumped to System.err.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class ThrowableHandler
+{
+ /**
+ * Container for throwable types.
+ */
+ public static interface Type
+ {
+ /** Unknown throwable. */
+ int UNKNOWN = 0;
+
+ /** Error throwable. */
+ int ERROR = 1;
+
+ /** Warning throwable. */
+ int WARNING = 2;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Listener Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /** The list of listeners */
+ protected static List listeners = Collections.synchronizedList(new ArrayList());
+
+ /**
+ * Add a ThrowableListener to the listener list. Listener is added only
+ * if if it is not already in the list.
+ *
+ * @param listener ThrowableListener to add to the list.
+ */
+ public static void addThrowableListener(ThrowableListener listener) {
+ // only add the listener if it isn't already in the list
+ if (!listeners.contains(listener)) {
+ listeners.add(listener);
+ }
+ }
+
+ /**
+ * Remove a ThrowableListener from the listener list.
+ *
+ * @param listener ThrowableListener to remove from the list.
+ */
+ public static void removeThrowableListener(ThrowableListener listener) {
+ listeners.remove(listener);
+ }
+
+ /**
+ * Fire onThrowable to all registered listeners.
+ *
+ * @param type The type off the throwable.
+ * @param t Throwable
+ */
+ protected static void fireOnThrowable(int type, Throwable t) {
+ Object[] list = listeners.toArray();
+
+ for (int i=0; i<list.length; i++) {
+ ((ThrowableListener)list[i]).onThrowable(type, t);
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Throwable Processing //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Add a throwable that is to be handled.
+ *
+ * @param type The type off the throwable.
+ * @param t Throwable to be handled.
+ */
+ public static void add(int type, Throwable t) {
+ // don't add null throwables
+ if (t == null) return;
+
+ try {
+ fireOnThrowable(type, t);
+ }
+ catch (Throwable bad) {
+ // don't let these propagate, that could introduce unwanted side-effects
+ System.err.println("Unable to handle throwable: " + t + " because of:");
+ bad.printStackTrace();
+ }
+ }
+
+ /**
+ * Add a throwable that is to be handled with unknown type.
+ *
+ * @param t Throwable to be handled.
+ */
+ public static void add(Throwable t) {
+ add(Type.UNKNOWN, t);
+ }
+
+ /**
+ * Add a throwable that is to be handled with error type.
+ *
+ * @param t Throwable to be handled.
+ */
+ public static void addError(Throwable t) {
+ add(Type.ERROR, t);
+ }
+
+ /**
+ * Add a throwable that is to be handled with warning type.
+ *
+ * @param t Throwable to be handled.
+ */
+ public static void addWarning(Throwable t) {
+ add(Type.ERROR, t);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/ThrowableHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/ThrowableListener.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/ThrowableListener.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/ThrowableListener.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,30 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.util.EventListener;
+
+/**
+ * An interface used to handle <tt>Throwable</tt> events.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface ThrowableListener
+ extends EventListener
+{
+ /**
+ * Process a throwable.
+ *
+ * @param type The type off the throwable.
+ * @param t Throwable
+ */
+ void onThrowable(int type, Throwable t);
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/ThrowableListener.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Throwables.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Throwables.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Throwables.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,37 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.io.PrintStream;
+import java.io.ByteArrayOutputStream;
+
+/**
+ * A collection of Throwable utilities.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class Throwables
+{
+ /**
+ * Return a string that consists of the stack trace of the given
+ * <code>Throwable</code>.
+ *
+ * @param t <code>Throwable</code> to get stack trace from.
+ * @return <code>Throwable</code> stack trace as a string.
+ */
+ public static String toString(final Throwable t) {
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ PrintStream stream = new PrintStream(output);
+ t.printStackTrace(stream);
+
+ return output.toString();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/Throwables.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimedCachePolicy.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimedCachePolicy.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimedCachePolicy.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,345 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/** An implementation of a timed cache. This is a cache whose entries have a
+ limited lifetime with the ability to refresh their lifetime. The entries
+ managed by the cache implement the TimedCachePolicy.TimedEntry interface. If
+ an object inserted into the cache does not implement this interface, it will
+ be wrapped in a DefaultTimedEntry and will expire without the possibility of
+ refresh after getDefaultLifetime() seconds.
+
+ This is a lazy cache policy in that objects are not checked for expiration
+ until they are accessed.
+
+ @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>.
+ @version $Revision$
+*/
+public class TimedCachePolicy
+ extends TimerTask
+ implements CachePolicy
+{
+ /** The interface that cache entries support.
+ */
+ public static interface TimedEntry
+ {
+ /** Initializes an entry with the current cache time. This is called when
+ the entry is first inserted into the cache so that entries do not
+ have to know the absolute system time.
+ */
+ public void init(long now);
+
+ /** Is the entry still valid basis the current time
+ @return true if the entry is within its lifetime, false if it is expired.
+ */
+ public boolean isCurrent(long now);
+
+ /** Attempt to extend the entry lifetime by refreshing it.
+ @return true if the entry was refreshed successfully, false otherwise.
+ */
+ public boolean refresh();
+
+ /** Notify the entry that it has been removed from the cache.
+ */
+ public void destroy();
+
+ /** Get the value component of the TimedEntry. This may or may not
+ be the TimedEntry implementation.
+ */
+ public Object getValue();
+ }
+
+ protected static Timer resolutionTimer = new Timer(true);
+
+ /** The map of cached TimedEntry objects. */
+ protected Map entryMap;
+ /** The lifetime in seconds to use for objects inserted
+ that do not implement the TimedEntry interface. */
+ protected int defaultLifetime;
+ /** A flag indicating if entryMap should be synchronized */
+ protected boolean threadSafe;
+ /** The caches notion of the current time */
+ protected long now;
+ /** The resolution in seconds of the cach current time */
+ protected int resolution;
+
+ /** Creates a new TimedCachePolicy with a default entry lifetime of 30 mins
+ that does not synchronized access to its policy store and uses a 60
+ second resolution.
+ */
+ public TimedCachePolicy()
+ {
+ this(30*60, false, 0);
+ }
+ /** Creates a new TimedCachePolicy with the given default entry lifetime
+ that does not synchronized access to its policy store and uses a 60
+ second resolution.
+ */
+ public TimedCachePolicy(int defaultLifetime)
+ {
+ this(defaultLifetime, false, 0);
+ }
+ /** Creates a new TimedCachePolicy with the given default entry lifetime
+ that does/does not synchronized access to its policy store depending
+ on the value of threadSafe.
+ @param defaultLifetime, the lifetime in seconds to use for objects inserted
+ that do not implement the TimedEntry interface.
+ @param threadSafe, a flag indicating if the cach store should be synchronized
+ to allow correct operation under multi-threaded access. If true, the
+ cache store is synchronized. If false the cache store is unsynchronized and
+ the cache is not thread safe.
+ @param resolution, the resolution in seconds of the cache timer. A cache does
+ not query the system time on every get() invocation. Rather the cache
+ updates its notion of the current time every 'resolution' seconds.
+ */
+ public TimedCachePolicy(int defaultLifetime, boolean threadSafe, int resolution)
+ {
+ this.defaultLifetime = defaultLifetime;
+ this.threadSafe = threadSafe;
+ if( resolution <= 0 )
+ resolution = 60;
+ this.resolution = resolution;
+ }
+
+ // Service implementation ----------------------------------------------
+ /** Initializes the cache for use. Prior to this the cache has no store.
+ */
+ public void create()
+ {
+ if( threadSafe )
+ entryMap = Collections.synchronizedMap(new HashMap());
+ else
+ entryMap = new HashMap();
+ now = System.currentTimeMillis();
+ }
+ /** Schedules this with the class resolutionTimer Timer object for
+ execution every resolution seconds.
+ */
+ public void start()
+ {
+ resolutionTimer.scheduleAtFixedRate(this, 0, 1000*resolution);
+ }
+ /** Stop cancels the resolution timer and flush()es the cache.
+ */
+ public void stop()
+ {
+ super.cancel();
+ flush();
+ }
+ /** Clears the cache of all entries.
+ */
+ public void destroy()
+ {
+ entryMap.clear();
+ }
+
+ // --- Begin CachePolicy interface methods
+ /** Get the cache value for key if it has not expired. If the TimedEntry
+ is expired its destroy method is called and then removed from the cache.
+ @returns the TimedEntry value or the original value if it was not an
+ instance of TimedEntry if key is in the cache, null otherwise.
+ */
+ public Object get(Object key)
+ {
+ TimedEntry entry = (TimedEntry) entryMap.get(key);
+ if( entry == null )
+ return null;
+
+ if( entry.isCurrent(now) == false )
+ { // Try to refresh the entry
+ if( entry.refresh() == false )
+ { // Failed, remove the entry and return null
+ entry.destroy();
+ entryMap.remove(key);
+ return null;
+ }
+ }
+ Object value = entry.getValue();
+ return value;
+ }
+ /** Get the cache value for key. This method does not check to see if
+ the entry has expired.
+ @returns the TimedEntry value or the original value if it was not an
+ instancee of TimedEntry if key is in the cache, null otherwise.
+ */
+ public Object peek(Object key)
+ {
+ TimedEntry entry = (TimedEntry) entryMap.get(key);
+ Object value = null;
+ if( entry != null )
+ value = entry.getValue();
+ return value;
+ }
+ /** Insert a value into the cache. In order to have the cache entry
+ reshresh itself value would have to implement TimedEntry and
+ implement the required refresh() method logic.
+ @param key, the key for the cache entry
+ @param value, Either an instance of TimedEntry that will be inserted without
+ change, or an abitrary value that will be wrapped in a non-refreshing
+ TimedEntry.
+ */
+ public void insert(Object key, Object value)
+ {
+ if( entryMap.containsKey(key) )
+ throw new IllegalStateException("Attempt to insert duplicate entry");
+ TimedEntry entry = null;
+ if( (value instanceof TimedEntry) == false )
+ { // Wrap the value in a DefaultTimedEntry
+ entry = new DefaultTimedEntry(defaultLifetime, value);
+ }
+ else
+ {
+ entry = (TimedEntry) value;
+ }
+ entry.init(now);
+ entryMap.put(key, entry);
+ }
+ /** Remove the entry associated with key and call destroy on the entry
+ if found.
+ */
+ public void remove(Object key)
+ {
+ TimedEntry entry = (TimedEntry) entryMap.remove(key);
+ if( entry != null )
+ entry.destroy();
+ }
+ /** Remove all entries from the cache.
+ */
+ public void flush()
+ {
+ Map tmpMap = null;
+ synchronized( this )
+ {
+ tmpMap = entryMap;
+ if( threadSafe )
+ entryMap = Collections.synchronizedMap(new HashMap());
+ else
+ entryMap = new HashMap();
+ }
+
+ // Notify the entries of their removal
+ Iterator iter = tmpMap.values().iterator();
+ while( iter.hasNext() )
+ {
+ TimedEntry entry = (TimedEntry) iter.next();
+ entry.destroy();
+ }
+ tmpMap.clear();
+ }
+
+ public int size()
+ {
+ return entryMap.size();
+ }
+ // --- End CachePolicy interface methods
+
+ /** Get the list of keys for entries that are not expired.
+ *
+ * @return A List of the keys corresponding to valid entries
+ */
+ public List getValidKeys()
+ {
+ ArrayList validKeys = new ArrayList();
+ synchronized( entryMap )
+ {
+ Iterator iter = entryMap.entrySet().iterator();
+ while( iter.hasNext() )
+ {
+ Map.Entry entry = (Map.Entry) iter.next();
+ TimedEntry value = (TimedEntry) entry.getValue();
+ if( value.isCurrent(now) == true )
+ validKeys.add(entry.getKey());
+ }
+ }
+ return validKeys;
+ }
+
+ /** Get the default lifetime of cache entries.
+ @return default lifetime in seconds of cache entries.
+ */
+ public int getDefaultLifetime()
+ {
+ return defaultLifetime;
+ }
+ /** Set the default lifetime of cache entries for new values added to the cache.
+ @param defaultLifetime, lifetime in seconds of cache values that do
+ not implement TimedEntry.
+ */
+ public void setDefaultLifetime(int defaultLifetime)
+ {
+ this.defaultLifetime = defaultLifetime;
+ }
+
+ /** The TimerTask run method. It updates the cache time to the
+ current system time.
+ */
+ public void run()
+ {
+ now = System.currentTimeMillis();
+ }
+
+ /** Get the cache time.
+ @return the cache time last obtained from System.currentTimeMillis()
+ */
+ public long currentTimeMillis()
+ {
+ return now;
+ }
+
+ /** Get the raw TimedEntry for key without performing any expiration check.
+ @return the TimedEntry value associated with key if one exists, null otherwise.
+ */
+ public TimedEntry peekEntry(Object key)
+ {
+ TimedEntry entry = (TimedEntry) entryMap.get(key);
+ return entry;
+ }
+
+ /** The default implementation of TimedEntry used to wrap non-TimedEntry
+ objects inserted into the cache.
+ */
+ static class DefaultTimedEntry implements TimedEntry
+ {
+ long expirationTime;
+ Object value;
+
+ DefaultTimedEntry(long lifetime, Object value)
+ {
+ this.expirationTime = 1000 * lifetime;
+ this.value = value;
+ }
+ public void init(long now)
+ {
+ expirationTime += now;
+ }
+ public boolean isCurrent(long now)
+ {
+ return expirationTime > now;
+ }
+ public boolean refresh()
+ {
+ return false;
+ }
+ public void destroy()
+ {
+ }
+ public Object getValue()
+ {
+ return value;
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimedCachePolicy.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimerQueue.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimerQueue.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimerQueue.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,183 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.util;
+
+/**
+ * This class runs in a single thread {@link TimerTask}s that have been
+ * scheduled. <p>
+ * A similar class is present in java.util package of jdk version >= 1.3;
+ * for compatibility with jdk 1.2 it is reimplemented here.
+ *
+ * @see TimerTask
+ * @author <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
+ * @version $Revision$
+ */
+public class TimerQueue
+ extends WorkerQueue
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+ /* This member is accessed only from putJob and getJob, that will
+ then guarantee necessary synchronization on it */
+ private Heap m_heap;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ /**
+ * Creates a new timer queue with default thread name of "TimerTask Thread"
+ */
+ public TimerQueue()
+ {
+ this("TimerTask Thread");
+ }
+ /**
+ * Creates a new timer queue with the specified thread name
+ */
+ public TimerQueue(String threadName)
+ {
+ super(threadName);
+ m_heap = new Heap();
+ }
+
+ // Public --------------------------------------------------------
+ /**
+ * Schedules the given TimerTask for immediate execution.
+ */
+ public void schedule(TimerTask t)
+ {
+ schedule(t, 0);
+ }
+ /**
+ * Schedule the given TimerTask to be executed after <code>delay</code>
+ * milliseconds.
+ */
+ public void schedule(TimerTask t, long delay)
+ {
+ if (t == null) throw new IllegalArgumentException("Can't schedule a null TimerTask");
+ if (delay < 0) delay = 0;
+ t.setNextExecutionTime(System.currentTimeMillis() + delay);
+ putJob(t);
+ }
+
+ // Z implementation ----------------------------------------------
+
+ // WorkerQueue overrides ---------------------------------------------------
+ protected void putJobImpl(Executable task)
+ {
+ m_heap.insert(task);
+ ((TimerTask)task).setState(TimerTask.SCHEDULED);
+ notifyAll();
+ }
+ protected Executable getJobImpl() throws InterruptedException
+ {
+ while (m_heap.peek() == null)
+ {
+ wait();
+ }
+ TimerTask task = (TimerTask)m_heap.extract();
+ switch (task.getState())
+ {
+ case TimerTask.CANCELLED:
+ case TimerTask.EXECUTED:
+ //don't hold onto last dead task if we wait.
+ task = null;
+ return getJobImpl();
+ case TimerTask.NEW:
+ case TimerTask.SCHEDULED:
+ return task;
+ default:
+ throw new IllegalStateException("TimerTask has an illegal state");
+ }
+ }
+ protected Runnable createQueueLoop()
+ {
+ return new TimerTaskLoop();
+ }
+ protected void clear()
+ {
+ super.clear();
+ synchronized (this)
+ {
+ m_heap.clear();
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+ /**
+ * Class that loops getting the next job to be executed and then
+ * executing it, in the timer task thread.
+ */
+ protected class TimerTaskLoop implements Runnable
+ {
+ public void run()
+ {
+ try
+ {
+ while (true)
+ {
+ try
+ {
+ // Wait for the first job
+ TimerTask task = (TimerTask)getJob();
+ long now = System.currentTimeMillis();
+ long executionTime = task.getNextExecutionTime();
+ long timeToWait = executionTime - now;
+ boolean runTask = timeToWait <= 0;
+ if (!runTask)
+ {
+ // Entering here when a new job is scheduled but
+ // it's not yet time to run the first one;
+ // the job was extracted from the heap, reschedule
+ putJob(task);
+ Object mutex = TimerQueue.this;
+ synchronized (mutex)
+ {
+ // timeToWait is always strictly > 0, so I don't wait forever
+ mutex.wait(timeToWait);
+ }
+ }
+ else
+ {
+ if (task.isPeriodic())
+ {
+ // Reschedule with the new time
+ task.setNextExecutionTime(executionTime + task.getPeriod());
+ putJob(task);
+ }
+ else
+ {
+ // The one-shot task is already removed from
+ // the heap, mark it as executed
+ task.setState(TimerTask.EXECUTED);
+ }
+ // Run it !
+ task.execute();
+ }
+ }
+ catch (InterruptedException x)
+ {
+ // Exit the thread
+ break;
+ }
+ catch (Exception e)
+ {
+ ThrowableHandler.add(ThrowableHandler.Type.ERROR, e);
+ }
+ }
+ }
+ finally {clear();}
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimerQueue.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimerTask.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimerTask.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimerTask.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,174 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util;
+
+/**
+ * A class that represent a task that can be scheduled for one-shot or
+ * repeated execution by a {@link TimerQueue}. <p>
+ * A similar class is present in java.util package of jdk version >= 1.3;
+ * for compatibility with jdk 1.2 we reimplemented it.
+ *
+ * @see TimerQueue
+ *
+ * @author <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
+ * @version $Revision$
+ */
+public abstract class TimerTask
+ implements Executable, Comparable
+{
+ /** The state before the first execution */
+ static final int NEW = 1;
+ /** The state after first execution if the TimerTask is repeating */
+ static final int SCHEDULED = 2;
+ /** The state after first execution if the TimerTask is not repeating */
+ static final int EXECUTED = 3;
+ /** The state when cancelled */
+ static final int CANCELLED = 4;
+
+ // Attributes ----------------------------------------------------
+ private final Object m_lock = new Object();
+ private int m_state;
+ private long m_period;
+ private long m_nextExecutionTime;
+
+ /**
+ * Creates a TimerTask object that will be executed once.
+ */
+ protected TimerTask()
+ {
+ setState(NEW);
+ m_period = 0;
+ m_nextExecutionTime = 0;
+ }
+
+ /**
+ * Creates a TimerTask object that will be executed every <code>period</code>
+ * milliseconds. <p>
+ * @param period the execution period; if zero, will be executed only once.
+ */
+ protected TimerTask(long period)
+ {
+ this();
+ if (period < 0) throw new IllegalArgumentException("Period can't be negative");
+ m_period = period;
+ }
+
+ /**
+ * Cancels the next execution of this TimerTask (if any). <br>
+ * If the TimerTask is executing it will prevent the next execution (if any).
+ * @returns true if one or more scheduled execution will not take place,
+ * false otherwise.
+ */
+ public boolean cancel()
+ {
+ synchronized (getLock())
+ {
+ boolean ret = (getState() == SCHEDULED);
+ setState(CANCELLED);
+ return ret;
+ }
+ }
+
+ // Executable implementation ---------------------------------------
+
+ /**
+ * The task to be executed, to be implemented in subclasses.
+ */
+ public abstract void execute() throws Exception;
+
+ // Comparable implementation ---------------------------------------
+
+ /**
+ * A TimerTask is less than another if it will be scheduled before.
+ */
+ public int compareTo(Object other)
+ {
+ if (!(other instanceof TimerTask))
+ throw new IllegalArgumentException("Can't compare a TimerTask with something else");
+ if (other == this) return 0;
+ // Avoid deadlock
+ TimerTask one = this;
+ TimerTask two = (TimerTask)other;
+ boolean swapped = false;
+ if (one.hashCode() > two.hashCode())
+ {
+ one = two;
+ two = this;
+ swapped = true;
+ }
+ synchronized (one)
+ {
+ synchronized (two)
+ {
+ int res = (int)(one.getNextExecutionTime() - two.getNextExecutionTime());
+ if (swapped) {return -res;}
+ else {return res;}
+ }
+ }
+ }
+
+ /** Returns the mutex that syncs the access to this object */
+ Object getLock()
+ {
+ return m_lock;
+ }
+
+ /** Sets the state of execution of this TimerTask */
+ void setState(int state)
+ {
+ synchronized (getLock())
+ {
+ m_state = state;
+ }
+ }
+
+ /** Returns the state of execution of this TimerTask */
+ int getState()
+ {
+ synchronized (getLock())
+ {
+ return m_state;
+ }
+ }
+
+ /** Returns whether this TimerTask is periodic */
+ boolean isPeriodic()
+ {
+ synchronized (getLock())
+ {
+ return m_period > 0;
+ }
+ }
+
+ /** Returns the next execution time for this TimerTask */
+ long getNextExecutionTime()
+ {
+ synchronized (getLock())
+ {
+ return m_nextExecutionTime;
+ }
+ }
+
+ /** Sets the next execution time for this TimerTask */
+ void setNextExecutionTime(long time)
+ {
+ synchronized (getLock())
+ {
+ m_nextExecutionTime = time;
+ }
+ }
+
+ /** Returns the period of this TimerTask */
+ protected long getPeriod()
+ {
+ synchronized (getLock())
+ {
+ return m_period;
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/TimerTask.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/UnexpectedThrowable.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/UnexpectedThrowable.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/UnexpectedThrowable.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,60 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * Thrown to indicate that a Throwable was caught but was not expected.
+ * This is typical when catching Throwables to handle and rethrow Exceptions
+ * and Errors.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class UnexpectedThrowable
+ extends NestedError
+{
+ /**
+ * Construct a <tt>UnexpectedThrowable</tt> with the specified
+ * detail message.
+ *
+ * @param msg Detail message.
+ */
+ public UnexpectedThrowable(final String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>UnexpectedThrowable</tt> with the specified
+ * detail message and nested <tt>Throwable</tt>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public UnexpectedThrowable(final String msg, final Throwable nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Construct a <tt>UnexpectedThrowable</tt> with the specified
+ * nested <tt>Throwable</tt>.
+ *
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public UnexpectedThrowable(final Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Construct a <tt>UnexpectedThrowable</tt> with no detail.
+ */
+ public UnexpectedThrowable() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/UnexpectedThrowable.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/UnreachableStatementException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/UnreachableStatementException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/UnreachableStatementException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,37 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+/**
+ * Thrown to indicate that section of code that should never have been
+ * reachable, has just been reached.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class UnreachableStatementException
+ extends RuntimeException
+{
+ /**
+ * Construct a <tt>UnreachableStatementException</tt> with a detail message.
+ *
+ * @param msg Detail message.
+ */
+ public UnreachableStatementException(final String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>UnreachableStatementException</tt> with no detail.
+ */
+ public UnreachableStatementException() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/UnreachableStatementException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WaitSemaphore.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WaitSemaphore.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WaitSemaphore.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util;
+
+/**
+ * Wait exclusive semaphore with wait - notify primitives
+ *
+ * @author <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
+ * @version $Revision$
+ */
+public class WaitSemaphore
+ extends Semaphore
+ implements WaitSync
+{
+ // Constants -----------------------------------------------------
+ private final static int MAX_USERS_ALLOWED = 1;
+
+ // Attributes ----------------------------------------------------
+ private int m_waiters;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+ public WaitSemaphore()
+ {
+ super(MAX_USERS_ALLOWED);
+ }
+
+ // Public --------------------------------------------------------
+ public void doWait() throws InterruptedException
+ {
+ synchronized (this)
+ {
+ release();
+ ++m_waiters;
+ waitImpl(this);
+ --m_waiters;
+ acquire();
+ }
+ }
+
+ public void doNotify() throws InterruptedException
+ {
+ synchronized (this)
+ {
+ if (getWaiters() > 0)
+ {
+ acquire();
+ notify();
+ release();
+ }
+ }
+ }
+
+ public int getWaiters()
+ {
+ synchronized (this)
+ {
+ return m_waiters;
+ }
+ }
+
+ // Object overrides ---------------------------------------------------
+ public String toString()
+ {
+ return super.toString() + " - " + m_waiters;
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WaitSemaphore.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WaitSync.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WaitSync.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WaitSync.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util;
+
+/**
+ * Interface that gives wait - notify primitives to implementors.
+ *
+ * @see Semaphore
+ *
+ * @author <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
+ * @version $Revision$
+ */
+public interface WaitSync
+ extends Sync
+{
+ /**
+ * Pone in wait status this sync, until {@link #doNotify} is called to wake it up.
+ *
+ * @see #doNotify
+ */
+ void doWait() throws InterruptedException;
+
+ /**
+ * Wakes up this sync that has been posed in wait status by a {@link #doWait} call.
+ * If this sync is not waiting, invoking this method should have no effect.
+ * @see #doWait
+ */
+ void doNotify() throws InterruptedException;
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WaitSync.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WeakObject.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WeakObject.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WeakObject.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,111 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util;
+
+import java.lang.ref.WeakReference;
+import java.lang.ref.ReferenceQueue;
+
+/**
+ * Convenience class to wrap an <tt>Object</tt> into a <tt>WeakReference</tt>.
+ *
+ * <p>Modified from <tt>java.util.WeakHashMap.WeakKey</tt>.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class WeakObject
+ extends WeakReference
+{
+ /** The hash code of the nested object */
+ protected final int hashCode;
+
+ /**
+ * Construct a <tt>WeakObject</tt>.
+ *
+ * @param obj Object to reference.
+ */
+ public WeakObject(final Object obj) {
+ super(obj);
+ hashCode = obj.hashCode();
+ }
+
+ /**
+ * Construct a <tt>WeakObject</tt>.
+ *
+ * @param obj Object to reference.
+ * @param queue Reference queue.
+ */
+ public WeakObject(final Object obj, final ReferenceQueue queue) {
+ super(obj, queue);
+ hashCode = obj.hashCode();
+ }
+
+ /**
+ * Check the equality of an object with this.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ WeakObject soft = (WeakObject)obj;
+
+ Object a = this.get();
+ Object b = soft.get();
+ if (a == null || b == null) return false;
+ if (a == b) return true;
+
+ return a.equals(b);
+ }
+
+ return false;
+ }
+
+ /**
+ * Return the hash code of the nested object.
+ *
+ * @return The hash code of the nested object.
+ */
+ public int hashCode() {
+ return hashCode;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Factory Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Create a <tt>WeakObject</tt> for the given object.
+ *
+ * @param obj Object to reference.
+ * @return <tt>WeakObject</tt> or <tt>null</tt> if object is null.
+ */
+ public static WeakObject create(final Object obj) {
+ if (obj == null) return null;
+ else return new WeakObject(obj);
+ }
+
+ /**
+ * Create a <tt>WeakObject</tt> for the given object.
+ *
+ * @param obj Object to reference.
+ * @param queue Reference queue.
+ * @return <tt>WeakObject</tt> or <tt>null</tt> if object is null.
+ */
+ public static WeakObject create(final Object obj,
+ final ReferenceQueue queue)
+ {
+ if (obj == null) return null;
+ else return new WeakObject(obj, queue);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WeakObject.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WorkerQueue.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WorkerQueue.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WorkerQueue.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,247 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.util;
+
+/**
+ * Class that queues {@link Executable} jobs that are executed sequentially
+ * by a single thread.
+ *
+ * @see Executable
+ *
+ * @author <a href="mailto:simone.bordet at compaq.com">Simone Bordet</a>
+ * @version $Revision$
+ */
+public class WorkerQueue
+{
+ /** The thread that runs the Executable jobs */
+ protected Thread m_queueThread;
+
+ /** The job that will be executed by the worker thread */
+ private JobItem m_currentJob;
+
+ /**
+ * Creates a new worker queue with default thread name of "Worker Thread"
+ */
+ public WorkerQueue()
+ {
+ this("Worker Thread");
+ }
+
+ /**
+ * Creates a new worker queue with the specified thread name
+ */
+ public WorkerQueue(String threadName)
+ {
+ m_queueThread = new Thread(createQueueLoop(), threadName);
+ }
+
+ /**
+ * Creates a new worker queue with the specified thread name
+ * and daemon mode flag
+ */
+ public WorkerQueue(String threadName, boolean isDaemon)
+ {
+ m_queueThread = new Thread(createQueueLoop(), threadName);
+ m_queueThread.setDaemon(isDaemon);
+ }
+
+ /**
+ * Starts the worker queue.
+ * @see #stop
+ */
+ public void start()
+ {
+ if (m_queueThread != null) {m_queueThread.start();}
+ }
+
+ /**
+ * Stops nicely the worker queue. <br>
+ * After this call trying to put a new job will result in a
+ * InterruptedException to be thrown. The jobs queued before and not
+ * yet processed are processed until the queue is empty, then this
+ * worker queue is cleared.
+ * @see #clear
+ * @see #start
+ * @see #isInterrupted
+ */
+ public synchronized void stop()
+ {
+ if (m_queueThread != null) {m_queueThread.interrupt();}
+ }
+
+ /**
+ * Called by a thread that is not the WorkerQueue thread, this method
+ * queues the job and, if necessary, wakes up this worker queue that is
+ * waiting in {@link #getJob}.
+ */
+ public synchronized void putJob(Executable job)
+ {
+ // Preconditions
+ if (m_queueThread == null || !m_queueThread.isAlive()) {
+ throw new IllegalStateException("Can't put job, thread is not alive or not present");
+ }
+
+ if (isInterrupted()) {
+ throw new IllegalStateException("Can't put job, thread was interrupted");
+ }
+
+ putJobImpl(job);
+ }
+
+ /**
+ * Returns whether the worker thread has been interrupted. <br>
+ * When this method returns true, it is not possible to put new jobs in the
+ * queue and the already present jobs are executed and removed from the
+ * queue, then the thread exits.
+ *
+ * @see #stop
+ */
+ protected boolean isInterrupted()
+ {
+ return m_queueThread.isInterrupted();
+ }
+
+ /**
+ * Called by this class, this method checks if the queue is empty;
+ * if it is, then waits, else returns the current job.
+ *
+ * @see #putJob
+ */
+ protected synchronized Executable getJob() throws InterruptedException
+ {
+ // Preconditions
+ if (m_queueThread == null || !m_queueThread.isAlive()) {
+ throw new IllegalStateException();
+ }
+
+ return getJobImpl();
+ }
+
+ /**
+ * Never call this method, only override in subclasses to perform
+ * job getting in a specific way, normally tied to the data structure
+ * holding the jobs.
+ */
+ protected Executable getJobImpl() throws InterruptedException
+ {
+ // While the queue is empty, wait();
+ // when notified take an event from the queue and return it.
+ while (m_currentJob == null) {wait();}
+ // This one is the job to return
+ JobItem item = m_currentJob;
+ // Go on to the next object for the next call.
+ m_currentJob = m_currentJob.m_next;
+ return item.m_job;
+ }
+
+ /**
+ * Never call this method, only override in subclasses to perform
+ * job adding in a specific way, normally tied to the data structure
+ * holding the jobs.
+ */
+ protected void putJobImpl(Executable job)
+ {
+ JobItem posted = new JobItem(job);
+ if (m_currentJob == null)
+ {
+ // The queue is empty, set the current job to process and
+ // wake up the thread waiting in method getJob
+ m_currentJob = posted;
+ notifyAll();
+ }
+ else
+ {
+ JobItem item = m_currentJob;
+ // The queue is not empty, find the end of the queue ad add the
+ // posted job at the end
+ while (item.m_next != null) {item = item.m_next;}
+ item.m_next = posted;
+ }
+ }
+
+ /**
+ * Clears the running thread after the queue has been stopped. <br>
+ * After this call, this worker queue is unusable and can be garbaged.
+ */
+ protected void clear()
+ {
+ m_queueThread = null;
+ m_currentJob = null;
+ }
+
+ /**
+ * Creates the loop that will get the next job and process it. <br>
+ * Override in subclasses to create a custom loop.
+ */
+ protected Runnable createQueueLoop() {
+ return new QueueLoop();
+ }
+
+ /**
+ * Class that loops getting the next job to be executed and then
+ * executing it, in the worker thread.
+ */
+ protected class QueueLoop
+ implements Runnable
+ {
+ public void run()
+ {
+ try
+ {
+ while (true)
+ {
+ try
+ {
+ if (isInterrupted())
+ {
+ flush();
+ break;
+ }
+ else
+ {
+ getJob().execute();
+ }
+ }
+ catch (InterruptedException e)
+ {
+ try {
+ flush();
+ }
+ catch (Exception ignored) {}
+ break;
+ }
+ catch (Exception e) {
+ ThrowableHandler.add(ThrowableHandler.Type.ERROR, e);
+ }
+ }
+ }
+ finally {
+ clear();
+ }
+ }
+
+ protected void flush() throws Exception
+ {
+ // Empty the queue of the posted jobs and exit
+ while (m_currentJob != null)
+ {
+ m_currentJob.m_job.execute();
+ m_currentJob = m_currentJob.m_next;
+ }
+ }
+ }
+
+ /**
+ * Simple linked cell, that has only a reference to the next job.
+ */
+ private class JobItem
+ {
+ private Executable m_job;
+ private JobItem m_next;
+ private JobItem(Executable job) {m_job = job;}
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/WorkerQueue.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/BoundCoercionHandler.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/BoundCoercionHandler.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/BoundCoercionHandler.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,27 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.coerce;
+
+/**
+ * A bound CoersionHandler, which is bound to a specific class type.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class BoundCoercionHandler
+ extends CoercionHandler
+{
+ /**
+ * Get the target class type for this CoercionHandler.
+ *
+ * @return Class type
+ */
+ public abstract Class getType();
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/BoundCoercionHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/CharacterHandler.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/CharacterHandler.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/CharacterHandler.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,68 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.coerce;
+
+import org.jboss.util.CoercionException;
+import org.jboss.util.NotCoercibleException;
+
+/**
+ * A Character coercion handler.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class CharacterHandler
+ extends BoundCoercionHandler
+{
+ /**
+ * Get the target class type for this CoercionHandler.
+ *
+ * @return Class type
+ */
+ public Class getType() {
+ return Character.class;
+ }
+
+ /**
+ * Coerces the given value into the given type (which should be
+ * Character.class).
+ *
+ * <p>This currently only support coercion from a String.
+ *
+ * @param value Value to coerce
+ * @param type Character.class
+ * @return Value coerced into a Character
+ *
+ * @throws CoercionException Failed to coerce
+ */
+ public Object coerce(Object value, Class type) throws CoercionException {
+ if (value.getClass().equals(String.class)) {
+ return coerce((String)value);
+ }
+
+ throw new NotCoercibleException(value);
+ }
+
+ /**
+ * Coerces the given string into a Character, by taking off the first
+ * index of the string and wrapping it.
+ *
+ * @param value String value to convert to a Character
+ * @return Character value or null if the string is empty.
+ */
+ public Object coerce(String value) {
+ char[] temp = value.toCharArray();
+ if (temp.length == 0) {
+ return null;
+ }
+ return new Character(temp[0]);
+ }
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/CharacterHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/ClassHandler.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/ClassHandler.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/ClassHandler.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,71 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.coerce;
+
+import org.jboss.util.CoercionException;
+import org.jboss.util.NotCoercibleException;
+
+/**
+ * A <tt>java.lang.Class</tt> coercion handler.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ClassHandler
+ extends BoundCoercionHandler
+{
+ /**
+ * Get the target class type for this <tt>CoercionHandler</tt>.
+ *
+ * @return Class type.
+ */
+ public Class getType() {
+ return Class.class;
+ }
+
+ /**
+ * Coerces the given value into the given type (which should be
+ * <tt>Class</tt>).
+ *
+ * <p>This currently only support coercion from a <tt>String</tt>.
+ *
+ * @param value Value to coerce.
+ * @param type <tt>java.lang.Class</tt>.
+ * @return Value coerced into a <tt>Class</tt>.
+ *
+ * @throws CoercionException Failed to coerce.
+ */
+ public Object coerce(Object value, Class type) throws CoercionException {
+ if (value.getClass().equals(String.class)) {
+ return coerce((String)value);
+ }
+
+ throw new NotCoercibleException(value);
+ }
+
+ /**
+ * Coerces the given String into a <tt>Class</tt> by doing a
+ * <code>Class.forName()</code>.
+ *
+ * @param value String value to convert to a <tt>Class</tt>.
+ * @return <tt>Class</tt> value.
+ *
+ * @throws NotCoercibleException Class not found.
+ */
+ public Object coerce(String value) {
+ try {
+ return Class.forName(value);
+ }
+ catch (ClassNotFoundException e) {
+ throw new NotCoercibleException(value, e);
+ }
+ }
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/ClassHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/CoercionHandler.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/CoercionHandler.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/CoercionHandler.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,161 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.coerce;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+
+import org.jboss.util.CoercionException;
+import org.jboss.util.NotCoercibleException;
+import org.jboss.util.NullArgumentException;
+import org.jboss.util.NotImplementedException;
+
+/**
+ * An abstract class to allow extending the default behavior of
+ * {@link org.jboss.util.Objects#coerce(Object,Class)} when it is
+ * not possible to implement {@link org.jboss.util.Coercible}
+ * directly in the target class or where coercion is desired from
+ * an unrelated class. Also provides a registry for all of the
+ * currently installed handlers.
+ *
+ * @todo Implement a URL package handler style method for finding
+ * handlers as well as the current explict methods.
+ * @todo Add URL handler.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class CoercionHandler
+{
+ /**
+ * Coerce the given value into the specified type.
+ *
+ * @param value Value to coerce
+ * @param type Object type to coerce into
+ * @return Coerced value
+ *
+ * @exception CoercionException Failed to coerce
+ */
+ public abstract Object coerce(Object value, Class type)
+ throws CoercionException;
+
+ /**
+ * Get the target class type for this CoercionHandler.
+ *
+ * @return Class type
+ *
+ * @throws NotImplementedException Handler is not bound
+ */
+ public Class getType() {
+ throw new NotImplementedException("handler is not bound");
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Factory Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /** Class -> CoercionHandler map */
+ private static Map handlers = Collections.synchronizedMap(new HashMap());
+
+ /** Initializes the CoercionHandler map */
+ static {
+ // initialzie the helper map with some defaults
+ install(new CharacterHandler());
+ install(new ClassHandler());
+ install(new FileHandler());
+ }
+
+ /**
+ * Install a CoercionHandler for a given class type.
+ *
+ * @param handler Coercion handler
+ *
+ * @throws NullArgumentException type or handler
+ */
+ public static void install(Class type, CoercionHandler handler) {
+ if (type == null)
+ throw new NullArgumentException("type");
+ if (handler == null)
+ throw new NullArgumentException("handler");
+
+ handlers.put(type, handler);
+ }
+
+ /**
+ * Install a BoundCoercionHandler.
+ *
+ * @param handler Bound coercion handler
+ *
+ * @throws NullArgumentException handler
+ */
+ public static void install(BoundCoercionHandler handler) {
+ if (handler == null)
+ throw new NullArgumentException("handler");
+
+ handlers.put(handler.getType(), handler);
+ }
+
+ /**
+ * Uninstall a CoercionHandler for a given class type.
+ *
+ * @param type Class type
+ *
+ * @throws NullArgumentException type
+ */
+ public static void uninstall(Class type) {
+ if (type == null)
+ throw new NullArgumentException("type");
+
+ handlers.remove(type);
+ }
+
+ /**
+ * Check if there is a CoercionHandler installed for the given class.
+ *
+ * @param type Class type
+ * @return True if there is a CoercionHandler
+ */
+ public static boolean isInstalled(Class type) {
+ return handlers.containsKey(type);
+ }
+
+ /**
+ * Lookup the CoercionHandler for a given class.
+ *
+ * @param type Class type
+ * @return A CoercionHandler or null if there is no installed handler
+ *
+ * @throws NullArgumentException type
+ */
+ public static CoercionHandler lookup(Class type) {
+ if (type == null)
+ throw new NullArgumentException("type");
+
+ return (CoercionHandler)handlers.get(type);
+ }
+
+ /**
+ * Create a CoercionHandler for the given class type.
+ *
+ * @param type Class type
+ * @return A CoercionHandler instance for the given class type.
+ *
+ * @throws CoercionException No installed handler for type
+ */
+ public static CoercionHandler create(Class type) {
+ CoercionHandler handler = lookup(type);
+ if (handler == null)
+ throw new CoercionException
+ ("no installed handler for type: " + type);
+
+ return handler;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/CoercionHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/FileHandler.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/FileHandler.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/FileHandler.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,68 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.coerce;
+
+import org.jboss.util.CoercionException;
+import org.jboss.util.NotCoercibleException;
+
+import java.io.File;
+
+/**
+ * A <tt>java.io.File</tt> coercion handler.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FileHandler
+ extends BoundCoercionHandler
+{
+ /**
+ * Get the target class type for this <tt>CoercionHandler</tt>.
+ *
+ * @return <tt>Class</tt> type.
+ */
+ public Class getType() {
+ return File.class;
+ }
+
+ /**
+ * Coerces the given value into the given type (which should be
+ * <tt>File</tt>).
+ *
+ * <p>This currently only support coercion from a <tt>String</tt>
+ *
+ * @param value Value to coerce.
+ * @param type <tt>File</tt>.
+ * @return Value coerced into a <tt>File</tt>.
+ *
+ * @throws CoercionException Failed to coerce.
+ */
+ public Object coerce(Object value, Class type) throws CoercionException {
+ if (value.getClass().equals(String.class)) {
+ return coerce((String)value);
+ }
+
+ throw new NotCoercibleException(value);
+ }
+
+ /**
+ * Coerces the given String into a <tt>File</tt> by creating attempting
+ * to create a new file for the given filename.
+ *
+ * @param value The name of the file to create.
+ * @return <tt>File</tt>
+ *
+ * @throws NotCoercibleException Failed to create file.
+ */
+ public Object coerce(String value) {
+ return new File(value);
+ }
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/FileHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Object coercion helper classes.</p>
+
+ <p>Classes contained here are used internaly by the
+ <code>planet57.util.Objects</code> class, and are probably
+ not very very useful outside of that scope.<p>
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>Change the handler loading mechanism to be more like a protocol
+ handler.
+ <li>Add more handlers
+ <ul>
+ <li>File handler
+ </ul>
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/coerce/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/AbstractQueue.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/AbstractQueue.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/AbstractQueue.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,147 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.util.AbstractCollection;
+
+/**
+ * An abstract implementation of a Queue. Sub-classes must provide methods
+ * for <code>addLast(Object)</code> and <code>removeFirst()</code>.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class AbstractQueue
+ extends AbstractCollection
+ implements Queue
+{
+ /** Default maximum queue size */
+ public static int DEFAULT_MAXIMUM_SIZE = UNLIMITED_MAXIMUM_SIZE;
+
+ /** Maximum queue size */
+ protected int maximumSize = DEFAULT_MAXIMUM_SIZE;
+
+ /**
+ * Initializes the AbstractQueue.
+ */
+ protected AbstractQueue() {}
+
+ /**
+ * Initializes the AbstractQueue.
+ *
+ * @param maxSize Maximum queue size.
+ *
+ * @exception IllegalArgumentException Illegal size.
+ */
+ protected AbstractQueue(final int maxSize) {
+ setMaximumSize(maxSize);
+ }
+
+ /**
+ * Get the maximum size of the queue.
+ *
+ * @return Maximum queue size or {@link #UNLIMITED_MAXIMUM_SIZE}.
+ */
+ public int getMaximumSize() {
+ return maximumSize;
+ }
+
+ /**
+ * Set the maximum size of the queue
+ *
+ * @param size New maximim queue size or {@link #UNLIMITED_MAXIMUM_SIZE}.
+ *
+ * @exception IllegalArgumentException Illegal size.
+ */
+ public void setMaximumSize(final int size) {
+ if (size < 0 && size != UNLIMITED_MAXIMUM_SIZE)
+ throw new IllegalArgumentException("illegal size: " + size);
+
+ maximumSize = size;
+ }
+
+ /**
+ * Check if the queue is full.
+ *
+ * @return True if the queue is full.
+ */
+ public boolean isFull() {
+ if (maximumSize != UNLIMITED_MAXIMUM_SIZE && size() >= maximumSize)
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Check if the queue is empty.
+ *
+ * @return True if the queue is empty.
+ */
+ public boolean isEmpty() {
+ if (size() <= 0)
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Append and object to the underling list.
+ *
+ * @param obj Object to enqueue.
+ * @return True if collection was modified.
+ *
+ * @exception FullCollectionException The queue is full.
+ */
+ public boolean add(Object obj) throws FullCollectionException {
+ if (isFull())
+ throw new FullCollectionException();
+
+ return addLast(obj);
+ }
+
+ /**
+ * Remove and return the first object in the queue.
+ *
+ * @return Dequeued object.
+ *
+ * @exception EmptyCollectionException The queue is empty.
+ */
+ public Object remove() throws EmptyCollectionException {
+ if (isEmpty())
+ throw new EmptyCollectionException();
+
+ return removeFirst();
+ }
+
+ /**
+ * Removes all of the elements from this queue
+ */
+ public void clear() {
+ while (!isEmpty()) {
+ remove();
+ }
+ }
+
+ /**
+ * Appends the given element to the end of the queue
+ *
+ * @param obj Object to append
+ * @return Per Collection.add(), we return a boolean to indicate if
+ * the object modified the collection.
+ */
+ protected abstract boolean addLast(Object obj);
+
+ /**
+ * Remove the first object in the queue
+ *
+ * @return First object in the queue
+ */
+ protected abstract Object removeFirst();
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/AbstractQueue.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ArrayIterator.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ArrayIterator.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ArrayIterator.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,91 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import java.io.Serializable;
+
+import org.jboss.util.NullArgumentException;
+
+/**
+ * An array iterator.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ArrayIterator
+ implements Iterator, Serializable, Cloneable
+{
+ /** Array to iterate over. */
+ protected final Object[] array;
+
+ /** The current position in the array. */
+ protected int index;
+
+ /**
+ * Construct an ArrayIterator.
+ *
+ * @param array The array to iterate over.
+ */
+ public ArrayIterator(final Object[] array) {
+ if (array == null)
+ throw new NullArgumentException("array");
+
+ this.array = array;
+ }
+
+ /**
+ * Returns true if there are more elements in the iteration.
+ *
+ * @return True if there are more elements in the iteration.
+ */
+ public boolean hasNext() {
+ return index < array.length;
+ }
+
+ /**
+ * Returns the next element in the iteration.
+ *
+ * @return The next element in the iteration.
+ *
+ * @throws NoSuchElementException The are no more elements available.
+ */
+ public Object next() {
+ if (! hasNext())
+ throw new NoSuchElementException();
+
+ return array[index++];
+ }
+
+ /**
+ * Unsupported.
+ *
+ * @throws UnsupportedOperationException
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns a shallow cloned copy of this object.
+ *
+ * @return A shallow cloned copy of this object.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ArrayIterator.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CachedCollection.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CachedCollection.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CachedCollection.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,137 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.util.Collection;
+import java.util.AbstractCollection;
+import java.util.Iterator;
+
+import java.lang.ref.ReferenceQueue;
+
+import org.jboss.util.SoftObject;
+import org.jboss.util.Objects;
+
+/**
+ * A wrapper around a <code>Collection</code> which translates added objects
+ * into {@link SoftObject} references, allowing the VM to garbage collect
+ * objects in the collection when memory is low.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class CachedCollection
+ extends AbstractCollection
+{
+ /** Reference queue */
+ protected final ReferenceQueue queue = new ReferenceQueue();
+
+ /** Wrapped collection */
+ protected final Collection collection;
+
+ /**
+ * Construct a CachedCollection.
+ *
+ * @param collection Collection to wrap.
+ */
+ public CachedCollection(final Collection collection) {
+ this.collection = collection;
+ }
+
+ /**
+ * Returns an iterator over the elements contained in this collection.
+ *
+ * @return An iterator over the elements contained in this collection.
+ */
+ public Iterator iterator() {
+ maintain();
+ return new MyIterator(collection.iterator());
+ }
+
+ /**
+ * Returns the size of the collection.
+ *
+ * @return The number of elements in the collection.
+ */
+ public int size() {
+ maintain();
+ return collection.size();
+ }
+
+ /**
+ * Add an object to the collection.
+ *
+ * @param obj Object (or <i>null</i> to add to the collection.
+ * @return True if object was added.
+ */
+ public boolean add(final Object obj) {
+ maintain();
+
+ SoftObject soft = SoftObject.create(obj, queue);
+
+ return collection.add(soft);
+ }
+
+ /**
+ * Maintains the collection by removing garbage collected objects.
+ */
+ private void maintain() {
+ SoftObject obj;
+ int count = 0;
+
+ while ((obj = (SoftObject)queue.poll()) != null) {
+ count++;
+ collection.remove(obj);
+ }
+
+ if (count != 0) {
+ // some temporary debugging fluff
+ System.err.println("vm reclaimed " + count + " objects");
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // De-Referencing Iterator //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * A dereferencing iterator.
+ */
+ private final class MyIterator
+ implements Iterator
+ {
+ private final Iterator iter;
+
+ public MyIterator(final Iterator iter) {
+ this.iter = iter;
+ }
+
+ public boolean hasNext() {
+ maintain();
+ return iter.hasNext();
+ }
+
+ private Object nextObject() {
+ Object obj = iter.next();
+
+ return Objects.deref(obj);
+ }
+
+ public Object next() {
+ maintain();
+ return nextObject();
+ }
+
+ public void remove() {
+ maintain();
+ iter.remove();
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CachedCollection.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CachedList.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CachedList.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CachedList.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,151 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.AbstractList;
+import java.util.Iterator;
+
+import java.lang.ref.ReferenceQueue;
+
+import org.jboss.util.SoftObject;
+import org.jboss.util.Objects;
+
+/**
+ * A wrapper around a <code>List</code> which translates added objects
+ * into {@link SoftObject} references, allowing the VM to garbage collect
+ * objects in the collection when memory is low.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class CachedList
+ extends AbstractList
+{
+ /** Reference queue. */
+ protected final ReferenceQueue queue = new ReferenceQueue();
+
+ /** Wrapped list. */
+ protected final List list;
+
+ /**
+ * Construct a <tt>CachedList</tt>.
+ *
+ * @param list List to wrap.
+ */
+ public CachedList(final List list) {
+ this.list = list;
+ }
+
+ /**
+ * Construct a <tt>CachedList</tt> using a <tt>LinkedList</tt> for
+ * storage.
+ */
+ public CachedList() {
+ this(new LinkedList());
+ }
+
+ /**
+ * Dereference the object at the given index.
+ */
+ private Object getObject(final int index) {
+ Object obj = list.get(index);
+
+ return Objects.deref(obj);
+ }
+
+ /**
+ * Returns the element at the specified position in this list.
+ *
+ * @param index Index of element to return.
+ * @return The element at the specified position.
+ */
+ public Object get(final int index) {
+ maintain();
+ return getObject(index);
+ }
+
+ /**
+ * Return the size of the list.
+ *
+ * @return The number of elements in the list.
+ */
+ public int size() {
+ maintain();
+ return list.size();
+ }
+
+ /**
+ * Replaces the element at the specified position in this list with the
+ * specified element.
+ *
+ * @param index Index of element to replace.
+ * @param obj Element to be stored at the specified postion.
+ * @return The previous element at the given index.
+ */
+ public Object set(final int index, final Object obj) {
+ maintain();
+
+ SoftObject soft = SoftObject.create(obj, queue);
+ soft = (SoftObject)list.set(index, soft);
+
+ return Objects.deref(soft);
+ }
+
+ /**
+ * Inserts the specified element at the specified position in this list
+ * (optional operation). Shifts the element currently at that position
+ * (if any) and any subsequent elements to the right (adds one to their
+ * indices).
+ *
+ * @param index Index at which the specified element is to be inserted.
+ * @param obj Element to be inserted.
+ */
+ public void add(final int index, final Object obj) {
+ maintain();
+
+ SoftObject soft = SoftObject.create(obj, queue);
+ list.add(index, soft);
+ }
+
+ /**
+ * Removes the element at the specified position in this list (optional
+ * operation). Shifts any subsequent elements to the left (subtracts one
+ * from their indices). Returns the element that was removed from the list.
+ *
+ * @param index The index of the element to remove.
+ * @return The element previously at the specified position.
+ */
+ public Object remove(final int index) {
+ maintain();
+
+ Object obj = list.remove(index);
+ return Objects.deref(obj);
+ }
+
+ /**
+ * Maintains the collection by removing garbage collected objects.
+ */
+ private void maintain() {
+ SoftObject obj;
+ int count = 0;
+
+ while ((obj = (SoftObject)queue.poll()) != null) {
+ count++;
+ list.remove(obj);
+ }
+
+ if (count != 0) {
+ // some temporary debugging fluff
+ System.err.println("vm reclaimed " + count + " objects");
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CachedList.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CollectionException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CollectionException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CollectionException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,37 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+/**
+ * A generic collection exception.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class CollectionException
+ extends RuntimeException
+{
+ /**
+ * Construct a <code>CollectionException</code> with the specified
+ * detail message.
+ *
+ * @param msg Detail message.
+ */
+ public CollectionException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <code>CollectionException</code> with no detail.
+ */
+ public CollectionException() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CollectionException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CompoundIterator.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CompoundIterator.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CompoundIterator.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,84 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * A compound iterator, which iterates over all of the elements in the
+ * given iterators.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class CompoundIterator
+ implements Iterator
+{
+ /** The array of iterators to iterate over. */
+ protected final Iterator iters[];
+
+ /** The index of the current iterator. */
+ protected int index;
+
+ /**
+ * Construct a CompoundIterator over the given array of iterators.
+ *
+ * @param iters Array of iterators to iterate over.
+ *
+ * @throws IllegalArgumentException Array is <kk>null</kk> or empty.
+ */
+ public CompoundIterator(final Iterator iters[]) {
+ if (iters == null || iters.length == 0)
+ throw new IllegalArgumentException("array is null or empty");
+
+ this.iters = iters;
+ }
+
+ /**
+ * Check if there are more elements.
+ *
+ * @return True if there are more elements.
+ */
+ public boolean hasNext() {
+ for (; index < iters.length; index++) {
+ if (iters[index] != null && iters[index].hasNext()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Return the next element from the current iterator.
+ *
+ * @return The next element from the current iterator.
+ *
+ * @throws NoSuchElementException There are no more elements.
+ */
+ public Object next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+
+ return iters[index].next();
+ }
+
+ /**
+ * Remove the current element from the current iterator.
+ *
+ * @throws IllegalStateException
+ * @throws UnsupportedOperationException
+ */
+ public void remove() {
+ iters[index].remove();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CompoundIterator.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CompoundKey.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CompoundKey.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CompoundKey.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,113 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.io.Serializable;
+
+import org.jboss.util.NullArgumentException;
+import org.jboss.util.Objects;
+import org.jboss.util.HashCode;
+import org.jboss.util.Strings;
+
+/**
+ * An immutable compound key class.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class CompoundKey
+ implements Serializable, Cloneable
+{
+ /** The elements of the key */
+ private final Object elements[];
+
+ /**
+ * Construct a CompoundKey.
+ *
+ * @param elements Elements of the key.
+ */
+ public CompoundKey(final Object elements[]) {
+ if (elements == null)
+ throw new NullArgumentException("elements");
+
+ this.elements = elements;
+ }
+
+ /**
+ * Construct a CompoundKey.
+ *
+ * @param a Element.
+ * @param b Element.
+ */
+ public CompoundKey(final Object a, final Object b) {
+ this(new Object[] { a, b });
+ }
+
+ /**
+ * Construct a CompoundKey.
+ *
+ * @param a Element.
+ * @param b Element.
+ * @param c Element.
+ */
+ public CompoundKey(final Object a, final Object b, final Object c) {
+ this(new Object[] { a, b, c });
+ }
+
+ /**
+ * Test the equality of an object with this.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ CompoundKey key = (CompoundKey)obj;
+
+ return Objects.equals(key.elements, elements);
+ }
+
+ return false;
+ }
+
+ /**
+ * Get the hash code of this object.
+ *
+ * @return Hash code.
+ */
+ public int hashCode() {
+ return HashCode.generate(elements);
+ }
+
+ /**
+ * Return a string representation of this object.
+ *
+ * @return A string representation of this object.
+ */
+ public String toString() {
+ return super.toString() + Strings.join(elements, "[", ",", "]");
+ }
+
+ /**
+ * Return a shallow cloned copy of this object.
+ *
+ * @return Shallow cloned copy of this object.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/CompoundKey.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/EmptyCollectionException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/EmptyCollectionException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/EmptyCollectionException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,38 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+/**
+ * Thrown to indicate that an operation can not be performed on an empty
+ * collection.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class EmptyCollectionException
+ extends CollectionException
+{
+ /**
+ * Construct a <code>EmptyCollectionException</code> with the specified
+ * detail message.
+ *
+ * @param msg Detail message.
+ */
+ public EmptyCollectionException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <code>EmptyCollectionException</code> with no detail.
+ */
+ public EmptyCollectionException() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/EmptyCollectionException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/FullCollectionException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/FullCollectionException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/FullCollectionException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,38 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+/**
+ * Thrown to indicate that an operation can not be performed on a full
+ * collection.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FullCollectionException
+ extends CollectionException
+{
+ /**
+ * Construct a <code>FullCollectionException</code> with the specified
+ * detail message.
+ *
+ * @param msg Detail message.
+ */
+ public FullCollectionException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <code>FullCollectionException</code> with no detail.
+ */
+ public FullCollectionException() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/FullCollectionException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/Iterators.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/Iterators.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/Iterators.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,293 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.util.Iterator;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+import java.util.Map;
+import java.util.HashMap;
+
+import org.jboss.util.Null;
+
+/**
+ * A collection of <code>Iterator</code> and <code>Enumeration</code>
+ * utilities.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class Iterators
+{
+ /////////////////////////////////////////////////////////////////////////
+ // Enumeration/Iterator Conversion //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * An Enumeration to Iterator wrapper.
+ */
+ private static final class Enum2Iterator
+ implements Iterator
+ {
+ private final Enumeration enum;
+
+ public Enum2Iterator(final Enumeration enum) {
+ this.enum = enum;
+ }
+
+ public boolean hasNext() {
+ return enum.hasMoreElements();
+ }
+
+ public Object next() {
+ return enum.nextElement();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("Enumerations are immutable");
+ }
+ }
+
+ /**
+ * Return an Iterator wrapper for the given Enumeration
+ *
+ * @param enum Enumeration to wrap
+ * @return Enumeration wrapped as an Iterator
+ */
+ public static Iterator forEnumeration(final Enumeration enum) {
+ return new Enum2Iterator(enum);
+ }
+
+ /**
+ * An Iterator to Enumeration wrapper class.
+ */
+ private static final class Iter2Enumeration
+ implements Enumeration
+ {
+ private final Iterator iter;
+
+ public Iter2Enumeration(final Iterator iter) {
+ this.iter = iter;
+ }
+
+ public boolean hasMoreElements() {
+ return iter.hasNext();
+ }
+
+ public Object nextElement() {
+ return iter.next();
+ }
+ }
+
+ /**
+ * Return an Enumeration for the given Iterator.
+ *
+ * @param iter Iterator to wrap.
+ * @return Enumeration wrapper.
+ */
+ public static Enumeration toEnumeration(final Iterator iter) {
+ return new Iter2Enumeration(iter);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Iterator Wrappers //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Wraps an Iterator making it immutable, by disabling calls to
+ * <code>remove()</code>
+ */
+ private static final class ImmutableIterator
+ implements Iterator
+ {
+ private final Iterator iter;
+
+ public ImmutableIterator(final Iterator iter) {
+ this.iter = iter;
+ }
+
+ public boolean hasNext() {
+ return iter.hasNext();
+ }
+
+ public Object next() {
+ return iter.next();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("iterator is immutable");
+ }
+ }
+
+ /**
+ * Make an Iterator immutable
+ *
+ * @param iter Iterator to make immutable
+ * @return Imutable iterator
+ */
+ public static Iterator makeImmutable(final Iterator iter) {
+ return new ImmutableIterator(iter);
+ }
+
+ /**
+ * Wraps an Iterator making it synchronized.
+ */
+ private static final class SyncIterator
+ implements Iterator
+ {
+ private final Iterator iter;
+
+ public SyncIterator(final Iterator iter) {
+ this.iter = iter;
+ }
+
+ public synchronized boolean hasNext() {
+ return iter.hasNext();
+ }
+
+ public synchronized Object next() {
+ return iter.next();
+ }
+
+ public synchronized void remove() {
+ iter.remove();
+ }
+ }
+
+ /**
+ * Returns a synchronized version of the given Iterator.
+ *
+ * @param iter Iterator to synchronize.
+ * @return Synchronized Iterator.
+ */
+ public static Iterator makeSynchronized(final Iterator iter) {
+ return new SyncIterator(iter);
+ }
+
+ /**
+ * Wraps an Enumeration making it synchronized.
+ */
+ private static final class SyncEnumeration
+ implements Enumeration
+ {
+ private final Enumeration enum;
+
+ public SyncEnumeration(final Enumeration enum) {
+ this.enum = enum;
+ }
+
+ public synchronized boolean hasMoreElements() {
+ return enum.hasMoreElements();
+ }
+
+ public synchronized Object nextElement() {
+ return enum.nextElement();
+ }
+ }
+
+ /**
+ * Returns a synchronized version of the given Enumeration.
+ *
+ * @param enum Enumeration to synchronize.
+ * @return Synchronized Enumeration.
+ */
+ public static Enumeration makeSynchronized(final Enumeration enum) {
+ return new SyncEnumeration(enum);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Empty Iterator //
+ /////////////////////////////////////////////////////////////////////////
+
+ /** An empty Iterator */
+ public static final Iterator EMPTY_ITERATOR = new EmptyIterator();
+
+ /**
+ * An empty Iterator
+ */
+ private static final class EmptyIterator
+ implements Iterator
+ {
+ public boolean hasNext() {
+ return false;
+ }
+
+ public Object next() {
+ throw new NoSuchElementException("no more elements");
+ }
+
+ public void remove() {
+ throw new IllegalStateException("no more elements");
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Misc Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Returns an Iterator containing the <i>union</i> of all of the elements
+ * in the given iterator array.
+ *
+ * @param iters Array of iterators.
+ * @return Iterator containing the <i>union</i>.
+ */
+ public static Iterator union(final Iterator iters[]) {
+ Map map = new HashMap();
+
+ for (int i=0; i < iters.length; i++) {
+ if (iters[i] != null) {
+ while (iters[i].hasNext()) {
+ Object obj = iters[i].next();
+ if (!map.containsKey(obj)) {
+ map.put(obj, Null.VALUE);
+ }
+ }
+ }
+ }
+
+ return map.keySet().iterator();
+ }
+
+ /**
+ * Return a delimited string representation of all of the elements
+ * in the given Iterator.
+ *
+ * @param iter Iterator to convert to string.
+ * @param delim Elemement delimiter.
+ * @return Delimited string value.
+ */
+ public static String toString(final Iterator iter, final String delim) {
+ StringBuffer buff = new StringBuffer();
+ while (iter.hasNext()) {
+ buff.append(iter.next());
+
+ if (iter.hasNext()) {
+ buff.append(delim);
+ }
+ }
+
+ return buff.toString();
+ }
+
+ /**
+ * Return a comma delimited string representation of all of the elements
+ * in the given Iterator.
+ *
+ * @param iter Iterator to convert to string.
+ * @return Delimited string value.
+ */
+ public static String toString(final Iterator iter) {
+ return toString(iter, ",");
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/Iterators.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ListQueue.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ListQueue.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ListQueue.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,159 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+
+import org.jboss.util.NullArgumentException;
+
+/**
+ * A ListQueue implements a first-in, first-out container using a List as
+ * a data structure.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ListQueue
+ extends AbstractQueue
+{
+ /** List container */
+ protected final List list;
+
+ /**
+ * Construct a new <i>constrained</i> ListQueue.
+ *
+ * @param list The list which will be used to store queued objects.
+ * @param maxSize The maximum size of the queue.
+ *
+ * @exception IllegalArgumentException List is <i>null</i>.
+ */
+ public ListQueue(final List list, final int maxSize) {
+ super(maxSize);
+
+ if (list == null)
+ throw new NullArgumentException("list");
+
+ this.list = list;
+ }
+
+ /**
+ * Construct a new <i>constrained</i> ListQueue using a
+ * <code>LinkedList</code> for a data-structure.
+ *
+ * @param maxSize The maximum size of the queue.
+ */
+ public ListQueue(final int maxSize) {
+ super(maxSize);
+ this.list = new LinkedList();
+ }
+
+ /**
+ * Construct a new <i>unconstrained</i> ListQueue.
+ *
+ * @param list The list which will be used to store queued objects.
+ *
+ * @exception IllegalArgumentException List is <i>null</i>
+ */
+ public ListQueue(final List list) {
+ this(list, UNLIMITED_MAXIMUM_SIZE);
+ }
+
+ /**
+ * Construct a new <i>unconstrained</i> ListQueue using a
+ * <code>LinkedList</code> for a data-structure.
+ */
+ public ListQueue() {
+ this(new LinkedList(), UNLIMITED_MAXIMUM_SIZE);
+ }
+
+ /**
+ * Appends the given element to the end of this list.
+ *
+ * @param obj Object to append.
+ */
+ protected boolean addLast(final Object obj) {
+ return list.add(obj);
+ }
+
+ /**
+ * Remove the first object in the queue.
+ *
+ * @return First object in the queue.
+ */
+ protected Object removeFirst() {
+ return list.remove(0);
+ }
+
+ /**
+ * Get the size of the queue.
+ *
+ * @return The number of elements in the queue.
+ */
+ public int size() {
+ return list.size();
+ }
+
+ /**
+ * Returns an iterator over the elements in this list in proper sequence.
+ *
+ * @return An iterator over the elements in this list in proper sequence.
+ */
+ public Iterator iterator() {
+ return list.iterator();
+ }
+
+ /**
+ * Get the object at the front of the queue.
+ *
+ * @return Object at the front of the queue.
+ *
+ * @exception EmptyCollectionException The queue is empty.
+ */
+ public Object getFront() throws EmptyCollectionException {
+ if (isEmpty())
+ throw new EmptyCollectionException();
+
+ return list.get(0);
+ }
+
+ /**
+ * Get the object at the back of the queue.
+ *
+ * @return Object at the back of the queue.
+ *
+ * @exception EmptyCollectionException The queue is empty.
+ */
+ public Object getBack() throws EmptyCollectionException {
+ if (isEmpty())
+ throw new EmptyCollectionException();
+
+ return list.get(list.size() - 1);
+ }
+
+ /**
+ * Returns an iterator over the elements in this list in reverse sequence.
+ *
+ * @return An iterator over the elements in this list in reverse sequence.
+ */
+ public Iterator reverseIterator() {
+ return new ReverseListIterator(list);
+ }
+
+ /**
+ * Return a String representation of this queue.
+ *
+ * @return String
+ */
+ public String toString() {
+ return list.toString();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ListQueue.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ListSet.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ListSet.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ListSet.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,165 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.Collection;
+
+import org.jboss.util.NullArgumentException;
+
+/**
+ * A thin wrapper around a <code>List</code> transforming it into a
+ * modifiable <code>Set</code>.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ListSet
+ extends AbstractSet
+ implements Set, Cloneable
+{
+ /** The <tt>List</tt> which will be used for element storage. */
+ protected final List list;
+
+ /**
+ * Construct a <tt>ListSet</tt>.
+ *
+ * @param list The <tt>List</tt> which will be used for element storage.
+ *
+ * @throws IllegalArgumentException List is <tt>null</tt> or contains
+ * duplicate entries.
+ */
+ public ListSet(final List list) {
+ if (list == null)
+ throw new NullArgumentException("list");
+
+ // make sure there are no duplicates
+ int size = list.size();
+ for (int i=0; i<size; i++) {
+ Object obj = list.get(i);
+ if (list.indexOf(obj) != list.lastIndexOf(obj)) {
+ throw new IllegalArgumentException
+ ("list contains duplicate entries");
+ }
+ }
+
+ this.list = list;
+ }
+
+ /**
+ * Construct a <tt>ListSet</tt> using an <tt>ArrayList</tt> for backing.
+ */
+ public ListSet() {
+ this(new ArrayList());
+ }
+
+ /**
+ * Construct a <tt>ListSet</tt> using an <tt>ArrayList</tt> for backing
+ * and populated with the given elements.
+ *
+ * @param elements The elements for the list.
+ */
+ public ListSet(final Collection elements) {
+ this(new ArrayList(elements));
+ }
+
+ public List getList()
+ {
+ return list;
+ }
+
+ /**
+ * Return the size of the set.
+ *
+ * @return The size of the set.
+ */
+ public int size() {
+ return list.size();
+ }
+
+ /**
+ * Return an iteration over the elements in the set.
+ *
+ * @return An iteration over the elements in the set.
+ */
+ public Iterator iterator() {
+ return list.iterator();
+ }
+
+ /**
+ * Add an element to the set.
+ *
+ * @param obj Element to add to the set.
+ * @return True if the element was added.
+ */
+ public boolean add(final Object obj) {
+ boolean added = false;
+
+ if (!list.contains(obj)) {
+ added = list.add(obj);
+ }
+
+ return added;
+ }
+
+ /**
+ * Returns <tt>true</tt> if this set contains no elements.
+ *
+ * @return <tt>true</tt> if this set contains no elements.
+ */
+ public boolean isEmpty() {
+ return list.isEmpty();
+ }
+
+ /**
+ * Returns <tt>true</tt> if this set contains the specified element.
+ *
+ * @param obj Element whose presence in this set is to be tested.
+ * @return <tt>true</tt> if this set contains the specified element.
+ */
+ public boolean contains(final Object obj) {
+ return list.contains(obj);
+ }
+
+ /**
+ * Removes the given element from this set if it is present.
+ *
+ * @param obj Object to be removed from this set, if present.
+ * @return <tt>true</tt> if the set contained the specified element.
+ */
+ public boolean remove(final Object obj) {
+ return list.remove(obj);
+ }
+
+ /**
+ * Removes all of the elements from this set.
+ */
+ public void clear() {
+ list.clear();
+ }
+
+ /**
+ * Returns a shallow copy of this <tt>ListSet</tt> instance.
+ *
+ * @return A shallow copy of this set.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ListSet.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/Queue.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/Queue.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/Queue.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,92 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.util.Collection;
+
+/**
+ * An iterface used to implement a first-in, first-out container.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface Queue
+ extends Collection
+{
+ /** Unlimited maximum queue size identifier. */
+ int UNLIMITED_MAXIMUM_SIZE = -1;
+
+ /**
+ * Get the maximum size of the queue.
+ *
+ * @return Maximum pool size or {@link #UNLIMITED_MAXIMUM_SIZE}.
+ */
+ int getMaximumSize();
+
+ /**
+ * Set the maximum size of the queue.
+ *
+ * @param size New maximim pool size or {@link #UNLIMITED_MAXIMUM_SIZE}.
+ *
+ * @exception IllegalArgumentException Illegal size.
+ */
+ void setMaximumSize(int size) throws IllegalArgumentException;
+
+ /**
+ * Check if the queue is full.
+ *
+ * @return True if the queue is full.
+ */
+ boolean isFull();
+
+ /**
+ * Check if the queue is empty.
+ *
+ * @return True if the queue is empty.
+ */
+ boolean isEmpty();
+
+ /**
+ * Enqueue an object onto the queue.
+ *
+ * @param obj Object to enqueue.
+ * @return True if collection was modified.
+ *
+ * @exception FullCollectionException The queue is full.
+ */
+ boolean add(Object obj) throws FullCollectionException;
+
+ /**
+ * Dequeue an object from the queue.
+ *
+ * @return Dequeued object.
+ *
+ * @exception EmptyCollectionException The queue is empty.
+ */
+ Object remove() throws EmptyCollectionException;
+
+ /**
+ * Get the object at the front of the queue.
+ *
+ * @return Object at the front of the queue.
+ *
+ * @exception EmptyCollectionException The queue is empty.
+ */
+ Object getFront() throws EmptyCollectionException;
+
+ /**
+ * Get the object at the back of the queue.
+ *
+ * @return Object at the back of the queue.
+ *
+ * @exception EmptyCollectionException The queue is empty.
+ */
+ Object getBack() throws EmptyCollectionException;
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/Queue.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ReverseListIterator.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ReverseListIterator.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ReverseListIterator.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,71 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+/**
+ * An iterator that returns elements in reverse order from a list.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ReverseListIterator
+ implements Iterator
+{
+ /** The list to get elements from */
+ protected final List list;
+
+ /** The current index of the list */
+ protected int current;
+
+ /**
+ * Construct a ReverseListIterator for the given list.
+ *
+ * @param list List to iterate over.
+ */
+ public ReverseListIterator(final List list) {
+ this.list = list;
+ current = list.size() - 1;
+ }
+
+ /**
+ * Check if there are more elements.
+ *
+ * @return True if there are more elements.
+ */
+ public boolean hasNext() {
+ return current > 0;
+ }
+
+ /**
+ * Get the next element.
+ *
+ * @return The next element.
+ *
+ * @throws NoSuchElementException
+ */
+ public Object next() {
+ if (current <= 0) {
+ throw new NoSuchElementException();
+ }
+
+ return list.get(current--);
+ }
+
+ /**
+ * Remove the current element.
+ */
+ public void remove() {
+ list.remove(current);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/ReverseListIterator.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/SerializableEnumeration.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/SerializableEnumeration.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/SerializableEnumeration.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util.collection;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+/**
+ * ???
+ *
+ * @author ???
+ * @version $Revision$
+ */
+public class SerializableEnumeration
+ extends ArrayList
+ implements Enumeration
+{
+ private int index;
+
+ public SerializableEnumeration () {
+ index = 0;
+ }
+
+ public SerializableEnumeration (Collection c) {
+ super(c);
+ index = 0;
+ }
+
+ public SerializableEnumeration (int initialCapacity) {
+ super(initialCapacity);
+ index = 0;
+ }
+
+ public boolean hasMoreElements() {
+ return (index < size());
+ }
+
+ public Object nextElement() throws NoSuchElementException
+ {
+ try {
+ Object nextObj = get(index);
+ index++;
+ return nextObj;
+ }
+ catch (IndexOutOfBoundsException e) {
+ throw new NoSuchElementException();
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws java.io.IOException
+ {
+ // the only thing to write is the index field
+ out.defaultWriteObject();
+ }
+
+ private void readObject(java.io.ObjectInputStream in)
+ throws java.io.IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/SerializableEnumeration.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/WeakSet.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/WeakSet.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/WeakSet.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,214 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.lang.ref.ReferenceQueue;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.jboss.util.NullArgumentException;
+import org.jboss.util.WeakObject;
+
+/**
+ * A <tt>Set</tt> implementation with <em>weak elements</em>. An entry in
+ * a <tt>WeakSet</tt> will automatically be removed when the element is no
+ * longer in ordinary use. More precisely, the presence of an given element
+ * will not prevent the element from being discarded by the garbage collector,
+ * that is, made finalizable, finalized, and then reclaimed.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class WeakSet
+ extends AbstractSet
+ implements Set
+{
+ /** The reference queue used to get object removal notifications. */
+ protected final ReferenceQueue queue = new ReferenceQueue();
+
+ /** The <tt>Set</tt> which will be used for element storage. */
+ protected final Set set;
+
+ /**
+ * Construct a <tt>WeakSet</tt>. Any elements in the given set will be
+ * wrapped in {@link WeakObject} references.
+ *
+ * @param set The <tt>Set</tt> which will be used for element storage.
+ *
+ * @throws NullArgumentException Set is <tt>null</tt>.
+ */
+ public WeakSet(final Set set) {
+ if (set == null)
+ throw new NullArgumentException("set");
+
+ // reset any elements to weak objects
+ if (set.size() != 0) {
+ Object elements[] = set.toArray();
+ set.clear();
+
+ for (int i=0; i<elements.length; i++) {
+ add(elements[i]);
+ }
+ }
+
+ this.set = set;
+ }
+
+ /**
+ * Construct a <tt>WeakSet</tt> based on a <tt>HashSet</tt>.
+ */
+ public WeakSet() {
+ this(new HashSet());
+ }
+
+ /**
+ * Maintain the elements in the set. Removes objects from the set that
+ * have been reclaimed due to GC.
+ */
+ protected final void maintain() {
+ WeakObject weak;
+ while ((weak = (WeakObject)queue.poll()) != null) {
+ set.remove(weak);
+ }
+ }
+
+ /**
+ * Return the size of the set.
+ *
+ * @return The size of the set.
+ */
+ public int size() {
+ maintain();
+
+ return set.size();
+ }
+
+ /**
+ * Return an iteration over the elements in the set.
+ *
+ * @return An iteration over the elements in the set.
+ */
+ public Iterator iterator() {
+ return new Iterator() {
+
+ /** The set's iterator */
+ Iterator iter = set.iterator();
+
+ /** The next available object. */
+ Object next = null;
+
+ public boolean hasNext() {
+ while (iter.hasNext()) {
+ WeakObject weak = (WeakObject)iter.next();
+ Object obj = null;
+ if (weak != null && (obj = weak.get()) == null) {
+ // object has been reclaimed by the GC
+ continue;
+ }
+
+ next = obj;
+ return true;
+ }
+
+ return false;
+ }
+
+ public Object next() {
+ if ((next == null) && !hasNext()) {
+ throw new NoSuchElementException();
+ }
+
+ Object obj = next;
+ next = null;
+
+ return obj;
+ }
+
+ public void remove() {
+ iter.remove();
+ }
+ };
+ }
+
+ /**
+ * Add an element to the set.
+ *
+ * @param obj Element to add to the set.
+ * @return True if the element was added.
+ */
+ public boolean add(final Object obj) {
+ maintain();
+
+ return set.add(WeakObject.create(obj, queue));
+ }
+
+ /**
+ * Returns <tt>true</tt> if this set contains no elements.
+ *
+ * @return <tt>true</tt> if this set contains no elements.
+ */
+ public boolean isEmpty() {
+ maintain();
+
+ return set.isEmpty();
+ }
+
+ /**
+ * Returns <tt>true</tt> if this set contains the specified element.
+ *
+ * @param obj Element whose presence in this set is to be tested.
+ * @return <tt>true</tt> if this set contains the specified element.
+ */
+ public boolean contains(final Object obj) {
+ maintain();
+
+ return set.contains(WeakObject.create(obj));
+ }
+
+ /**
+ * Removes the given element from this set if it is present.
+ *
+ * @param obj Object to be removed from this set, if present.
+ * @return <tt>true</tt> if the set contained the specified element.
+ */
+ public boolean remove(final Object obj) {
+ maintain();
+
+ return set.remove(WeakObject.create(obj));
+ }
+
+ /**
+ * Removes all of the elements from this set.
+ */
+ public void clear() {
+ set.clear();
+ }
+
+ /**
+ * Returns a shallow copy of this <tt>WeakSet</tt> instance: the elements
+ * themselves are not cloned.
+ *
+ * @return A shallow copy of this set.
+ */
+ public Object clone() {
+ maintain();
+
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/WeakSet.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/WeakValueHashMap.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/WeakValueHashMap.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/WeakValueHashMap.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,239 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.collection;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.AbstractMap;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.AbstractSet;
+import java.util.NoSuchElementException;
+
+import java.lang.ref.WeakReference;
+import java.lang.ref.ReferenceQueue;
+
+
+/**
+ * This Map will remove entries when the value in the map has been
+ * cleaned from garbage collection
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ */
+public class WeakValueHashMap
+ extends AbstractMap
+ implements Map
+{
+ private static class WeakValueRef extends WeakReference
+ {
+ public Object key;
+
+ private WeakValueRef(Object key, Object val, ReferenceQueue q)
+ {
+ super(val, q);
+ this.key = key;
+ }
+
+ private static WeakValueRef create(Object key, Object val, ReferenceQueue q)
+ {
+ if (val == null) return null;
+ else return new WeakValueRef(key, val, q);
+ }
+
+ }
+ public Set entrySet()
+ {
+ processQueue();
+ return hash.entrySet();
+ }
+
+ /* Hash table mapping WeakKeys to values */
+ private Map hash;
+
+ /* Reference queue for cleared WeakKeys */
+ private ReferenceQueue queue = new ReferenceQueue();
+
+ /* Remove all invalidated entries from the map, that is, remove all entries
+ whose values have been discarded.
+ */
+ private void processQueue()
+ {
+ WeakValueRef ref;
+ while ((ref = (WeakValueRef)queue.poll()) != null) {
+ if (ref == (WeakValueRef) hash.get(ref.key)) {
+ // only remove if it is the *exact* same WeakValueRef
+ //
+ hash.remove(ref.key);
+ }
+ }
+ }
+
+
+ /* -- Constructors -- */
+
+ /**
+ * Constructs a new, empty <code>WeakHashMap</code> with the given
+ * initial capacity and the given load factor.
+ *
+ * @param initialCapacity The initial capacity of the
+ * <code>WeakHashMap</code>
+ *
+ * @param loadFactor The load factor of the <code>WeakHashMap</code>
+ *
+ * @throws IllegalArgumentException If the initial capacity is less than
+ * zero, or if the load factor is
+ * nonpositive
+ */
+ public WeakValueHashMap(int initialCapacity, float loadFactor)
+ {
+ hash = new HashMap(initialCapacity, loadFactor);
+ }
+
+ /**
+ * Constructs a new, empty <code>WeakHashMap</code> with the given
+ * initial capacity and the default load factor, which is
+ * <code>0.75</code>.
+ *
+ * @param initialCapacity The initial capacity of the
+ * <code>WeakHashMap</code>
+ *
+ * @throws IllegalArgumentException If the initial capacity is less than
+ * zero
+ */
+ public WeakValueHashMap(int initialCapacity)
+ {
+ hash = new HashMap(initialCapacity);
+ }
+
+ /**
+ * Constructs a new, empty <code>WeakHashMap</code> with the default
+ * initial capacity and the default load factor, which is
+ * <code>0.75</code>.
+ */
+ public WeakValueHashMap()
+ {
+ hash = new HashMap();
+ }
+
+ /**
+ * Constructs a new <code>WeakHashMap</code> with the same mappings as the
+ * specified <tt>Map</tt>. The <code>WeakHashMap</code> is created with an
+ * initial capacity of twice the number of mappings in the specified map
+ * or 11 (whichever is greater), and a default load factor, which is
+ * <tt>0.75</tt>.
+ *
+ * @param t the map whose mappings are to be placed in this map.
+ * @since 1.3
+ */
+ public WeakValueHashMap(Map t)
+ {
+ this(Math.max(2*t.size(), 11), 0.75f);
+ putAll(t);
+ }
+
+ /* -- Simple queries -- */
+
+ /**
+ * Returns the number of key-value mappings in this map.
+ * <strong>Note:</strong> <em>In contrast with most implementations of the
+ * <code>Map</code> interface, the time required by this operation is
+ * linear in the size of the map.</em>
+ */
+ public int size()
+ {
+ processQueue();
+ return hash.size();
+ }
+
+ /**
+ * Returns <code>true</code> if this map contains no key-value mappings.
+ */
+ public boolean isEmpty()
+ {
+ processQueue();
+ return hash.isEmpty();
+ }
+
+ /**
+ * Returns <code>true</code> if this map contains a mapping for the
+ * specified key.
+ *
+ * @param key The key whose presence in this map is to be tested
+ */
+ public boolean containsKey(Object key)
+ {
+ processQueue();
+ return hash.containsKey(key);
+ }
+
+ /* -- Lookup and modification operations -- */
+
+ /**
+ * Returns the value to which this map maps the specified <code>key</code>.
+ * If this map does not contain a value for this key, then return
+ * <code>null</code>.
+ *
+ * @param key The key whose associated value, if any, is to be returned
+ */
+ public Object get(Object key)
+ {
+ processQueue();
+ WeakReference ref = (WeakReference)hash.get(key);
+ if (ref != null) return ref.get();
+ return null;
+ }
+
+ /**
+ * Updates this map so that the given <code>key</code> maps to the given
+ * <code>value</code>. If the map previously contained a mapping for
+ * <code>key</code> then that mapping is replaced and the previous value is
+ * returned.
+ *
+ * @param key The key that is to be mapped to the given
+ * <code>value</code>
+ * @param value The value to which the given <code>key</code> is to be
+ * mapped
+ *
+ * @return The previous value to which this key was mapped, or
+ * <code>null</code> if if there was no mapping for the key
+ */
+ public Object put(Object key, Object value)
+ {
+ processQueue();
+ Object rtn = hash.put(key, WeakValueRef.create(key, value, queue));
+ if (rtn != null) rtn = ((WeakReference)rtn).get();
+ return rtn;
+ }
+
+ /**
+ * Removes the mapping for the given <code>key</code> from this map, if
+ * present.
+ *
+ * @param key The key whose mapping is to be removed
+ *
+ * @return The value to which this key was mapped, or <code>null</code> if
+ * there was no mapping for the key
+ */
+ public Object remove(Object key)
+ {
+ processQueue();
+ return hash.remove(key);
+ }
+
+ /**
+ * Removes all mappings from this map.
+ */
+ public void clear()
+ {
+ processQueue();
+ hash.clear();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/WeakValueHashMap.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Extentions to the <i>Java Collections framework</i>.<p>
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/collection/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilePrefixFilter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilePrefixFilter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilePrefixFilter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,66 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.file;
+
+import java.io.File;
+import java.io.FileFilter;
+
+/**
+ * A <em>prefix</em> based file filter.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FilePrefixFilter
+ implements FileFilter
+{
+ /** The prefix which files must have to be accepted. */
+ protected final String prefix;
+
+ /** Flag to signal that we want to ignore the case. */
+ protected final boolean ignoreCase;
+
+ /**
+ * Construct a <tt>FilePrefixFilter</tt>.
+ *
+ * @param prefix The prefix which files must have to be accepted.
+ * @param ignoreCase <tt>True</tt> if the filter should be case-insensitive.
+ */
+ public FilePrefixFilter(final String prefix,
+ final boolean ignoreCase)
+ {
+ this.ignoreCase = ignoreCase;
+ this.prefix = (ignoreCase ? prefix.toLowerCase() : prefix);
+ }
+
+ /**
+ * Construct a case sensitive <tt>FilePrefixFilter</tt>.
+ *
+ * @param prefix The prefix which files must have to be accepted.
+ */
+ public FilePrefixFilter(final String prefix) {
+ this(prefix, false);
+ }
+
+ /**
+ * Check if a file is acceptible.
+ *
+ * @param file The file to check.
+ * @return <tt>true</tt> if the file is acceptable.
+ */
+ public boolean accept(final File file) {
+ if (ignoreCase) {
+ return file.getName().toLowerCase().startsWith(prefix);
+ }
+ else {
+ return file.getName().startsWith(prefix);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilePrefixFilter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FileSuffixFilter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FileSuffixFilter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FileSuffixFilter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,100 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.file;
+
+import java.io.File;
+import java.io.FileFilter;
+
+/**
+ * A <em>suffix</em> based file filter.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FileSuffixFilter
+ implements FileFilter
+{
+ /** A list of suffixes which files must have to be accepted. */
+ protected final String suffixes[];
+
+ /** Flag to signal that we want to ignore the case. */
+ protected final boolean ignoreCase;
+
+ /**
+ * Construct a <tt>FileSuffixFilter</tt>.
+ *
+ * @param suffixes A list of suffixes which files mut have to be accepted.
+ * @param ignoreCase <tt>True</tt> if the filter should be case-insensitive.
+ */
+ public FileSuffixFilter(final String suffixes[],
+ final boolean ignoreCase)
+ {
+ this.ignoreCase = ignoreCase;
+ if (ignoreCase) {
+ this.suffixes = new String[suffixes.length];
+ for (int i=0; i<suffixes.length; i++) {
+ this.suffixes[i] = suffixes[i].toLowerCase();
+ }
+ }
+ else {
+ this.suffixes = suffixes;
+ }
+ }
+
+ /**
+ * Construct a <tt>FileSuffixFilter</tt>.
+ *
+ * @param suffixes A list of suffixes which files mut have to be accepted.
+ */
+ public FileSuffixFilter(final String suffixes[])
+ {
+ this(suffixes, false);
+ }
+
+ /**
+ * Construct a <tt>FileSuffixFilter</tt>.
+ *
+ * @param suffix The suffix which files must have to be accepted.
+ * @param ignoreCase <tt>True</tt> if the filter should be case-insensitive.
+ */
+ public FileSuffixFilter(final String suffix,
+ final boolean ignoreCase)
+ {
+ this(new String[] { suffix }, ignoreCase);
+ }
+
+ /**
+ * Construct a case sensitive <tt>FileSuffixFilter</tt>.
+ *
+ * @param suffix The suffix which files must have to be accepted.
+ */
+ public FileSuffixFilter(final String suffix) {
+ this(suffix, false);
+ }
+
+ /**
+ * Check if a file is acceptible.
+ *
+ * @param file The file to check.
+ * @return <tt>true</tt> if the file is acceptable.
+ */
+ public boolean accept(final File file) {
+ boolean success = false;
+
+ for (int i=0; i<suffixes.length && !success; i++) {
+ if (ignoreCase)
+ success = file.getName().toLowerCase().endsWith(suffixes[i]);
+ else
+ success = file.getName().endsWith(suffixes[i]);
+ }
+
+ return success;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FileSuffixFilter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilenamePrefixFilter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilenamePrefixFilter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilenamePrefixFilter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,67 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.file;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ * A <em>prefix</em> based filename filter.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FilenamePrefixFilter
+ implements FilenameFilter
+{
+ /** The prefix which files must have to be accepted. */
+ protected final String prefix;
+
+ /** Flag to signal that we want to ignore the case. */
+ protected final boolean ignoreCase;
+
+ /**
+ * Construct a <tt>FilenamePrefixFilter</tt>.
+ *
+ * @param prefix The prefix which files must have to be accepted.
+ * @param ignoreCase <tt>True</tt> if the filter should be case-insensitive.
+ */
+ public FilenamePrefixFilter(final String prefix,
+ final boolean ignoreCase)
+ {
+ this.ignoreCase = ignoreCase;
+ this.prefix = (ignoreCase ? prefix.toLowerCase() : prefix);
+ }
+
+ /**
+ * Construct a case sensitive <tt>FilenamePrefixFilter</tt>.
+ *
+ * @param prefix The prefix which files must have to be accepted.
+ */
+ public FilenamePrefixFilter(final String prefix) {
+ this(prefix, false);
+ }
+
+ /**
+ * Check if a file is acceptible.
+ *
+ * @param dir The directory the file resides in.
+ * @param name The name of the file.
+ * @return <tt>true</tt> if the file is acceptable.
+ */
+ public boolean accept(final File dir, final String name) {
+ if (ignoreCase) {
+ return name.toLowerCase().startsWith(prefix);
+ }
+ else {
+ return name.startsWith(prefix);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilenamePrefixFilter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilenameSuffixFilter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilenameSuffixFilter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilenameSuffixFilter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,67 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.file;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ * A <em>suffix</em> based filename filter.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FilenameSuffixFilter
+ implements FilenameFilter
+{
+ /** The suffix which files must have to be accepted. */
+ protected final String suffix;
+
+ /** Flag to signal that we want to ignore the case. */
+ protected final boolean ignoreCase;
+
+ /**
+ * Construct a <tt>FilenameSuffixFilter</tt>.
+ *
+ * @param suffix The suffix which files must have to be accepted.
+ * @param ignoreCase <tt>True</tt> if the filter should be case-insensitive.
+ */
+ public FilenameSuffixFilter(final String suffix,
+ final boolean ignoreCase)
+ {
+ this.ignoreCase = ignoreCase;
+ this.suffix = (ignoreCase ? suffix.toLowerCase() : suffix);
+ }
+
+ /**
+ * Construct a case sensitive <tt>FilenameSuffixFilter</tt>.
+ *
+ * @param suffix The suffix which files must have to be accepted.
+ */
+ public FilenameSuffixFilter(final String suffix) {
+ this(suffix, false);
+ }
+
+ /**
+ * Check if a file is acceptible.
+ *
+ * @param dir The directory the file resides in.
+ * @param name The name of the file.
+ * @return <tt>true</tt> if the file is acceptable.
+ */
+ public boolean accept(final File dir, final String name) {
+ if (ignoreCase) {
+ return name.toLowerCase().endsWith(suffix);
+ }
+ else {
+ return name.endsWith(suffix);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/FilenameSuffixFilter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/Files.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/Files.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/Files.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,144 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.file;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+
+import org.jboss.util.stream.Streams;
+
+/**
+ * A collection of file utilities.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class Files
+{
+ /**
+ * Delete a directory and all of its contents.
+ *
+ * @param dir The directory to delete.
+ * @return True if all delete operations were successfull.
+ */
+ public static boolean delete(final File dir)
+ {
+ boolean success = true;
+
+ File files[] = dir.listFiles();
+ if (files != null) {
+ for (int i=0; i<files.length; i++) {
+ if (files[i].isDirectory()) {
+ // delete the directory and all of its contents.
+ if (!delete(files[i])) {
+ success = false;
+ }
+ }
+
+ // delete each file in the directory
+ if (!files[i].delete()) {
+ success = false;
+ }
+ }
+ }
+
+ // finally delete the directory
+ if (!dir.delete()) {
+ success = false;
+ }
+
+ return success;
+ }
+
+ /**
+ * Delete a directory and all of its contents.
+ *
+ * @param dirname The name of the directory to delete.
+ * @return True if all delete operations were successfull.
+ */
+ public static boolean delete(final String dirname)
+ {
+ return delete(new File(dirname));
+ }
+
+ /** The default size of the copy buffer. */
+ public static final int DEFAULT_BUFFER_SIZE = 8192; // 8k
+
+ /**
+ * Copy a file.
+ *
+ * @param source Source file to copy.
+ * @param target Destination target file.
+ * @param buff The copy buffer.
+ *
+ * @throws IOException Failed to copy file.
+ */
+ public static void copy(final File source,
+ final File target,
+ final byte buff[])
+ throws IOException
+ {
+ DataInputStream in = new DataInputStream
+ (new BufferedInputStream(new FileInputStream(source)));
+
+ DataOutputStream out = new DataOutputStream
+ (new BufferedOutputStream(new FileOutputStream(target)));
+
+ int read;
+
+ try {
+ while ((read = in.read(buff)) != -1) {
+ out.write(buff, 0, read);
+ }
+ }
+ finally {
+ Streams.flush(out);
+ Streams.close(in);
+ Streams.close(out);
+ }
+ }
+
+ /**
+ * Copy a file.
+ *
+ * @param source Source file to copy.
+ * @param target Destination target file.
+ * @param size The size of the copy buffer.
+ *
+ * @throws IOException Failed to copy file.
+ */
+ public static void copy(final File source,
+ final File target,
+ final int size)
+ throws IOException
+ {
+ copy(source, target, new byte[size]);
+ }
+
+ /**
+ * Copy a file.
+ *
+ * @param source Source file to copy.
+ * @param target Destination target file.
+ *
+ * @throws IOException Failed to copy file.
+ */
+ public static void copy(final File source, final File target)
+ throws IOException
+ {
+ copy(source, target, DEFAULT_BUFFER_SIZE);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/Files.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/JarUtils.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/JarUtils.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/JarUtils.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,386 @@
+package org.jboss.util.file;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+/** A utility class for dealing with Jar files.
+
+ at author Scott.Stark at jboss.org
+ at version $Revision$
+*/
+public final class JarUtils
+{
+ /**
+ * Hide the constructor
+ */
+ private JarUtils()
+ {
+ }
+
+ /**
+ * <P>This function will create a Jar archive containing the src
+ * file/directory. The archive will be written to the specified
+ * OutputStream.</P>
+ *
+ * <P>This is a shortcut for<br>
+ * <code>jar(out, new File[] { src }, null, null, null);</code></P>
+ *
+ * @param out The output stream to which the generated Jar archive is
+ * written.
+ * @param src The file or directory to jar up. Directories will be
+ * processed recursively.
+ */
+ public static void jar(OutputStream out, File src) throws IOException
+ {
+ jar(out, new File[] { src }, null, null, null);
+ }
+
+ /**
+ * <P>This function will create a Jar archive containing the src
+ * file/directory. The archive will be written to the specified
+ * OutputStream.</P>
+ *
+ * <P>This is a shortcut for<br>
+ * <code>jar(out, src, null, null, null);</code></P>
+ *
+ * @param out The output stream to which the generated Jar archive is
+ * written.
+ * @param src The file or directory to jar up. Directories will be
+ * processed recursively.
+ */
+ public static void jar(OutputStream out, File[] src) throws IOException
+ {
+ jar(out, src, null, null, null);
+ }
+
+ /**
+ * <P>This function will create a Jar archive containing the src
+ * file/directory. The archive will be written to the specified
+ * OutputStream. Directories are processed recursively, applying the
+ * specified filter if it exists.
+ *
+ * <P>This is a shortcut for<br>
+ * <code>jar(out, src, filter, null, null);</code></P>
+ *
+ * @param out The output stream to which the generated Jar archive is
+ * written.
+ * @param src The file or directory to jar up. Directories will be
+ * processed recursively.
+ * @param filter The filter to use while processing directories. Only
+ * those files matching will be included in the jar archive. If
+ * null, then all files are included.
+ */
+ public static void jar(OutputStream out, File[] src, FileFilter filter)
+ throws IOException
+ {
+ jar(out, src, filter, null, null);
+ }
+
+ /**
+ * <P>This function will create a Jar archive containing the src
+ * file/directory. The archive will be written to the specified
+ * OutputStream. Directories are processed recursively, applying the
+ * specified filter if it exists.
+ *
+ * @param out The output stream to which the generated Jar archive is
+ * written.
+ * @param src The file or directory to jar up. Directories will be
+ * processed recursively.
+ * @param filter The filter to use while processing directories. Only
+ * those files matching will be included in the jar archive. If
+ * null, then all files are included.
+ * @param prefix The name of an arbitrary directory that will precede all
+ * entries in the jar archive. If null, then no prefix will be
+ * used.
+ * @param man The manifest to use for the Jar archive. If null, then no
+ * manifest will be included.
+ */
+ public static void jar(OutputStream out, File[] src, FileFilter filter,
+ String prefix, Manifest man) throws IOException
+ {
+
+ for (int i = 0; i < src.length; i++)
+ {
+ if (!src[i].exists())
+ {
+ throw new FileNotFoundException(src.toString());
+ }
+ }
+
+ JarOutputStream jout;
+ if (man == null)
+ {
+ jout = new JarOutputStream(out);
+ }
+ else
+ {
+ jout = new JarOutputStream(out, man);
+ }
+ if (prefix != null && prefix.length() > 0 && !prefix.equals("/"))
+ {
+ // strip leading '/'
+ if (prefix.charAt(0) == '/')
+ {
+ prefix = prefix.substring(1);
+ }
+ // ensure trailing '/'
+ if (prefix.charAt(prefix.length() - 1) != '/')
+ {
+ prefix = prefix + "/";
+ }
+ }
+ else
+ {
+ prefix = "";
+ }
+ JarInfo info = new JarInfo(jout, filter);
+ for (int i = 0; i < src.length; i++)
+ {
+ jar(src[i], prefix, info);
+ }
+ jout.close();
+ }
+
+ /**
+ * This simple convenience class is used by the jar method to reduce the
+ * number of arguments needed. It holds all non-changing attributes
+ * needed for the recursive jar method.
+ */
+ private static class JarInfo
+ {
+ public JarOutputStream out;
+ public FileFilter filter;
+ public byte[] buffer;
+
+ public JarInfo(JarOutputStream out, FileFilter filter)
+ {
+ this.out = out;
+ this.filter = filter;
+ buffer = new byte[1024];
+ }
+ }
+
+ /**
+ * This recursive method writes all matching files and directories to
+ * the jar output stream.
+ */
+ private static void jar(File src, String prefix, JarInfo info)
+ throws IOException
+ {
+
+ JarOutputStream jout = info.out;
+ if (src.isDirectory())
+ {
+ // create / init the zip entry
+ prefix = prefix + src.getName() + "/";
+ ZipEntry entry = new ZipEntry(prefix);
+ entry.setTime(src.lastModified());
+ entry.setMethod(JarOutputStream.STORED);
+ entry.setSize(0L);
+ entry.setCrc(0L);
+ jout.putNextEntry(entry);
+ jout.closeEntry();
+
+ // process the sub-directories
+ File[] files = src.listFiles(info.filter);
+ for (int i = 0; i < files.length; i++)
+ {
+ jar(files[i], prefix, info);
+ }
+ }
+ else if (src.isFile())
+ {
+ // get the required info objects
+ byte[] buffer = info.buffer;
+
+ // create / init the zip entry
+ ZipEntry entry = new ZipEntry(prefix + src.getName());
+ entry.setTime(src.lastModified());
+ jout.putNextEntry(entry);
+
+ // dump the file
+ FileInputStream in = new FileInputStream(src);
+ int len;
+ while ((len = in.read(buffer, 0, buffer.length)) != -1)
+ {
+ jout.write(buffer, 0, len);
+ }
+ in.close();
+ jout.closeEntry();
+ }
+ }
+
+ /**
+ * Dump the contents of a JarArchive to the dpecified destination.
+ */
+ public static void unjar(InputStream in, File dest) throws IOException
+ {
+ if (!dest.exists())
+ {
+ dest.mkdirs();
+ }
+ if (!dest.isDirectory())
+ {
+ throw new IOException("Destination must be a directory.");
+ }
+ JarInputStream jin = new JarInputStream(in);
+ byte[] buffer = new byte[1024];
+
+ ZipEntry entry = jin.getNextEntry();
+ while (entry != null)
+ {
+ String fileName = entry.getName();
+ if (fileName.charAt(fileName.length() - 1) == '/')
+ {
+ fileName = fileName.substring(0, fileName.length() - 1);
+ }
+ if (fileName.charAt(0) == '/')
+ {
+ fileName = fileName.substring(1);
+ }
+ if (File.separatorChar != '/')
+ {
+ fileName = fileName.replace('/', File.separatorChar);
+ }
+ File file = new File(dest, fileName);
+ if (entry.isDirectory())
+ {
+ // make sure the directory exists
+ file.mkdirs();
+ jin.closeEntry();
+ }
+ else
+ {
+ // make sure the directory exists
+ File parent = file.getParentFile();
+ if (parent != null && !parent.exists())
+ {
+ parent.mkdirs();
+ }
+
+ // dump the file
+ OutputStream out = new FileOutputStream(file);
+ int len = 0;
+ while ((len = jin.read(buffer, 0, buffer.length)) != -1)
+ {
+ out.write(buffer, 0, len);
+ }
+ out.flush();
+ out.close();
+ jin.closeEntry();
+ }
+ entry = jin.getNextEntry();
+ }
+ jin.close();
+ }
+
+ /** Given a URL check if its a jar url(jar:<url>!/archive) and if it is,
+ extract the archive entry into the given dest directory and return a file
+ URL to its location. If jarURL is not a jar url then it is simply returned
+ as the URL for the jar.
+
+ @param jarURL the URL to validate and extract the referenced entry if its
+ a jar protocol URL
+ @param dest, the directory into which the nested jar will be extracted.
+ @return the file: URL for the jar referenced by the jarURL parameter.
+ */
+ public static URL extractNestedJar(URL jarURL, File dest)
+ throws IOException
+ {
+ // This may not be a jar URL so validate the protocol
+ if( jarURL.getProtocol().equals("jar") == false )
+ return jarURL;
+
+ String destPath = dest.getPath();
+ URLConnection urlConn = jarURL.openConnection();
+ JarURLConnection jarConn = (JarURLConnection) urlConn;
+ // Extract the archive to dest/jarName-contents/archive
+ String parentArchiveName = jarConn.getJarFile().getName();
+ // Find the longest common prefix between destPath and parentArchiveName
+ int length = Math.min(destPath.length(), parentArchiveName.length());
+ int n = 0;
+ while( n < length )
+ {
+ char a = destPath.charAt(n);
+ char b = parentArchiveName.charAt(n);
+ if( a != b )
+ break;
+ n ++;
+ }
+ // Remove any common prefix from parentArchiveName
+ parentArchiveName = parentArchiveName.substring(n);
+
+ File archiveDir = new File(dest, parentArchiveName+"-contents");
+ if( archiveDir.exists() == false && archiveDir.mkdirs() == false )
+ throw new IOException("Failed to create contents directory for archive, path="+archiveDir.getAbsolutePath());
+ String archiveName = jarConn.getEntryName();
+ File archiveFile = new File(archiveDir, archiveName);
+ File archiveParentDir = archiveFile.getParentFile();
+ if( archiveParentDir.exists() == false && archiveParentDir.mkdirs() == false )
+ throw new IOException("Failed to create parent directory for archive, path="+archiveParentDir.getAbsolutePath());
+ InputStream archiveIS = jarConn.getInputStream();
+ FileOutputStream fos = new FileOutputStream(archiveFile);
+ BufferedOutputStream bos = new BufferedOutputStream(fos);
+ byte[] buffer = new byte[4096];
+ int read, totalRead = 0;
+ while( (read = archiveIS.read(buffer)) > 0 )
+ {
+ bos.write(buffer, 0, read);
+ totalRead += read;
+ }
+ archiveIS.close();
+ bos.close();
+
+ // Return the file url to the extracted jar
+ return archiveFile.toURL();
+ }
+
+
+ /**
+ * A simple jar-like tool used for testing. It's actually faster than
+ * jar, though doesn't sipport as many options.
+ */
+ public static void main(String[] args) throws Exception
+ {
+ if (args.length == 0)
+ {
+ System.out.println("usage: <x or c> <jar-archive> <files...>");
+ System.exit(0);
+ }
+ if (args[0].equals("x"))
+ {
+ BufferedInputStream in = new BufferedInputStream(new FileInputStream(args[1]));
+ File dest = new File(args[2]);
+ unjar(in, dest);
+ }
+ else if (args[0].equals("c"))
+ {
+ BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(args[1]));
+ File[] src = new File[args.length - 2];
+ for (int i = 0; i < src.length; i++)
+ {
+ src[i] = new File(args[2 + i]);
+ }
+ jar(out, src);
+ }
+ else
+ {
+ System.out.println("Need x or c as first argument");
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/JarUtils.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>File related classes.</p>
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/file/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/GUID.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/GUID.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/GUID.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,172 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.id;
+
+import org.jboss.util.CloneableObject;
+
+/**
+ * A globally unique identifier (globally across a cluster of virtual
+ * machines).
+ *
+ * <p>The identifier is composed of:
+ * <ol>
+ * <li>The VMID for the virtual machine.</li>
+ * <li>A UID to provide uniqueness over a VMID.</li>
+ * </ol>
+ *
+ * <pre>
+ * [ address ] - [ process id ] - [ time ] - [ counter ] - [ time ] - [ counter ]
+ * |------- UID --------| |------- UID --------|
+ * |---------------------- VMID -----------------------|
+ * </pre>
+ *
+ * @see VMID
+ * @see UID
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class GUID
+ extends CloneableObject
+ implements ID
+{
+ /** The virtual machine identifier */
+ protected final VMID vmid;
+
+ /** The unique identifier */
+ protected final UID uid;
+
+ /** The hash code of this GUID */
+ protected final int hashCode;
+
+ /**
+ * Construct a new GUID.
+ */
+ public GUID() {
+ this(VMID.getInstance(), new UID());
+ }
+
+ /**
+ * Initialze a new GUID with specific values.
+ */
+ protected GUID(final VMID vmid, final UID uid)
+ {
+ this.vmid = vmid;
+ this.uid = uid;
+
+ // generate a hash code for this GUID
+ int code = vmid.hashCode();
+ code ^= uid.hashCode();
+ hashCode = code;
+ }
+
+ /**
+ * Copy a GUID.
+ *
+ * @param guid GUID to copy.
+ */
+ protected GUID(final GUID guid) {
+ this.vmid = guid.vmid;
+ this.uid = guid.uid;
+ this.hashCode = guid.hashCode;
+ }
+
+ /**
+ * Get the VMID portion of this GUID.
+ *
+ * @return The VMID portion of this GUID.
+ */
+ public final VMID getVMID() {
+ return vmid;
+ }
+
+ /**
+ * Get the UID portion of this GUID.
+ *
+ * @return The UID portion of this GUID.
+ */
+ public final UID getUID() {
+ return uid;
+ }
+
+ /**
+ * Return a string representation of this GUID.
+ *
+ * @return A string representation of this GUID.
+ */
+ public String toString() {
+ return vmid.toString() + "-" + uid.toString();
+ }
+
+ /**
+ * Return the hash code of this GUID.
+ *
+ * @return The hash code of this GUID.
+ */
+ public int hashCode() {
+ return hashCode;
+ }
+
+ /**
+ * Check if the given object is equal to this GUID.
+ *
+ * <p>A GUID is equal to another GUID if the VMID and UID portions are
+ * equal.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal to this GUID.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ GUID guid = (GUID)obj;
+
+ return
+ guid.vmid.equals(vmid) &&
+ guid.uid.equals(uid);
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns a GUID as a string.
+ *
+ * @return GUID as a string.
+ */
+ public static String asString() {
+ return new GUID().toString();
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Factory Access //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Creates GUID instances which are unique to the factory instance.
+ * The UID portion of the GUID areare generated from a UID.Factory.
+ */
+ public static class Factory
+ {
+ /** A factory for creating UIDs */
+ protected final UID.Factory factory = new UID.Factory();
+ protected final VMID vmid = VMID.getInstance();
+
+ /**
+ * Create a new UID.
+ */
+ public GUID create()
+ {
+ return new GUID(vmid, factory.create());
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/GUID.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/ID.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/ID.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/ID.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,27 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.id;
+
+import java.io.Serializable;
+
+/**
+ * A tagging interface for an identifier.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface ID
+ extends Serializable, Cloneable
+{
+ /**
+ * Expose clone as a public method.
+ */
+ Object clone();
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/ID.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/UID.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/UID.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/UID.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,170 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.id;
+
+import org.jboss.util.CloneableObject;
+import org.jboss.util.LongCounter;
+
+/**
+ * A unique identifier (uniqueness only guarantied inside of the virtual
+ * machine in which it was created).
+ *
+ * <p>The identifier is composed of:
+ * <ol>
+ * <li>A long generated from the current system time (in milliseconds).</li>
+ * <li>A long generated from a counter (which is the number of UID objects
+ * that have been created durring the life of the executing virtual
+ * machine).</li>
+ * </ol>
+ *
+ * <pre>
+ * [ time ] - [ counter ]
+ * </pre>
+ *
+ * <p>Numbers are converted to radix(Character.MAX_RADIX) when converting
+ * to strings.
+ *
+ * <p>This <i>should</i> provide adequate uniqueness for most purposes.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class UID
+ extends CloneableObject
+ implements ID
+{
+ /** A counter for generating identity values */
+ protected static final LongCounter COUNTER =
+ LongCounter.makeSynchronized(new LongCounter(0));
+
+ /** The time portion of the UID */
+ protected final long time;
+
+ /** The identity portion of the UID */
+ protected final long id;
+
+ /**
+ * Construct a new UID.
+ */
+ public UID() {
+ time = System.currentTimeMillis();
+ id = COUNTER.increment();
+ }
+
+ /**
+ * Initialze a new UID with specific values.
+ */
+ protected UID(final long time, final long id)
+ {
+ this.time = time;
+ this.id = id;
+ }
+
+ /**
+ * Copy a UID.
+ */
+ protected UID(final UID uid) {
+ time = uid.time;
+ id = uid.id;
+ }
+
+ /**
+ * Get the time portion of this UID.
+ *
+ * @return The time portion of this UID.
+ */
+ public final long getTime() {
+ return time;
+ }
+
+ /**
+ * Get the identity portion of this UID.
+ *
+ * @return The identity portion of this UID.
+ */
+ public final long getID() {
+ return id;
+ }
+
+ /**
+ * Return a string representation of this UID.
+ *
+ * @return A string representation of this UID.
+ */
+ public String toString() {
+ return
+ Long.toString(time, Character.MAX_RADIX) +
+ "-" +
+ Long.toString(id, Character.MAX_RADIX);
+ }
+
+ /**
+ * Return the hash code of this UID.
+ *
+ * @return The hash code of this UID.
+ */
+ public int hashCode() {
+ return (int)((time ^ id) >> 32);
+ }
+
+ /**
+ * Checks if the given object is equal to this UID.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equal to this UID.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ UID uid = (UID)obj;
+
+ return
+ uid.time == time &&
+ uid.id == id;
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns a UID as a string.
+ *
+ * @return UID as a string.
+ */
+ public static String asString() {
+ return new UID().toString();
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Factory Access //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Creates UID instances which are unique to the factory instance.
+ * The [ counter ] (or ID) portion of the UID are generated from a
+ * counter field instead of the global COUNTER instance.
+ */
+ public static class Factory
+ {
+ /** A counter for generating identity values */
+ protected final LongCounter counter =
+ LongCounter.makeSynchronized(new LongCounter(0));
+
+ /**
+ * Create a new UID.
+ */
+ public UID create()
+ {
+ return new UID(System.currentTimeMillis(), counter.increment());
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/UID.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/VMID.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/VMID.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/VMID.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,249 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.id;
+
+import java.net.InetAddress;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.jboss.util.Primitives;
+import org.jboss.util.HashCode;
+import org.jboss.util.platform.PID;
+
+/**
+ * An object that uniquely identifies a virtual machine.
+ *
+ * <p>The identifier is composed of:
+ * <ol>
+ * <li>The Internet address of the physical machine.</li>
+ * <li>The process identifier of the virtual machine.</li>
+ * <li>A UID to guarantee uniqness across multipule virtual
+ * machines on the same physical machine.</li>
+ * </ol>
+ *
+ * <pre>
+ * [ address ] - [ process id ] - [ time ] - [ counter ]
+ * |------- UID --------|
+ * </pre>
+ *
+ * <p>Numbers are converted to radix(Character.MAX_RADIX) when converting
+ * to strings.
+ *
+ * @see UID
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class VMID
+ implements ID
+{
+ /** The address of the current virtual machine */
+ protected final byte[] address;
+
+ /** The process identifier of the current virtual machine */
+ protected final PID pid;
+
+ /** A unique identifier to ensure uniqueness across the host machine */
+ protected final UID uid;
+
+ /** The hash code of this VMID */
+ protected final int hashCode;
+
+ /**
+ * Construct a new VMID.
+ *
+ * @param address The address of the current virtual machine.
+ * @param pid Process identifier.
+ * @param uid Unique identifier.
+ *
+ * @see #getInstance() For getting a VMID instance reference.
+ */
+ protected VMID(final byte[] address, final PID pid, final UID uid) {
+ this.address = address;
+ this.pid = pid;
+ this.uid = uid;
+
+ // generate a hashCode for this VMID
+ int code = pid.hashCode();
+ code ^= uid.hashCode();
+ code ^= HashCode.generate(address);
+ hashCode = code;
+ }
+
+ /**
+ * Copy a VMID.
+ *
+ * @param vmid VMID to copy.
+ */
+ protected VMID(final VMID vmid) {
+ this.address = vmid.address;
+ this.pid = vmid.pid;
+ this.uid = vmid.uid;
+ this.hashCode = vmid.hashCode;
+ }
+
+ /**
+ * Get the address portion of this VMID.
+ *
+ * @return The address portion of this VMID.
+ */
+ public final byte[] getAddress() {
+ return address;
+ }
+
+ /**
+ * Get the process identifier portion of this VMID.
+ *
+ * @return The process identifier portion of this VMID.
+ */
+ public final PID getProcessID() {
+ return pid;
+ }
+
+ /**
+ * Get the UID portion of this VMID.
+ *
+ * @return The UID portion of this VMID.
+ */
+ public final UID getUID() {
+ return uid;
+ }
+
+ /**
+ * Return a string representation of this VMID.
+ *
+ * @return A string representation of this VMID.
+ */
+ public String toString() {
+ StringBuffer buff = new StringBuffer();
+
+ for (int i=0; i<address.length; i++) {
+ int n = (int) (address[i] & 0xFF);
+ buff.append(Integer.toString(n, Character.MAX_RADIX));
+ }
+
+ buff.append("-").append(pid.toString(Character.MAX_RADIX));
+ buff.append("-").append(uid);
+
+ return buff.toString();
+ }
+
+ /**
+ * Return the hash code of this VMID.
+ *
+ * @return The hash code of this VMID.
+ */
+ public final int hashCode() {
+ return hashCode;
+ }
+
+ /**
+ * Check if the given object is equal to this VMID.
+ *
+ * <p>A VMID is equals to another VMID if the address,
+ * process identifer and UID portions are equal.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equals to this VMID.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ VMID vmid = (VMID)obj;
+ return
+ Primitives.equals(vmid.address, address) &&
+ vmid.pid.equals(pid) &&
+ vmid.uid.equals(uid);
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns a copy of this VMID.
+ *
+ * @return A copy of this VMID.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+ /**
+ * Returns a VMID as a string.
+ *
+ * @return VMID as a string.
+ */
+ public static String asString() {
+ return getInstance().toString();
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Instance Access //
+ /////////////////////////////////////////////////////////////////////////
+
+ /** The single instance of VMID for the running Virtual Machine */
+ private static VMID instance = null;
+
+ /**
+ * Get the VMID for the current virtual machine.
+ *
+ * @return Virtual machine identifier.
+ *
+ * @throws NestedError Failed to create VMID instance.
+ */
+ public synchronized static VMID getInstance() {
+ if (instance == null) {
+ instance = create();
+ }
+ return instance;
+ }
+
+ /**
+ * The address used when conventional methods fail to return the address
+ * of the current machine.
+ */
+ public static final byte[] UNKNOWN_HOST = { 0, 0, 0, 0 };
+
+ /**
+ * Return the current host internet address.
+ */
+ private static byte[] getHostAddress() {
+ return (byte[]) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ try {
+ return InetAddress.getLocalHost().getAddress();
+ }
+ catch (Exception e) {
+ return UNKNOWN_HOST;
+ }
+ }
+ });
+ }
+
+ /**
+ * Create the VMID for the current virtual mahcine.
+ *
+ * @return Virtual machine identifer.
+ */
+ private static VMID create() {
+ // get the local internet address for the current host
+ byte[] address = getHostAddress();
+
+ return new VMID(address, PID.getInstance(), new UID());
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/VMID.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Unique and globally unique identifier classes.</p>
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/id/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/JMXExceptionDecoder.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/JMXExceptionDecoder.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/JMXExceptionDecoder.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,82 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.jmx;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.MBeanException;
+import javax.management.ReflectionException;
+import javax.management.RuntimeOperationsException;
+import javax.management.RuntimeMBeanException;
+import javax.management.RuntimeErrorException;
+
+/**
+ * A simple helper to rethrow and/or decode those pesky
+ * JMX exceptions.
+ *
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @version $Revision$
+ */
+public class JMXExceptionDecoder
+{
+ /**
+ * Attempt to decode the given Throwable. If it
+ * is a container JMX exception, then the target
+ * is returned. Otherwise the argument is returned.
+ */
+ public static Throwable decode(final Throwable t)
+ {
+ if (t instanceof MBeanException) {
+ return ((MBeanException)t).getTargetException();
+ }
+ if (t instanceof ReflectionException) {
+ return ((ReflectionException)t).getTargetException();
+ }
+ if (t instanceof RuntimeOperationsException) {
+ return ((RuntimeOperationsException)t).getTargetException();
+ }
+ if (t instanceof RuntimeMBeanException) {
+ return ((RuntimeMBeanException)t).getTargetException();
+ }
+ if (t instanceof RuntimeErrorException) {
+ return ((RuntimeErrorException)t).getTargetError();
+ }
+
+ // can't decode
+ return t;
+ }
+
+ /**
+ * Decode and rethrow the given Throwable. If it
+ * is a container JMX exception, then the target
+ * is thrown. Otherwise the argument is thrown.
+ */
+ public static void rethrow(final Exception e)
+ throws Exception
+ {
+ if (e instanceof MBeanException) {
+ throw ((MBeanException)e).getTargetException();
+ }
+ if (e instanceof ReflectionException) {
+ throw ((ReflectionException)e).getTargetException();
+ }
+ if (e instanceof RuntimeOperationsException) {
+ throw ((RuntimeOperationsException)e).getTargetException();
+ }
+ if (e instanceof RuntimeMBeanException) {
+ throw ((RuntimeMBeanException)e).getTargetException();
+ }
+ if (e instanceof RuntimeErrorException) {
+ throw ((RuntimeErrorException)e).getTargetError();
+ }
+
+ // can't decode
+ throw e;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/JMXExceptionDecoder.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanProxy.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanProxy.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanProxy.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,287 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.jmx;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.InvocationHandler;
+
+import java.util.HashMap;
+
+import javax.management.Attribute;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
+
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * A factory for producing MBean proxies.
+ *
+ * <p>Created proxies will also implement {@link MBeanProxyInstance}
+ * allowing access to the proxies configuration.
+ *
+ * <p><b>Revisions:</b>
+ * <p><b>20020321 Adrian Brock:</b>
+ * <ul>
+ * <li>Don't process attributes using invoke.
+ * </ul>
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:rickard.oberg at telkel.com">Rickard Öberg</a>.
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:adrian.brock at happeningtimes.com">Adrian Brock</a>.
+ */
+public class MBeanProxy
+ implements InvocationHandler, MBeanProxyInstance
+{
+ /** The server to proxy invoke calls to. */
+ private final MBeanServer server;
+
+ /** The name of the object to invoke. */
+ private final ObjectName name;
+
+ /** The MBean's attributes */
+ private final HashMap attributeMap = new HashMap();
+
+ /**
+ * Construct a MBeanProxy.
+ */
+ MBeanProxy(final ObjectName name, final MBeanServer server)
+ {
+ this.name = name;
+ this.server = server;
+
+ // The MBean's attributes
+ try
+ {
+ MBeanInfo info = server.getMBeanInfo(name);
+ MBeanAttributeInfo[] attributes = info.getAttributes();
+
+ for (int i = 0; i < attributes.length; ++i)
+ attributeMap.put(attributes[i].getName(), attributes[i]);
+ }
+ catch (Exception e)
+ {
+ throw new NestedRuntimeException("Error creating MBeanProxy: " + name, e);
+ }
+ }
+
+ /** Used when args is null. */
+ private static final Object EMPTY_ARGS[] = {};
+
+ /**
+ * Invoke the configured MBean via the target MBeanServer and decode
+ * any resulting JMX exceptions that are thrown.
+ */
+ public Object invoke(final Object proxy,
+ final Method method,
+ final Object[] args)
+ throws Throwable
+ {
+ // if the method belongs to ProxyInstance, then invoke locally
+ Class type = method.getDeclaringClass();
+ if (type == MBeanProxyInstance.class) {
+ return method.invoke(this, args);
+ }
+
+ String methodName = method.getName();
+
+ // Get attribute
+ if (methodName.startsWith("get") && args == null)
+ {
+ String attrName = methodName.substring(3);
+ MBeanAttributeInfo info = (MBeanAttributeInfo) attributeMap.get(attrName);
+ if (info != null)
+ {
+ String retType = method.getReturnType().getName();
+ if (retType.equals(info.getType()))
+ {
+ try
+ {
+ return server.getAttribute(name, attrName);
+ }
+ catch (Exception e)
+ {
+ throw JMXExceptionDecoder.decode(e);
+ }
+ }
+ }
+ }
+
+ // Is attribute
+ else if (methodName.startsWith("is") && args == null)
+ {
+ String attrName = methodName.substring(2);
+ MBeanAttributeInfo info = (MBeanAttributeInfo) attributeMap.get(attrName);
+ if (info != null && info.isIs())
+ {
+ Class retType = method.getReturnType();
+ if (retType.equals(Boolean.class) || retType.equals(Boolean.TYPE))
+ {
+ try
+ {
+ return server.getAttribute(name, attrName);
+ }
+ catch (Exception e)
+ {
+ throw JMXExceptionDecoder.decode(e);
+ }
+ }
+ }
+ }
+
+ // Set attribute
+ else if (methodName.startsWith("set") && args != null && args.length == 1)
+ {
+ String attrName = methodName.substring(3);
+ MBeanAttributeInfo info = (MBeanAttributeInfo) attributeMap.get(attrName);
+ if (info != null && method.getReturnType() == Void.TYPE)
+ {
+ try
+ {
+ server.setAttribute(name, new Attribute(attrName, args[0]));
+ return null;
+ }
+ catch (Exception e)
+ {
+ throw JMXExceptionDecoder.decode(e);
+ }
+ }
+ }
+
+ // Operation
+
+ // convert the parameter types to strings for JMX
+ Class[] types = method.getParameterTypes();
+ String[] sig = new String[types.length];
+ for (int i = 0; i < types.length; i++) {
+ sig[i] = types[i].getName();
+ }
+
+ // invoke the server and decode JMX exceptions
+ try {
+ return server.invoke(name, methodName, args == null ? EMPTY_ARGS : args, sig);
+ }
+ catch (Exception e) {
+ throw JMXExceptionDecoder.decode(e);
+ }
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // MBeanProxyInstance //
+ ///////////////////////////////////////////////////////////////////////////
+
+ public final ObjectName getMBeanProxyObjectName()
+ {
+ return name;
+ }
+
+ public final MBeanServer getMBeanProxyMBeanServer()
+ {
+ return server;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Factory Methods //
+ ///////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Create an MBean proxy.
+ *
+ * @param intf The interface which the proxy will implement.
+ * @param name A string used to construct the ObjectName of the
+ * MBean to proxy to.
+ * @return A MBean proxy.
+ *
+ * @throws MalformedObjectNameException Invalid object name.
+ */
+ public static Object create(final Class intf, final String name)
+ throws MalformedObjectNameException
+ {
+ return create(intf, new ObjectName(name));
+ }
+
+ /**
+ * Create an MBean proxy.
+ *
+ * @param intf The interface which the proxy will implement.
+ * @param name A string used to construct the ObjectName of the
+ * MBean to proxy to.
+ * @param server The MBeanServer that contains the MBean to proxy to.
+ * @return A MBean proxy.
+ *
+ * @throws MalformedObjectNameException Invalid object name.
+ */
+ public static Object create(final Class intf,
+ final String name,
+ final MBeanServer server)
+ throws MalformedObjectNameException
+ {
+ return create(intf, new ObjectName(name), server);
+ }
+
+ /**
+ * Create an MBean proxy.
+ *
+ * @param intf The interface which the proxy will implement.
+ * @param name The name of the MBean to proxy invocations to.
+ * @return A MBean proxy.
+ */
+ public static Object create(final Class intf, final ObjectName name)
+ {
+ return create(intf, name, MBeanServerLocator.locate());
+ }
+
+ /**
+ * Create an MBean proxy.
+ *
+ * @param intf The interface which the proxy will implement.
+ * @param name The name of the MBean to proxy invocations to.
+ * @param server The MBeanServer that contains the MBean to proxy to.
+ * @return A MBean proxy.
+ */
+ public static Object create(final Class intf,
+ final ObjectName name,
+ final MBeanServer server)
+ {
+ // make a which delegates to MBeanProxyInstance's cl for it's class resolution
+ ClassLoader cl = new ClassLoader(intf.getClassLoader())
+ {
+ public Class loadClass(final String className) throws ClassNotFoundException
+ {
+ try {
+ return super.loadClass(className);
+ }
+ catch (ClassNotFoundException e) {
+ // only allow loading of MBeanProxyInstance from this loader
+ if (className.equals(MBeanProxyInstance.class.getName())) {
+ return MBeanProxyInstance.class.getClassLoader().loadClass(className);
+ }
+
+ // was some other classname, throw the CNFE
+ throw e;
+ }
+ }
+ };
+
+ return Proxy.newProxyInstance(cl,
+ new Class[] { MBeanProxyInstance.class, intf },
+ new MBeanProxy(name, server));
+ }
+}
+/*
+vim:tabstop=3:et:shiftwidth=3
+*/
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanProxy.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanProxyInstance.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanProxyInstance.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanProxyInstance.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,37 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.jmx;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * An interface which exposes the attributes of a {@link MBeanProxy}
+ * instance.
+ *
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @version $Revision$
+ */
+public interface MBeanProxyInstance
+{
+ /**
+ * Return the ObjectName for this proxy.
+ *
+ * @return The ObjectName for this proxy.
+ */
+ ObjectName getMBeanProxyObjectName();
+
+ /**
+ * Return the MBeanServer for this proxy.
+ *
+ * @return The ObjectName for this proxy.
+ */
+ MBeanServer getMBeanProxyMBeanServer();
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanProxyInstance.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanServerLocator.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanServerLocator.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanServerLocator.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,33 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.jmx;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
+/**
+ * A helper class to locate a MBeanServer.
+ *
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @version $Revision$
+ */
+public class MBeanServerLocator
+{
+ public static MBeanServer locate(final String agentID) {
+ MBeanServer server = (MBeanServer)
+ MBeanServerFactory.findMBeanServer(agentID).iterator().next();
+
+ return server;
+ }
+
+ public static MBeanServer locate() {
+ return locate(null);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/MBeanServerLocator.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/ObjectNameConverter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/ObjectNameConverter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/ObjectNameConverter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,388 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.util.jmx;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+/**
+ * Converts forbidden characters in the key and value of an object name
+ * to valid characters and back.
+ * <br>
+ * Character Conversion Table: (based on RFC 1738 style escapes<br>
+ * '%' => '%25' <br>
+ * '*' => '%2a' <br>
+ * ',' => '%2c' <br>
+ * ':' => '%3a' <br>
+ * '?' => '%3f' <br>
+ * '=' => '%3d' <br>
+ * <br>Thanx to William Hoyle for mention this
+ * <br><b>Attention:</b>When you have a comma in one of your property
+ * value then you have to use a <i>Hashtable</i> to provide the properties
+ * otherwise the property parsing will fail.
+ *
+ * @author <a href="mailto:andreas at jboss.org">Andreas Schaefer</a>
+ * @author <a href="mailto:william.hoyle at jungledrum.co.nz">William Hoyle</a>
+ * @version $Revision$
+ */
+public class ObjectNameConverter
+{
+ /**
+ * Parses the given Object Name String representation and
+ * replaces any invalid characters in property keays and values with
+ * valid characters.
+ * </b>Attention:</b> Do not use this method when a property
+ * key or value contain a comma because then the parsing will fail.
+ * Please use the {@link #convert( java.lang.String, java.util.Hashtable )
+ * convert( String, Hashtable )} instead because the properties
+ * are already parsed (by you).
+ *
+ * @param pObjectName String representing an Object Name which must
+ * not contain a comman inside a property value
+ *
+ * @return Created Object Name with the converted keys and values
+ * of the given Object Name
+ *
+ * @throws MalformedObjectNameException If the given Object Name
+ * is not correct
+ **/
+ public static ObjectName convert( String pObjectName )
+ throws MalformedObjectNameException
+ {
+ if( pObjectName == null ) {
+ throw new MalformedObjectNameException( "null name" );
+ }
+
+ // REVIEW, is the following a hack?: It is in the spec for patterns
+ if( pObjectName.length() == 0 ) {
+ pObjectName = "*:*";
+ }
+
+ int lIndex = pObjectName.indexOf( ":" );
+ if( lIndex < 0 ) {
+ throw new MalformedObjectNameException( "missing domain" );
+ }
+ String lDomain = pObjectName.substring( 0, lIndex );
+ if( ( lIndex + 1 ) < pObjectName.length() ) {
+ Hashtable lProperties = initProperties( pObjectName.substring( lIndex + 1 ) );
+ return new ObjectName( lDomain, lProperties );
+ } else {
+ throw new MalformedObjectNameException( "properties missing" );
+ }
+ }
+
+ /**
+ * Check the keys and values of the properties and convert invalid characters
+ *
+ * @param pDomainName Name of the Domain
+ * @param pProperites Hashtable containing the properties of the Object Name
+ *
+ * @return Created Object Name with the converted keays and values
+ *
+ * @throws MalformedObjectNameException If the given Object Name
+ * is not correct
+ **/
+ public static ObjectName convert( String pDomainName, Hashtable pProperties )
+ throws MalformedObjectNameException
+ {
+ if( pDomainName == null ) {
+ throw new MalformedObjectNameException( "missing domain" );
+ }
+ if( pProperties == null || pProperties.size() == 0 ) {
+ throw new MalformedObjectNameException(" null or empty properties" );
+ }
+ Hashtable lProperties = initProperties( pProperties, false );
+ return new ObjectName( pDomainName, lProperties );
+ }
+
+ /**
+ * Takes the properties from the given Object Name and convert
+ * special characters back
+ *
+ * @param pObjectName Given Object Name
+ *
+ * @return Hashtable with the back converted properties in it
+ * and will contain a "*" as key if the given object
+ * name is a property pattern for queries.
+ **/
+ public static Hashtable getProperties( ObjectName pObjectName )
+ {
+ Hashtable lReturn = reverseProperties( pObjectName.getKeyPropertyList() );
+ if( pObjectName.isPropertyPattern() ) {
+ lReturn.put( "*", "*" );
+ }
+ return lReturn;
+ }
+
+ /**
+ * Takes the properties from the given Object Name and convert
+ * special characters back
+ *
+ * @param pObjectName Given Object Name
+ *
+ * @return String with the original Object Name String representation and
+ * when a property pattern Object Name for queries it contains a ",*"
+ * at the end.
+ **/
+ public static String getString( ObjectName pObjectName )
+ {
+ String lReturn = pObjectName.getDomain() + ":" + reverseString( pObjectName.getKeyPropertyList() );
+ if( pObjectName.isPropertyPattern() ) {
+ lReturn = lReturn + ",*";
+ }
+ return lReturn;
+ }
+
+ /**
+ * Encrypt or decrypt the forbidden characters in an Object Name value property
+ *
+ * @param pValue Property Value of the Object Name's property list to be en- or decrypted
+ * @param pEncrypt True if the value must be encrypted otherwise decrypted
+ *
+ * @return A en- or decrypted String according to the conversion table above
+ **/
+ public static String convertCharacters( String pValue, boolean pEncrypt ) {
+ String lReturn = pValue;
+ if( pEncrypt ) {
+ int lIndex = lReturn.indexOf( "%" );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ "%25" +
+ ( ( lIndex + 1 ) < lReturn.length() ? lReturn.substring( lIndex + 1 ) : "" );
+ lIndex = lReturn.indexOf( "%", lIndex + 2 );
+ }
+ lIndex = lReturn.indexOf( "*" );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ "%2a" +
+ ( ( lIndex + 1 ) < lReturn.length() ? lReturn.substring( lIndex + 1 ) : "" );
+ lIndex = lReturn.indexOf( "*" );
+ }
+ lIndex = lReturn.indexOf( ":" );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ "%3a" +
+ ( ( lIndex + 1 ) < lReturn.length() ? lReturn.substring( lIndex + 1 ) : "" );
+ lIndex = lReturn.indexOf( ":" );
+ }
+ lIndex = lReturn.indexOf( "?" );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ "%3f" +
+ ( ( lIndex + 1 ) < lReturn.length() ? lReturn.substring( lIndex + 1 ) : "" );
+ lIndex = lReturn.indexOf( "?" );
+ }
+ lIndex = lReturn.indexOf( "=" );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ "%3d" +
+ ( ( lIndex + 1 ) < lReturn.length() ? lReturn.substring( lIndex + 1 ) : "" );
+ lIndex = lReturn.indexOf( "=" );
+ }
+ lIndex = lReturn.indexOf( "," );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ "%2c" +
+ ( ( lIndex + 1 ) < lReturn.length() ? lReturn.substring( lIndex + 1 ) : "" );
+ lIndex = lReturn.indexOf( "," );
+ }
+ } else {
+ int lIndex = lReturn.indexOf( "%2a" );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ "*" +
+ ( ( lIndex + 3 ) < lReturn.length() ? lReturn.substring( lIndex + 3 ) : "" );
+ lIndex = lReturn.indexOf( "%2a" );
+ }
+ lIndex = lReturn.indexOf( "%3a" );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ ":" +
+ ( ( lIndex + 3 ) < lReturn.length() ? lReturn.substring( lIndex + 3 ) : "" );
+ lIndex = lReturn.indexOf( "%3a" );
+ }
+ lIndex = lReturn.indexOf( "%3f" );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ "?" +
+ ( ( lIndex + 3 ) < lReturn.length() ? lReturn.substring( lIndex + 3 ) : "" );
+ lIndex = lReturn.indexOf( "%3f" );
+ }
+ lIndex = lReturn.indexOf( "%3d" );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ "=" +
+ ( ( lIndex + 3 ) < lReturn.length() ? lReturn.substring( lIndex + 3 ) : "" );
+ lIndex = lReturn.indexOf( "%3d" );
+ }
+ lIndex = lReturn.indexOf( "%2c" );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ "," +
+ ( ( lIndex + 3 ) < lReturn.length() ? lReturn.substring( lIndex + 3 ) : "" );
+ lIndex = lReturn.indexOf( "%2c" );
+ }
+ lIndex = lReturn.indexOf( "%25" );
+ while( lIndex >= 0 ) {
+ lReturn = ( lIndex > 0 ? lReturn.substring( 0, lIndex ) : "" ) +
+ "%" +
+ ( ( lIndex + 3 ) < lReturn.length() ? lReturn.substring( lIndex + 3 ) : "" );
+ lIndex = lReturn.indexOf( "%25" );
+ }
+ }
+ return lReturn;
+ }
+
+ /**
+ * takes the properties string and breaks it up into key/value pairs for
+ * insertion into a newly created hashtable.
+ *
+ * minimal validation is performed so that it doesn't blow up when
+ * constructing the kvp strings.
+ *
+ * checks for duplicate keys
+ *
+ * detects property patterns
+ *
+ */
+ private static Hashtable initProperties(String properties) throws MalformedObjectNameException
+ {
+ if (null == properties || properties.length() < 1)
+ {
+ throw new MalformedObjectNameException("null or empty properties");
+ }
+
+ // The StringTokenizer below hides malformations such as ',,' in the
+ // properties string or ',' as the first or last character.
+ // Rather than asking for tokens and building a state machine I'll
+ // just manually check for those 3 scenarios.
+
+ if (properties.startsWith(",") || properties.endsWith(",") || properties.indexOf(",,") != -1)
+ {
+ throw new MalformedObjectNameException("empty key/value pair in properties string");
+ }
+
+ Hashtable ptable = new Hashtable();
+
+ StringTokenizer tokenizer = new StringTokenizer(properties, ",");
+ boolean lPattern = false;
+ while (tokenizer.hasMoreTokens())
+ {
+ String chunk = tokenizer.nextToken();
+
+ if (chunk.equals("*"))
+ {
+ lPattern = true;
+ continue;
+ }
+
+ int keylen = chunk.length();
+ int eqpos = chunk.indexOf('=');
+
+ // test below: as in '=value' or 'key=' so that our substrings don't blow up
+ if (eqpos < 1 || (keylen == eqpos + 1))
+ {
+ throw new MalformedObjectNameException("malformed key/value pair: " + chunk);
+ }
+
+ String key = chunk.substring(0, eqpos);
+ if (ptable.containsKey(key))
+ {
+ throw new MalformedObjectNameException("duplicate key: " + key);
+ }
+
+ ptable.put(key, chunk.substring(eqpos + 1, keylen));
+ }
+
+ return initProperties( ptable, lPattern );
+ }
+
+ /**
+ * validates incoming properties hashtable
+ *
+ * builds canonical string
+ *
+ * precomputes the hashcode
+ *
+ * ATTENTION: Originally taken from the JBossMX ObjectName Implementation
+ * but adjusted to our need here.
+ */
+ private static Hashtable initProperties(Hashtable properties, boolean pPattern ) throws MalformedObjectNameException
+ {
+ if (null == properties || (!pPattern && properties.size() < 1))
+ {
+ throw new MalformedObjectNameException("null or empty properties");
+ }
+
+ Iterator it = properties.keySet().iterator();
+ Hashtable lReturn = new Hashtable( properties.size() );
+ while (it.hasNext())
+ {
+ String key = null;
+ try
+ {
+ key = (String) it.next();
+ }
+ catch (ClassCastException e)
+ {
+ throw new MalformedObjectNameException("key is not a string");
+ }
+
+ String val = null;
+ try
+ {
+ val = (String) properties.get(key);
+ }
+ catch (ClassCastException e)
+ {
+ throw new MalformedObjectNameException("value is not a string");
+ }
+
+ // Search for invalid characters and replace them
+ String lKey = convertCharacters( key, true );
+ String lValue = convertCharacters( val, true );
+
+ lReturn.put( lKey, lValue );
+ }
+ return lReturn;
+ }
+
+ private static Hashtable reverseProperties( Hashtable pProperties ) {
+ Hashtable lReturn = new Hashtable( pProperties.size() );
+ Iterator i = pProperties.keySet().iterator();
+ while( i.hasNext() ) {
+ String lKey = (String) i.next();
+ String lValue = (String) pProperties.get( lKey );
+ lKey = convertCharacters( lKey, false );
+ lValue = convertCharacters( lValue, false );
+ lReturn.put( lKey, lValue );
+ }
+ return lReturn;
+ }
+
+ private static String reverseString( Hashtable pProperties ) {
+ StringBuffer lReturn = new StringBuffer();
+ Iterator i = pProperties.keySet().iterator();
+ while( i.hasNext() ) {
+ String lKey = (String) i.next();
+ String lValue = (String) pProperties.get( lKey );
+ lKey = convertCharacters( lKey, false );
+ lValue = convertCharacters( lValue, false );
+ if( lReturn.length() > 0 ) {
+ lReturn.append( "," );
+ }
+ lReturn.append( lKey );
+ lReturn.append( "=" );
+ lReturn.append( lValue );
+ }
+ return lReturn.toString();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/ObjectNameConverter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/ObjectNameFactory.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/ObjectNameFactory.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/ObjectNameFactory.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,58 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.jmx;
+
+import java.util.Hashtable;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+/**
+ * A simple factory for creating safe object names. This factory
+ * will <b>not</b> throw MalformedObjectNameException. Any such
+ * exceptions will be translated into Errors.
+ *
+ * <p>
+ * This should only be used where it is not possible to catch a
+ * MalformedObjectNameException, such as when defining a static final in an
+ * interface.
+ *
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @version $Revision$
+ */
+public class ObjectNameFactory
+{
+ public static ObjectName create(String name) {
+ try {
+ return new ObjectName(name);
+ }
+ catch (MalformedObjectNameException e) {
+ throw new Error("Invalid ObjectName: " + name + "; " + e);
+ }
+ }
+
+ public static ObjectName create(String domain, String key, String value) {
+ try {
+ return new ObjectName(domain, key, value);
+ }
+ catch (MalformedObjectNameException e) {
+ throw new Error("Invalid ObjectName: " + domain + "," + key + "," + value + "; " + e);
+ }
+ }
+
+ public static ObjectName create(String domain, Hashtable table) {
+ try {
+ return new ObjectName(domain, table);
+ }
+ catch (MalformedObjectNameException e) {
+ throw new Error("Invalid ObjectName: " + domain + "," + table + "; " + e);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/ObjectNameFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Utilities for the <em>Java Management Extentions</em> API.
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/jmx/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming/NonSerializableFactory.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming/NonSerializableFactory.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming/NonSerializableFactory.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,234 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.util.naming;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.RefAddr;
+import javax.naming.StringRefAddr;
+import javax.naming.spi.ObjectFactory;
+
+/** A utility class that allows one to bind a non-serializable object into a
+local JNDI context. The binding will only be valid for the lifetime of the
+VM in which the JNDI InitialContext lives. An example usage code snippet is:
+
+<code>
+ // The non-Serializable object to bind
+ Object nonserializable = ...;
+ // An arbitrary key to use in the StringRefAddr. The best key is the jndi
+ // name that the object will be bound under.
+ String key = ...;
+ // This places nonserializable into the NonSerializableFactory hashmap under key
+ NonSerializableFactory.rebind(key, nonserializable);
+
+ Context ctx = new InitialContext();
+ // Bind a reference to nonserializable using NonSerializableFactory as the ObjectFactory
+ String className = nonserializable.getClass().getName();
+ String factory = NonSerializableFactory.class.getName();
+ StringRefAddr addr = new StringRefAddr("nns", key);
+ Reference memoryRef = new Reference(className, addr, factory, null);
+ ctx.rebind(key, memoryRef);
+</code>
+
+Or you can use the rebind(Context, String, Object) convience method to simplify
+the number of steps to:
+<code>
+ Context ctx = new InitialContext();
+ // The non-Serializable object to bind
+ Object nonserializable = ...;
+ // The jndiName that the object will be bound into ctx with
+ String jndiName = ...;
+ // This places nonserializable into the NonSerializableFactory hashmap under key
+ NonSerializableFactory.rebind(ctx, jndiName, nonserializable);
+</code>
+
+To unbind the object, use the following code snippet:
+
+<code>
+ new InitialContext().unbind(key);
+ NonSerializableFactory.unbind(key);
+</code>
+
+ at see javax.naming.spi.ObjectFactory
+ at see #rebind(Context, String, Object)
+
+ at author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>.
+ at version $Revision$
+*/
+public class NonSerializableFactory implements ObjectFactory
+{
+ private static Map wrapperMap = Collections.synchronizedMap(new HashMap());
+
+ /** Place an object into the NonSerializableFactory namespace for subsequent
+ access by getObject. There cannot be an already existing binding for key.
+
+ @param key, the name to bind target under. This should typically be the
+ name that will be used to bind target in the JNDI namespace, but it does
+ not have to be.
+ @param target, the non-Serializable object to bind.
+ @throws NameAlreadyBoundException, thrown if key already exists in the
+ NonSerializableFactory map
+ */
+ public static synchronized void bind(String key, Object target) throws NameAlreadyBoundException
+ {
+ if( wrapperMap.containsKey(key) == true )
+ throw new NameAlreadyBoundException(key+" already exists in the NonSerializableFactory map");
+ wrapperMap.put(key, target);
+ }
+ /** Place or replace an object in the NonSerializableFactory namespce
+ for subsequent access by getObject. Any existing binding for key will be
+ replaced by target.
+
+ @param key, the name to bind target under. This should typically be the
+ name that will be used to bind target in the JNDI namespace, but it does
+ not have to be.
+ @param target, the non-Serializable object to bind.
+ */
+ public static void rebind(String key, Object target)
+ {
+ wrapperMap.put(key, target);
+ }
+
+ /** Remove a binding from the NonSerializableFactory map.
+
+ @param key, the key into the NonSerializableFactory map to remove.
+ @throws NameNotFoundException, thrown if key does not exist in the
+ NonSerializableFactory map
+ */
+ public static void unbind(String key) throws NameNotFoundException
+ {
+ if( wrapperMap.remove(key) == null )
+ throw new NameNotFoundException(key+" was not found in the NonSerializableFactory map");
+ }
+ /** Remove a binding from the NonSerializableFactory map.
+
+ @param name, the name for the key into NonSerializableFactory map to remove.
+ The key is obtained as name.toString().
+ @throws NameNotFoundException, thrown if key does not exist in the
+ NonSerializableFactory map
+ */
+ public static void unbind(Name name) throws NameNotFoundException
+ {
+ String key = name.toString();
+ if( wrapperMap.remove(key) == null )
+ throw new NameNotFoundException(key+" was not found in the NonSerializableFactory map");
+ }
+
+ /** Lookup a value from the NonSerializableFactory map.
+ @return the object bound to key is one exists, null otherwise.
+ */
+ public static Object lookup(String key)
+ {
+ Object value = wrapperMap.get(key);
+ return value;
+ }
+ /** Lookup a value from the NonSerializableFactory map.
+ @return the object bound to key is one exists, null otherwise.
+ */
+ public static Object lookup(Name name)
+ {
+ String key = name.toString();
+ Object value = wrapperMap.get(key);
+ return value;
+ }
+
+ /** A convience method that simplifies the process of rebinding a
+ non-zerializable object into a JNDI context.
+
+ @param ctx, the JNDI context to rebind to.
+ @param key, the key to use in both the NonSerializableFactory map and JNDI. It
+ must be a valid name for use in ctx.bind().
+ @param target, the non-Serializable object to bind.
+ @throws NamingException, thrown on failure to rebind key into ctx.
+ */
+ public static synchronized void rebind(Context ctx, String key, Object target) throws NamingException
+ {
+ NonSerializableFactory.rebind(key, target);
+ // Bind a reference to target using NonSerializableFactory as the ObjectFactory
+ String className = target.getClass().getName();
+ String factory = NonSerializableFactory.class.getName();
+ StringRefAddr addr = new StringRefAddr("nns", key);
+ Reference memoryRef = new Reference(className, addr, factory, null);
+ ctx.rebind(key, memoryRef);
+ }
+
+ /** A convience method that simplifies the process of rebinding a
+ non-zerializable object into a JNDI context. This version binds the
+ target object into the default IntitialContext using name path.
+
+ @param name, the name to use as JNDI path name. The key into the
+ NonSerializableFactory map is obtained from the toString() value of name.
+ The name parameter cannot be a 0 length name.
+ Any subcontexts between the root and the name must exist.
+ @param target, the non-Serializable object to bind.
+ @throws NamingException, thrown on failure to rebind key into ctx.
+ */
+ public static synchronized void rebind(Name name, Object target) throws NamingException
+ {
+ rebind(name, target, false);
+ }
+
+ /** A convience method that simplifies the process of rebinding a
+ non-zerializable object into a JNDI context. This version binds the
+ target object into the default IntitialContext using name path.
+
+ @param name, the name to use as JNDI path name. The key into the
+ NonSerializableFactory map is obtained from the toString() value of name.
+ The name parameter cannot be a 0 length name.
+ @param target, the non-Serializable object to bind.
+ @param createSubcontexts, a flag indicating if subcontexts of name should
+ be created if they do not already exist.
+ @throws NamingException, thrown on failure to rebind key into ctx.
+ */
+ public static synchronized void rebind(Name name, Object target,
+ boolean createSubcontexts) throws NamingException
+ {
+ String key = name.toString();
+ InitialContext ctx = new InitialContext();
+ if( createSubcontexts == true && name.size() > 1 )
+ {
+ int size = name.size() - 1;
+ Util.createSubcontext(ctx, name.getPrefix(size));
+ }
+ rebind(ctx, key, target);
+ }
+
+// --- Begin ObjectFactory interface methods
+ /** Transform the obj Reference bound into the JNDI namespace into the
+ actual non-Serializable object.
+
+ @param obj, the object bound in the JNDI namespace. This must be an implementation
+ of javax.naming.Reference with a javax.naming.RefAddr of type "nns" whose
+ content is the String key used to location the non-Serializable object in the
+ NonSerializableFactory map.
+ @param name, ignored.
+ @param nameCtx, ignored.
+ @param env, ignored.
+
+ @return the non-Serializable object associated with the obj Reference if one
+ exists, null if one does not.
+ */
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env)
+ throws Exception
+ { // Get the nns value from the Reference obj and use it as the map key
+ Reference ref = (Reference) obj;
+ RefAddr addr = ref.get("nns");
+ String key = (String) addr.getContent();
+ Object target = wrapperMap.get(key);
+ return target;
+ }
+// --- End ObjectFactory interface methods
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming/NonSerializableFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming/Util.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming/Util.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming/Util.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.util.naming;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+/** A static utility class for common JNDI operations.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class Util
+{
+
+ /** Create a subcontext including any intermediate contexts.
+ @param ctx, the parent JNDI Context under which value will be bound
+ @param name, the name relative to ctx of the subcontext.
+ @return The new or existing JNDI subcontext
+ @throws NamingException, on any JNDI failure
+ */
+ public static Context createSubcontext(Context ctx, String name)
+ throws NamingException
+ {
+ Name n = ctx.getNameParser("").parse(name);
+ return createSubcontext(ctx, n);
+ }
+ /** Create a subcontext including any intermediate contexts.
+ @param ctx, the parent JNDI Context under which value will be bound
+ @param name, the name relative to ctx of the subcontext.
+ @return The new or existing JNDI subcontext
+ @throws NamingException, on any JNDI failure
+ */
+ public static Context createSubcontext(Context ctx, Name name)
+ throws NamingException
+ {
+ Context subctx = ctx;
+ for(int pos = 0; pos < name.size(); pos ++)
+ {
+ String ctxName = name.get(pos);
+ try
+ {
+ subctx = (Context) ctx.lookup(ctxName);
+ }
+ catch(NameNotFoundException e)
+ {
+ subctx = ctx.createSubcontext(ctxName);
+ }
+ // The current subctx will be the ctx for the next name component
+ ctx = subctx;
+ }
+ return subctx;
+ }
+
+ /** Bind val to name in ctx, and make sure that all intermediate contexts exist
+ @param ctx, the parent JNDI Context under which value will be bound
+ @param name, the name relative to ctx where value will be bound
+ @param value, the value to bind.
+ */
+ public static void bind(Context ctx, String name, Object value)
+ throws NamingException
+ {
+ Name n = ctx.getNameParser("").parse(name);
+ bind(ctx, n, value);
+ }
+ /** Bind val to name in ctx, and make sure that all intermediate contexts exist
+ @param ctx, the parent JNDI Context under which value will be bound
+ @param name, the name relative to ctx where value will be bound
+ @param value, the value to bind.
+ */
+ public static void bind(Context ctx, Name name, Object value)
+ throws NamingException
+ {
+ int size = name.size();
+ String atom = name.get(size-1);
+ Context parentCtx = createSubcontext(ctx, name.getPrefix(size-1));
+ parentCtx.bind(atom, value);
+ }
+
+ /** Rebind val to name in ctx, and make sure that all intermediate contexts exist
+ @param ctx, the parent JNDI Context under which value will be bound
+ @param name, the name relative to ctx where value will be bound
+ @param value, the value to bind.
+ */
+ public static void rebind(Context ctx, String name, Object value)
+ throws NamingException
+ {
+ Name n = ctx.getNameParser("").parse(name);
+ rebind(ctx, n, value);
+ }
+ /** Rebind val to name in ctx, and make sure that all intermediate contexts exist
+ @param ctx, the parent JNDI Context under which value will be bound
+ @param name, the name relative to ctx where value will be bound
+ @param value, the value to bind.
+ */
+ public static void rebind(Context ctx, Name name, Object value)
+ throws NamingException
+ {
+ int size = name.size();
+ String atom = name.get(size-1);
+ Context parentCtx = createSubcontext(ctx, name.getPrefix(size-1));
+ parentCtx.rebind(atom, value);
+ }
+
+ /** Unbinds a name from ctx, and removes parents if they are empty
+ @param ctx, the parent JNDI Context under which the name will be unbound
+ @param name, The name to unbind
+ */
+ public static void unbind(Context ctx, String name)
+ throws NamingException
+ {
+ unbind(ctx,ctx.getNameParser("").parse(name));
+ }
+
+ /** Unbinds a name from ctx, and removes parents if they are empty
+ @param ctx, the parent JNDI Context under which the name will be unbound
+ @param name, The name to unbind
+ */
+ public static void unbind(Context ctx, Name name)
+ throws NamingException
+ {
+ ctx.unbind(name); //unbind the end node in the name
+ int sz = name.size();
+ //walk the list backwards, stopping at the domain since I don't know if
+ //a domain can be unbound this way.
+ while (--sz > 0) //walk the tree backwards, stopping at the domain
+ {
+ Name pname = name.getPrefix(sz);
+ if (ctx.listBindings(pname).hasMore()) //if we have more children stop now
+ break;
+ else
+ ctx.unbind(pname); //must be no children, nuke it and continue
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/naming/Util.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Utility classes and interfaces.</p>
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/Constants.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/Constants.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/Constants.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,30 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.platform;
+
+import org.jboss.util.property.Property;
+
+/**
+ * Platform constants.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface Constants
+{
+ /** Platform dependent line separator. */
+ String LINE_SEPARATOR = Property.get("line.separator");
+
+ /** Platform dependant file separator. */
+ String FILE_SEPARATOR = Property.get("file.separator");
+
+ /** Platform dependant path separator. */
+ String PATH_SEPARATOR = Property.get("path.separator");
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/Constants.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/Java.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/Java.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/Java.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,120 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.platform;
+
+import org.jboss.util.ThrowableHandler;
+
+/**
+ * Provides common access to specifics about the version of <em>Java</em>
+ * that a virtual machine supports.
+ *
+ * <p>Determines the version of the <em>Java Virtual Machine</em> by checking
+ * for the availablity of version specific classes.<p>
+ *
+ * <p>Classes are loaded in the following order:
+ * <ol>
+ * <li><tt>java.lang.StackTraceElement</tt> was introduced in JDK 1.4</li>
+ * <li><tt>java.lang.StrictMath</tt> was introduced in JDK 1.3</li>
+ * <li><tt>java.lang.ThreadLocal</tt> was introduced in JDK 1.2</li>
+ * <li><tt>java.lang.Void</tt> was introduced in JDK 1.1</li>
+ * </ol>
+ * </p>
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class Java
+{
+ /** Prevent instantiation */
+ private Java() {}
+
+ /** Java version 1.0 token */
+ public static final int VERSION_1_0 = 0x01;
+
+ /** Java version 1.1 token */
+ public static final int VERSION_1_1 = 0x02;
+
+ /** Java version 1.2 token */
+ public static final int VERSION_1_2 = 0x03;
+
+ /** Java version 1.3 token */
+ public static final int VERSION_1_3 = 0x04;
+
+ /** Java version 1.4 token */
+ public static final int VERSION_1_4 = 0x05;
+
+ /**
+ * Private to avoid over optimization by the compiler.
+ *
+ * @see #getVersion() Use this method to access this final value.
+ */
+ private static final int VERSION;
+
+ /** Initialize VERSION. */
+ static {
+ // default to 1.0
+ int version = VERSION_1_0;
+
+ try {
+ // check for 1.1
+ Class.forName("java.lang.Void");
+ version = VERSION_1_1;
+
+ // check for 1.2
+ Class.forName("java.lang.ThreadLocal");
+ version = VERSION_1_2;
+
+ // check for 1.3
+ Class.forName("java.lang.StrictMath");
+ version = VERSION_1_3;
+
+ // check for 1.4
+ Class.forName("java.lang.StackTraceElement");
+ version = VERSION_1_4;
+ }
+ catch (ClassNotFoundException e) {
+ ThrowableHandler.add(e);
+ }
+
+ VERSION = version;
+ }
+
+ /**
+ * Return the version of <em>Java</em> supported by the VM.
+ *
+ * @return The version of <em>Java</em> supported by the VM.
+ */
+ public static int getVersion() {
+ return VERSION;
+ }
+
+ /**
+ * Retrurns true if the given version identifer is equal to the
+ * version identifier of the current virtuial machine.
+ *
+ * @param version The version identifier to check for.
+ * @return True if the current virtual machine is the same version.
+ */
+ public static boolean isVersion(final int version) {
+ return VERSION == version;
+ }
+
+ /**
+ * Retrurns true if the current virtual machine is compatible with
+ * the given version identifer.
+ *
+ * @param version The version identifier to check compatibility of.
+ * @return True if the current virtual machine is compatible.
+ */
+ public static boolean isCompatible(final int version) {
+ // if our vm is the same or newer then we are compatible
+ return VERSION >= version;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/Java.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/PID.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/PID.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/PID.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,137 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.platform;
+
+import java.io.Serializable;
+
+import java.util.Random;
+
+/**
+ * Provides access to the process identifier for this virtual machine.
+ *
+ * <p>Currently does not support native access and generates random numbers
+ * for the process id.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class PID
+ implements Serializable, Cloneable
+{
+ /** The <tt>int</tt> process identifier. */
+ protected final int id;
+
+ /**
+ * Construct a new PID.
+ *
+ * @param id Process identifier.
+ */
+ protected PID(final int id) {
+ this.id = id;
+ }
+
+ /**
+ * Get the <tt>int</tt> process identifier.
+ *
+ * @return <tt>int</tt> process identifier.
+ */
+ public final int getID() {
+ return id;
+ }
+
+ /**
+ * Return a string representation of this PID.
+ *
+ * @return A string representation of this PID.
+ */
+ public String toString() {
+ return String.valueOf(id);
+ }
+
+ /**
+ * Return a string representation of this PID.
+ *
+ * @return A string representation of this PID.
+ */
+ public String toString(int radix) {
+ return Integer.toString(id, radix);
+ }
+
+ /**
+ * Return the hash code of this PID.
+ *
+ * @return The hash code of this PID.
+ */
+ public int hashCode() {
+ return id;
+ }
+
+ /**
+ * Check if the given object is equal to this PID.
+ *
+ * @param obj Object to test equality with.
+ * @return True if object is equals to this PID.
+ */
+ public boolean equals(final Object obj) {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ PID pid = (PID)obj;
+ return pid.id == id;
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns a copy of this PID.
+ *
+ * @return A copy of this PID.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Instance Access //
+ /////////////////////////////////////////////////////////////////////////
+
+ /** The single instance of PID for the running Virtual Machine */
+ private static PID instance = null;
+
+ /**
+ * Get the PID for the current virtual machine.
+ *
+ * @return Process identifier.
+ */
+ public synchronized static PID getInstance() {
+ if (instance == null) {
+ instance = create();
+ }
+ return instance;
+ }
+
+ /**
+ * Create the PID for the current virtual mahcine.
+ *
+ * @return Process identifier.
+ */
+ private static PID create() {
+ // for now just return a random integer.
+ int random = Math.abs(new Random().nextInt());
+ return new PID(random);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/PID.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Platform specific extentions to the <i>Java programming language</i>.</p>
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>Add default implementation for PID that generates psuedo-pid-like
+ numbers
+ <li>Add native support for PID
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/platform/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/BoundPropertyAdapter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/BoundPropertyAdapter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/BoundPropertyAdapter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,38 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+/**
+ * An abstract adapter class for receiving bound property events.
+ *
+ * <p>Methods defined in this class are empty. This class exists as
+ * as convenience for creating listener objects.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class BoundPropertyAdapter
+ extends PropertyAdapter
+ implements BoundPropertyListener
+{
+ /**
+ * Notifies that this listener was bound to a property.
+ *
+ * @param map PropertyMap which contains property bound to.
+ */
+ public void propertyBound(final PropertyMap map) {}
+
+ /**
+ * Notifies that this listener was unbound from a property.
+ *
+ * @param map PropertyMap which contains property bound to.
+ */
+ public void propertyUnbound(final PropertyMap map) {}
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/BoundPropertyAdapter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/BoundPropertyListener.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/BoundPropertyListener.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/BoundPropertyListener.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,53 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+/**
+ * The listener interface for receiving bound property events (as well as
+ * property events).
+ *
+ * <p>Classes that are interested in processing a bound property event
+ * implement this interface, and register instance objects with a given
+ * {@link PropertyMap} or via
+ * {@link PropertyManager#addPropertyListener(PropertyListener)}.
+ *
+ * <p>Note that this is not the typical listener interface, as it extends
+ * from {@link PropertyListener}, and defines {@link #getPropertyName()}
+ * which is not an event triggered method. This method serves to instruct
+ * the {@link PropertyMap} the listener is registered with, which property
+ * it will bind to.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface BoundPropertyListener
+ extends PropertyListener
+{
+ /**
+ * Get the property name which this listener is bound to.
+ *
+ * @return Property name.
+ */
+ String getPropertyName();
+
+ /**
+ * Notifies that this listener was bound to a property.
+ *
+ * @param map <tt>PropertyMap</tt> which contains property bound to.
+ */
+ void propertyBound(PropertyMap map);
+
+ /**
+ * Notifies that this listener was unbound from a property.
+ *
+ * @param map <tt>PropertyMap</tt> which contains property bound to.
+ */
+ void propertyUnbound(PropertyMap map);
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/BoundPropertyListener.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/Configurable.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/Configurable.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/Configurable.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,27 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+/**
+ * An interface that allows for dynamic configuration of instance objects
+ * with properties.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface Configurable
+{
+ /**
+ * Configure this object with the given properties.
+ *
+ * @param props Properties to configure from.
+ */
+ void configure(PropertyMap props);
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/Configurable.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/DefaultPropertyReader.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/DefaultPropertyReader.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/DefaultPropertyReader.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,84 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import org.jboss.util.Objects;
+import org.jboss.util.CoercionException;
+
+/**
+ * Reads properties from files specified via a system property.
+ *
+ * <p>Unless otherwise specified, propertie filenames will be read from
+ * the <tt>org.jboss.properties</tt> singleton or array property.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class DefaultPropertyReader
+ extends FilePropertyReader
+{
+ //
+ // Might want to have a org.jboss.properties.property.name or something
+ // property to determine what property name to read from.
+ //
+ // For now just use 'properties'
+ //
+
+ /** Default property name to read filenames from */
+ public static final String DEFAULT_PROPERTY_NAME = "properties";
+
+ /**
+ * Construct a <tt>DefaultPropertyReader</tt> with a specified property
+ * name.
+ *
+ * @param name Property name.
+ */
+ public DefaultPropertyReader(final String propertyName) {
+ super(getFilenames(propertyName));
+ }
+
+ /**
+ * Construct a <tt>DefaultPropertyReader</tt>.
+ */
+ public DefaultPropertyReader() {
+ this(DEFAULT_PROPERTY_NAME);
+ }
+
+ /**
+ * Get an array of filenames to load.
+ *
+ * @param propertyName Property to read filenames from.
+ * @return Array of filenames.
+ */
+ public static String[] getFilenames(final String propertyName)
+ throws PropertyException
+ {
+ String filenames[];
+
+ // check for singleton property first
+ Object filename = PropertyManager.getProperty(propertyName);
+ if (filename != null) {
+ filenames = new String[] { String.valueOf(filename) };
+ }
+ else {
+ // if no singleton property exists then look for array props
+ Object[] values = PropertyManager.getArrayProperty(propertyName);
+ try {
+ // return coerced string objects
+ filenames = (String[])Objects.coerce(values, String[].class);
+ }
+ catch (CoercionException e) {
+ throw new PropertyException(e);
+ }
+ }
+
+ return filenames;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/DefaultPropertyReader.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/FieldBoundPropertyListener.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/FieldBoundPropertyListener.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/FieldBoundPropertyListener.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,163 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import org.jboss.util.FieldInstance;
+import org.jboss.util.NullArgumentException;
+import org.jboss.util.Classes;
+import org.jboss.util.Objects;
+import org.jboss.util.CoercionException;
+import org.jboss.util.ThrowableHandler;
+
+/**
+ * Binds property values to class fields.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FieldBoundPropertyListener
+ extends BoundPropertyAdapter
+{
+ /** Property name which we are bound to */
+ protected final String propertyName;
+
+ /** Field instance */
+ protected final FieldInstance fieldInstance;
+
+ /**
+ * Constructs a <tt>FieldBoundPropertyListener</tt>.
+ *
+ * @param instance Instance object.
+ * @param fieldName Field name.
+ * @param propertyName Property to bind to.
+ *
+ * @throws NullArgumentException Property name is <tt>null</tt>.
+ */
+ public FieldBoundPropertyListener(final Object instance,
+ final String fieldName,
+ final String propertyName)
+ {
+ if (propertyName == null)
+ throw new NullArgumentException("propertyName");
+ // FieldInstance checks instance & fieldName
+
+ this.propertyName = propertyName;
+
+ try {
+ // construct field instance
+ fieldInstance = new FieldInstance(instance, fieldName);
+ try {
+ fieldInstance.getField().setAccessible(true);
+ }
+ catch (SecurityException e) {
+ ThrowableHandler.add(e);
+ }
+
+ // force the given class to load, so that any CoersionHelpers
+ // that are nested in it are loaded properly
+ Classes.forceLoad(fieldInstance.getField().getType());
+ }
+ catch (NoSuchFieldException e) {
+ throw new PropertyException(e);
+ }
+ }
+
+ /**
+ * Constructs a <tt>FieldBoundPropertyListener</tt>.
+ *
+ * <p>Field name is used for property name.
+ *
+ * @param instance Instance object.
+ * @param fieldName Field name.
+ */
+ public FieldBoundPropertyListener(final Object instance,
+ final String fieldName)
+ {
+ this(instance, fieldName, fieldName);
+ }
+
+ /**
+ * Get the property name which this listener is bound to.
+ *
+ * @return Property name.
+ */
+ public final String getPropertyName() {
+ return propertyName;
+ }
+
+ /**
+ * Filter the property value prior to coercing and binding to field.
+ *
+ * <p>Allows instance to filter values prior to object coercion and
+ * field binding.
+ *
+ * @param value Property value.
+ */
+ public String filterValue(String value) {
+ return value;
+ }
+
+ /**
+ * Coerce and set specified value to field.
+ *
+ * @param value Field value.
+ *
+ * @throws PropertyException Failed to set field value.
+ */
+ protected void setFieldValue(String value) {
+ try {
+ // filter property value
+ value = filterValue(value);
+
+ // coerce value to field type
+ Class type = fieldInstance.getField().getType();
+ Object coerced = Objects.coerce(value, type);
+
+ // bind value to field
+ fieldInstance.set(coerced);
+ }
+ catch (IllegalAccessException e) {
+ throw new PropertyException(e);
+ }
+ catch (CoercionException e) {
+ throw new PropertyException(e);
+ }
+ }
+
+ /**
+ * Notifies that a property has been added.
+ *
+ * @param event Property event.
+ */
+ public void propertyAdded(final PropertyEvent event) {
+ setFieldValue(event.getPropertyValue());
+ }
+
+ /**
+ * Notifies that a property has changed
+ *
+ * @param event Property event
+ */
+ public void propertyChanged(final PropertyEvent event) {
+ setFieldValue(event.getPropertyValue());
+ }
+
+ /**
+ * Notifies that this listener was bound to a property.
+ *
+ * @param map PropertyMap which contains property bound to.
+ */
+ public void propertyBound(final PropertyMap map) {
+ // only set the field if the map contains the property already
+ if (map.containsProperty(propertyName)) {
+ setFieldValue(map.getProperty(propertyName));
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/FieldBoundPropertyListener.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/FilePropertyReader.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/FilePropertyReader.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/FilePropertyReader.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,114 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import java.util.Properties;
+import java.util.Map;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+
+import java.net.URL;
+
+import org.jboss.util.NullArgumentException;
+
+/**
+ * Reads properties from one or more files.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FilePropertyReader
+ implements PropertyReader
+{
+ /** Array of filenames to load properties from */
+ protected String[] filenames;
+
+ /**
+ * Construct a FilePropertyReader with an array of filenames
+ * to read from.
+ *
+ * @param filenames Filenames to load properties from
+ */
+ public FilePropertyReader(String[] filenames) {
+ if (filenames == null)
+ throw new NullArgumentException("filenames");
+
+ this.filenames = filenames;
+ }
+
+ /**
+ * Construct a FilePropertyReader with a single filename to read from.
+ *
+ * @param filename Filename to load properties from
+ */
+ public FilePropertyReader(String filename) {
+ this(new String[] { filename });
+ }
+
+ /**
+ * Get an input stream for the given filename.
+ *
+ * @param filename File name to get input stream for.
+ * @return Input stream for file.
+ *
+ * @throws IOException Failed to get input stream for file.
+ */
+ protected InputStream getInputStream(String filename) throws IOException {
+ File file = new File(filename);
+ return new FileInputStream(file);
+ }
+
+ /**
+ * Load properties from a file into a properties map.
+ *
+ * @param props Properties map to load properties into.
+ * @param filename Filename to read properties from.
+ *
+ * @throws IOException Failed to load properties from filename.
+ * @throws IllegalArgumentException Filename is invalid.
+ */
+ protected void loadProperties(Properties props, String filename)
+ throws IOException
+ {
+ if (filename == null)
+ throw new NullArgumentException("filename");
+ if (filename.equals(""))
+ throw new IllegalArgumentException("filename");
+
+ InputStream in = new BufferedInputStream(getInputStream(filename));
+ props.load(in);
+ in.close();
+ }
+
+ /**
+ * Read properties from each specified filename
+ *
+ * @return Read properties
+ *
+ * @throws PropertyException Failed to read properties.
+ * @throws IOException I/O error while reading properties.
+ */
+ public Map readProperties()
+ throws PropertyException, IOException
+ {
+ Properties props = new Properties();
+
+ // load each specified property file
+ for (int i=0; i<filenames.length; i++) {
+ loadProperties(props, filenames[i]);
+ }
+
+ return props;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/FilePropertyReader.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/MethodBoundPropertyListener.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/MethodBoundPropertyListener.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/MethodBoundPropertyListener.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,190 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import java.beans.Introspector;
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.beans.BeanInfo;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+import org.jboss.util.ThrowableHandler;
+import org.jboss.util.Objects;
+
+/**
+ * Binds property values to class methods.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class MethodBoundPropertyListener
+ extends BoundPropertyAdapter
+{
+ /** Property name which we are bound to */
+ protected final String propertyName;
+
+ /** Instance object that contains setter method */
+ protected final Object instance;
+
+ /** Property setter method */
+ protected final Method setter;
+
+ /** Property descriptor */
+ protected final PropertyDescriptor descriptor;
+
+ /**
+ * Construct a MethodBoundPropertyListener.
+ *
+ * @param instance Instance object that contains setter method.
+ * @param propertyName The name of the property which will be bound.
+ * @param beanPropertyName The name of the property setter method.
+ *
+ * @throws PropertyException
+ */
+ public MethodBoundPropertyListener(final Object instance,
+ final String propertyName,
+ final String beanPropertyName)
+ {
+ this.instance = instance;
+ this.propertyName = propertyName;
+
+ try {
+ descriptor = getPropertyDescriptor(beanPropertyName);
+ if (descriptor == null) {
+ throw new PropertyException
+ ("missing method for: " + beanPropertyName);
+ }
+
+ setter = descriptor.getWriteMethod();
+ if (setter == null) {
+ throw new PropertyException
+ ("missing setter method for: " + beanPropertyName);
+ }
+ try {
+ setter.setAccessible(true);
+ }
+ catch (SecurityException e) {
+ ThrowableHandler.add(e);
+ }
+ }
+ catch (IntrospectionException e) {
+ throw new PropertyException(e);
+ }
+ }
+
+ /**
+ * Get the <tt>PropertyDescriptor</tt> for the given bean property name.
+ *
+ * @param beanPropertyName Bean property name.
+ * @return <tt>PropertyDescriptor</tt>.
+ */
+ private PropertyDescriptor getPropertyDescriptor(final String beanPropertyName)
+ throws IntrospectionException
+ {
+ Class instanceType = instance.getClass();
+ BeanInfo beanInfo = Introspector.getBeanInfo(instanceType);
+ PropertyDescriptor descriptors[] = beanInfo.getPropertyDescriptors();
+ PropertyDescriptor descriptor = null;
+
+ for (int i=0; i<descriptors.length; i++) {
+ if (descriptors[i].getName().equals(beanPropertyName)) {
+ descriptor = descriptors[i];
+ break;
+ }
+ }
+
+ return descriptor;
+ }
+
+ /**
+ * Construct a MethodBoundPropertyListener.
+ *
+ * @param instance Instance object that contains setter method.
+ * @param propertyName The name of the property which will be bound.
+ */
+ public MethodBoundPropertyListener(final Object instance,
+ final String propertyName)
+ {
+ this(instance, propertyName, propertyName);
+ }
+
+ /**
+ * Get the property name which this listener is bound to.
+ *
+ * @return Property name.
+ */
+ public final String getPropertyName() {
+ return propertyName;
+ }
+
+ /**
+ * Coerce and invoke the property setter method on the instance.
+ *
+ * @param value Method value.
+ *
+ * @throws PropertyException Failed to invoke setter method.
+ */
+ protected void invokeSetter(String value) {
+ try {
+ // coerce value to field type
+ Class type = descriptor.getPropertyType();
+ Object coerced = Objects.coerce(value, type);
+ // System.out.println("type: " + type);
+ // System.out.println("coerced: " + coerced);
+
+ // invoke the setter method
+ setter.invoke(instance, new Object[] { coerced });
+ }
+ catch (InvocationTargetException e) {
+ Throwable target = e.getTargetException();
+ if (target instanceof PropertyException) {
+ throw (PropertyException)target;
+ }
+ else {
+ throw new PropertyException(target);
+ }
+ }
+ catch (Exception e) {
+ throw new PropertyException(e);
+ }
+ }
+
+ /**
+ * Notifies that a property has been added.
+ *
+ * @param event Property event.
+ */
+ public void propertyAdded(final PropertyEvent event) {
+ invokeSetter(event.getPropertyValue());
+ }
+
+ /**
+ * Notifies that a property has changed.
+ *
+ * @param event Property event.
+ */
+ public void propertyChanged(final PropertyEvent event) {
+ invokeSetter(event.getPropertyValue());
+ }
+
+ /**
+ * Notifies that this listener was bound to a property.
+ *
+ * @param map PropertyMap which contains property bound to.
+ */
+ public void propertyBound(final PropertyMap map) {
+ // only set the field if the map contains the property already
+ if (map.containsProperty(propertyName)) {
+ invokeSetter(map.getProperty(propertyName));
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/MethodBoundPropertyListener.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/Property.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/Property.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/Property.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,141 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+/**
+ * Provides shorter method names for working with the {@link PropertyManager}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class Property
+{
+ /**
+ * Add a property listener
+ *
+ * @param listener Property listener to add
+ */
+ public static void addListener(PropertyListener listener) {
+ PropertyManager.addPropertyListener(listener);
+ }
+
+ /**
+ * Add an array of property listeners
+ *
+ * @param listeners Array of property listeners to add
+ */
+ public static void addListeners(PropertyListener[] listeners) {
+ PropertyManager.addPropertyListeners(listeners);
+ }
+
+ /**
+ * Remove a property listener
+ *
+ * @param listener Property listener to remove
+ * @return True if listener was removed
+ */
+ public static boolean removeListener(PropertyListener listener) {
+ return PropertyManager.removePropertyListener(listener);
+ }
+
+ /**
+ * Set a property
+ *
+ * @param name Property name
+ * @param value Property value
+ * @return Previous property value or null
+ */
+ public static String set(String name, String value) {
+ return PropertyManager.setProperty(name, value);
+ }
+
+ /**
+ * Remove a property
+ *
+ * @param name Property name
+ * @return Removed property value or null
+ */
+ public static String remove(String name) {
+ return PropertyManager.getProperty(name);
+ }
+
+ /**
+ * Get a property
+ *
+ * @param name Property name
+ * @param defaultValue Default property value
+ * @return Property value or default
+ */
+ public static String get(String name, String defaultValue) {
+ return PropertyManager.getProperty(name, defaultValue);
+ }
+
+ /**
+ * Get a property
+ *
+ * @param name Property name
+ * @return Property value or null
+ */
+ public static String get(String name) {
+ return PropertyManager.getProperty(name);
+ }
+
+ /**
+ * Get an array style property
+ *
+ * @param base Base property name
+ * @param defaultValues Default property values
+ * @return Array of property values or default
+ */
+ public static String[] getArray(String base, String[] defaultValues) {
+ return PropertyManager.getArrayProperty(base, defaultValues);
+ }
+
+ /**
+ * Get an array style property
+ *
+ * @param name Property name
+ * @return Array of property values or empty array
+ */
+ public static String[] getArray(String name) {
+ return PropertyManager.getArrayProperty(name);
+ }
+
+ /**
+ * Check if a property of the given name exists.
+ *
+ * @param name Property name
+ * @return True if property exists
+ */
+ public static boolean exists(String name) {
+ return PropertyManager.containsProperty(name);
+ }
+
+ /**
+ * Get a property group for the given property base
+ *
+ * @param basename Base property name
+ * @return Property group
+ */
+ public static PropertyGroup getGroup(String basename) {
+ return PropertyManager.getPropertyGroup(basename);
+ }
+
+ /**
+ * Get a property group for the given property base at the given index
+ *
+ * @param basename Base property name
+ * @param index Array property index
+ * @return Property group
+ */
+ public static PropertyGroup getGroup(String basename, int index) {
+ return PropertyManager.getPropertyGroup(basename, index);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/Property.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyAdapter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyAdapter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyAdapter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,44 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+/**
+ * An abstract adapter class for receving property events.
+ *
+ * <p>Methods defined in this class are empty. This class exists as
+ * as convenience for creating listener objects.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class PropertyAdapter
+ implements PropertyListener
+{
+ /**
+ * Notifies that a property was added.
+ *
+ * @param event Property event.
+ */
+ public void propertyAdded(final PropertyEvent event) {}
+
+ /**
+ * Notifies that a property was removed.
+ *
+ * @param event Property event.
+ */
+ public void propertyRemoved(final PropertyEvent event) {}
+
+ /**
+ * Notifies that a property has changed.
+ *
+ * @param event Property event.
+ */
+ public void propertyChanged(final PropertyEvent event) {}
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyAdapter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyContainer.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyContainer.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyContainer.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,147 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import java.util.Properties;
+
+/**
+ * Provides helper methods for working with instance or class properties.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class PropertyContainer
+ extends PropertyMap
+{
+ /** The group name for this container. */
+ protected String groupname = "<unknown>";
+
+ /**
+ * Initialize the container with a property group.
+ *
+ * @param group Properties.
+ */
+ public PropertyContainer(final Properties props) {
+ super(props);
+ }
+
+ /**
+ * Initialize the container with a property group of the given name.
+ *
+ * @param groupname Property group name.
+ */
+ public PropertyContainer(final String groupname) {
+ this(Property.getGroup(groupname));
+ this.groupname = groupname;
+ }
+
+ /**
+ * Initialize the container with a property group of the given class name.
+ *
+ * @param type The class whos name will be the property group name.
+ */
+ public PropertyContainer(final Class type) {
+ this(type.getName());
+ }
+
+ /**
+ * Creates a {@link FieldBoundPropertyListener} for the field and
+ * property name and adds it the underlying property group.
+ *
+ * @param name The field name to bind values to.
+ * @param propertyName The property name to bind to.
+ *
+ * @throws IllegalArgumentException Field of property name is null or
+ * empty.
+ */
+ protected void bindField(final String name, final String propertyName) {
+ if (name == null || name.equals(""))
+ throw new IllegalArgumentException("name");
+ if (propertyName == null || propertyName.equals(""))
+ throw new IllegalArgumentException("propertyName");
+
+ addPropertyListener
+ (new FieldBoundPropertyListener(this, name, propertyName));
+ }
+
+ /**
+ * Creates a {@link FieldBoundPropertyListener} for the field and
+ * property name and adds it the underlying property group.
+ *
+ * @param name The field name and property to bind values to.
+ *
+ * @throws IllegalArgumentException Field of property name is null or
+ * empty.
+ */
+ protected void bindField(final String name) {
+ bindField(name, name);
+ }
+
+ /**
+ * Creates a {@link MethodBoundPropertyListener} for the method and
+ * property name and adds it the underlying property group.
+ *
+ * @param name The method name to bind values to.
+ * @param propertyName The property name to bind to.
+ *
+ * @throws IllegalArgumentException Method of property name is null or
+ * empty.
+ */
+ protected void bindMethod(final String name, final String propertyName) {
+ if (name == null || name.equals(""))
+ throw new IllegalArgumentException("name");
+ if (propertyName == null || propertyName.equals(""))
+ throw new IllegalArgumentException("propertyName");
+
+ addPropertyListener // opposite of field bound =(
+ (new MethodBoundPropertyListener(this, propertyName, name));
+ }
+
+ /**
+ * Creates a {@link MethodBoundPropertyListener} for the method and
+ * property name and adds it the underlying property group.
+ *
+ * @param name The method name and property to bind values to.
+ *
+ * @throws IllegalArgumentException Method of property name is null or
+ * empty.
+ */
+ protected void bindMethod(final String name) {
+ bindMethod(name, name);
+ }
+
+ private String makeName(final String name) {
+ return groupname + "." + name;
+ }
+
+ protected void throwException(final String name)
+ throws PropertyException
+ {
+ throw new PropertyException(makeName(name));
+ }
+
+ protected void throwException(final String name, final String msg)
+ throws PropertyException
+ {
+ throw new PropertyException(makeName(name) + ": " + msg);
+ }
+
+ protected void throwException(final String name, final String msg, final Throwable nested)
+ throws PropertyException
+ {
+ throw new PropertyException(makeName(name) + ": " + msg, nested);
+ }
+
+ protected void throwException(final String name, final Throwable nested)
+ throws PropertyException
+ {
+ throw new PropertyException(makeName(name), nested);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyContainer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyError.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyError.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyError.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,60 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import org.jboss.util.NestedError;
+
+/**
+ * Thrown to indicate a fatal problem with the property system.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class PropertyError
+ extends NestedError
+{
+ /**
+ * Construct a <tt>PropertyError</tt> with the specified detail
+ * message.
+ *
+ * @param msg Detail message.
+ */
+ public PropertyError(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>PropertyError</tt> with the specified detail
+ * message and nested <tt>Throwable</tt>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public PropertyError(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Construct a <tt>PropertyError</tt> with the specified
+ * nested <tt>Throwable</tt>.
+ *
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public PropertyError(Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Construct a <tt>PropertyError</tt> with no detail.
+ */
+ public PropertyError() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyError.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyEvent.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyEvent.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyEvent.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,95 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import java.util.EventObject;
+
+import org.jboss.util.NullArgumentException;
+
+/**
+ * A property event.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class PropertyEvent
+ extends EventObject
+{
+ /** Property name. */
+ protected final String name;
+
+ /** Property value. */
+ protected final String value;
+
+ /**
+ * Construct a new <tt>PropertyEvent</tt>.
+ *
+ * @param source The source of the event.
+ * @param name The property name effected.
+ * @param value The value of the property effected.
+ *
+ * @throws NullArgumentException Name or source is <tt>null</tt>.
+ */
+ public PropertyEvent(final Object source,
+ final String name,
+ final String value)
+ {
+ super(source);
+
+ if (name == null)
+ throw new NullArgumentException("name");
+ // value can be null
+
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * Construct a new <tt>PropertyEvent</tt>.
+ *
+ * @param source The source of the event.
+ * @param name The property name effected.
+ *
+ * @throws NullArgumentException Name or source is <tt>null</tt>.
+ */
+ public PropertyEvent(Object source, String name) {
+ this(source, name, null);
+ }
+
+ /**
+ * Get the name of the property that is effected.
+ *
+ * @return Property name.
+ */
+ public final String getPropertyName() {
+ return name;
+ }
+
+ /**
+ * Get the value of the property that is effected.
+ *
+ * @return The value of the property that is effected or <tt>null</tt>.
+ */
+ public final String getPropertyValue() {
+ return value;
+ }
+
+ /**
+ * Return a string representation of this event.
+ *
+ * @return A string representation of this event.
+ */
+ public String toString() {
+ return super.toString() +
+ "{ name=" + name +
+ ", value=" + value +
+ " }";
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyEvent.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyException.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyException.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyException.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,61 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * This exception is thrown to indicate a non-fatal problem with the
+ * property system.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class PropertyException
+ extends NestedRuntimeException
+{
+ /**
+ * Construct a <tt>PropertyException</tt> with the specified detail
+ * message.
+ *
+ * @param msg Detail message.
+ */
+ public PropertyException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>PropertyException</tt> with the specified detail
+ * message and nested <tt>Throwable</tt>.
+ *
+ * @param msg Detail message.
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public PropertyException(String msg, Throwable nested) {
+ super(msg, nested);
+ }
+
+ /**
+ * Construct a <tt>PropertyException</tt> with the specified
+ * nested <tt>Throwable</tt>.
+ *
+ * @param nested Nested <tt>Throwable</tt>.
+ */
+ public PropertyException(Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Construct a <tt>PropertyException</tt> with no detail.
+ */
+ public PropertyException() {
+ super();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyGroup.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyGroup.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyGroup.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,281 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import java.util.Properties;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.jboss.util.NullArgumentException;
+
+/**
+ * This is a helper class to access a group of properties with out having to
+ * refer to their full names.
+ *
+ * <p>This class needs more work to be fully functional. It should suffice
+ * for adding property listeners and getting/setting property values,
+ * but other activies might not work out so well.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class PropertyGroup
+ extends PropertyMap
+{
+ /** Base property name */
+ protected final String basename;
+
+ /**
+ * Construct a <tt>PropertyGroup</tt>.
+ *
+ * @param basename Base property name.
+ * @param container Property container.
+ *
+ * @throws NullArgumentException Basename is <tt>null</tt>.
+ */
+ public PropertyGroup(final String basename, final Properties container) {
+ super(container);
+
+ if (basename == null)
+ throw new NullArgumentException("basename");
+
+ this.basename = basename;
+ }
+
+ /**
+ * Get the base property name for this group.
+ *
+ * @return Base property name.
+ */
+ public final String getBaseName() {
+ return basename;
+ }
+
+ /**
+ * Make a fully qualified property name.
+ *
+ * @param suffix Property name suffix.
+ */
+ private String makePropertyName(final String suffix) {
+ return basename + PropertyMap.PROPERTY_NAME_SEPARATOR + suffix;
+ }
+
+ /**
+ * Make a fully qualified property name.
+ *
+ * @param suffix Property name suffix.
+ */
+ private String makePropertyName(final Object suffix) {
+ return makePropertyName(String.valueOf(suffix));
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Properties Overrides //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Check if this <tt>PropertyMap</tt> contains a given property name.
+ *
+ * @param name Property name.
+ * @return True if property map or defaults contains key.
+ */
+ public boolean containsKey(final Object name) {
+ if (name == null)
+ throw new NullArgumentException("name");
+
+ return super.containsKey(makePropertyName(name));
+ }
+
+ /**
+ * Set a property.
+ *
+ * @param name Property name.
+ * @param value Property value.
+ * @return Previous property value or <tt>null</tt>.
+ */
+ public Object put(final Object name, final Object value) {
+ if (name == null)
+ throw new NullArgumentException("name");
+
+ return super.put(makePropertyName(name), value);
+ }
+
+ /**
+ * Get a property
+ *
+ * @param name Property name.
+ * @return Property value or <tt>null</tt>.
+ */
+ public Object get(final Object name) {
+ if (name == null)
+ throw new NullArgumentException("name");
+
+ return super.get(makePropertyName(name));
+ }
+
+ /**
+ * Remove a property.
+ *
+ * @param name Property name.
+ * @return Removed property value.
+ */
+ public Object remove(final Object name) {
+ if (name == null)
+ throw new NullArgumentException("name");
+
+ return super.remove(makePropertyName(name));
+ }
+
+ /**
+ * Returns an entry set for all properties in this group.
+ *
+ * <p>
+ * This is currently ver inefficient, but should get the
+ * job done for now.
+ */
+ public Set entrySet()
+ {
+ final Set superSet = super.entrySet(true);
+
+ return new java.util.AbstractSet()
+ {
+ private boolean isInGroup(Map.Entry entry)
+ {
+ String key = (String)entry.getKey();
+ return key.startsWith(basename);
+ }
+
+ public int size()
+ {
+ Iterator iter = superSet.iterator();
+ int count = 0;
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ if (isInGroup(entry)) {
+ count++;
+ }
+ }
+
+ return count;
+ }
+
+ public Iterator iterator()
+ {
+ return new Iterator()
+ {
+ private Iterator iter = superSet.iterator();
+ private Object next;
+
+ public boolean hasNext()
+ {
+ if (next != null)
+ return true;
+
+ while (next == null) {
+ if (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ if (isInGroup(entry)) {
+ next = entry;
+ return true;
+ }
+ }
+ else {
+ break;
+ }
+ }
+
+ return false;
+ }
+
+ public Object next()
+ {
+ if (next == null)
+ throw new java.util.NoSuchElementException();
+
+ Object obj = next;
+ next = null;
+
+ return obj;
+ }
+
+ public void remove()
+ {
+ iter.remove();
+ }
+ };
+ }
+ };
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Property Listener Overrides //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Add a bound property listener.
+ *
+ * <p>Generates a fully qualified property name and adds the listener
+ * under that name.
+ *
+ * @param listener Bound property listener to add.
+ */
+ protected void addPropertyListener(final BoundPropertyListener listener) {
+ // get the bound property name
+ String name = makePropertyName(listener.getPropertyName());
+
+ // get the bound listener list for the property
+ List list = (List)boundListeners.get(name);
+
+ // if list is null, then add a new list
+ if (list == null) {
+ list = new ArrayList();
+ boundListeners.put(name, list);
+ }
+
+ // if listener is not in the list already, then add it
+ if (! list.contains(listener)) {
+ list.add(listener);
+ // notify listener that is is bound
+ listener.propertyBound(this);
+ }
+ }
+
+ /**
+ * Remove a bound property listener.
+ *
+ * <p>Generates a fully qualified property name and removes the listener
+ * under that name.
+ *
+ * @param listener Bound property listener to remove.
+ * @return True if listener was removed.
+ */
+ protected boolean removePropertyListener(final BoundPropertyListener listener) {
+ // get the bound property name
+ String name = makePropertyName(listener.getPropertyName());
+
+ // get the bound listener list for the property
+ List list = (List)boundListeners.get(name);
+ boolean removed = false;
+ if (list != null) {
+ removed = list.remove(listener);
+
+ // notify listener that is was unbound
+ if (removed) listener.propertyUnbound(this);
+ }
+
+ return removed;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyGroup.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyListener.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyListener.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyListener.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,47 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import java.util.EventListener;
+
+/**
+ * The listener interface for receiving property events.
+ *
+ * <p>Classes that are interested in processing a property event implement
+ * this interface, and register instance objects with a given PropertyMap
+ * or the PropertyManager via <code>addPropertyListener()</code>.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface PropertyListener
+ extends EventListener
+{
+ /**
+ * Notifies that a property was added
+ *
+ * @param event Property event
+ */
+ void propertyAdded(PropertyEvent event);
+
+ /**
+ * Notifies that a property was removed
+ *
+ * @param event Property event
+ */
+ void propertyRemoved(PropertyEvent event);
+
+ /**
+ * Notifies that a property has changed
+ *
+ * @param event Property event
+ */
+ void propertyChanged(PropertyEvent event);
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyListener.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyManager.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyManager.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyManager.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,286 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import java.util.Map;
+import java.util.Iterator;
+
+import java.io.IOException;
+
+import org.jboss.util.ThrowableHandler;
+
+/**
+ * A more robust replacement of <tt>java.lang.System</tt> for property
+ * access.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class PropertyManager
+{
+ /** Property reader list property name */
+ public static final String READER_PROPERTY_NAME = "org.jboss.util.property.reader";
+
+ /** Token which specifies the default property reader */
+ public static final String DEFAULT_PROPERTY_READER_TOKEN = "DEFAULT";
+
+ /** The default property reader name array */
+ private static final String[] DEFAULT_PROPERTY_READERS = {
+ DEFAULT_PROPERTY_READER_TOKEN
+ };
+
+ /** Default property container */
+ private static PropertyMap props;
+
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private PropertyManager() {}
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Property System Initialization //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Initialize the property system.
+ */
+ static {
+ // construct default property container and initialze from system props
+ props = new PropertyMap();
+ props.putAll(System.getProperties());
+
+ // replace system props to enable notifications via System.setProperty()
+ System.setProperties(props);
+
+ // load properties from initial property readers
+ String[] readerNames = getArrayProperty(READER_PROPERTY_NAME,
+ DEFAULT_PROPERTY_READERS);
+
+ // construct each source and read its properties
+ for (int i=0; i<readerNames.length; i++) {
+ try {
+ if (readerNames[i].equals(DEFAULT_PROPERTY_READER_TOKEN)) {
+ load(new DefaultPropertyReader());
+ }
+ else {
+ load(readerNames[i]);
+ }
+ }
+ catch (IOException e) {
+ ThrowableHandler.add(e);
+ }
+ }
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Access to Default Map //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Get the default <tt>PropertyMap</tt>.
+ *
+ * @return Default <tt>PropertyMap</tt>.
+ */
+ public static PropertyMap getDefaultPropertyMap() {
+ return props;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+ // Static Accessors to Default Property Map //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Add a property listener.
+ *
+ * @param listener Property listener to add.
+ */
+ public static void addPropertyListener(final PropertyListener listener) {
+ props.addPropertyListener(listener);
+ }
+
+ /**
+ * Add an array of property listeners.
+ *
+ * @param listeners Array of property listeners to add.
+ */
+ public static void addPropertyListeners(final PropertyListener[] listeners)
+ {
+ props.addPropertyListeners(listeners);
+ }
+
+ /**
+ * Remove a property listener.
+ *
+ * @param listener Property listener to remove.
+ * @return True if listener was removed.
+ */
+ public static boolean removePropertyListener(final PropertyListener listener)
+ {
+ return props.removePropertyListener(listener);
+ }
+
+ /**
+ * Load properties from a map.
+ *
+ * @param prefix Prefix to append to all map keys (or <tt>null</tt>).
+ * @param map Map containing properties to load.
+ */
+ public static void load(final String prefix,
+ final Map map)
+ throws PropertyException
+ {
+ props.load(prefix, map);
+ }
+
+ /**
+ * Load properties from a map.
+ *
+ * @param map Map containing properties to load.
+ */
+ public static void load(final Map map)
+ throws PropertyException, IOException
+ {
+ props.load(map);
+ }
+
+ /**
+ * Load properties from a <tt>PropertyReader</tt>.
+ *
+ * @param reader <tt>PropertyReader</tt> to read properties from.
+ */
+ public static void load(final PropertyReader reader)
+ throws PropertyException, IOException
+ {
+ props.load(reader);
+ }
+
+ /**
+ * Load properties from a <tt>PropertyReader</tt> specifed by the
+ * given class name.
+ *
+ * @param classname Class name of a <tt>PropertyReader</tt> to
+ * read from.
+ */
+ public static void load(final String classname)
+ throws PropertyException, IOException
+ {
+ props.load(classname);
+ }
+
+ /**
+ * Set a property.
+ *
+ * @param name Property name.
+ * @param value Property value.
+ * @return Previous property value or <tt>null</tt>.
+ */
+ public static String setProperty(final String name, final String value) {
+ return (String)props.setProperty(name, value);
+ }
+
+ /**
+ * Remove a property.
+ *
+ * @param name Property name.
+ * @return Removed property value or <tt>null</tt>.
+ */
+ public static String removeProperty(final String name) {
+ return props.removeProperty(name);
+ }
+
+ /**
+ * Get a property.
+ *
+ * @param name Property name.
+ * @param defaultValue Default property value.
+ * @return Property value or default.
+ */
+ public static String getProperty(final String name,
+ final String defaultValue)
+ {
+ return props.getProperty(name, defaultValue);
+ }
+
+ /**
+ * Get a property.
+ *
+ * @param name Property name.
+ * @return Property value or <tt>null</tt>.
+ */
+ public static String getProperty(final String name) {
+ return props.getProperty(name);
+ }
+
+ /**
+ * Get an array style property.
+ *
+ * @param base Base property name.
+ * @param defaultValues Default property values.
+ * @return Array of property values or default.
+ */
+ public static String[] getArrayProperty(final String base,
+ final String[] defaultValues)
+ {
+ return props.getArrayProperty(base, defaultValues);
+ }
+
+ /**
+ * Get an array style property.
+ *
+ * @param name Property name.
+ * @return Array of property values or empty array.
+ */
+ public static String[] getArrayProperty(final String name) {
+ return props.getArrayProperty(name);
+ }
+
+ /**
+ * Return an iterator over all contained property names.
+ *
+ * @return Property name iterator.
+ */
+ public static Iterator names() {
+ return props.names();
+ }
+
+ /**
+ * Check if this map contains a given property.
+ *
+ * @param name Property name.
+ * @return True if contains property.
+ */
+ public static boolean containsProperty(final String name) {
+ return props.containsProperty(name);
+ }
+
+ /**
+ * Get a property group for the given property base.
+ *
+ * @param basename Base property name.
+ * @return Property group.
+ */
+ public static PropertyGroup getPropertyGroup(final String basename) {
+ return props.getPropertyGroup(basename);
+ }
+
+ /**
+ * Get a property group for the given property base at the given index.
+ *
+ * @param basename Base property name.
+ * @param index Array property index.
+ * @return Property group.
+ */
+ public static PropertyGroup getPropertyGroup(final String basename,
+ final int index)
+ {
+ return props.getPropertyGroup(basename, index);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyManager.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyMap.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyMap.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyMap.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,712 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+import java.util.Properties;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.jboss.util.NullArgumentException;
+
+/**
+ * A replacement for the standard <code>java.util.Properties</code>
+ * class which adds, among others, property event capabilities.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class PropertyMap
+ extends Properties
+{
+ /** Property name separator */
+ public static final String PROPERTY_NAME_SEPARATOR = ".";
+
+ /** Empty array property */
+ public static final String[] EMPTY_ARRAY_PROPERTY = new String[0];
+
+ /** Property listener list */
+ protected transient List unboundListeners;
+
+ /** Bound property name -> listener list map */
+ protected transient Map boundListeners;
+
+ /**
+ * Construct a PropertyMap with default properties.
+ *
+ * @param defaults Default properties.
+ */
+ public PropertyMap(Properties defaults) {
+ super(defaults);
+ init();
+ }
+
+ /**
+ * Construct a PropertyMap.
+ */
+ public PropertyMap() {
+ this(null);
+ }
+
+ /** Initialized listener lists */
+ private void init() {
+ unboundListeners = Collections.synchronizedList(new ArrayList());
+ boundListeners = Collections.synchronizedMap(new HashMap());
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Properties Override Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Check if this PropertyMap contains a given property name.
+ *
+ * @param name Property name.
+ * @return True if property map or defaults contains key.
+ */
+ public boolean containsKey(Object name) {
+ if (name == null)
+ throw new NullArgumentException("name");
+
+ boolean contains = super.containsKey(name);
+ return (contains || defaults == null) ? contains : defaults.containsKey(name);
+ }
+
+ /**
+ * Set a property.
+ *
+ * @param name Property name.
+ * @param value Property value.
+ * @return Previous property value or null.
+ */
+ public Object put(Object name, Object value) {
+ if (name == null)
+ throw new NullArgumentException("name");
+ // value can be null
+
+ // check if this is a new addition or not prior to updating the hash
+ boolean add = !containsKey(name);
+ Object prev = super.put(name, value);
+
+ PropertyEvent event =
+ new PropertyEvent(this, String.valueOf(name), String.valueOf(value));
+
+ // fire propertyAdded or propertyChanged
+ if (add) {
+ firePropertyAdded(event);
+ }
+ else {
+ firePropertyChanged(event);
+ }
+
+ return prev;
+ }
+
+ /**
+ * Get a property.
+ *
+ * @param name Property name.
+ * @return Property value or null.
+ *
+ * @throws IllegalArgumentException Name is empty or null.
+ */
+ public Object get(Object name) {
+ if (name == null || name.equals(""))
+ throw new IllegalArgumentException("name");
+
+ Object obj = super.get(name);
+ String value = (obj instanceof String) ? (String)obj : null;
+
+ if (value == null && defaults != null) {
+ value = defaults.getProperty(String.valueOf(name));
+ }
+
+ return value;
+ }
+
+ /**
+ * Remove a property.
+ *
+ * @param name Property name.
+ * @return Removed property value.
+ */
+ public Object remove(Object name) {
+ if (name == null)
+ throw new NullArgumentException("name");
+
+ // check if there is a property with this name
+ boolean contains = containsKey(name);
+ String value = null;
+
+ if (contains) {
+ value = (String)super.remove(name);
+ if (defaults != null) {
+ Object obj = defaults.remove(name);
+ if (value == null) {
+ value = (String)obj;
+ }
+ }
+
+ PropertyEvent event = new PropertyEvent(this, (String)name, value);
+ firePropertyRemoved(event);
+ }
+
+ return value;
+ }
+
+ /**
+ * Returns a set of keys for all entries in this group and optionally
+ * all of the keys in the defaults map.
+ */
+ public Set keySet(final boolean includeDefaults)
+ {
+ if (includeDefaults) {
+ Set set = new HashSet();
+ set.addAll(defaults.keySet());
+ set.addAll(super.keySet());
+ return Collections.synchronizedSet(set);
+ }
+
+ return super.keySet();
+ }
+
+ /**
+ * Returns a set of entrys for all entries in this group and optionally
+ * all of the entrys in the defaults map.
+ */
+ public Set entrySet(final boolean includeDefaults)
+ {
+ if (includeDefaults) {
+ Set set = new HashSet();
+ set.addAll(defaults.entrySet());
+ set.addAll(super.entrySet());
+ return Collections.synchronizedSet(set);
+ }
+
+ return super.entrySet();
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Property Listener Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Add a property listener.
+ *
+ * @param listener Property listener to add.
+ */
+ public void addPropertyListener(PropertyListener listener) {
+ if (listener == null)
+ throw new NullArgumentException("listener");
+
+ if (listener instanceof BoundPropertyListener) {
+ addPropertyListener((BoundPropertyListener)listener);
+ }
+ else {
+ // only add the listener if it is not in the list already
+ if (! unboundListeners.contains(listener))
+ unboundListeners.add(listener);
+ }
+ }
+
+ /**
+ * Add a bound property listener.
+ *
+ * @param listener Bound property listener to add.
+ */
+ protected void addPropertyListener(BoundPropertyListener listener) {
+ // get the bound property name
+ String name = listener.getPropertyName();
+
+ // get the bound listener list for the property
+ List list = (List)boundListeners.get(name);
+
+ // if list is null, then add a new list
+ if (list == null) {
+ list = Collections.synchronizedList(new ArrayList());
+ boundListeners.put(name, list);
+ }
+
+ // if listener is not in the list already, then add it
+ if (! list.contains(listener)) {
+ list.add(listener);
+ // notify listener that is is bound
+ listener.propertyBound(this);
+ }
+ }
+
+ /**
+ * Add an array of property listeners.
+ *
+ * @param listeners Array of property listeners to add.
+ */
+ public void addPropertyListeners(PropertyListener[] listeners) {
+ if (listeners == null)
+ throw new NullArgumentException("listeners");
+
+ for (int i=0; i<listeners.length; i++) {
+ addPropertyListener(listeners[i]);
+ }
+ }
+
+ /**
+ * Remove a property listener.
+ *
+ * @param listener Property listener to remove.
+ * @return True if listener was removed.
+ */
+ public boolean removePropertyListener(PropertyListener listener) {
+ if (listener == null)
+ throw new NullArgumentException("listener");
+
+ boolean removed = false;
+ if (listener instanceof BoundPropertyListener) {
+ removed = removePropertyListener((BoundPropertyListener)listener);
+ }
+ else {
+ removed = unboundListeners.remove(listener);
+ }
+
+ return removed;
+ }
+
+ /**
+ * Remove a bound property listener.
+ *
+ * @param listener Bound property listener to remove.
+ * @return True if listener was removed.
+ */
+ protected boolean removePropertyListener(BoundPropertyListener listener) {
+ // get the bound property name
+ String name = listener.getPropertyName();
+
+ // get the bound listener list for the property
+ List list = (List)boundListeners.get(name);
+ boolean removed = false;
+ if (list != null) {
+ removed = list.remove(listener);
+
+ // notify listener that is was unbound
+ if (removed) listener.propertyUnbound(this);
+ }
+ return removed;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Listener Notification Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Fire a property added event to the given list of listeners.
+ *
+ * @param list Listener list.
+ * @param event Property event.
+ */
+ private void firePropertyAdded(List list, PropertyEvent event) {
+ if (list == null) return;
+
+ int size = list.size();
+ for (int i=0; i<size; i++) {
+ PropertyListener listener = (PropertyListener)list.get(i);
+ listener.propertyAdded(event);
+ }
+ }
+
+ /**
+ * Fire a property added event to all registered listeners.
+ *
+ * @param event Property event.
+ */
+ protected void firePropertyAdded(PropertyEvent event) {
+ // fire all bound listeners (if any) first
+ if (boundListeners != null) {
+ List list = (List)boundListeners.get(event.getPropertyName());
+ if (list != null) {
+ firePropertyAdded(list, event);
+ }
+ }
+
+ // next fire all unbound listeners
+ firePropertyAdded(unboundListeners, event);
+ }
+
+ /**
+ * Fire a property removed event to the given list of listeners.
+ *
+ * @param list Listener list.
+ * @param event Property event.
+ */
+ private void firePropertyRemoved(List list, PropertyEvent event) {
+ if (list == null) return;
+
+ int size = list.size();
+ for (int i=0; i<size; i++) {
+ PropertyListener listener = (PropertyListener)list.get(i);
+ listener.propertyRemoved(event);
+ }
+ }
+
+ /**
+ * Fire a property removed event to all registered listeners.
+ *
+ * @param event Property event.
+ */
+ protected void firePropertyRemoved(PropertyEvent event) {
+ // fire all bound listeners (if any) first
+ if (boundListeners != null) {
+ List list = (List)boundListeners.get(event.getPropertyName());
+ if (list != null) {
+ firePropertyRemoved(list, event);
+ }
+ }
+
+ // next fire all unbound listeners
+ firePropertyRemoved(unboundListeners, event);
+ }
+
+ /**
+ * Fire a property changed event to the given list of listeners.
+ *
+ * @param list Listener list.
+ * @param event Property event.
+ */
+ private void firePropertyChanged(List list, PropertyEvent event) {
+ if (list == null) return;
+
+ int size = list.size();
+ for (int i=0; i<size; i++) {
+ PropertyListener listener = (PropertyListener)list.get(i);
+ listener.propertyChanged(event);
+ }
+ }
+
+ /**
+ * Fire a property changed event to all listeners.
+ *
+ * @param event Property event.
+ * @param value Property value.
+ */
+ protected void firePropertyChanged(PropertyEvent event) {
+ // fire all bound listeners (if any) first
+ if (boundListeners != null) {
+ List list = (List)boundListeners.get(event.getPropertyName());
+ if (list != null) {
+ firePropertyChanged(list, event);
+ }
+ }
+
+ // next fire all unbound listeners
+ firePropertyChanged(unboundListeners, event);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Property Loading Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Make a optionaly prefixed property name.
+ *
+ * @param base Base property name.
+ * @param prefix Optional prefix (can be null).
+ * @return Property name.
+ */
+ protected String makePrefixedPropertyName(String base, String prefix) {
+ String name = base;
+
+ if (prefix != null) {
+ StringBuffer buff = new StringBuffer(base);
+ if (prefix != null) {
+ buff.insert(0, PROPERTY_NAME_SEPARATOR);
+ buff.insert(0, prefix);
+ }
+ return buff.toString();
+ }
+
+ return name;
+ }
+
+ /**
+ * Load properties from a map.
+ *
+ * @param prefix Prefix to append to all map keys (or null).
+ * @param map Map containing properties to load.
+ */
+ public void load(String prefix, Map map) throws PropertyException {
+ // prefix can be null
+ if (map == null)
+ throw new NullArgumentException("map");
+
+ // set properties for each key in map
+ Iterator iter = map.keySet().iterator();
+ while (iter.hasNext()) {
+ // make a string key with optional prefix
+ String key = String.valueOf(iter.next());
+ String name = makePrefixedPropertyName(key, prefix);
+ String value = String.valueOf(map.get(name));
+
+ // set the property
+ setProperty(name, value);
+ }
+ }
+
+ /**
+ * Load properties from a map.
+ *
+ * @param map Map containing properties to load.
+ */
+ public void load(Map map) throws PropertyException {
+ load(null, map);
+ }
+
+ /**
+ * Load properties from a PropertyReader.
+ *
+ * @param reader PropertyReader to read properties from.
+ */
+ public void load(PropertyReader reader) throws PropertyException, IOException {
+ if (reader == null)
+ throw new NullArgumentException("reader");
+
+ load(reader.readProperties());
+ }
+
+ /**
+ * Load properties from a PropertyReader specifed by the given class name.
+ *
+ * @param className Class name of a PropertyReader to read from.
+ */
+ public void load(String className) throws PropertyException, IOException {
+ if (className == null)
+ throw new NullArgumentException("className");
+
+ PropertyReader reader = null;
+
+ try {
+ Class type = Class.forName(className);
+ reader = (PropertyReader)type.newInstance();
+ }
+ catch (Exception e) {
+ throw new PropertyException(e);
+ }
+
+ // load the properties from the source
+ load(reader);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Direct Property Access Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Set a property.
+ *
+ * <p>Returns Object instead of String due to limitations with
+ * <code>java.util.Properties</code>.
+ *
+ * @param name Property name.
+ * @param value Property value.
+ * @return Previous property value or null.
+ */
+ public Object setProperty(String name, String value) {
+ return put(name, value);
+ }
+
+ /**
+ * Remove a property.
+ *
+ * @param name Property name.
+ * @return Removed property value or null.
+ */
+ public String removeProperty(String name) {
+ return (String)remove(name);
+ }
+
+ /**
+ * Get a property.
+ *
+ * @param name Property name.
+ * @param defaultValue Default property value.
+ * @return Property value or default.
+ */
+ public String getProperty(String name, String defaultValue) {
+ String value = (String)get(name);
+ return (value != null) ? value : defaultValue;
+ }
+
+ /**
+ * Get a property.
+ *
+ * @param name Property name.
+ * @return Property value or null.
+ */
+ public String getProperty(String name) {
+ return getProperty(name, null);
+ }
+
+ /**
+ * Make an indexed property name.
+ *
+ * @param base Base property name.
+ * @param index Property index.
+ * @return Indexed property name.
+ */
+ protected String makeIndexPropertyName(String base, int index) {
+ return base + PROPERTY_NAME_SEPARATOR + index;
+ }
+
+ /**
+ * Get an array style property.
+ *
+ * <p>Array properties are specified as:
+ * <code>base_property_name.<b>INDEX</b>.
+ *
+ * <p>Indexes begin with zero and must be contiguous. A break in
+ * continuity signals the end of the array.
+ *
+ * @param base Base property name.
+ * @param defaultValues Default property values.
+ * @return Array of property values or default.
+ */
+ public String[] getArrayProperty(String base, String[] defaultValues) {
+ if (base == null)
+ throw new NullArgumentException("base");
+
+ // create a new list to store indexed values into
+ List list = new LinkedList();
+
+ int i=0;
+ while (true) {
+ // make the index property name
+ String name = makeIndexPropertyName(base, i);
+
+ // see if there is a value for this property
+ String value = getProperty(name);
+
+ if (value != null) {
+ list.add(value);
+ }
+ else if (i >= 0) {
+ break; // no more index properties
+ }
+
+ i++;
+ }
+
+ String values[] = defaultValues;
+
+ // if the list is not empty, then return it as an array
+ if (list.size() != 0) {
+ values = (String[])list.toArray(new String[list.size()]);
+ }
+
+ return values;
+ }
+
+ /**
+ * Get an array style property.
+ *
+ * @param name Property name.
+ * @return Array of property values or empty array.
+ */
+ public String[] getArrayProperty(String name) {
+ return getArrayProperty(name, EMPTY_ARRAY_PROPERTY);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Iterator Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return an iterator over all contained property names.
+ *
+ * @return Property name iterator.
+ */
+ public Iterator names() {
+ return keySet().iterator();
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // State Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Check if this map contains a given property.
+ *
+ * @param name Property name.
+ * @return True if contains property.
+ */
+ public boolean containsProperty(String name) {
+ return containsKey(name);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Property Group Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Get a property group for the given property base.
+ *
+ * @param basename Base property name.
+ * @return Property group.
+ */
+ public PropertyGroup getPropertyGroup(String basename) {
+ return new PropertyGroup(basename, this);
+ }
+
+ /**
+ * Get a property group for the given property base at the given index.
+ *
+ * @param basename Base property name.
+ * @param index Array property index.
+ * @return Property group.
+ */
+ public PropertyGroup getPropertyGroup(String basename, int index) {
+ String name = makeIndexPropertyName(basename, index);
+ return getPropertyGroup(name);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Serialization Methods //
+ /////////////////////////////////////////////////////////////////////////
+
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException
+ {
+ // reset the listener lists
+ init();
+
+ stream.defaultReadObject();
+ }
+
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException
+ {
+ stream.defaultWriteObject();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyMap.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyReader.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyReader.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyReader.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,34 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property;
+
+import java.util.Map;
+
+import java.io.IOException;
+
+/**
+ * Iterface used to allow a <tt>PropertyMap</tt> to read property definitions
+ * in an implementation independent fashion.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface PropertyReader
+{
+ /**
+ * Read a map of properties from this input source.
+ *
+ * @return Read properties map.
+ *
+ * @throws PropertyException Failed to read properties.
+ * @throws IOException I/O error while reading properties.
+ */
+ Map readProperties() throws PropertyException, IOException;
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/PropertyReader.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/jmx
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/jmx/SystemPropertyClassValue.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/jmx/SystemPropertyClassValue.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/jmx/SystemPropertyClassValue.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,129 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.property.jmx;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A helper for setting system properties based on class availablity.<p>
+ *
+ * It has a static method and an MBean wrapper for dynamic configuration.<p>
+ *
+ * The class is first checked for availablity before setting the system
+ * property.
+
+ * @jmx:mbean
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>
+ */
+public class SystemPropertyClassValue
+ implements SystemPropertyClassValueMBean
+{
+ public static final Logger log = Logger.getLogger(SystemPropertyClassValue.class);
+
+ /** Property name. */
+ protected String property;
+
+ /** Class Name. */
+ protected String className;
+
+ /**
+ * Constructor.
+ */
+ public SystemPropertyClassValue()
+ {
+ }
+
+ /**
+ * The system property value
+ *
+ * @jmx:managed-attribute
+ */
+ public String getProperty()
+ {
+ return property;
+ }
+
+ /**
+ * The system property value
+ *
+ * @jmx:managed-attribute
+ */
+ public void setProperty(String property)
+ {
+ this.property = property;
+ }
+
+ /**
+ * The class name to use a value for the system property
+ * when it is available
+ *
+ * @jmx:managed-attribute
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * The class name to use a value for the system property
+ * when it is available
+ *
+ * @jmx:managed-attribute
+ */
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+
+ /**
+ * JBoss lifecycle
+ *
+ * @jmx:managed-operation
+ */
+ public void create()
+ {
+ Throwable error = setSystemPropertyClassValue(property, className);
+ if (error != null)
+ log.trace("Error loading class " + className + " property " + property + " not set.", error);
+ }
+
+ /**
+ * Sets the system property to a class when the class is available.
+ *
+ * @param property the property to set
+ * @param className the class to set as the properties value
+ * @return any error loading the class
+ * @exception IllegalArgumentException for a null or empty parameter
+ */
+ public static Throwable setSystemPropertyClassValue(String property, String className)
+ {
+ // Validation
+ if (property == null || property.trim().length() == 0)
+ throw new IllegalArgumentException("Null or empty property");
+ if (className == null || className.trim().length() == 0)
+ throw new IllegalArgumentException("Null or empty class name");
+
+ // Is the class available?
+ try
+ {
+ Thread.currentThread().getContextClassLoader().loadClass(className);
+ }
+ catch (Throwable problem)
+ {
+ return problem;
+ }
+
+ // The class is there, set the property.
+ System.setProperty(property, className);
+ return null;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/jmx/SystemPropertyClassValue.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>An advanced property access, managment and notification system.</p>
+
+ <p>This system provides some helpful additions to the standard Java
+ property system. Some of these features include:
+ <ul>
+ <li>Events</li>
+ <li>Convenience Grouping</li>
+ <li>Array Properties</li>
+ </ul>
+ </p>
+
+ <p>
+ Aims to provide a <i>JavaBeans</i> style api for accessing properties
+ in a simple, powerful and consistent fashion.
+ </p>
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>Re-design storeage of properties; making them more tree-like</li>
+ <li>Re-design property binding events; probably force use of a
+ PropertyContainer sub-class or another <i>JavaBeans</i> like
+ object</li>
+ <li>Move back to planet57.core?</li>
+ <li>Allow reading properties from a URL</li>
+ <li>Read properties correctly with win32 or unix style pathing</li>
+ <li>Create a property parser framework</li>
+ <li>Add an XML property parser</li>
+ <li>Add property map support and general configuration objects access.
+ This will allow property.foo to be mapped to com.whatever.class.</li>
+ <li>Allow configuration objects to take more than one property group name,
+ using the order for precidence.</li>
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/property/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ArrayListEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ArrayListEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ArrayListEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,28 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * A property editor for {@link java.util.ArrayList}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ArrayListEditor
+ extends ListEditor
+{
+ protected List createList()
+ {
+ return new ArrayList();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ArrayListEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BigDecimalEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BigDecimalEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BigDecimalEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,36 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+
+import java.math.BigDecimal;
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * A property editor for {@link java.math.BigDecimal}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ */
+public class BigDecimalEditor
+ extends TextPropertyEditorSupport
+{
+ /**
+ * Returns a BigDecimal for the input object converted to a string.
+ *
+ * @return a BigDecimal object
+ *
+ */
+ public Object getValue()
+ {
+ return new BigDecimal(getAsText());
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BigDecimalEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BitSetEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BitSetEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BitSetEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,27 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.BitSet;
+
+/**
+ * A property editor for {@link java.lang.BitSet}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class BitSetEditor
+ extends IntegerEditor
+{
+ public void setValue(final Integer i)
+ {
+ super.setValue(new BitSet(i.intValue()));
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BitSetEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BooleanEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BooleanEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BooleanEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * A property editor for {@link java.lang.Boolean}.
+ *
+ * @version $Revision$
+ * @author Scott.Stark at jboss.org
+ */
+public class BooleanEditor extends PropertyEditorSupport
+{
+ private static final String[] BOOLEAN_TAGS = {"true", "false"};
+
+ /**
+ * Map the argument text into Boolean.TRUE or Boolean.FALSE
+ * using Boolean.valueOf.
+ */
+ public void setAsText(final String text)
+ {
+ Object newValue = Boolean.valueOf(text);
+ setValue(newValue);
+ }
+
+ /**
+ * @return the values {"true", "false"}
+ */
+ public String[] getTags()
+ {
+ return BOOLEAN_TAGS;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/BooleanEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ClassEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ClassEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ClassEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,45 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * A property editor for {@link java.lang.Class}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ClassEditor
+ extends TextPropertyEditorSupport
+{
+ /**
+ * Returns a Class for the input object converted to a string.
+ *
+ * @return a Class object
+ *
+ * @throws NestedRuntimeException Failed to create Class instance.
+ */
+ public Object getValue()
+ {
+ try
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ String classname = getAsText();
+ Class type = loader.loadClass(classname);
+
+ return type;
+ }
+ catch (Exception e)
+ {
+ throw new NestedRuntimeException(e);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ClassEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/CollectionEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/CollectionEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/CollectionEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,45 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.StringTokenizer;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * A property editor for {@link java.util.Collection}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class CollectionEditor
+ extends PropertyEditorSupport
+{
+ protected Collection createCollection()
+ {
+ return new LinkedList();
+ }
+
+ public void setAsText(final String text)
+ {
+ Collection bag = createCollection();
+ StringTokenizer stok = new StringTokenizer(text, ",");
+
+ // need to handle possible "[" and "]"
+
+ while (stok.hasMoreTokens()) {
+ bag.add(stok.nextToken().trim());
+ }
+
+ setValue(bag);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/CollectionEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/DOM4JElementEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/DOM4JElementEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/DOM4JElementEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,83 @@
+
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ *
+ */
+
+package org.jboss.util.propertyeditor;
+
+import java.beans.PropertyEditorSupport;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
+import org.dom4j.io.XMLWriter;
+import org.jboss.util.NestedRuntimeException;
+import org.jboss.util.propertyeditor.TextPropertyEditorSupport;
+
+
+
+/**
+ * DOM4JElementEditor.java
+ *
+ *
+ * Created: Fri Feb 7 08:36:34 2003
+ *
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @version
+ */
+
+public class DOM4JElementEditor extends PropertyEditorSupport {
+ public DOM4JElementEditor() {
+
+ }
+
+ public void setAsText(String text)
+ {
+ if (text == null || text.length() == 0)
+ {
+ setValue(null);
+ } // end of if ()
+ else
+ {
+ try {
+ Reader reader = new StringReader(text);
+ SAXReader saxReader = new SAXReader();
+ Document doc = saxReader.read(reader);
+ setValue(doc.getRootElement());
+ }
+ catch (DocumentException e)
+ {
+ throw new NestedRuntimeException(e);
+ }
+ }
+ }
+
+ public String getAsText()
+ {
+ if (getValue() == null)
+ {
+ return null;
+ } // end of if ()
+
+ try {
+ Element element = (Element)getValue();
+ Writer writer = new StringWriter();
+ XMLWriter xmlWriter = new XMLWriter(writer);
+ xmlWriter.write(element);
+ return writer.toString();
+ }
+ catch (IOException e)
+ {
+ throw new NestedRuntimeException(e);
+ }
+ }
+}// DOM4JElementEditor
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/DOM4JElementEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/DateEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/DateEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/DateEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,45 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * A property editor for {@link Date}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ */
+public class DateEditor
+ extends TextPropertyEditorSupport
+{
+ /**
+ * Returns a Date for the input object converted to a string.
+ *
+ * @return a Date object
+ *
+ */
+ public Object getValue()
+ {
+ try
+ {
+ DateFormat df = DateFormat.getDateInstance();
+ return df.parse(getAsText());
+ }
+ catch (ParseException e)
+ {
+ throw new NestedRuntimeException(e);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/DateEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/FileEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/FileEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/FileEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,42 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * A property editor for {@link java.io.File}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FileEditor
+ extends TextPropertyEditorSupport
+{
+ /**
+ * Returns a URL for the input object converted to a string.
+ *
+ * @return a URL object
+ *
+ * @throws NestedRuntimeException An IOException occured.
+ */
+ public Object getValue()
+ {
+ try {
+ return new File(getAsText()).getCanonicalFile();
+ }
+ catch (IOException e) {
+ throw new NestedRuntimeException(e);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/FileEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/HashSetEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/HashSetEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/HashSetEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,28 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * A property editor for {@link java.util.HashSet}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class HashSetEditor
+ extends SetEditor
+{
+ protected Set createSet()
+ {
+ return new HashSet();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/HashSetEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/InetAddressEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/InetAddressEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/InetAddressEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,57 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.jboss.util.Strings;
+
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * A property editor for {@link java.net.InetAddress}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:Adrian.Brock at HappeningTimes.com">Adrian Brock</a>
+ */
+public class InetAddressEditor
+ extends TextPropertyEditorSupport
+{
+ /**
+ * Returns a InetAddress for the input object converted to a string.
+ *
+ * @return an InetAddress
+ *
+ * @throws NestedRuntimeException An UnknownHostException occured.
+ */
+ public Object getValue()
+ {
+ try
+ {
+ String text = getAsText();
+ if (text==null)
+ {
+ return null;
+ }
+ if (text.startsWith("/"))
+ {
+ // seems like localhost sometimes will look like:
+ // /127.0.0.1 and the getByNames barfs on the slash - JGH
+ text = text.substring(1);
+ }
+ return InetAddress.getByName(Strings.replaceProperties(text));
+ }
+ catch (UnknownHostException e)
+ {
+ throw new NestedRuntimeException(e);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/InetAddressEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/IntegerEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/IntegerEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/IntegerEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,32 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * A property editor for {@link java.lang.Integer}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author Scott.Stark at jboss.org
+ */
+public class IntegerEditor
+ extends PropertyEditorSupport
+{
+ /**
+ * Map the argument text into and Integer using Integer.valueOf.
+ */
+ public void setAsText(final String text)
+ {
+ Integer newValue = Integer.valueOf(text);
+ setValue(newValue);
+ }
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/IntegerEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/IteratorEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/IteratorEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/IteratorEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,27 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.List;
+
+/**
+ * A property editor for {@link java.util.Iterator}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class IteratorEditor
+ extends ListEditor
+{
+ public void setValue(final List list)
+ {
+ super.setValue((Object)list.iterator());
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/IteratorEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/LinkedListEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/LinkedListEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/LinkedListEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,28 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.List;
+import java.util.LinkedList;
+
+/**
+ * A property editor for {@link java.util.LinkedList}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class LinkedListEditor
+ extends ListEditor
+{
+ protected List createList()
+ {
+ return new LinkedList();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/LinkedListEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ListEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ListEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ListEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,34 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.LinkedList;
+
+/**
+ * A property editor for {@link java.util.List}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ListEditor
+ extends CollectionEditor
+{
+ protected Collection createCollection()
+ {
+ return createList();
+ }
+
+ protected List createList()
+ {
+ return new LinkedList();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ListEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ListIteratorEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ListIteratorEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ListIteratorEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,27 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.List;
+
+/**
+ * A property editor for {@link java.util.ListIterator}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ListIteratorEditor
+ extends IteratorEditor
+{
+ public void setValue(final List list)
+ {
+ super.setValue((Object)list.listIterator());
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ListIteratorEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ObjectNameEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ObjectNameEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ObjectNameEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,42 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
+
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * A property editor for {@link javax.management.ObjectName}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ObjectNameEditor
+ extends TextPropertyEditorSupport
+{
+ /**
+ * Returns a ObjectName for the input object converted to a string.
+ *
+ * @return a ObjectName object
+ *
+ * @throws NestedRuntimeException An MalformedObjectNameException occured.
+ */
+ public Object getValue()
+ {
+ try {
+ return new ObjectName(getAsText());
+ }
+ catch (MalformedObjectNameException e) {
+ throw new NestedRuntimeException(e);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/ObjectNameEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/PropertiesEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/PropertiesEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/PropertiesEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,49 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.Properties;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * A property editor for {@link java.util.Properties}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class PropertiesEditor
+ extends TextPropertyEditorSupport
+{
+ /**
+ * Returns a Properties object initialized with the input object
+ * as a properties file based string.
+ *
+ * @return a Properties object
+ *
+ * @throws NestedRuntimeException An IOException occured.
+ */
+ public Object getValue()
+ {
+ try {
+ ByteArrayInputStream is = new ByteArrayInputStream(getAsText().getBytes());
+ Properties p = new Properties();
+ p.load(is);
+
+ return p;
+ }
+ catch (IOException e) {
+ throw new NestedRuntimeException(e);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/PropertiesEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/PropertyEditors.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/PropertyEditors.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/PropertyEditors.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,178 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+
+import org.jboss.util.Classes;
+
+/**
+ * A collection of PropertyEditor utilities. Provides the same interface
+ * as PropertyManagerEditor plus more...
+ *
+ * <p>Installs the default PropertyEditors.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class PropertyEditors
+{
+ /**
+ * Augment the PropertyEditorManager search path to incorporate the JBoss
+ * specific editors by appending the org.jboss.util.propertyeditor package
+ * to the PropertyEditorManager editor search path.
+ */
+ static
+ {
+ String[] currentPath = PropertyEditorManager.getEditorSearchPath();
+ int length = currentPath != null ? currentPath.length : 0;
+ String[] newPath = new String[length+1];
+ System.arraycopy(currentPath, 0, newPath, 0, length);
+
+ // May want to put the JBoss editor path first, for now append it
+ newPath[length] = "org.jboss.util.propertyeditor";
+ PropertyEditorManager.setEditorSearchPath(newPath);
+
+ // Some editors must be installed, as they do not follow naming conventions
+ Class[] map = {
+ String[].class, org.jboss.util.propertyeditor.StringArrayEditor.class,
+ };
+
+ for (int i=0; i<map.length; i++) {
+ PropertyEditorManager.registerEditor(map[i++], map[i]);
+ }
+ }
+
+ /**
+ * Locate a value editor for a given target type.
+ *
+ * @param type The class of the object to be edited.
+ * @return An editor for the given type or null if none was found.
+ */
+ public static PropertyEditor findEditor(final Class type)
+ {
+ return PropertyEditorManager.findEditor(type);
+ }
+
+ /**
+ * Locate a value editor for a given target type.
+ *
+ * @param typeName The class name of the object to be edited.
+ * @return An editor for the given type or null if none was found.
+ */
+ public static PropertyEditor findEditor(final String typeName)
+ throws ClassNotFoundException
+ {
+ // see if it is a primitive type first
+ Class type = Classes.getPrimitiveTypeForName(typeName);
+ if (type == null)
+ {
+ // nope try look up
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try {
+ type = loader.loadClass(typeName);
+ }
+ catch (ClassNotFoundException e) {
+ // look for a nested class
+ type = loader.loadClass(typeName + "$PropertyEditor");
+ }
+ }
+
+ return PropertyEditorManager.findEditor(type);
+ }
+
+ /**
+ * Get a value editor for a given target type.
+ *
+ * @param type The class of the object to be edited.
+ * @return An editor for the given type.
+ *
+ * @throws RuntimeException No editor was found.
+ */
+ public static PropertyEditor getEditor(final Class type)
+ {
+ PropertyEditor editor = findEditor(type);
+ if (editor == null)
+ {
+ throw new RuntimeException("No property editor for type: " + type);
+ }
+
+ return editor;
+ }
+
+ /**
+ * Get a value editor for a given target type.
+ *
+ * @param typeName The class name of the object to be edited.
+ * @return An editor for the given type.
+ *
+ * @throws RuntimeException No editor was found.
+ */
+ public static PropertyEditor getEditor(final String typeName)
+ throws ClassNotFoundException
+ {
+ PropertyEditor editor = findEditor(typeName);
+ if (editor == null)
+ {
+ throw new RuntimeException("No property editor for type: " + typeName);
+ }
+
+ return editor;
+ }
+
+ /**
+ * Register an editor class to be used to editor values of a given target class.
+ *
+ * @param type The class of the objetcs to be edited.
+ * @param editorType The class of the editor.
+ */
+ public static void registerEditor(final Class type, final Class editorType)
+ {
+ PropertyEditorManager.registerEditor(type, editorType);
+ }
+
+ /**
+ * Register an editor class to be used to editor values of a given target class.
+ *
+ * @param typeName The classname of the objetcs to be edited.
+ * @param editorTypeName The class of the editor.
+ */
+ public static void registerEditor(final String typeName,
+ final String editorTypeName)
+ throws ClassNotFoundException
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Class type = loader.loadClass(typeName);
+ Class editorType = loader.loadClass(editorTypeName);
+
+ PropertyEditorManager.registerEditor(type, editorType);
+ }
+
+ /**
+ * Gets the package names that will be searched for property editors.
+ *
+ * @return The package names that will be searched for property editors.
+ */
+ public String[] getEditorSearchPath()
+ {
+ return PropertyEditorManager.getEditorSearchPath();
+ }
+
+ /**
+ * Sets the package names that will be searched for property editors.
+ *
+ * @param path The serach path.
+ */
+ public void setEditorSearchPath(final String[] path)
+ {
+ PropertyEditorManager.setEditorSearchPath(path);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/PropertyEditors.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/SetEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/SetEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/SetEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,47 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.StringTokenizer;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * A property editor for {@link java.util.Set}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class SetEditor
+ extends PropertyEditorSupport
+{
+ protected Collection createCollection()
+ {
+ return createSet();
+ }
+
+ protected Set createSet()
+ {
+ return new HashSet();
+ }
+
+ protected void setValue(Set list)
+ {
+ super.setValue(list);
+ }
+
+ public void setValue(Collection bag)
+ {
+ setValue((Set)bag);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/SetEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/StackEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/StackEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/StackEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,28 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.List;
+import java.util.Stack;
+
+/**
+ * A property editor for {@link java.util.Stack}
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class StackEditor
+ extends ListEditor
+{
+ protected List createList()
+ {
+ return new Stack();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/StackEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/StringArrayEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/StringArrayEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/StringArrayEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,70 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.StringTokenizer;
+
+/**
+ * A property editor for String[].
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * total code replacement...
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ */
+public class StringArrayEditor
+ extends TextPropertyEditorSupport
+{
+ /**
+ * Returns a String[] by spliting up the input string where
+ * elements are separated by commas.
+ *
+ * @return a URL object
+ *
+ * @throws NestedRuntimeException An MalformedURLException occured.
+ */
+ public void setAsText(String text)
+ {
+ if (text == null || text.length() == 0)
+ {
+ setValue(null);
+ } // end of if ()
+ else
+ {
+ StringTokenizer stok = new StringTokenizer(text, ",");
+ List list = new LinkedList();
+
+ while (stok.hasMoreTokens())
+ {
+ list.add(stok.nextToken());
+ }
+
+ setValue((String[])list.toArray(new String[list.size()]));
+ } // end of else
+ }
+
+ public String getAsText()
+ {
+ String[] strings = (String[])getValue();
+ if (strings == null || strings.length == 0)
+ {
+ return null;
+ } // end of if ()
+ StringBuffer result = new StringBuffer(strings[0]);
+ for (int i = 1; i < strings.length; i++)
+ {
+ result.append(",").append(strings[i]);
+ } // end of for ()
+ return result.toString();
+ }
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/StringArrayEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/TextPropertyEditorSupport.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/TextPropertyEditorSupport.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/TextPropertyEditorSupport.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,42 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.beans.PropertyEditorSupport;
+
+/**
+ * A property editor support class for textual properties.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class TextPropertyEditorSupport
+ extends PropertyEditorSupport
+{
+ protected TextPropertyEditorSupport(final Object source)
+ {
+ super(source);
+ }
+
+ protected TextPropertyEditorSupport()
+ {
+ super();
+ }
+
+ /**
+ * Sets the property value by parsing a given String.
+ *
+ * @param text The string to be parsed.
+ */
+ public void setAsText(final String text)
+ {
+ setValue(text);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/TextPropertyEditorSupport.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/TreeSetEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/TreeSetEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/TreeSetEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,28 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * A property editor for {@link java.util.TreeSet}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class TreeSetEditor
+ extends SetEditor
+{
+ protected Set createSet()
+ {
+ return new TreeSet();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/TreeSetEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/URLEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/URLEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/URLEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,44 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import org.jboss.util.Strings;
+
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * A property editor for {@link java.net.URL}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class URLEditor
+ extends TextPropertyEditorSupport
+{
+ /**
+ * Returns a URL for the input object converted to a string.
+ *
+ * @return a URL object
+ *
+ * @throws NestedRuntimeException An MalformedURLException occured.
+ */
+ public Object getValue()
+ {
+ try {
+ return Strings.toURL(getAsText());
+ }
+ catch (MalformedURLException e) {
+ throw new NestedRuntimeException(e);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/URLEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/VectorEditor.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/VectorEditor.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/VectorEditor.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,28 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.propertyeditor;
+
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * A property editor for {@link java.util.Vector}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class VectorEditor
+ extends ListEditor
+{
+ protected List createList()
+ {
+ return new Vector();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/VectorEditor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Property editors for use with <em>java.beans.PropertyEditorManager</em>.
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/propertyeditor/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/AcceptableState.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/AcceptableState.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/AcceptableState.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,34 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.state;
+
+/**
+ * An abstract state to build dynamicily state acceptabile states.
+ *
+ * <p>Sub-classes must implement
+ * {@link StateMachine.Acceptable#isAcceptable(State)}.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class AcceptableState
+ extends State
+ implements StateMachine.Acceptable
+{
+ public AcceptableState(final int value, final String name)
+ {
+ super(value, name);
+ }
+
+ public AcceptableState(final int value)
+ {
+ super(value);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/AcceptableState.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/DefaultStateMachineModel.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/DefaultStateMachineModel.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/DefaultStateMachineModel.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,337 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.state;
+
+import java.io.Serializable;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+import java.util.Iterator;
+
+import org.jboss.util.NullArgumentException;
+import org.jboss.util.CloneableObject;
+import org.jboss.util.PrettyString;
+
+/**
+ * A default implementation of a state machine model.
+ *
+ * <p>Accepting to acceptable state mappings are backed up
+ * by a HashMap and HashSets.
+ *
+ * <p>Implements clonable so that the model can be used as a
+ * prototype. Nested containers are cloned, so that changes
+ * will not effect the master or other clones.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class DefaultStateMachineModel
+ extends CloneableObject
+ implements StateMachine.Model, Serializable, PrettyString.Appendable
+{
+ /** The State to StateMapping table. */
+ protected Map acceptingMap = new HashMap();
+
+ /** The mapping for the initial state. */
+ protected StateMapping initial;
+
+ /** The mapping for the current state. */
+ protected StateMapping current;
+
+ /**
+ * Construct a new <tt>DefaultStateMachineModel</tt>.
+ */
+ public DefaultStateMachineModel()
+ {
+ super();
+ }
+
+ public StringBuffer appendPrettyString(StringBuffer buff, String prefix)
+ {
+ buff.append(prefix).append(super.toString()).append(" {").append("\n");
+ buff.append(prefix).append(" Accepting state mappings:\n");
+ Iterator iter = acceptingMap.keySet().iterator();
+ while (iter.hasNext()) {
+ buff.append(prefix).append(" ").append(acceptingMap.get((State)iter.next()));
+ buff.append("\n");
+ }
+ buff.append(prefix).append(" Initial state: ")
+ .append(initial == null ? null : initial.state)
+ .append("\n");
+
+ buff.append(prefix).append(" Current state: ")
+ .append(current == null ? null : current.state)
+ .append("\n");
+
+ buff.append(prefix).append("}");
+
+ return buff;
+ }
+
+ public String toString()
+ {
+ return appendPrettyString(new StringBuffer(), "").toString();
+ }
+
+ public boolean equals(final Object obj)
+ {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ DefaultStateMachineModel model = (DefaultStateMachineModel)obj;
+
+ return
+ ((current == model.current) ||
+ (current != null && current.equals(model.current))) &&
+ ((initial == model.initial) ||
+ (initial != null && initial.equals(model.initial))) &&
+ ((acceptingMap == model.acceptingMap) ||
+ (acceptingMap != null && acceptingMap.equals(model.acceptingMap)));
+ }
+
+ return false;
+ }
+
+ /**
+ * Get the mapping for the given state.
+ *
+ * @param state The state of the mapping; must not be null.
+ */
+ protected StateMapping getStateMapping(final State state)
+ {
+ if (state == null)
+ throw new NullArgumentException("state");
+
+ return (StateMapping)acceptingMap.get(state);
+ }
+
+ /**
+ * Put a new mapping into the map.
+ *
+ * @return The previous mapping for the state or null if none.
+ */
+ protected StateMapping putStateMapping(final State state, final Set acceptable)
+ {
+ return (StateMapping)acceptingMap.put(state, new StateMapping(state, acceptable));
+ }
+
+ public boolean isMappedState(State state)
+ {
+ if (state == null) return false;
+
+ return getStateMapping(state) != null;
+ }
+
+ public State getMappedState(final State state)
+ {
+ StateMapping mapping = getStateMapping(state);
+ if (mapping != null)
+ return mapping.getAcceptingState();
+
+ throw new IllegalArgumentException("State not mapped: " + state);
+ }
+
+ public Set addState(final State state, final Set acceptable)
+ {
+ StateMapping prevStateMapping = getStateMapping(state);
+
+ // If we will replace the state, do some clean up before
+ if (containsState(state)) {
+ // update mapping to reflect new state value
+ updateAcceptableMapping(state, false);
+ }
+
+ // Now replace it
+ putStateMapping(state, acceptable);
+
+ if (acceptable != null) {
+ // Sanity check acceptable states
+ Iterator iter = acceptable.iterator();
+ while (iter.hasNext()) {
+ State temp = (State)iter.next();
+ if (temp == null)
+ throw new NullArgumentException("acceptable", "Set Element");
+
+ if (temp.equals(state)) {
+ throw new IllegalArgumentException
+ ("Acceptable states must not include the accepting state: " + temp);
+ }
+
+ // Add final states for all non-existant states
+ if (!containsState(temp)) {
+ addState(temp);
+ }
+ }
+ }
+
+ return prevStateMapping == null ? null : prevStateMapping.getAcceptableStates();
+ }
+
+ public Set addState(final State state, final State[] acceptable)
+ {
+ if (acceptable == null)
+ throw new NullArgumentException("acceptable");
+
+ if (acceptable.length == 0) {
+ return addState(state, (Set)null);
+ }
+
+ HashSet set = new HashSet(acceptable.length);
+
+ for (int i=0; i<acceptable.length; i++) {
+ if (acceptable[i] == null)
+ throw new NullArgumentException("acceptable", i);
+
+ set.add(acceptable[i]);
+ }
+
+ return addState(state, set);
+ }
+
+ public Set addState(final State state, final State acceptable)
+ {
+ HashSet set = new HashSet(1);
+ set.add(acceptable);
+ return addState(state, set);
+ }
+
+ public Set addState(final State state)
+ {
+ return addState(state, (Set)null);
+ }
+
+ public void setInitialState(final State state)
+ {
+ StateMapping mapping = getStateMapping(state);
+ if (mapping == null)
+ throw new IllegalArgumentException("State not mapped: " + state);
+
+ this.initial = mapping;
+ }
+
+ public State getInitialState()
+ {
+ return initial != null ? initial.state : null;
+ }
+
+ public void setCurrentState(final State state)
+ {
+ StateMapping mapping = getStateMapping(state);
+ if (mapping == null)
+ throw new IllegalArgumentException("State not mapped: " + state);
+
+ this.current = mapping;
+ }
+
+ public State getCurrentState()
+ {
+ return current != null ? current.state : null;
+ }
+
+ public boolean containsState(final State state)
+ {
+ return acceptingMap.containsKey(state);
+ }
+
+ public Set removeState(final State state)
+ {
+ if (state == null)
+ throw new NullArgumentException("state");
+ if (current != null && state.equals(current.state))
+ throw new IllegalArgumentException
+ ("Can not remove current state: " + state);
+
+ StateMapping prevStateMapping = getStateMapping(state);
+
+ // remove the mappings for this state
+ updateAcceptableMapping(state, true);
+
+ // Finally remove it
+ acceptingMap.remove(state);
+
+ return prevStateMapping.getAcceptableStates();
+ }
+
+ /**
+ * Update acceptable mappings.
+ *
+ * @param state The state value to update or remove
+ * @param remove True to remove the state from all mappings.
+ */
+ protected void updateAcceptableMapping(final State state, final boolean remove)
+ {
+ Iterator iter = acceptingMap.entrySet().iterator();
+
+ while (iter.hasNext()) {
+ StateMapping mapping = (StateMapping)((Map.Entry)iter.next()).getValue();
+
+ // only attempt to update non-final states
+ if (mapping.getAcceptableStates() != null &&
+ mapping.getAcceptableStates().contains(state))
+ {
+ mapping.getAcceptableStates().remove(state);
+
+ if (!remove) {
+ mapping.getAcceptableStates().add(state);
+ }
+ }
+ }
+ }
+
+ public Set states()
+ {
+ return Collections.unmodifiableSet(acceptingMap.keySet());
+ }
+
+ public Set acceptableStates(final State state)
+ {
+ StateMapping mapping = getStateMapping(state);
+
+ if (mapping.getAcceptableStates() != null)
+ return Collections.unmodifiableSet(mapping.getAcceptableStates());
+ return null;
+ }
+
+ public void clear()
+ {
+ acceptingMap.clear();
+ initial = null;
+ current = null;
+ }
+
+ public Object clone()
+ {
+ // clone one level deeper so that the model can be used as a prototype.
+
+ DefaultStateMachineModel model = (DefaultStateMachineModel)super.clone();
+ model.acceptingMap = new HashMap();
+
+ // Need to make sure that value entries are cloned too
+ Iterator iter = acceptingMap.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ model.acceptingMap.put(entry.getKey(),
+ ((StateMapping)entry.getValue()).clone());
+ }
+
+ if (model.current != null)
+ model.current = (StateMapping)current.clone();
+
+ if (model.initial != null)
+ model.initial = (StateMapping)initial.clone();
+
+ return model;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/DefaultStateMachineModel.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/State.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/State.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/State.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,126 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.state;
+
+import java.io.Serializable;
+
+import org.jboss.util.CloneableObject;
+
+/**
+ * Provides the basic interface for states (both accepting, acceptable and final)
+ * of a state machine.
+ *
+ * <p>Each state is immutable and has a name and integer value. States are
+ * considered equivilent if the integer values equal.
+ *
+ * <p>Note that the second opperand is an annonymous class, changing its
+ * equivilence from a vanilla Type instance.
+ *
+ * <p>State objects also can contain an optional opaque object. This is provided
+ * for applications to make use of the state machine for managing data
+ * assocciated with the state.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class State
+ extends CloneableObject
+ implements Serializable
+{
+ /**
+ * The integer value of the state.
+ *
+ * <p>States with the same value are equal.
+ */
+ public final int value;
+
+ /** The human readable name of the state. */
+ public final String name;
+
+ /** The optional opaque user data for the state. */
+ protected Object opaque;
+
+ public State(final int value, final String name)
+ {
+ this.value = value;
+ this.name = name;
+ }
+
+ public State(final int value)
+ {
+ this(value, null);
+ }
+
+ public int getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Returns the name of the state, or if null returns the
+ * integer value as a string.
+ */
+ public String getName()
+ {
+ return (name == null ? String.valueOf(value) : name);
+ }
+
+ public void setOpaque(final Object obj)
+ {
+ opaque = obj;
+ }
+
+ public Object getOpaque()
+ {
+ return opaque;
+ }
+
+ public String toString()
+ {
+ return getName();
+ }
+
+ /**
+ * Returns the identity string of this state.
+ *
+ * <p>This is the same value returned by {@link Object#toString()}.
+ */
+ public String toIdentityString()
+ {
+ return super.toString();
+ }
+
+ /**
+ * Returns the has code of the object.
+ *
+ * @return The integer value of the state.
+ */
+ public int hashCode()
+ {
+ return value;
+ }
+
+ /**
+ * Check for state equality.
+ *
+ * <p>States are considered equal if the integer values
+ * of the State objects are equivilent.
+ */
+ public boolean equals(final Object obj)
+ {
+ if (obj == this) return true;
+
+ if (obj instanceof State) {
+ return value == ((State)obj).getValue();
+ }
+
+ return false;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/State.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateAdapter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateAdapter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateAdapter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.state;
+
+/**
+ * A helper state for instances which need to be
+ * {@link StateMachine.Acceptable} and/or {@link StateMachine.ChangeListener}s.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class StateAdapter
+ extends State
+ implements StateMachine.Acceptable, StateMachine.ChangeListener
+{
+ public StateAdapter(final int value, final String name)
+ {
+ super(value, name);
+ }
+
+ public StateAdapter(final int value)
+ {
+ super(value);
+ }
+
+ /**
+ * Always returns false.
+ *
+ * @return False;
+ */
+ public boolean isAcceptable(final State state) { return false; }
+
+ public void stateChanged(final StateMachine.ChangeEvent event) {}
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateAdapter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateMachine.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateMachine.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateMachine.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,1055 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.state;
+
+import java.io.Serializable;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Collections;
+import java.util.EventListener;
+import java.util.EventObject;
+
+import org.jboss.util.NullArgumentException;
+import org.jboss.util.CloneableObject;
+import org.jboss.util.PrettyString;
+
+/**
+ * A generalization of a programmable finite-state machine (with a twist).
+ *
+ * <p>A state machine is backed up by a {@link Model}
+ * which simply provides data encapsulation. The machine starts
+ * in the initial state, which must not be null. Care must be
+ * taken to ensure that the machine state is not corrupted
+ * due to invalid modifications of the model. Best to leave the
+ * model alone once the machine has been created.
+ *
+ * <p>Provides change notification via {@link ChangeListener} objects.
+ * When a listener throws an exception it will not corrupt the state
+ * machine; it may however corrupt any application state which is
+ * dependent on the listener mechanism. For this reason listeners
+ * should handle exceptions which might be thrown or the client
+ * application should handle recovery of such corruption by catching
+ * those undeclared exceptions.
+ *
+ * <p>State instances which implement {@link Acceptable} will
+ * be consulted to determine if a state is acceptable. If such a
+ * state throws an exception the state of the machine will not change.
+ * The exception will be propagated to the client application for processing.
+ *
+ * <p>Durring state change events, such as acceptting and resetting,
+ * if the previous and/or current state objects implement
+ * {@link ChangeListener} they will be notified in that order.
+ *
+ * <p>State machine is not synchronized. Use {@link #makeSynchronized}
+ * to make a machine thread safe.
+ *
+ * <p>Example of how to program a state machine:
+ * <pre>
+ * <code>
+ * // Create some states
+ * State NEW = new State(0, "NEW");
+ * State INITALIZEING = new State(1, "INITALIZING");
+ * State INITIALIZED = new State(2, "INITIALIZED");
+ * State STARTING = new State(3, "STARTING");
+ * State STARTED = new State(4, "STARTED");
+ * State FAILED = new State(5, "FAILED");
+ *
+ * // Create a model for the state machine
+ * StateMachine.Model model = new DefaultStateMachineModel();
+ *
+ * // Add some state mappings
+ * model.addState(NEW, INITIALIZING);
+ * model.addState(INITIALIZING, new State[] { INITIALIZED, FAILED });
+ * model.addState(INITIALIZED, new State[] { STARTING });
+ * model.addState(STARTING, new State[] { STARTED, FAILED });
+ *
+ * // These states are final (they do not accept any states)
+ * model.addState(STARTED);
+ * model.addState(FAILED);
+ *
+ * // Set the initial state
+ * model.setInitialState(NEW);
+ *
+ * // Create the machine
+ * StateMachine machine = new StateMachine(model);
+ * </code>
+ * </pre>
+ *
+ * <p>Once you have created a StateMachine instance, using it is simple:
+ * <pre>
+ * <code>
+ * // Change to the INITIALIZING state
+ * machine.transition(INITIALIZING);
+ *
+ * // Change to the INITIALIZED state
+ * machine.transition(INITIALIZED); *
+ *
+ * // Try to change to an invalid state:
+ * try {
+ * // As programmed, the INITIALIZED state does not accept the NEW
+ * // state, it only accepts the STARTING state.
+ * machine.transition(NEW);
+ * }
+ * catch (IllegalStateException e) {
+ * // Do something with the exception; The state of the machine is
+ * // still INITIALIZED.
+ * }
+ *
+ * // Transition to a final state
+ * machine.transition(STARTING);
+ * machine.transition(FAILED);
+ *
+ * // Any attempt to transition to any state will fail, the FAILED is
+ * // a final state, as it does not accept any other states.
+ *
+ * // Reset the machine so we can use it again
+ * machine.reset();
+ *
+ * // The state of the machine is now the same as it was when the
+ * // state machine was first created (short of any added change
+ * // listeners... they do not reset).
+ * </code>
+ * </pre>
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class StateMachine
+ extends CloneableObject
+ implements Serializable
+{
+ /** The data model for the machine. */
+ protected final Model model;
+
+ /** The list of change listeners which are registered. */
+ protected final List changeListeners;
+
+ /**
+ * Construct a state machine with the given model.
+ *
+ * @param model The model for the machine; must not be null.
+ */
+ public StateMachine(final Model model)
+ {
+ if (model == null)
+ throw new NullArgumentException("model");
+
+ this.model = model;
+ this.changeListeners = new ArrayList();
+
+ // Set the current state to the initial state
+ State initialState = model.getInitialState();
+ if (initialState == null)
+ throw new IllegalArgumentException("Model initial state is null");
+
+ reset();
+ }
+
+ /** For sync and immutable wrappers. */
+ private StateMachine(final Model model, final Object hereForSigChangeOnly)
+ {
+ // must be initialized (they are final), but never used.
+ this.model = model;
+ this.changeListeners = null;
+ }
+
+ /**
+ * Returns a human readable snapshot of the current state of the machine.
+ */
+ public String toString()
+ {
+ StringBuffer buff = new StringBuffer(super.toString()).append(" {").append("\n");
+
+ buff.append(" Model:\n");
+ model.appendPrettyString(buff, " ").append("\n");
+ buff.append(" Change listeners: ").append(changeListeners).append("\n}");
+
+ return buff.toString();
+ }
+
+ /**
+ * Return the model which provides data encapsulation for the machine.
+ *
+ * @return The model for the machine.
+ */
+ public Model getModel()
+ {
+ return model;
+ }
+
+ /**
+ * Returns the current state of the machine.
+ *
+ * @see Model#getCurrentState
+ * @see StateMachine#getModel
+ *
+ * @return The current state; will not be null.
+ */
+ public State getCurrentState()
+ {
+ return model.getCurrentState();
+ }
+
+ /**
+ * Returns the initial state of the machine.
+ *
+ * @see Model#getInitialState
+ * @see StateMachine#getModel
+ *
+ * @return The current state; will not be null.
+ */
+ public State getInitialState()
+ {
+ return model.getInitialState();
+ }
+
+ /**
+ * Provides the interface for dynmaic state acceptability.
+ *
+ * <p>State instances which implement this interface will be asked
+ * if a state is acceptable before looking at the current states
+ * acceptable state list.
+ */
+ public static interface Acceptable
+ {
+ /**
+ * Check if the given state is an acceptable transition from this state.
+ *
+ * @param state The state to determine acceptability; must not be null.
+ * @return True if the state is acceptable, else false.
+ */
+ boolean isAcceptable(State state);
+ }
+
+ /**
+ * Check if the current state can accept a transition to the given state.
+ *
+ * <p>If the current state is final or does not list the given state as
+ * acceptable, then machine can not make the transition.
+ * The only exception to this rule is if the current state implements
+ * {@link Acceptable}; then the state is asked to determine acceptance.
+ * If the state returns false then the acceptable list will be consulted
+ * to make the final descision.
+ *
+ * <p>The mapped version of the state (not the version passed to accept)
+ * will be used to check acceptance.
+ *
+ * @param state The state check.
+ * @return True if the given state is acceptable for transition; else false.
+ */
+ public boolean isAcceptable(State state)
+ {
+ if (state == null)
+ throw new NullArgumentException("state");
+
+
+ return isAcceptable(model.getCurrentState(), state);
+ }
+
+ /**
+ * Actually checks the acceptability of a state.
+ */
+ protected boolean isAcceptable(final State origin, final State target)
+ {
+ // assert origin != null
+ // assert target != null
+ // assert model.conains(origin)
+
+ // state is not acceptable if the model does not contain this state
+ // or the origin is final
+ if (!model.containsState(target) || isStateFinal(origin)) {
+ return false;
+ }
+
+ // Do not allow the current state to accept itself
+ if (target.equals(origin)) {
+ return false;
+ }
+
+ boolean rv = false;
+
+ // Replace state with the mapped version
+ State state = model.getMappedState(target);
+
+ // If the current state implements Acceptable let it have a whack
+ if (origin instanceof Acceptable) {
+ rv = ((Acceptable)origin).isAcceptable(state);
+ }
+
+ // If we still have not accepted, then check the accept list
+ Set states = model.acceptableStates(origin);
+ if (!rv) {
+ rv = states.contains(state);
+ }
+
+ return rv;
+ }
+
+ /**
+ * Attempt to transition into the give state if the current state
+ * can accept it.
+ *
+ * <p>The mapped version of the state (not the version passed to transition)
+ * will be used in the transition.
+ *
+ * @param state The state to transiiton into.
+ *
+ * @throws IllegalStateException State can not be accepted, current
+ * state is final or non-acceptable.
+ */
+ public void transition(final State state)
+ {
+ // Make sure we are in an acceptable state
+ ensureAcceptable(state);
+
+ // state is acceptable, let any listeners know about it
+ changeState(state);
+ }
+
+ protected void ensureAcceptable(final State state)
+ {
+ if (!isAcceptable(state)) {
+ State currentState = model.getCurrentState();
+
+ // make an informative exception message
+ StringBuffer buff = new StringBuffer();
+
+ if (isStateFinal()) {
+ buff.append("Current state is final");
+ }
+ else {
+ buff.append("State must be ");
+
+ Set temp = model.acceptableStates(currentState);
+ State[] states = (State[])temp.toArray(new State[temp.size()]);
+
+ for (int i=0; i<states.length; i++) {
+ buff.append(states[i].getName());
+
+ if (i < states.length - 2)
+ buff.append(", ");
+ else if (i < states.length - 1)
+ buff.append(" or ");
+ }
+ }
+
+ buff.append("; cannot accept state: ")
+ .append(state.getName())
+ .append("; state=")
+ .append(currentState.getName());
+
+ throw new IllegalStateException(buff.toString());
+ }
+ }
+
+ /**
+ * Reset the state machine.
+ *
+ * <p>This will transition to the initial state and send change
+ * events to all listeners and to all accepting states which
+ * implement {@link ChangeListener}. Each state will only
+ * be notified once.
+ */
+ public void reset()
+ {
+ State prev = model.getCurrentState();
+ State initial = model.getInitialState();
+ ChangeEvent event = changeState(initial);
+
+ Iterator iter = model.states().iterator();
+ while (iter.hasNext()) {
+ State state = (State)iter.next();
+
+ // skip previous and initial states, they have been notfied by changeStatex
+ if (state.equals(prev) ||
+ state.equals(initial))
+ {
+ continue;
+ }
+
+ if (state instanceof ChangeListener) {
+ ((ChangeListener)state).stateChanged(event);
+ }
+ }
+ }
+
+ /**
+ * Change the state of the machine and send change events
+ * to all listeners and to the previous and new state objects
+ * if they implement {@link ChangeListener}.
+ *
+ * <p>If a change listener throws an Error or RuntimeException
+ * the state of the machine should remain in the changed state.
+ */
+ protected ChangeEvent changeState(final State state)
+ {
+ // assert state != null
+
+ // Replace state with the mapped version
+ State mappedState = model.getMappedState(state);
+
+ State prev = model.getCurrentState();
+ model.setCurrentState(mappedState);
+
+ ChangeEvent event = new ChangeEvent(this, prev, mappedState, state);
+
+ // Let the previous, current and user states deal if they want
+ if (prev instanceof ChangeListener) {
+ ((ChangeListener)prev).stateChanged(event);
+ }
+ if (mappedState instanceof ChangeListener) {
+ ((ChangeListener)mappedState).stateChanged(event);
+ }
+ if (state instanceof ChangeListener) {
+ ((ChangeListener)state).stateChanged(event);
+ }
+
+ // fire change event
+ fireStateChanged(event);
+
+ return event;
+ }
+
+ /**
+ * Return all states which are final.
+ *
+ * @see #isStateFinal(State)
+ *
+ * @return An immutable set of the final states of the machine.
+ */
+ public Set finalStates()
+ {
+ Set set = new HashSet();
+ Iterator iter = model.states().iterator();
+
+ while (iter.hasNext()) {
+ State state = (State)iter.next();
+ if (isStateFinal(state)) {
+ set.add(state);
+ }
+ }
+
+ return Collections.unmodifiableSet(set);
+ }
+
+ /**
+ * Determine if the given state is final.
+ *
+ * <p>Determing the finality of states which implement
+ * {@link Acceptable} is costly.
+ *
+ * @param state The state to check for finality; must not be null.
+ * @return True if the state is final; else false.
+ *
+ * @throws IllegalArgumentException State not found in model.
+ */
+ public boolean isStateFinal(final State state)
+ {
+ if (state == null)
+ throw new NullArgumentException("state");
+
+ if (!model.containsState(state)) {
+ throw new IllegalArgumentException("State not found in model: " + state);
+ }
+
+ if (state instanceof Acceptable) {
+ Acceptable a = (Acceptable)state;
+ Iterator iter = model.states().iterator();
+
+ //
+ // jason: Could potentially cache the results for better performance.
+ // Would have to expose control of the cachability to the user.
+ //
+ while (iter.hasNext()) {
+ // if at least one state is acceptable then the state is not final
+ if (a.isAcceptable((State)iter.next())) {
+ return false;
+ }
+ }
+ }
+
+ Set acceptable = model.acceptableStates(state);
+
+ if (acceptable == null) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Determine if the current state is final.
+ *
+ * @param state The state to check for finality; must not be null.
+ * @return True if the state is final; else false.
+ *
+ * @see #isStateFinal(State)
+ */
+ public boolean isStateFinal()
+ {
+ return isStateFinal(model.getCurrentState());
+ }
+
+ /**
+ * Check if the given state is the current state.
+ *
+ * @param state The state to check.
+ * @return True if the state is the current state.
+ */
+ public boolean isCurrentState(final State state)
+ {
+ return model.getCurrentState().equals(state);
+ }
+
+ /**
+ * Check if the given state is the initial state.
+ *
+ * @param state The state to check.
+ * @return True if the state is the initial state.
+ */
+ public boolean isInitialState(final State state)
+ {
+ return model.getInitialState().equals(state);
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Change Listeners //
+ ///////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Add a state change listener.
+ *
+ * @param listener The listener to add; must not be null
+ */
+ public void addChangeListener(final ChangeListener listener)
+ {
+ if (listener == null)
+ throw new NullArgumentException("listener");
+
+ synchronized (changeListeners) {
+ if (!changeListeners.contains(listener)) {
+ changeListeners.add(listener);
+ }
+ }
+ }
+
+ /**
+ * Remove a state change listener.
+ *
+ * <p>If the give value is null then this is a non-operation.
+ */
+ public void removeChangeListener(final ChangeListener listener)
+ {
+ synchronized (changeListeners) {
+ if (listener != null)
+ changeListeners.remove(listener);
+ }
+ }
+
+ /**
+ * Send a change event to all listeners.
+ *
+ * <p>Listeners are invoked in the same order which they have been added.
+ *
+ * <p>This method (as well as add and remove methods) are protected
+ * from concurrent modification exceptions.
+ *
+ * <p>Any Error or RuntimeException thrown by a change listener will
+ * prevent notification of listeners added after the throwing listener.
+ */
+ protected void fireStateChanged(final ChangeEvent event)
+ {
+ // assert event != null
+
+ ChangeListener[] listeners;
+
+ synchronized (changeListeners) {
+ listeners = (ChangeListener[])
+ changeListeners.toArray(new ChangeListener[changeListeners.size()]);
+ }
+
+ for (int i=0; i<listeners.length; i++) {
+ listeners[i].stateChanged(event);
+ }
+ }
+
+ /**
+ * An event for state change notifications.
+ */
+ public static class ChangeEvent
+ extends EventObject
+ {
+ public final StateMachine machine;
+ public final State previous;
+ public final State current;
+ public final State user;
+
+ public ChangeEvent(final StateMachine source,
+ final State previous,
+ final State current,
+ final State user)
+ {
+ super(source);
+
+ // previous may be null
+ if (current == null)
+ throw new NullArgumentException("current");
+ if (user == null)
+ throw new NullArgumentException("user");
+
+ this.machine = source;
+ this.previous = previous;
+ this.current = current;
+ this.user = user;
+ }
+
+ /**
+ * The previous state of the machine.
+ *
+ * <p>This value will not be null unless the initial state
+ * of the machine implements Acceptable. This can be used
+ * to determine when the state machine has been reset.
+ *
+ * @return The previous state of the machine.
+ */
+ public State getPreviousState()
+ {
+ return previous;
+ }
+
+ /**
+ * The current state of the machine. ie. The state the machine
+ * has just transition into and which triggered the change event.
+ *
+ * @return The current state of the machine; will not be null.
+ */
+ public State getCurrentState()
+ {
+ return current;
+ }
+
+ /**
+ * Returns the state instance which the was passed to the machine
+ * by the user.
+ *
+ * @return The state instance the user passed the machine.
+ */
+ public State getUserState()
+ {
+ return user;
+ }
+
+ /**
+ * The state machine which generated the event.
+ */
+ public StateMachine getStateMachine()
+ {
+ return (StateMachine)getSource();
+ }
+
+ public String toString()
+ {
+ return getClass().getName() + // don't use super, it will mess up formating
+ "{ previous=" + previous +
+ ", current=" + current +
+ (user != current ? (", user=" + user) : "") +
+ " }";
+ }
+ }
+
+ /**
+ * A listener for state change events.
+ */
+ public static interface ChangeListener
+ extends EventListener
+ {
+ /**
+ * Invoked after a state has been changed.
+ *
+ * @param event The state event, which encodes that data for the
+ * state change.
+ */
+ void stateChanged(ChangeEvent event);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Model //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Defines the data model required by a {@link StateMachine}.
+ */
+ public interface Model
+ extends CloneableObject.Cloneable, PrettyString.Appendable
+ {
+ //
+ // jason: Expose StateMapping here
+ //
+
+ /**
+ * Add a non-final state.
+ *
+ * <p>Existing acceptable states will be replaced by the given states.
+ *
+ * <p>Acceptable states which are not registered as accepting states
+ * will be added as final states.
+ *
+ * <p>If the acceptable set is null, then the added state will be final.
+ *
+ * <p>Note, states are added based on the valid states which can be
+ * transitioned to from the given state, not on the states which
+ * accept the given state.
+ *
+ * <p>For example, if adding state A which accepts B and C, this means
+ * that when the machine is in state A, it will allow transitions
+ * to B or C and not from C to A or B to A (unless of course a state
+ * mapping is setup up such that C and B both accept A).
+ *
+ * @param state The accepting state; must not be null.
+ * @param acceptable The valid acceptable states; must not contain null elements.
+ */
+ Set addState(State state, Set acceptable);
+
+ /**
+ * Add a non-final state.
+ *
+ * @param state The accepting state; must not be null.
+ * @param acceptable The valid acceptable states; must not contain null elements.
+ *
+ * @see #addState(State,Set)
+ */
+ Set addState(State state, State[] acceptable);
+
+ /**
+ * Add a final state.
+ *
+ * <p>Note, if the given state implements {@link StateMachine.Acceptable} then
+ * the final determiniation of its finality will be unknown until
+ * runtime.
+ *
+ * @param state The final state; must not be null.
+ */
+ Set addState(State state);
+
+ /**
+ * Returns the state object mapped for the given state value.
+ *
+ * <p>Since states with the same value are equivlent, this provides
+ * access to the actual state instance which is bound in the model.
+ *
+ * @param state The state with the value of the bound state to return;
+ * null will return false.
+ * @return The bound state instance.
+ *
+ * @throws IllegalArgumentException State not mapped.
+ */
+ State getMappedState(State state);
+
+ /**
+ * Determins if there is a mapping for the given state object.
+ *
+ * @param state The state with the value of the bound state to check for;
+ * must not be null.
+ * @return True if the state is mapped; else false.
+ *
+ * @throws IllegalArgumentException State not mapped.
+ */
+ boolean isMappedState(State state);
+
+ /**
+ * Set the initial state.
+ *
+ * <p>Does not need to validate the state, {@link StateMachine} will
+ * handle those details.
+ *
+ * @param state The initial state; must not be null.
+ */
+ void setInitialState(State state);
+
+ /**
+ * Return the initial state which the state machine should start in.
+ *
+ * @return The initial state of the state machine; must not be null.
+ */
+ State getInitialState();
+
+ /**
+ * Set the current state.
+ *
+ * <p>Does not need to validate the state, {@link StateMachine} will
+ * handle those details.
+ *
+ * @param state The current state; must not be null.
+ */
+ void setCurrentState(State state);
+
+ /**
+ * Get the current state.
+ *
+ * @return The current state; can be null if not used by a state machine.
+ * Once it has been given to a state machine this must not be
+ * null.
+ */
+ State getCurrentState();
+
+ /**
+ * Check if a give state is contained in the model.
+ *
+ * @param state The state to look for.
+ * @return True if the state is contained in the model; false if not.
+ */
+ boolean containsState(State state);
+
+ /**
+ * Remove a state from the model.
+ *
+ * @param state The state to remove.
+ * @return The acceptable states for the removed state or null.
+ */
+ Set removeState(State state);
+
+ /**
+ * Clear all accepting state mappings and reset the initial and current
+ * state to null.
+ */
+ void clear();
+
+ /**
+ * Return an immutable set of the accepting states.
+ *
+ * @return A set of accepting states.
+ */
+ Set states();
+
+ /**
+ * Return an immutable set of the acceptable states for a given
+ * accepting state.
+ *
+ * @param state The accepting state to get acceptable states for; must not be null.
+ * @return A set of accepting states.
+ */
+ Set acceptableStates(State state);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Synchronization //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return a synchronized state machine.
+ *
+ * @param machine State machine to synchronize; must not be null.
+ * @param mutex The object to lock on; null to use returned instance.
+ * @return Synchronized state machine.
+ */
+ public static StateMachine makeSynchronized(final StateMachine machine,
+ final Object mutex)
+ {
+ if (machine == null)
+ throw new NullArgumentException("machine");
+
+ return new StateMachine(null, null)
+ {
+ private Object lock = (mutex == null ? this : mutex);
+
+ public Model getModel()
+ {
+ synchronized (lock) {
+ return machine.getModel();
+ }
+ }
+
+ public State getInitailState()
+ {
+ synchronized (lock) {
+ return machine.getInitialState();
+ }
+ }
+
+ public State getCurrentState()
+ {
+ synchronized (lock) {
+ return machine.getCurrentState();
+ }
+ }
+
+ public boolean isInitialState(final State state)
+ {
+ synchronized (lock) {
+ return machine.isInitialState(state);
+ }
+ }
+
+ public boolean isCurrentState(final State state)
+ {
+ synchronized (lock) {
+ return machine.isCurrentState(state);
+ }
+ }
+
+ public boolean isAcceptable(final State state)
+ {
+ synchronized (lock) {
+ return machine.isAcceptable(state);
+ }
+ }
+
+ public void transition(final State state)
+ {
+ synchronized (lock) {
+ machine.transition(state);
+ }
+ }
+
+ public void reset()
+ {
+ synchronized (lock) {
+ machine.reset();
+ }
+ }
+
+ public Set finalStates()
+ {
+ synchronized (lock) {
+ return machine.finalStates();
+ }
+ }
+
+ public boolean isStateFinal(final State state)
+ {
+ synchronized (lock) {
+ return machine.isStateFinal(state);
+ }
+ }
+
+ public boolean isStateFinal()
+ {
+ synchronized (lock) {
+ return machine.isStateFinal();
+ }
+ }
+
+ public Object clone()
+ {
+ synchronized (lock) {
+ return super.clone();
+ }
+ }
+
+ public void addChangeListener(final ChangeListener listener)
+ {
+ synchronized (lock) {
+ machine.addChangeListener(listener);
+ }
+ }
+
+ public void removeChangeListener(final ChangeListener listener)
+ {
+ synchronized (lock) {
+ machine.removeChangeListener(listener);
+ }
+ }
+ };
+ }
+
+ /**
+ * Return a synchronized state machine.
+ *
+ * @param machine State machine to synchronize; must not be null.
+ * @return Synchronized state machine.
+ */
+ public static StateMachine makeSynchronized(final StateMachine machine)
+ {
+ return makeSynchronized(machine, null);
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Immutablility //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Return a immutable state machine.
+ *
+ * <p>Immutable state machines can not be transitioned or reset; methods
+ * will throw a <tt>UnsupportedOperationException</tt>.
+ *
+ * <p>If model is not hidden, then users can still mess up the model
+ * if they want, thus corrupting the state machine.
+ *
+ * @param machine State machine to make immutable; must not be null.
+ * @param hideModel Make the model inaccessable too.
+ * @return Immutable state machine with hidden model.
+ */
+ public static StateMachine makeImmutable(final StateMachine machine,
+ final boolean hideModel)
+ {
+ if (machine == null)
+ throw new NullArgumentException("machine");
+
+ return new StateMachine(machine.getModel(), null)
+ {
+ public Model getModel()
+ {
+ if (hideModel) {
+ throw new UnsupportedOperationException
+ ("Model has been hidden; state machine is immutable");
+ }
+
+ return super.getModel();
+ }
+
+ public void transition(final State state)
+ {
+ throw new UnsupportedOperationException
+ ("Can not transition; state machine is immutable");
+ }
+
+ public void reset()
+ {
+ throw new UnsupportedOperationException
+ ("Can not reset; state machine is immutable");
+ }
+
+ public void addChangeListener(final ChangeListener listener)
+ {
+ throw new UnsupportedOperationException
+ ("Can not add change listener; state machine is immutable");
+ }
+
+ public void removeChangeListener(final ChangeListener listener)
+ {
+ throw new UnsupportedOperationException
+ ("Can not remove change listener; state machine is immutable");
+ }
+ };
+ }
+
+ /**
+ * Return a immutable state machine.
+ *
+ * <p>Immutable state machines can not be transitioned or reset; methods
+ * will throw a <tt>UnsupportedOperationException</tt>.
+ *
+ * @param machine State machine to make immutable; must not be null.
+ * @return Immutable state machine.
+ */
+ public static StateMachine makeImmutable(final StateMachine machine)
+ {
+ return makeImmutable(machine, true);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateMachine.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateMapping.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateMapping.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateMapping.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,124 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.state;
+
+import java.io.Serializable;
+
+import java.util.Set;
+import java.util.HashSet;
+
+import org.jboss.util.NullArgumentException;
+import org.jboss.util.CloneableObject;
+
+/**
+ * A container for a state mapping, which maps an accepting state
+ * to it's acceptable states.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class StateMapping
+ extends CloneableObject
+ implements Serializable
+{
+ protected State state;
+ protected Set acceptable;
+
+ public StateMapping(final State state, final Set acceptable)
+ {
+ construct(state, acceptable);
+ }
+
+ public StateMapping(final State state, final State[] acceptable)
+ {
+ if (acceptable == null)
+ throw new NullArgumentException("acceptable");
+
+ if (acceptable.length == 0) {
+ construct(state, (Set)null);
+ return;
+ }
+
+ HashSet set = new HashSet(acceptable.length);
+
+ for (int i=0; i<acceptable.length; i++) {
+ if (acceptable[i] == null)
+ throw new NullArgumentException("acceptable", i);
+
+ set.add(acceptable[i]);
+ }
+
+ construct(state, set);
+ }
+
+ public StateMapping(final State state)
+ {
+ construct(state, null);
+ }
+
+ protected void construct(final State state, final Set acceptable)
+ {
+ if (state == null)
+ throw new NullArgumentException("state");
+
+ this.state = state;
+ this.acceptable = acceptable;
+ }
+
+ public boolean equals(final Object obj)
+ {
+ if (obj == this) return true;
+
+ if (obj != null && obj.getClass() == getClass()) {
+ StateMapping mapping = (StateMapping)obj;
+
+ return
+ ((state == mapping.state) ||
+ (state != null && state.equals(mapping.state))) &&
+ ((acceptable == mapping.acceptable) ||
+ (acceptable != null && acceptable.equals(mapping.acceptable)));
+ }
+
+ return false;
+ }
+
+ public String toString()
+ {
+ return
+ state + (isFinal()
+ ? " is final"
+ : " accepts: " + acceptable);
+ }
+
+ public Object clone()
+ {
+ StateMapping mapping = (StateMapping)super.clone();
+ if (mapping.acceptable != null) {
+ mapping.acceptable = new HashSet(acceptable);
+ }
+
+ return mapping;
+ }
+
+ public State getAcceptingState()
+ {
+ return state;
+ }
+
+ public Set getAcceptableStates()
+ {
+ return acceptable;
+ }
+
+ public boolean isFinal()
+ {
+ return acceptable == null;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/StateMapping.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/Test.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/Test.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/Test.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,439 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.state;
+
+import java.util.Set;
+import java.util.Iterator;
+import java.util.HashSet;
+
+/**
+ * ???
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class Test
+{
+ static StateMachine machine = null;
+ static StateMachine.Model originalModel = null;
+
+ static State NEW = new State(0, "NEW");
+ static State INITIALIZING = new State(1, "INITIALIZING");
+ static State INITIALIZED = new State(2, "INITIALIZED");
+ static State STARTING = new State(3, "STARTING");
+ static State STARTED = new StateAdapter(4, "STARTED") {
+ public void stateChanged(StateMachine.ChangeEvent event) {
+ startedGotEvent = true;
+ }
+ };
+ static State FAILED = new StateAdapter(100, "FAILED") {
+ public void stateChanged(StateMachine.ChangeEvent event) {
+ failedGotEvent = true;
+ }
+ };
+ static State FINAL = new AcceptableState(101, "FINAL") {
+ public boolean isAcceptable(State state) {
+ finalChecking = true;
+ return false;
+ }
+ };
+
+ static boolean startedGotEvent = false;
+ static boolean failedGotEvent = false;
+ static boolean finalChecking = false;
+
+ public static StateMachine.Model makeClone()
+ {
+ StateMachine.Model model = (StateMachine.Model)originalModel.clone();
+ Assert.assertTrue(model.equals(originalModel), "Clone was mutated");
+ return model;
+ }
+
+ private static class Assert
+ {
+ public static int failed = 0;
+ public static int total = 0;
+
+ public static void assertTrue(boolean rv)
+ {
+ assertTrue(rv, null);
+ }
+
+ public static void assertTrue(boolean rv, String msg)
+ {
+ total++;
+ if (!rv) failed++;
+
+ if (!rv && msg != null) {
+ System.out.println(rv + ": " + msg);
+ }
+ else if (!rv) {
+ System.out.println(rv);
+ }
+ }
+ }
+
+ public static boolean canSerialize(java.io.Serializable obj)
+ {
+ try {
+ org.jboss.util.Objects.copy(obj);
+ return true;
+ }
+ catch (Exception e) {
+ return false;
+ }
+ }
+
+ public static void main(String[] args)
+ throws Exception
+ {
+ try {
+ doit();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ System.out.println("\n\nTotal: " + Assert.total);
+ System.out.println("Failed: " + Assert.failed);
+ }
+
+ private static void doit() throws Exception
+ {
+ System.out.println("\nTesting data structure equality...");
+ Assert.assertTrue(new DefaultStateMachineModel().equals(new DefaultStateMachineModel()));
+
+ Set set;
+
+ Set setA = new HashSet();
+ setA.add(FAILED);
+
+ Set setB = new HashSet();
+ setB.add(FAILED);
+
+ Set setC = new HashSet();
+ setC.add(FAILED);
+ setC.add(NEW);
+
+ Set setD = new HashSet();
+ setD.add(FAILED);
+ setD.add(STARTED);
+ setD.add(NEW);
+
+ DefaultStateMachineModel modelA = new DefaultStateMachineModel();
+ modelA.addState(NEW);
+ DefaultStateMachineModel modelB = new DefaultStateMachineModel();
+ modelB.addState(NEW);
+ DefaultStateMachineModel modelC = new DefaultStateMachineModel();
+ modelC.addState(FINAL);
+ DefaultStateMachineModel modelD = new DefaultStateMachineModel();
+ modelD.addState(FINAL);
+ modelD.addState(NEW);
+ modelD.setInitialState(FINAL);
+
+ DefaultStateMachineModel modelA1 = new DefaultStateMachineModel();
+ modelA1.addState(NEW, setA);
+ DefaultStateMachineModel modelB1 = new DefaultStateMachineModel();
+ modelB1.addState(NEW, setB);
+ DefaultStateMachineModel modelC1 = new DefaultStateMachineModel();
+ modelC1.addState(FINAL, setC);
+ DefaultStateMachineModel modelD1 = new DefaultStateMachineModel();
+ modelD1.addState(FINAL, setD);
+ modelD1.addState(NEW);
+ modelD1.setInitialState(FINAL);
+
+ DefaultStateMachineModel modelA2 = (DefaultStateMachineModel)modelA1.clone();
+ DefaultStateMachineModel modelB2 = (DefaultStateMachineModel)modelB1.clone();
+ DefaultStateMachineModel modelC2 = (DefaultStateMachineModel)modelC1.clone();
+ DefaultStateMachineModel modelD2 = (DefaultStateMachineModel)modelD1.clone();
+
+ Assert.assertTrue(modelA.equals(modelA) == true, "Equality is broken 1");
+ Assert.assertTrue(modelA.equals(modelB) == true, "Equality is broken 2");
+ Assert.assertTrue(modelB.equals(modelA) == true, "Equality is broken 3");
+ Assert.assertTrue(modelA.equals(modelC) != true, "Equality is broken 4");
+
+ Assert.assertTrue(modelA1.equals(modelA1) == true, "Equality is broken 5");
+ Assert.assertTrue(modelA1.equals(modelB1) == true, "Equality is broken 6");
+ Assert.assertTrue(modelB1.equals(modelA1) == true, "Equality is broken 7");
+ Assert.assertTrue(modelA1.equals(modelC1) != true, "Equality is broken 8");
+ Assert.assertTrue(modelD1.equals(modelD1) == true, "Equality is broken 9");
+ Assert.assertTrue(modelD1.equals(modelA1) != true, "Equality is broken a");
+
+ Assert.assertTrue(modelA.equals(modelA1) != true, "Equality is broken b");
+ Assert.assertTrue(modelB.equals(modelB1) != true, "Equality is broken c");
+ Assert.assertTrue(modelC.equals(modelC1) != true, "Equality is broken d");
+ Assert.assertTrue(modelD.equals(modelD1) != true, "Equality is broken e");
+
+ Assert.assertTrue(modelA1.equals(modelA2) == true, "Equality is broken f");
+ Assert.assertTrue(modelB1.equals(modelB2) == true, "Equality is broken g");
+ Assert.assertTrue(modelC1.equals(modelC2) == true, "Equality is broken h");
+ Assert.assertTrue(modelD1.equals(modelD2) == true, "Equality is broken h");
+
+ modelD.removeState(NEW);
+
+ System.out.println("\nTesting serializaion...");
+ Assert.assertTrue(canSerialize(new State(0, "")), "State is not serializable");
+ Assert.assertTrue(canSerialize(new StateAdapter(0, "")), "StateAdapter is not serializable");
+ Assert.assertTrue(canSerialize(new AcceptableState(0, "") { public boolean isAcceptable(State state) { return false; } }), "AcceptableState is not serializable");
+ Assert.assertTrue(canSerialize(new DefaultStateMachineModel()), "DefaultStateMachineModel is not serializable");
+
+ System.out.println("\nSetting up model for tests...");
+
+ DefaultStateMachineModel model = new DefaultStateMachineModel();
+
+ Assert.assertTrue(model.equals(new DefaultStateMachineModel()) == true, "Equality is broken");
+ Assert.assertTrue(model.equals((StateMachine.Model)model.clone()) == true, "Equality is broken");
+
+ set = model.addState(NEW, INITIALIZING);
+ Assert.assertTrue(((set == null) == true), "Should have returned a null replacement set");
+
+ Assert.assertTrue(model.equals(new DefaultStateMachineModel()) != true, "Equality is broken");
+ Assert.assertTrue(model.equals((StateMachine.Model)model.clone()) == true, "Equality is broken");
+
+ model.addState(INITIALIZING, new State[] { INITIALIZED, FAILED });
+ model.addState(INITIALIZED, new State[] { STARTING, FAILED });
+ model.addState(STARTING, INITIALIZED);
+
+ Assert.assertTrue(model.equals((StateMachine.Model)model.clone()) == true, "Cloned equality is broken 1");
+
+ // test set replacement returns
+ model.addState(STARTED, INITIALIZED); // invalid state
+ set = model.addState(STARTED, STARTING); // this is what we want
+ Assert.assertTrue(set.size() == 1 && set.contains(INITIALIZED), "State replacement is broken 2");
+
+ Assert.assertTrue(model.equals((StateMachine.Model)model.clone()) == true, "Cloned equality is broken 3");
+
+ model.addState(FINAL);
+
+ Assert.assertTrue(model.equals((StateMachine.Model)model.clone()) == true, "Cloned equality is broken 4");
+
+ Set mostStates = new HashSet(model.states());
+ mostStates.remove(NEW); // new can only transition to INITIALIZED, not FAILED
+ mostStates.remove(FAILED); // can not accept outselves
+ model.addState(FAILED, mostStates);
+
+ model.setInitialState(NEW);
+
+ originalModel = (DefaultStateMachineModel)org.jboss.util.Objects.copy(model);
+ System.out.println("Original model: " + originalModel);
+
+ System.out.println("\nTesting clonability of model...");
+
+ StateMachine.Model aModel;
+
+ Assert.assertTrue(model.equals(makeClone()) == true, "Cloned equality is broken 5");
+
+ aModel = (StateMachine.Model)model.clone();
+ Assert.assertTrue(model.equals(aModel) == true);
+ Assert.assertTrue(aModel.equals(model) == true);
+
+ aModel.clear();
+
+ Assert.assertTrue(model.equals(aModel) != true, "Cloned equality is broken 6");
+
+ aModel = (StateMachine.Model)model.clone();
+ Assert.assertTrue(model.equals(aModel) == true, "Cloned equality is broken 7");
+
+ aModel.removeState(FINAL);
+ Assert.assertTrue(model.equals(aModel) != true, "Cloned equality is broken 8");
+
+ aModel = (StateMachine.Model)model.clone();
+ Assert.assertTrue(model.equals(aModel) == true, "Cloned equality is broken 9");
+
+ aModel.addState(new State(FINAL.getValue(), "NEW FINAL"));
+
+ Assert.assertTrue(model.equals(aModel) == true, "Cloned equality is broken a");
+
+ machine = new StateMachine(makeClone());
+ System.out.println(machine);
+ System.out.println();
+
+ test("new machine");
+
+ Assert.assertTrue(machine.isStateFinal(FINAL), "State FINAL should be final");
+ Assert.assertTrue(!machine.isStateFinal(NEW), "State NEW should not be final");
+
+ Assert.assertTrue(finalChecking, "Acceptable State broken");
+ Assert.assertTrue(startedGotEvent, "ChangeListener broken");
+ Assert.assertTrue(failedGotEvent, "ChangeListener broken");
+
+ machine.reset();
+ test("reset");
+
+ /*
+ machine = new StateMachine(makeClone(), true);
+ test("chainable");
+
+ System.out.println("\nTesting isAcceptable w/chaining...");
+
+ machine = new StateMachine(makeClone(), true);
+ Assert.assertTrue(machine.isAcceptable(INITIALIZED), "Chaining to valid state is broken");
+ machine.transition(INITIALIZED);
+ Assert.assertTrue(machine.getCurrentState().equals(INITIALIZED));
+ Assert.assertTrue(!machine.isAcceptable(NEW), "Chaining to invalid state is broken");
+ try {
+ machine.transition(NEW);
+ System.out.println(false);
+ }
+ catch (Exception e) {
+ System.out.println(true);
+ }
+ Assert.assertTrue(machine.getCurrentState().equals(INITIALIZED), "State should have been INITIALIZED");
+ Assert.assertTrue(!machine.isAcceptable(INITIALIZED), "Can transition to current state");
+ try {
+ machine.transition(INITIALIZED);
+ Assert.assertTrue(false, "Invalid state change allowed");
+ }
+ catch (Exception e) {
+ Assert.assertTrue(true);
+ }
+ */
+
+ machine = new StateMachine(makeClone());
+ // System.out.println("Prototype model: " + model);
+ // System.out.println("Machine model: " + machine.getModel());
+ test("model cloning");
+
+ aModel = makeClone();
+ aModel.removeState(FAILED);
+ // System.out.println("Prototype model: " + model);
+
+ machine = new StateMachine(aModel);
+ try {
+ test("model cloning with removal");
+ }
+ catch (IllegalStateException e) {
+ Assert.assertTrue(e.getMessage().equals("State must be STARTING; cannot accept state: FAILED; state=INITIALIZED"));
+ }
+
+ machine = new StateMachine(makeClone());
+ // System.out.println("Prototype model states: " + model.states());
+ test("model cloning after removal");
+
+ // test exception handling
+ machine = new StateMachine(makeClone());
+
+ // change listener
+ machine.addChangeListener(new StateMachine.ChangeListener() {
+ public void stateChanged(StateMachine.ChangeEvent event) {
+ throw new RuntimeException("ChangeListener");
+ }
+ });
+
+ try {
+ machine.transition(INITIALIZING);
+ Assert.assertTrue(false);
+ // should not make it here
+ }
+ catch (RuntimeException e) {
+ Assert.assertTrue(e.getMessage().equals("ChangeListener"), "Invalid message from change listener");
+ Assert.assertTrue(machine.getCurrentState().equals(INITIALIZING), "State should be INITAILIZING");
+ }
+
+ machine = new StateMachine(makeClone());
+
+ // acceptable state
+ State state = new AcceptableState(100, "FAILED") {
+ public boolean isAcceptable(State state) {
+ throw new RuntimeException("Accetable");
+ }
+ };
+
+ // System.out.println("New FAILED state: " + state + "(" + state.toIdentityString() + ")");
+
+ aModel = machine.getModel();
+ // System.out.println("Most states: " + mostStates);
+
+ set = aModel.addState(state, mostStates); // will replace previous state with same value
+ // System.out.println("Removed states: " + set);
+ // System.out.println("new states: " + aModel.states());
+
+ machine.transition(INITIALIZING);
+ Assert.assertTrue(machine.getCurrentState().equals(INITIALIZING), "State should be INITALIAING");
+ machine.transition(FAILED);
+ Assert.assertTrue(machine.getCurrentState().equals(FAILED), "State should be FAILED");
+
+ try {
+ machine.transition(FINAL);
+ // should not make it here
+ }
+ catch (Exception e) {
+ Assert.assertTrue(e.getMessage().equals("Accetable"), "Invalid message from Acceptable");
+ Assert.assertTrue(machine.getCurrentState().equals(FAILED), "State should be FAILED");
+ }
+
+ System.out.println("\nDone.");
+ }
+
+ public static void dumpState(State state)
+ {
+ Set acceptable = machine.getModel().states();
+ System.out.println(state + " accepts " + acceptable);
+ }
+
+ public static void dumpStates(Set set)
+ {
+ Iterator iter = set.iterator();
+ while (iter.hasNext()) {
+ dumpState((State)iter.next());
+ }
+ }
+
+ public static void test(String name)
+ {
+ System.out.println("\nTesting " + name + "...");
+
+ StateMachine.Model model = machine.getModel();
+ // System.out.println("Using model: " + model);
+
+ Assert.assertTrue(model.getInitialState().equals(NEW), "Initial state should have been NEW");
+ Assert.assertTrue(machine.getCurrentState().equals(NEW), "State should have been NEW");
+
+ // dumpStates(machine.getModel().states());
+
+ // dumpState();
+
+ // try some valid state changes
+ machine.transition(INITIALIZING);
+ Assert.assertTrue(machine.getCurrentState().equals(INITIALIZING), "State should have been INITIALIZING");
+ machine.transition(INITIALIZED);
+ Assert.assertTrue(machine.getCurrentState().equals(INITIALIZED), "State should have been INITIALIZED");
+
+ // now for an invalid state change
+ try {
+ machine.transition(NEW);
+ Assert.assertTrue(false, "Invalid state change allowed; can not trans from INITIALIZED to NEW");
+ }
+ catch (IllegalStateException e) {
+ Assert.assertTrue(machine.getCurrentState().equals(INITIALIZED), "State should be INITIALIZED");
+ }
+
+ // now for an invalid when we are in a final state
+ machine.transition(FAILED);
+ Assert.assertTrue(machine.getCurrentState().equals(FAILED), "State should be FAILED");
+
+ machine.transition(FINAL);
+ Assert.assertTrue(machine.getCurrentState().equals(FINAL), "State should be FINAL");
+
+ try {
+ machine.transition(NEW);
+ Assert.assertTrue(false, "Invalid state change allowed; can not trans from FINAL to NEW");
+ }
+ catch (IllegalStateException e) {
+ Assert.assertTrue(machine.getCurrentState().equals(FINAL), "State should be FINAL");
+ }
+ }
+
+ public static void dumpState()
+ {
+ System.out.print("Current state: ");
+ dumpState(machine.getCurrentState());
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/Test.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>State machine classes.</p>
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/state/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AppendObjectOutputStream.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AppendObjectOutputStream.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AppendObjectOutputStream.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,45 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.stream;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+
+/**
+ * An <code>ObjectOutputStream</code> that is meant for appending onto an
+ * existing stream written to by a non <code>AppendObjectOutputStream</code>
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class AppendObjectOutputStream
+ extends ObjectOutputStream
+{
+ /**
+ * Construct a new AppendObjectOutputStream.
+ *
+ * @param out An output stream.
+ *
+ * @throws IOException Any exception thrown by the underlying OutputStream.
+ */
+ public AppendObjectOutputStream(OutputStream out) throws IOException {
+ super(out);
+ }
+
+ /**
+ * Reset the stream, does not write headers.
+ *
+ * @throws IOException Any exception thrown by the underlying OutputStream.
+ */
+ protected void writeStreamHeader() throws IOException {
+ this.reset();
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AppendObjectOutputStream.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AppendingObjectOutputStream.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AppendingObjectOutputStream.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AppendingObjectOutputStream.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,71 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.stream;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+
+/**
+ * An <tt>ObjectOutputStream</tt> that can conditionally be put into
+ * <i>appending</i> mode.
+ *
+ * <dl>
+ * <dt><b>Concurrency: </b></dt>
+ * <dd>This class is <b>not</b> synchronized.</dd>
+ * </dl>
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class AppendingObjectOutputStream
+ extends ObjectOutputStreamAdapter
+{
+ /**
+ * Construct an <tt>AppendingObjectOutputStream</tt>.
+ *
+ * @param out An <tt>OutputStream</tt> stream.
+ * @param append <tt>True</tt> to append written objects; <tt>false</tt>
+ * to use default action (writes stream header).
+ *
+ * @throws IOException Any exception thrown by
+ * the underlying <tt>OutputStream</tt>.
+ */
+ public AppendingObjectOutputStream(OutputStream out, boolean append)
+ throws IOException
+ {
+ super(createStream(out, append));
+ }
+
+ /**
+ * Helper to return a <tt>ObjectOutputStream</tt>.
+ */
+ private static ObjectOutputStream createStream(OutputStream out,
+ boolean append)
+ throws IOException
+ {
+ ObjectOutputStream stream;
+
+ // if we are appending then return an append only stream
+ if (append) {
+ stream = new AppendObjectOutputStream(out);
+ }
+ // else if it already an oos then return it
+ else if (out instanceof ObjectOutputStream) {
+ stream = (ObjectOutputStream)out;
+ }
+ // else wrap the stream in an oos
+ else {
+ stream = new ObjectOutputStream(out);
+ }
+
+ return stream;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AppendingObjectOutputStream.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AutoResetObjectOutputStream.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AutoResetObjectOutputStream.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AutoResetObjectOutputStream.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,112 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.stream;
+
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+
+/**
+ * An <code>ObjectOutputStream</code> that will auto reset after <i>n</i>
+ * objects have been written to the underlying stream.
+ *
+ * <h3>Concurrency</h3>
+ * This class is <b>not</b> synchronized.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class AutoResetObjectOutputStream
+ extends ObjectOutputStreamAdapter
+{
+ /** Number of objects to write before resetting. */
+ protected int after; // = 0
+
+ /** Number of objects written so far. */
+ protected int count; // = 0
+
+ /**
+ * Construct a new AutoResetObjectOutputStream.
+ *
+ * @param out An ObjectOutputStream stream.
+ * @param after Number of objects to write before resetting.
+ *
+ * @throws IllegalArgumentException After <= 0
+ * @throws IOException Any exception thrown by
+ * the underlying OutputStream.
+ */
+ public AutoResetObjectOutputStream(ObjectOutputStream out, int after)
+ throws IOException
+ {
+ super(out);
+
+ setResetAfter(after);
+ }
+
+ /**
+ * Set the number of objects that must be written before resetting
+ * the stream.
+ *
+ * @param after Number of objects to write before resetting.
+ *
+ * @throws IllegalArgumentException After <= 0
+ */
+ public void setResetAfter(int after) {
+ if (after <= 0)
+ throw new IllegalArgumentException("after <= 0");
+
+ this.after = after;
+ }
+
+ /**
+ * Get the number of objects that must be written before resetting
+ * the stream.
+ *
+ * @return Number of objects to write before resetting.
+ */
+ public final int getResetAfter() {
+ return after;
+ }
+
+ /**
+ * Get the number of objects written to the stream so far.
+ *
+ * @return The number of objects written to the stream so far.
+ */
+ public final int getCount() {
+ return count;
+ }
+
+ /**
+ * Write the given object and reset if the number of objects written
+ * (including this one) exceeds the after count.
+ *
+ * @param obj Object to write.
+ *
+ * @throws IOException Any exception thrown by the underlying stream.
+ */
+ protected void writeObjectOverride(Object obj) throws IOException {
+ super.writeObjectOverride(obj);
+ count++;
+
+ if (count >= after) {
+ reset();
+ }
+ }
+
+ /**
+ * Resets the object counter as well as the nested stream.
+ *
+ * @throws IOException
+ */
+ public void reset() throws IOException {
+ out.reset();
+ count = 0;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/AutoResetObjectOutputStream.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/CRLFPrintWriter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/CRLFPrintWriter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/CRLFPrintWriter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,75 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.stream;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.OutputStream;
+import java.io.InterruptedIOException;
+import java.io.Writer;
+
+/**
+ * A <tt>PrintWriter</tt> that ends lines with a carriage return-line feed
+ * (<tt>CRLF</tt>).
+ *
+ * <h3>Concurrency</h3>
+ * This class is <b>as</b> synchronized as <tt>PrintWriter</tt>.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class CRLFPrintWriter
+ extends PrintWriter
+{
+ protected boolean autoFlush = false;
+
+ public CRLFPrintWriter(final Writer out) {
+ super(out);
+ }
+
+ public CRLFPrintWriter(final Writer out, final boolean autoFlush) {
+ super(out, autoFlush);
+ this.autoFlush = autoFlush;
+ }
+
+ public CRLFPrintWriter(final OutputStream out) {
+ super(out);
+ }
+
+ public CRLFPrintWriter(final OutputStream out, final boolean autoFlush) {
+ super(out, autoFlush);
+ this.autoFlush = autoFlush;
+ }
+
+ protected void ensureOpen() throws IOException {
+ if (out == null)
+ throw new IOException("Stream closed");
+ }
+
+ public void println() {
+ try {
+ synchronized (lock) {
+ ensureOpen();
+
+ out.write("\r\n");
+
+ if (autoFlush) {
+ out.flush();
+ }
+ }
+ }
+ catch (InterruptedIOException e) {
+ Thread.currentThread().interrupt();
+ }
+ catch (IOException e) {
+ setError();
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/CRLFPrintWriter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/NullInputStream.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/NullInputStream.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/NullInputStream.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,99 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.stream;
+
+import java.io.InputStream;
+
+/**
+ * A <tt>null</tt> <code>InputStream</code>. Methods that return values,
+ * return values that indicate that there is no more data to be read, other
+ * methods are non-operations.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class NullInputStream
+ extends InputStream
+{
+ /** A default null input stream. */
+ public static final NullInputStream INSTANCE = new NullInputStream();
+
+ /**
+ * Always returns zero.
+ *
+ * @return Zero.
+ */
+ public int available() {
+ return 0;
+ }
+
+ /**
+ * Non-operation.
+ */
+ public void mark(final int readLimit) {
+ }
+
+ /**
+ * Always returns false.
+ *
+ * @return False.
+ */
+ public boolean markSupported() {
+ return false;
+ }
+
+ /**
+ * Non-operation.
+ */
+ public void reset() {
+ }
+
+ /**
+ * Non-operation.
+ */
+ public void close() {
+ }
+
+ /**
+ * Always returns -1.
+ *
+ * @return -1.
+ */
+ public int read() {
+ return -1;
+ }
+
+ /**
+ * Always returns -1.
+ *
+ * @return -1.
+ */
+ public int read(final byte bytes[], final int offset, final int length) {
+ return -1;
+ }
+
+ /**
+ * Always returns -1.
+ *
+ * @return -1.
+ */
+ public int read(final byte bytes[]) {
+ return -1;
+ }
+
+ /**
+ * Always returns zero.
+ *
+ * @return Zero.
+ */
+ public long skip(final long n) {
+ return 0;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/NullInputStream.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/NullOutputStream.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/NullOutputStream.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/NullOutputStream.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,54 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.stream;
+
+import java.io.OutputStream;
+
+/**
+ * A <tt>null</tt> <code>OutputStream</code>. All values passed to
+ * {@link #write(int)} are discarded. Calls to {@link #flush()} and
+ * {@link #close()} are ignored.
+ *
+ * <p>All methods are declared <b>NOT</b> to throw <code>IOException</code>s.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class NullOutputStream
+ extends OutputStream
+{
+ /** A default null output stream. */
+ public static final NullOutputStream STREAM = new NullOutputStream();
+
+ /**
+ * Non-operation.
+ */
+ public void write(final int b) {}
+
+ /**
+ * Non-operation.
+ */
+ public void flush() {}
+
+ /**
+ * Non-operation.
+ */
+ public void close() {}
+
+ /**
+ * Non-operation.
+ */
+ public void write(final byte[] bytes) {}
+
+ /**
+ * Non-operation.
+ */
+ public void write(final byte[] bytes, final int offset, final int length) {}
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/NullOutputStream.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/ObjectOutputStreamAdapter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/ObjectOutputStreamAdapter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/ObjectOutputStreamAdapter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,139 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.stream;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+import org.jboss.util.NullArgumentException;
+
+/**
+ * An <code>ObjectOutputStream</code> wrapping adapter.
+ *
+ * <h3>Concurrency</h3>
+ * This class is <b>not</b> synchronized.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class ObjectOutputStreamAdapter
+ extends ObjectOutputStream
+{
+ /** Nested object output stream */
+ protected ObjectOutputStream out;
+
+ /**
+ * Construct a new ObjectOutputStreamAdapter.
+ *
+ * @param out An ObjectOutputStream stream.
+ *
+ * @throws IOException Any exception thrown by the underlying
+ * OutputStream.
+ * @throws IllegalArgumentException Out is null.
+ */
+ public ObjectOutputStreamAdapter(ObjectOutputStream out)
+ throws IOException
+ {
+ super(); // allow calls to writeObjectOverride()
+
+ if (out == null)
+ throw new NullArgumentException("out");
+
+ this.out = out;
+ }
+
+ protected void writeObjectOverride(Object obj) throws IOException {
+ out.writeObject(obj);
+ }
+
+ public void useProtocolVersion(int version) throws IOException {
+ out.useProtocolVersion(version);
+ }
+
+ public void defaultWriteObject() throws IOException {
+ out.defaultWriteObject();
+ }
+
+ public ObjectOutputStream.PutField putFields() throws IOException {
+ return out.putFields();
+ }
+
+ public void writeFields() throws IOException {
+ out.writeFields();
+ }
+
+ public void reset() throws IOException {
+ out.reset();
+ }
+
+ public void write(int data) throws IOException {
+ out.write(data);
+ }
+
+ public void write(byte b[]) throws IOException {
+ out.write(b);
+ }
+
+ public void write(byte b[], int off, int len) throws IOException {
+ out.write(b, off, len);
+ }
+
+ public void flush() throws IOException {
+ out.flush();
+ }
+
+ public void close() throws IOException {
+ out.close();
+ }
+
+ public void writeBoolean(boolean data) throws IOException {
+ out.writeBoolean(data);
+ }
+
+ public void writeByte(int data) throws IOException {
+ out.writeByte(data);
+ }
+
+ public void writeShort(int data) throws IOException {
+ out.writeShort(data);
+ }
+
+ public void writeChar(int data) throws IOException {
+ out.writeChar(data);
+ }
+
+ public void writeInt(int data) throws IOException {
+ out.writeInt(data);
+ }
+
+ public void writeLong(long data) throws IOException {
+ out.writeLong(data);
+ }
+
+ public void writeFloat(float data) throws IOException {
+ out.writeFloat(data);
+ }
+
+ public void writeDouble(double data) throws IOException {
+ out.writeDouble(data);
+ }
+
+ public void writeBytes(String data) throws IOException {
+ out.writeBytes(data);
+ }
+
+ public void writeChars(String data) throws IOException {
+ out.writeChars(data);
+ }
+
+ public void writeUTF(String s) throws IOException {
+ out.writeUTF(s);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/ObjectOutputStreamAdapter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/Printable.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/Printable.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/Printable.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,53 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.stream;
+
+import java.io.PrintWriter;
+import java.io.PrintStream;
+
+/**
+ * A simple interface to allow an object to print itself to a
+ * <code>PrintWriter</code> or <code>PrintStream</code>.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public interface Printable
+{
+ /**
+ * Print to a PrintWriter.
+ *
+ * @param writer PrintWriter to print to.
+ */
+ void print(PrintWriter writer);
+
+ /**
+ * Print to a PrintWriter.
+ *
+ * @param writer PrintWriter to print to.
+ * @param prefix Prefix to append to each line in the stream.
+ */
+ void print(PrintWriter writer, String prefix);
+
+ /**
+ * Print to a PrintStream.
+ *
+ * @param stream PrintStream to print to.
+ */
+ void print(PrintStream stream);
+
+ /**
+ * Print to a PrintStream.
+ *
+ * @param stream PrintStream to print to.
+ * @param prefix Prefix to append to each line in the stream.
+ */
+ void print(PrintStream stream, String prefix);
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/Printable.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/Streams.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/Streams.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/Streams.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,447 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.util.stream;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+
+import org.jboss.util.ThrowableHandler;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A collection of stream related utility methods.
+ *
+ * <p>Exceptions that are thrown and not explicitly declared are given to
+ * the {@link ThrowableHandler} for further processing.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public final class Streams
+{
+ private static final Logger log = Logger.getLogger(Streams.class);
+
+ /////////////////////////////////////////////////////////////////////////
+ // Closing //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Attempt to close an <tt>InputStream</tt>.
+ *
+ * @param stream <tt>InputStream</tt> to attempt to close.
+ * @return <tt>True</tt> if stream was closed (or stream was null),
+ * or <tt>false</tt> if an exception was thrown.
+ */
+ public static boolean close(final InputStream stream) {
+ // do not attempt to close null stream, but return sucess
+ if (stream == null) {
+ return true;
+ }
+
+ boolean success = true;
+
+ try {
+ stream.close();
+ }
+ catch (IOException e) {
+ success = false;
+ ThrowableHandler.add(e);
+ }
+
+ return success;
+ }
+
+ /**
+ * Attempt to close an <tt>OutputStream</tt>.
+ *
+ * @param stream <tt>OutputStream</tt> to attempt to close.
+ * @return <tt>True</tt> if stream was closed (or stream was null),
+ * or <tt>false</tt> if an exception was thrown.
+ */
+ public static boolean close(final OutputStream stream) {
+ // do not attempt to close null stream, but return sucess
+ if (stream == null) {
+ return true;
+ }
+
+ boolean success = true;
+
+ try {
+ stream.close();
+ }
+ catch (IOException e) {
+ success = false;
+ ThrowableHandler.add(e);
+ }
+
+ return success;
+ }
+
+ /**
+ * Attempt to close an <tt>InputStream</tt> or <tt>OutputStream</tt>.
+ *
+ * @param stream Stream to attempt to close.
+ * @return <tt>True</tt> if stream was closed (or stream was null),
+ * or <tt>false</tt> if an exception was thrown.
+ *
+ * @throws IllegalArgumentException Stream is not an <tt>InputStream</tt>
+ * or <tt>OuputStream</tt>.
+ */
+ public static boolean close(final Object stream) {
+ boolean success = false;
+
+ if (stream instanceof InputStream) {
+ success = close((InputStream)stream);
+ }
+ else if (stream instanceof OutputStream) {
+ success = close((OutputStream)stream);
+ }
+ else {
+ throw new IllegalArgumentException
+ ("stream is not an InputStream or OutputStream");
+ }
+
+ return success;
+ }
+
+ /**
+ * Attempt to close an array of <tt>InputStream</tt>s.
+ *
+ * @param streams Array of <tt>InputStream</tt>s to attempt to close.
+ * @return <tt>True</tt> if all streams were closed, or <tt>false</tt>
+ * if an exception was thrown.
+ */
+ public static boolean close(final InputStream[] streams) {
+ boolean success = true;
+
+ for (int i=0; i<streams.length; i++) {
+ boolean rv = close(streams[i]);
+ if (!rv) success = false;
+ }
+
+ return success;
+ }
+
+ /**
+ * Attempt to close an array of <tt>OutputStream</tt>s.
+ *
+ * @param streams Array of <tt>OutputStream</tt>s to attempt to close.
+ * @return <tt>True</tt> if all streams were closed, or <tt>false</tt>
+ * if an exception was thrown.
+ */
+ public static boolean close(final OutputStream[] streams) {
+ boolean success = true;
+
+ for (int i=0; i<streams.length; i++) {
+ boolean rv = close(streams[i]);
+ if (!rv) success = false;
+ }
+
+ return success;
+ }
+
+ /**
+ * Attempt to close an array of <tt>InputStream</tt>a and/or
+ * <tt>OutputStream</tt>s.
+ *
+ * @param streams Array of streams to attempt to close.
+ * @return <tt>True</tt> if all streams were closed, or <tt>false</tt>
+ * if an exception was thrown.
+ *
+ * @throws IllegalArgumentException Stream is not an <tt>InputStream</tt>
+ * or <tt>OuputStream</tt>. Closing
+ * stops at the last valid stream
+ * object in this case.
+ */
+ public static boolean close(final Object[] streams) {
+ boolean success = true;
+
+ for (int i=0; i<streams.length; i++) {
+ boolean rv = close(streams[i]);
+ if (!rv) success = false;
+ }
+
+ return success;
+ }
+
+ /**
+ * Attempt to flush and close an <tt>OutputStream</tt>.
+ *
+ * @param stream <tt>OutputStream</tt> to attempt to flush and close.
+ * @return <tt>True</tt> if stream was flushed and closed, or
+ * <tt>false</tt> if an exception was thrown.
+ */
+ public static boolean fclose(final OutputStream stream) {
+ return flush(stream) && close(stream);
+ }
+
+ /**
+ * Attempt to flush and close an array of <tt>OutputStream</tt>s.
+ *
+ * @param streams <tt>OutputStream</tt>s to attempt to flush and close.
+ * @return <tt>True</tt> if all streams were flushed and closed,
+ * or <tt>false</tt> if an exception was thrown.
+ */
+ public static boolean fclose(final OutputStream[] streams) {
+ boolean success = true;
+
+ for (int i=0; i<streams.length; i++) {
+ boolean rv = fclose(streams[i]);
+ if (!rv) success = false;
+ }
+
+ return success;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Flushing //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Attempt to flush an <tt>OutputStream</tt>.
+ *
+ * @param stream <tt>OutputStream</tt> to attempt to flush.
+ * @return <tt>True</tt> if stream was flushed (or stream was null),
+ * or <tt>false</tt> if an exception was thrown.
+ */
+ public static boolean flush(final OutputStream stream) {
+ // do not attempt to close null stream, but return sucess
+ if (stream == null) {
+ return true;
+ }
+
+ boolean success = true;
+
+ try {
+ stream.flush();
+ }
+ catch (IOException e) {
+ success = false;
+ ThrowableHandler.add(e);
+ }
+
+ return success;
+ }
+
+ /**
+ * Attempt to flush an array of <tt>OutputStream</tt>s.
+ *
+ * @param streams <tt>OutputStream</tt>s to attempt to flush.
+ * @return <tt>True</tt> if all streams were flushed, or <tt>false</tt>
+ * if an exception was thrown.
+ */
+ public static boolean flush(final OutputStream[] streams) {
+ boolean success = true;
+
+ for (int i=0; i<streams.length; i++) {
+ boolean rv = flush(streams[i]);
+ if (!rv) success = false;
+ }
+
+ return success;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // Misc //
+ /////////////////////////////////////////////////////////////////////////
+
+ /** The default buffer size that will be used for buffered operations. */
+ public static final int DEFAULT_BUFFER_SIZE = 2048;
+
+ /**
+ * Copy all of the bytes from the input stream to the output stream.
+ *
+ * @param input Stream to read bytes from.
+ * @param output Stream to write bytes to.
+ * @param buffer The buffer to use while copying.
+ * @return The total number of bytes copied.
+ *
+ * @throws IOException Failed to copy bytes.
+ */
+ public static long copy(final InputStream input,
+ final OutputStream output,
+ final byte buffer[])
+ throws IOException
+ {
+ long total = 0;
+ int read;
+
+ boolean trace = log.isTraceEnabled();
+ if (trace) {
+ log.trace("copying " + input + " to " + output + " with buffer size: " + buffer.length);
+ }
+
+ while ((read = input.read(buffer)) != -1) {
+ output.write(buffer, 0, read);
+ total += read;
+
+ if (trace) {
+ log.trace("bytes read: " + read + "; total bytes read: " + total);
+ }
+ }
+
+ return total;
+ }
+
+ /**
+ * Copy all of the bytes from the input stream to the output stream.
+ *
+ * @param input Stream to read bytes from.
+ * @param output Stream to write bytes to.
+ * @param size The size of the buffer to use while copying.
+ * @return The total number of bytes copied.
+ *
+ * @throws IOException Failed to copy bytes.
+ */
+ public static long copy(final InputStream input,
+ final OutputStream output,
+ final int size)
+ throws IOException
+ {
+ return copy(input, output, new byte[size]);
+ }
+
+ /**
+ * Copy all of the bytes from the input stream to the output stream.
+ *
+ * @param input Stream to read bytes from.
+ * @param output Stream to write bytes to.
+ * @return The total number of bytes copied.
+ *
+ * @throws IOException Failed to copy bytes.
+ */
+ public static long copy(final InputStream input,
+ final OutputStream output)
+ throws IOException
+ {
+ return copy(input, output, DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Copy all of the bytes from the input stream to the output stream
+ * wrapping streams in buffers as needed.
+ *
+ * @param input Stream to read bytes from.
+ * @param output Stream to write bytes to.
+ * @return The total number of bytes copied.
+ *
+ * @throws IOException Failed to copy bytes.
+ */
+ public static long copyb(InputStream input,
+ OutputStream output)
+ throws IOException
+ {
+ if (!(input instanceof BufferedInputStream)) {
+ input = new BufferedInputStream(input);
+ }
+
+ if (!(output instanceof BufferedOutputStream)) {
+ output = new BufferedOutputStream(output);
+ }
+
+ long bytes = copy(input, output, DEFAULT_BUFFER_SIZE);
+
+ output.flush();
+
+ return bytes;
+ }
+
+ /**
+ * Copy a limited number of bytes from the input stream to the
+ * output stream.
+ *
+ * @param input Stream to read bytes from.
+ * @param output Stream to write bytes to.
+ * @param buffer The buffer to use while copying.
+ * @param length The maximum number of bytes to copy.
+ * @return The total number of bytes copied.
+ *
+ * @throws IOException Failed to copy bytes.
+ */
+ public static long copySome(final InputStream input,
+ final OutputStream output,
+ final byte buffer[],
+ final long length)
+ throws IOException
+ {
+ long total = 0;
+ int read;
+ int readLength;
+
+ boolean trace = log.isTraceEnabled();
+
+ // setup the initial readLength, if length is less than the buffer
+ // size, then we only want to read that much
+ readLength = Math.min((int)length, buffer.length);
+ if (trace) {
+ log.trace("initial read length: " + readLength);
+ }
+
+ while (readLength != 0 && (read = input.read(buffer, 0, readLength)) != -1)
+ {
+ if (trace) log.trace("read bytes: " + read);
+ output.write(buffer, 0, read);
+ total += read;
+ if (trace) log.trace("total bytes read: " + total);
+
+ // update the readLength
+ readLength = Math.min((int)(length - total), buffer.length);
+ if (trace) log.trace("next read length: " + readLength);
+ }
+
+ return total;
+ }
+
+ /**
+ * Copy a limited number of bytes from the input stream to the
+ * output stream.
+ *
+ * @param input Stream to read bytes from.
+ * @param output Stream to write bytes to.
+ * @param size The size of the buffer to use while copying.
+ * @param length The maximum number of bytes to copy.
+ * @return The total number of bytes copied.
+ *
+ * @throws IOException Failed to copy bytes.
+ */
+ public static long copySome(final InputStream input,
+ final OutputStream output,
+ final int size,
+ final long length)
+ throws IOException
+ {
+ return copySome(input, output, new byte[size], length);
+ }
+
+ /**
+ * Copy a limited number of bytes from the input stream to the
+ * output stream.
+ *
+ * @param input Stream to read bytes from.
+ * @param output Stream to write bytes to.
+ * @param length The maximum number of bytes to copy.
+ * @return The total number of bytes copied.
+ *
+ * @throws IOException Failed to copy bytes.
+ */
+ public static long copySome(final InputStream input,
+ final OutputStream output,
+ final long length)
+ throws IOException
+ {
+ return copySome(input, output, DEFAULT_BUFFER_SIZE, length);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/Streams.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Stream related classes.</p>
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/stream/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/Timeout.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/Timeout.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/Timeout.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,32 @@
+/*
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
+package org.jboss.util.timeout;
+
+
+/**
+ * The public interface of timeouts.
+ *
+ * @author <a href="osh at sparre.dk">Ole Husgaard</a>
+ * @version $Revision$
+*/
+public interface Timeout {
+ /**
+ * Cancel this timeout.
+ *
+ * It is guaranteed that on return from this method this timer is
+ * no longer active. This means that either it has been cancelled and
+ * the timeout will not happen, or (in case of late cancel) the
+ * timeout has happened and the timeout callback function has returned.
+ *
+ * On return from this method this instance should no longer be
+ * used. The reason for this is that an implementation may reuse
+ * cancelled timeouts, and at return the instance may already be
+ * in use for another timeout.
+ */
+ public void cancel();
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/Timeout.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/TimeoutFactory.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/TimeoutFactory.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/TimeoutFactory.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,562 @@
+/*
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
+package org.jboss.util.timeout;
+
+import org.jboss.util.ThrowableHandler;
+
+
+/**
+ * The timeout factory.
+ *
+ * This is written with performance in mind. In case of <code>n</code>
+ * active timeouts, creating, cancelling and firing timeouts all operate
+ * in time <code>O(log(n))</code>.
+ *
+ * If a timeout is cancelled, the timeout is not discarded. Instead the
+ * timeout is saved to be reused for another timeout. This means that if
+ * no timeouts are fired, this class will eventually operate without
+ * allocating anything on the heap.
+ *
+ * @author <a href="osh at sparre.dk">Ole Husgaard</a>
+ * @version $Revision$
+ */
+public class TimeoutFactory
+{
+
+ // Code commented out with the mark "INV:" are runtime checks
+ // of invariants that are not needed for a production system.
+ // For problem solving, you can remove these comments.
+
+ // Multithreading notes:
+ //
+ // While a TimeoutImpl is enqueued, its index field contains the index
+ // of the instance in the queue; that is, for 1 <= n <= size,
+ // q[n].index = n.
+ // Modifications of an enqueued TimeoutImpl instance may only happen
+ // in code synchronized on the TimeoutFactory instance that has it
+ // enqueued.
+ // Modifications on the priority queue may only happen while running in
+ // code synchronized on the TimeoutFactory instance that holds the queue.
+ // When a TimeoutImpl instance is no longer enqueued, its index field
+ // changes to one of the negative constants declared in the TimeoutImpl
+ // class.
+ // When a TimeoutImpl is not in use, its index field is TimeoutImpl.DONE
+ // and it is on the freeList.
+ //
+ // Cancellation may race with the timeout.
+ // To avoid problems with this, the TimeoutImpl index field is set to
+ // TimeoutImpl.TIMEOUT when the TimeoutImpl is taken out of the queue.
+ // If a cancellation is attempted while the timeout callback is running,
+ // the TimeoutImpl field index is set to TimeoutImpl.CWAIT to indicate
+ // that someone is waiting for the timeout callback to finish.
+ // When the timeout callback returns it is checked if the index field
+ // was changed to TimeoutImpl.CWAIT, and if it was all waiting threads
+ // are notified. Finally the index field is set to TimeoutImpl.DONE, and
+ // the TimeoutImpl instance is discarded.
+
+ /**
+ * Our private Timeout implementation.
+ */
+ private class TimeoutImpl implements Timeout {
+ static final int DONE = -1; // done, may be finalized or reused
+ static final int TIMEOUT = -2; // target being called
+ static final int CWAIT = -3; // target being called and cancel waiting
+
+ int index; // index in queue, or one of constants above.
+ long time; // time to fire
+ TimeoutTarget target; // target to fire at
+ TimeoutImpl nextFree; // next on free list
+
+ public void cancel() {
+ TimeoutFactory.this.dropTimeout(this);
+ }
+ }
+
+ /**
+ * A worker thread that fires the timeout.
+ */
+ private static class TimeoutWorker extends Thread {
+ private TimeoutImpl work;
+
+ /**
+ * Create a new instance.
+ *
+ * @param work The timeout that should be fired.
+ */
+ TimeoutWorker(TimeoutImpl work) {
+ this.work = work;
+ setDaemon(false);
+ }
+
+ /**
+ * Override to fire the timeout.
+ */
+ public void run() {
+ try {
+ work.target.timedOut(work);
+ }
+ catch (Throwable t) {
+ ThrowableHandler.add(ThrowableHandler.Type.ERROR, t);
+ }
+
+ synchronized (work) {
+ if (work.index == TimeoutImpl.CWAIT) {
+ work.index = TimeoutImpl.DONE;
+ work.notifyAll(); // wake up cancel() threads.
+ } else
+ work.index = TimeoutImpl.DONE;
+ }
+ }
+ }
+
+
+ /** Linked list of free TimeoutImpl instances. */
+ private TimeoutImpl freeList;
+
+ /** The size of the timeout queue. */
+ private int size;
+
+ /**
+ * Our priority queue.
+ *
+ * This is a balanced binary tree. If nonempty, the root is at index 1,
+ * and all nodes are at indices 1..size. Nodes with index greater than
+ * size are null. Index 0 is never used.
+ * Children of the node at index <code>j</code> are at <code>j*2</code>
+ * and <code>j*2+1</code>. The children of a node always fire the timeout
+ * no earlier than the node.
+ *
+ *
+ * Or, more formally:
+ *
+ * Only indices <code>1</code>..<code>size</code> of this array are used.
+ * All other indices contain the null reference.
+ * This array represent a balanced binary tree.
+ *
+ * If <code>size</code> is <code>0</code> the tree is empty, otherwise
+ * the root of the tree is at index <code>1</code>.
+ *
+ * Given an arbitrary node at index <code>n</code> that is not the root
+ * node, the parent node of <code>n</code> is at index <code>n/2</code>.
+ *
+ * Given an arbitrary node at index <code>n</code>; if
+ * <code>2*n <= size</code> the node at <code>n</code> has its left child
+ * at index <code>2*n</code>, otherwise the node at <code>n</code> has
+ * no left child.
+ *
+ * Given an arbitrary node at index <code>n</code>; if
+ * <code>2*n+1 <= size</code> the node at <code>n</code> has its right child
+ * at index <code>2*n+1</code>, otherwise the node at <code>n</code> has
+ * no right child.
+ *
+ * The priority function is called T. Given a node <code>n</code>,
+ * <code>T(n)</code> denotes the absolute time (in milliseconds since
+ * the epoch) that the timeout for node <code>n</code> should happen.
+ * Smaller values of <code>T</code> means higher priority.
+ *
+ * The tree satisfies the following invariant:
+ * <i>
+ * For any node <code>n</code> in the tree:
+ * If node <code>n</code> has a left child <code>l</code>,
+ * <code>T(n) <= T(l)</code>.
+ * If node <code>n</code> has a right child <code>r</code>,
+ * <code>T(n) <= T(r)</code>.
+ * </i>
+ *
+ *
+ * The invariant may be temporarily broken while executing synchronized
+ * on <code>this</code> instance, but is always reestablished before
+ * leaving the synchronized code.
+ *
+ * The node at index <code>1</code> is always the first node to timeout,
+ * as can be deduced from the invariant.
+ *
+ * For the following algorithm pseudocode, the operation
+ * <code>swap(n,m)</code> denotes the exchange of the nodes at indices
+ * <code>n</code> and <code>m</code> in the tree.
+ *
+ * Insertion of a new node happend as follows:
+ * <pre>
+ * IF size = q.length THEN
+ * "expand q array to be larger";
+ * ENDIF
+ * size <- size + 1;
+ * q[size] <- "new node";
+ * n <- size;
+ * WHILE n > 1 AND T(n/2) > T(n) DO
+ * swap(n/2, n);
+ * n <- n/2;
+ * ENDWHILE
+ * </pre>
+ * Proof that this insertion algorithm respects the invariant is left to
+ * the interested reader.
+ *
+ * The removal algorithm is a bit more complicated. To remove the node
+ * at index <code>n</code>:
+ * <pre>
+ * swap(n, size);
+ * size <- size - 1;
+ * IF n > 1 AND T(n/2) > T(n) THEN
+ * WHILE n > 1 AND T(n/2) > T(n) DO
+ * swap(n/2, n);
+ * n <- n/2;
+ * ENDWHILE
+ * ELSE
+ * WHILE 2*n <= size DO
+ * IF 2*n+1 <= size THEN
+ * // Both children present
+ * IF T(2*n) <= T(2*n+1) THEN
+ * IF T(n) <= T(2*n) THEN
+ * EXIT;
+ * ENDIF
+ * swap(n, 2*n);
+ * n <- 2*n;
+ * ELSE
+ * IF T(n) <= T(2*n+1) THEN
+ * EXIT;
+ * ENDIF
+ * swap(n, 2*n+1);
+ * n <- 2*n+1;
+ * ENDIF
+ * ELSE
+ * // Only left child, right child not present.
+ * IF T(n) <= T(2*n) THEN
+ * EXIT;
+ * ENDIF
+ * swap(n, 2*n);
+ * n <- 2*n;
+ * ENDIF
+ * ENDWHILE
+ * ENDIF
+ * </pre>
+ * Proof that this removal algorithm respects the invariant is left to
+ * the interested reader. Really, I am not going to prove it here.
+ *
+ * If you are interested, you can find this data structure and its
+ * associated operations in most textbooks on algorithmics.
+ *
+ * @see checkTree
+ */
+ private TimeoutImpl[] q;
+
+ /**
+ * Debugging helper.
+ */
+ private void assertExpr(boolean expr)
+ {
+ if (!expr)
+ {
+ RuntimeException ex = new RuntimeException("***** assert failed *****");
+ try {
+ Thread.sleep(30000);
+ } catch (Exception e) {}
+ }
+ }
+
+ /**
+ * Check invariants of the queue.
+ */
+ private void checkTree() {
+ assertExpr(size >= 0);
+ assertExpr(size < q.length);
+ assertExpr(q[0] == null);
+
+ if (size > 0) {
+ assertExpr(q[1] != null);
+ assertExpr(q[1].index == 1);
+ for (int i = 2; i <= size; ++i) {
+ assertExpr(q[i] != null);
+ assertExpr(q[i].index == i);
+ assertExpr(q[i >> 1].time <= q[i].time); // parent fires first
+ }
+ for (int i = size+1; i < q.length; ++i)
+ assertExpr(q[i] == null);
+ }
+ }
+
+ /**
+ * Check invariants of the free list.
+ */
+ private void checkFreeList() {
+ TimeoutImpl to = freeList;
+
+ while (to != null) {
+ assertExpr(to.index == TimeoutImpl.DONE);
+ to = to.nextFree;
+ }
+ }
+
+ /**
+ * Swap two nodes in the tree.
+ */
+ private void swap(int a, int b) {
+ // INV: assertExpr(a > 0);
+ // INV: assertExpr(a <= size);
+ // INV: assertExpr(b > 0);
+ // INV: assertExpr(b <= size);
+ // INV: assertExpr(q[a] != null);
+ // INV: assertExpr(q[b] != null);
+ // INV: assertExpr(q[a].index == a);
+ // INV: assertExpr(q[b].index == b);
+ TimeoutImpl temp = q[a];
+ q[a] = q[b];
+ q[a].index = a;
+ q[b] = temp;
+ q[b].index = b;
+ }
+
+ /**
+ * A new node has been added at index <code>index</code>.
+ * Normalize the tree by moving the new node up the tree.
+ *
+ * @return True iff the tree was modified.
+ */
+ private boolean normalizeUp(int index) {
+ // INV: assertExpr(index > 0);
+ // INV: assertExpr(index <= size);
+ // INV: assertExpr(q[index] != null);
+
+ if (index == 1)
+ return false; // at root
+
+ boolean ret = false;
+ long t = q[index].time;
+ int p = index >> 1;
+
+ while (q[p].time > t) {
+ // INV: assertExpr(q[index].time == t);
+ swap(p, index);
+ ret = true;
+
+ if (p == 1)
+ break; // at root
+
+ index = p;
+ p >>= 1;
+ }
+ return ret;
+ }
+
+ /**
+ * Remove a node from the tree and normalize.
+ *
+ * @return The removed node.
+ */
+ private TimeoutImpl removeNode(int index) {
+ // INV: assertExpr(index > 0);
+ // INV: assertExpr(index <= size);
+ TimeoutImpl res = q[index];
+ // INV: assertExpr(res != null);
+ // INV: assertExpr(res.index == index);
+
+ if (index == size) {
+ --size;
+ q[index] = null;
+ return res;
+ }
+
+ swap(index, size); // Exchange removed node with last leaf node
+ --size;
+
+ // INV: assertExpr(res.index == size + 1);
+ q[res.index] = null;
+
+ if (normalizeUp(index))
+ return res; // Node moved up, so it shouldn't move down
+
+ long t = q[index].time;
+ int c = index << 1;
+
+ while (c <= size) {
+ // INV: assertExpr(q[index].time == t);
+
+ TimeoutImpl l = q[c];
+ // INV: assertExpr(l != null);
+ // INV: assertExpr(l.index == c);
+
+ if (c+1 <= size) {
+ // two children, swap with smallest
+ TimeoutImpl r = q[c+1];
+ // INV: assertExpr(r != null);
+ // INV: assertExpr(r.index == c+1);
+
+ if (l.time <= r.time) {
+ if (t <= l.time)
+ break; // done
+ swap(index, c);
+ index = c;
+ } else {
+ if (t <= r.time)
+ break; // done
+ swap(index, c+1);
+ index = c+1;
+ }
+ } else { // one child
+ if (t <= l.time)
+ break; // done
+ swap(index, c);
+ index = c;
+ }
+
+ c = index << 1;
+ }
+
+ return res;
+ }
+
+ /**
+ * Create a new timeout.
+ */
+ private synchronized Timeout newTimeout(long time, TimeoutTarget target) {
+ // INV: checkTree();
+
+ // INV: assertExpr(size < q.length);
+ if (++size == q.length) {
+ TimeoutImpl[] newQ = new TimeoutImpl[2*q.length];
+ System.arraycopy(q, 0, newQ, 0, q.length);
+ q = newQ;
+ }
+ // INV: assertExpr(size < q.length);
+ // INV: assertExpr(q[size] == null);
+
+ TimeoutImpl timeout;
+
+ if (freeList != null) {
+ timeout = q[size] = freeList;
+ freeList = timeout.nextFree;
+ // INV: checkFreeList();
+ // INV: assertExpr(timeout.index == TimeoutImpl.DONE);
+ } else
+ timeout = q[size] = new TimeoutImpl();
+
+ timeout.index = size;
+ timeout.time = time;
+ timeout.target = target;
+
+ normalizeUp(size);
+
+ if (timeout.index == 1)
+ notify();
+
+ // INV: checkTree();
+
+ return timeout;
+ }
+
+ /**
+ * Cancel a timeout.
+ */
+ private void dropTimeout(TimeoutImpl timeout) {
+ synchronized (this) {
+ if (timeout.index > 0) {
+ // Active timeout, remove it.
+ // INV: assertExpr(q[timeout.index] == timeout);
+ // INV: checkTree();
+ removeNode(timeout.index);
+ // INV: checkTree();
+ timeout.index = TimeoutImpl.DONE;
+ timeout.nextFree = freeList;
+ freeList = timeout;
+ // INV: checkFreeList();
+ return;
+ }
+ }
+
+ // If timeout has already started, wait until done.
+ synchronized (timeout) {
+ if (timeout.index == TimeoutImpl.TIMEOUT ||
+ timeout.index == TimeoutImpl.CWAIT) {
+ // Wait to avoid race with the actual timeout that is happening now.
+ timeout.index = TimeoutImpl.CWAIT;
+ while (timeout.index == TimeoutImpl.CWAIT) {
+ try {
+ timeout.wait();
+ } catch (InterruptedException ex) { }
+ }
+ }
+ }
+ }
+
+ /**
+ * Timeout worker method.
+ * This method never returns. Whenever it is time to do a timeout,
+ * the callback method is called from here.
+ */
+ private void doWork() {
+ while (true) {
+ TimeoutImpl work = null;
+
+ // Look for work
+ synchronized (this) {
+ if (size == 0) {
+ try {
+ wait();
+ } catch (InterruptedException ex) {}
+ } else {
+ long now = System.currentTimeMillis();
+ if (q[1].time > now) {
+ try {
+ wait(q[1].time - now);
+ } catch (InterruptedException ex) {}
+ }
+ if (size > 0 && q[1].time <= System.currentTimeMillis()) {
+ work = removeNode(1);
+ work.index = TimeoutImpl.TIMEOUT;
+ }
+ }
+ }
+
+ // Do work, if any
+ if (work != null) {
+ // Create a new thread to do the callback.
+ TimeoutWorker worker = new TimeoutWorker(work);
+ worker.start();
+ }
+ }
+ }
+
+
+ /** Our singleton instance. */
+ static private TimeoutFactory singleton;
+
+ /** Our private constructor. */
+ private TimeoutFactory() {
+ freeList = null;
+ size = 0;
+ q = new TimeoutImpl[16];
+ }
+
+ /**
+ * Initialize class.
+ * The will initialize the singleton and create a single
+ * worker thread.
+ */
+ static {
+ singleton = new TimeoutFactory();
+ Thread thread = new Thread() {
+ public void run() {
+ singleton.doWork();
+ }
+ };
+ thread.setDaemon(true);
+ thread.start();
+ }
+
+ /**
+ * Schedule a new timeout.
+ */
+ static public Timeout createTimeout(long time, TimeoutTarget target) {
+ if (time <= 0)
+ throw new IllegalArgumentException("Time not positive");
+ if (target == null)
+ throw new IllegalArgumentException("Null target");
+
+ return singleton.newTimeout(time, target);
+ }
+
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/TimeoutFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/TimeoutTarget.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/TimeoutTarget.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/TimeoutTarget.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,22 @@
+/*
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
+package org.jboss.util.timeout;
+
+
+/**
+ * The interface of objects that can receive timeouts.
+ *
+ * @author <a href="osh at sparre.dk">Ole Husgaard</a>
+ * @version $Revision$
+*/
+public interface TimeoutTarget {
+ /**
+ * The timeout callback function is invoked when the timeout expires.
+ */
+ public void timedOut(Timeout timeout);
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/TimeoutTarget.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>Timeout utilties.
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/timeout/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/DOMWriter.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/DOMWriter.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/DOMWriter.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,331 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999, 2000 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 acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" 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 at apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * 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 and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.apache.org. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.jboss.util.xml;
+
+
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.io.UnsupportedEncodingException;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+/**
+ * A sample DOM writer. This sample program illustrates how to
+ * traverse a DOM tree in order to print a document that is parsed.
+ *
+ * @version $Id$
+ * @version ORIGINAL - DOMWriter.java,v 1.8 2000/09/19 17:15:47 jeffreyr
+ */
+public class DOMWriter {
+
+ //
+ // Constants
+ //
+
+
+ //
+ // Data
+ //
+
+ /** Default Encoding */
+ private static String
+ PRINTWRITER_ENCODING = "UTF8";
+
+ private static String MIME2JAVA_ENCODINGS[] =
+ { "Default", "UTF-8", "US-ASCII", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4",
+ "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-2022-JP",
+ "SHIFT_JIS", "EUC-JP","GB2312", "BIG5", "EUC-KR", "ISO-2022-KR", "KOI8-R", "EBCDIC-CP-US",
+ "EBCDIC-CP-CA", "EBCDIC-CP-NL", "EBCDIC-CP-DK", "EBCDIC-CP-NO", "EBCDIC-CP-FI", "EBCDIC-CP-SE",
+ "EBCDIC-CP-IT", "EBCDIC-CP-ES", "EBCDIC-CP-GB", "EBCDIC-CP-FR", "EBCDIC-CP-AR1",
+ "EBCDIC-CP-HE", "EBCDIC-CP-CH", "EBCDIC-CP-ROECE","EBCDIC-CP-YU",
+ "EBCDIC-CP-IS", "EBCDIC-CP-AR2", "UTF-16"
+ };
+
+
+
+ /** Print writer. */
+ protected PrintWriter out;
+
+ /** Canonical output. */
+ protected boolean canonical;
+
+
+ public DOMWriter(Writer w, boolean canonical)
+ throws UnsupportedEncodingException {
+ out = new PrintWriter(w);
+ this.canonical = canonical;
+ } // <init>(String,boolean)
+
+ //
+ // Constructors
+ //
+
+ public static String getWriterEncoding( ) {
+ return(PRINTWRITER_ENCODING);
+ }// getWriterEncoding
+
+
+
+ public void print(Node node) {
+ print(node, true);
+ }
+
+ /** Prints the specified node, recursively. */
+ public void print(Node node, boolean prettyprint) {
+
+ // is there anything to do?
+ if ( node == null ) {
+ return;
+ }
+
+ int type = node.getNodeType();
+ switch ( type ) {
+ // print document
+ case Node.DOCUMENT_NODE: {
+ if ( !canonical ) {
+ String Encoding = this.getWriterEncoding();
+ if ( Encoding.equalsIgnoreCase( "DEFAULT" ) )
+ Encoding = "UTF-8";
+ else if ( Encoding.equalsIgnoreCase( "Unicode" ) )
+ Encoding = "UTF-16";
+ else
+ Encoding = MIME2Java.reverse( Encoding );
+
+ out.println("<?xml version=\"1.0\" encoding=\""+
+ Encoding + "\"?>");
+ }
+ //print(((Document)node).getDocumentElement());
+
+ NodeList children = node.getChildNodes();
+ for ( int iChild = 0; iChild < children.getLength(); iChild++ ) {
+ print(children.item(iChild));
+ }
+ out.flush();
+ break;
+ }
+
+ // print element with attributes
+ case Node.ELEMENT_NODE: {
+ out.print('<');
+ out.print(node.getNodeName());
+ Attr attrs[] = sortAttributes(node.getAttributes());
+ for ( int i = 0; i < attrs.length; i++ ) {
+ Attr attr = attrs[i];
+ out.print(' ');
+ out.print(attr.getNodeName());
+ out.print("=\"");
+ out.print(normalize(attr.getNodeValue()));
+ out.print('"');
+ }
+ out.print('>');
+ NodeList children = node.getChildNodes();
+ if ( children != null ) {
+ int len = children.getLength();
+ for ( int i = 0; i < len; i++ ) {
+ print(children.item(i));
+ }
+ }
+ break;
+ }
+
+ // handle entity reference nodes
+ case Node.ENTITY_REFERENCE_NODE: {
+ if ( canonical ) {
+ NodeList children = node.getChildNodes();
+ if ( children != null ) {
+ int len = children.getLength();
+ for ( int i = 0; i < len; i++ ) {
+ print(children.item(i));
+ }
+ }
+ } else {
+ out.print('&');
+ out.print(node.getNodeName());
+ out.print(';');
+ }
+ break;
+ }
+
+ // print cdata sections
+ case Node.CDATA_SECTION_NODE: {
+ if ( canonical ) {
+ out.print(normalize(node.getNodeValue()));
+ } else {
+ out.print("<![CDATA[");
+ out.print(node.getNodeValue());
+ out.print("]]>");
+ }
+ break;
+ }
+
+ // print text
+ case Node.TEXT_NODE: {
+ out.print(normalize(node.getNodeValue()));
+ break;
+ }
+
+ // print processing instruction
+ case Node.PROCESSING_INSTRUCTION_NODE: {
+ out.print("<?");
+ out.print(node.getNodeName());
+ String data = node.getNodeValue();
+ if ( data != null && data.length() > 0 ) {
+ out.print(' ');
+ out.print(data);
+ }
+ out.println("?>");
+ break;
+ }
+ }
+
+ if ( type == Node.ELEMENT_NODE ) {
+ out.print("</");
+ out.print(node.getNodeName());
+ out.print('>');
+ if (prettyprint) out.println();
+ }
+
+ out.flush();
+
+ } // print(Node)
+
+ /** Returns a sorted list of attributes. */
+ protected Attr[] sortAttributes(NamedNodeMap attrs) {
+
+ int len = (attrs != null) ? attrs.getLength() : 0;
+ Attr array[] = new Attr[len];
+ for ( int i = 0; i < len; i++ ) {
+ array[i] = (Attr)attrs.item(i);
+ }
+ for ( int i = 0; i < len - 1; i++ ) {
+ String name = array[i].getNodeName();
+ int index = i;
+ for ( int j = i + 1; j < len; j++ ) {
+ String curName = array[j].getNodeName();
+ if ( curName.compareTo(name) < 0 ) {
+ name = curName;
+ index = j;
+ }
+ }
+ if ( index != i ) {
+ Attr temp = array[i];
+ array[i] = array[index];
+ array[index] = temp;
+ }
+ }
+
+ return(array);
+
+ } // sortAttributes(NamedNodeMap):Attr[]
+
+
+
+
+ /** Normalizes the given string. */
+ protected String normalize(String s) {
+ StringBuffer str = new StringBuffer();
+
+ int len = (s != null) ? s.length() : 0;
+ for ( int i = 0; i < len; i++ ) {
+ char ch = s.charAt(i);
+ switch ( ch ) {
+ case '<': {
+ str.append("<");
+ break;
+ }
+ case '>': {
+ str.append(">");
+ break;
+ }
+ case '&': {
+ str.append("&");
+ break;
+ }
+ case '"': {
+ str.append(""");
+ break;
+ }
+ case '\r':
+ case '\n': {
+ if ( canonical ) {
+ str.append("&#");
+ str.append(Integer.toString(ch));
+ str.append(';');
+ break;
+ }
+ // else, default append char
+ }
+ default: {
+ str.append(ch);
+ }
+ }
+ }
+
+ return(str.toString());
+
+ } // normalize(String):String
+
+
+
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/DOMWriter.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/MIME2Java.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/MIME2Java.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/MIME2Java.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,667 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 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 acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xerces" 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 at apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * 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 and was
+ * originally based on software copyright (c) 1999, International
+ * Business Machines, Inc., http://www.apache.org. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+package org.jboss.util.xml;
+
+import java.util.*;
+
+/**
+ * MIME2Java is a convenience class which handles conversions between MIME charset names
+ * and Java encoding names.
+ * <p>The supported XML encodings are the intersection of XML-supported code sets and those
+ * supported in JDK 1.1.
+ * <p>MIME charset names are used on <var>xmlEncoding</var> parameters to methods such
+ * as <code>TXDocument#setEncoding</code> and <code>DTD#setEncoding</code>.
+ * <p>Java encoding names are used on <var>encoding</var> parameters to
+ * methods such as <code>TXDocument#printWithFormat</code> and <code>DTD#printExternal</code>.
+ * <P>
+ * <TABLE BORDER="0" WIDTH="100%">
+ * <TR>
+ * <TD WIDTH="33%">
+ * <P ALIGN="CENTER"><B>Common Name</B>
+ * </TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER"><B>Use this name in XML files</B>
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER"><B>Name Type</B>
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER"><B>Xerces converts to this Java Encoder Name</B>
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">8 bit Unicode</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">UTF-8
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">UTF8
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin 1</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-1
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-1
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin 2</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-2
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-2
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin 3</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-3
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-3
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin 4</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-4
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-4
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin Cyrillic</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-5
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-5
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin Arabic</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-6
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-6
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin Greek</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-7
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-7
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin Hebrew</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-8
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-8
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">ISO Latin 5</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ISO-8859-9
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">ISO-8859-9
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: US</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-us
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp037
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Canada</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-ca
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp037
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Netherlands</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-nl
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp037
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Denmark</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-dk
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp277
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Norway</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-no
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp277
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Finland</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-fi
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp278
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Sweden</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-se
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp278
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Italy</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-it
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp280
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Spain, Latin America</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-es
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp284
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Great Britain</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-gb
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp285
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: France</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-fr
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp297
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Arabic</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-ar1
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp420
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Hebrew</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-he
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp424
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Switzerland</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-ch
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp500
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Roece</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-roece
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp870
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Yogoslavia</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-yu
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp870
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Iceland</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-is
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp871
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">EBCDIC: Urdu</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">ebcdic-cp-ar2
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">IANA
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">cp918
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Chinese for PRC, mixed 1/2 byte</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">gb2312
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">GB2312
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Extended Unix Code, packed for Japanese</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">euc-jp
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">eucjis
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Japanese: iso-2022-jp</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">iso-2020-jp
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">JIS
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Japanese: Shift JIS</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">Shift_JIS
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">SJIS
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Japanese Windows: An extension of Shift JIS</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">Windows-31J
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">MS932 (since JDK 1.2)
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Chinese: Big5</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">Big5
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">Big5
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Extended Unix Code, packed for Korean</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">euc-kr
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">iso2022kr
+ * </TD>
+ * </TR>
+ * <TR>
+ * <TD WIDTH="33%">Cyrillic</TD>
+ * <TD WIDTH="15%">
+ * <P ALIGN="CENTER">koi8-r
+ * </TD>
+ * <TD WIDTH="12%">
+ * <P ALIGN="CENTER">MIME
+ * </TD>
+ * <TD WIDTH="31%">
+ * <P ALIGN="CENTER">koi8-r
+ * </TD>
+ * </TR>
+ * </TABLE>
+ *
+ * @version $Id$
+ * @version ORIGINAL - MIME2Java.java,v 1.2 2000/12/14 19:21:46 lehors
+ * @author TAMURA Kent <kent at trl.ibm.co.jp>
+ */
+public class MIME2Java {
+
+ static private Hashtable s_enchash;
+ static private Hashtable s_revhash;
+
+ static {
+ s_enchash = new Hashtable();
+ // <preferred MIME name (uppercase)>, <Java encoding name>
+ s_enchash.put("UTF-8", "UTF8");
+ s_enchash.put("US-ASCII", "ASCII");
+ s_enchash.put("ISO-8859-1", "8859_1");
+ s_enchash.put("ISO-8859-2", "8859_2");
+ s_enchash.put("ISO-8859-3", "8859_3");
+ s_enchash.put("ISO-8859-4", "8859_4");
+ s_enchash.put("ISO-8859-5", "8859_5");
+ s_enchash.put("ISO-8859-6", "8859_6");
+ s_enchash.put("ISO-8859-7", "8859_7");
+ s_enchash.put("ISO-8859-8", "8859_8");
+ s_enchash.put("ISO-8859-9", "8859_9");
+ s_enchash.put("ISO-2022-JP", "JIS");
+ s_enchash.put("SHIFT_JIS", "SJIS");
+ /**
+ * MS932 is suitable for Windows-31J,
+ * but JDK 1.1.x does not support MS932.
+ */
+ String version = System.getProperty("java.version");
+ if (version.equals("1.1") || version.startsWith("1.1.")) {
+ s_enchash.put("WINDOWS-31J", "SJIS");
+ } else {
+ s_enchash.put("WINDOWS-31J", "MS932");
+ }
+ s_enchash.put("EUC-JP", "EUCJIS");
+ s_enchash.put("GB2312", "GB2312");
+ s_enchash.put("BIG5", "Big5");
+ s_enchash.put("EUC-KR", "KSC5601");
+ s_enchash.put("ISO-2022-KR", "ISO2022KR");
+ s_enchash.put("KOI8-R", "KOI8_R");
+
+ s_enchash.put("EBCDIC-CP-US", "CP037");
+ s_enchash.put("EBCDIC-CP-CA", "CP037");
+ s_enchash.put("EBCDIC-CP-NL", "CP037");
+ s_enchash.put("EBCDIC-CP-DK", "CP277");
+ s_enchash.put("EBCDIC-CP-NO", "CP277");
+ s_enchash.put("EBCDIC-CP-FI", "CP278");
+ s_enchash.put("EBCDIC-CP-SE", "CP278");
+ s_enchash.put("EBCDIC-CP-IT", "CP280");
+ s_enchash.put("EBCDIC-CP-ES", "CP284");
+ s_enchash.put("EBCDIC-CP-GB", "CP285");
+ s_enchash.put("EBCDIC-CP-FR", "CP297");
+ s_enchash.put("EBCDIC-CP-AR1", "CP420");
+ s_enchash.put("EBCDIC-CP-HE", "CP424");
+ s_enchash.put("EBCDIC-CP-CH", "CP500");
+ s_enchash.put("EBCDIC-CP-ROECE", "CP870");
+ s_enchash.put("EBCDIC-CP-YU", "CP870");
+ s_enchash.put("EBCDIC-CP-IS", "CP871");
+ s_enchash.put("EBCDIC-CP-AR2", "CP918");
+
+ // j:CNS11643 -> EUC-TW?
+ // ISO-2022-CN? ISO-2022-CN-EXT?
+
+ s_revhash = new Hashtable();
+ // <Java encoding name (uppercase)>, <preferred MIME name>
+ s_revhash.put("UTF8", "UTF-8");
+ s_revhash.put("ASCII", "US-ASCII");
+ s_revhash.put("8859_1", "ISO-8859-1");
+ s_revhash.put("8859_2", "ISO-8859-2");
+ s_revhash.put("8859_3", "ISO-8859-3");
+ s_revhash.put("8859_4", "ISO-8859-4");
+ s_revhash.put("8859_5", "ISO-8859-5");
+ s_revhash.put("8859_6", "ISO-8859-6");
+ s_revhash.put("8859_7", "ISO-8859-7");
+ s_revhash.put("8859_8", "ISO-8859-8");
+ s_revhash.put("8859_9", "ISO-8859-9");
+ s_revhash.put("JIS", "ISO-2022-JP");
+ s_revhash.put("SJIS", "Shift_JIS");
+ s_revhash.put("MS932", "WINDOWS-31J");
+ s_revhash.put("EUCJIS", "EUC-JP");
+ s_revhash.put("GB2312", "GB2312");
+ s_revhash.put("BIG5", "Big5");
+ s_revhash.put("KSC5601", "EUC-KR");
+ s_revhash.put("ISO2022KR", "ISO-2022-KR");
+ s_revhash.put("KOI8_R", "KOI8-R");
+
+ s_revhash.put("CP037", "EBCDIC-CP-US");
+ s_revhash.put("CP037", "EBCDIC-CP-CA");
+ s_revhash.put("CP037", "EBCDIC-CP-NL");
+ s_revhash.put("CP277", "EBCDIC-CP-DK");
+ s_revhash.put("CP277", "EBCDIC-CP-NO");
+ s_revhash.put("CP278", "EBCDIC-CP-FI");
+ s_revhash.put("CP278", "EBCDIC-CP-SE");
+ s_revhash.put("CP280", "EBCDIC-CP-IT");
+ s_revhash.put("CP284", "EBCDIC-CP-ES");
+ s_revhash.put("CP285", "EBCDIC-CP-GB");
+ s_revhash.put("CP297", "EBCDIC-CP-FR");
+ s_revhash.put("CP420", "EBCDIC-CP-AR1");
+ s_revhash.put("CP424", "EBCDIC-CP-HE");
+ s_revhash.put("CP500", "EBCDIC-CP-CH");
+ s_revhash.put("CP870", "EBCDIC-CP-ROECE");
+ s_revhash.put("CP870", "EBCDIC-CP-YU");
+ s_revhash.put("CP871", "EBCDIC-CP-IS");
+ s_revhash.put("CP918", "EBCDIC-CP-AR2");
+ }
+
+ private MIME2Java() {
+ }
+
+ /**
+ * Convert a MIME charset name, also known as an XML encoding name, to a Java encoding name.
+ * @param mimeCharsetName Case insensitive MIME charset name: <code>UTF-8, US-ASCII, ISO-8859-1,
+ * ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6,
+ * ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-2022-JP, Shift_JIS, Windows-31J
+ * EUC-JP, GB2312, Big5, EUC-KR, ISO-2022-KR, KOI8-R,
+ * EBCDIC-CP-US, EBCDIC-CP-CA, EBCDIC-CP-NL, EBCDIC-CP-DK,
+ * EBCDIC-CP-NO, EBCDIC-CP-FI, EBCDIC-CP-SE, EBCDIC-CP-IT,
+ * EBCDIC-CP-ES, EBCDIC-CP-GB, EBCDIC-CP-FR, EBCDIC-CP-AR1,
+ * EBCDIC-CP-HE, EBCDIC-CP-CH, EBCDIC-CP-ROECE, EBCDIC-CP-YU,
+ * EBCDIC-CP-IS and EBCDIC-CP-AR2</code>.
+ * @return Java encoding name, or <var>null</var> if <var>mimeCharsetName</var>
+ * is unknown.
+ * @see #reverse
+ */
+ public static String convert(String mimeCharsetName) {
+ return (String)s_enchash.get(mimeCharsetName.toUpperCase());
+ }
+
+ /**
+ * Convert a Java encoding name to MIME charset name.
+ * Available values of <i>encoding</i> are "UTF8", "8859_1", "8859_2", "8859_3", "8859_4",
+ * "8859_5", "8859_6", "8859_7", "8859_8", "8859_9", "JIS", "SJIS", "MS932", "EUCJIS",
+ * "GB2312", "BIG5", "KSC5601", "ISO2022KR", "KOI8_R", "CP037", "CP277", "CP278",
+ * "CP280", "CP284", "CP285", "CP297", "CP420", "CP424", "CP500", "CP870", "CP871" and "CP918".
+ * @param encoding Case insensitive Java encoding name: <code>UTF8, 8859_1, 8859_2, 8859_3,
+ * 8859_4, 8859_5, 8859_6, 8859_7, 8859_8, 8859_9, JIS, SJIS, MS932, EUCJIS,
+ * GB2312, BIG5, KSC5601, ISO2022KR, KOI8_R, CP037, CP277, CP278,
+ * CP280, CP284, CP285, CP297, CP420, CP424, CP500, CP870, CP871
+ * and CP918</code>.
+ * @return MIME charset name, or <var>null</var> if <var>encoding</var> is unknown.
+ * @see #convert
+ */
+ public static String reverse(String encoding) {
+ return (String)s_revhash.get(encoding.toUpperCase());
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/MIME2Java.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/XmlHelper.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/XmlHelper.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/XmlHelper.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,222 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.util.xml;
+
+import java.io.Writer;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Collection;
+
+/**
+ * A utility class to cover up the rough bits of xml parsing
+ *
+ * @author <a href="mailto:chris at kimptoc.net">Chris Kimpton</a>
+ * @version $Revision$
+ */
+public class XmlHelper
+{
+ public static void write(Writer out, Document dom)
+ throws Exception
+ {
+ DOMWriter writer = new DOMWriter(out, false);
+ writer.print(dom, true);
+ }
+
+ /**
+ * Returns an iterator over the children of the given element with
+ * the given tag name.
+ *
+ * @param element The parent element
+ * @param tagName The name of the desired child
+ * @return An interator of children or null if element is null.
+ */
+ public static Iterator getChildrenByTagName(Element element,
+ String tagName)
+ {
+ if (element == null) return null;
+ // getElementsByTagName gives the corresponding elements in the whole
+ // descendance. We want only children
+
+ NodeList children = element.getChildNodes();
+ ArrayList goodChildren = new ArrayList();
+ for (int i=0; i<children.getLength(); i++) {
+ Node currentChild = children.item(i);
+ if (currentChild.getNodeType() == Node.ELEMENT_NODE &&
+ ((Element)currentChild).getTagName().equals(tagName)) {
+ goodChildren.add((Element)currentChild);
+ }
+ }
+ return goodChildren.iterator();
+ }
+
+ /**
+ * Gets the child of the specified element having the specified unique
+ * name. If there are more than one children elements with the same name
+ * and exception is thrown.
+ *
+ * @param element The parent element
+ * @param tagName The name of the desired child
+ * @return The named child.
+ *
+ * @throws Exception Child was not found or was not unique.
+ */
+ public static Element getUniqueChild(Element element, String tagName)
+ throws Exception
+ {
+ Iterator goodChildren = getChildrenByTagName(element, tagName);
+
+ if (goodChildren != null && goodChildren.hasNext()) {
+ Element child = (Element)goodChildren.next();
+ if (goodChildren.hasNext()) {
+ throw new Exception
+ ("expected only one " + tagName + " tag");
+ }
+ return child;
+ } else {
+ throw new Exception
+ ("expected one " + tagName + " tag");
+ }
+ }
+
+ /**
+ * Gets the child of the specified element having the
+ * specified name. If the child with this name doesn't exist
+ * then null is returned instead.
+ *
+ * @param element the parent element
+ * @param tagName the name of the desired child
+ * @return either the named child or null
+ */
+ public static Element getOptionalChild(Element element, String tagName)
+ throws Exception
+ {
+ return getOptionalChild(element, tagName, null);
+ }
+
+ /**
+ * Gets the child of the specified element having the
+ * specified name. If the child with this name doesn't exist
+ * then the supplied default element is returned instead.
+ *
+ * @param element the parent element
+ * @param tagName the name of the desired child
+ * @param defaultElement the element to return if the child
+ * doesn't exist
+ * @return either the named child or the supplied default
+ */
+ public static Element getOptionalChild(Element element,
+ String tagName,
+ Element defaultElement)
+ throws Exception
+ {
+ Iterator goodChildren = getChildrenByTagName(element, tagName);
+
+ if (goodChildren != null && goodChildren.hasNext()) {
+ Element child = (Element)goodChildren.next();
+ if (goodChildren.hasNext()) {
+ throw new Exception
+ ("expected only one " + tagName + " tag");
+ }
+ return child;
+ } else {
+ return defaultElement;
+ }
+ }
+
+ /**
+ * Get the content of the given element.
+ *
+ * @param element The element to get the content for.
+ * @return The content of the element or null.
+ */
+ public static String getElementContent(final Element element)
+ throws Exception
+ {
+ return getElementContent(element, null);
+ }
+
+ /**
+ * Get the content of the given element.
+ *
+ * @param element The element to get the content for.
+ * @param defaultStr The default to return when there is no content.
+ * @return The content of the element or the default.
+ */
+ public static String getElementContent(Element element, String defaultStr)
+ throws Exception
+ {
+ if (element == null)
+ return defaultStr;
+
+ NodeList children = element.getChildNodes();
+ String result = "";
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ if (children.item(i).getNodeType() == Node.TEXT_NODE ||
+ children.item(i).getNodeType() == Node.CDATA_SECTION_NODE)
+ {
+ result += children.item(i).getNodeValue();
+ }
+ else if( children.item(i).getNodeType() == Node.COMMENT_NODE )
+ {
+ // Ignore comment nodes
+ }
+ }
+ return result.trim();
+ }
+
+ /**
+ * Macro to get the content of a unique child element.
+ *
+ * @param element The parent element.
+ * @param tagName The name of the desired child.
+ * @return The element content or null.
+ */
+ public static String getUniqueChildContent(Element element,
+ String tagName)
+ throws Exception
+ {
+ return getElementContent(getUniqueChild(element, tagName));
+ }
+
+ /**
+ * Macro to get the content of an optional child element.
+ *
+ * @param element The parent element.
+ * @param tagName The name of the desired child.
+ * @return The element content or null.
+ */
+ public static String getOptionalChildContent(Element element,
+ String tagName)
+ throws Exception
+ {
+ return getElementContent(getOptionalChild(element, tagName));
+ }
+
+ public static boolean getOptionalChildBooleanContent(Element element, String name) throws Exception
+ {
+ Element child = getOptionalChild(element, name);
+ if(child != null)
+ {
+ String value = getElementContent(child).toLowerCase();
+ return value.equals("true") || value.equals("yes");
+ }
+
+ return false;
+ }
+
+
+}
+
+
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/XmlHelper.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/catalog
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/catalog/helpers
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/catalog/readers
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/package.html
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/package.html (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/package.html 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <!-- $Id$ -->
+ <!--
+
+ JBoss: The OpenSource J2EE WebOS
+
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+
+ -->
+ </head>
+
+ <body bgcolor="white">
+ <p>XML utilities.
+
+ <h2>Package Specification</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Related Documentation</h2>
+ <ul>
+ <li><a href="javascript: alert('not available')">Not Available</a>
+ </ul>
+
+ <h2>Package Status</h2>
+ <ul>
+ <li><font color="green"><b>STABLE</b></font>
+ </ul>
+
+ <h2>Todo</h2>
+ <ul>
+ <li>???
+ </ul>
+
+ <!-- Put @see and @since tags down here. -->
+
+ </body>
+</html>
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/main/org/jboss/util/xml/package.html
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/test
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/test/org
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/test/org/jboss
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/test/org/jboss/util
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/test/org/jboss/util/propertyeditor
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/common/src/test/org/jboss/util/propertyeditor/PropertyEditorUnitTestCase.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/common/src/test/org/jboss/util/propertyeditor/PropertyEditorUnitTestCase.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/common/src/test/org/jboss/util/propertyeditor/PropertyEditorUnitTestCase.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,77 @@
+
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ *
+ */
+
+package org.jboss.util.propertyeditor;
+
+import java.beans.PropertyEditor;
+import org.apache.log4j.Logger;
+import org.dom4j.Element;
+
+
+
+import junit.framework.*;
+
+
+
+/**
+ * PropertyEditorUnitTestCase.java
+ *
+ *
+ * Created: Fri Feb 7 12:37:20 2003
+ *
+ * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
+ * @version
+ */
+
+public class PropertyEditorUnitTestCase extends TestCase {
+
+ private static final Logger log = Logger.getLogger(PropertyEditorUnitTestCase.class);
+
+ public PropertyEditorUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ private static final String TEST_XML = "<element attribute=\"value\"><nested/></element>";
+ public void testDOM4JElementEditor() throws Exception
+ {
+ PropertyEditor pe = new DOM4JElementEditor();
+ pe.setAsText(TEST_XML);
+ Element element = (Element)pe.getValue();
+ pe.setValue(element);
+ String result = pe.getAsText();
+ log.info("DOM4JElementEditor returned: " + result);
+ assertTrue("Result should be equal to original string: original: " + TEST_XML + ", result: " + result, TEST_XML.equals(result));
+ boundaryTests(pe);
+ }
+
+ private final static String TEST_STRING_ARRAY = "first,second,third";
+ public void testStringArrayEditor() throws Exception
+ {
+ PropertyEditor pe = new StringArrayEditor();
+ pe.setAsText(TEST_STRING_ARRAY);
+ String[] strings = (String[])pe.getValue();
+ pe.setValue(strings);
+ String result = pe.getAsText();
+ log.info("StringArrayEditor returned: " + result);
+ assertTrue("Result should be equal to original string: original: " + TEST_STRING_ARRAY + ", result: " + result, TEST_STRING_ARRAY.equals(result));
+ boundaryTests(pe);
+ }
+
+ private void boundaryTests(PropertyEditor pe) throws Exception
+ {
+ pe.setAsText(null);
+ assertTrue("value should be null, is: " + pe.getValue(), pe.getValue() == null);
+ pe.setAsText("");
+ assertTrue("value should be null, is: " + pe.getValue(), pe.getValue() == null);
+ pe.setValue(null);
+ assertTrue("getAsText should return null, is: " + pe.getAsText(), pe.getAsText() == null);
+ }
+
+}// PropertyEditorUnitTestCase
Property changes on: labs/jbossbuild/buildmagic/trunk/common/src/test/org/jboss/util/propertyeditor/PropertyEditorUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/tasks/build.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/build.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tasks/build.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -2,7 +2,6 @@
<!DOCTYPE project [
<!ENTITY buildmagic SYSTEM "../tools/etc/buildfragments/buildmagic.ent">
<!ENTITY tools SYSTEM "../tools/etc/buildfragments/tools.ent">
- <!ENTITY libraries SYSTEM "../tools/etc/buildfragments/libraries.ent">
<!ENTITY modules SYSTEM "../tools/etc/buildfragments/modules.ent">
<!ENTITY defaults SYSTEM "../tools/etc/buildfragments/defaults.ent">
<!ENTITY targets SYSTEM "../tools/etc/buildfragments/targets.ent">
@@ -32,7 +31,6 @@
<!--+====================================================================+-->
&buildmagic;
- &libraries;
&modules;
&defaults;
&tools;
@@ -60,17 +58,24 @@
<target name="configure" unless="configure.disable">
+ <!-- Module name(s) & version -->
+ <property name="module.name" value="tasks"/>
+ <property name="module.Name" value="Buildmagic/Tasks"/>
+
<!--+================================+-->
<!--| Library & Module Dependencies. |-->
<!--+================================+-->
<!-- Configure thirdparty libraries -->
- <call target="configure-libraries"/>
- <path id="library.classpath">
- <path refid="apache.log4j.classpath"/>
- <path refid="ibm.bsf.classpath"/>
- </path>
-
+ <dependency-manager
+ cacheDir="${project.thirdparty.cache}"
+ metadataFile="${project.root}/build/.metadata/${module.name}.tstamp"
+ dependencyFile="${module.root}/dependencies.xml"
+ offline="${dependency-manager.offline}"
+ pathID="library.classpath">
+ <repository url="http://jboss.sf.net/buildmagic/thirdparty" type="jboss"/>
+ </dependency-manager>
+
<!-- Configure modules -->
<call target="configure-modules"/>
<path id="dependentmodule.classpath">
@@ -146,6 +151,7 @@
<include name="org/jboss/util/Strings*.class"/>
<include name="org/jboss/util/Objects*.class"/>
<include name="org/jboss/util/*Exception*.class"/>
+ <include name="org/jboss/util/*Error*.class"/>
<include name="org/jboss/util/*Throwable*.class"/>
<include name="org/jboss/util/platform/Constants.class"/>
<include name="org/jboss/util/property/**"/>
Added: labs/jbossbuild/buildmagic/trunk/tasks/dependencies.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/dependencies.xml (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/dependencies.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id$ -->
+
+<!--+======================================================================+-->
+<!--| JBoss (The OpenSource J2EE WebOS) Thirdparty Dependencies |-->
+<!--| |-->
+<!--| Distributable under LGPL license. |-->
+<!--| See terms of license at http://www.gnu.org. |-->
+<!--+======================================================================+-->
+
+<dependencies>
+
+ <dependency>
+ <group-id>apache-log4j</group-id>
+ <id>log4j</id>
+ <version>1.2.4</version>
+ </dependency>
+
+ <dependency>
+ <group-id>ibm-bsf</group-id>
+ <id>bsf</id>
+ <version>2.2</version>
+ </dependency>
+
+</dependencies>
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/dependencies.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/bin
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/etc
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/etc/default.mf
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/FetchDependencyTask.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/FetchDependencyTask.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/FetchDependencyTask.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,482 @@
+/*
+ * Greebo: An Ant task to manage dependency files.
+ *
+ * Copyright (C) 2002 Ozben Evren
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+//
+// Heavily modified for use with JBoss
+//
+
+package oevren.ant.greebo;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+
+import org.apache.tools.ant.taskdefs.Get;
+import org.apache.tools.ant.taskdefs.Touch;
+import org.apache.tools.ant.taskdefs.UpToDate;
+
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.FileSet;
+
+import org.apache.xerces.parsers.DOMParser;
+import org.w3c.dom.*;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Collection;
+import java.util.Stack;
+import java.io.File;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import org.jboss.tools.buildmagic.task.util.TaskLogger;
+
+/**
+ *
+ * <p>
+ * <pre>
+ * $Log: FetchDependencyTask.java,v $
+ * Revision 1.1.2.2 2003/03/08 19:30:38 user57
+ * o make sure we read the right file
+ *
+ * Revision 1.1.2.1 2003/03/08 18:07:43 user57
+ * o import of heavily modified Greebo dependency manager task
+ * o modified buildmagic/tasks module to use the new fluff
+ *
+ * Revision 1.1 2002/11/22 02:41:47 ozbene
+ * Initial check-in to CVS
+ *
+ * </pre>
+ *
+ * @author Ozben Evren
+ * @version $Id$
+ *
+ */
+public class FetchDependencyTask
+ extends Task
+{
+ public static final String DEFAULT_REPOSITORY = "http://jboss.sf.net/buildmagic/thirdparty/";
+
+ public static class Context
+ {
+ private FetchDependencyTask task;
+ private TaskLogger logger;
+
+ public Context(final FetchDependencyTask task)
+ {
+ this.task = task;
+ this.logger = new TaskLogger(task);
+ }
+
+ public Task getTask()
+ {
+ return task;
+ }
+
+ public TaskLogger getLogger()
+ {
+ return logger;
+ }
+
+ public boolean isOffline()
+ {
+ return task.isOffline();
+ }
+ }
+
+ private Context context;
+ private TaskLogger log;
+
+ private boolean offline = false;
+
+ /**
+ * An external dependencies file, with the same dependency structure of the
+ * project.xml file of Maven.
+ */
+ private File dependencyFile;
+
+ /**
+ * Optional state file for dependency metadata
+ */
+ private File metadataFile;
+
+ /**
+ * The optional path id where the generated dependecy path will be installed.
+ */
+ private String pathID;
+
+ /**
+ * The destination directory for this dependency task.
+ */
+ private File dir;
+
+ private LinkedList dependencies;
+ private LinkedList repositories;
+ private Get get;
+
+ public FetchDependencyTask()
+ {
+ dependencies = new LinkedList();
+ repositories = new LinkedList();
+ get = new Get() {
+ public void log (String msg)
+ {
+ if (msg.startsWith("Error opening connection "))
+ {
+ return;
+ }
+ if (msg.startsWith("Can't get "))
+ {
+ return;
+ }
+ if (msg.startsWith("Not modified - so not downloaded"))
+ {
+ return;
+ }
+ if (msg.startsWith("Getting:"))
+ {
+ return;
+ }
+ super.log(msg);
+ }
+ };
+ get.setUseTimestamp(true);
+ get.setVerbose(false);
+ }
+
+ public void init()
+ {
+ log = new TaskLogger(this);
+ context = new Context(this);
+ }
+
+ private void validate() throws BuildException
+ {
+ if (dependencyFile == null && dependencies.size() == 0)
+ throw new BuildException("You have to have either a dependencyFile, or at least one JarDependency");
+
+ if (dir == null)
+ throw new BuildException("target directory <dir> is not specified.");
+
+ if (!dir.exists()) {
+ dir.mkdirs();
+ log.info("Created dir: " + dir);
+ }
+
+ if (!dir.isDirectory())
+ throw new BuildException("target directory <dir> is not a directory.");
+ }
+
+ public void execute() throws BuildException
+ {
+ get.setTaskName(getTaskName());
+ get.setProject(getProject());
+ validate();
+
+ // Setup repository list, add default if none specified
+ if (repositories.size() == 0) {
+ log("No Repository Url is specified, assuming: " + DEFAULT_REPOSITORY);
+ Repository repository = new Repository(context);
+
+ try {
+ repository.setURL(new URL(DEFAULT_REPOSITORY));
+ }
+ catch (MalformedURLException e) {
+ throw new org.jboss.util.NestedError(e); // Should never happen
+ }
+
+ repositories.add(repository);
+ }
+
+ // Generate a list of depends from an optional dependency file
+ if (dependencyFile != null) {
+ log.verbose("Reading dependency file: " + dependencyFile);
+
+ try {
+ Collection temp = getDependenciesFromFile(dependencyFile);
+ dependencies.addAll(temp);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ throw new BuildException("Failed to read dependencies from file: " + dependencyFile);
+ }
+ }
+
+ boolean skipVerify = false;
+
+ // If a metadata file was given use it to check if we need update depenencies
+ if (metadataFile != null && metadataFile.exists()) {
+ UpToDate u2d = (UpToDate)getProject().createTask("uptodate");
+ u2d.setTaskName(getTaskName());
+ u2d.setTargetFile(metadataFile);
+
+ File antFile = new File(getProject().getProperty("ant.file"));
+ u2d.setSrcfile(antFile);
+ log.verbose("Checking if " + antFile + " is newer than our metadata");
+ skipVerify = u2d.eval();
+
+ if (skipVerify) {
+ if (dependencyFile != null) {
+ log.verbose("Checking if " + dependencyFile + " is newer than our metadata");
+ u2d.setSrcfile(dependencyFile);
+ skipVerify = u2d.eval();
+ }
+ }
+
+ // now make sure that all of the dependencies still exist
+ if (skipVerify) {
+ Iterator iter=dependencies.iterator();
+ while (iter.hasNext()) {
+ JarDependency dep = (JarDependency)iter.next();
+ File file = new File(dir, dep.getFileNameFragment());
+ if (!file.exists()) {
+ // missing one, force verify
+ log.verbose("Forcing verification; Missing cached dependency: " + file);
+ skipVerify = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!skipVerify) {
+ // Verify depends, downloads to cache as needed
+ int size = dependencies.size();
+ log.info("Verifying "+size+" dependenc"+(size>1?"ies":"y")+"...");
+ grabDependencies(dependencies);
+ }
+ else {
+ log.info("Dependencies are up-to-date (metadata check).");
+ }
+
+ // Generate an Ant FileSet containing all of the depends
+ FileSet dependFileSet = new FileSet();
+ dependFileSet.setDir(dir);
+
+ if (pathID != null) {
+ log("Generate path with ID: " + pathID, Project.MSG_DEBUG);
+
+ Iterator iter=dependencies.iterator();
+ while (iter.hasNext()) {
+ JarDependency dep = (JarDependency)iter.next();
+ dependFileSet.createInclude().setName(dep.getFileNameFragment());
+ }
+
+ Path path = new Path(getProject());
+ path.addFileset(dependFileSet);
+
+ log("Path: " + path, Project.MSG_DEBUG);
+ getProject().getReferences().put(pathID, path);
+ }
+
+ // If we have a metadata file touch it to keep from checking over and over
+ if (metadataFile != null) {
+ metadataFile.getParentFile().mkdirs();
+ Touch touch = (Touch)getProject().createTask("touch");
+ touch.setTaskName(getTaskName());
+ touch.setFile(metadataFile);
+ touch.execute();
+ log.verbose("Touched metadata file: " + metadataFile);
+ }
+ }
+
+ public void grabDependencies(Collection dependencies) throws BuildException
+ {
+ if (offline) {
+ log.warning("Remote repositories offline; Can not verify cached dependencies");
+ }
+
+ Iterator i = dependencies.iterator();
+ Iterator iRepos;
+ Stack synchroStack = new Stack(); //stack of repositories that need to be synchronized
+ File downloadedFile = null;
+
+ int count=0;
+ while (i.hasNext()) {
+
+ JarDependency dependency = (JarDependency) i.next();
+
+ iRepos = repositories.iterator();
+ while (iRepos.hasNext()) {
+ Repository repository = (Repository) iRepos.next();
+
+ try {
+ File destinationFile = new File(dir, dependency.getFileNameFragment());
+ long lastModified = destinationFile.lastModified();
+
+ downloadedFile = repository.getDependency(dependency, dir, get);
+
+ while (!synchroStack.isEmpty()) {
+ Repository synchroRepository = (Repository) synchroStack.pop();
+ synchroRepository.synchronizeFile(downloadedFile, dependency);
+ }
+
+ count++;
+ if (lastModified != downloadedFile.lastModified()) {
+ log(" " + count + ") Downloaded " + dependency + " from: " + repository);
+ }
+ else if (offline) {
+ log(" " + count + ") " + dependency + " exists; may be stale");
+ }
+ else {
+ log(" " + count + ") " + dependency + " is up-to-date");
+ }
+ break;
+ }
+ catch (Exception e) {
+ if (!iRepos.hasNext())
+ throw new BuildException("Could not get <" + dependency.getName() + "> from any repository");
+ else {
+ if (repository.isSynchronize()) {
+ synchroStack.push(repository);
+ }
+ log("Couldn't get <" + dependency.getName() + ">, trying next repository...",Project.MSG_DEBUG);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Utility function to load a Xerces DOM Document with the given filename.
+ *
+ * @param filename the name of the file to load
+ * @return the DOM Document object that is created
+ * @throws org.apache.tools.ant.BuildException
+ */
+ private Document getDocument(File file) throws Exception
+ {
+ DOMParser parser = new DOMParser();
+ parser.parse(file.getAbsolutePath());
+ return parser.getDocument();
+ }
+
+ /**
+ * Loads the dependencies from the file with the given name.
+ *
+ * @param fileName of the file to be loaded
+ */
+ private LinkedList getDependenciesFromFile(File file) throws Exception
+ {
+ LinkedList list = new LinkedList();
+ Document doc = getDocument(file);
+ NodeList dependencies = doc.getElementsByTagName("dependency");
+
+ for (int c = 0; c < dependencies.getLength(); ++c) {
+ Element element = (Element) dependencies.item(c);
+
+ JarDependency dep = new JarDependency();
+ dep.setName(getTextOfChildElement(element, "id", 0));
+ dep.setVersion(getTextOfChildElement(element, "version", 0));
+ dep.setJar(getTextOfChildElement(element, "jar", 0));
+ dep.setGroupName(getTextOfChildElement(element, "group-id", 0));
+
+ list.add(dep);
+ }
+
+ return list;
+ }
+
+ /**
+ * Utility method to grab the text data of the child of the given parent object.
+ */
+ private String getTextOfChildElement(Element parent, String childName, int childNo)
+ {
+ NodeList childList = parent.getElementsByTagName(childName);
+
+ if (childList.getLength() <= childNo)
+ return null;
+
+ Element child = (Element) childList.item(childNo);
+
+ NodeList grandChildren = child.getChildNodes();
+
+ for (int c = 0; c < grandChildren.getLength(); ++c) {
+ Node grandChild = grandChildren.item(c);
+ if (grandChild.getNodeType() == Node.TEXT_NODE)
+ return ((Text) grandChild).getData();
+ }
+
+ return null;
+ }
+
+ /**
+ * Creates a JarDependency based on the <code>jarDependency</code> tag
+ * embedded inside in this task.
+ *
+ * @return the newly created JarDependency
+ */
+ public Object createJarDependency() {
+ JarDependency ret = new JarDependency();
+ dependencies.add(ret);
+ return ret;
+ }
+
+ public Object createRepository() {
+ Repository ret = new Repository(context);
+ repositories.add(ret);
+ return ret;
+ }
+
+ public File getDependencyFile() {
+ return dependencyFile;
+ }
+
+ public void setDependencyFile(File dependencyFile) {
+ this.dependencyFile = dependencyFile;
+ }
+
+ public File getMetadataFile()
+ {
+ return metadataFile;
+ }
+
+ public void setMetadataFile(File file)
+ {
+ this.metadataFile = file;
+ }
+
+ public File getCacheDir() {
+ return dir;
+ }
+
+ public void setCacheDir(File dir) {
+ this.dir = dir;
+ }
+
+ public String getPathId() {
+ return pathID;
+ }
+
+ public void setPathId(String id) {
+ this.pathID = id;
+ }
+
+ public void setOffline(boolean flag)
+ {
+ offline = flag;
+ }
+
+ public boolean isOffline()
+ {
+ return offline;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/FetchDependencyTask.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/JarDependency.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/JarDependency.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/JarDependency.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,170 @@
+/*
+ * Greebo: An Ant task to manage dependency files.
+ *
+ * Copyright (C) 2002 Ozben Evren
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+//
+// Heavily modified for use with JBoss
+//
+
+package oevren.ant.greebo;
+
+import java.io.File;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ *
+ * <p>
+ * <pre>
+ * $Log: JarDependency.java,v $
+ * Revision 1.1.2.1 2003/03/08 18:07:43 user57
+ * o import of heavily modified Greebo dependency manager task
+ * o modified buildmagic/tasks module to use the new fluff
+ *
+ * Revision 1.1 2002/11/22 02:41:47 ozbene
+ * Initial check-in to CVS
+ *
+ * </pre>
+ *
+ * @author Ozben Evren
+ * @version $Id$
+ *
+ */
+public class JarDependency
+{
+ private String name;
+ private String groupName;
+ private String version;
+ private String jar;
+ private String repository;
+
+ public JarDependency() {}
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public String getGroupName() {
+ if (groupName != null)
+ return groupName;
+ if (name != null)
+ return name;
+
+ return "ungrouped";
+ }
+
+ public void setGroupName(final String name) {
+ this.groupName = name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(final String version) {
+ this.version = version;
+ }
+
+ public String getJar() {
+ return jar;
+ }
+
+ public void setJar(final String jar) {
+ this.jar = jar;
+ }
+
+ public String getRepository() {
+ return repository;
+ }
+
+ public void setRepository(final String repository) {
+ this.repository = repository;
+ }
+
+ public String toString() {
+ if (jar != null)
+ return jar;
+ return name + "-" + version + ".jar";
+ }
+
+ public String getFileName()
+ {
+ if (jar == null) {
+ if (name == null || version == null)
+ throw new BuildException("Name and Version, or jar must be specified");
+
+ return name + "-" + version + ".jar";
+ }
+
+ return jar;
+ }
+
+ public String getFileNameFragment()
+ {
+ return new File(new File(new File(getGroupName()), "lib"), getFileName()).toString();
+ }
+
+ /**
+ * Generates and returns the complete repository to fetch this dependency.
+ * If only <code>name</code> and <code>version</code> is defined, then it
+ * will use those and passed <code>repositoryUrl</code> to create the
+ * repository. If <code>jar</code> is defined, then it will be used instead of
+ * <code>name</code> and <code>version</code>. If <code>repository</code> is specified,
+ * then it will override the passed <code>repositoryUrl</code>
+ * @param defaultRepository The URL to the default repository.
+ * @return The full repository for this dependency
+ */
+ public URL getURL(Repository defaultRepository) throws MalformedURLException, BuildException
+ {
+ String fileName = getFileName();
+
+ if (repository != null)
+ return new URL(repository + "/" + fileName);
+
+ if (name == null || version == null)
+ throw new BuildException("Name and Version must be specified, if no repository is specified");
+
+ URL base = defaultRepository.getURL();
+ String suffix = "UNKNOWN";
+
+ switch (defaultRepository.getTypeID())
+ {
+ case Repository.FLAT_ID:
+ suffix = fileName;
+ break;
+
+ case Repository.MAVEN_ID:
+ suffix = name + "/jars/" + fileName;
+ break;
+
+ case Repository.JBOSS_ID:
+ suffix = getGroupName() + "/lib/" + fileName;
+ break;
+ }
+
+ return new URL(base, suffix);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/JarDependency.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/Repository.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/Repository.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/Repository.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,182 @@
+/*
+ * Greebo: An Ant task to manage dependency files.
+ *
+ * Copyright (C) 2002 Ozben Evren
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+//
+// Heavily modified for use with JBoss
+//
+
+package oevren.ant.greebo;
+
+import org.apache.tools.ant.taskdefs.Get;
+import org.apache.tools.ant.BuildException;
+
+import java.io.File;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import oevren.ant.greebo.FetchDependencyTask.Context;
+import org.jboss.tools.buildmagic.task.util.TaskLogger;
+
+/**
+ *
+ * <p>
+ * <pre>
+ * $Log: Repository.java,v $
+ * Revision 1.1.2.1 2003/03/08 18:07:43 user57
+ * o import of heavily modified Greebo dependency manager task
+ * o modified buildmagic/tasks module to use the new fluff
+ *
+ * Revision 1.1 2002/11/22 02:41:47 ozbene
+ * Initial check-in to CVS
+ *
+ * </pre>
+ *
+ * @author Ozben Evren
+ * @version $Id$
+ *
+ */
+public class Repository
+{
+ private URL url;
+ private String type;
+ private boolean synchronize;
+
+ public static final String FLAT = "flat";
+ public static final int FLAT_ID = 0;
+
+ public static final String MAVEN = "maven";
+ public static final int MAVEN_ID = 1;
+
+ public static final String JBOSS = "jboss";
+ public static final int JBOSS_ID = 2;
+
+ private Context context;
+ private TaskLogger log;
+
+ public Repository(Context context)
+ {
+ this.context = context;
+ this.log = context.getLogger();
+
+ type = JBOSS;
+ synchronize = false;
+ }
+
+ public String toString()
+ {
+ return getURL().toString();
+ }
+
+ public URL getURL() {
+ return url;
+ }
+
+ public void setURL(final URL url) throws MalformedURLException
+ {
+ if (!url.toString().endsWith("/")) {
+ this.url = new URL(url.toString() + "/");
+ }
+ else {
+ this.url = url;
+ }
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public int getTypeID()
+ {
+ String temp = type.toLowerCase();
+ if (temp.equals(FLAT))
+ return FLAT_ID;
+
+ if (temp.equals(MAVEN))
+ return MAVEN_ID;
+
+ if (temp.equals(JBOSS))
+ return JBOSS_ID;
+
+ throw new BuildException("Invalid type: " + type);
+ }
+
+ public void setType(final String type) {
+ this.type = type;
+ }
+
+ public boolean isSynchronize() {
+ return synchronize;
+ }
+
+ public void setSynchronize(final boolean synchronize) {
+ this.synchronize = synchronize;
+ }
+
+ public void synchronizeFile(File source, JarDependency dependency)
+ throws Exception
+ {
+ if (url.getProtocol().equals("file")) {
+ URL url = dependency.getURL(this);
+ log.verbose(("Synchronizing:" + source + "->" + url));
+
+ File target = new File(new File(url.getHost()), url.getFile());
+
+ try {
+ org.jboss.util.file.Files.copy(source, target);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ throw new BuildException("Could not synchronize download: " + source + " in-repository: " + target);
+ }
+ }
+
+ throw new BuildException("Can only synchronize local file repositories");
+ }
+
+ public File getDependency(JarDependency dependency, File dir, Get get)
+ throws Exception
+ {
+ URL url = dependency.getURL(this);
+ File file = new File(dir, dependency.getFileNameFragment());
+
+ // Try to make the dest directory
+ file.getParentFile().mkdirs();
+
+ // Special handlig for remote repositories when offline
+ if (context.isOffline() && !url.getProtocol().equals("file")) {
+ // First check if we have a local file
+ if (!file.exists()) {
+ throw new BuildException("Remote repositories offline; Missing dependency: " + dependency);
+ }
+ }
+ else {
+ log.verbose("Getting " + url + "->" + file);
+ get.setUseTimestamp(true);
+ // get.setVerbose(true);
+ get.setSrc(url);
+ get.setDest(file);
+ get.execute();
+ }
+
+ return file;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/oevren/ant/greebo/Repository.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Ant.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Ant.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Ant.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,302 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999 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", "Ant", 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 at 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
+ * <http://www.apache.org/>.
+ */
+
+package org.jboss.tools.buildmagic.task;
+
+import org.apache.tools.ant.*;
+import java.io.*;
+import java.util.*;
+
+import org.apache.tools.ant.taskdefs.Property;
+
+/**
+ * Call Ant in a sub-project
+ *
+ * <pre>
+ * <target name="foo" depends="init">
+ * <ant antfile="build.xml" target="bar" >
+ * <property name="property1" value="aaaaa" />
+ * <property name="foo" value="baz" />
+ * </ant>
+ * </target>
+ *
+ * <target name="bar" depends="init">
+ * <echo message="prop is ${property1} ${foo}" />
+ * </target>
+ * </pre>
+ *
+ *
+ * @author costin at dnt.ro
+ */
+public class Ant
+ extends org.apache.tools.ant.taskdefs.Ant
+{
+ protected File dir = null;
+ protected String antFile = null;
+ protected String target = null;
+ protected String output = null;
+ protected Vector properties=new Vector();
+ protected boolean inheritAll = true;
+
+ protected Project p1;
+
+ public void init() {
+ p1 = new Project();
+ p1.setJavaVersionProperty();
+ p1.addTaskDefinition("property",
+ (Class)project.getTaskDefinitions().get("property"));
+ }
+
+ protected void reinit() {
+ init();
+ for (int i=0; i<properties.size(); i++) {
+ Property p = (Property) properties.elementAt(i);
+ Property newP = (Property) p1.createTask("property");
+ newP.setName(p.getName());
+ if (p.getValue() != null) {
+ newP.setValue(p.getValue());
+ }
+ if (p.getFile() != null) {
+ newP.setFile(p.getFile());
+ }
+ if (p.getResource() != null) {
+ newP.setResource(p.getResource());
+ }
+ properties.setElementAt(newP, i);
+ }
+ }
+
+ protected void initializeProject() {
+ Vector listeners = project.getBuildListeners();
+ for (int i = 0; i < listeners.size(); i++) {
+ p1.addBuildListener((BuildListener)listeners.elementAt(i));
+ }
+
+ if (output != null) {
+ try {
+ PrintStream out = new PrintStream(new FileOutputStream(output));
+ DefaultLogger logger = new DefaultLogger();
+ logger.setMessageOutputLevel(Project.MSG_INFO);
+ logger.setOutputPrintStream(out);
+ logger.setErrorPrintStream(out);
+ p1.addBuildListener(logger);
+ }
+ catch( IOException ex ) {
+ log( "Ant: Can't set output to " + output );
+ }
+ }
+
+ Hashtable taskdefs = project.getTaskDefinitions();
+ Enumeration et = taskdefs.keys();
+ while (et.hasMoreElements()) {
+ String taskName = (String) et.nextElement();
+ Class taskClass = (Class) taskdefs.get(taskName);
+ p1.addTaskDefinition(taskName, taskClass);
+ }
+
+ Hashtable typedefs = project.getDataTypeDefinitions();
+ Enumeration e = typedefs.keys();
+ while (e.hasMoreElements()) {
+ String typeName = (String) e.nextElement();
+ Class typeClass = (Class) typedefs.get(typeName);
+ p1.addDataTypeDefinition(typeName, typeClass);
+ }
+
+ // set user-define properties
+ Hashtable prop1;
+ if (inheritAll) {
+ prop1 = project.getProperties();
+ }
+ else {
+ prop1 = project.getUserProperties();
+ p1.setSystemProperties();
+ }
+
+ e = prop1.keys();
+ while (e.hasMoreElements()) {
+ String arg = (String) e.nextElement();
+ String value = (String) prop1.get(arg);
+
+ if (inheritAll) {
+ p1.setProperty(arg, value);
+ }
+ else {
+ p1.setUserProperty(arg, value);
+ }
+ }
+ }
+
+ public void setInheritAll(boolean inherit) {
+ inheritAll = inherit;
+ }
+
+ public File getBuildFile() throws BuildException {
+ String filename = antFile;
+ if (filename == null) {
+ filename = "build.xml";
+ }
+ else {
+ filename = ResolveProperties.subst(filename, project);
+ }
+
+ File file = new File("build.xml");
+ if (!file.isAbsolute()) {
+ filename = (new File(dir, filename)).getAbsolutePath();
+ file = new File(filename);
+ if( ! file.isFile() ) {
+ throw new BuildException("Build file " + file + " not found.");
+ }
+ }
+
+ return file;
+ }
+
+ /**
+ * Do the execution.
+ */
+ public void execute() throws BuildException {
+ try {
+ if (p1 == null) {
+ reinit();
+ }
+
+ if(dir == null)
+ dir = project.getBaseDir();
+
+ initializeProject();
+
+ p1.setBaseDir(dir);
+ p1.setUserProperty("basedir" , dir.getAbsolutePath());
+
+ // Override with local-defined properties
+ Enumeration e = properties.elements();
+ while (e.hasMoreElements()) {
+ Property p=(Property) e.nextElement();
+ p.execute();
+ }
+
+ if (antFile == null) {
+ antFile = "build.xml";
+ }
+ else {
+ antFile = ResolveProperties.subst(antFile, project);
+ }
+
+ File file = new File(antFile);
+ if (!file.isAbsolute()) {
+ antFile = (new File(dir, antFile)).getAbsolutePath();
+ file = (new File(antFile)) ;
+ if( ! file.isFile() ) {
+ throw new BuildException("Build file " + file + " not found.");
+ }
+ }
+
+ p1.setUserProperty( "ant.file" , antFile );
+ ProjectHelper.configureProject(p1, new File(antFile));
+
+ if (target == null) {
+ target = p1.getDefaultTarget();
+ }
+
+ // Are we trying to call the target in which we are defined?
+ if (p1.getBaseDir().equals(project.getBaseDir()) &&
+ p1.getProperty("ant.file").equals(project.getProperty("ant.file")) &&
+ getOwningTarget() != null &&
+ target.equals(this.getOwningTarget().getName())) {
+
+ throw new BuildException("ant task calling its own parent target");
+ }
+
+ p1.executeTarget(target);
+ } finally {
+ // help the gc
+ p1 = null;
+ }
+ }
+
+ public Project getTargetProject() {
+ return p1;
+ }
+
+ public void addBuildListener(BuildListener l) {
+ p1.addBuildListener(l);
+ }
+
+ public void setDir(File d) {
+ this.dir = d;
+ }
+
+ public void setAntfile(String s) {
+ this.antFile = s;
+ }
+
+ public void setTarget(String s) {
+ this.target = s;
+ }
+
+ public void setOutput(String s) {
+ this.output = s;
+ }
+
+ public Property createProperty() {
+ if (p1 == null) {
+ reinit();
+ }
+
+ Property p=(Property)p1.createTask("property");
+ p.setUserProperty(true);
+ properties.addElement( p );
+ return p;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Ant.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AppendPath.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AppendPath.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AppendPath.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,71 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task;
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Path.PathElement;
+
+/**
+ * Append a path to another path
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class AppendPath
+ extends Task
+{
+ protected List paths = new LinkedList();
+ protected String refid;
+
+ public void setRefid(String id) {
+ this.refid = id;
+ }
+
+ /**
+ * Create a nested path.
+ */
+ public Path createPath() {
+ Path path = new Path(project);
+ paths.add(path);
+ return path;
+ }
+
+ /**
+ * Create a nested path element.
+ */
+ public PathElement createPathElement() {
+ Path path = new Path(project);
+ paths.add(path);
+ return path.createPathElement();
+ }
+
+ /**
+ * Execute the task.
+ */
+ public void execute() throws BuildException {
+ if (refid == null)
+ throw new MissingAttributeException("refid", this);
+
+ Path target = (Path)project.getReferences().get(refid);
+ Iterator iter = paths.iterator();
+ while (iter.hasNext()) {
+ Path path = (Path)iter.next();
+ target.append(path);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/AppendPath.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ContainerTask.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ContainerTask.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ContainerTask.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,110 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task;
+
+import java.util.*;
+
+import org.apache.tools.ant.*;
+
+import org.jboss.tools.buildmagic.task.util.*;
+
+/**
+ * Base class for tasks that can contain other tasks or scripts.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class ContainerTask
+ extends Task
+ implements Cloneable
+{
+ /** Instance logger. */
+ protected final TaskLogger log = new TaskLogger(this);
+
+ /** The list of tasks to execute. */
+ protected List tasks = new LinkedList();
+
+ /**
+ * Set the target to execute when expr is true.
+ *
+ * @param target The target to execute.
+ */
+ public void setTarget(final String target) {
+ CallTarget call = createCall();
+ call.setTarget(target);
+ tasks.add(call);
+ }
+
+ /**
+ * Set the script for this target.
+ *
+ * @param script The script for this target.
+ */
+ public void setScript(final String script) {
+ Script task = createScript();
+ task.addText(script);
+ tasks.add(task);
+ }
+
+ /**
+ * Create a nested <tt>call</tt> target.
+ */
+ public CallTarget createCall() {
+ CallTarget task = (CallTarget)project.createTask("call");
+ tasks.add(task);
+ return task;
+ }
+
+ /**
+ * Create a nested <tt>script</tt> target.
+ */
+ public Script createScript() {
+ Script task = (Script)project.createTask("script");
+ tasks.add(task);
+ return task;
+ }
+
+ /**
+ * Validate the attributes for this task.
+ *
+ * @throws BuildException Attributes are not valid.
+ */
+ protected void validate() throws BuildException {
+ if (tasks.size() == 0)
+ throw new MissingElementException("call' or 'task", this);
+ }
+
+ /**
+ * Execute all of the sub-tasks.
+ */
+ protected void executeTasks() throws BuildException {
+ Iterator iter = tasks.iterator();
+
+ while (iter.hasNext()) {
+ Task task = (Task)iter.next();
+ log.debug("executing sub-task: " + task);
+ task.execute();
+ }
+ }
+
+ /**
+ * Return a cloned copy of this object.
+ *
+ * @return Cloned object.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ContainerTask.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/FindRoot.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/FindRoot.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/FindRoot.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,107 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task;
+
+import java.io.File;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+
+import org.jboss.tools.buildmagic.task.util.TaskLogger;
+
+/**
+ * Find a root directory by searching upwards for a suffix.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class FindRoot
+ extends Task
+{
+ protected TaskLogger log;
+ protected String basedir = ".";
+ protected String suffix;
+ protected String property;
+
+ public FindRoot() {
+ this.log = new TaskLogger(this);
+ }
+
+ public FindRoot(TaskLogger log) {
+ this.log = log;
+ }
+
+ public void setSuffix(String suffix) {
+ this.suffix = suffix;
+ }
+
+ public void setBasedir(String basedir) {
+ this.basedir = basedir;
+ }
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+ public File getRoot() throws BuildException {
+ if (suffix == null)
+ throw new MissingAttributeException("suffix", this);
+ if (property == null)
+ throw new MissingAttributeException("property", this);
+
+ File root = findRoot(basedir, suffix);
+ log.verbose("using root: " + root);
+
+ return root;
+ }
+
+ /**
+ * Execute the task.
+ */
+ public void execute() throws BuildException {
+ File root = getRoot();
+ project.getProperties().put(property, root.getAbsolutePath());
+ }
+
+ private File getParentFile(File file) {
+ String filename = file.getAbsolutePath();
+ file = new File(filename);
+ filename = file.getParent();
+ return (filename == null) ? null : new File(filename);
+ }
+
+ private File findRoot(String start, String suffix)
+ throws BuildException
+ {
+ log.verbose("Searching for " + suffix + " ...");
+
+ File parent = new File(new File(start).getAbsolutePath());
+ File file = new File(parent, suffix);
+
+ // check if the target file exists in the current directory
+ while (!file.exists()) {
+ // change to parent directory
+ parent = getParentFile(parent);
+
+ // if parent is null, then we are at the root of the fs,
+ // complain that we can't find the build file.
+ if (parent == null) {
+ throw new BuildException("Could not locate a " + suffix);
+ }
+
+ // refresh our file handle
+ file = new File(parent, suffix);
+ }
+
+ return parent;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/FindRoot.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Loop.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Loop.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Loop.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,59 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task;
+
+import org.apache.tools.ant.*;
+
+/**
+ * An looping task.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class Loop
+ extends ContainerTask
+{
+ /** The loop count. */
+ protected int count = -1;
+
+ /**
+ * Set the loop count.
+ *
+ * @param count The loop count.
+ */
+ public void setCount(final int count) {
+ this.count = count;
+ }
+
+ /**
+ * Validate the attributes for this task.
+ *
+ * @throws BuildException Attributes are not valid.
+ */
+ protected void validate() throws BuildException {
+ super.validate();
+
+ if (count <= 0)
+ throw new IllegalAttributeException("count", "must be > 0", this);
+ }
+
+ /**
+ * Execute the configured target the configured number of times.
+ */
+ public void execute() throws BuildException {
+ validate();
+
+ log.verbose("looping '" + target + "' for count: " + count);
+ for (int i=0; i<count; i++) {
+ log.debug("i: " + i);
+ executeTasks();
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Loop.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ProjectHelp.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ProjectHelp.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ProjectHelp.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,139 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task;
+
+import java.util.Map;
+import java.util.Iterator;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Collections;
+
+import java.io.PrintWriter;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Show the targets.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ProjectHelp
+ extends Task
+{
+ protected PrintWriter out = new PrintWriter(System.out);
+ protected List headers = new LinkedList();
+ protected List footers = new LinkedList();
+
+ public Heading createHeader() {
+ Heading header = new Heading();
+ headers.add(header);
+ return header;
+ }
+
+ public Heading createFooter() {
+ Heading footer = new Heading();
+ footers.add(footer);
+ return footer;
+ }
+
+ /**
+ * Execute the task.
+ */
+ public void execute() throws BuildException {
+ Map targets = project.getTargets();
+ List names = new LinkedList();
+ int maxlen = 0;
+ Iterator iter = targets.keySet().iterator();
+
+ while (iter.hasNext()) {
+ String name = (String)iter.next();
+ Target target = (Target)targets.get(name);
+ String desc = target.getDescription();
+
+ if (desc != null) {
+ int len = name.length();
+ if (len > maxlen) maxlen = len;
+ names.add(name);
+ }
+ }
+
+ printHeading(headers);
+ printTargets(out, names, maxlen);
+ printHeading(footers);
+
+ out.flush();
+ }
+
+ protected void printHeading(List list) {
+ Iterator iter = list.iterator();
+ while (iter.hasNext()) {
+ Heading heading = (Heading)iter.next();
+ heading.setProject(project);
+ heading.print(out);
+ }
+ }
+
+ protected String getDescription(String name) {
+ Target target = (Target)project.getTargets().get(name);
+ return target.getDescription();
+ }
+
+ protected void printTargets(PrintWriter out,
+ List names,
+ int maxlen)
+ {
+ String spaces = " ";
+ while (spaces.length() < maxlen) {
+ spaces += spaces;
+ }
+
+ Collections.sort(names);
+
+ for (int i=0; i<names.size(); i++) {
+ String name = (String)names.get(i);
+ String pad = spaces.substring(0, maxlen - name.length() + 4);
+
+ out.print(" ");
+ out.print(name);
+ out.print(pad);
+ out.print(getDescription(name));
+ out.println();
+ }
+ }
+
+ protected class Heading
+ {
+ protected StringBuffer buff = new StringBuffer();
+ protected Project project;
+
+ public void setProject(Project project) {
+ this.project = project;
+ }
+
+ public void setMessage(final String text) {
+ addText(text);
+ }
+
+ public void addText(final String text) {
+ buff.append(text);
+ }
+
+ public void print(PrintWriter out) {
+ String msg = buff.toString();
+ msg = ResolveProperties.subst(msg, project.getProperties(), false);
+ out.println(msg);
+ }
+ }
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ProjectHelp.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Property.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Property.java 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Property.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -43,6 +43,11 @@
protected boolean force;
protected boolean system;
+ //
+ // HACK
+ //
+ protected FindRoot findRoot;
+
public void setType(final String type) {
this.type = type;
}
@@ -73,6 +78,14 @@
}
}
+ //
+ // HACK
+ //
+ public FindRoot createFindRoot() {
+ findRoot = new FindRoot(log);
+ return findRoot;
+ }
+
/**
* Add some raw text to the property.
*
@@ -109,6 +122,15 @@
}
public void execute() throws BuildException {
+ //
+ // HACK
+ //
+ if (findRoot != null) {
+ findRoot.setProperty(getName());
+ File root = findRoot.getRoot();
+ value = root.getAbsolutePath();
+ }
+
if (resolve) {
log.debug("resolving property: " + name + "(force: " + force + ")");
Hashtable props = project.getProperties();
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Script.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Script.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Script.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,78 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.tools.ant.*;
+
+import com.ibm.bsf.*;
+
+/**
+ * Execute a script.
+ *
+ * @version $Id$
+ * @author Jason Dillon <A href="mailto:jason at planet57.com"><jason at planet57.com></A>
+ */
+public class Script
+ extends ScriptedTask
+{
+ /** The script text to execute. */
+ protected StringBuffer script = new StringBuffer();
+
+ /**
+ * Load the script from an external file.
+ *
+ * @param file The file to load the source from.
+ */
+ public void setSrc(final File file) throws BuildException {
+ log.verbose("reading script file: " + file);
+
+ if (!file.exists())
+ throw new BuildException("file not found: " + file);
+
+ int count = (int)file.length();
+ byte data[] = new byte[count];
+
+ try {
+ InputStream in = new BufferedInputStream(new FileInputStream(file));
+ in.read(data);
+ in.close();
+ }
+ catch (IOException e) {
+ throw new BuildException(e);
+ }
+
+ script.append(new String(data));
+ }
+
+ /**
+ * Add some lines to the script.
+ *
+ * @param test A line of text to add to the script.
+ */
+ public void addText(final String text) {
+ script.append(text);
+ }
+
+ /**
+ * Execute the script.
+ *
+ * @param engine The scripting engine.
+ */
+ protected void execute(final BSFEngine engine)
+ throws BSFException, BuildException
+ {
+ // execute the script
+ engine.exec("<SCRIPT>", 0, 0, script.toString());
+ }
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Script.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedContainerTask.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedContainerTask.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedContainerTask.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,97 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task;
+
+import java.util.*;
+
+import org.apache.tools.ant.*;
+
+/**
+ * A scripted container task.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class ScriptedContainerTask
+ extends ScriptedTask
+{
+ /** The list of tasks to execute. */
+ protected List tasks = new LinkedList();
+
+ /**
+ * Set the target to execute when expr is true.
+ *
+ * @param target The target to execute.
+ */
+ public void setTarget(final String target) {
+ CallTarget call = createCall();
+ call.setTarget(target);
+ tasks.add(call);
+ }
+
+ /**
+ * Set the script for this target.
+ *
+ * @param script The script for this target.
+ */
+ public void setScript(final String script) {
+ Script task = createScript();
+ task.addText(script);
+ tasks.add(task);
+ }
+
+ /**
+ * Create a nested <tt>call</tt> target.
+ */
+ public CallTarget createCall() {
+ log.verbose("creating nested <call> task");
+ CallTarget task = (CallTarget)project.createTask("call");
+ tasks.add(task);
+ log.verbose("tasks: " + tasks);
+ return task;
+ }
+
+ /**
+ * Create a nested <tt>script</tt> target.
+ */
+ public Script createScript() {
+ log.verbose("creating nested <script> task");
+ Script task = (Script)project.createTask("script");
+ tasks.add(task);
+ log.verbose("tasks: " + tasks);
+ return task;
+ }
+
+ /**
+ * Validate the attributes for this task.
+ *
+ * @throws BuildException Attributes are not valid.
+ */
+ protected void validate() throws BuildException {
+ super.validate();
+
+ if (tasks.size() == 0)
+ throw new MissingElementException("call' or 'script", this);
+ }
+
+ /**
+ * Execute all of the sub-tasks.
+ */
+ protected void executeTasks() throws BuildException {
+ Iterator iter = tasks.iterator();
+
+ while (iter.hasNext()) {
+ Task task = (Task)iter.next();
+ log.debug("executing sub-task: " + task);
+ task.execute();
+ }
+ }
+}
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedContainerTask.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedTask.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedTask.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedTask.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,201 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task;
+
+import java.util.*;
+
+import org.apache.tools.ant.*;
+
+import com.ibm.bsf.*;
+
+import org.jboss.tools.buildmagic.task.util.*;
+
+/**
+ * Base class for tasks which use scripting.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class ScriptedTask
+ extends Task
+ implements Cloneable
+{
+ /** Instance logger. */
+ protected final TaskLogger log = new TaskLogger(this);
+
+ /** Map of bean name -> bean value */
+ protected final Map beans = new HashMap();
+
+ /** The BSF manager object. */
+ protected BSFManager manager;
+
+ /** The name of the scripting language to use. */
+ protected String language = "jpython";
+
+ /**
+ * Set the scripting language that will be used.
+ */
+ public void setLanguage(final String language) {
+ this.language = language;
+ }
+
+ /**
+ * Validate the attributes for this task.
+ *
+ * @throws BuildException Attributes are not valid.
+ */
+ protected void validate() throws BuildException {
+ if (language == null)
+ throw new MissingAttributeException("language", this);
+ }
+
+ /**
+ * Get a reference to the BSF manager.
+ *
+ * @throws BSFException Failed to create BSF manager.
+ */
+ protected BSFManager getManager() throws BSFException {
+ if (manager == null) {
+ manager = new BSFManager();
+ log.debug("created bsf manager: " + manager);
+ }
+
+ return manager;
+ }
+
+ /**
+ * Create a scripting language engine for the configured language.
+ *
+ * @return Scripting language engine.
+ *
+ * @throws BSFException Failed to create engine.
+ */
+ protected BSFEngine createEngine() throws BSFException {
+ BSFManager manager = getManager();
+
+ // update the namespace
+ addBeans(project.getProperties());
+ addBeans(project.getUserProperties());
+ addBeans(project.getTargets());
+ addBeans(project.getReferences());
+
+ beans.put("project", project);
+
+ Iterator iter = beans.keySet().iterator();
+ while (iter.hasNext()) {
+ String key = (String)iter.next();
+ Object value = beans.get(key);
+
+ manager.declareBean(key, value, value.getClass());
+ log.debug("declared bean: " + key + " = " + value);
+ }
+
+ BSFEngine engine = manager.loadScriptingEngine(language);
+ log.debug("created engine: " + engine);
+
+ return engine;
+ }
+
+ /**
+ * Return the source name of the script.
+ *
+ * @return Source name of the script.
+ */
+ protected String getSourceName() {
+ return "<SCRIPT>";
+ }
+
+ /**
+ * Check if a given string is a valid identifier.
+ *
+ * @param valie String to check.
+ * @return True if the string is a valid identifier.
+ */
+ protected boolean isValidIdentifier(String value) {
+ boolean valid = value.length()>0 &&
+ Character.isJavaIdentifierStart(value.charAt(0));
+
+ for (int i=1; valid && i<value.length(); i++) {
+ valid = Character.isJavaIdentifierPart(value.charAt(i));
+ }
+
+ return valid;
+ }
+
+ /**
+ * Add each element in the given map to the beans map if the key
+ * is a valid identifier.
+ *
+ * @param map Map to add elements from.
+ */
+ protected void addBeans(final Map map) {
+ Iterator iter = map.keySet().iterator();
+
+ while (iter.hasNext()) {
+ String key = (String)iter.next();
+ if (isValidIdentifier(key)) {
+ beans.put(key, map.get(key));
+ }
+ else {
+ log.debug("not a valid identifier: " + key);
+ }
+ }
+ }
+
+ /**
+ * Execute the scripted task.
+ *
+ * <p>Invokes {@link #execute(BSFEngine)} and handles any
+ * <tt>BSFException</tt>s that are thrown.
+ */
+ public void execute() throws BuildException {
+ validate();
+
+ try {
+ BSFEngine engine = createEngine();
+ execute(engine);
+ }
+ catch (BSFException e) {
+ Throwable nested = e.getTargetException();
+
+ if (nested != null) {
+ if (nested instanceof BuildException) {
+ throw (BuildException)nested;
+ }
+ else {
+ nested = e;
+ }
+ }
+ throw new BuildException(nested);
+ }
+ }
+
+ /**
+ * Called to actually execute the scripted task.
+ *
+ * @param engine The script specific engine.
+ */
+ protected abstract void execute(BSFEngine engine)
+ throws BSFException, BuildException;
+
+ /**
+ * Return a cloned copy of this object.
+ *
+ * @return Cloned object.
+ */
+ public Object clone() {
+ try {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/ScriptedTask.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Set.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Set.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Set.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,158 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task;
+
+import java.io.File;
+
+import java.util.Map;
+import java.util.Iterator;
+import java.util.List;
+import java.util.LinkedList;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.BuildException;
+
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.FileSet;
+
+/**
+ * Sets variables from nested elements.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class Set
+ extends VariableTask
+{
+ /** The list of nested elements. */
+ protected List elements = new LinkedList();
+
+ /**
+ * Default to references.
+ */
+ public Set() {
+ type = REFERENCE;
+ }
+
+ /**
+ * Execute the task, set the variable in name.
+ */
+ public void execute() throws BuildException {
+ if (name == null)
+ throw new MissingAttributeException("name", this);
+
+ // if the type is a ref, then it can be any object
+ if (type == REFERENCE) {
+ Object value = getObject();
+ project.getReferences().put(name, value);
+ log.verbose("set reference " + name + "=" + value);
+ }
+ else {
+ // else it must be converted to a string
+ String value = getString();
+ String ptype = null;
+ Map map = null;
+
+ switch (type) {
+ case PROPERTY:
+ map = project.getProperties();
+ ptype = "project";
+ break;
+
+ case USER_PROPERTY:
+ map = project.getUserProperties();
+ ptype = "user";
+ break;
+
+ case SYSTEM_PROPERTY:
+ map = System.getProperties();
+ ptype = "system";
+ break;
+ }
+
+ map.put(name, value);
+ log.verbose("set " + ptype + " property " + name + "=" + value);
+ }
+ }
+
+ /**
+ * Return a single object that represents the elements.
+ */
+ protected Object getObject() {
+ Path path = new Path(project);
+
+ Iterator iter = elements.iterator();
+ while (iter.hasNext()) {
+ Object obj = iter.next();
+ if (obj instanceof Path) {
+ path.append((Path)obj);
+ }
+ else {
+ path.append(new RPath(project, obj.toString()));
+ }
+ }
+
+ return path;
+ }
+
+ /**
+ * Return a string that represents the elements.
+ */
+ protected String getString() {
+ return getObject().toString();
+ }
+
+ /**
+ * Create a nested path element.
+ */
+ public Path createPath() {
+ Path path = new Path(project);
+ elements.add(path);
+ return path;
+ }
+
+ /**
+ * A Path extentsion that will automatically resolve its contents
+ * for property values.
+ *
+ * <p>NOTE: This is currently disabled due to its parrent prepending
+ * the project root to things it thinks are relative.
+ * Unfortunatly the bits required to fix this are in statics
+ * and/or hidden in the Project object such that it is
+ * impossible to fix this with out a large amount of pain.
+ *
+ * I can't wait for Ant2.
+ */
+ protected class RPath
+ extends Path
+ {
+ protected Project project;
+
+ public RPath(final Project project) {
+ super(project);
+ this.project = project;
+ }
+
+ public RPath(final Project project, final String path) {
+ super(project, path);
+ }
+
+ public String[] list() {
+ String[] values = super.list();
+ Map props = project.getProperties();
+
+ for (int i=0; i<values.length; i++) {
+ values[i] = ResolveProperties.subst(values[i], props, false);
+ }
+
+ return values;
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Set.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Unset.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Unset.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Unset.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,59 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * A task that will unset variables.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class Unset
+ extends VariableTask
+{
+ /**
+ * Default to references.
+ */
+ public Unset() {
+ type = REFERENCE;
+ }
+
+ /**
+ * Execute the task, unset the variable in name.
+ */
+ public void execute() throws BuildException {
+ if (name == null)
+ throw new MissingAttributeException("name", this);
+
+ switch (type) {
+ case PROPERTY:
+ project.getProperties().remove(name);
+ log.verbose("unset property: " + name);
+ break;
+
+ case USER_PROPERTY:
+ project.getUserProperties().remove(name);
+ log.verbose("unset user property: " + name);
+ break;
+
+ case SYSTEM_PROPERTY:
+ System.getProperties().remove(name);
+ log.verbose("unset system property: " + name);
+ break;
+
+ case REFERENCE:
+ project.getReferences().remove(name);
+ log.verbose("unset reference: " + name);
+ break;
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/Unset.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/VariableTask.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/VariableTask.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/VariableTask.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,75 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task;
+
+import org.apache.tools.ant.Task;
+
+import org.jboss.tools.buildmagic.task.util.TaskLogger;
+
+/**
+ * Base class for other variable related tasks.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class VariableTask
+ extends Task
+{
+ /** Property variable. */
+ public static final int PROPERTY = 0;
+
+ /** User property variable. */
+ public static final int USER_PROPERTY = 1;
+
+ /** System property variable. */
+ public static final int SYSTEM_PROPERTY = 2;
+
+ /** Reference variable. */
+ public static final int REFERENCE = 3;
+
+ /** Instance logger. */
+ protected final TaskLogger log = new TaskLogger(this);
+
+ /** The name of the variable. */
+ protected String name;
+
+ /** The type of variable. */
+ protected int type;
+
+ /**
+ * Set the name of the variable.
+ */
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Set the type of the variable.
+ */
+ public void setType(String type) {
+ type = type.toLowerCase();
+
+ if (type.equals("prop") || type.equals("property")) {
+ this.type = PROPERTY;
+ }
+ else if (type.equals("userprop") || type.equals("userproperty")) {
+ this.type = USER_PROPERTY;
+ }
+ else if (type.equals("sysprop") || type.equals("systemproperty")) {
+ this.type = SYSTEM_PROPERTY;
+ }
+ else if (type.equals("ref") || type.equals("reference")) {
+ this.type = REFERENCE;
+ }
+ else {
+ throw new IllegalAttributeException("type", this);
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/VariableTask.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/Library.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/Library.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/Library.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,220 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task.config;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.PatternSet;
+
+import org.jboss.tools.buildmagic.task.MissingAttributeException;
+import org.jboss.tools.buildmagic.task.util.TaskLogger;
+
+import org.jboss.util.DirectoryBuilder;
+
+/**
+ * A helper task to setup library the properties and path
+ * elements for using a thirdparty library.
+ *
+ * <p>This will setup the following properties:
+ * <ul>
+ * <li><tt><em>vendor</em>.<em>name</em>.root</tt>
+ * <li><tt><em>vendor</em>.<em>name</em>.lib</tt>
+ * </ul>
+ *
+ * <p>As well as the following path, based on set attributes
+ * and nested elements:
+ * <ul>
+ * <li><tt><em>vendor</em>.<em>name</em>.classpath</tt>
+ *
+ * <p>Usage:
+ * <xmp>
+ *
+ * <library vendor="sun" name="jmx" root="${project.thirdparty}">
+ * <classpath>
+ * <include name="*.jar"/>
+ * </classpath>
+ * </library>
+ *
+ * <library vendor="sun" name="jaxp" root="${project.thirdparty}">
+ * <include name="*.jar"/>
+ * </library>
+ *
+ * <library vendor="sun" name="jaax" root="${project.thirdparty}" includes="*.jar"/>
+ *
+ * </xmp>
+ *
+ * <p>If no includes/excludes or classpath elements are specified,
+ * then a default includes of "*" is used.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class Library
+ extends Task
+{
+ /** Instance logger. */
+ protected final TaskLogger log = new TaskLogger(this);
+
+ protected String vendor;
+ protected String name;
+ protected File root;
+ protected FileSet classpathSet;
+
+ protected Path classpath;
+
+ public void setVendor(final String vendor)
+ {
+ this.vendor = vendor;
+ }
+
+ public void setName(final String name)
+ {
+ this.name = name;
+ }
+
+ public void setRoot(final File root)
+ {
+ this.root = root;
+ }
+
+ public void setIncludes(final String include)
+ {
+ // add to classpath
+ FileSet fs = createClasspath();
+ PatternSet.NameEntry entry = fs.createInclude();
+ entry.setName(include);
+ }
+
+ public void setExcludes(final String exclude)
+ {
+ // add to classpath
+ FileSet fs = createClasspath();
+ PatternSet.NameEntry entry = fs.createExclude();
+ entry.setName(exclude);
+ }
+
+ public FileSet createClasspath()
+ {
+ if (classpathSet == null) {
+ classpathSet = new FileSet();
+ }
+
+ return classpathSet;
+ }
+
+ /** Helpers */
+ public PatternSet.NameEntry createInclude()
+ {
+ return createClasspath().createInclude();
+ }
+
+ /** Helpers */
+ public PatternSet.NameEntry createExclude()
+ {
+ return createClasspath().createExclude();
+ }
+
+ /**
+ * Validate the attributes for this task.
+ *
+ * @throws BuildException Attributes are not valid.
+ */
+ protected void validate() throws BuildException
+ {
+ if (vendor == null)
+ throw new MissingAttributeException("vendor", this);
+ if (name == null)
+ throw new MissingAttributeException("name", this);
+ if (root == null)
+ throw new MissingAttributeException("root", this);
+ }
+
+ protected File getVendorDir()
+ {
+ DirectoryBuilder builder = new DirectoryBuilder(root);
+
+ // make vendor dir
+ builder.cd(vendor).cd(name);
+ File dir = builder.get();
+
+ return dir;
+ }
+
+ protected File getLibraryDir()
+ {
+ DirectoryBuilder builder = new DirectoryBuilder(getVendorDir());
+
+ // make vendor dir
+ builder.cd("lib");
+ File dir = builder.get();
+
+ return dir;
+ }
+
+ /**
+ * Execute the task.
+ *
+ * @throws BuildException Failed to execute.
+ */
+ public void execute() throws BuildException
+ {
+ // short circuit if we are done
+ if (classpath != null) return;
+
+ validate();
+
+ log.debug("vendor: " + vendor);
+ log.debug("name: " + name);
+ log.debug("root: " + root);
+
+ File vendorDir = getVendorDir();
+ project.setProperty(vendor + "." + name + ".root", vendorDir.toString());
+ log.debug("vendorDir: " + vendorDir);
+
+ // make lib dir
+ File libDir = getLibraryDir();
+ project.setProperty(vendor + "." + name + ".lib", libDir.toString());
+ log.debug("libDir: " + libDir);
+
+ // assemple classpath
+ if (classpathSet == null) {
+ setIncludes("*");
+ }
+
+ log.debug("classpathSet: " + classpathSet);
+ classpathSet.setDir(libDir);
+ classpath = new Path(project);
+ classpath.addFileset(classpathSet);
+ log.debug("classpath: " + classpath);
+
+ // set classpath ref
+ Map refs = project.getReferences();
+ refs.put(vendor + "." + name + ".classpath", classpath);
+
+ // help gc
+ vendor = null;
+ name = null;
+ root = null;
+ classpathSet = null;
+ }
+
+ /**
+ * For helper tasks.
+ */
+ public Path getClasspath()
+ {
+ return classpath;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/Library.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/LibrarySet.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/LibrarySet.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/LibrarySet.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,167 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task.config;
+
+import java.io.File;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.PatternSet;
+
+import org.jboss.tools.buildmagic.task.MissingAttributeException;
+import org.jboss.tools.buildmagic.task.MissingElementException;
+import org.jboss.tools.buildmagic.task.util.TaskLogger;
+
+/**
+ * A helper task to setup a path from a set of library elements.
+ *
+ * <p>Usage:
+ * <xmp>
+ *
+ * <libraryset name="library" root="${project.thirdparty}">
+ *
+ * <!-- Java API for XML Processing (JAXP) -->
+ * <library vendor="sun" name="jaxp"/>
+ *
+ * <!-- IBM Bean Scripting Framework (BSF) -->
+ * <library vendor="ibm" name="bsf"/>
+ *
+ * <!-- JUnit -->
+ * <library vendor="junit" name="junit"/>
+ *
+ * <!-- Log4j -->
+ * <library vendor="apache" name="log4j"/>
+ *
+ * </libraryset>
+ *
+ * </xmp>
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class LibrarySet
+ extends Task
+{
+ /** Instance logger. */
+ protected final TaskLogger log = new TaskLogger(this);
+
+ protected String pathID;
+ protected File root;
+ protected List libraries;
+
+ protected Path classpath;
+
+ public void setPathID(final String pathID)
+ {
+ this.pathID = pathID;
+ }
+
+ public void setRoot(final File root)
+ {
+ this.root = root;
+ }
+
+ public Library createLibrary()
+ {
+ Library lib = (Library)project.createTask("library");
+
+ if (libraries == null) {
+ libraries = new ArrayList();
+ }
+ libraries.add(lib);
+
+ return lib;
+ }
+
+ public Library createModuleLibrary()
+ {
+ Library lib = (Library)project.createTask("modulelibrary");
+
+ if (libraries == null) {
+ libraries = new ArrayList();
+ }
+ libraries.add(lib);
+
+ return lib;
+ }
+
+ /**
+ * Validate the attributes for this task.
+ *
+ * @throws BuildException Attributes are not valid.
+ */
+ protected void validate() throws BuildException
+ {
+ if (pathID == null)
+ throw new MissingAttributeException("pathID", this);
+ }
+
+ /**
+ * Execute the task.
+ *
+ * @throws BuildException Failed to execute.
+ */
+ public void execute() throws BuildException
+ {
+ // short circuit if we are done
+ if (classpath != null) return;
+
+ validate();
+
+ log.debug("pathID: " + pathID);
+ log.debug("root: " + root);
+
+ // setup the classpath
+ classpath = new Path(project);
+
+ if (libraries != null) {
+ Iterator iter = libraries.iterator();
+ while (iter.hasNext()) {
+ Library lib = (Library)iter.next();
+
+ // set the root if we have one, else use the libs
+ if (root != null) {
+ lib.setRoot(root);
+ }
+
+ // execute
+ lib.execute();
+
+ // append the classpath
+ classpath.append(lib.getClasspath());
+ }
+
+ log.debug("classpath: " + classpath);
+ }
+
+ // set classpath ref
+ Map refs = project.getReferences();
+ refs.put(pathID, classpath);
+
+ // help gc
+ pathID = null;
+ root = null;
+ libraries = null;
+ }
+
+ /**
+ * For helper tasks.
+ */
+ public Path getClasspath()
+ {
+ return classpath;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/LibrarySet.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/ModuleLibrary.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/ModuleLibrary.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/ModuleLibrary.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,37 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task.config;
+
+import java.io.File;
+
+import org.jboss.util.DirectoryBuilder;
+
+/**
+ * A special extention of {@link Library} for modules. It sets
+ * up the namespace differently.
+ *
+ * <p>Expects vendor dir to be under <tt><em>name</em>/output</tt>.
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ModuleLibrary
+ extends Library
+{
+ protected File getVendorDir()
+ {
+ DirectoryBuilder builder = new DirectoryBuilder(root);
+
+ builder.cd(name).cd("output");
+ File dir = builder.get();
+
+ return dir;
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/config/ModuleLibrary.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/AbstractInfo.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/AbstractInfo.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/AbstractInfo.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,55 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task.module;
+
+import java.util.Map;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+
+import org.jboss.tools.buildmagic.task.util.TaskLogger;
+
+/**
+ * Abstract task for project and module info tasks.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public abstract class AbstractInfo
+ extends Task
+{
+ /** Instance logger. */
+ protected final TaskLogger log = new TaskLogger(this);
+
+ protected String _if;
+ protected String unless;
+
+ public void setIf(final String property) {
+ this._if = property;
+ }
+
+ public void setUnless(final String property) {
+ this.unless = property;
+ }
+
+ protected boolean canContinue() {
+ Map map = project.getProperties();
+ if (_if != null && !map.containsKey(_if))
+ return false;
+ else if (unless != null && map.containsKey(unless))
+ return false;
+
+ return true;
+ }
+
+ protected String getProperty(String name) {
+ return project.getProperty(name);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/AbstractInfo.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ExecuteModules.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ExecuteModules.java 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ExecuteModules.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -10,6 +10,7 @@
package org.jboss.tools.buildmagic.task.module;
import java.io.File;
+import java.io.PrintWriter;
import java.util.List;
import java.util.LinkedList;
@@ -18,17 +19,23 @@
import java.util.Map;
import org.apache.tools.ant.Task;
-import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.TaskAdapter;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Property;
import org.apache.tools.ant.taskdefs.Echo;
+import org.jboss.util.Strings;
+
+import org.jboss.tools.buildmagic.task.IllegalAttributeException;
import org.jboss.tools.buildmagic.task.ResolveProperties;
+import org.jboss.tools.buildmagic.task.Ant;
import org.jboss.tools.buildmagic.task.AbstractBuildListener;
+
import org.jboss.tools.buildmagic.task.util.TaskLogger;
-import org.jboss.util.Strings;
/**
* Executes a set of modules (sub-projects).
@@ -50,7 +57,7 @@
});
}
*/
-
+
/** Instance logger. */
protected final TaskLogger log = new TaskLogger(this);
@@ -59,7 +66,7 @@
/** The buildfile to use. */
protected String antfile;
-
+
/** The list of module names to exectue. */
protected List modules;
@@ -74,11 +81,11 @@
protected String moduleProperty = "module";
protected String targetProperty = "target";
-
+
/** Skip over modules that do not exist. */
protected boolean skipMissing = false;
protected boolean inheritAll = false;
-
+
/** Tasks to echo some output before and after each module executes. */
protected List headers = new LinkedList();
protected List footers = new LinkedList();
@@ -98,149 +105,124 @@
{
threading = flag;
}
-
- public void setExportproperties(String list)
- {
+
+ public void setExportproperties(String list) {
StringTokenizer stok = new StringTokenizer(list, ",");
- while (stok.hasMoreTokens())
- {
+ while (stok.hasMoreTokens()) {
exportProperties.add(stok.nextToken().trim());
}
}
-
- public void setModuleproperty(String property)
- {
+
+ public void setModuleproperty(String property) {
moduleProperty = property;
}
- public void setTargetproperty(String property)
- {
+ public void setTargetproperty(String property) {
targetProperty = property;
}
- public void setInheritAll(boolean flag)
- {
+ public void setInheritAll(boolean flag) {
inheritAll = flag;
}
/** Setup the internal project. */
- public void init()
- {
+ public void init() {
_project = new Project();
_project.setJavaVersionProperty();
Map tasks = project.getTaskDefinitions();
- _project.addTaskDefinition("property", (Class) tasks.get("property"));
- _project.addTaskDefinition("echo", (Class) tasks.get("echo"));
+ _project.addTaskDefinition("property", (Class)tasks.get("property"));
+ _project.addTaskDefinition("echo", (Class)tasks.get("echo"));
}
/** Re-initialize the internal project. */
- protected void reinit()
- {
+ protected void reinit() {
init();
// copy the list of properties to the new internal project
- for (int i = 0; i < properties.size(); i++)
- {
- Property a = (Property) properties.get(i);
- Property b = (Property) _project.createTask("property");
- copy(a, b);
+ for (int i=0; i<properties.size(); i++) {
+ Property a = (Property)properties.get(i);
+ Property b = (Property)_project.createTask("property");
+ copy(a, b);
properties.set(i, b);
}
}
/** Copy a property values to another property. */
- protected void copy(final Property a, final Property b)
- {
+ protected void copy(final Property a, final Property b) {
b.setName(a.getName());
-
- if (a.getValue() != null)
- {
+
+ if (a.getValue() != null) {
b.setValue(a.getValue());
}
-
- if (a.getFile() != null)
- {
+
+ if (a.getFile() != null) {
b.setFile(a.getFile());
}
-
- if (a.getResource() != null)
- {
+
+ if (a.getResource() != null) {
b.setResource(a.getResource());
}
}
-
+
/** Set the target name. */
- public void setTarget(final String target)
- {
+ public void setTarget(final String target) {
this.target = target;
}
/** Set the buildfile to use. */
- public void setAntfile(final String antfile)
- {
+ public void setAntfile(final String antfile) {
this.antfile = antfile;
}
-
+
/** Set the modules to execute. */
- public void setModules(String names)
- {
+ public void setModules(String names) {
names = ResolveProperties.subst(names, project, true);
StringTokenizer stok = new StringTokenizer(names, ",");
modules = new LinkedList();
- while (stok.hasMoreTokens())
- {
+ while (stok.hasMoreTokens()) {
modules.add(stok.nextToken().trim());
}
}
- public void setSkipmissing(boolean flag)
- {
+ public void setSkipmissing(boolean flag) {
skipMissing = flag;
}
-
+
/** Set the root. */
- public void setRoot(final String dir) throws BuildException
- {
+ public void setRoot(final String dir) throws BuildException {
this.root = dir;
}
-
+
/**
* Execute this task.
*
* @throws BuildException Failed to execute task.
*/
- public void execute() throws BuildException
- {
- try
- {
+ public void execute() throws BuildException {
+ try {
// need at least one module name
- if (modules == null || modules.size() == 0)
- {
+ if (modules == null || modules.size() == 0) {
throw new BuildException
("No module names were specified", location);
}
// need the root directory
- if (root == null)
- {
+ if (root == null) {
throw new BuildException
("Root directory not specified", location);
}
Iterator iter = modules.iterator();
- while (iter.hasNext())
- {
- String module = (String) iter.next();
- executeModule(module);
+ while (iter.hasNext()) {
+ executeModule((String)iter.next());
}
}
- finally
- {
+ finally {
// help the gc
_project = null;
}
}
-
+
/**
* Execute a single module.
*/
@@ -248,61 +230,55 @@
throws BuildException
{
this.module = module;
-
+
// create and setup the ant task
- final Ant ant = (Ant) project.createTask("ant");
+ final Ant ant = (Ant)project.createTask("Ant");
ant.setInheritAll(inheritAll);
ant.init();
// add a property for the name of the module (our name that is)
Property p = createProperty(null);
+
p.setName(moduleProperty);
p.setValue(module);
- _project.setProperty(moduleProperty, module);
copy(p, ant.createProperty());
p.execute();
// project.setUserProperty(moduleProperty, module);
-
+
// add a property for the target of the module (our name that is)
String temp = (target == null) ? "<default>" : target;
resolve(temp);
p = createProperty(null);
p.setName(targetProperty);
p.setValue(temp);
- _project.setProperty(targetProperty, temp);
copy(p, ant.createProperty());
p.execute();
// project.setUserProperty(targetProperty, temp);
-
+
ant.setLocation(location);
temp = ResolveProperties.subst(root, project);
temp = Strings.subst("@MODULE@", module, temp);
temp = Strings.subst("@TARGET@", target, temp);
-
+
File moduleRoot = new File(temp);
log.verbose("module root: " + moduleRoot);
ant.setDir(moduleRoot);
ant.setAntfile(antfile);
-
- if (target != null)
- {
+
+ if (target != null) {
log.verbose("using target: " + target);
ant.setTarget(target);
}
Map props = project.getProperties();
-
+
// see if this is a valid ant file
- /*
- try
- {
- if (ant.getBuildFile() != null) ;
+ try {
+ if (ant.getBuildFile() != null);
}
- catch (BuildException e)
- {
+ catch (BuildException e) {
log.verbose("exception: " + e);
- if (skipMissing)
- {
+ if (skipMissing) {
listener.skipped(module);
log.warning("Missing build file; skipping module: " + module);
@@ -314,17 +290,15 @@
log.error("Missing build file: " + module);
throw e;
}
- */
-
- runHooks(beforeHooks);
- // ant.addBuildListener(listener);
-
+ runHooks(beforeHooks);
+
+ ant.addBuildListener(listener);
+
// set up any properties
Iterator iter = properties.iterator();
- while (iter.hasNext())
- {
- Property a = (Property) iter.next();
+ while (iter.hasNext()) {
+ Property a = (Property)iter.next();
Property b = ant.createProperty();
copy(a, b);
a.execute();
@@ -332,10 +306,9 @@
// export any listed property names
iter = exportProperties.iterator();
- while (iter.hasNext())
- {
- String name = (String) iter.next();
- String value = (String) props.get(name);
+ while (iter.hasNext()) {
+ String name = (String)iter.next();
+ String value = (String)props.get(name);
p = ant.createProperty();
p.setName(name);
p.setValue(value);
@@ -344,86 +317,76 @@
}
final String targetName = temp;
-
+
Runnable runner = new Runnable()
- {
- public void run()
{
- // execute the task
- printHeading(headers);
- log.verbose("Executing " + targetName + " in module '" + module + "'...");
+ public void run()
+ {
+ // execute the task
+ printHeading(headers);
+ log.verbose("Executing " + targetName + " in module '" + module + "'...");
- ant.execute();
+ ant.execute();
+
+ log.verbose("Finished with " + targetName + " in module '" + module + "'...");
+ printHeading(footers);
- log.verbose("Finished with " + targetName + " in module '" + module + "'...");
- printHeading(footers);
-
- runHooks(afterHooks);
- }
- };
-
- if (threading)
- {
+ runHooks(afterHooks);
+ }
+ };
+
+ if (threading) {
new Thread(runner, "Module Runner (" + module + ":" + targetName + ")").start();
}
- else
- {
+ else {
runner.run();
}
-
+
// shit this sucks
// jason: this will not work in ant 1.5
// props.remove(moduleProperty);
// props.remove(targetProperty);
-
+
// iter = properties.iterator();
// while (iter.hasNext()) {
// Property a = (Property)iter.next();
// props.remove(a.getName());
// }
- }
+ }
- protected void printHeading(List list)
- {
+ protected void printHeading(List list) {
Iterator iter = list.iterator();
- while (iter.hasNext())
- {
- MyEcho echo = (MyEcho) iter.next();
+ while (iter.hasNext()) {
+ MyEcho echo = (MyEcho)iter.next();
echo.execute();
}
}
-
+
/** Create a nested property. */
- public Property createProperty()
- {
+ public Property createProperty() {
Property prop = createProperty(properties);
return prop;
}
/** Create a nested property. */
- public Property createProperty(List list)
- {
- if (_project == null)
- {
+ public Property createProperty(List list) {
+ if (_project == null) {
reinit();
}
- Property temp = (Property) _project.createTask("property");
+ Property temp = (Property)_project.createTask("property");
temp.setUserProperty(true);
-
- if (list != null)
- {
+
+ if (list != null) {
list.add(0, temp);
}
-
+
return temp;
}
-
+
/** Create a nested header. */
- public Echo createHeader()
- {
- if (_project == null)
- {
+ public Echo createHeader() {
+ if (_project == null) {
reinit();
}
@@ -433,33 +396,30 @@
}
/** Create a nested footer. */
- public Echo createFooter()
- {
- if (_project == null)
- {
+ public Echo createFooter() {
+ if (_project == null) {
reinit();
}
-
+
MyEcho footer = new MyEcho(project);
footers.add(footer);
return footer;
}
- public String resolve(String property)
- {
+ public String resolve(String property) {
Map props = project.getUserProperties();
property = ResolveProperties.subst(property, props, false);
-
+
props = _project.getUserProperties();
property = ResolveProperties.subst(property, props, false);
props = _project.getProperties();
property = ResolveProperties.subst(property, props, false);
-
+
return property;
}
-
+
/**
* Nested echo class to hold header and footer data.
*/
@@ -467,21 +427,19 @@
extends Echo
{
Project project;
-
+
public MyEcho(Project project)
{
this.project = project;
}
-
- public void addText(String msg)
- {
+
+ public void addText(String msg) {
message += msg;
}
-
- public void execute() throws BuildException
- {
+
+ public void execute() throws BuildException {
String temp = resolve(message);
-
+
temp = Strings.subst("@MODULE@", module, temp);
temp = Strings.subst("@TARGET@", ExecuteModules.this.target, temp);
@@ -489,69 +447,60 @@
}
}
- public Hook createBefore()
- {
+ public Hook createBefore() {
Hook hook = new Hook(this);
beforeHooks.add(hook);
return hook;
}
-
- public Hook createAfter()
- {
+
+ public Hook createAfter() {
Hook hook = new Hook(this);
afterHooks.add(hook);
return hook;
}
-
+
protected class Hook
{
public ExecuteModules task;
public String target;
-
- public Hook(ExecuteModules task)
- {
+
+ public Hook(ExecuteModules task) {
this.task = task;
}
-
- public void setTarget(String target)
- {
+
+ public void setTarget(String target) {
this.target = target;
}
- public void execute() throws BuildException
- {
+ public void execute() throws BuildException {
Project project = task.getProject();
String t = task.resolve(target);
t = Strings.subst("@MODULE@", module, t);
t = Strings.subst("@TARGET@", ExecuteModules.this.target, t);
-
- if (project.getTargets().containsKey(t))
- {
+
+ if (project.getTargets().containsKey(t)) {
project.executeTarget(t);
}
- else
- {
+ else {
log.verbose("skipping missing hook: " + t);
}
}
}
- protected void runHooks(List list) throws BuildException
- {
+ protected void runHooks(List list) throws BuildException {
log.verbose("executing hooks");
log.debug("list: " + list);
-
+
Iterator iter = list.iterator();
- while (iter.hasNext())
- {
- Hook hook = (Hook) iter.next();
+ while (iter.hasNext()) {
+ Hook hook = (Hook)iter.next();
log.debug("executing hook: " + hook);
hook.execute();
}
}
-
+
/**
* This is meant to provide the ability to generate an xml file
* which contains what modules we have invoked, their targets and
@@ -567,63 +516,46 @@
//
// hookup xml output here
//
- public void skipped(String module)
- {
+ public void skipped(String module) {
// System.out.println("skipped module: " + module);
}
-
- public void buildStarted(BuildEvent event)
- {
+ public void buildStarted(BuildEvent event) {
// System.out.println("started build: " + event);
}
-
- public void buildFinished(BuildEvent event)
- {
+ public void buildFinished(BuildEvent event) {
// System.out.println("finished build: " + event);
}
-
- public void targetStarted(BuildEvent event)
- {
+ public void targetStarted(BuildEvent event) {
// System.out.println("started target: " + event.getTarget());
}
-
- public void targetFinished(BuildEvent event)
- {
+ public void targetFinished(BuildEvent event) {
// System.out.println("finished target: " + event.getTarget());
}
-
- public void taskStarted(BuildEvent event)
- {
+ public void taskStarted(BuildEvent event) {
// System.out.println("started task: " + event.getTask());
}
-
- public void taskFinished(BuildEvent event)
- {
+ public void taskFinished(BuildEvent event) {
// System.out.println("finished task: " + event.getTask());
}
-
- public void messageLogged(BuildEvent event)
- {
+ public void messageLogged(BuildEvent event) {
Throwable t = event.getException();
int pri = event.getPriority();
String message = event.getMessage();
-
- if (t != null)
- {
+
+ if (t != null) {
// System.out.println("exception: " + t);
}
- switch (pri)
- {
- case Project.MSG_ERR:
- // System.out.println("error: " + message);
- break;
- case Project.MSG_WARN:
- // System.out.println("warning: " + message);
- break;
- case Project.MSG_INFO:
- case Project.MSG_VERBOSE:
- case Project.MSG_DEBUG:
+ switch (pri) {
+ case Project.MSG_ERR:
+ // System.out.println("error: " + message);
+ break;
+ case Project.MSG_WARN:
+ // System.out.println("warning: " + message);
+ break;
+ case Project.MSG_INFO:
+ case Project.MSG_VERBOSE:
+ case Project.MSG_DEBUG:
}
}
}
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInfo.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInfo.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInfo.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,34 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task.module;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Displays module information.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ModuleInfo
+ extends AbstractInfo
+{
+ /**
+ * Execute this task.
+ *
+ * @throws BuildException Failed to execute task.
+ */
+ public void execute() throws BuildException {
+ if (!canContinue()) return;
+
+ log.info("Project root: " + getProperty("project.root"));
+ log.info(" Module root: " + getProperty("module.root"));
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInfo.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInit.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInit.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInit.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,93 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task.module;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+
+import org.jboss.tools.buildmagic.task.MissingAttributeException;
+import org.jboss.tools.buildmagic.task.MissingElementException;
+import org.jboss.tools.buildmagic.task.util.TaskLogger;
+
+/**
+ * A helper for initializing a modules environment.
+ *
+ * <p>Usage:
+ * <xmp>
+ *
+ *
+ *
+ * </xmp>
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ModuleInit
+ extends Task
+{
+ /** Instance logger. */
+ protected final TaskLogger log = new TaskLogger(this);
+
+ protected String name;
+ protected String title;
+ protected String version;
+
+ public void setName(final String name)
+ {
+ this.name = name;
+ }
+
+ public void setTitle(final String title)
+ {
+ this.title = title;
+ }
+
+ public void setVersion(final String version)
+ {
+ this.version = version;
+ }
+
+ /**
+ * Validate the attributes for this task.
+ *
+ * @throws BuildException Attributes are not valid.
+ */
+ protected void validate() throws BuildException
+ {
+ if (name == null)
+ throw new MissingAttributeException("name", this);
+ }
+
+ /**
+ * Execute the task.
+ *
+ * @throws BuildException Failed to execute.
+ */
+ public void execute() throws BuildException
+ {
+ validate();
+
+ project.setProperty("module.name", name);
+ log.debug("name: " + name);
+
+ if (title == null) {
+ title = name;
+ }
+ project.setProperty("module.title", name);
+ project.setProperty("module.Name", name); // deprecated
+ log.debug("title: " + title);
+
+ if (version == null) {
+ version = "DEV";
+ }
+ project.setProperty("module.version", version);
+ log.debug("version: " + version);
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ModuleInit.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ProjectInfo.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ProjectInfo.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ProjectInfo.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,34 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task.module;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Displays project information.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class ProjectInfo
+ extends AbstractInfo
+{
+ /**
+ * Execute this task.
+ *
+ * @throws BuildException Failed to execute task.
+ */
+ public void execute() throws BuildException {
+ if (!canContinue()) return;
+
+ log.info("Project root: " + getProperty("project.root"));
+ log.info("Modules: " + getProperty("modules"));
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/module/ProjectInfo.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Dump.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Dump.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Dump.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,89 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task.util;
+
+import java.util.Map;
+import java.util.Iterator;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Dumps lots of information
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class Dump
+ extends Task
+{
+ /** Instance logger. */
+ protected final TaskLogger log = new TaskLogger(this);
+
+ protected boolean refs;
+ protected boolean properties;
+ protected boolean datatypes;
+ protected boolean targets;
+ protected boolean taskdefs;
+ protected boolean filters;
+
+ public void setRefs(boolean flag) {
+ refs = flag;
+ }
+
+ public void setProperties(boolean flag) {
+ properties = flag;
+ }
+
+ public void setProps(boolean flag) {
+ setProperties(flag);
+ }
+
+ public void setDatatypes(boolean flag) {
+ datatypes = flag;
+ }
+
+ public void setTargets(boolean flag) {
+ targets = flag;
+ }
+
+ public void setTaskdefs(boolean flag) {
+ taskdefs = flag;
+ }
+
+ public void setFilters(boolean flag) {
+ filters = flag;
+ }
+
+ public void execute() throws BuildException {
+ if (refs) dumpMap("References", project.getReferences());
+ if (properties) dumpMap("Properties", project.getProperties());
+ if (datatypes) dumpMap("DataTypes", project.getDataTypeDefinitions());
+ if (targets) dumpMap("Targets", project.getTargets());
+ if (taskdefs) dumpMap("Taskdefs", project.getTaskDefinitions());
+ if (filters) dumpMap("Filters", project.getFilters());
+ }
+
+ protected void dumpMap(final String name, final Map map) {
+ log.info(name + ":");
+ dumpMap(map, " ");
+ log.info("");
+ }
+
+ protected void dumpMap(final Map map, final String prefix) {
+ Iterator iter = map.keySet().iterator();
+ while (iter.hasNext()) {
+ String key = (String)iter.next();
+ Object value = map.get(key);
+ String classname = value.getClass().getName();
+ log.info(prefix + key + "=" + value + " (" + classname + ")");
+ }
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Dump.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Puke.java
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Puke.java (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Puke.java 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,35 @@
+/***************************************
+ * *
+ * JBoss: The OpenSource J2EE WebOS *
+ * *
+ * Distributable under LGPL license. *
+ * See terms of license at gnu.org. *
+ * *
+ ***************************************/
+
+package org.jboss.tools.buildmagic.task.util;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Simply throws an exception.
+ *
+ * @version <pre>$Id$</pre>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class Puke
+ extends Task
+{
+ public Puke() {
+ throw new RuntimeException("puke");
+ }
+
+ public void init() throws BuildException {
+ throw new BuildException("puke");
+ }
+
+ public void execute() throws BuildException {
+ throw new BuildException("puke");
+ }
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/main/org/jboss/tools/buildmagic/task/util/Puke.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/resources
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss/tools
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss/tools/buildmagic
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss/tools/buildmagic/task
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss/tools/buildmagic/task/autoload.properties
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss/tools/buildmagic/task/autoload.properties 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tasks/src/resources/org/jboss/tools/buildmagic/task/autoload.properties 2008-08-19 22:06:02 UTC (rev 21628)
@@ -8,6 +8,7 @@
### Stuff that glues things together ###
+resolveproperties=org.jboss.tools.buildmagic.task.ResolveProperties
resolver=org.jboss.tools.buildmagic.task.ResolveProperties
propertyfilter=org.jboss.tools.buildmagic.task.PropertyFilter
require=org.jboss.tools.buildmagic.task.Require
@@ -17,4 +18,25 @@
### Project/Module tasks ###
execmodules=org.jboss.tools.buildmagic.task.module.ExecuteModules
+projectinfo=org.jboss.tools.buildmagic.task.module.ProjectInfo
+moduleinfo=org.jboss.tools.buildmagic.task.module.ModuleInfo
moduleconfig=org.jboss.tools.buildmagic.task.module.ModuleConfig
+moduleinit=org.jboss.tools.buildmagic.task.module.ModuleInit
+
+### Configuration Helpers ###
+library=org.jboss.tools.buildmagic.task.config.Library
+modulelibrary=org.jboss.tools.buildmagic.task.config.ModuleLibrary
+libraryset=org.jboss.tools.buildmagic.task.config.LibrarySet
+
+### Misc ###
+
+projecthelp=org.jboss.tools.buildmagic.task.ProjectHelp
+_puke=org.jboss.tools.buildmagic.task.util.Puke
+_dump=org.jboss.tools.buildmagic.task.util.Dump
+
+### Unused ??? ###
+
+#set=org.jboss.tools.buildmagic.task.Set
+#unset=org.jboss.tools.buildmagic.task.Unset
+#appendpath=org.jboss.tools.buildmagic.task.AppendPath
+#findroot=org.jboss.tools.buildmagic.task.FindRoot
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/LICENSE
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/VERSION
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/VERSION 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/VERSION 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1 +1,2 @@
-5.1 2003-04-25 md5=54f27d984f1862815219b524038c7177
+5.0 Release Candidate 1
+
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/VERSION
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,19 +0,0 @@
-<project name="apache-bcel-component-info">
-
- <!-- ============================================================ -->
- <!-- Apache BCEL -->
- <!-- ============================================================ -->
-
- <component id="apache-bcel"
- licenseType="apache-2.0"
- version="5.1"
- projectHome="http://jakarta.apache.org/bcel/index.html"
- description="Byte Code Engineering Library">
- <artifact id="bcel.jar"/>
- <export>
- <include input="bcel.jar"/>
- </export>
- </component>
-
-
-</project>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-bcel/lib/bcel.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/README.txt
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/README.txt 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/README.txt 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,17 +0,0 @@
-This is a list of the files and versions in this directory. Please keep it up
-to date:
-
-commons-collections.jar: The 2,1 release of commons-collections obtained from
-http://jakarta.apache.org/builds/jakarta-commons/release/commons-collections/v2.1/
-
-commons-logging.jar: The 1.0.3 release of the commons logging wrapper from
-http://archive.apache.org/dist/jakarta/commons/logging/binaries/
-NOTE: See jboss.patch.txt for a patch to use a WeakHashMap in the LogFactory
-which avoids memory leaks caused by hard references to classloaders in the
-apache distribution.
-
-commons-httpclient.jar: The 2.0 release of the commons http client from
-http://www.apache.org/dist/jakarta/commons/httpclient/binary/commons-httpclient-2.0.zip
-
-commons-vfs.jar: The 1.0-dev release of the commons vfs library obtained from
-http://cvs.apache.org/builds/jakarta-commons/nightly/commons-vfs/
\ No newline at end of file
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,21 +0,0 @@
-<project name="apache-commons-component-info">
-
- <!-- ============================================================ -->
- <!-- Apache Commons -->
- <!-- ============================================================ -->
-
- <component id="apache-commons"
- licenseType="apache-2.0"
- version="mixed"
- projectHome="http://jakarta.apache.org/commons/index.html">
-
- <artifact id="commons-logging.jar"/>
- <artifact id="commons-httpclient.jar"/>
- <artifact id="commons-discovery.jar"/>
- <export>
- <include input="commons-logging.jar"/>
- <include input="commons-httpclient.jar"/>
- <include input="commons-discovery.jar"/>
- </export>
- </component>
-</project>
\ No newline at end of file
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/jboss.patch.txt
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/jboss.patch.txt 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/jboss.patch.txt 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,38 +0,0 @@
---- LogFactory.java.1.0.3 2005-06-08 19:02:38.000000000 -0400
-+++ LogFactory.java 2005-06-08 19:10:21.000000000 -0400
-@@ -70,9 +70,12 @@
- import java.lang.reflect.Method;
- import java.security.AccessController;
- import java.security.PrivilegedAction;
-+import java.util.Collections;
- import java.util.Enumeration;
--import java.util.Hashtable;
-+import java.util.Iterator;
-+import java.util.Map;
- import java.util.Properties;
-+import java.util.WeakHashMap;
-
-
- /**
-@@ -225,7 +228,7 @@
- * The previously constructed <code>LogFactory</code> instances, keyed by
- * the <code>ClassLoader</code> with which it was created.
- */
-- protected static Hashtable factories = new Hashtable();
-+ protected static Map factories = Collections.synchronizedMap(new WeakHashMap());
-
-
- // --------------------------------------------------------- Static Methods
-@@ -448,9 +451,9 @@
- public static void releaseAll() {
-
- synchronized (factories) {
-- Enumeration elements = factories.elements();
-- while (elements.hasMoreElements()) {
-- LogFactory element = (LogFactory) elements.nextElement();
-+ Iterator elements = factories.values().iterator();
-+ while (elements.hasNext()) {
-+ LogFactory element = (LogFactory) elements.next();
- element.release();
- }
- factories.clear();
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-beanutils.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-codec-1.2.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-digester-1.6.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-discovery.jar
===================================================================
(Binary files differ)
Added: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-fileupload-1.0-beta-1.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-fileupload-1.0-beta-1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-fileupload.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-httpclient.jar
===================================================================
(Binary files differ)
Added: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-lang-1.0.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-lang-1.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-lang-2.0.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-logging-api.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-logging.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-validator-1.1.3.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-commons/lib/commons-vfs.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,18 +0,0 @@
-<project name="apache-log4j-component-info">
- <!-- ============================================================ -->
- <!-- Apache Log4j -->
- <!-- ============================================================ -->
-
- <component id="apache-log4j"
- licenseType="apache-2.0"
- version="1.2.8"
- projectHome="http://logging.apache.org/"
- description="Java logging framework">
- <artifact id="log4j.jar"/>
- <artifact id="snmpTrapAppender.jar"/>
- <export>
- <include input="log4j.jar"/>
- </export>
- </component>
-
-</project>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/lib/README
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/lib/README 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/lib/README 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,3 +1,9 @@
This is a list of the files and versions in this directory. Please keep it up to date:
-log4j.jar - jakarta-log4j-1.2.8
+log4j.jar is actually log4j-1.2.4.jar released June 13, 2002.
+commons-logging.jar appears to be a modified post 1.0 release with the classes
+ LogFactory SimpleLog having a later date of 2/26/2002. Also, this version
+ contains the Java source files, which is why it is larger.
+
+Frederick N. Brier
+6/20/2002
\ No newline at end of file
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/lib/log4j.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-log4j/lib/snmpTrapAppender.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/LICENSE
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/client
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/client/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/client/lib/commons-httpclient.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/client/lib/commons-httpclient.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/client/lib/webdavlib.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/apache-slide/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,18 +0,0 @@
-<project name="apache-slide-component-info">
-
- <!-- ============================================================ -->
- <!-- Apache Slide -->
- <!-- ============================================================ -->
-
- <component id="apache-slide"
- licenseType="apache-2.0"
- version="2.0"
- projectHome="http://jakarta.apache.org/slide/index.html"
- description="WebDAV Support Library">
-
- <artifact id="webdavlib.jar"/>
- <export>
- <include input="webdavlib.jar"/>
- </export>
- </component>
-</project>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/README
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/README 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/README 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,4 +1,5 @@
-$Id$
+File list:
-Version 1.5 of dom4j from http://www.dom4j.org. This also includes the
-jaxen-1.1-beta-4.jar from the same dist.
+The lib directory contains dom4j.jar, version 1.3
+
+Last Updated: $Date$, $Author$
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,19 +0,0 @@
-<project name="dom4j-dom4j-component-info">
-
- <!-- ============================================================ -->
- <!-- DOM4J -->
- <!-- ============================================================ -->
-
- <component id="dom4j-dom4j"
- licenseType="dom4j"
- version="1.5"
- projectHome="http://dom4j.org/"
- description="Library for XML, XPath and XSLT on the Java platform">
- <artifact id="dom4j.jar"/>
- <export>
- <include input="dom4j.jar"/>
- </export>
- </component>
-
-
-</project>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/lib/dom4j.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/dom4j-dom4j/lib/jaxen-1.1-beta-4.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-getopt
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-getopt/LICENSE.lgpl
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-getopt/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-getopt/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-getopt/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,18 +0,0 @@
-<project name="gnu-getopt-component-info">
- <!-- ============================================================ -->
- <!-- GNU Getopt -->
- <!-- ============================================================ -->
-
- <component id="gnu-getopt"
- licenseType="lgpl"
- version="1.0.10"
- projectHome="http://www.urbanophile.com/arenn/hacking/download.html"
- description="Java getopt classes for short and long argument parsing">
-
- <artifact id="getopt.jar"/>
- <export>
- <include input="getopt.jar"/>
- </export>
- </component>
-
-</project>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-getopt/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-regexp
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-regexp/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-regexp/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-regexp/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,19 +0,0 @@
-<project name="gnu-regexp-component-info">
-
- <!-- ============================================================ -->
- <!-- GNU Regular Expressions -->
- <!-- ============================================================ -->
-
- <component id="gnu-regexp"
- licenseType="lgpl"
- version="1.1.14"
- projectHome="http://freshmeat.net/projects/gnu.regexp/"
- description="Regular expression package for Java">
-
- <artifact id="gnu-regexp.jar"/>
- <export>
- <include input="gnu-regexp.jar"/>
- </export>
- </component>
-
-</project>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/gnu-regexp/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/ibm-bsf
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/ibm-bsf/VERSION
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/ibm-bsf/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/junit-junit
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/junit-junit/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/junit-junit/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/junit-junit/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,18 +0,0 @@
-<project name="junit-junit-component-info">
- <!-- ============================================================ -->
- <!-- JUnit -->
- <!-- ============================================================ -->
-
- <component id="junit-junit"
- licenseType="lgpl"
- version="3.8.1"
- projectHome="http://www.junit.org/index.htm"
- description="Java unit testing framework">
-
- <artifact id="junit.jar"/>
- <export>
- <include input="junit.jar"/>
- </export>
- </component>
-
-</project>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/junit-junit/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/junit-junit/lib/junit.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,18 +0,0 @@
-<project name="oswego-concurrent-component-info">
-
- <!-- ============================================================ -->
- <!-- Oswego Concurrent Library -->
- <!-- ============================================================ -->
-
- <component id="oswego-concurrent"
- licenseType="opensaml"
- version="1.3.4"
- projectHome="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"
- description="Oswego util.concurrent package">
-
- <artifact id="concurrent.jar"/>
- <export>
- <include input="concurrent.jar"/>
- </export>
- </component>
-</project>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/LICENSE.txt
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/LICENSE.txt 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/LICENSE.txt 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,4 +0,0 @@
-Originally written by Doug Lea and released into the public domain.
-This may be used for any purposes whatsoever without acknowledgment.
-Thanks for the assistance and support of Sun Microsystems Labs,
-and everyone contributing, testing, and using this code.
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/README.txt
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/README.txt 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/README.txt 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,104 +0,0 @@
-$Id$
-NAME: Oswego util.concurrent package
-VERSION: 1.3.3
-PROJECT: http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html
-PURPOSE: Used by many modules for non-trival concurrency primatives
-
-# 10Jul1998 1.0
-# 11Jul1998 1.0.1: removed .class files from release, Fixed documentation error, included Barrier interface.
-# 12Jul1998 1.0.2: Fixed return value for swap; fixed documentation errors.
-# 15Jul1998 1.0.3: Fixed more documentation errors; re-fixed swap; other cosmetic improvements.
-# 18Jul1998 1.0.4: Simplified some classes by removing some alleged optimizations that do not actually help on some platforms; improved SynchronizationTimer; added some documentation.
-# 1Sep1998 version 1.1.0:
-
- * Replace SynchronousChannel algorithm with fairer, more scalable one
- * TimeoutException now extends InterruptedException
- * Replace int counters with longs to avoid wrapping.
- * new LayeredSync class
- * new ObservableSync class
- * new NullSync class
- * new TimeoutSync class
- * new SyncCollection classes
- * new ReentrantWriterPreferenceReadWriteLock class
- * peek added to Channel
- * new ClockDaemon class
- * Refactorings to standardize usage of thread factories
- * removed reliance on ThreadGroups in PooledExecutor
-
-# 7Jan 1999 Version 1.2
-
- * ClockDaemon.shutdown allows immediate restart
- * Callable.call throws Throwable, not Exception
- * new Task, TaskRunner, TaskRunnerGroup classes
- * new taskDemo subdirectory
-
-# 13Jan1999 version 1.2.1
-
- * Minor cleanup of Task classes
-
-# 17Jan1999 version 1.2.2:
-
- * Simplify Task classes; improve documentation; add priority control; they are no longer labeled as `preliminary'.
- * More sample programs in taskDemos
- * Add warnings about reentrancy to RW locks
- * Callable throws Exception again, but FutureResult handles Throwables
-
-# 25Mar1999 version 1.2.3
-
- * PooledExecutor -- allow pool to shrink when max size decreased
- * Task -- add reset, array-based operations
- * new PropertyChangeMulticaster, VetoableChangeMulticaster
-
-# 21may1999 version 1.2.4
-
- * PooledExecutor -- allow supplied Channel in constructor; new methods createThreads(), drain()
- * Task, TaskRunner, TaskRunnerGroup renamed to FJTask, FJTaskRunner, FJTaskRunnerGroup to avoid clashes with commonly used class name of `Task'.
- * Misc documentation improvements
- * WriterPreferenceReadWriteLock -- fix to notify on interrupt
-
-# 23oct1999 version 1.2.5
-
- * PooledExecutor -- add minimumPoolSize settings
- * LU in taskDemo
- * Minor improvements to LinkedQueue, FJTaskRunner
-
-# 29dec1999 version 1.2.6
-
- * FJTaskRunner -- now works on MP JVMs that do not correctly implement read-after-write of volatiles.
- * added TimedCallable
-
-# 12jan2001 version 1.3.0
-
- * new ConcurrentHashMap, ConcurrentReaderHashMap classes.
- * BoundedLinkedQueue.setCapacity: immediately reconcile permits.
- * ReentrantWriterPreferenceReadWriteLock: Both readers and writers are now reentrant.
- * PooledExecutor: policy now an interface, not abstract class.
- * QueuedExecutor, PooledExecutor: new shutdown methods
-
-# 2dec2001 Version 1.3.1
-
- * PooledExecutor: declare inner class constructor as protected, more flexible shutdown support, blocked exec handlers can throw InterruptedExceptions.
- * Ensure all serialization methods are private.
- * Joe Bowbeer's SwingWorker now in misc
- * Improvements to ConcurrentHashMap, ConcurrentReaderHashMap, FIFOReadWriteLock, ReentrantWriterPreferenceReadWriteLock. WaitFreeQueue, SynchronousChannel.
-
-# 12dec2002 Version 1.3.2
-
- * SemaphoreControlledChannel - fix constructor to use longs, not its.
- * Improvements to Heap.
- * Fix interference check in ConcurrentReaderHashMap.
- * ReentrantWriterPreferenceReadWriteLock throw IllegalStateException instead of NullPointerException on release errors.
-
-# 20feb2004 Version 1.3.3
-
- * PooledExecutor: Create new threads if needed when terminating. (Thanks to Bruno Dumon), and replace dying thread if it is only one.
- * Clarify by-permission wordings.
- * Fix synchronization scope error in SynchronizedLong (Thanks to Aaron Greenhouse.)
-
-# 20may2004 Version 1.3.4
- * WaitableX: notify on bitwise operations
- * QueuedExecutor: can shutdown before thread created (thanks to Wolfgang Hoschek)
-
-# Coming attractions
-
- * This package is entering maintenance mode because improved versions of main functionality are part of JDK1.5 java.util.concurrent via JSR 166.
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/concurrent-src.zip
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/oswego-concurrent/lib/concurrent.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jaxp
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jaxp/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jaxp/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jaxp/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,22 +0,0 @@
-<project name="sun-jaxp-component-info">
- <!-- ============================================================ -->
- <!-- Sun Java XML Parser (JAXP) -->
- <!-- ============================================================ -->
-
- <component id="sun-jaxp"
- version="1.2.3"
- licenseType="sun-jaxp"
- projectHome="http://java.sun.com/xml/jaxp/"
- description="Java API for XML Processing"
- >
- <artifact id="jaxp.jar"/>
- <!-- <artifact id="crimson.jar"/> -->
- <export>
- <include input="jaxp.jar"/>
- <!-- <include input="crimson.jar"/>-->
- <!--include input="xalan.jar"/-->
- </export>
- </component>
-
-
-</project>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jaxp/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jaxp/lib/jaxp.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jmx
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jmx/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jmx/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jmx/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,15 +0,0 @@
-<project name="sun-jmx-component-info">
- <!-- ============================================================ -->
- <!-- Sun Java Management Extensions -->
- <!-- ============================================================ -->
-
- <component id="sun-jmx" version="1.2.8">
- <artifact id="jmxri.jar"/>
- <artifact id="jmxtools.jar"/>
- <export>
- <include input="jmxri.jar"/>
- <include input="jmxtools.jar"/>
- </export>
- </component>
-
-</project>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/sun-jmx/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/commons-logging.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-bea-module-jb4.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-ejb-module-jb4.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-java-module-jb4.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-jb4.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-jboss-module-jb4.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-jdo-module-jb4.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-jmx-module-jb4.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-web-module-jb4.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-xdoclet-module-jb4.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-xjavadoc-jb4.jar
===================================================================
(Binary files differ)
Added: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-xjavadoc-uc-jb4.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/xdoclet-xdoclet/lib/xdoclet-xjavadoc-uc-jb4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/xml-sax
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Deleted: labs/jbossbuild/buildmagic/trunk/thirdparty/xml-sax/component-info.xml
===================================================================
--- labs/jbossbuild/buildmagic/trunk/thirdparty/xml-sax/component-info.xml 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/thirdparty/xml-sax/component-info.xml 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,18 +0,0 @@
-<project name="xml-sax-component-info">
-
- <!-- ============================================================ -->
- <!-- SAX2 & SAX2 Extensions -->
- <!-- ============================================================ -->
-
- <component id="xml-sax"
- version="2.0.x">
- <artifact id="sax2.jar"/>
- <artifact id="sax2-ext.jar"/>
- <export>
- <include input="sax2.jar"/>
- <include input="sax2-ext.jar"/>
- </export>
- </component>
-
-
-</project>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/thirdparty/xml-sax/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tools
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/tools/.donotremove
===================================================================
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/.donotremove
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossbuild/buildmagic/trunk/tools/.project
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/.project 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tools/.project 2008-08-19 22:06:02 UTC (rev 21628)
@@ -5,7 +5,13 @@
<projects>
</projects>
<buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/bin
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/tools/bin/ant
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/ant 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/ant 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,77 +1,24 @@
#! /bin/sh
-# Copyright 2001-2005 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.
+# Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+# reserved.
-# Extract launch and ant arguments, (see details below).
-ant_exec_args=
-no_config=false
-use_jikes_default=false
-ant_exec_debug=false
-show_help=false
-for arg in "$@" ; do
- if [ "$arg" = "--noconfig" ] ; then
- no_config=true
- elif [ "$arg" = "--usejikes" ] ; then
- use_jikes_default=true
- elif [ "$arg" = "--execdebug" ] ; then
- ant_exec_debug=true
- elif [ my"$arg" = my"--h" -o my"$arg" = my"--help" ] ; then
- show_help=true
- ant_exec_args="$ant_exec_args -h"
- else
- if [ my"$arg" = my"-h" -o my"$arg" = my"-help" ] ; then
- show_help=true
- fi
- ant_exec_args="$ant_exec_args \"$arg\""
- fi
-done
+# load system-wide ant configuration
+if [ -f "/etc/ant.conf" ] ; then
+ . /etc/ant.conf
+fi
-# Source/default ant configuration
-if $no_config ; then
- rpm_mode=false
- usejikes=$use_jikes_default
-else
- # load system-wide ant configuration
- if [ -f "/etc/ant.conf" ] ; then
- . /etc/ant.conf
- fi
-
- # load user ant configuration
- if [ -f "$HOME/.ant/ant.conf" ] ; then
- . $HOME/.ant/ant.conf
- fi
- if [ -f "$HOME/.antrc" ] ; then
- . "$HOME/.antrc"
- fi
-
- # provide default configuration values
- if [ -z "$rpm_mode" ] ; then
- rpm_mode=false
- fi
- if [ -z "$usejikes" ] ; then
- usejikes=$use_jikes_default
- fi
+# provide default values for people who don't use RPMs
+if [ -z "$rpm_mode" ] ; then
+ rpm_mode=false;
fi
+if [ -z "$usejikes" ] ; then
+ usejikes=false;
+fi
-# Setup Java environment in rpm mode
-if $rpm_mode ; then
- if [ -f /usr/share/java-utils/java-functions ] ; then
- . /usr/share/java-utils/java-functions
- set_jvm
- set_javacmd
- fi
+# load user ant configuration
+if [ -f "$HOME/.antrc" ] ; then
+ . "$HOME/.antrc"
fi
# OS specific support. $var _must_ be set to either true or false.
@@ -81,29 +28,43 @@
CYGWIN*) cygwin=true ;;
Darwin*) darwin=true
if [ -z "$JAVA_HOME" ] ; then
- JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+ JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
fi
;;
esac
-if [ -z "$ANT_HOME" -o ! -d "$ANT_HOME" ] ; then
+if [ -z "$ANT_HOME" ] ; then
+ # try to find ANT
+ if [ -d /opt/ant ] ; then
+ ANT_HOME=/opt/ant
+ fi
+
+ if [ -d "${HOME}/opt/ant" ] ; then
+ ANT_HOME="${HOME}/opt/ant"
+ fi
+
## resolve links - $0 may be a link to ant's home
PRG="$0"
progname=`basename "$0"`
+ saveddir=`pwd`
# need this for relative symlinks
+ cd `dirname "$PRG"`
+
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
+ if expr "$link" : '.*/.*' > /dev/null; then
+ PRG="$link"
else
- PRG=`dirname "$PRG"`"/$link"
+ PRG=`dirname "$PRG"`"/$link"
fi
done
-
+
ANT_HOME=`dirname "$PRG"`/..
+ cd "$saveddir"
+
# make it fully qualified
ANT_HOME=`cd "$ANT_HOME" && pwd`
fi
@@ -114,98 +75,90 @@
ANT_HOME=`cygpath --unix "$ANT_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# set ANT_LIB location
ANT_LIB="${ANT_HOME}/lib"
-if [ -z "$JAVACMD" ] ; then
+if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
- JAVACMD=`which java 2> /dev/null `
- if [ -z "$JAVACMD" ] ; then
- JAVACMD=java
- fi
+ JAVACMD=java
fi
fi
-
+
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly."
echo " We cannot execute $JAVACMD"
exit 1
fi
-# Build local classpath using just the launcher in non-rpm mode or
-# use the Jpackage helper in rpm mode with basic and default jars
-# specified in the ant.conf configuration. Because the launcher is
-# used, libraries linked in ANT_HOME will also be include, but this
-# is discouraged as it is not java-version safe. A user should
-# request optional jars and their dependencies via the OPT_JAR_LIST
-# variable
-if $rpm_mode && [ -f /usr/bin/build-classpath ] ; then
- LOCALCLASSPATH="$(/usr/bin/build-classpath ant ant-launcher jaxp_parser_impl xml-commons-apis)"
- # If the user requested to try to add some other jars to the classpath
- if [ -n "$OPT_JAR_LIST" ] ; then
- _OPTCLASSPATH="$(/usr/bin/build-classpath $OPT_JAR_LIST 2> /dev/null)"
- if [ -n "$_OPTCLASSPATH" ] ; then
- LOCALCLASSPATH="$LOCALCLASSPATH:$_OPTCLASSPATH"
+if [ -n "$CLASSPATH" ] ; then
+ LOCALCLASSPATH="$CLASSPATH"
+fi
+
+# in rpm_mode get ant/optional/xml parser&api from JAVALIBDIR
+if $rpm_mode; then
+ JAVALIBDIR=/usr/share/java
+ for i in ant ant-optional jaxp_parser xml_apis
+ do
+ if [ -z "$LOCALCLASSPATH" ] ; then
+ LOCALCLASSPATH="$JAVALIBDIR/$i.jar"
+ else
+ LOCALCLASSPATH="$JAVALIBDIR/$i.jar":"$LOCALCLASSPATH"
fi
+ done
+
+ # in rpm mode ant/lib is in /usr/share/java/ant
+ ANT_LIB="${JAVALIBDIR}/ant"
+fi
+
+# add in the dependency .jar files in non-RPM mode (the default)
+for i in "${ANT_LIB}"/*.jar
+do
+ # if the directory is empty, then it will return the input string
+ # this is stupid, so case for it
+ if [ -f "$i" ] ; then
+ if [ -z "$LOCALCLASSPATH" ] ; then
+ LOCALCLASSPATH="$i"
+ else
+ LOCALCLASSPATH="$i":"$LOCALCLASSPATH"
+ fi
fi
+done
- # Explicitly add javac path to classpath, assume JAVA_HOME set
- # properly in rpm mode
+if [ -n "$JAVA_HOME" ] ; then
if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar"
fi
+
if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then
LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip"
fi
- # if CLASSPATH_OVERRIDE env var is set, LOCALCLASSPATH will be
- # user CLASSPATH first and ant-found jars after.
- # In that case, the user CLASSPATH will override ant-found jars
- #
- # if CLASSPATH_OVERRIDE is not set, we'll have the normal behaviour
- # with ant-found jars first and user CLASSPATH after
- if [ -n "$CLASSPATH" ] ; then
- # merge local and specified classpath
- if [ -z "$LOCALCLASSPATH" ] ; then
- LOCALCLASSPATH="$CLASSPATH"
- elif [ -n "$CLASSPATH_OVERRIDE" ] ; then
- LOCALCLASSPATH="$CLASSPATH:$LOCALCLASSPATH"
- else
- LOCALCLASSPATH="$LOCALCLASSPATH:$CLASSPATH"
- fi
-
- # remove class path from launcher -cp option
- CLASSPATH=""
- fi
-else
- # not using rpm_mode; use launcher to determine classpaths
- if [ -z "$LOCALCLASSPATH" ] ; then
- LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar
- else
- LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH
- fi
-fi
-
-if [ -n "$JAVA_HOME" ] ; then
# OSX hack to make Ant work with jikes
if $darwin ; then
- OSXHACK="${JAVA_HOME}/../Classes"
- if [ -d "${OSXHACK}" ] ; then
- for i in "${OSXHACK}"/*.jar
+ OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes"
+ if [ -d ${OSXHACK} ] ; then
+ for i in ${OSXHACK}/*.jar
do
JIKESPATH="$JIKESPATH:$i"
done
fi
fi
+else
+ echo "Warning: JAVA_HOME environment variable is not set."
+ echo " If build fails because sun.* classes could not be found"
+ echo " you will need to set the JAVA_HOME environment variable"
+ echo " to the installation directory of java."
fi
# Allow Jikes support (off by default)
@@ -213,87 +166,27 @@
ANT_OPTS="$ANT_OPTS -Dbuild.compiler=jikes"
fi
-# For Cygwin, switch paths to appropriate format before running java
-# For PATHs convert to unix format first, then to windows format to ensure
-# both formats are supported. Probably this will fail on directories with ;
-# in the name in the path. Let's assume that paths containing ; are more
-# rare than windows style paths on cygwin.
+# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
- if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
- format=mixed
- else
- format=windows
- fi
- ANT_HOME=`cygpath --$format "$ANT_HOME"`
- ANT_LIB=`cygpath --$format "$ANT_LIB"`
- JAVA_HOME=`cygpath --$format "$JAVA_HOME"`
- LCP_TEMP=`cygpath --path --unix "$LOCALCLASSPATH"`
- LOCALCLASSPATH=`cygpath --path --$format "$LCP_TEMP"`
- if [ -n "$CLASSPATH" ] ; then
- CP_TEMP=`cygpath --path --unix "$CLASSPATH"`
- CLASSPATH=`cygpath --path --$format "$CP_TEMP"`
- fi
- CYGHOME=`cygpath --$format "$HOME"`
+ ANT_HOME=`cygpath --path --windows "$ANT_HOME"`
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ LOCALCLASSPATH=`cygpath --path --windows "$LOCALCLASSPATH"`
+ CYGHOME=`cygpath --path --windows "$HOME"`
fi
-# Show script help if requested
-if $show_help ; then
- echo $0 '[script options] [options] [target [target2 [target3] ..]]'
- echo 'Script Options:'
- echo ' --help, --h print this message and ant help'
- echo ' --noconfig suppress sourcing of /etc/ant.conf,'
- echo ' $HOME/.ant/ant.conf, and $HOME/.antrc'
- echo ' configuration files'
- echo ' --usejikes enable use of jikes by default, unless'
- echo ' set explicitly in configuration files'
- echo ' --execdebug print ant exec line generated by this'
- echo ' launch script'
- echo ' '
-fi
-# add a second backslash to variables terminated by a backslash under cygwin
-if $cygwin; then
- case "$ANT_HOME" in
- *\\ )
- ANT_HOME="$ANT_HOME\\"
- ;;
- esac
- case "$CYGHOME" in
- *\\ )
- CYGHOME="$CYGHOME\\"
- ;;
- esac
- case "$JIKESPATH" in
- *\\ )
- JIKESPATH="$JIKESPATH\\"
- ;;
- esac
- case "$LOCALCLASSPATH" in
- *\\ )
- LOCALCLASSPATH="$LOCALCLASSPATH\\"
- ;;
- esac
- case "$CLASSPATH" in
- *\\ )
- CLASSPATH="$CLASSPATH\\"
- ;;
- esac
-fi
-# Execute ant using eval/exec to preserve spaces in paths,
-# java options, and ant args
-ant_sys_opts=
if [ -n "$CYGHOME" ]; then
if [ -n "$JIKESPATH" ]; then
- ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\" -Dcygwin.user.home=\"$CYGHOME\""
+ JIKESPATH=`cygpath --path --windows "$JIKESPATH"`
+ "$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Djikes.class.path="$JIKESPATH" -Dcygwin.user.home="$CYGHOME" $ANT_OPTS org.apache.tools.ant.Main $ANT_ARGS "$@"
else
- ant_sys_opts="-Dcygwin.user.home=\"$CYGHOME\""
+ "$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Dcygwin.user.home="$CYGHOME" $ANT_OPTS org.apache.tools.ant.Main $ANT_ARGS "$@"
fi
else
if [ -n "$JIKESPATH" ]; then
- ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\""
+ "$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Djikes.class.path="$JIKESPATH" $ANT_OPTS org.apache.tools.ant.Main $ANT_ARGS "$@"
+ else
+ "$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" $ANT_OPTS org.apache.tools.ant.Main $ANT_ARGS "$@"
fi
fi
-ant_exec_command="exec \"$JAVACMD\" $ANT_OPTS -classpath \"$LOCALCLASSPATH\" -Dant.home=\"$ANT_HOME\" -Dant.library.dir=\"$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"$CLASSPATH\" $ant_exec_args"
-if $ant_exec_debug ; then
- echo $ant_exec_command
-fi
-eval $ant_exec_command
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/bin/ant
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossbuild/buildmagic/trunk/tools/bin/ant.bat
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/ant.bat 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/ant.bat 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,23 +1,11 @@
@echo off
-REM Copyright 2001,2004-2005 The Apache Software Foundation
-REM
-REM Licensed under the Apache License, Version 2.0 (the "License");
-REM you may not use this file except in compliance with the License.
-REM You may obtain a copy of the License at
-REM
-REM http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing, software
-REM distributed under the License is distributed on an "AS IS" BASIS,
-REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM See the License for the specific language governing permissions and
-REM limitations under the License.
+REM Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+REM reserved.
if exist "%HOME%\antrc_pre.bat" call "%HOME%\antrc_pre.bat"
if "%OS%"=="Windows_NT" @setlocal
-if "%OS%"=="WINNT" @setlocal
rem %~dp0 is expanded pathname of the current script under NT
set DEFAULT_ANT_HOME=%~dp0..
@@ -25,8 +13,6 @@
if "%ANT_HOME%"=="" set ANT_HOME=%DEFAULT_ANT_HOME%
set DEFAULT_ANT_HOME=
-set _USE_CLASSPATH=yes
-
rem Slurp the command line arguments. This loop allows for an unlimited number
rem of arguments (up to the command line limit, anyway).
set ANT_CMD_LINE_ARGS=%1
@@ -34,39 +20,31 @@
shift
:setupArgs
if ""%1""=="""" goto doneStart
-if ""%1""==""-noclasspath"" goto clearclasspath
set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1
shift
goto setupArgs
-
-rem here is there is a -noclasspath in the options
-:clearclasspath
-set _USE_CLASSPATH=no
-shift
-goto setupArgs
-
-rem This label provides a place for the argument list loop to break out
+rem This label provides a place for the argument list loop to break out
rem and for NT handling to skip to.
-
:doneStart
+
rem find ANT_HOME if it does not exist due to either an invalid value passed
rem by the user or the %0 problem on Windows 9x
-if exist "%ANT_HOME%\lib\ant.jar" goto checkJava
+if exist "%ANT_HOME%" goto checkJava
-rem check for ant in Program Files
-if not exist "%ProgramFiles%\ant" goto checkSystemDrive
-set ANT_HOME=%ProgramFiles%\ant
+rem check for ant in Program Files on system drive
+if not exist "%SystemDrive%\Program Files\ant" goto checkSystemDrive
+set ANT_HOME=%SystemDrive%\Program Files\ant
goto checkJava
:checkSystemDrive
rem check for ant in root directory of system drive
-if not exist %SystemDrive%\ant\lib\ant.jar goto checkCDrive
+if not exist %SystemDrive%\ant\nul goto checkCDrive
set ANT_HOME=%SystemDrive%\ant
goto checkJava
:checkCDrive
rem check for ant in C:\ant for Win9X users
-if not exist C:\ant\lib\ant.jar goto noAntHome
+if not exist C:\ant\nul goto noAntHome
set ANT_HOME=C:\ant
goto checkJava
@@ -75,51 +53,42 @@
goto end
:checkJava
-set _JAVACMD=%JAVACMD%
+set LOCALCLASSPATH=%CLASSPATH%
+for %%i in ("%ANT_HOME%\lib\*.jar") do call "%ANT_HOME%\bin\lcp.bat" %%i
if "%JAVA_HOME%" == "" goto noJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
-if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe
+set _JAVACMD=%JAVA_HOME%\bin\java.exe
+if exist "%JAVA_HOME%\lib\tools.jar" call "%ANT_HOME%\bin\lcp.bat" "%JAVA_HOME%\lib\tools.jar"
+if exist "%JAVA_HOME%\lib\classes.zip" call "%ANT_HOME%\bin\lcp.bat" "%JAVA_HOME%\lib\classes.zip"
goto checkJikes
:noJavaHome
-if "%_JAVACMD%" == "" set _JAVACMD=java.exe
+set _JAVACMD=java.exe
+echo.
+echo Warning: JAVA_HOME environment variable is not set.
+echo If build fails because sun.* classes could not be found
+echo you will need to set the JAVA_HOME environment variable
+echo to the installation directory of java.
+echo.
:checkJikes
if not "%JIKESPATH%"=="" goto runAntWithJikes
:runAnt
-if "%_USE_CLASSPATH%"=="no" goto runAntNoClasspath
-if not "%CLASSPATH%"=="" goto runAntWithClasspath
-"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%
+"%_JAVACMD%" -classpath "%LOCALCLASSPATH%" "-Dant.home=%ANT_HOME%" %ANT_OPTS% org.apache.tools.ant.Main %ANT_CMD_LINE_ARGS%
goto end
-:runAntNoClasspath
-"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%
-goto end
-
-:runAntWithClasspath
-"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp "%CLASSPATH%" %ANT_CMD_LINE_ARGS%
-goto end
-
:runAntWithJikes
-if "%_USE_CLASSPATH%"=="no" goto runAntWithJikesNoClasspath
-if not "%CLASSPATH%"=="" goto runAntWithJikesAndClasspath
-
-:runAntWithJikesNoClasspath
-"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%
+"%_JAVACMD%" -classpath "%LOCALCLASSPATH%" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" %ANT_OPTS% org.apache.tools.ant.Main %ANT_CMD_LINE_ARGS%
goto end
-:runAntWithJikesAndClasspath
-"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp "%CLASSPATH%" %ANT_CMD_LINE_ARGS%
-goto end
-
:end
+set LOCALCLASSPATH=
set _JAVACMD=
set ANT_CMD_LINE_ARGS=
if "%OS%"=="Windows_NT" @endlocal
-if "%OS%"=="WINNT" @endlocal
:mainEnd
if exist "%HOME%\antrc_post.bat" call "%HOME%\antrc_post.bat"
Modified: labs/jbossbuild/buildmagic/trunk/tools/bin/antRun
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/antRun 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/antRun 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,21 +1,7 @@
-#!/bin/sh
+#! /bin/sh
-#
-# Copyright 2001-2002,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.
-#
-#
+# Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+# reserved.
# Args: DIR command
cd "$1"
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/bin/antRun
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossbuild/buildmagic/trunk/tools/bin/antRun.bat
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/antRun.bat 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/antRun.bat 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,24 +1,9 @@
@echo off
-REM
-REM Copyright 2001-2002,2004-2005 The Apache Software Foundation
-REM
-REM Licensed under the Apache License, Version 2.0 (the "License");
-REM you may not use this file except in compliance with the License.
-REM You may obtain a copy of the License at
-REM
-REM http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing, software
-REM distributed under the License is distributed on an "AS IS" BASIS,
-REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM See the License for the specific language governing permissions and
-REM limitations under the License.
-REM
-REM
+REM Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+REM reserved.
if "%OS%"=="Windows_NT" @setlocal
-if "%OS%"=="WINNT" @setlocal
if ""%1""=="""" goto runCommand
@@ -43,5 +28,4 @@
%ANT_RUN_CMD%
if "%OS%"=="Windows_NT" @endlocal
-if "%OS%"=="WINNT" @endlocal
Added: labs/jbossbuild/buildmagic/trunk/tools/bin/antRun.pl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/antRun.pl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/antRun.pl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+#######################################################################
+#
+# antRun.pl
+#
+# wrapper script for invoking commands on a platform with Perl installed
+# this is akin to antRun.bat, and antRun the SH script
+#
+# created: 2001-10-18
+# last modified: 2001-11-13
+# author: Jeff Tulley jtulley at novell.com
+#######################################################################
+#be fussy about variables
+use strict;
+
+#turn warnings on during dev; generates a few spurious uninitialised var access warnings
+#use warnings;
+
+#and set $debug to 1 to turn on trace info (currently unused)
+my $debug=1;
+
+#######################################################################
+# change drive and directory to "%1"
+my $ANT_RUN_CMD = @ARGV[0];
+
+# assign current run command to "%2"
+chdir (@ARGV[0]) || die "Can't cd to $ARGV[0]: $!\n";
+if ($^O eq "NetWare") {
+ # There is a bug in Perl 5 on NetWare, where chdir does not
+ # do anything. On NetWare, the following path-prefixed form should
+ # always work. (afaict)
+ $ANT_RUN_CMD .= "/". at ARGV[1];
+}
+else {
+ $ANT_RUN_CMD = @ARGV[1];
+}
+
+# dispose of the first two arguments, leaving only the command's args.
+shift;
+shift;
+
+# run the command
+my $returnValue = system $ANT_RUN_CMD, @ARGV;
+if ($returnValue eq 0) {
+ exit 0;
+}
+else {
+ # only 0 and 1 are widely recognized as exit values
+ # so change the exit value to 1
+ exit 1;
+}
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/bin/antRun.pl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/bin/build.bat
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/build.bat (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/build.bat 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,83 @@
+ at echo off
+rem
+rem Invokes the 'ant.bat' script from the 'tools' module.
+rem
+rem @author Jason Dillon <jason at planet57.com>
+rem
+
+rem $Id$
+
+setlocal
+
+set PROGNAME=%~nx0
+set DIRNAME=%~dp0
+
+rem Legacy shell support
+if x%PROGNAME%==x set PROGNAME=build.bat
+if x%DIRNAME%==x set DIRNAME=.\
+
+rem If not started by the loader script then setup some values
+if x%TOOLS_ROOT%==x set TOOLS_ROOT=%DIRNAME%..
+if x%MODULE_ROOT%==x set MODULE_ROOT=.
+
+rem Setup ant variables
+set ANT=%TOOLS_ROOT%\bin\ant.bat
+set ANT_HOME=%TOOLS_ROOT%
+if x%ANT_LOGGER%==x set ANT_LOGGER=org.apache.tools.ant.NoBannerLogger
+set ANT_OPTIONS=%ANT_OPTIONS% -logger %ANT_LOGGER%
+
+rem Set the minimum and maximum VM heap size
+if x%JVM_MS%==x set JVM_MS=32m
+if x%JVM_MX%==x set JVM_MX=640m
+if x%ANT_OPTS%==x set ANT_OPTS=-Xms%JVM_MS% -Xmx%JVM_MX%
+
+rem Save the arguments to the script
+set ARGS=%*
+
+rem Ignore the user's classpath
+set CLASSPATH=
+
+rem Start'er up yo
+goto main
+
+:debug
+if not x%DEBUG%==x echo %PROGNAME%: %*
+goto :EOF
+
+:set-jaxp
+set ANT_OPTS=%ANT_OPTS% -Djavax.xml.parsers.DocumentBuilderFactory=%1
+set ANT_OPTS=%ANT_OPTS% -Djavax.xml.parsers.SAXParserFactory=%2
+goto :EOF
+
+:main
+call :debug PROGNAME=%PROGNAME%
+call :debug DIRNAME=%DIRNAME%
+call :debug TOOLS_ROOT=%TOOLS_ROOT%
+call :debug MODULE_ROOT=%MODULE_ROOT%
+
+rem Setup JAXP impl
+if x%JAXP%==x set JAXP=crimson
+if %JAXP%==crimson call :set-jaxp org.apache.crimson.jaxp.DocumentBuilderFactoryImpl org.apache.crimson.jaxp.SAXParserFactoryImpl
+if %JAXP%==xerces call :set-jaxp org.apache.xerces.jaxp.DocumentBuilderFactoryImpl org.apache.xerces.jaxp.SAXParserFactoryImpl
+rem could complain if invalid JAXP here, but for now forget it
+
+rem Check if the script exits
+if exist %ANT% goto :execute-ant & goto :EOF
+
+echo %PROGNAME%: *ERROR* The ant script does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%: %ANT%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools'
+echo %PROGNAME%: module and make sure it is up to date.
+goto :EOF
+
+:execute-ant
+call :debug Ant JVM options: %ANT_OPTS%
+
+echo Executing %ANT% %ANT_OPTIONS% %ARGS%
+call %ANT% %ANT_OPTIONS% %ARGS%
+
+if x%NOPAUSE%==x pause
+
+goto :EOF
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/bin/build.bat
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/bin/build.sh
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/build.sh (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/build.sh 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,145 @@
+#!/bin/sh
+##
+## Sets up the basic environment for Ant and then starts it.
+##
+## @author Jason Dillon <jason at planet57.com>
+##
+
+# $Id$
+
+# If we are running under Cygwin do some translation
+if [ ! -z "$COMSPEC" ]; then
+ temp=`cygpath --unix $0`
+else
+ temp="$0"
+fi
+PROGNAME=`basename $temp`
+DIRNAME=`dirname $temp`
+
+# If we have not been included from the loader script setup some values
+if [ "x$TOOLS_ROOT" = "x" ]; then
+ TOOLS_ROOT=`cd $DIRNAME/.. && pwd`
+fi
+if [ "x$MODULE_ROOT" = "x" ]; then
+ MODULE_ROOT=`pwd`;
+fi
+if [ "$CYGWIN" = true ]; then
+ TOOLS_ROOT=`cygpath --unix $TOOLS_ROOT`
+fi
+
+# Include common /bin/sh functions
+. "$TOOLS_ROOT/bin/common.shlib"
+
+# The minimum and maximum VM heap size
+xset JVM_MS="32m"
+xset JVM_MX="640m"
+
+# Detect which OS we are on
+check_os
+
+TOOLS_ROOT=`convertpath --unix $TOOLS_ROOT`
+MODULE_ROOT=`convertpath --unix $MODULE_ROOT`
+debug "TOOLS_ROOT: $TOOLS_ROOT"
+debug "MODULE_ROOT: $MODULE_ROOT"
+
+# Setup defaults
+xset MAX_FD "maximum"
+xset JAXP "crimson"
+
+# Ignore user's ANT_HOME if it is set
+if [ "x$ANT_HOME" != "x" ]; then
+ warn "Ignoring environment value for \$ANT_HOME"
+fi
+ANT_HOME=`convertpath --unix $TOOLS_ROOT`
+debug "Ant home: $ANT_HOME"
+
+# Use the color logger if requested
+if [ "x$ANT_COLOR" != "x" ]; then
+ xset ANT_LOGGER "org.apache.tools.ant.listener.AnsiColorLogger"
+else
+ xset ANT_LOGGER "org.apache.tools.ant.NoBannerLogger"
+fi
+debug "Using Ant logger: $ANT_LOGGER"
+
+# The nitty gritty dirty fluffy fluff
+main() {
+ # if there is a build config file. then source it
+ maybe_source "$MODULE_ROOT/build.conf" "$HOME/.build.conf"
+
+ # Increase the maximum file descriptors if we can
+ if [ $WIN32 = "false" ]; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ]; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
+ # use the system max
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ]; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+ fi
+
+ # Make sure we have one
+ ANT="$ANT_HOME/bin/ant"
+ if [ ! -x "$ANT" ]; then
+ die "Ant script is not executable: $ANT"
+ fi
+
+ # Specify the jaxp parser impls to use
+ debug "JAXP type: $JAXP"
+ case "$JAXP" in
+ crimson)
+ JAXP_DOM_FACTORY="org.apache.crimson.jaxp.DocumentBuilderFactoryImpl"
+ JAXP_SAX_FACTORY="org.apache.crimson.jaxp.SAXParserFactoryImpl"
+ ;;
+
+ xerces)
+ JAXP_DOM_FACTORY="org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"
+ JAXP_SAX_FACTORY="org.apache.xerces.jaxp.SAXParserFactoryImpl"
+ ;;
+
+ *)
+ die "Unknown JAXP impl: $JAXP; define \$JAXP_DOM_FACTORY and \$JAXP_SAX_FACTORY"
+ ;;
+ esac
+
+ # Set the options which ant will pass to its JVM
+ xset ANT_OPTS "-Xms$JVM_MS -Xmx$JVM_MX"
+
+ if [ "x$JAXP_DOM_FACTORY" != "x" ]; then
+ ANT_OPTS="$ANT_OPTS -Djavax.xml.parsers.DocumentBuilderFactory=$JAXP_DOM_FACTORY"
+ fi
+ if [ "x$JAXP_SAX_FACTORY" != "x" ]; then
+ ANT_OPTS="$ANT_OPTS -Djavax.xml.parsers.SAXParserFactory=$JAXP_SAX_FACTORY"
+ fi
+ debug "Ant JVM options: $ANT_OPTS"
+
+ # Add some options to Ant
+ xset ANT_OPTIONS "-logger $ANT_LOGGER"
+
+ # Unset the classpath so it will not interfear
+ CLASSPATH=""
+
+ # Export some stuff for Ant
+ export ANT ANT_HOME ANT_OPTS CLASSPATH
+
+ # Change to the directory where the script lives so users are not forced
+ # to be in the same directory as build.xml
+ debug "Entering $MODULE_ROOT"
+ cd $MODULE_ROOT
+
+ notice "Executing: $ANT $ANT_OPTIONS $@"
+ if [ "x$TRACE" != "x" ]; then
+ exec /bin/sh -x $ANT $ANT_OPTIONS "$@"
+ else
+ exec $ANT $ANT_OPTIONS "$@"
+ fi
+}
+
+# Lets get ready to rumble!
+main "$@"
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/bin/build.sh
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/bin/common.shlib
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/common.shlib (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/common.shlib 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,189 @@
+#!/bin/sh
+##
+## Definitions of common /bin/sh functions.
+##
+## @author Jason Dillon <jason at planet57.com>
+##
+
+# $Id: common.shlib,v 1.2 2002/10/06 10:58:51 user57 Exp $
+
+xset() # <var_name> <value>
+{
+ id=$1; shift; eval "value=\${$id}"
+ if [ "$value" = "" ]; then
+ eval "${id}=\"$*\""
+ fi
+}
+
+xset UNAME "uname"
+xset GAWK "gawk"
+xset EGREP "egrep"
+
+die() {
+ echo "${PROGNAME}: *FATAL* $*"
+ exit 1
+}
+
+warn() {
+ echo "${PROGNAME}: *WARNING* $*"
+}
+
+notice() {
+ echo "${PROGNAME}: $*"
+}
+
+debug() {
+ if [ "x$DEBUG" != "x" ]; then
+ echo "${PROGNAME}: $*"
+ fi
+}
+
+search() {
+ mode="$1"; shift
+ suffix="$1"; shift
+ search="$*"
+
+ for d in $search; do
+ x="$d/$suffix"
+ if [ $mode "$x" ]; then
+ # found a match
+ echo $d
+ break
+ fi
+ done
+}
+
+call () # <func_name>
+{
+ if [ -r "$RC" ]; then
+ temp=`$EGREP "^${1} \(\)" $RC`
+ if [ "$temp" != "" ]; then
+ eval $1
+ fi
+ fi
+}
+
+push () # <var_name> <list>
+{
+ _id=$1; _value=; shift
+ while [ "$1" != "" ]; do
+ eval "_value=$`echo $_id`"
+ eval "${_id}='`echo $_value` $1'"
+ shift
+ done
+ unset _id _value
+}
+
+prepend () # <var_name> <value>
+{
+ _id=$1; _value=; shift
+ eval "_value=$`echo $_id`"
+ eval "${_id}='${1}`echo $_value`'"
+ unset _id _value
+}
+
+append () # <var_name> <value>
+{
+ _id=$1; _value=; shift
+ eval "_value=$`echo $_id`"
+ eval "${_id}='`echo $_value`$1'"
+ unset _id _value
+}
+
+source () # <file_list>
+{
+ for file in "$*"; do
+ . $file
+ done
+}
+
+dump_var () # <var_name>
+{
+ _id=$1; _value=
+ eval "_value=$`echo $_id`"
+ echo "${_id}: $_value"
+}
+
+math () # <expression>
+{
+ echo `$GAWK "BEGIN { print $* }"`
+}
+
+pick () # <index> <list>
+{
+ c=1; i="$1"; shift
+ while [ "$c" -lt "$i" ]; do
+ c=`math $c + 1`
+ shift
+ done
+ echo "$1"
+}
+
+random () # <list>
+{
+ c=`echo $* | $WC -w`
+ i=`$GAWK "BEGIN{ srand(); print int( 1 + ( 1000000 * rand() ) % $c ) }"`
+ echo "`pick $i $*`"
+}
+
+check_arg () # <option_name> <expected_value>
+{
+ if [ "$2" = "" ]; then
+ die "option '$1' requires an additional argument"
+ fi
+}
+
+check_os()
+{
+ # OS specific support (must be 'true' or 'false').
+ CYGWIN=false
+ DARWIN=false
+ WIN32=false
+ export CYGWIN DARWIN WIN32
+
+ systype=`$UNAME`
+ debug "System Type: $systype"
+ if [ -z "$systype" ]; then
+ die "Unable to determine system type; uname return null output."
+ fi
+
+ case "$systype" in
+ CYGWIN*)
+ CYGWIN=true
+ WIN32=true
+ debug "Detected CYGWIN"
+ ;;
+
+ Darwin*)
+ DARWIN=true
+ debug "Detected DARWIN (MacOS X)"
+ ;;
+
+ *)
+ if [ ! -z "$COMSPEC" ]; then
+ WIN32=true
+ debug "Detected generic win32 environemnt"
+ fi
+ ;;
+ esac
+}
+
+maybe_source() {
+ for file in $*; do
+ if [ -f "$file" ]; then
+ . $file
+ fi
+ done
+}
+
+convertpath()
+{
+ options=$1; shift
+ temp=$*
+ if [ "$CYGWIN" = true ]; then
+ temp=`cygpath $options $temp`
+ fi
+ echo $temp
+}
+
+debug "Common functions loaded"
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/bin/common.shlib
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/bin/complete-ant-cmd.pl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/complete-ant-cmd.pl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/complete-ant-cmd.pl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,102 @@
+#!/usr/bin/perl
+#
+# Copyright (c) 2001 The Apache Software Foundation. All rights
+# reserved.
+#
+# A script to allow Bash or Z-Shell to complete an Ant command-line.
+#
+# To install for Bash 2.0 or better, add the following to ~/.bashrc:
+#
+# $ complete -C complete-ant-cmd ant build.sh
+#
+# To install for Z-Shell 2.5 or better, add the following to ~/.zshrc:
+#
+# function ant_complete () {
+# local args_line args
+# read -l args_line
+# set -A args $args_line
+# set -A reply $(COMP_LINE=$args_line complete-ant-cmd ${args[1]} $1)
+# }
+# compctl -K ant_complete ant build.sh
+#
+# @author Mike Williams <mikew at cortexebusiness.com.au>
+
+my $cmdLine = $ENV{'COMP_LINE'};
+my $antCmd = $ARGV[0];
+my $word = $ARGV[1];
+
+my @completions;
+if ($word =~ /^-/) {
+ list( restrict( $word, getArguments() ));
+} elsif ($cmdLine =~ /-(f|buildfile)\s+\S*$/) {
+ list( getBuildFiles($word) );
+} else {
+ list( restrict( $word, getTargets() ));
+}
+
+exit(0);
+
+sub list {
+ for (@_) {
+ print "$_\n";
+ }
+}
+
+sub restrict {
+ my ($word, @completions) = @_;
+ grep( /^\Q$word\E/, @completions );
+}
+
+sub getArguments {
+ qw(-buildfile -debug -emacs -f -find -help -listener -logfile
+ -logger -projecthelp -quiet -verbose -version);
+}
+
+
+sub getBuildFiles {
+ my ($word) = @_;
+ grep( /\.xml$/, glob( "$word*" ));
+}
+
+sub getTargets {
+
+ # Look for build-file
+ my $buildFile = 'build.xml';
+ if ($cmdLine =~ /-(f|buildfile)\s+(\S+)/) {
+ $buildFile = $2;
+ }
+ return () unless (-f $buildFile);
+
+ # Run "ant -projecthelp" to list targets. Keep a cache of results in a
+ # cache-file.
+ my $cacheFile = $buildFile;
+ $cacheFile =~ s|(.*/)?(.*)|${1}.ant-targets-${2}|;
+ if ((!-e $cacheFile) || (-M $buildFile) < (-M $cacheFile)) {
+ open( CACHE, '>'.$cacheFile ) || die "can\'t write $cacheFile: $!\n";
+ open( HELP, "$antCmd -projecthelp -f '$buildFile'|" ) || return();
+ my %targets;
+ while( <HELP> ) {
+ if (/^\s+(\S+)/) {
+ $targets{$1}++;
+ }
+ }
+ my @targets = sort keys %targets;
+ for (@targets) { print CACHE "$_\n"; }
+ return @targets;
+ }
+
+ # Read the target-cache
+ open( CACHE, $cacheFile ) || die "can\'t read $cacheFile: $!\n";
+ my @targets;
+ while (<CACHE>) {
+ chop;
+ s/\r$//; # for Cygwin
+ push( @targets, $_ );
+ }
+ close( CACHE );
+ @targets;
+
+}
+
+
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/bin/complete-ant-cmd.pl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: labs/jbossbuild/buildmagic/trunk/tools/bin/lcp.bat
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/lcp.bat 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/lcp.bat 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,19 +1,5 @@
-REM
-REM Copyright 2001-2004 The Apache Software Foundation
-REM
-REM Licensed under the Apache License, Version 2.0 (the "License");
-REM you may not use this file except in compliance with the License.
-REM You may obtain a copy of the License at
-REM
-REM http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing, software
-REM distributed under the License is distributed on an "AS IS" BASIS,
-REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM See the License for the specific language governing permissions and
-REM limitations under the License.
-REM
-REM
+REM Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+REM reserved.
set _CLASSPATHCOMPONENT=%1
if ""%1""=="""" goto gotAllArgs
Added: labs/jbossbuild/buildmagic/trunk/tools/bin/runant.pl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/runant.pl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/runant.pl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,162 @@
+#!/usr/bin/perl
+#
+# Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+# reserved.
+#
+#######################################################################
+#
+# runant.pl
+#
+# wrapper script for invoking ant in a platform with Perl installed
+# this may include cgi-bin invocation, which is considered somewhat daft.
+# (slo: that should be a separate file which can be derived from this
+# and returns the XML formatted output)
+#
+# the code is not totally portable due to classpath and directory splitting
+# issues. oops. (NB, use File::Spec::Functions will help and the code is
+# structured for the catfile() call, but because of perl version funnies
+# the code is not included.
+#
+# created: 2000-8-24
+# last modified: 2000-8-24
+# author: Steve Loughran steve_l at sourceforge.net
+#######################################################################
+#
+# Assumptions:
+#
+# - the "java" executable/script is on the command path
+# - ANT_HOME has been set
+# - target platform uses ":" as classpath separator or perl indicates it is dos/win32
+# - target platform uses "/" as directory separator.
+
+#be fussy about variables
+use strict;
+
+#platform specifics (disabled)
+#use File::Spec::Functions;
+
+#turn warnings on during dev; generates a few spurious uninitialised var access warnings
+#use warnings;
+
+#and set $debug to 1 to turn on trace info
+my $debug=0;
+
+#######################################################################
+#
+# check to make sure environment is setup
+#
+
+my $HOME = $ENV{ANT_HOME};
+if ($HOME eq "")
+ {
+ die "\n\nANT_HOME *MUST* be set!\n\n";
+ }
+
+my $JAVACMD = $ENV{JAVACMD};
+$JAVACMD = "java" if $JAVACMD eq "";
+
+my $onnetware = 0;
+if ($^O eq "NetWare")
+{
+ $onnetware = 1;
+}
+
+#ISSUE: what java wants to split up classpath varies from platform to platform
+#and perl is not too hot at hinting which box it is on.
+#here I assume ":" 'cept on win32, dos, and netware. Add extra tests here as needed.
+my $s=":";
+if(($^O eq "MSWin32") || ($^O eq "dos") || ($^O eq "cygwin") ||
+ ($onnetware == 1))
+ {
+ $s=";";
+ }
+
+#build up standard classpath
+my $localpath=$ENV{CLASSPATH};
+if ($localpath eq "")
+ {
+ print "warning: no initial classpath\n" if ($debug);
+ $localpath="";
+ }
+if ($onnetware == 1)
+{
+# avoid building a command line bigger than 512 characters - make localpath
+# only include the "extra" stuff, and add in the system classpath as an expanded
+# variable.
+ $localpath="";
+}
+
+#add jar files. I am sure there is a perl one liner to do this.
+my $jarpattern="$HOME/lib/*.jar";
+my @jarfiles =glob($jarpattern);
+print "jarfiles=@jarfiles\n" if ($debug);
+my $jar;
+foreach $jar (@jarfiles )
+ {
+ $localpath.="$s$jar";
+ }
+
+#if Java home is defined, look for tools.jar & classes.zip and add to classpath
+my $JAVA_HOME = $ENV{JAVA_HOME};
+if ($JAVA_HOME ne "")
+ {
+ my $tools="$JAVA_HOME/lib/tools.jar";
+ if (-e "$tools")
+ {
+ $localpath .= "$s$tools";
+ }
+ my $classes="$JAVA_HOME/lib/classes.zip";
+ if (-e $classes)
+ {
+ $localpath .= "$s$classes";
+ }
+ }
+else
+ {
+ print "\n\nWarning: JAVA_HOME environment variable is not set.\n".
+ "If the build fails because sun.* classes could not be found\n".
+ "you will need to set the JAVA_HOME environment variable\n".
+ "to the installation directory of java\n";
+ }
+
+#set JVM options and Ant arguments, if any
+my @ANT_OPTS=split(" ", $ENV{ANT_OPTS});
+my @ANT_ARGS=split(" ", $ENV{ANT_ARGS});
+
+#jikes
+if($ENV{JIKESPATH} ne "")
+ {
+ push @ANT_OPTS, "-Djikes.class.path=$ENV{JIKESPATH}";
+ }
+
+#construct arguments to java
+my @ARGS;
+if ($onnetware == 1)
+{
+# make classpath literally $CLASSPATH; and then the contents of $localpath
+# this is to avoid pushing us over the 512 character limit
+# even skip the ; - that is already in $localpath
+ push @ARGS, "-classpath", "\$CLASSPATH$localpath";
+}
+else
+{
+ push @ARGS, "-classpath", "$localpath";
+}
+push @ARGS, "-Dant.home=$HOME";
+push @ARGS, @ANT_OPTS;
+push @ARGS, "org.apache.tools.ant.Main", @ANT_ARGS;
+push @ARGS, @ARGV;
+
+print "\n $JAVACMD @ARGS\n\n" if ($debug);
+
+my $returnValue = system $JAVACMD, @ARGS;
+if ($returnValue eq 0)
+ {
+ exit 0;
+ }
+else
+ {
+ # only 0 and 1 are widely recognized as exit values
+ # so change the exit value to 1
+ exit 1;
+ }
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/bin/runant.pl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/bin/runant.py
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/runant.py (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/runant.py 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,99 @@
+#!/usr/bin/python
+"""
+
+ runant.py
+
+ This script is a translation of the runant.pl written by Steve Loughran.
+ It runs ant with/out arguments, it should be quite portable (thanks to
+ the python os library)
+ This script has been tested with Python2.0/Win2K
+
+ Copyright (c) 2001 The Apache Software Foundation. All rights
+ reserved.
+
+ created: 2001-04-11
+ author: Pierre Dittgen pierre.dittgen at criltelecom.com
+
+ Assumptions:
+
+ - the "java" executable/script is on the command path
+ - ANT_HOME has been set
+"""
+import os, os.path, string, sys
+
+# Change it to 1 to get extra debug information
+debug = 0
+
+#######################################################################
+#
+# check to make sure environment is setup
+#
+if not os.environ.has_key('ANT_HOME'):
+ print '\n\nANT_HOME *MUST* be set!\n\n'
+ sys.exit(1)
+else:
+ ANT_HOME = os.environ['ANT_HOME']
+
+if not os.environ.has_key('JAVACMD'):
+ JAVACMD = 'java'
+else:
+ JAVACMD = os.environ['JAVACMD']
+
+# Sets the separator char for CLASSPATH
+SEPARATOR = ':'
+if os.name == 'dos' or os.name == 'nt':
+ SEPARATOR = ';'
+
+# Build up standard classpath
+localpath = ''
+if os.environ.has_key('CLASSPATH'):
+ localpath = os.environ['CLASSPATH']
+else:
+ if debug:
+ print 'Warning: no initial classpath\n'
+
+# Add jar files
+LIBDIR = os.path.join(ANT_HOME, 'lib')
+jarfiles = []
+for file in os.listdir(LIBDIR):
+ if file[-4:] == '.jar':
+ jarfiles.append(os.path.join(LIBDIR,file))
+if debug:
+ print 'Jar files:'
+ for jar in jarfiles:
+ print jar
+localpath = localpath + SEPARATOR + string.join(jarfiles, SEPARATOR)
+
+# If JAVA_HOME is defined, look for tools.jar & classes.zip
+# and add to classpath
+if os.environ.has_key('JAVA_HOME') and os.environ['JAVA_HOME'] != '':
+ JAVA_HOME = os.environ['JAVA_HOME']
+ TOOLS = os.path.join(JAVA_HOME, os.path.join('lib', 'tools.jar'))
+ if os.path.exists(TOOLS):
+ localpath = localpath + SEPARATOR + TOOLS
+ CLASSES = os.path.join(JAVA_HOME, os.path.join('lib', 'classes.zip'))
+ if os.path.exists(CLASSES):
+ localpath = localpath + SEPARATOR + CLASSES
+else:
+ print '\n\nWarning: JAVA_HOME environment variable is not set.\n', \
+ 'If the build fails because sun.* classes could not be found\n', \
+ 'you will need to set the JAVA_HOME environment variable\n', \
+ 'to the installation directory of java\n'
+
+# Jikes
+ANT_OPTS = []
+if os.environ.has_key('ANT_OPTS'):
+ ANT_OPTS = string.split(os.environ['ANT_OPTS'])
+if os.environ.has_key('JIKESPATH'):
+ ANT_OPTS.append('-Djikes.class.path=' + os.environ['JIKESPATH'])
+
+# Builds the commandline
+cmdline = '%s -classpath %s -Dant.home=%s %s org.apache.tools.ant.Main %s' \
+ % (JAVACMD, localpath, ANT_HOME, string.join(ANT_OPTS,' '), \
+ string.join(sys.argv[1:], ' '))
+
+if debug:
+ print '\n%s\n\n' % (cmdline)
+
+# Run the biniou!
+os.system(cmdline)
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/bin/runant.py
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/bin/ubuild.bat
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/bin/ubuild.bat (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/bin/ubuild.bat 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,81 @@
+ at echo off
+rem
+rem Invokes the 'build.sh' script from the 'tools' module with
+rem the ASH shell provided by the 'tools-win32' module.
+rem
+rem @author Jason Dillon <jason at planet57.com>
+rem
+
+rem $Id$
+
+setlocal
+
+set PROGNAME=%~nx0
+set DIRNAME=%~dp0
+
+rem Legacy shell support
+if x%PROGNAME%==x set PROGNAME=build.bat
+if x%DIRNAME%==x set DIRNAME=.\
+
+rem If not started by the loader script then setup some values
+if x%TOOLS_ROOT%==x set TOOLS_ROOT=%DIRNAME%..
+if x%MODULE_ROOT%==x set MODULE_ROOT=.
+
+set SHELL=%TOOLS_ROOT%\win32\ash.exe
+set SHELL_OPTS=
+if not x%TRACE%==x set SHELL_OPTS=-x
+
+set BUILD_SH=%TOOLS_ROOT%\bin\build.sh
+set FALLBACK_BUILD_BAT=%TOOLS_ROOT%\bin\fb-build.bat
+set ARGS=%*
+
+rem Setup the command search path to include our binaries
+set PATH=%TOOLS_ROOT%\win32;%TOOLS_ROOT%\bin;%PATH%
+
+rem Start'er up yo
+goto main
+
+:debug
+if not x%DEBUG%==x echo %PROGNAME%: %*
+goto :EOF
+
+:main
+call :debug PROGNAME=%PROGNAME%
+call :debug DIRNAME=%DIRNAME%
+call :debug TOOLS_ROOT=%TOOLS_ROOT%
+call :debug MODULE_ROOT=%MODULE_ROOT%
+call :debug SHELL=%SHELL%
+call :debug PATH=%PATH%
+
+if exist %SHELL% goto :check-script & goto :EOF
+rem else fail, we can not go on (might consider just calling ant here
+rem %FALLBACK_BUILD_BAT%)
+
+echo %PROGNAME%: *ERROR* The command shell does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%: %SHELL%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools-win32'
+echo %PROGNAME%: module and make sure it is up to date.
+goto :EOF
+
+:check-script
+call :debug BUILD_SH=%BUILD_SH%
+if exist %BUILD_SH% goto :execute-shell & goto :EOF
+rem else fail, we can not go on
+
+echo %PROGNAME%: *ERROR* The target script does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%: %BUILD_SH%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools'
+echo %PROGNAME%: module and make sure it is up to date.
+goto :EOF
+
+:execute-shell
+call :debug Executing %SHELL% %SHELL_OPTS% %BUILD_SH% %ARGS%
+%SHELL% %SHELL_OPTS% %BUILD_SH% %ARGS%
+
+if x%NOPAUSE%==x pause
+
+goto :EOF
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/bin/ubuild.bat
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/autoload.properties
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/autoload.properties (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/autoload.properties 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,42 @@
+### ====================================================================== ###
+## ##
+## BuildMagic tasks which will be autoloaded. ##
+## ##
+### ====================================================================== ###
+
+### $Id$ ###
+
+### Stuff that glues things together ###
+
+resolveproperties=org.jboss.tools.buildmagic.task.ResolveProperties
+resolver=org.jboss.tools.buildmagic.task.ResolveProperties
+propertyfilter=org.jboss.tools.buildmagic.task.PropertyFilter
+require=org.jboss.tools.buildmagic.task.Require
+call=org.jboss.tools.buildmagic.task.CallTarget
+Ant=org.jboss.tools.buildmagic.task.Ant
+
+### Project/Module tasks ###
+
+execmodules=org.jboss.tools.buildmagic.task.module.ExecuteModules
+projectinfo=org.jboss.tools.buildmagic.task.module.ProjectInfo
+moduleinfo=org.jboss.tools.buildmagic.task.module.ModuleInfo
+moduleconfig=org.jboss.tools.buildmagic.task.module.ModuleConfig
+moduleinit=org.jboss.tools.buildmagic.task.module.ModuleInit
+
+### Configuration Helpers ###
+library=org.jboss.tools.buildmagic.task.config.Library
+modulelibrary=org.jboss.tools.buildmagic.task.config.ModuleLibrary
+libraryset=org.jboss.tools.buildmagic.task.config.LibrarySet
+
+### Misc ###
+
+projecthelp=org.jboss.tools.buildmagic.task.ProjectHelp
+_puke=org.jboss.tools.buildmagic.task.util.Puke
+_dump=org.jboss.tools.buildmagic.task.util.Dump
+
+### Unused ??? ###
+
+#set=org.jboss.tools.buildmagic.task.Set
+#unset=org.jboss.tools.buildmagic.task.Unset
+#appendpath=org.jboss.tools.buildmagic.task.AppendPath
+#findroot=org.jboss.tools.buildmagic.task.FindRoot
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/autoload.properties
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/buildmagic.ent
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/buildmagic.ent (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/buildmagic.ent 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,270 @@
+<!-- $Id$ -->
+
+<!-- ================================================================== -->
+<!-- Initialization -->
+<!-- ================================================================== -->
+
+<!-- Initialize the build system. -->
+<target name="_buildmagic:init" unless="init.disable">
+
+ <!-- Make sure we have the right version of Ant -->
+ <property name="buildmagic.ant.baseversion" value="1.5"/>
+
+ <!--
+ | Add new conditions for other supported Ant versions when they
+ | become avaialble.
+ -->
+
+ <condition property="buildmagic.ant.compatible">
+ <and>
+ <contains string="${ant.version}"
+ substring="Ant version ${buildmagic.ant.baseversion}"/>
+ </and>
+ </condition>
+
+ <fail unless="buildmagic.ant.compatible">
+
+ Unsupported Ant version:
+
+ ${ant.version}
+
+ Please install a version which is compatible with Ant ${buildmagic.ant.baseversion}.
+
+ </fail>
+
+ <!-- JDK Detection -->
+ <available classname="java.lang.Void" property="HAVE_JDK_1.1"/>
+ <available classname="java.lang.ThreadLocal" property="HAVE_JDK_1.2"/>
+ <available classname="java.lang.StrictMath" property="HAVE_JDK_1.3"/>
+ <available classname="java.lang.StackTraceElement" property="HAVE_JDK_1.4"/>
+
+ <!-- Setup the project environment. -->
+ <dirname property="project.root" file="${basedir}"/>
+ <property name="project.build" value="${project.root}/build"/>
+ <property name="project.tools" value="${project.root}/tools"/>
+ <property name="project.thirdparty" value="${project.root}/thirdparty"/>
+ <property name="project.thirdparty.cache" value="${project.root}/thirdparty-cache"/>
+
+ <!-- Setup the module environment. -->
+ <property name="module.root" value="${basedir}"/>
+ <property file="${module.root}/local.properties"/>
+ <property name="module.source" value="${module.root}/src"/>
+ <property name="module.output" value="${module.root}/output"/>
+ <property name="module.tools" value="${module.root}/tools"/>
+ <property name="module.thirdparty" value="${module.root}/thirdparty"/>
+
+ <!-- Load Buildmagic extention tasks. -->
+ <property name="buildmagic.local.classpath" value="."/>
+ <path id="buildmagic.task.classpath">
+ <fileset dir="${project.tools}/lib">
+ <include name="*"/>
+ </fileset>
+ <pathelement location="${project.tools}/lib"/>
+ <pathelement location="${project.tools}/etc"/>
+ <pathelement location="${project.tools}"/>
+ <pathelement path="${buildmagic.local.classpath}"/>
+ </path>
+ <taskdef file="${project.tools}/etc/buildfragments/autoload.properties"
+ classpathref="buildmagic.task.classpath"/>
+ <taskdef name="property" classname="org.jboss.tools.buildmagic.task.Property"
+ classpathref="buildmagic.task.classpath"/>
+ <taskdef name="dependency-manager"
+ classname="oevren.ant.greebo.FetchDependencyTask"
+ classpathref="buildmagic.task.classpath"/>
+
+ <!-- Include user and project property overrides. -->
+ <property file="${project.build}/local.properties"/>
+ <property file="${user.home}/.buildmagic.properties"/>
+ <property file="${user.home}/.ant.properties"/>
+
+ <call target="_buildmagic:init:local-properties">
+ <available file="${module.root}/etc/local.properties-example"
+ property="init.have-local-properties"/>
+ </call>
+
+ <!-- Setup the build.log -->
+ <call target="_buildmagic:init:buildlog" unless="init-buildlog.disable"/>
+
+ <!-- Load common properties -->
+ <property file="${project.tools}/etc/buildfragments/common.properties"/>
+
+ <!-- Setup the build timestamp & build identifer properties -->
+ <tstamp>
+ <format property="build.number" pattern="yyyyMMddHHmm"/>
+ <format property="YEAR" pattern="yyyy"/>
+ </tstamp>
+ <property name="build.id" value="${build.number}"/>
+
+ <!-- Invoke the configure task -->
+ <call target="configure" unless="configure.disable"/>
+
+ <!-- Load common task properties -->
+ <property file="${project.tools}/etc/buildfragments/task.properties"/>
+
+ <property name="build-bypass.marker" value="${module.output}/build-marker"/>
+
+ <!-- Install filters -->
+ <propertyfilter all="${buildmagic.propertyfilter.all}"/>
+
+ <call target="_buildmagic:init:show-environment" if="init.verbose"/>
+
+ <!-- Finish up -->
+ <property name="init.disable" value="true"/>
+</target>
+
+<!-- Install the local.properties example if it is there -->
+<target name="_buildmagic:init:local-properties">
+ <!-- Setup the local.properties file as needed -->
+ <copy file="${module.root}/etc/local.properties-example"
+ tofile="${module.root}/local.properties" filtering="yes"/>
+ <property file="${module.root}/local.properties"/>
+</target>
+
+<!-- Initialize the build.log -->
+<target name="_buildmagic:init:buildlog">
+ <property name="buildlog.level" value="info"/>
+ <record name="${basedir}/build.log" append="no" loglevel="${buildlog.level}"/>
+ <property name="init-buildlog.disable" value="true" system="true"/>
+</target>
+
+<!-- Show the running environment if -Dinit.verbose=true -->
+<target name="_buildmagic:init:show-environment">
+ <echo><![CDATA[
+project.root: ${project.root}
+module.root: ${module.root}
+user.home: ${user.home}
+build.compiler: ${build.compiler}
+java.home: ${java.home}
+java.class.path: ${java.class.path}
+java.version: ${java.version}
+java.vendor: ${java.vendor}
+java.vm.version: ${java.vm.version}
+java.vm.name: ${java.vm.name}
+java.vm.info: ${java.vm.info}
+os.name: ${os.name}
+os.arch: ${os.arch}
+os.version: ${os.version}
+]]></echo>
+</target>
+
+<!-- ================================================================== -->
+<!-- Build Bypass -->
+<!-- ================================================================== -->
+
+<target name="_buildmagic:build-bypass-checker" depends="init" unless="build-bypass.disabled">
+
+ <uptodate property="build-bypass.on" targetfile="${build-bypass.marker}">
+ <srcfiles dir="${module.source}" includes="**/*"/>
+ <srcfiles dir="${module.root}" includes="build.xml,local.properties"/>
+ <srcfiles dir="${project.root}" includes="build/build.xml,build/local.properties"/>
+ </uptodate>
+
+</target>
+
+<target name="_buildmagic:build-bypass-notice" if="build-bypass.on">
+ <echo>
+Build disabled because module is already built. To force the module
+to build define build-bypass.disabled=true.
+ </echo>
+</target>
+
+<target name="_buildmagic:build-bypass-check" depends="_buildmagic:build-bypass-checker, _buildmagic:build-bypass-notice"/>
+
+
+<!-- ================================================================== -->
+<!-- Cleaning -->
+<!-- ================================================================== -->
+
+<!-- Clean up all build output -->
+<target name="_buildmagic:clean" depends="init">
+ <delete dir="${module.output}"/>
+</target>
+
+<!-- Clean up all generated files -->
+<target name="_buildmagic:clobber" depends="init">
+ <delete file="${module.root}/local.properties"/>
+
+ <!-- Try to stop the build log before we delete the file. -->
+ <record name="${module.root}/build.log" action="stop"/>
+
+ <!--
+ | This file may be opened still due and fail to be removed on win32
+ | systems, so lets just ignore those errors for now.
+ -->
+ <delete file="${module.root}/build.log" quiet="true" failonerror="false"/>
+</target>
+
+
+<!-- ================================================================== -->
+<!-- Help -->
+<!-- ================================================================== -->
+
+<target name="_buildmagic:help:standard" depends="init">
+ <projecthelp taskname="help">
+ <header><![CDATA[
+ The ${module.Name} module.
+]]></header>
+ <footer><![CDATA[
+ -projecthelp for all targets
+ -help for full options
+]]></footer>
+ </projecthelp>
+</target>
+
+<target name="_buildmagic:help:build" depends="init">
+ <projecthelp taskname="help">
+ <header><![CDATA[
+ The ${module.Name} module.
+]]></header>
+ <footer><![CDATA[
+ -Dgroups=<group>[(,<group>)*] Specify the module groups.
+ -Dmodules=<module>[(,<module>)*] Specify the modules.
+ (overrides groups).
+ -projecthelp for all targets
+ -help for full options
+]]></footer>
+ </projecthelp>
+</target>
+
+
+<!-- ================================================================== -->
+<!-- Release -->
+<!-- ================================================================== -->
+
+<target name="_buildmagic:release:zip" depends="init">
+ <zip zipfile="${module.output}/${release.id}.zip">
+ <fileset dir="${module.output}">
+ <include name="${release.id}/**"/>
+ </fileset>
+ </zip>
+</target>
+
+<target name="_buildmagic:release:tar" depends="init">
+ <tar tarfile="${module.output}/${release.id}.tar" longfile="gnu"
+ basedir="${module.output}"
+ includes="${release.id}/**">
+ </tar>
+</target>
+
+<target name="_buildmagic:release:tgz" depends="_buildmagic:release:tar">
+ <gzip src="${module.output}/${release.id}.tar"
+ zipfile="${module.output}/${release.id}.tgz"/>
+</target>
+
+
+<!-- ================================================================== -->
+<!-- Install -->
+<!-- ================================================================== -->
+
+<target name="_buildmagic:install:default" depends="init">
+ <!-- Copy the output directory to the install directory -->
+ <mkdir dir="${install.root}"/>
+ <copy todir="${install.root}" filtering="no">
+ <fileset dir="${module.output}">
+ <include name="**/*"/>
+ <exclude name="${install.id}/**"/>
+ </fileset>
+ </copy>
+</target>
+
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/buildmagic.ent
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/common.properties
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/common.properties (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/common.properties 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,36 @@
+### ====================================================================== ###
+## ##
+## Copyright (c) 1998-2000 by Jason Dillon <jason at planet57.com> ##
+## ##
+## This file is part of BuildMagic; an extension to Ant. ##
+## ##
+## This library is free software; you can redistribute it and/or modify ##
+## it under the terms of the GNU Lesser General Public License as ##
+## published by the Free Software Foundation; either version 2 of the ##
+## License, or (at your option) any later version. ##
+## ##
+## This library is distributed in the hope that it will be useful, but ##
+## WITHOUT ANY WARRANTY; without even the implied warranty of ##
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ##
+## Lesser General Public License for more details. ##
+## ##
+### ====================================================================== ###
+## ##
+## Common Properties ##
+## ##
+### ====================================================================== ###
+
+### $Id$ ###
+
+buildmagic.resolveproperties.force=false
+buildmagic.propertyfilter.all=true
+
+### Jython Support ###
+
+true=1
+false=0
+
+### Misc ###
+
+/=${file.separator}
+sun.boot.classpath=${sun.boot.class.path}
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/common.properties
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/defaults.ent
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/defaults.ent (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/defaults.ent 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,144 @@
+<!-- $Id$ -->
+
+<target name="configure-defaults" unless="configure-defaults.disable">
+
+ <!-- =============== -->
+ <!-- Module defaults -->
+ <!-- =============== -->
+
+ <basename property="module.name" file="${basedir}"/>
+ <property name="module.Name" value="${ant.project.name}"/>
+ <property name="module.version" value="DEV"/>
+
+ <property name="version.major" value="UNKNOWN"/>
+ <property name="version.minor" value="UNKNOWN"/>
+ <property name="version.revision" value="UNKNOWN"/>
+ <property name="version.tag" value="UNKNOWN"/>
+ <property name="version.name" value="UNKNOWN"/>
+
+ <!-- This must be set to the CVS tag for any release -->
+ <property name="version.cvstag" value="UNKNOWN"/>
+
+ <!-- Manifest version info -->
+ <property name="specification.title" value="JBoss"/>
+ <property name="specification.version" value="${version.major}.${version.minor}"/>
+ <property name="specification.vendor" value="JBoss Group, LLC (http://jboss.org)"/>
+
+ <property name="implementation.title" value="JBoss [${version.name}]"/>
+ <property name="implementation.url" value="http://jboss.org"/>
+ <property name="implementation.version"
+ value="${version.major}.${version.minor}.${version.revision}${version.tag} (build: CVSTag=${version.cvstag} date=${build.id})"/>
+ <property name="implementation.vendor" value="JBoss Group, LLC"/>
+ <property name="implementation.vendor.id" value="${implementation.url}"/>
+
+
+ <!-- ========= -->
+ <!-- Locations -->
+ <!-- ========= -->
+
+ <!-- Where source files live -->
+ <property name="source.classes" value="${module.source}/main"/>
+ <property name="source.docs" value="${module.source}/docs"/>
+ <property name="source.etc" value="${module.source}/etc"/>
+ <property name="source.examples" value="${module.source}/examples"/>
+ <property name="source.bin" value="${module.source}/bin"/>
+ <property name="source.resources" value="${module.source}/resources"/>
+ <property name="source.stylesheets" value="${module.source}/stylesheets"/>
+ <property name="source.web" value="${module.source}/web"/>
+ <property name="source.test" value="${module.source}/test"/>
+
+ <!-- Where build generated files will go -->
+ <property name="build.api" value="${module.output}/api"/>
+ <property name="build.bin" value="${module.output}/bin"/>
+ <property name="build.classes" value="${module.output}/classes"/>
+ <property name="build.docs" value="${module.output}/docs"/>
+ <property name="build.stylesheets" value="${module.output}/stylesheets"/>
+ <property name="build.etc" value="${module.output}/etc"/>
+ <property name="build.examples" value="${module.output}/examples"/>
+ <property name="build.gen" value="${module.output}/gen"/>
+ <property name="build.gen.classes" value="${build.gen}/classes"/>
+ <property name="build.jmx-api" value="${module.output}/jmx-api"/>
+ <property name="build.jmx-doc" value="${module.output}/jmx-doc"/>
+ <property name="build.lib" value="${module.output}/lib"/>
+ <property name="build.reports" value="${module.output}/reports"/>
+ <property name="build.resources" value="${module.output}/resources"/>
+ <property name="build.todo" value="${module.output}/todo"/>
+ <property name="build.web" value="${module.output}/web"/>
+ <property name="build.log" value="${module.output}/log"/>
+ <property name="build.cache" value="${module.output}/cache"/>
+ <property name="build.test" value="${module.output}/test"/>
+ <property name="build.gen.test" value="${build.gen}/test"/>
+
+ <!-- Legacy -->
+ <property name="build.metadata" value="${module.output}/metadata"/>
+ <property name="build.gen-src" value="${build.gen.classes}"/>
+ <property name="source.java" value="${source.classes}"/>
+ <property name="source.metadata" value="${module.source}/metadata"/>
+
+ <!-- Install/Release structure -->
+ <property name="install.id" value="${module.name}-${module.version}"/>
+ <property name="release.id" value="${install.id}"/>
+ <property name="install.root" value="${module.output}/${install.id}"/>
+
+ <property name="install.docs" value="${install.root}/docs"/>
+ <property name="install.api" value="${install.docs}/api"/>
+ <property name="install.jmx-api" value="${install.docs}/jmx-api"/>
+ <property name="install.todo" value="${install.docs}/todo"/>
+ <property name="install.examples" value="${install.docs}/examples"/>
+ <property name="install.dtd" value="${install.docs}/dtd"/>
+ <property name="install.bin" value="${install.root}/bin"/>
+ <property name="install.etc" value="${install.root}/etc"/>
+ <property name="install.client" value="${install.root}/client"/>
+ <property name="install.lib" value="${install.root}/lib"/>
+
+
+ <!-- ============= -->
+ <!-- Task defaults -->
+ <!-- ============= -->
+
+ <property name="xdoclet.mergedir" value="${project.tools}/etc/xdoclet/templates"/>
+
+ <!-- Access to environment variables -->
+ <property environment="env"/>
+
+ <!-- The combined thirdparty classpath -->
+ <path id="thirdparty.classpath">
+ <path refid="library.classpath"/>
+ <path refid="dependentmodule.classpath"/>
+ </path>
+
+ <property name="jar.update" value="true"/>
+ <property name="jar.index" value="true"/>
+
+ <property name="javac.depend.dump" value="true"/>
+ <property name="javac.depend.closure" value="false"/>
+ <property name="javac.depend.cachedir" value="${build.cache}/depends"/>
+
+ <property name="javac.target" value="1.3"/>
+ <property name="rmic.stubVersion" value="1.2"/>
+
+ <!-- classpath and local.classpath must have a value using with a path -->
+ <property name="classpath" value=""/>
+ <property name="local.classpath" value=""/>
+
+ <!-- The classpath required to build classes. -->
+ <path id="javac.classpath">
+ <pathelement path="${classpath}"/>
+ <pathelement path="${local.classpath}"/>
+ <path refid="thirdparty.classpath"/>
+ </path>
+
+ <!-- The classpath required to build javadocs. -->
+ <path id="javadoc.classpath">
+ <path refid="javac.classpath"/>
+ </path>
+
+ <!-- Packages to include when generating api documentation -->
+ <property name="javadoc.packages" value="org.jboss.*"/>
+
+ <!-- Override JUnit defaults -->
+ <property name="junit.timeout" value="240000"/> <!-- 4 minutes -->
+ <property name="junit.batchtest.todir" value="${build.reports}"/>
+ <property name="junit.jvm.options" value="-Ddummy"/>
+
+</target>
\ No newline at end of file
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/defaults.ent
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/libraries.ent
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/libraries.ent (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/libraries.ent 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,356 @@
+<!-- $Id$ -->
+
+<target name="libraries" depends="configure-libraries"/>
+
+<target name="configure-libraries" unless="configure-libraries.disable">
+
+ <!-- Apache BCEL -->
+ <property name="apache.bcel.root" value="${project.thirdparty}/apache-bcel"/>
+ <property name="apache.bcel.lib" value="${apache.bcel.root}/lib"/>
+ <path id="apache.bcel.classpath">
+ <pathelement path="${apache.bcel.lib}/bcel.jar"/>
+ </path>
+
+ <!-- Apache Commons -->
+ <property name="apache.commons.root" value="${project.thirdparty}/apache-commons"/>
+ <property name="apache.commons.lib" value="${apache.commons.root}/lib"/>
+ <path id="apache.commons.classpath">
+ <pathelement path="${apache.commons.lib}/commons-collections.jar"/>
+ <pathelement path="${apache.commons.lib}/commons-lang-1.0.jar"/>
+ <pathelement path="${apache.commons.lib}/commons-logging-api.jar"/>
+ <pathelement path="${apache.commons.lib}/commons-pool.jar"/>
+ <pathelement path="${apache.commons.lib}/commons-discovery.jar"/>
+ <pathelement path="${apache.commons.lib}/commons-fileupload-1.0-beta-1.jar"/>
+ </path>
+
+ <!-- Apache Log4j -->
+ <property name="apache.log4j.root" value="${project.thirdparty}/apache-log4j"/>
+ <property name="apache.log4j.lib" value="${apache.log4j.root}/lib"/>
+ <path id="apache.log4j.classpath">
+ <pathelement path="${apache.log4j.lib}/log4j.jar"/>
+ <pathelement path="${apache.commons.lib}/commons-logging.jar"/>
+ </path>
+
+ <!-- Javassist -->
+ <property name="javassist.root" value="${project.thirdparty}/javassist"/>
+ <property name="javassist.lib" value="${javassist.root}/lib"/>
+ <path id="javassist.classpath">
+ <pathelement path="${javassist.lib}/javassist.jar"/>
+ </path>
+
+ <!-- Apache Xalan -->
+ <property name="apache.xalan.root" value="${project.thirdparty}/apache-xalan"/>
+ <property name="apache.xalan.lib" value="${apache.xalan.root}/lib"/>
+ <path id="apache.xalan.classpath">
+ <pathelement path="${apache.xalan.lib}/xml-apis.jar"/>
+ <pathelement path="${apache.xalan.lib}/xalan.jar"/>
+ </path>
+
+ <!-- Apache Struts -->
+ <property name="apache.struts.root" value="${project.thirdparty}/apache-struts"/>
+ <property name="apache.struts.lib" value="${apache.struts.root}/lib"/>
+ <path id="apache.struts.classpath">
+ <pathelement path="${apache.struts.lib}/struts.jar"/>
+ </path>
+
+ <!-- Apache Lucene -->
+ <property name="apache.lucene.root" value="${project.thirdparty}/apache-lucene"/>
+ <property name="apache.lucene.lib" value="${apache.lucene.root}/lib"/>
+ <path id="apache.lucene.classpath">
+ <pathelement path="${apache.lucene.lib}/lucene-1.2.jar"/>
+ </path>
+
+ <!-- Apache Slide -->
+ <property name="apache.slide.root" value="${project.thirdparty}/apache-slide"/>
+ <property name="apache.slide.lib" value="${apache.slide.root}/client/lib"/>
+ <path id="apache.slide.classpath">
+ <pathelement path="${apache.slide.lib}/webdavlib.jar"/>
+ <pathelement path="${apache.slide.lib}/commons-httpclient.jar"/>
+ </path>
+
+ <!-- GNU Regex -->
+ <property name="gnu.regexp.root" value="${project.thirdparty}/gnu-regexp"/>
+ <property name="gnu.regexp.lib" value="${gnu.regexp.root}/lib"/>
+ <path id="gnu.regexp.classpath">
+ <pathelement path="${gnu.regexp.lib}/gnu-regexp.jar"/>
+ </path>
+
+ <!-- GNU Getopt -->
+ <property name="gnu.getopt.root" value="${project.thirdparty}/gnu-getopt"/>
+ <property name="gnu.getopt.lib" value="${gnu.getopt.root}/lib"/>
+ <path id="gnu.getopt.classpath">
+ <pathelement path="${gnu.getopt.lib}/getopt.jar"/>
+ </path>
+
+ <!-- MySQL -->
+ <property name="mysql.mysql.root" value="${project.thirdparty}/mysql-mysql"/>
+ <property name="mysql.mysql.lib" value="${mysql.mysql.root}/lib"/>
+ <path id="mysql.mysql.classpath">
+ <pathelement path="${mysql.mysql.lib}/mysql-connector-java-3.0.0-beta-bin.jar"/>
+ </path>
+
+ <!-- org.jdom -->
+ <property name="jdom.root" value="${project.thirdparty}/jdom-beta-7"/>
+ <property name="jdom.lib" value="${jdom.root}/lib"/>
+ <path id="jdom.classpath">
+ <pathelement path="${jdom.lib}/jdom.jar"/>
+ </path>
+
+ <!-- JUnit -->
+ <property name="junit.junit.root" value="${project.thirdparty}/junit-junit"/>
+ <property name="junit.junit.lib" value="${junit.junit.root}/lib"/>
+ <path id="junit.junit.classpath">
+ <pathelement path="${junit.junit.lib}/junit.jar"/>
+ </path>
+
+ <!-- EDU.oswego.cs.dl.util.concurrent -->
+ <property name="oswego.concurrent.root" value="${project.thirdparty}/oswego-concurrent"/>
+ <property name="oswego.concurrent.lib" value="${oswego.concurrent.root}/lib"/>
+ <path id="oswego.concurrent.classpath">
+ <pathelement path="${oswego.concurrent.lib}/concurrent.jar"/>
+ </path>
+
+ <!-- org.xml.sax (SAX2 & SAX2 Extensions) -->
+ <property name="sax.root" value="${project.thirdparty}/xml-sax"/>
+ <property name="sax.lib" value="${sax.root}/lib"/>
+ <path id="sax.classpath">
+ <pathelement path="${sax.lib}/sax2.jar"/>
+ <pathelement path="${sax.lib}/sax2-ext.jar"/>
+ </path>
+
+ <!-- Ant -->
+ <property name="apache.ant.root" value="${project.tools}"/>
+ <property name="apache.ant.lib" value="${apache.ant.root}/lib"/>
+ <path id="apache.ant.classpath">
+ <pathelement path="${apache.ant.lib}/ant.jar"/>
+ <pathelement path="${apache.ant.lib}/optional.jar"/>
+ </path>
+
+ <!-- IBM WSDL4j -->
+ <property name="ibm.wsdl4j.root" value="${project.thirdparty}/ibm-wsdl4j"/>
+ <property name="ibm.wsdl4j.lib" value="${ibm.wsdl4j.root}/lib"/>
+ <path id="ibm.wsdl4j.classpath">
+ <pathelement path="${ibm.wsdl4j.lib}/wsdl4j.jar"/>
+ </path>
+
+ <!-- IBM UDDI4j -->
+ <property name="ibm.uddi4j.root" value="${project.thirdparty}/ibm-uddi4j"/>
+ <property name="ibm.uddi4j.lib" value="${ibm.uddi4j.root}/lib"/>
+ <path id="ibm.uddi4j.classpath">
+ <pathelement path="${ibm.uddi4j.lib}/uddi4j.jar"/>
+ </path>
+
+ <!-- IBM BSF -->
+ <property name="ibm.bsf.root" value="${project.thirdparty}/ibm-bsf"/>
+ <property name="ibm.bsf.lib" value="${ibm.bsf.root}/lib"/>
+ <path id="ibm.bsf.classpath">
+ <pathelement path="${ibm.bsf.lib}/bsf.jar"/>
+ </path>
+
+ <!-- Apache Axis -->
+ <property name="apache.axis.root" value="${project.thirdparty}/apache-axis"/>
+ <property name="apache.axis.lib" value="${apache.axis.root}/lib"/>
+ <path id="apache.axis.classpath">
+ <pathelement path="${apache.axis.lib}/axis.jar"/>
+ <pathelement path="${apache.axis.lib}/jaxrpc.jar"/>
+ <pathelement path="${apache.axis.lib}/saaj.jar"/>
+ <path refid="ibm.wsdl4j.classpath"/>
+ <path refid="ibm.uddi4j.classpath"/>
+ </path>
+
+ <!-- Dom4j -->
+ <property name="dom4j.dom4j.root" value="${project.thirdparty}/dom4j-dom4j"/>
+ <property name="dom4j.dom4j.lib" value="${dom4j.dom4j.root}/lib"/>
+ <path id="dom4j.dom4j.classpath">
+ <pathelement path="${dom4j.dom4j.lib}/dom4j.jar"/>
+ </path>
+
+ <!-- Exolab Castor -->
+ <property name="exolab.castor.root" value="${project.thirdparty}/exolab-castor"/>
+ <property name="exolab.castor.lib" value="${exolab.castor.root}/lib"/>
+ <path id="exolab.castor.classpath">
+ <pathelement path="${exolab.castor.lib}/castor.jar"/>
+ </path>
+
+ <!-- Exolab Tyrex -->
+ <property name="exolab.tyrex.root" value="${project.thirdparty}/exolab-tyrex"/>
+ <property name="exolab.tyrex.lib" value="${exolab.tyrex.root}/lib"/>
+ <path id="exolab.tyrex.classpath">
+ <pathelement path="${exolab.tyrex.lib}/tyrex.jar"/>
+ </path>
+
+ <!-- GJT JPL-Util -->
+ <property name="gjt.jpl-util.root" value="${project.thirdparty}/gjt-jpl-util"/>
+ <property name="gjt.jpl-util.lib" value="${gjt.jpl-util.root}/lib"/>
+ <path id="gjt.jpl-util.classpath">
+ <pathelement path="${gjt.jpl-util.lib}/jpl-util.jar"/>
+ <pathelement path="${gjt.jpl-util.lib}/jpl-pattern.jar"/>
+ </path>
+
+ <!-- Hypersonic SQL -->
+ <property name="hsqldb.hsqldb.root" value="${project.thirdparty}/hsqldb-hsqldb"/>
+ <property name="hsqldb.hsqldb.lib" value="${hsqldb.hsqldb.root}/lib"/>
+ <path id="hsqldb.hsqldb.classpath">
+ <pathelement path="${hsqldb.hsqldb.lib}/hsqldb.jar"/>
+ </path>
+
+ <!-- JacORB -->
+ <property name="jacorb.jacorb.root" value="${project.thirdparty}/jacorb-jacorb"/>
+ <property name="jacorb.jacorb.lib" value="${jacorb.jacorb.root}/lib"/>
+ <path id="jacorb.jacorb.classpath">
+ <pathelement path="${jacorb.jacorb.lib}/jacorb.jar"/>
+ </path>
+
+ <!-- JavaGroups -->
+ <property name="javagroups.javagroups.root" value="${project.thirdparty}/javagroups-javagroups"/>
+ <property name="javagroups.javagroups.lib" value="${javagroups.javagroups.root}/lib"/>
+ <path id="javagroups.javagroups.classpath">
+ <pathelement path="${javagroups.javagroups.lib}/javagroups-2.0.jar"/>
+ </path>
+
+ <!-- Jasper Why is this under jetty??, should be apache -->
+ <property name="jetty.jasper.root" value="${project.thirdparty}/mortbay-jetty"/>
+ <property name="jetty.jasper.lib" value="${jetty.jasper.root}/lib"/>
+ <path id="jetty.jasper.classpath">
+ <pathelement path="${jetty.jasper.lib}/org.apache.jasper.jar"/>
+ </path>
+
+ <!-- Servlets -->
+ <property name="sun.servlet.root" value="${project.thirdparty}/sun-servlet"/>
+ <property name="sun.servlet.lib" value="${sun.servlet.root}/lib"/>
+ <path id="sun.servlet.classpath">
+ <pathelement path="${sun.servlet.lib}/servlet.jar"/>
+ </path>
+
+ <!-- Sun JMX -->
+ <property name="sun.jmx.root" value="${project.thirdparty}/sun-jmx"/>
+ <property name="sun.jmx.lib" value="${sun.jmx.root}/lib"/>
+ <path id="sun.jmx.classpath">
+ <pathelement path="${sun.jmx.lib}/jmxri.jar"/>
+ <pathelement path="${sun.jmx.lib}/jmxtools.jar"/>
+ </path>
+
+ <!-- Java Authentication and Authorization Service (JAAS) -->
+ <property name="sun.jaas.root" value="${project.thirdparty}/sun-jaas"/>
+ <property name="sun.jaas.lib" value="${sun.jaas.root}/lib"/>
+ <path id="sun.jaas.classpath">
+ <pathelement path="${sun.jaas.lib}/jaas.jar"/>
+ </path>
+
+ <!-- Java XML Parser -->
+ <property name="sun.jaxp.root" value="${project.thirdparty}/sun-jaxp"/>
+ <property name="sun.jaxp.lib" value="${sun.jaxp.root}/lib"/>
+ <path id="sun.jaxp.classpath">
+ <pathelement path="${sun.jaxp.lib}/jaxp.jar"/>
+ <pathelement path="${sun.jaxp.lib}/crimson.jar"/>
+ <pathelement path="${sun.jaxp.lib}/xalan.jar"/>
+ </path>
+
+ <!-- JavaBeans Activation Framework (JAF) -->
+ <property name="sun.jaf.root" value="${project.thirdparty}/sun-jaf"/>
+ <property name="sun.jaf.lib" value="${sun.jaf.root}/lib"/>
+ <path id="sun.jaf.classpath">
+ <pathelement path="${sun.jaf.lib}/activation.jar"/>
+ </path>
+
+ <!-- JavaCC -->
+ <property name="sun.javacc.root" value="${project.thirdparty}/sun-javacc"/>
+ <property name="sun.javacc.lib" value="${sun.javacc.root}/lib"/>
+
+ <!-- Java Cryptography Extension (JCE) -->
+ <property name="sun.jce.root" value="${project.thirdparty}/sun-jce"/>
+ <property name="sun.jce.lib" value="${sun.jce.root}/lib"/>
+ <path id="sun.jce.classpath">
+ <pathelement path="${sun.jce.lib}/jce1_2_1.jar"/>
+ <pathelement path="${sun.jce.lib}/sunjce_provider.jar"/>
+ <pathelement path="${sun.jce.lib}/local_policy.jar"/>
+ <pathelement path="${sun.jce.lib}/US_export_policy.jar"/>
+ </path>
+
+ <!-- JavaMail -->
+ <property name="sun.javamail.root" value="${project.thirdparty}/sun-javamail"/>
+ <property name="sun.javamail.lib" value="${sun.javamail.root}/lib"/>
+ <path id="sun.javamail.classpath">
+ <pathelement path="${sun.javamail.lib}/mail.jar"/>
+ </path>
+
+ <!-- Java Secure Socket Extension (JSSE) -->
+ <property name="sun.jsse.root" value="${project.thirdparty}/sun-jsse"/>
+ <property name="sun.jsse.lib" value="${sun.jsse.root}/lib"/>
+ <path id="sun.jsse.classpath">
+ <pathelement path="${sun.jsse.lib}/jsse.jar"/>
+ <pathelement path="${sun.jsse.lib}/jcert.jar"/>
+ <pathelement path="${sun.jsse.lib}/jnet.jar"/>
+ </path>
+
+ <!-- Java Transaction Service (JTS) -->
+ <property name="sun.jts.root" value="${project.thirdparty}/sun-jts"/>
+ <property name="sun.jts.lib" value="${sun.jts.root}/lib"/>
+ <path id="sun.jts.classpath">
+ <pathelement path="${sun.jts.lib}/jts.jar"/>
+ </path>
+
+ <!-- JBoss Plastic APIs -->
+ <property name="jboss.plastic.root" value="${project.thirdparty}/jboss-plastic"/>
+ <property name="jboss.plastic.lib" value="${jboss.plastic.root}/lib"/>
+ <path id="jboss.plastic.classpath">
+ <pathelement path="${jboss.plastic.lib}/jboss-j2ee.jar"/>
+ </path>
+
+ <!-- SourceForge Tapestry -->
+ <property name="sourceforge.tapestry.root" value="${project.thirdparty}/sourceforge-tapestry"/>
+ <property name="sourceforge.tapestry.lib" value="${sourceforge.tapestry.root}/lib"/>
+ <path id="sourceforge.tapestry.classpath">
+ <pathelement path="${sourceforge.tapestry.lib}/net.sf.tapestry-2.2.jar"/>
+ <pathelement path="${sourceforge.tapestry.lib}/net.sf.tapestry.contrib-2.2.jar"/>
+ </path>
+
+ <!-- XDoclet -->
+
+ <!--
+ | xdoclet has appended a version string to all their jars.
+ | I'm using jb4 so we don't have to track them so carefully
+ -->
+ <property name="xdoclet.version" value="jb4"/>
+
+ <!--
+
+ jason: it seems like this hack is better defaulting to the default in thirdparty, if you
+ want to build from CVS then change this to the value below in build/local.properties.
+
+ <!- - this may be overridden by the build/local.properties file to use version from cvs- ->
+ <property name="xdoclet.xdoclet.root" value="${project.root}/xdoclet/output"/>
+
+ -->
+ <property name="xdoclet.xdoclet.root" value="${project.thirdparty}/xdoclet-xdoclet"/>
+
+ <property name="xdoclet.xdoclet.lib" value="${xdoclet.xdoclet.root}/lib"/>
+ <path id="xdoclet.xdoclet.classpath">
+ <pathelement path="${xdoclet.xdoclet.lib}/xdoclet-${xdoclet.version}.jar"/>
+ <pathelement path="${xdoclet.xdoclet.lib}/xdoclet-xjavadoc-${xdoclet.version}.jar"/>
+ <pathelement path="${xdoclet.xdoclet.lib}/xdoclet-bea-module-${xdoclet.version}.jar"/>
+ <pathelement path="${xdoclet.xdoclet.lib}/xdoclet-ejb-module-${xdoclet.version}.jar"/>
+ <pathelement path="${xdoclet.xdoclet.lib}/xdoclet-java-module-${xdoclet.version}.jar"/>
+ <pathelement path="${xdoclet.xdoclet.lib}/xdoclet-jboss-module-${xdoclet.version}.jar"/>
+ <pathelement path="${xdoclet.xdoclet.lib}/xdoclet-jdo-module-${xdoclet.version}.jar"/>
+ <pathelement path="${xdoclet.xdoclet.lib}/xdoclet-jmx-module-${xdoclet.version}.jar"/>
+ <pathelement path="${xdoclet.xdoclet.lib}/xdoclet-web-module-${xdoclet.version}.jar"/>
+ <pathelement path="${xdoclet.xdoclet.lib}/xdoclet-xdoclet-module-${xdoclet.version}.jar"/>
+ <path refid="apache.commons.classpath"/>
+ </path>
+
+ <!-- BeanShell -->
+ <property name="beanshell.beanshell.root" value="${project.thirdparty}/beanshell-beanshell"/>
+ <property name="beanshell.beanshell.lib" value="${beanshell.beanshell.root}/lib"/>
+ <path id="beanshell.beanshell.classpath">
+ <pathelement path="${beanshell.beanshell.lib}/bsh-core-1.2b7.jar"/>
+ </path>
+
+ <!-- Informix -->
+ <property name="informix.informix.root" value="${project.thirdparty}/informix-informix"/>
+ <property name="informix.informix.lib" value="${informix.informix.root}/lib"/>
+ <path id="informix.informix.classpath">
+ <pathelement path="${informix.informix.lib}/ifxjdbc.jar"/>
+ </path>
+
+</target>
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/libraries.ent
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/modules.ent
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/modules.ent (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/modules.ent 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,178 @@
+<!-- $Id$ -->
+
+<target name="configure-modules" unless="configure-modules.disabled">
+
+ <!-- Cluster -->
+ <property name="jboss.cluster.root" value="${project.root}/cluster/output"/>
+ <property name="jboss.cluster.lib" value="${jboss.cluster.root}/lib"/>
+ <path id="jboss.cluster.classpath">
+ <pathelement path="${jboss.cluster.root}/classes"/>
+ </path>
+
+ <!-- Common -->
+ <property name="jboss.common.root" value="${project.root}/common/output"/>
+ <property name="jboss.common.lib" value="${jboss.common.root}/lib"/>
+ <path id="jboss.common.classpath">
+ <pathelement path="${jboss.common.lib}/jboss-common.jar"/>
+ </path>
+
+ <!-- Connector -->
+ <property name="jboss.connector.root" value="${project.root}/connector/output"/>
+ <property name="jboss.connector.lib" value="${jboss.connector.root}/lib"/>
+ <path id="jboss.connector.classpath">
+ <pathelement path="${jboss.connector.lib}/jboss-jca.jar"/>
+ <pathelement path="${jboss.connector.lib}/local-ra-jdbc-libs.jar"/>
+ </path>
+
+ <!-- Iiop -->
+ <property name="jboss.iiop.root" value="${project.root}/iiop/output"/>
+ <property name="jboss.iiop.lib" value="${jboss.iiop.root}/lib"/>
+ <path id="jboss.iiop.classpath">
+ <pathelement path="${jboss.iiop.lib}/jboss-iiop.jar"/>
+ </path>
+
+ <!-- J2EE -->
+ <property name="jboss.j2ee.root" value="${project.root}/j2ee/output"/>
+ <property name="jboss.j2ee.lib" value="${jboss.j2ee.root}/lib"/>
+ <path id="jboss.j2ee.classpath">
+ <pathelement path="${jboss.j2ee.lib}/jboss-j2ee.jar"/>
+ </path>
+
+ <!-- Jbossnet -->
+ <property name="jboss.jbossnet.root" value="${project.root}/jboss.net/output"/>
+ <property name="jboss.jbossnet.lib" value="${jboss.jbossnet.root}/lib"/>
+ <!--path id="jboss.jbossnet.classpath">
+ <pathelement path="${jboss.jbossnet.lib}/jboss-net.sar"/>
+ </path-->
+
+ <!-- Jetty -->
+ <property name="jboss.jetty.root" value="${project.root}/jetty/output"/>
+ <property name="jboss.jetty.lib" value="${jboss.jetty.root}/lib"/>
+ <!--path id="jboss.jetty.classpath">
+ <pathelement path="${jboss.jetty.lib}/??.sar"/>
+ </path-->
+ <path id="jetty.servlet.classpath">
+ <pathelement path="${jboss.jetty.lib}/javax.servlet.jar"/>
+ </path>
+
+ <!-- JMX -->
+ <property name="jboss.jmx.root" value="${project.root}/jmx/output"/>
+ <property name="jboss.jmx.lib" value="${jboss.jmx.root}/lib"/>
+ <path id="jboss.jmx.classpath">
+ <pathelement path="${jboss.jmx.lib}/jboss-jmx.jar"/>
+ </path>
+
+ <!-- AOP -->
+ <property name="jboss.aop.root" value="${project.root}/aop/output"/>
+ <property name="jboss.aop.lib" value="${jboss.aop.root}/lib"/>
+ <path id="jboss.aop.classpath">
+ <pathelement path="${jboss.aop.lib}/jboss-aop.jar"/>
+ </path>
+
+ <!-- Management -->
+ <property name="jboss.management.root" value="${project.root}/management/output"/>
+ <property name="jboss.management.lib" value="${jboss.management.root}/lib"/>
+ <path id="jboss.management.classpath">
+ <pathelement path="${jboss.management.lib}/jboss-jsr77.jar"/>
+ <pathelement path="${jboss.management.lib}/jboss-management.jar"/>
+ </path>
+
+ <!-- Messaging -->
+ <property name="jboss.messaging.root" value="${project.root}/messaging/output"/>
+ <property name="jboss.messaging.lib" value="${jboss.messaging.root}/lib"/>
+ <path id="jboss.messaging.classpath">
+ <pathelement path="${jboss.messaging.lib}/jbossmq.jar"/>
+ </path>
+
+ <!-- Naming -->
+ <property name="jboss.naming.root" value="${project.root}/naming/output"/>
+ <property name="jboss.naming.lib" value="${jboss.naming.root}/lib"/>
+ <path id="jboss.naming.classpath">
+ <pathelement path="${jboss.naming.lib}/jnpserver.jar"/>
+ </path>
+
+ <!-- Security -->
+ <property name="jboss.security.root" value="${project.root}/security/output"/>
+ <property name="jboss.security.lib" value="${jboss.security.root}/lib"/>
+ <path id="jboss.security.classpath">
+ <pathelement path="${jboss.security.lib}/jbosssx.jar"/>
+ <pathelement path="${jboss.security.lib}/jboss-jaas.jar"/>
+ </path>
+
+ <!-- Server -->
+ <property name="jboss.server.root" value="${project.root}/server/output"/>
+ <property name="jboss.server.lib" value="${jboss.server.root}/lib"/>
+ <path id="jboss.server.classpath">
+ <pathelement path="${jboss.server.lib}/jboss.jar"/>
+ <pathelement path="${jboss.server.lib}/jmx-rmi-connector-client.jar"/>
+ <pathelement path="${jboss.server.lib}/jmx-rmi-adaptor.jar"/>
+ </path>
+
+ <!-- System -->
+ <property name="jboss.system.root" value="${project.root}/system/output"/>
+ <property name="jboss.system.lib" value="${jboss.system.root}/lib"/>
+ <path id="jboss.system.classpath">
+ <pathelement path="${jboss.system.lib}/jboss-system.jar"/>
+ </path>
+ <property name="jboss.system.xdocletpath"
+ value="${project.root}/system/src/main"/>
+
+ <!-- Transaction -->
+ <property name="jboss.transaction.root" value="${project.root}/transaction/output"/>
+ <property name="jboss.transaction.lib" value="${jboss.transaction.root}/lib"/>
+ <path id="jboss.transaction.classpath">
+ <pathelement path="${jboss.transaction.lib}/jboss-transaction.jar"/>
+ </path>
+
+ <!-- Varia -->
+ <property name="jboss.varia.root" value="${project.root}/varia/output"/>
+ <property name="jboss.varia.lib" value="${jboss.varia.root}/lib"/>
+ <path id="jboss.varia.classpath">
+ <pathelement path="${jboss.varia.root}/classes"/>
+ </path>
+
+ <!-- Blocks -->
+ <property name="jboss.blocks.root" value="${project.root}/blocks/output"/>
+ <property name="jboss.blocks.lib" value="${jboss.blocks.root}/lib"/>
+ <path id="jboss.blocks.classpath">
+ <pathelement path="${jboss.blocks.lib}/jboss-blocks.jar"/>
+ </path>
+ <property name="jboss.blocks.source" value="${project.root}/blocks/src"/>
+ <property name="jboss.blocks.source.java" value="${project.root}/blocks/src/main"/>
+
+ <!-- EJB -->
+ <property name="jboss.ejb.root" value="${project.root}/ejb/output"/>
+ <property name="jboss.ejb.lib" value="${jboss.ejb.root}/lib"/>
+ <path id="jboss.ejb.classpath">
+ <pathelement path="${jboss.ejb.lib}/jboss-ejb.jar"/>
+ </path>
+
+ <!-- Nukes on JBoss -->
+ <property name="jboss.nukes.root" value="${project.root}/nukes/output"/>
+ <property name="jboss.nukes.lib" value="${jboss.nukes.root}/lib"/>
+ <path id="jboss.nukes.classpath">
+ <pathelement path="${jboss.nukes.lib}/nukes-lib.jar"/>
+ </path>
+
+ <!-- Nukes ON JBoss journal -->
+ <property name="jboss.nukes-journal.root" value="${project.root}/journal/output"/>
+ <property name="jboss.nukes-journal.lib" value="${jboss.nukes-journal.root}/lib"/>
+ <path id="jboss.nukes-journal.classpath">
+ <pathelement path="${jboss.nukes-journal.lib}/nukes-journal-lib.jar"/>
+ </path>
+
+ <!-- JBoss Media -->
+ <property name="jboss.media.root" value="${project.root}/media/output"/>
+ <property name="jboss.media.lib" value="${jboss.media.root}/lib"/>
+ <path id="jboss.media.classpath">
+ <pathelement path="${jboss.media.root}/classes"/>
+ </path>
+
+ <!-- JBoss Remoting -->
+ <property name="jboss.remoting.root" value="${project.root}/remoting/output"/>
+ <property name="jboss.remoting.lib" value="${jboss.remoting.root}/lib"/>
+ <path id="jboss.remoting.classpath">
+ <pathelement path="${jboss.remoting.root}/classes"/>
+ </path>
+
+</target>
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/modules.ent
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/targets.ent
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/targets.ent (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/targets.ent 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,743 @@
+<!-- $Id$ -->
+
+<!-- ================================================================== -->
+<!-- Initialization -->
+<!-- ================================================================== -->
+
+<!--
+ | Initialize the build system. Must depend on '_buildmagic:init'.
+ | Other targets should depend on 'init' or things will mysteriously fail.
+ -->
+
+<target name="_default:init" unless="init.disable" depends="_buildmagic:init">
+</target>
+
+
+<!-- ================================================================== -->
+<!-- Compile -->
+<!-- ================================================================== -->
+
+<!-- Compile all class files -->
+<target name="_default:compile-classes" depends="init" unless="compile.disable">
+ <mkdir dir="${build.classes}"/>
+
+ <!-- Hack, required to avoid duplicate javac targets -->
+ <mkdir dir="${build.gen.classes}"/>
+
+ <!-- Remove classes which depend on changed files, so they will rebuild. -->
+ <depend srcdir="${source.java}:${build.gen.classes}"
+ destdir="${build.classes}"
+ dump="${javac.depend.dump}"
+ closure="${javac.depend.closure}">
+ <include name="${javac.includes}"/>
+ <exclude name="${javac.excludes}"/>
+ </depend>
+
+ <javac destdir="${build.classes}"
+ optimize="${javac.optimize}"
+ target="${javac.target}"
+ debug="${javac.debug}"
+ depend="${javac.depend}"
+ verbose="${javac.verbose}"
+ deprecation="${javac.deprecation}"
+ includeAntRuntime="${javac.include.ant.runtime}"
+ includeJavaRuntime="${javac.include.java.runtime}"
+ failonerror="${javac.fail.onerror}">
+ <src path="${source.java}:${build.gen.classes}"/>
+ <classpath refid="javac.classpath"/>
+ <include name="${javac.includes}"/>
+ <exclude name="${javac.excludes}"/>
+ </javac>
+</target>
+
+<!-- Compile all module test class files -->
+<target name="_default:compile-test-classes" depends="init" unless="compile.disable">
+
+ <mkdir dir="${build.test}"/>
+
+ <!-- Hack, required to avoid duplicate javac targets -->
+ <mkdir dir="${build.gen.test}"/>
+
+ <!-- Remove classes which depend on changed files, so they will rebuild. -->
+ <depend srcdir="${source.test}:${build.gen.test}"
+ destdir="${build.test}"
+ dump="${javac.depend.dump}"
+ closure="${javac.depend.closure}">
+ <include name="${javac.includes}"/>
+ <exclude name="${javac.excludes}"/>
+ </depend>
+
+ <javac destdir="${build.test}"
+ optimize="${javac.optimize}"
+ target="${javac.target}"
+ debug="${javac.debug}"
+ depend="${javac.depend}"
+ verbose="${javac.verbose}"
+ deprecation="${javac.deprecation}"
+ includeAntRuntime="${javac.include.ant.runtime}"
+ includeJavaRuntime="${javac.include.java.runtime}"
+ failonerror="${javac.fail.onerror}">
+ <src path="${source.test}:${build.gen.test}"/>
+ <classpath>
+ <path refid="javac.classpath"/>
+ <pathelement location="${build.classes}"/>
+ </classpath>
+ <include name="${javac.includes}"/>
+ <exclude name="${javac.excludes}"/>
+ </javac>
+</target>
+
+<!-- Compile manifests -->
+<target name="_default:compile-etc" depends="init" unless="compile.disable">
+ <mkdir dir="${build.etc}"/>
+ <copy todir="${build.etc}" filtering="yes">
+ <fileset dir="${source.etc}">
+ <include name="**"/>
+ </fileset>
+ </copy>
+</target>
+
+<!-- Compile resource files -->
+<target name="_default:compile-resources" depends="init" unless="compile.disable">
+ <mkdir dir="${build.resources}"/>
+ <copy todir="${build.resources}" filtering="yes">
+ <fileset dir="${source.resources}">
+ <patternset refid="compile-resources.filter.pattern"/>
+ </fileset>
+ </copy>
+ <copy todir="${build.resources}" filtering="no">
+ <fileset dir="${source.resources}">
+ <patternset refid="compile-resources.pattern"/>
+ </fileset>
+ </copy>
+</target>
+
+<patternset id="compile-resources.filter.pattern">
+ <include name="**/*"/>
+</patternset>
+
+<patternset id="compile-resources.pattern">
+ <exclude name="INVALID_FILE_DOES_NOT_EXISTS"/>
+</patternset>
+
+<!-- Compile stylesheets files -->
+<target name="_default:compile-stylesheets" depends="init" unless="compile.disable">
+ <mkdir dir="${build.stylesheets}"/>
+ <copy todir="${build.stylesheets}" filtering="yes">
+ <fileset dir="${source.stylesheets}">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+</target>
+
+<!-- Compile bin scripts -->
+<target name="_default:compile-bin" depends="init" unless="compile.disable">
+ <mkdir dir="${build.bin}"/>
+ <copy todir="${build.bin}" filtering="yes">
+ <fileset dir="${source.bin}">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+
+ <call target="_default:fix-bin"/>
+</target>
+
+<target name="_default:fix-bin" depends="init">
+ <fixcrlf srcdir="${build.bin}"
+ eol="lf" eof="remove"
+ includes="**/*.sh"/>
+
+ <fixcrlf srcdir="${build.bin}"
+ eol="crlf" eof="remove"
+ includes="**/*.bat, **/*.cmd"/>
+
+ <chmod perm="+x">
+ <fileset dir="${build.bin}">
+ <include name="**/*.sh"/>
+ </fileset>
+ </chmod>
+</target>
+
+<target name="_default:compile-web" depends="init" unless="compile.disable">
+ <mkdir dir="${build.web}"/>
+ <copy todir="${build.web}" filtering="yes">
+ <fileset dir="${source.web}">
+ <patternset refid="compile-web.filter.pattern"/>
+ </fileset>
+ </copy>
+ <copy todir="${build.web}" filtering="no">
+ <fileset dir="${source.web}">
+ <patternset refid="compile-web.pattern"/>
+ </fileset>
+ </copy>
+</target>
+
+<patternset id="compile-web.pattern">
+ <exclude name="INVALID_FILE_DOES_NOT_EXISTS"/>
+</patternset>
+
+<patternset id="compile-web.filter.pattern">
+ <include name="**/*"/>
+</patternset>
+
+<target name="_default:compile-checksums" depends="init" unless="compile.disable">
+ <checksum>
+ <fileset dir="${build.lib}">
+ <include name="*.jar"/>
+ <include name="*.zip"/>
+ </fileset>
+ </checksum>
+</target>
+
+<!-- Compile RMI stubs -->
+<target name="_default:compile-rmi" depends="init" unless="compile.disable">
+ <rmic base="${build.classes}"
+ verify="${rmic.verify}"
+ iiop="${rmic.iiop}"
+ iiopopts="${rmic.iiopops}"
+ idl="${rmic.idl}"
+ idlopts="${rmic.idlops}"
+ debug="${rmic.debug}"
+ stubVersion="${rmic.stubVersion}">
+ <classpath refid="javac.classpath"/>
+ <patternset refid="compile-rmi.pattern"/>
+ </rmic>
+</target>
+
+<patternset id="compile-rmi.pattern">
+ <exclude name="INVALID_FILE_DOES_NOT_EXISTS"/>
+</patternset>
+
+<!-- ================================================================== -->
+<!-- Tests -->
+<!-- ================================================================== -->
+<!-- default test target. To test a module, include
+ <target name="tests" depends="_default:tests"/>
+ in the module build file-->
+
+ <target name="_default:tests" depends="compile" unless="tests.disable">
+<echo message="build.reports: ${build.reports}"/>
+ <mkdir dir="${build.test}"/>
+
+ <!-- Hack, required to avoid duplicate javac targets -->
+ <mkdir dir="${build.gen.test}"/>
+
+ <path id="tests.classpath">
+ <pathelement path="${classpath}"/>
+ <pathelement path="${local.classpath}"/>
+ <pathelement path="${project.tools}/lib/ant.jar"/>
+ <pathelement path="${project.tools}/lib/junit.jar"/>
+ <pathelement path="${project.tools}/lib/optional.jar"/>
+ <path refid="thirdparty.classpath"/>
+<!-- FIXME: Need to add at least log4j here, what else? -->
+ <path refid="apache.log4j.classpath"/>
+ </path>
+
+ <!--default value, reset earlier if desired-->
+ <property name="log4j.configuration" value="file:${project.root}/testsuite/src/resources/log4j.xml"/>
+ <property name="test.pattern" value="**/*TestCase.class"/>
+
+
+ <mkdir dir="${build.reports}"/>
+ <mkdir dir="${build.log}"/>
+ <junit dir="${module.output}"
+ printsummary="${junit.printsummary}"
+ haltonerror="${junit.haltonerror}"
+ haltonfailure="${junit.haltonfailure}"
+ fork="${junit.fork}"
+ timeout="${junit.timeout}"
+ jvm="${junit.jvm}">
+
+ <jvmarg value="${junit.jvm.options}"/>
+ <sysproperty key="build.log" value="${build.log}"/>
+ <sysproperty key="log4j.configuration" value="${log4j.configuration}"/>
+ <sysproperty key="jbosstest.data.dir" value="${jbosstest.data.dir}"/>
+
+ <classpath>
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${build.test}"/>
+ <pathelement location="${build.resources}"/>
+ <path refid="tests.classpath"/>
+ </classpath>
+
+ <formatter type="xml" usefile="${junit.formatter.usefile}"/>
+
+ <batchtest todir="${build.reports}"
+ haltonerror="${junit.batchtest.haltonerror}"
+ haltonfailure="${junit.batchtest.haltonfailure}"
+ fork="${junit.batchtest.fork}">
+
+ <fileset dir="${build.test}">
+ <include name="${test.pattern}"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+ <!-- end _default:tests-->
+
+<!-- ================================================================== -->
+<!-- Documents -->
+<!-- ================================================================== -->
+
+<target name="_default:docs" description="Builds all documentation."
+ depends="docs-api,
+ docs-todo"/>
+
+<!-- ======== -->
+<!-- JavaDocs -->
+<!-- ======== -->
+
+<target name="docs-javadocs-check" depends="init">
+
+ <!-- if index.html is newer than the sources we are up to date -->
+ <uptodate property="docs-javadocs.disable"
+ targetfile="${build.api}/index.html">
+ <srcfiles dir="${source.java}" includes="**/*.java"/>
+ </uptodate>
+ </target>
+
+ <!-- Generate Javadoc if we are out of date -->
+ <target name="docs-javadocs"
+ depends="docs-javadocs-check"
+ unless="docs-javadocs.disable">
+
+ <mkdir dir="${build.api}"/>
+ <javadoc packagenames="${javadoc.packages}"
+ sourcepath="${source.classes}:${build.gen.classes}"
+ destdir="${build.api}"
+ classpathref="javadoc.classpath"
+ windowtitle="${javadoc.windowtitle}"
+ splitindex="${javadoc.splitindex}"
+ author="${javadoc.author}"
+ version="${javadoc.version}"
+ public="${javadoc.public}"
+ package="${javadoc.package}"
+ protected="${javadoc.protected}"
+ private="${javadoc.private}"
+ use="${javadoc.use}"
+ verbose="${javadoc.verbose}">
+ <doctitle><![CDATA[<h1>${module.Name} API Documentation</h1>]]></doctitle>
+ <bottom><![CDATA[
+ <i>
+ <div align="center">
+ <font size="-1">Copyright © 2002 JBoss Group, LLC. All Rights Reserved.</font>
+ </div>
+ </i>
+ ]]></bottom>
+
+ <!--
+ <link href="http://java.sun.com/j2se/1.3/docs/api"/>
+ -->
+ </javadoc>
+</target>
+
+<target name="docs-api" depends="docs-javadocs"/>
+
+<target name="javadocs" depends="docs-javadocs"/>
+
+<!-- ========= -->
+<!-- TODO Docs -->
+<!-- ========= -->
+
+<target name="docs-todo-check" depends="init">
+
+ <!-- if index.html is newer than the sources we are up to date -->
+ <uptodate property="docs-todo.disable"
+ targetfile="${build.todo}/index.html">
+ <srcfiles dir="${source.java}" includes="**/*.java"/>
+ </uptodate>
+ </target>
+
+ <!-- Generate TODO list from @todo tags -->
+ <target name="docs-todo"
+ depends="docs-todo-check"
+ unless="docs-todo.disable">
+
+ <mkdir dir="${build.todo}"/>
+ <todo destdir="${build.todo}">
+ <fileset dir="${source.java}">
+ <include name="**/*.java"/>
+ </fileset>
+
+ <info/>
+ </todo>
+</target>
+
+<target name="todo" depends="docs-todo"/>
+
+<!-- ============== -->
+<!-- JMX MBean Docs -->
+<!-- ============== -->
+
+<target name="jmx-docs" depends="init">
+
+ <mkdir dir="${build.jmx-doc}"/>
+ <jmxdoclet destdir="${build.jmx-doc}"
+ force="false"
+ excludedtags="@version, at author">
+ <fileset dir="${source.java}">
+ <include name="**/*.java"/>
+ </fileset>
+ <jbossXmlDoc/>
+ </jmxdoclet>
+
+</target>
+
+<!-- Generate the plain HTML jmx docs -->
+<target name="docs-jmx-html-plain" depends="jmx-docs">
+
+ <!-- Force the use of SAXON XSLT -->
+ <property system="true"
+ name="javax.xml.transform.TransformerFactory"
+ value="com.icl.saxon.TransformerFactoryImpl"/>
+
+ <mkdir dir="${build.jmx-api}"/>
+ <style style="${project.thirdparty}/oasis/docbook-xsl/html/docbook.xsl"
+ processor="trax"
+ extension=".html"
+ basedir="${build.jmx-doc}"
+ destdir="${build.jmx-api}">
+ <include name="**/*.xml"/>
+ <param name="quiet" expression="${oasis.docbook.xsl.chunker.quiet}"/>
+ <param name="base.dir" expression="${build.jmx-api}${file.separator}"/>
+ <xmlcatalog>
+ <dtd
+ publicId="-//OASIS//DTD DocBook XML V4.1.2//EN"
+ location="${project.thirdparty}/oasis/docbook-xml/docbookx.dtd"/>
+ </xmlcatalog>
+ </style>
+
+</target>
+
+
+<!-- ================================================================== -->
+<!-- Cleaning -->
+<!-- ================================================================== -->
+
+<!-- Clean up all build output -->
+<target name="_default:clean"
+ description="Cleans up most generated files."
+ depends="_buildmagic:clean">
+</target>
+
+<!-- Clean up all generated files -->
+<target name="_default:clobber"
+ description="Cleans up all generated files."
+ depends="_buildmagic:clobber, clean">
+</target>
+
+<target name="rebuild" depends="clean,most"/>
+
+
+<!-- ================================================================== -->
+<!-- Misc. -->
+<!-- ================================================================== -->
+
+<target name="_default:main"
+ description="Executes the default target (most)."
+ depends="most"/>
+
+<target name="_default:all"
+ description="Builds everything."
+ depends="most,docs"/>
+
+<target name="_default:most"
+ description="Builds almost everything."
+ depends="output"/>
+
+<target name="_default:help"
+ description="Show this help message."
+ depends="_buildmagic:help:standard"/>
+
+
+<!-- ================================================================== -->
+<!-- Install & Release -->
+<!-- ================================================================== -->
+
+<!--
+ | These are almost never overriden, so no need to force module build.xml
+ | to define them.
+ -->
+
+<target name="release-zip"
+ description="Builds a ZIP distribution."
+ depends="output, _buildmagic:release:zip"/>
+
+<target name="release-tar"
+ description="Builds a TAR distribution."
+ depends="output, _buildmagic:release:tar"/>
+
+<target name="release-tgz"
+ description="Builds a TAR-GZ distribution."
+ depends="output, _buildmagic:release:tgz"/>
+
+<target name="release-all"
+ description="Builds a distribution for each archive type."
+ depends="release-zip, release-tgz"/>
+
+
+ <!-- ================================================================== -->
+ <!-- Project (build module) Targets -->
+ <!-- ================================================================== -->
+
+<!-- jason: this needs to be cleaned up -->
+
+<target name="configure-project" unless="configure-project.disable">
+
+ <!-- Bits for building source archives -->
+ <patternset id="source.ignore">
+ <exclude name="**/output/**"/>
+ </patternset>
+ <patternset id="source.free">
+ <exclude name="tools/**"/>
+ <exclude name="thirdparty/**"/>
+ <include name="**"/>
+ </patternset>
+ <patternset id="source.external">
+ <include name="tools/**"/>
+ <include name="thirdparty/**"/>
+ </patternset>
+
+ <!-- Skip any missing modules and issue a warning -->
+ <property name="executemodules.skipmissing" value="true"/>
+
+ <!-- The header and footer displayed during each module execution -->
+ <property name="executemodules.header"><![CDATA[
+ ==============================================================
+ ==
+ == Executing '@TARGET@' in module '@MODULE@'...
+ ==
+ ==]]></property>
+
+ <property name="executemodules.footer"><![CDATA[
+ ==
+ ==
+ == Finished '@TARGET@' in module '@MODULE@'.
+ ==
+ ==============================================================
+ ]]></property>
+
+ <property name="executemodules.exportproperties">
+ version.major,
+ version.minor,
+ version.revision,
+ version.tag,
+ version.name,
+ version.cvstag,
+
+ specification.title,
+ specification.version,
+ specification.vendor,
+
+ implementation.title,
+ implementation.version,
+ implementation.vendor,
+ implementation.vendor.id,
+ implementation.url
+ </property>
+
+ <!-- Show the module configuration -->
+ <echo>groups: ${groups}</echo>
+ <echo>modules: ${modules}</echo>
+
+ <property name="configure-project.disable" value="true" system="true"/>
+
+</target>
+
+ <!-- ================================================================== -->
+ <!-- Module Pass-through Targets -->
+ <!-- ================================================================== -->
+
+ <!--
+ | These targets will execute all configured modules with the specified
+ | target.
+ -->
+
+ <target name="modules-all" depends="_buildmagic:modules:all"/>
+ <target name="modules-most" depends="_buildmagic:modules:most"/>
+ <target name="modules-main" depends="_buildmagic:modules:main"/>
+ <target name="modules-release" depends="_buildmagic:modules:release"/>
+ <target name="modules-tests" depends="_buildmagic:modules:tests"/>
+ <target name="modules-clean" depends="_buildmagic:modules:clean"/>
+ <target name="modules-clobber" depends="_buildmagic:modules:clobber"/>
+
+
+<!-- ================================================================== -->
+<!-- Module Pass-through Targets -->
+<!-- ================================================================== -->
+
+<!-- Invoke the 'all' on all configured modules -->
+<target name="_buildmagic:modules:all" depends="init">
+ <execmodules target="all"
+ modules="${modules}"
+ root="${project.root}/@MODULE@"
+ skipmissing="${executemodules.skipmissing}"
+ exportproperties="${executemodules.exportproperties}">
+ <before target="_module- at MODULE@- at TARGET@-prepare"/>
+ <header message="${executemodules.header}"/>
+ <footer message="${executemodules.footer}"/>
+ <after target="_module- at MODULE@- at TARGET@"/>
+ <property name="init.have-parent" value="true"/>
+ </execmodules>
+</target>
+
+<!-- Invoke the 'most' on all configured modules -->
+<target name="_buildmagic:modules:most" depends="init">
+ <execmodules target="most"
+ modules="${modules}"
+ root="${project.root}/@MODULE@"
+ skipmissing="${executemodules.skipmissing}"
+ exportproperties="${executemodules.exportproperties}">
+ <header message="${executemodules.header}"/>
+ <footer message="${executemodules.footer}"/>
+ <before target="_module- at MODULE@- at TARGET@-prepare"/>
+ <after target="_module- at MODULE@- at TARGET@"/>
+ <property name="init.have-parent" value="true"/>
+ </execmodules>
+</target>
+
+<!-- Invoke the 'main' on all configured modules -->
+<target name="_buildmagic:modules:main" depends="init">
+ <execmodules target="main"
+ modules="${modules}"
+ root="${project.root}/@MODULE@"
+ skipmissing="${executemodules.skipmissing}"
+ exportproperties="${executemodules.exportproperties}">
+ <header message="${executemodules.header}"/>
+ <footer message="${executemodules.footer}"/>
+ <before target="_module- at MODULE@- at TARGET@-prepare"/>
+ <after target="_module- at MODULE@- at TARGET@"/>
+ <property name="init.have-parent" value="true"/>
+ </execmodules>
+</target>
+
+<!-- Invoke the 'release' on all configured modules -->
+<target name="_buildmagic:modules:release" depends="init">
+ <execmodules target="release"
+ modules="${modules}"
+ root="${project.root}/@MODULE@"
+ skipmissing="${executemodules.skipmissing}"
+ exportproperties="${executemodules.exportproperties}">
+ <before target="_module- at MODULE@- at TARGET@-prepare"/>
+ <header message="${executemodules.header}"/>
+ <footer message="${executemodules.footer}"/>
+ <after target="_module- at MODULE@- at TARGET@"/>
+ <property name="init.have-parent" value="true"/>
+ </execmodules>
+</target>
+
+<!-- Invoke the 'tests' on all configured modules -->
+<target name="_buildmagic:modules:tests" depends="init">
+ <execmodules target="tests"
+ modules="${modules}"
+ root="${project.root}/@MODULE@"
+ skipmissing="${executemodules.skipmissing}"
+ exportproperties="${executemodules.exportproperties}">
+ <before target="_module- at MODULE@- at TARGET@-prepare"/>
+ <header message="${executemodules.header}"/>
+ <footer message="${executemodules.footer}"/>
+ <after target="_module- at MODULE@- at TARGET@"/>
+ <property name="init.have-parent" value="true"/>
+ <property name="build.reports" value="${project.root}/testsuite/output/reports"/>
+ </execmodules>
+</target>
+
+<!-- Invoke the 'clean' on all configured modules -->
+<target name="_buildmagic:modules:clean" depends="init">
+ <execmodules target="clean"
+ modules="${modules}"
+ root="${project.root}/@MODULE@"
+ skipmissing="${executemodules.skipmissing}">
+ <before target="_module- at MODULE@- at TARGET@-prepare"/>
+ <header message="${executemodules.header}"/>
+ <footer message="${executemodules.footer}"/>
+ <after target="_module- at MODULE@- at TARGET@"/>
+ <property name="init.have-parent" value="true"/>
+ </execmodules>
+</target>
+
+<!-- Invoke the 'clobber' on all configured modules -->
+<target name="_buildmagic:modules:clobber" depends="init">
+ <execmodules target="clobber"
+ modules="${modules}"
+ root="${project.root}/@MODULE@"
+ skipmissing="${executemodules.skipmissing}">
+ <before target="_module- at MODULE@- at TARGET@-prepare"/>
+ <header message="${executemodules.header}"/>
+ <footer message="${executemodules.footer}"/>
+ <after target="_module- at MODULE@- at TARGET@"/>
+ <property name="init.have-parent" value="true"/>
+ </execmodules>
+</target>
+
+
+ <!-- ================================================================== -->
+ <!-- Source Archives -->
+ <!-- ================================================================== -->
+
+ <target name="source-free-zip" depends="init"
+ description="Builds a ZIP free source distribution.">
+ <mkdir dir="${module.output}"/>
+ <zip zipfile="${module.output}/${release.id}-free-src.zip">
+ <fileset dir="${project.root}">
+ <patternset refid="source.ignore"/>
+ <patternset refid="source.free"/>
+ </fileset>
+ </zip>
+ </target>
+
+ <target name="source-external-zip" depends="init"
+ description="Builds a ZIP external source distribution.">
+ <mkdir dir="${module.output}"/>
+ <zip zipfile="${module.output}/${release.id}-external-src.zip">
+ <fileset dir="${project.root}">
+ <patternset refid="source.ignore"/>
+ <patternset refid="source.external"/>
+ </fileset>
+ </zip>
+ </target>
+
+ <target name="source-zip" depends="source-free-zip, source-external-zip"
+ description="Builds a ZIP source distribution."/>
+
+ <target name="source-free-tar" depends="init"
+ description="Builds a TAR free source distribution.">
+ <mkdir dir="${module.output}"/>
+ <tar tarfile="${module.output}/${release.id}-free-src.tar" longfile="gnu"
+ basedir="${project.root}">
+ <patternset refid="source.ignore"/>
+ <patternset refid="source.free"/>
+ </tar>
+ </target>
+
+ <target name="source-external-tar" depends="init"
+ description="Builds a TAR external source distribution.">
+ <mkdir dir="${module.output}"/>
+ <tar tarfile="${module.output}/${release.id}-external-src.tar" longfile="gnu"
+ basedir="${project.root}">
+ <patternset refid="source.ignore"/>
+ <patternset refid="source.external"/>
+ </tar>
+ </target>
+
+ <target name="source-tar" depends="source-free-tar, source-external-tar"
+ description="Builds a TAR source distribution."/>
+
+ <target name="source-free-tgz" depends="source-free-tar"
+ description="Builds a TAR-GZIP free source distribution.">
+ <gzip src="${module.output}/${release.id}-free-src.tar"
+ zipfile="${module.output}/${release.id}-free-src.tgz"/>
+ </target>
+
+ <target name="source-external-tgz" depends="source-external-tar"
+ description="Builds a TAR-GZIP external source distribution.">
+ <gzip src="${module.output}/${release.id}-external-src.tar"
+ zipfile="${module.output}/${release.id}-external-src.tgz"/>
+ </target>
+
+ <target name="source-tgz" depends="source-free-tgz, source-external-tgz"
+ description="Builds a TAR-GZIP source distribution."/>
+
+ <target name="source-all"
+ depends="source-tar, source-tgz, source-zip"
+ description="Builds all source distributions."/>
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/targets.ent
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/task.properties
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/task.properties (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/task.properties 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,83 @@
+### ====================================================================== ###
+## ##
+## Default Task Properties ##
+## ##
+### ====================================================================== ###
+
+### $Id$ ###
+
+### Javac Defaults ###
+
+javac.includes=**/*.java
+javac.excludes=
+javac.defaultexcludes=yes
+
+javac.boot.classpath=${sun.boot.classpath}
+javac.classpath=${classpath}
+
+javac.debug=off
+javac.optimize=on
+javac.deprecation=on
+javac.target=1.2
+javac.verbose=off
+javac.depend=off
+javac.source=1.3
+
+javac.include.ant.runtime=no
+javac.include.java.runtime=no
+javac.fail.onerror=true
+
+classpath=
+classpath.local=
+classpath.thirdparty=
+
+### Javadoc Defaults ###
+
+javadoc.classpath=${javac.classpath}
+javadoc.sourcepath=
+javadoc.source.path=
+javadoc.source.files=
+
+javadoc.public=false
+javadoc.package=false
+javadoc.protected=true
+javadoc.private=false
+javadoc.version=true
+javadoc.author=true
+javadoc.use=true
+javadoc.verbose=false
+
+javadoc.windowtitle=${module.Name} API
+javadoc.doctitle=${module.Name}
+javadoc.splitindex=no
+
+### RMIC Defaults ###
+
+rmic.base=${build.classes}
+rmic.stubVersion=${javac.target}
+rmic.verify=true
+rmic.sourcebase=
+rmic.debug=false
+rmic.iiop=false
+rmic.iiopopts=
+rmic.idl=false
+rmic.idlopts=
+rmic.includes=
+rmic.excludes=
+
+### JUnit Defaults ###
+
+junit.printsummary=true
+junit.haltonerror=false
+junit.haltonfailure=false
+junit.fork=true
+junit.timeout=300000
+junit.jvm=java
+junit.jvm.options=
+
+junit.formatter.type=xml
+junit.formatter.usefile=true
+
+junit.batchtest.fork=${junit.fork}
+junit.batchtest.haltonerror=${junit.haltonerror}
+junit.batchtest.haltonfailure=${junit.haltonfailure}
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/task.properties
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/tools.ent
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/tools.ent (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/tools.ent 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,70 @@
+<!-- $Id$ -->
+
+
+<target name="configure-tools" unless="configure-tools.disable">
+
+ <call target="_configure:xdoclet:tasks" unless="_configure:xdoclet:tasks.done">
+ <available file="${xdoclet.xdoclet.lib}/xdoclet-${xdoclet.version}.jar"/>
+ <available file="${xdoclet.xdoclet.lib}/xdoclet-jmx-module-${xdoclet.version}.jar"/>
+ </call>
+
+ <call target="_configure:xdoclet:ejbdoclet" unless="_configure:xdoclet:ejbdoclet.done">
+ <available file="${xdoclet.xdoclet.lib}/xdoclet-${xdoclet.version}.jar"/>
+ <available file="${xdoclet.xdoclet.lib}/xdoclet-ejb-module-${xdoclet.version}.jar"/>
+ <available file="${jboss.plastic.lib}/jboss-j2ee.jar"/>
+ </call>
+
+ <call target="_configure:xdoclet:webdoclet" unless="_configure:xdoclet:webdoclet.done">
+ <available file="${xdoclet.xdoclet.lib}/xdoclet-${xdoclet.version}.jar"/>
+ <available file="${xdoclet.xdoclet.lib}/xdoclet-web-module-${xdoclet.version}.jar"/>
+ <available file="${sun.servlet.lib}/servlet.jar"/>
+ </call>
+
+</target>
+
+<target name="_configure:xdoclet:tasks">
+
+ <path id="xdoclet.base.task.classpath">
+ <path refid="xdoclet.xdoclet.classpath"/>
+ <path refid="apache.log4j.classpath"/>
+ <path refid="apache.ant.classpath"/>
+ </path>
+
+ <taskdef name="jmxdoclet"
+ classname="xdoclet.modules.jmx.JMXDocletTask"
+ classpathref="xdoclet.base.task.classpath"/>
+
+ <taskdef name="todo"
+ classname="xdoclet.modules.doc.DocumentDocletTask"
+ classpathref="xdoclet.base.task.classpath"/>
+
+ <property name="_configure:xdoclet:tasks.done" value="true" system="true"/>
+
+</target>
+
+<target name="_configure:xdoclet:ejbdoclet">
+
+ <path id="ejbdoclet.task.classpath">
+ <path refid="xdoclet.base.task.classpath"/>
+ <path refid="jboss.plastic.classpath"/>
+ </path>
+
+ <taskdef name="ejbdoclet"
+ classname="xdoclet.modules.ejb.EjbDocletTask"
+ classpathref="ejbdoclet.task.classpath"/>
+
+ <property name="_configure:xdoclet:ejbdoclet.done" value="true" system="true"/>
+</target>
+
+<target name="_configure:xdoclet:webdoclet">
+ <path id="webdoclet.task.classpath">
+ <path refid="xdoclet.base.task.classpath"/>
+ <path refid="sun.servlet.classpath"/>
+ </path>
+
+ <taskdef name="webdoclet"
+ classname="xdoclet.modules.web.WebDocletTask"
+ classpathref="webdoclet.task.classpath"/>
+
+ <property name="_configure:xdoclet:webdoclet.done" value="true" system="true"/>
+</target>
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/buildfragments/tools.ent
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/changelog.xsl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/changelog.xsl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/changelog.xsl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
+ version='1.0'>
+
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 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", "Ant", 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 at 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
+ <http://www.apache.org/>.
+ -->
+ <xsl:param name="title"/>
+ <xsl:param name="module"/>
+ <xsl:param name="cvsweb"/>
+
+ <xsl:output method="html" indent="yes" encoding="US-ASCII"
+ doctype-public="-//W3C//DTD HTML 4.01//EN"
+ doctype-system="http://www.w3.org/TR/html401/strict.dtd"/>
+
+ <!-- Copy standard document elements. Elements that
+ should be ignored must be filtered by apply-templates
+ tags. -->
+ <xsl:template match="*">
+ <xsl:copy>
+ <xsl:copy-of select="attribute::*[. != '']"/>
+ <xsl:apply-templates/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="changelog">
+ <html>
+ <head>
+ <title><xsl:value-of select="$title"/></title>
+ <style type="text/css">
+ body, p {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 80%;
+ color: #000000;
+ background-color: #ffffff;
+ }
+ tr, td {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ background: #eeeee0;
+ }
+ td {
+ padding-left: 20px;
+ }
+ .dateAndAuthor {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ text-align: left;
+ background: #a6caf0;
+ padding-left: 3px;
+ }
+ a {
+ color: #000000;
+ }
+ pre {
+ font-weight: bold;
+ }
+ </style>
+ </head>
+ <body>
+ <h1>
+ <a name="top"><xsl:value-of select="$title"/></a>
+ </h1>
+ <p style="text-align: right">Designed for use with <a href="http://jakarta.apache.org/ant/">Ant</a>.</p>
+ <hr/>
+ <table border="0" width="100%" cellspacing="1">
+
+ <xsl:apply-templates select=".//entry">
+ <xsl:sort select="date" data-type="text" order="descending"/>
+ <xsl:sort select="time" data-type="text" order="descending"/>
+ </xsl:apply-templates>
+
+ </table>
+
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="entry">
+ <tr>
+ <td class="dateAndAuthor">
+ <xsl:value-of select="date"/><xsl:text> </xsl:text><xsl:value-of select="time"/><xsl:text> </xsl:text><xsl:value-of select="author"/>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <pre>
+<xsl:apply-templates select="msg"/></pre>
+ <ul>
+ <xsl:apply-templates select="file"/>
+ </ul>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="date">
+ <i><xsl:value-of select="."/></i>
+ </xsl:template>
+
+ <xsl:template match="time">
+ <i><xsl:value-of select="."/></i>
+ </xsl:template>
+
+ <xsl:template match="author">
+ <i>
+ <a>
+ <xsl:attribute name="href">mailto:<xsl:value-of select="."/></xsl:attribute>
+ <xsl:value-of select="."/></a>
+ </i>
+ </xsl:template>
+
+ <xsl:template match="file">
+ <li>
+ <a>
+ <xsl:choose>
+ <xsl:when test="string-length(prevrevision) = 0 ">
+ <xsl:attribute name="href"><xsl:value-of select="$cvsweb"/><xsl:value-of select="$module" />/<xsl:value-of select="name" />?rev=<xsl:value-of select="revision" />&content-type=text/x-cvsweb-markup</xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="href"><xsl:value-of select="$cvsweb"/><xsl:value-of select="$module" />/<xsl:value-of select="name" />?r1=<xsl:value-of select="revision" />&r2=<xsl:value-of select="prevrevision"/></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:value-of select="name" /> (<xsl:value-of select="revision"/>)</a>
+ </li>
+ </xsl:template>
+
+ <!-- Any elements within a msg are processed,
+ so that we can preserve HTML tags. -->
+ <xsl:template match="msg">
+ <xsl:apply-templates/>
+ </xsl:template>
+
+</xsl:stylesheet>
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/changelog.xsl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/checkstyle-frames.xsl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/checkstyle-frames.xsl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/checkstyle-frames.xsl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,324 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:lxslt="http://xml.apache.org/xslt"
+ xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
+ extension-element-prefixes="redirect">
+
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 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", "Ant", 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 at 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
+ <http://www.apache.org/>.
+ -->
+
+ <xsl:output method="html" indent="yes" encoding="US-ASCII"/>
+ <xsl:decimal-format decimal-separator="." grouping-separator="," />
+
+ <xsl:param name="output.dir" select="'.'"/>
+
+ <xsl:template match="checkstyle">
+ <!-- create the index.html -->
+ <redirect:write file="{$output.dir}/index.html">
+ <xsl:call-template name="index.html"/>
+ </redirect:write>
+
+ <!-- create the stylesheet.css -->
+ <redirect:write file="{$output.dir}/stylesheet.css">
+ <xsl:call-template name="stylesheet.css"/>
+ </redirect:write>
+
+ <!-- create the overview-summary.html at the root -->
+ <redirect:write file="{$output.dir}/overview-frame.html">
+ <xsl:apply-templates select="." mode="overview"/>
+ </redirect:write>
+
+ <!-- create the all-classes.html at the root -->
+ <redirect:write file="{$output.dir}/allclasses-frame.html">
+ <xsl:apply-templates select="." mode="all.classes"/>
+ </redirect:write>
+
+ <!-- process all files -->
+ <xsl:apply-templates select="file"/>
+ </xsl:template>
+
+ <xsl:template name="index.html">
+ <html>
+ <head>
+ <title>CheckStyle Audit</title>
+ </head>
+ <frameset cols="20%,80%">
+ <frame src="allclasses-frame.html" name="fileListFrame"/>
+ <frame src="overview-frame.html" name="fileFrame"/>
+ </frameset>
+ <noframes>
+ <h2>Frame Alert</h2>
+ <p>
+ This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
+ </p>
+ </noframes>
+ </html>
+ </xsl:template>
+
+ <xsl:template name="pageHeader">
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="text-align:right"><h2>CheckStyle Audit</h2></td>
+ </tr>
+ <tr>
+ <td class="text-align:right">Designed for use with <a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+ </xsl:template>
+
+ <xsl:template match="checkstyle" mode="overview">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <!-- page header -->
+ <xsl:call-template name="pageHeader"/>
+
+ <!-- Summary part -->
+ <xsl:apply-templates select="." mode="summary"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- File list part -->
+ <xsl:apply-templates select="." mode="filelist"/>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template name="stylesheet.css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin-left: 10;
+ margin-right: 10;
+ font:normal 80% arial,helvetica,sanserif;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ font-weight:bold;
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ font-size:100%;
+ border: none
+ }
+ table.log tr td, tr th {
+
+ }
+ h2 {
+ font-weight:bold;
+ font-size:140%;
+ margin-bottom: 5;
+ }
+ h3 {
+ font-size:100%;
+ font-weight:bold;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+ </xsl:template>
+
+ <!--
+ Creates an all-classes.html file that contains a link to all files.
+ -->
+ <xsl:template match="checkstyle" mode="all.classes">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <h2>Files</h2>
+ <p>
+ <table width="100%">
+ <!-- For each file create its part -->
+ <xsl:apply-templates select="file" mode="all.classes">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </p>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="checkstyle" mode="filelist">
+ <h3>Files</h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Name</th>
+ <th>Errors</th>
+ </tr>
+ <xsl:apply-templates select="file" mode="filelist">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </xsl:template>
+
+ <xsl:template match="file" mode="filelist">
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td nowrap="nowrap">
+ <a>
+ <xsl:attribute name="href">
+ <xsl:text>files/</xsl:text><xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ <td><xsl:value-of select="count(error)"/></td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="file" mode="all.classes">
+ <tr>
+ <td nowrap="nowrap">
+ <a target="fileFrame">
+ <xsl:attribute name="href">
+ <xsl:text>files/</xsl:text><xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <!--
+ transform string like a/b/c to ../../../
+ @param path the path to transform into a descending directory path
+ -->
+ <xsl:template name="path">
+ <xsl:param name="path"/>
+ <xsl:if test="contains($path,'/')">
+ <xsl:text>../</xsl:text>
+ <xsl:call-template name="path">
+ <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'/')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="not(contains($path,'/')) and not($path = '')">
+ <xsl:text>../</xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="file">
+ <redirect:write file="{$output.dir}/files/{@name}.html">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css">
+ <xsl:attribute name="href"><xsl:call-template name="path"><xsl:with-param name="path" select="@name"/></xsl:call-template><xsl:text>stylesheet.css</xsl:text></xsl:attribute>
+ </link>
+ </head>
+ <body>
+ <xsl:call-template name="pageHeader"/>
+ <h3>File <xsl:value-of select="@name"/></h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Error Description</th>
+ <th>Line</th>
+ </tr>
+ <xsl:for-each select="error">
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="@message"/></td>
+ <td><xsl:value-of select="@line"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+ </redirect:write>
+ </xsl:template>
+
+ <xsl:template match="checkstyle" mode="summary">
+ <h3>Summary</h3>
+ <xsl:variable name="fileCount" select="count(file)"/>
+ <xsl:variable name="errorCount" select="count(file/error)"/>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Files</th>
+ <th>Errors</th>
+ </tr>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="$fileCount"/></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ </tr>
+ </table>
+ </xsl:template>
+
+ <xsl:template name="alternated-row">
+ <xsl:attribute name="class">
+ <xsl:if test="position() mod 2 = 1">a</xsl:if>
+ <xsl:if test="position() mod 2 = 0">b</xsl:if>
+ </xsl:attribute>
+ </xsl:template>
+</xsl:stylesheet>
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/checkstyle-frames.xsl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/coverage-frames.xsl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/coverage-frames.xsl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/coverage-frames.xsl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,533 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:lxslt="http://xml.apache.org/xslt"
+ xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
+ extension-element-prefixes="redirect">
+<xsl:output method="html" indent="yes"/>
+<xsl:decimal-format decimal-separator="." grouping-separator="," />
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 2001-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", "Ant", 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 at 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
+ <http://www.apache.org/>.
+ -->
+
+<!--
+
+ Sample stylesheet to be used with JProbe 3.0 XML output.
+
+ It creates a set of HTML files a la javadoc where you can browse easily
+ through all packages and classes.
+
+ It is best used with JProbe Coverage Ant task that gives you the benefit
+ of a reference classpath so that you have the list of classes/methods
+ that are not used at all in a given classpath.
+
+ @author Stephane Bailliez <a href="mailto:sbailliez at apache.org"/>
+
+-->
+
+<!-- default output directory is current directory -->
+<xsl:param name="output.dir" select="'.'"/>
+
+<!-- ======================================================================
+ Root element
+ ======================================================================= -->
+<xsl:template match="/snapshot">
+ <!-- create the index.html -->
+ <redirect:write file="{$output.dir}/index.html">
+ <xsl:call-template name="index.html"/>
+ </redirect:write>
+
+ <!-- create the stylesheet.css -->
+ <redirect:write file="{$output.dir}/stylesheet.css">
+ <xsl:call-template name="stylesheet.css"/>
+ </redirect:write>
+
+ <!-- create the overview-packages.html at the root -->
+ <redirect:write file="{$output.dir}/overview-summary.html">
+ <xsl:apply-templates select="." mode="overview.packages"/>
+ </redirect:write>
+
+ <!-- create the all-packages.html at the root -->
+ <redirect:write file="{$output.dir}/overview-frame.html">
+ <xsl:apply-templates select="." mode="all.packages"/>
+ </redirect:write>
+
+ <!-- create the all-classes.html at the root -->
+ <redirect:write file="{$output.dir}/allclasses-frame.html">
+ <xsl:apply-templates select="." mode="all.classes"/>
+ </redirect:write>
+
+ <!-- process all packages -->
+ <xsl:apply-templates select="./package" mode="write"/>
+</xsl:template>
+
+<!-- =======================================================================
+ Frameset definition. Entry point for the report.
+ 3 frames: packageListFrame, classListFrame, classFrame
+ ======================================================================= -->
+<xsl:template name="index.html">
+<html>
+ <head><title>Coverage Results.</title></head>
+ <frameset cols="20%,80%">
+ <frameset rows="30%,70%">
+ <frame src="overview-frame.html" name="packageListFrame"/>
+ <frame src="allclasses-frame.html" name="classListFrame"/>
+ </frameset>
+ <frame src="overview-summary.html" name="classFrame"/>
+ </frameset>
+ <noframes>
+ <h2>Frame Alert</h2>
+ <p>
+ This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
+ </p>
+ </noframes>
+</html>
+</xsl:template>
+
+<!-- =======================================================================
+ Stylesheet CSS used
+ ======================================================================= -->
+<!-- this is the stylesheet css to use for nearly everything -->
+<xsl:template name="stylesheet.css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin-left: 10;
+ margin-right: 10;
+ font:normal 80% arial,helvetica,sanserif;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ font-weight:bold;
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ font-size:100%;
+ border: none
+ }
+ table.log tr td, tr th {
+
+ }
+ h2 {
+ font-weight:bold;
+ font-size:140%;
+ margin-bottom: 5;
+ }
+ h3 {
+ font-size:100%;
+ font-weight:bold;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+</xsl:template>
+
+<!-- =======================================================================
+ List of all classes in all packages
+ This will be the first page in the classListFrame
+ ======================================================================= -->
+<xsl:template match="snapshot" mode="all.classes">
+ <html>
+ <head>
+ <xsl:call-template name="create.stylesheet.link"/>
+ </head>
+ <body>
+ <h2>Classes</h2>
+ <table width="100%">
+ <xsl:for-each select="package/class">
+ <xsl:sort select="@name"/>
+ <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/>
+ <xsl:variable name="link">
+ <xsl:if test="not($package.name='')">
+ <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
+ </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
+ </xsl:variable>
+ <tr>
+ <td nowrap="nowrap">
+ <a target="classFrame" href="{$link}"><xsl:value-of select="@name"/></a>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<!-- list of all packages -->
+<xsl:template match="snapshot" mode="all.packages">
+ <html>
+ <head>
+ <xsl:call-template name="create.stylesheet.link"/>
+ </head>
+ <body>
+ <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
+ <h2>Packages</h2>
+ <table width="100%">
+ <xsl:for-each select="package">
+ <xsl:sort select="@name" order="ascending"/>
+ <tr>
+ <td nowrap="nowrap">
+ <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame">
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<!-- overview of statistics in packages -->
+<xsl:template match="snapshot" mode="overview.packages">
+ <html>
+ <head>
+ <xsl:call-template name="create.stylesheet.link"/>
+ </head>
+ <body onload="open('allclasses-frame.html','classListFrame')">
+ <xsl:call-template name="pageHeader"/>
+ <h3>Summary</h3>
+ <table class="log" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <!--th width="10%" nowrap="nowrap">Date</th>
+ <th width="10%" nowrap="nowrap">Elapsed time</th-->
+ <th width="10%" nowrap="nowrap">Reported Classes</th>
+ <th width="10%" nowrap="nowrap">Methods Hit</th>
+ <th width="10%" nowrap="nowrap">Lines Hit</th>
+ </tr>
+ <tr class="a">
+ <!--td nowrap="nowrap"><xsl:value-of select="execution_log/@program_start"/></td>
+ <td><xsl:value-of select="format-number(execution_log/@elapsed_time div 1000,'0.0')"/>secs</td-->
+ <td><xsl:value-of select="count(package/class)"/></td>
+ <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
+ <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
+ </tr>
+ </table>
+ <table border="0" width="100%">
+ <tr>
+ <td style="text-align: justify;">
+ To ensure accurate test runs on Java applications, developers need to know how much of
+ the code has been tested, and where to find any untested code. Coverage helps you
+ locate untested code, and measure precisely how much code has been exercised.
+ The result is a higher quality application in a shorter period of time.
+ <p/>
+ </td>
+ </tr>
+ </table>
+
+ <h3>Packages</h3>
+ <table class="log" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:apply-templates select="package[1]" mode="stats.header"/>
+ <!-- display packages and sort them via their coverage rate -->
+ <xsl:for-each select="package">
+ <xsl:sort data-type="number" select="cov.data/@hit_lines div cov.data/@total_lines"/>
+ <tr>
+ <xsl:call-template name="alternate-row"/>
+ <td><a href="{translate(@name,'.','/')}/package-summary.html"><xsl:value-of select="@name"/></a></td>
+ <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
+ <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ <xsl:call-template name="pageFooter"/>
+ </body>
+ </html>
+</xsl:template>
+
+<!--
+ detailed info for a package. It will output the list of classes
+, the summary page, and the info for each class
+-->
+<xsl:template match="package" mode="write">
+ <xsl:variable name="package.dir">
+ <xsl:if test="not(@name = '')"><xsl:value-of select="translate(@name,'.','/')"/></xsl:if>
+ <xsl:if test="@name = ''">.</xsl:if>
+ </xsl:variable>
+
+ <!-- create a classes-list.html in the package directory -->
+ <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
+ <xsl:apply-templates select="." mode="classes.list"/>
+ </redirect:write>
+
+ <!-- create a package-summary.html in the package directory -->
+ <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
+ <xsl:apply-templates select="." mode="package.summary"/>
+ </redirect:write>
+
+ <!-- for each class, creates a @name.html -->
+ <xsl:for-each select="class">
+ <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
+ <xsl:apply-templates select="." mode="class.details"/>
+ </redirect:write>
+ </xsl:for-each>
+</xsl:template>
+
+<!-- list of classes in a package -->
+<xsl:template match="package" mode="classes.list">
+ <html>
+ <HEAD>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="@name"/>
+ </xsl:call-template>
+ </HEAD>
+ <BODY>
+ <table width="100%">
+ <tr>
+ <td nowrap="nowrap">
+ <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2>
+ </td>
+ </tr>
+ </table>
+
+ <H2>Classes</H2>
+ <TABLE WIDTH="100%">
+ <xsl:for-each select="class">
+ <xsl:sort select="@name"/>
+ <tr>
+ <td nowrap="nowrap">
+ <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </TABLE>
+ </BODY>
+ </html>
+</xsl:template>
+
+<!-- summary of a package -->
+<xsl:template match="package" mode="package.summary">
+ <HTML>
+ <HEAD>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="@name"/>
+ </xsl:call-template>
+ </HEAD>
+ <!-- when loading this package, it will open the classes into the frame -->
+ <BODY onload="open('package-frame.html','classListFrame')">
+ <xsl:call-template name="pageHeader"/>
+ <h3>Package <xsl:value-of select="@name"/></h3>
+ <table class="log" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:apply-templates select="." mode="stats.header"/>
+ <xsl:apply-templates select="." mode="stats"/>
+ </table>
+
+ <xsl:if test="count(class) > 0">
+ <H3>Classes</H3>
+ <table class="log" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:apply-templates select="." mode="stats.header"/>
+ <xsl:apply-templates select="class" mode="stats">
+ <xsl:sort data-type="number" select="cov.data/@hit_lines div cov.data/@total_lines"/>
+ </xsl:apply-templates>
+ </table>
+ </xsl:if>
+ <xsl:call-template name="pageFooter"/>
+ </BODY>
+ </HTML>
+</xsl:template>
+
+<!-- details of a class -->
+<xsl:template match="class" mode="class.details">
+ <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/>
+ <HTML>
+ <HEAD>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="$package.name"/>
+ </xsl:call-template>
+ </HEAD>
+ <BODY>
+ <xsl:call-template name="pageHeader"/>
+ <H3>Class <xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3>
+
+ <!-- class summary -->
+ <table class="log" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:apply-templates select="." mode="stats.header"/>
+ <xsl:apply-templates select="." mode="stats"/>
+ </table>
+
+ <!-- details of methods -->
+ <H3>Methods</H3>
+ <table class="log" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:apply-templates select="method[1]" mode="stats.header"/>
+ <xsl:apply-templates select="method" mode="stats">
+ <xsl:sort data-type="number" select="cov.data/@hit_lines div cov.data/@total_lines"/>
+ </xsl:apply-templates>
+ </table>
+ <xsl:call-template name="pageFooter"/>
+ </BODY>
+ </HTML>
+
+</xsl:template>
+
+<!-- Page Header -->
+<xsl:template name="pageHeader">
+ <!-- jakarta logo -->
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="bannercell" rowspan="2">
+ <a href="http://jakarta.apache.org/">
+ <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
+ </a>
+ </td>
+ <td style="text-align:right"><h2>Source Code Coverage</h2></td>
+ </tr>
+ <tr>
+ <td style="text-align:right">Designed for use with <a href='http://www.sitraka.com/jprobe'>Sitraka JProbe</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+</xsl:template>
+
+<!-- Page Footer -->
+<xsl:template name="pageFooter">
+ <table width="100%">
+ <tr><td><hr noshade="yes" size="1"/></td></tr>
+ <tr><td>
+ <div align="center"><font color="#525D76" size="-1"><em>
+ Copyright © 1999-2001, Apache Software Foundation
+ </em></font></div>
+ </td></tr>
+ </table>
+</xsl:template>
+
+
+<xsl:template name="table.header">
+ <tr>
+ <th width="80%">Name</th>
+ <th width="10%" nowrap="nowrap">Methods Hit</th>
+ <th width="10%" nowrap="nowrap">Lines Hit</th>
+ </tr>
+</xsl:template>
+
+<xsl:template match="method" mode="stats.header">
+ <tr>
+ <th width="90%">Name</th>
+ <th width="10%" nowrap="nowrap">Lines Hit</th>
+ </tr>
+</xsl:template>
+<xsl:template match="method" mode="stats">
+ <tr>
+ <xsl:call-template name="alternate-row"/>
+ <td><xsl:value-of select="@name"/></td>
+ <td>
+ <xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/>
+ </td>
+ </tr>
+</xsl:template>
+
+<xsl:template match="package|class" mode="stats.header">
+ <tr>
+ <th width="80%">Name</th>
+ <th width="10%" nowrap="nowrap">Methods Hit</th>
+ <th width="10%" nowrap="nowrap">Lines Hit</th>
+ </tr>
+</xsl:template>
+<xsl:template match="package|class" mode="stats">
+ <tr>
+ <xsl:call-template name="alternate-row"/>
+ <td><xsl:value-of select="@name"/></td>
+ <td><xsl:value-of select="format-number(cov.data/@hit_methods div cov.data/@total_methods,'0.0%')"/></td>
+ <td><xsl:value-of select="format-number(cov.data/@hit_lines div cov.data/@total_lines,'0.0%')"/></td>
+ </tr>
+</xsl:template>
+
+<!--
+ transform string like a.b.c to ../../../
+ @param path the path to transform into a descending directory path
+-->
+<xsl:template name="path">
+ <xsl:param name="path"/>
+ <xsl:if test="contains($path,'.')">
+ <xsl:text>../</xsl:text>
+ <xsl:call-template name="path">
+ <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="not(contains($path,'.')) and not($path = '')">
+ <xsl:text>../</xsl:text>
+ </xsl:if>
+</xsl:template>
+
+
+<!-- create the link to the stylesheet based on the package name -->
+<xsl:template name="create.stylesheet.link">
+ <xsl:param name="package.name"/>
+ <LINK REL ="stylesheet" TYPE="text/css" TITLE="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></LINK>
+</xsl:template>
+
+<!-- alternated row style -->
+<xsl:template name="alternate-row">
+<xsl:attribute name="class">
+ <xsl:if test="position() mod 2 = 1">a</xsl:if>
+ <xsl:if test="position() mod 2 = 0">b</xsl:if>
+</xsl:attribute>
+</xsl:template>
+
+</xsl:stylesheet>
+
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/coverage-frames.xsl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/jdepend-frames.xsl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/jdepend-frames.xsl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/jdepend-frames.xsl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,522 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:lxslt="http://xml.apache.org/xslt"
+ xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
+ extension-element-prefixes="redirect">
+<xsl:output method="html" indent="yes" encoding="US-ASCII"/>
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 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", "Ant", 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 at 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
+ <http://www.apache.org/>.
+ -->
+<!--
+
+ Sample stylesheet to be used with JDepend XML output.
+
+ It creates a set of HTML files a la javadoc where you can browse easily
+ through all packages and classes.
+
+ @author <a href="mailto:jtulley at novell.com">Jeff Tulley</a>
+
+ -->
+<xsl:param name="output.dir" select="'.'"/>
+
+<xsl:template match="JDepend">
+ <!-- create the index.html -->
+ <redirect:write file="{$output.dir}/index.html">
+ <xsl:call-template name="index.html"/>
+ </redirect:write>
+
+ <!-- create the stylesheet.css -->
+ <redirect:write file="{$output.dir}/stylesheet.css">
+ <xsl:call-template name="stylesheet.css"/>
+ </redirect:write>
+
+ <!-- create the overview-packages.html at the root -->
+ <redirect:write file="{$output.dir}/overview-summary.html">
+ <xsl:apply-templates select="." mode="overview.packages"/>
+ </redirect:write>
+
+ <!-- create the overview-packages.html at the root -->
+ <redirect:write file="{$output.dir}/overview-packages.html">
+ <xsl:apply-templates select="." mode="packages.details"/>
+ </redirect:write>
+
+ <!-- create the overview-cycles.html at the root -->
+ <redirect:write file="{$output.dir}/overview-cycles.html">
+ <xsl:apply-templates select="." mode="cycles.details"/>
+ </redirect:write>
+
+ <!-- create the overview-cycles.html at the root -->
+ <redirect:write file="{$output.dir}/overview-explanations.html">
+ <xsl:apply-templates select="." mode="explanations"/>
+ </redirect:write>
+
+ <!-- create the all-packages.html at the root -->
+ <redirect:write file="{$output.dir}/all-packages.html">
+ <xsl:apply-templates select="Packages" mode="all.packages"/>
+ </redirect:write>
+
+ <!-- create the all-cycles.html at the root -->
+ <redirect:write file="{$output.dir}/all-cycles.html">
+ <xsl:apply-templates select="Cycles" mode="all.cycles"/>
+ </redirect:write>
+</xsl:template>
+
+
+<xsl:template name="index.html">
+<html>
+ <head>
+ <title>JDepend Analysis</title>
+ </head>
+ <frameset cols="20%,80%">
+ <frameset rows="30%,70%">
+ <frame src="all-packages.html" name="packageListFrame"/>
+ <frame src="all-cycles.html" name="classListFrame"/>
+ </frameset>
+ <frame src="overview-summary.html" name="classFrame"/>
+ </frameset>
+ <noframes>
+ <h2>Frame Alert</h2>
+ <p>
+ This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
+ </p>
+ </noframes>
+</html>
+</xsl:template>
+
+<!-- this is the stylesheet css to use for nearly everything -->
+<xsl:template name="stylesheet.css">
+ <style type="text/css">
+ body {
+ font:normal 68% verdana,arial,helvetica;
+ color:#000000;
+ }
+ table tr td, tr th {
+ font-size: 68%;
+ }
+ table.details tr th{
+ font-weight: bold;
+ text-align:left;
+ background:#a6caf0;
+ }
+ table.details tr td{
+ background:#eeeee0;
+ }
+
+ p {
+ line-height:1.5em;
+ margin-top:0.5em; margin-bottom:1.0em;
+ margin-left:2em;
+ margin-right:2em;
+ }
+ h1 {
+ margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
+ }
+ h2 {
+ margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
+ }
+ h3 {
+ margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
+ }
+ h4 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+ }
+ h5 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+ }
+ h6 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+ }
+ .Error {
+ font-weight:bold; color:red;
+ }
+ .Failure {
+ font-weight:bold; color:purple;
+ }
+ .Properties {
+ text-align:right;
+ }
+ </style>
+</xsl:template>
+
+<xsl:template match="JDepend" mode="overview.packages">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <xsl:call-template name="pageHeader"/>
+ <table width="100%"><tr align="left"><h2>Summary</h2><td>
+ </td><td align="right">
+ [summary]
+ [<a href="overview-packages.html">packages</a>]
+ [<a href="overview-cycles.html">cycles</a>]
+ [<a href="overview-explanations.html">explanations</a>]
+ </td></tr></table>
+ <table width="100%" class="details">
+ <tr>
+ <th>Package</th>
+ <th>Total Classes</th>
+ <th><a href="overview-explanations.html#EXnumber">Abstract Classes</a></th>
+ <th><a href="overview-explanations.html#EXnumber">Concrete Classes</a></th>
+ <th><a href="overview-explanations.html#EXafferent">Afferent Couplings</a></th>
+ <th><a href="overview-explanations.html#EXefferent">Efferent Couplings</a></th>
+ <th><a href="overview-explanations.html#EXabstractness">Abstractness</a></th>
+ <th><a href="overview-explanations.html#EXinstability">Instability</a></th>
+ <th><a href="overview-explanations.html#EXdistance">Distance</a></th>
+
+ </tr>
+ <xsl:for-each select="./Packages/Package">
+ <xsl:if test="count(error) = 0">
+ <tr>
+ <td align="left">
+ <a>
+ <xsl:attribute name="href">overview-packages.html#PK<xsl:value-of select="@name"/>
+ </xsl:attribute>
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ <td align="right"><xsl:value-of select="Stats/TotalClasses"/></td>
+ <td align="right"><xsl:value-of select="Stats/AbstractClasses"/></td>
+ <td align="right"><xsl:value-of select="Stats/ConcreteClasses"/></td>
+ <td align="right"><xsl:value-of select="Stats/Ca"/></td>
+ <td align="right"><xsl:value-of select="Stats/Ce"/></td>
+ <td align="right"><xsl:value-of select="Stats/A"/></td>
+ <td align="right"><xsl:value-of select="Stats/I"/></td>
+ <td align="right"><xsl:value-of select="Stats/D"/></td>
+ </tr>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:for-each select="./Packages/Package">
+ <xsl:if test="count(error) > 0">
+ <tr>
+ <td align="left">
+ <xsl:value-of select="@name"/>
+ </td>
+ <td align="left" colspan="8"><xsl:value-of select="error"/></td>
+ </tr>
+ </xsl:if>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="JDepend" mode="packages.details">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <xsl:call-template name="pageHeader"/>
+ <table width="100%"><tr align="left"><h2>Packages</h2><td>
+ </td><td align="right">
+ [<a href="overview-summary.html">summary</a>]
+ [packages]
+ [<a href="overview-cycles.html">cycles</a>]
+ [<a href="overview-explanations.html">explanations</a>]
+ </td></tr></table>
+
+ <xsl:for-each select="./Packages/Package">
+ <xsl:if test="count(error) = 0">
+ <h3><a><xsl:attribute name="name">PK<xsl:value-of select="@name"/></xsl:attribute>
+ <xsl:value-of select="@name"/></a></h3>
+
+ <table width="100%"><tr>
+ <td><a href="overview-explanations.html#EXafferent">Afferent Couplings</a>: <xsl:value-of select="Stats/Ca"/></td>
+ <td><a href="overview-explanations.html#EXefferent">Efferent Couplings</a>: <xsl:value-of select="Stats/Ce"/></td>
+ <td><a href="overview-explanations.html#EXabstractness">Abstractness</a>: <xsl:value-of select="Stats/A"/></td>
+ <td><a href="overview-explanations.html#EXinstability">Instability</a>: <xsl:value-of select="Stats/I"/></td>
+ <td><a href="overview-explanations.html#EXdistance">Distance</a>: <xsl:value-of select="Stats/D"/></td>
+ </tr></table>
+
+ <table width="100%" class="details">
+ <tr>
+ <th>Abstract Classes</th>
+ <th>Concrete Classes</th>
+ <th>Used by Packages</th>
+ <th>Uses Packages</th>
+ </tr>
+ <tr>
+ <td valign="top" width="25%">
+ <xsl:if test="count(AbstractClasses/Class)=0">
+ <i>None</i>
+ </xsl:if>
+ <xsl:for-each select="AbstractClasses/Class">
+ <xsl:value-of select="node()"/><br/>
+ </xsl:for-each>
+ </td>
+ <td valign="top" width="25%">
+ <xsl:if test="count(ConcreteClasses/Class)=0">
+ <i>None</i>
+ </xsl:if>
+ <xsl:for-each select="ConcreteClasses/Class">
+ <xsl:value-of select="node()"/><br/>
+ </xsl:for-each>
+ </td>
+ <td valign="top" width="25%">
+ <xsl:if test="count(UsedBy/Package)=0">
+ <i>None</i>
+ </xsl:if>
+ <xsl:for-each select="UsedBy/Package">
+ <a>
+ <xsl:attribute name="href">overview-packages.html#PK<xsl:value-of select="node()"/></xsl:attribute>
+ <xsl:value-of select="node()"/>
+ </a><br/>
+ </xsl:for-each>
+ </td>
+ <td valign="top" width="25%">
+ <xsl:if test="count(DependsUpon/Package)=0">
+ <i>None</i>
+ </xsl:if>
+ <xsl:for-each select="DependsUpon/Package">
+ <a>
+ <xsl:attribute name="href">overview-packages.html#PK<xsl:value-of select="node()"/></xsl:attribute>
+ <xsl:value-of select="node()"/>
+ </a><br/>
+ </xsl:for-each>
+ </td>
+ </tr>
+ </table>
+ </xsl:if>
+ </xsl:for-each>
+ <!-- this is often a long listing; provide a lower navigation table also -->
+ <table width="100%"><tr align="left"><td></td><td align="right">
+ [<a href="overview-summary.html">summary</a>]
+ [packages]
+ [<a href="overview-cycles.html">cycles</a>]
+ [<a href="overview-explanations.html">explanations</a>]
+ </td></tr></table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="JDepend" mode="cycles.details">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <xsl:call-template name="pageHeader"/>
+ <table width="100%"><tr align="left"><h2>Cycles</h2><td>
+ </td><td align="right">
+ [<a href="overview-summary.html">summary</a>]
+ [<a href="overview-packages.html">packages</a>]
+ [cycles]
+ [<a href="overview-explanations.html">explanations</a>]
+ </td></tr></table>
+ <!--<table width="100%"><tr><td>
+ </td><td align="right">
+ [<a href="#NVsummary">summary</a>]
+ [<a href="#NVpackages">packages</a>]
+ [<a href="#NVcycles">cycles</a>]
+ [<a href="#NVexplanations">explanations</a>]
+ </td></tr></table> -->
+
+ <xsl:if test="count(Cycles/Package) = 0">
+ <p>There are no cyclic dependancies.</p>
+ </xsl:if>
+ <xsl:for-each select="Cycles/Package">
+ <h3><a><xsl:attribute name="name">#CY<xsl:value-of select="@Name"/></xsl:attribute><xsl:value-of select="@Name"/></a></h3><p>
+ <xsl:for-each select="Package">
+ <xsl:value-of select="."/><br/>
+ </xsl:for-each></p>
+ </xsl:for-each>
+ <!-- this is often a long listing; provide a lower navigation table also -->
+ <table width="100%"><tr align="left"><td></td><td align="right">
+ [<a href="overview-summary.html">summary</a>]
+ [<a href="overview-packages.html">packages</a>]
+ [cycles]
+ [<a href="overview-explanations.html">explanations</a>]
+ </td></tr></table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="JDepend" mode="explanations">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <xsl:call-template name="pageHeader"/>
+
+ <table width="100%"><tr align="left"><h2>Explanations</h2><td>
+ </td><td align="right">
+ [<a href="overview-summary.html">summary</a>]
+ [<a href="overview-packages.html">packages</a>]
+ [<a href="overview-cycles.html">cycles</a>]
+ [explanations]
+ </td></tr></table>
+
+ <p>The following explanations are for quick reference and are lifted directly from the original <a href="http://www.clarkware.com/software/JDepend.html">JDepend documentation</a>.</p>
+
+ <h3><a name="EXnumber">Number of Classes</a></h3>
+ <p>The number of concrete and abstract classes (and interfaces) in the package is an indicator of the extensibility of the package.</p>
+ <h3><a name="EXafferent">Afferent Couplings</a></h3>
+ <p>The number of other packages that depend upon classes within the package is an indicator of the package's responsibility. </p>
+ <h3><a name="EXefferent">Efferent Couplings</a></h3>
+ <p>The number of other packages that the classes in the package depend upon is an indicator of the package's independence. </p>
+ <h3><a name="EXabstractness">Abstractness</a></h3>
+ <p>The ratio of the number of abstract classes (and interfaces) in the analyzed package to the total number of classes in the analyzed package. </p>
+ <p>The range for this metric is 0 to 1, with A=0 indicating a completely concrete package and A=1 indicating a completely abstract package. </p>
+ <h3><a name="EXinstability">Instability</a></h3>
+ <p>The ratio of efferent coupling (Ce) to total coupling (Ce / (Ce + Ca)). This metric is an indicator of the package's resilience to change. </p>
+ <p>The range for this metric is 0 to 1, with I=0 indicating a completely stable package and I=1 indicating a completely instable package. </p>
+ <h3><a name="EXdistance">Distance</a></h3>
+ <p>The perpendicular distance of a package from the idealized line A + I = 1. This metric is an indicator of the package's balance between abstractness and stability. </p>
+ <p>A package squarely on the main sequence is optimally balanced with respect to its abstractness and stability. Ideal packages are either completely abstract and stable (x=0, y=1) or completely concrete and instable (x=1, y=0). </p>
+ <p>The range for this metric is 0 to 1, with D=0 indicating a package that is coincident with the main sequence and D=1 indicating a package that is as far from the main sequence as possible. </p>
+
+ </body>
+ </html>
+</xsl:template>
+
+
+<!--
+Creates an html file that contains a link to all package links in overview-packages.html.
+ @bug there will be a problem here, I don't know yet how to handle unnamed package :(
+-->
+<xsl:template match="JDepend/Packages" mode="all.packages">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <table width="100%"><tr align="left"><td></td><td nowrap="nowrap" align="right">
+ [<a href="overview-summary.html" target="classFrame">summary</a>]
+ [<a href="overview-packages.html" target="classFrame">packages</a>]
+ [<a href="overview-cycles.html" target="classFrame">cycles</a>]
+ [<a href="overview-explanations.html" target="classFrame">explanations</a>]
+ </td></tr></table>
+ <h2>Packages</h2>
+ <table width="100%">
+ <xsl:apply-templates select="Package[count(error)=0]" mode="all.packages.link">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="Package[count(error) > 0]" mode="all.packages.nolink">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="JDepend/Packages/Package" mode="all.packages.link">
+ <tr>
+ <td nowrap="nowrap">
+ <a href="overview-packages.html#PK{@name}" target="classFrame">
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ </tr>
+</xsl:template>
+
+<!--
+I do not know JDepend enough to know if every error results in a non-analyzed package,
+but that is how I am presenting it to the viewer. This may need to change.
+ @bug there will be a problem here, I don't know yet how to handle unnamed package :(
+-->
+<xsl:template match="JDepend/Packages/Package" mode="all.packages.nolink">
+ <tr>
+ <td nowrap="nowrap">
+ Not Analyzed: <xsl:value-of select="@name"/>
+ </td>
+ </tr>
+</xsl:template>
+
+<!--
+Creates an html file that contains a link to all package links in overview-cycles.html.
+ @bug there will be a problem here, I don't know yet how to handle unnamed package :(
+-->
+<xsl:template match="JDepend/Cycles" mode="all.cycles">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <table width="100%"><tr align="left"><td></td><td nowrap="nowrap" align="right">
+ [<a href="overview-summary.html" target="classFrame">summary</a>]
+ [<a href="overview-packages.html" target="classFrame">packages</a>]
+ [<a href="overview-cycles.html" target="classFrame">cycles</a>]
+ [<a href="overview-explanations.html" target="classFrame">explanations</a>]
+ </td></tr></table>
+ <h2>Cycles</h2>
+ <table width="100%">
+ <xsl:apply-templates select="Package" mode="all.cycles">
+ <xsl:sort select="@Name"/>
+ </xsl:apply-templates>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="JDepend/Cycles/Package" mode="all.cycles">
+ <tr>
+ <td nowrap="nowrap">
+ <a href="overview-cycles.html#CY{@Name}" target="classFrame"><xsl:value-of select="@Name"/></a>
+ </td>
+ </tr>
+</xsl:template>
+
+<!-- Page HEADER -->
+<xsl:template name="pageHeader">
+ <h1>JDepend Analysis</h1>
+ <table width="100%">
+ <tr>
+ <td align="left"></td>
+ <td align="right">Designed for use with <a href="http://www.clarkware.com/software/JDepend.html">JDepend</a> and <a href="http://jakarta.apache.org">Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+</xsl:template>
+
+</xsl:stylesheet>
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/jdepend-frames.xsl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/jdepend.xsl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/jdepend.xsl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/jdepend.xsl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,312 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 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", "Ant", 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 at 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
+ <http://www.apache.org/>.
+ -->
+
+<xsl:output method="html" indent="yes" encoding="US-ASCII"/>
+
+<xsl:template match="JDepend">
+ <html>
+ <head>
+ <title>JDepend Analysis</title>
+
+ <style type="text/css">
+ body {
+ font:normal 68% verdana,arial,helvetica;
+ color:#000000;
+ }
+ table tr td, tr th {
+ font-size: 68%;
+ }
+ table.details tr th{
+ font-weight: bold;
+ text-align:left;
+ background:#a6caf0;
+ }
+ table.details tr td{
+ background:#eeeee0;
+ }
+
+ p {
+ line-height:1.5em;
+ margin-top:0.5em; margin-bottom:1.0em;
+ margin-left:2em;
+ margin-right:2em;
+ }
+ h1 {
+ margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
+ }
+ h2 {
+ margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
+ }
+ h3 {
+ margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
+ }
+ h4 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+ }
+ h5 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+ }
+ h6 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+ }
+ .Error {
+ font-weight:bold; color:red;
+ }
+ .Failure {
+ font-weight:bold; color:purple;
+ }
+ .Properties {
+ text-align:right;
+ }
+ </style>
+
+
+ </head>
+ <body>
+ <!--h1>JDepend Report</h1>
+ <ul>
+ <xsl:for-each select="./Packages/Package">
+ <xsl:sort select="@name"/>
+ <li><xsl:value-of select="@name"/></li>
+ </xsl:for-each>
+ </ul-->
+
+ <h1><a name="top">JDepend Analysis</a></h1>
+ <p align="right">Designed for use with <a href="http://www.clarkware.com/software/JDepend.html">JDepend</a> and <a href="http://jakarta.apache.org">Ant</a>.</p>
+ <hr size="2" />
+
+ <table width="100%"><tr><td>
+ <a name="NVsummary"><h2>Summary</h2></a>
+ </td><td align="right">
+ [<a href="#NVsummary">summary</a>]
+ [<a href="#NVpackages">packages</a>]
+ [<a href="#NVcycles">cycles</a>]
+ [<a href="#NVexplanations">explanations</a>]
+ </td></tr></table>
+
+ <table width="100%" class="details">
+ <tr>
+ <th>Package</th>
+ <th>Total Classes</th>
+ <th><a href="#EXnumber">Abstract Classes</a></th>
+ <th><a href="#EXnumber">Concrete Classes</a></th>
+ <th><a href="#EXafferent">Afferent Couplings</a></th>
+ <th><a href="#EXefferent">Efferent Couplings</a></th>
+ <th><a href="#EXabstractness">Abstractness</a></th>
+ <th><a href="#EXinstability">Instability</a></th>
+ <th><a href="#EXdistance">Distance</a></th>
+
+ </tr>
+ <xsl:for-each select="./Packages/Package">
+ <xsl:if test="count(error) = 0">
+ <tr>
+ <td align="left">
+ <a>
+ <xsl:attribute name="href">#PK<xsl:value-of select="@name"/>
+ </xsl:attribute>
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ <td align="right"><xsl:value-of select="Stats/TotalClasses"/></td>
+ <td align="right"><xsl:value-of select="Stats/AbstractClasses"/></td>
+ <td align="right"><xsl:value-of select="Stats/ConcreteClasses"/></td>
+ <td align="right"><xsl:value-of select="Stats/Ca"/></td>
+ <td align="right"><xsl:value-of select="Stats/Ce"/></td>
+ <td align="right"><xsl:value-of select="Stats/A"/></td>
+ <td align="right"><xsl:value-of select="Stats/I"/></td>
+ <td align="right"><xsl:value-of select="Stats/D"/></td>
+
+
+ </tr>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:for-each select="./Packages/Package">
+ <xsl:if test="count(error) > 0">
+ <tr>
+ <td align="left">
+ <xsl:value-of select="@name"/>
+ </td>
+ <td align="left" colspan="8"><xsl:value-of select="error"/></td>
+ </tr>
+ </xsl:if>
+ </xsl:for-each>
+ </table>
+
+ <table width="100%"><tr><td>
+ <a name="NVpackages"><h2>Packages</h2></a>
+ </td><td align="right">
+ [<a href="#NVsummary">summary</a>]
+ [<a href="#NVpackages">packages</a>]
+ [<a href="#NVcycles">cycles</a>]
+ [<a href="#NVexplanations">explanations</a>]
+ </td></tr></table>
+
+ <xsl:for-each select="./Packages/Package">
+ <xsl:if test="count(error) = 0">
+ <h3><a><xsl:attribute name="name">PK<xsl:value-of select="@name"/></xsl:attribute>
+ <xsl:value-of select="@name"/></a></h3>
+
+ <table width="100%"><tr>
+ <td><a href="#EXafferent">Afferent Couplings</a>: <xsl:value-of select="Stats/Ca"/></td>
+ <td><a href="#EXefferent">Efferent Couplings</a>: <xsl:value-of select="Stats/Ce"/></td>
+ <td><a href="#EXabstractness">Abstractness</a>: <xsl:value-of select="Stats/A"/></td>
+ <td><a href="#EXinstability">Instability</a>: <xsl:value-of select="Stats/I"/></td>
+ <td><a href="#EXdistance">Distance</a>: <xsl:value-of select="Stats/D"/></td>
+ </tr></table>
+
+ <table width="100%" class="details">
+ <tr>
+ <th>Abstract Classes</th>
+ <th>Concrete Classes</th>
+ <th>Used by Packages</th>
+ <th>Uses Packages</th>
+ </tr>
+ <tr>
+ <td valign="top" width="25%">
+ <xsl:if test="count(AbstractClasses/Class)=0">
+ <i>None</i>
+ </xsl:if>
+ <xsl:for-each select="AbstractClasses/Class">
+ <xsl:value-of select="node()"/><br/>
+ </xsl:for-each>
+ </td>
+ <td valign="top" width="25%">
+ <xsl:if test="count(ConcreteClasses/Class)=0">
+ <i>None</i>
+ </xsl:if>
+ <xsl:for-each select="ConcreteClasses/Class">
+ <xsl:value-of select="node()"/><br/>
+ </xsl:for-each>
+ </td>
+ <td valign="top" width="25%">
+ <xsl:if test="count(UsedBy/Package)=0">
+ <i>None</i>
+ </xsl:if>
+ <xsl:for-each select="UsedBy/Package">
+ <a>
+ <xsl:attribute name="href">#PK<xsl:value-of select="node()"/></xsl:attribute>
+ <xsl:value-of select="node()"/>
+ </a><br/>
+ </xsl:for-each>
+ </td>
+ <td valign="top" width="25%">
+ <xsl:if test="count(DependsUpon/Package)=0">
+ <i>None</i>
+ </xsl:if>
+ <xsl:for-each select="DependsUpon/Package">
+ <a>
+ <xsl:attribute name="href">#PK<xsl:value-of select="node()"/></xsl:attribute>
+ <xsl:value-of select="node()"/>
+ </a><br/>
+ </xsl:for-each>
+ </td>
+ </tr>
+ </table>
+ </xsl:if>
+ </xsl:for-each>
+
+ <table width="100%"><tr><td>
+ <a name="NVcycles"><h2>Cycles</h2></a>
+ </td><td align="right">
+ [<a href="#NVsummary">summary</a>]
+ [<a href="#NVpackages">packages</a>]
+ [<a href="#NVcycles">cycles</a>]
+ [<a href="#NVexplanations">explanations</a>]
+ </td></tr></table>
+
+ <xsl:if test="count(Cycles/Package) = 0">
+ <p>There are no cyclic dependancies.</p>
+ </xsl:if>
+ <xsl:for-each select="Cycles/Package">
+ <h3><xsl:value-of select="@Name"/></h3><p>
+ <xsl:for-each select="Package">
+ <xsl:value-of select="."/><br/>
+ </xsl:for-each></p>
+ </xsl:for-each>
+
+ <table width="100%"><tr><td>
+ <a name="NVexplanations"><h2>Explanations</h2></a>
+ </td><td align="right">
+ [<a href="#NVsummary">summary</a>]
+ [<a href="#NVpackages">packages</a>]
+ [<a href="#NVcycles">cycles</a>]
+ [<a href="#NVexplanations">explanations</a>]
+ </td></tr></table>
+
+ <p>The following explanations are for quick reference and are lifted directly from the original <a href="http://www.clarkware.com/software/JDepend.html">JDepend documentation</a>.</p>
+
+ <h3><a name="EXnumber">Number of Classes</a></h3>
+ <p>The number of concrete and abstract classes (and interfaces) in the package is an indicator of the extensibility of the package.</p>
+ <h3><a name="EXafferent">Afferent Couplings</a></h3>
+ <p>The number of other packages that depend upon classes within the package is an indicator of the package's responsibility. </p>
+ <h3><a name="EXefferent">Efferent Couplings</a></h3>
+ <p>The number of other packages that the classes in the package depend upon is an indicator of the package's independence. </p>
+ <h3><a name="EXabstractness">Abstractness</a></h3>
+ <p>The ratio of the number of abstract classes (and interfaces) in the analyzed package to the total number of classes in the analyzed package. </p>
+ <p>The range for this metric is 0 to 1, with A=0 indicating a completely concrete package and A=1 indicating a completely abstract package. </p>
+ <h3><a name="EXinstability">Instability</a></h3>
+ <p>The ratio of efferent coupling (Ce) to total coupling (Ce / (Ce + Ca)). This metric is an indicator of the package's resilience to change. </p>
+ <p>The range for this metric is 0 to 1, with I=0 indicating a completely stable package and I=1 indicating a completely instable package. </p>
+ <h3><a name="EXdistance">Distance</a></h3>
+ <p>The perpendicular distance of a package from the idealized line A + I = 1. This metric is an indicator of the package's balance between abstractness and stability. </p>
+ <p>A package squarely on the main sequence is optimally balanced with respect to its abstractness and stability. Ideal packages are either completely abstract and stable (x=0, y=1) or completely concrete and instable (x=1, y=0). </p>
+ <p>The range for this metric is 0 to 1, with D=0 indicating a package that is coincident with the main sequence and D=1 indicating a package that is as far from the main sequence as possible. </p>
+
+ </body>
+ </html>
+</xsl:template>
+
+</xsl:stylesheet>
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/jdepend.xsl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/junit-frames.xsl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/junit-frames.xsl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/junit-frames.xsl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,741 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:lxslt="http://xml.apache.org/xslt"
+ xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
+ extension-element-prefixes="redirect">
+<xsl:output method="html" indent="yes" encoding="US-ASCII"/>
+<xsl:decimal-format decimal-separator="." grouping-separator=","/>
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 2001-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", "Ant", 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 at 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
+ <http://www.apache.org/>.
+ -->
+
+<!--
+
+ Sample stylesheet to be used with An JUnitReport output.
+
+ It creates a set of HTML files a la javadoc where you can browse easily
+ through all packages and classes.
+
+ @author Stephane Bailliez <a href="mailto:sbailliez at apache.org"/>
+ @author Erik Hatcher <a href="mailto:ehatcher at apache.org"/>
+
+-->
+<xsl:param name="output.dir" select="'.'"/>
+
+
+<xsl:template match="testsuites">
+ <!-- create the index.html -->
+ <redirect:write file="{$output.dir}/index.html">
+ <xsl:call-template name="index.html"/>
+ </redirect:write>
+
+ <!-- create the stylesheet.css -->
+ <redirect:write file="{$output.dir}/stylesheet.css">
+ <xsl:call-template name="stylesheet.css"/>
+ </redirect:write>
+
+ <!-- create the overview-packages.html at the root -->
+ <redirect:write file="{$output.dir}/overview-summary.html">
+ <xsl:apply-templates select="." mode="overview.packages"/>
+ </redirect:write>
+
+ <!-- create the all-packages.html at the root -->
+ <redirect:write file="{$output.dir}/overview-frame.html">
+ <xsl:apply-templates select="." mode="all.packages"/>
+ </redirect:write>
+
+ <!-- create the all-classes.html at the root -->
+ <redirect:write file="{$output.dir}/allclasses-frame.html">
+ <xsl:apply-templates select="." mode="all.classes"/>
+ </redirect:write>
+
+ <!-- process all packages -->
+ <xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
+ <xsl:call-template name="package">
+ <xsl:with-param name="name" select="@package"/>
+ </xsl:call-template>
+ </xsl:for-each>
+</xsl:template>
+
+
+<xsl:template name="package">
+ <xsl:param name="name"/>
+ <xsl:variable name="package.dir">
+ <xsl:if test="not($name = '')"><xsl:value-of select="translate($name,'.','/')"/></xsl:if>
+ <xsl:if test="$name = ''">.</xsl:if>
+ </xsl:variable>
+ <!--Processing package <xsl:value-of select="@name"/> in <xsl:value-of select="$output.dir"/> -->
+ <!-- create a classes-list.html in the package directory -->
+ <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
+ <xsl:call-template name="classes.list">
+ <xsl:with-param name="name" select="$name"/>
+ </xsl:call-template>
+ </redirect:write>
+
+ <!-- create a package-summary.html in the package directory -->
+ <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
+ <xsl:call-template name="package.summary">
+ <xsl:with-param name="name" select="$name"/>
+ </xsl:call-template>
+ </redirect:write>
+
+ <!-- for each class, creates a @name.html -->
+ <!-- @bug there will be a problem with inner classes having the same name, it will be overwritten -->
+ <xsl:for-each select="/testsuites/testsuite[@package = $name]">
+ <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
+ <xsl:apply-templates select="." mode="class.details"/>
+ </redirect:write>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template name="index.html">
+<html>
+ <head>
+ <title>Unit Test Results.</title>
+ </head>
+ <frameset cols="20%,80%">
+ <frameset rows="30%,70%">
+ <frame src="overview-frame.html" name="packageListFrame"/>
+ <frame src="allclasses-frame.html" name="classListFrame"/>
+ </frameset>
+ <frame src="overview-summary.html" name="classFrame"/>
+ <noframes>
+ <h2>Frame Alert</h2>
+ <p>
+ This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
+ </p>
+ </noframes>
+ </frameset>
+</html>
+</xsl:template>
+
+<!-- this is the stylesheet css to use for nearly everything -->
+<xsl:template name="stylesheet.css">
+body {
+ font:normal 68% verdana,arial,helvetica;
+ color:#000000;
+}
+table tr td, table tr th {
+ font-size: 68%;
+}
+table.details tr th{
+ font-weight: bold;
+ text-align:left;
+ background:#a6caf0;
+}
+table.details tr td{
+ background:#eeeee0;
+}
+
+p {
+ line-height:1.5em;
+ margin-top:0.5em; margin-bottom:1.0em;
+}
+h1 {
+ margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
+}
+h2 {
+ margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
+}
+h3 {
+ margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
+}
+h4 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+}
+h5 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+}
+h6 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+}
+.Error {
+ font-weight:bold; color:red;
+}
+.Failure {
+ font-weight:bold; color:purple;
+}
+.Properties {
+ text-align:right;
+}
+</xsl:template>
+
+
+<!-- ======================================================================
+ This page is created for every testsuite class.
+ It prints a summary of the testsuite and detailed information about
+ testcase methods.
+ ====================================================================== -->
+<xsl:template match="testsuite" mode="class.details">
+ <xsl:variable name="package.name" select="@package"/>
+ <xsl:variable name="class.name"><xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></xsl:variable>
+ <html>
+ <head>
+ <title>Unit Test Results: <xsl:value-of select="$class.name"/></title>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="$package.name"/>
+ </xsl:call-template>
+ <script type="text/javascript" language="JavaScript">
+ var TestCases = new Array();
+ var cur;
+ <xsl:apply-templates select="properties"/>
+ </script>
+ <script type="text/javascript" language="JavaScript"><![CDATA[
+ function displayProperties (name) {
+ var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1');
+ var doc = win.document.open();
+ doc.write("<html><head><title>Properties of " + name + "</title>");
+ doc.write("<style type=\"text/css\">");
+ doc.write("body {font:normal 68% verdana,arial,helvetica; color:#000000; }");
+ doc.write("table tr td, table tr th { font-size: 68%; }");
+ doc.write("table.properties { border-collapse:collapse; border-left:solid 1 #cccccc; border-top:solid 1 #cccccc; padding:5px; }");
+ doc.write("table.properties th { text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#eeeeee; }");
+ doc.write("table.properties td { font:normal; text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#fffffff; }");
+ doc.write("h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica }");
+ doc.write("</style>");
+ doc.write("</head><body>");
+ doc.write("<h3>Properties of " + name + "</h3>");
+ doc.write("<div align=\"right\"><a href=\"javascript:window.close();\">Close</a></div>");
+ doc.write("<table class='properties'>");
+ doc.write("<tr><th>Name</th><th>Value</th></tr>");
+ for (prop in TestCases[name]) {
+ doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop] + "</td></tr>");
+ }
+ doc.write("</table>");
+ doc.write("</body></html>");
+ doc.close();
+ win.focus();
+ }
+ ]]>
+ </script>
+ </head>
+ <body>
+ <xsl:call-template name="pageHeader"/>
+ <h3>Class <xsl:value-of select="$class.name"/></h3>
+
+
+ <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
+ <xsl:call-template name="testsuite.test.header"/>
+ <xsl:apply-templates select="." mode="print.test"/>
+ </table>
+
+ <h2>Tests</h2>
+ <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
+ <xsl:call-template name="testcase.test.header"/>
+ <!--
+ test can even not be started at all (failure to load the class)
+ so report the error directly
+ -->
+ <xsl:if test="./error">
+ <tr class="Error">
+ <td colspan="4"><xsl:apply-templates select="./error"/></td>
+ </tr>
+ </xsl:if>
+ <xsl:apply-templates select="./testcase" mode="print.test"/>
+ </table>
+ <div class="Properties">
+ <a>
+ <xsl:attribute name="href">javascript:displayProperties('<xsl:value-of select="@package"/>.<xsl:value-of select="@name"/>');</xsl:attribute>
+ Properties »
+ </a>
+ </div>
+ </body>
+ </html>
+</xsl:template>
+
+ <!--
+ Write properties into a JavaScript data structure.
+ This is based on the original idea by Erik Hatcher (ehatcher at apache.org)
+ -->
+ <xsl:template match="properties">
+ cur = TestCases['<xsl:value-of select="../@package"/>.<xsl:value-of select="../@name"/>'] = new Array();
+ <xsl:for-each select="property">
+ <xsl:sort select="@name"/>
+ cur['<xsl:value-of select="@name"/>'] = '<xsl:call-template name="JS-escape"><xsl:with-param name="string" select="@value"/></xsl:call-template>';
+ </xsl:for-each>
+ </xsl:template>
+
+
+<!-- ======================================================================
+ This page is created for every package.
+ It prints the name of all classes that belongs to this package.
+ @param name the package name to print classes.
+ ====================================================================== -->
+<!-- list of classes in a package -->
+<xsl:template name="classes.list">
+ <xsl:param name="name"/>
+ <html>
+ <head>
+ <title>Unit Test Classes: <xsl:value-of select="$name"/></title>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="$name"/>
+ </xsl:call-template>
+ </head>
+ <body>
+ <table width="100%">
+ <tr>
+ <td nowrap="nowrap">
+ <h2><a href="package-summary.html" target="classFrame"><xsl:value-of select="$name"/></a></h2>
+ </td>
+ </tr>
+ </table>
+
+ <h2>Classes</h2>
+ <table width="100%">
+ <xsl:for-each select="/testsuites/testsuite[./@package = $name]">
+ <xsl:sort select="@name"/>
+ <tr>
+ <td nowrap="nowrap">
+ <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+
+<!--
+ Creates an all-classes.html file that contains a link to all package-summary.html
+ on each class.
+-->
+<xsl:template match="testsuites" mode="all.classes">
+ <html>
+ <head>
+ <title>All Unit Test Classes</title>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name"/>
+ </xsl:call-template>
+ </head>
+ <body>
+ <h2>Classes</h2>
+ <table width="100%">
+ <xsl:apply-templates select="testsuite" mode="all.classes">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="testsuite" mode="all.classes">
+ <xsl:variable name="package.name" select="@package"/>
+ <tr>
+ <td nowrap="nowrap">
+ <a target="classFrame">
+ <xsl:attribute name="href">
+ <xsl:if test="not($package.name='')">
+ <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
+ </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ </tr>
+</xsl:template>
+
+
+<!--
+ Creates an html file that contains a link to all package-summary.html files on
+ each package existing on testsuites.
+ @bug there will be a problem here, I don't know yet how to handle unnamed package :(
+-->
+<xsl:template match="testsuites" mode="all.packages">
+ <html>
+ <head>
+ <title>All Unit Test Packages</title>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name"/>
+ </xsl:call-template>
+ </head>
+ <body>
+ <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
+ <h2>Packages</h2>
+ <table width="100%">
+ <xsl:apply-templates select="testsuite[not(./@package = preceding-sibling::testsuite/@package)]" mode="all.packages">
+ <xsl:sort select="@package"/>
+ </xsl:apply-templates>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="testsuite" mode="all.packages">
+ <tr>
+ <td nowrap="nowrap">
+ <a href="{translate(@package,'.','/')}/package-summary.html" target="classFrame">
+ <xsl:value-of select="@package"/>
+ </a>
+ </td>
+ </tr>
+</xsl:template>
+
+
+<xsl:template match="testsuites" mode="overview.packages">
+ <html>
+ <head>
+ <title>Unit Test Results: Summary</title>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name"/>
+ </xsl:call-template>
+ </head>
+ <body>
+ <xsl:attribute name="onload">open('allclasses-frame.html','classListFrame')</xsl:attribute>
+ <xsl:call-template name="pageHeader"/>
+ <h2>Summary</h2>
+ <xsl:variable name="testCount" select="sum(testsuite/@tests)"/>
+ <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/>
+ <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/>
+ <xsl:variable name="timeCount" select="sum(testsuite/@time)"/>
+ <xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
+ <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
+ <tr valign="top">
+ <th>Tests</th>
+ <th>Failures</th>
+ <th>Errors</th>
+ <th>Success rate</th>
+ <th>Time</th>
+ </tr>
+ <tr valign="top">
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="$errorCount > 0">Error</xsl:when>
+ <xsl:when test="$failureCount > 0">Failure</xsl:when>
+ <xsl:otherwise>Pass</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <td><xsl:value-of select="$testCount"/></td>
+ <td><xsl:value-of select="$failureCount"/></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ <td>
+ <xsl:call-template name="display-percent">
+ <xsl:with-param name="value" select="$successRate"/>
+ </xsl:call-template>
+ </td>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="$timeCount"/>
+ </xsl:call-template>
+ </td>
+
+ </tr>
+ </table>
+ <table border="0" width="95%">
+ <tr>
+ <td style="text-align: justify;">
+ Note: <em>failures</em> are anticipated and checked for with assertions while <em>errors</em> are unanticipated.
+ </td>
+ </tr>
+ </table>
+
+ <h2>Packages</h2>
+ <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
+ <xsl:call-template name="testsuite.test.header"/>
+ <xsl:for-each select="testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
+ <xsl:sort select="@package" order="ascending"/>
+ <!-- get the node set containing all testsuites that have the same package -->
+ <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = current()/@package]"/>
+ <tr valign="top">
+ <!-- display a failure if there is any failure/error in the package -->
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="sum($insamepackage/@errors) > 0">Error</xsl:when>
+ <xsl:when test="sum($insamepackage/@failures) > 0">Failure</xsl:when>
+ <xsl:otherwise>Pass</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <td><a href="{translate(@package,'.','/')}/package-summary.html"><xsl:value-of select="@package"/></a></td>
+ <td><xsl:value-of select="sum($insamepackage/@tests)"/></td>
+ <td><xsl:value-of select="sum($insamepackage/@errors)"/></td>
+ <td><xsl:value-of select="sum($insamepackage/@failures)"/></td>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="sum($insamepackage/@time)"/>
+ </xsl:call-template>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+
+<xsl:template name="package.summary">
+ <xsl:param name="name"/>
+ <html>
+ <head>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="$name"/>
+ </xsl:call-template>
+ </head>
+ <body>
+ <xsl:attribute name="onload">open('package-frame.html','classListFrame')</xsl:attribute>
+ <xsl:call-template name="pageHeader"/>
+ <h3>Package <xsl:value-of select="$name"/></h3>
+
+ <!--table border="0" cellpadding="5" cellspacing="2" width="95%">
+ <xsl:call-template name="class.metrics.header"/>
+ <xsl:apply-templates select="." mode="print.metrics"/>
+ </table-->
+
+ <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = $name]"/>
+ <xsl:if test="count($insamepackage) > 0">
+ <h2>Classes</h2>
+ <p>
+ <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
+ <xsl:call-template name="testsuite.test.header"/>
+ <xsl:apply-templates select="$insamepackage" mode="print.test">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </p>
+ </xsl:if>
+ </body>
+ </html>
+</xsl:template>
+
+
+<!--
+ transform string like a.b.c to ../../../
+ @param path the path to transform into a descending directory path
+-->
+<xsl:template name="path">
+ <xsl:param name="path"/>
+ <xsl:if test="contains($path,'.')">
+ <xsl:text>../</xsl:text>
+ <xsl:call-template name="path">
+ <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="not(contains($path,'.')) and not($path = '')">
+ <xsl:text>../</xsl:text>
+ </xsl:if>
+</xsl:template>
+
+
+<!-- create the link to the stylesheet based on the package name -->
+<xsl:template name="create.stylesheet.link">
+ <xsl:param name="package.name"/>
+ <link rel="stylesheet" type="text/css" title="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></link>
+</xsl:template>
+
+
+<!-- Page HEADER -->
+<xsl:template name="pageHeader">
+ <h1>Unit Test Results</h1>
+ <table width="100%">
+ <tr>
+ <td align="left"></td>
+ <td align="right">Designed for use with <a href="http://www.junit.org/">JUnit</a> and <a href="http://jakarta.apache.org/">Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+</xsl:template>
+
+<!-- class header -->
+<xsl:template name="testsuite.test.header">
+ <tr valign="top">
+ <th width="80%">Name</th>
+ <th>Tests</th>
+ <th>Errors</th>
+ <th>Failures</th>
+ <th nowrap="nowrap">Time(s)</th>
+ </tr>
+</xsl:template>
+
+<!-- method header -->
+<xsl:template name="testcase.test.header">
+ <tr valign="top">
+ <th>Name</th>
+ <th>Status</th>
+ <th width="80%">Type</th>
+ <th nowrap="nowrap">Time(s)</th>
+ </tr>
+</xsl:template>
+
+
+<!-- class information -->
+<xsl:template match="testsuite" mode="print.test">
+ <tr valign="top">
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@errors[.> 0]">Error</xsl:when>
+ <xsl:when test="@failures[.> 0]">Failure</xsl:when>
+ <xsl:otherwise>Pass</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <td><a href="{@name}.html"><xsl:value-of select="@name"/></a></td>
+ <td><xsl:apply-templates select="@tests"/></td>
+ <td><xsl:apply-templates select="@errors"/></td>
+ <td><xsl:apply-templates select="@failures"/></td>
+ <td><xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="@time"/>
+ </xsl:call-template>
+ </td>
+ </tr>
+</xsl:template>
+
+<xsl:template match="testcase" mode="print.test">
+ <tr valign="top">
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="error">Error</xsl:when>
+ <xsl:when test="failure">Failure</xsl:when>
+ <xsl:otherwise>TableRowColor</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <td><xsl:value-of select="@name"/></td>
+ <xsl:choose>
+ <xsl:when test="failure">
+ <td>Failure</td>
+ <td><xsl:apply-templates select="failure"/></td>
+ </xsl:when>
+ <xsl:when test="error">
+ <td>Error</td>
+ <td><xsl:apply-templates select="error"/></td>
+ </xsl:when>
+ <xsl:otherwise>
+ <td>Success</td>
+ <td></td>
+ </xsl:otherwise>
+ </xsl:choose>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="@time"/>
+ </xsl:call-template>
+ </td>
+ </tr>
+</xsl:template>
+
+
+<!-- Note : the below template error and failure are the same style
+ so just call the same style store in the toolkit template -->
+<xsl:template match="failure">
+ <xsl:call-template name="display-failures"/>
+</xsl:template>
+
+<xsl:template match="error">
+ <xsl:call-template name="display-failures"/>
+</xsl:template>
+
+<!-- Style for the error and failure in the testcase template -->
+<xsl:template name="display-failures">
+ <xsl:choose>
+ <xsl:when test="not(@message)">N/A</xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@message"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <!-- display the stacktrace -->
+ <br/><br/>
+ <code>
+ <xsl:call-template name="br-replace">
+ <xsl:with-param name="word" select="."/>
+ </xsl:call-template>
+ </code>
+ <!-- the latter is better but might be problematic for non-21" monitors... -->
+ <!--pre><xsl:value-of select="."/></pre-->
+</xsl:template>
+
+<xsl:template name="JS-escape">
+ <xsl:param name="string"/>
+ <xsl:choose>
+ <xsl:when test="contains($string,"'")">
+ <xsl:value-of select="substring-before($string,"'")"/>\'<xsl:call-template name="JS-escape">
+ <xsl:with-param name="string" select="substring-after($string,"'")"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="contains($string,'\')">
+ <xsl:value-of select="substring-before($string,'\')"/>\\<xsl:call-template name="JS-escape">
+ <xsl:with-param name="string" select="substring-after($string,'\')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$string"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!--
+ template that will convert a carriage return into a br tag
+ @param word the text from which to convert CR to BR tag
+-->
+<xsl:template name="br-replace">
+ <xsl:param name="word"/>
+ <xsl:choose>
+ <xsl:when test="contains($word,'
')">
+ <xsl:value-of select="substring-before($word,'
')"/>
+ <br/>
+ <xsl:call-template name="br-replace">
+ <xsl:with-param name="word" select="substring-after($word,'
')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$word"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="display-time">
+ <xsl:param name="value"/>
+ <xsl:value-of select="format-number($value,'0.000')"/>
+</xsl:template>
+
+<xsl:template name="display-percent">
+ <xsl:param name="value"/>
+ <xsl:value-of select="format-number($value,'0.00%')"/>
+</xsl:template>
+</xsl:stylesheet>
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/junit-frames.xsl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/junit-noframes.xsl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/junit-noframes.xsl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/junit-noframes.xsl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,519 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:output method="html" indent="yes" encoding="US-ASCII"
+ doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
+<xsl:decimal-format decimal-separator="." grouping-separator="," />
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 2001-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", "Ant", 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 at 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
+ <http://www.apache.org/>.
+ -->
+
+<!--
+
+ Sample stylesheet to be used with An JUnitReport output.
+
+ It creates a non-framed report that can be useful to send via
+ e-mail or such.
+
+ @author Stephane Bailliez <a href="mailto:sbailliez at apache.org"/>
+ @author Erik Hatcher <a href="mailto:ehatcher at apache.org"/>
+
+-->
+<xsl:template match="testsuites">
+ <html>
+ <head>
+ <title>Unit Test Results</title>
+ <style type="text/css">
+ body {
+ font:normal 68% verdana,arial,helvetica;
+ color:#000000;
+ }
+ table tr td, table tr th {
+ font-size: 68%;
+ }
+ table.details tr th{
+ font-weight: bold;
+ text-align:left;
+ background:#a6caf0;
+ }
+ table.details tr td{
+ background:#eeeee0;
+ }
+
+ p {
+ line-height:1.5em;
+ margin-top:0.5em; margin-bottom:1.0em;
+ }
+ h1 {
+ margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
+ }
+ h2 {
+ margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
+ }
+ h3 {
+ margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
+ }
+ h4 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+ }
+ h5 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+ }
+ h6 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+ }
+ .Error {
+ font-weight:bold; color:red;
+ }
+ .Failure {
+ font-weight:bold; color:purple;
+ }
+ .Properties {
+ text-align:right;
+ }
+ </style>
+ <script type="text/javascript" language="JavaScript">
+ var TestCases = new Array();
+ var cur;
+ <xsl:for-each select="./testsuite">
+ <xsl:apply-templates select="properties"/>
+ </xsl:for-each>
+
+ </script>
+ <script type="text/javascript" language="JavaScript"><![CDATA[
+ function displayProperties (name) {
+ var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1');
+ var doc = win.document.open();
+ doc.write("<html><head><title>Properties of " + name + "</title>");
+ doc.write("<style>")
+ doc.write("body {font:normal 68% verdana,arial,helvetica; color:#000000; }");
+ doc.write("table tr td, table tr th { font-size: 68%; }");
+ doc.write("table.properties { border-collapse:collapse; border-left:solid 1 #cccccc; border-top:solid 1 #cccccc; padding:5px; }");
+ doc.write("table.properties th { text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#eeeeee; }");
+ doc.write("table.properties td { font:normal; text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#fffffff; }");
+ doc.write("h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica }");
+ doc.write("</style>");
+ doc.write("</head><body>");
+ doc.write("<h3>Properties of " + name + "</h3>");
+ doc.write("<div align=\"right\"><a href=\"javascript:window.close();\">Close</a></div>");
+ doc.write("<table class='properties'>");
+ doc.write("<tr><th>Name</th><th>Value</th></tr>");
+ for (prop in TestCases[name]) {
+ doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop] + "</td></tr>");
+ }
+ doc.write("</table>");
+ doc.write("</body></html>");
+ doc.close();
+ win.focus();
+ }
+ ]]>
+ </script>
+ </head>
+ <body>
+ <a name="top"></a>
+ <xsl:call-template name="pageHeader"/>
+
+ <!-- Summary part -->
+ <xsl:call-template name="summary"/>
+ <hr size="1" width="95%" align="left"/>
+
+ <!-- Package List part -->
+ <xsl:call-template name="packagelist"/>
+ <hr size="1" width="95%" align="left"/>
+
+ <!-- For each package create its part -->
+ <xsl:call-template name="packages"/>
+ <hr size="1" width="95%" align="left"/>
+
+ <!-- For each class create the part -->
+ <xsl:call-template name="classes"/>
+
+ </body>
+ </html>
+</xsl:template>
+
+
+
+ <!-- ================================================================== -->
+ <!-- Write a list of all packages with an hyperlink to the anchor of -->
+ <!-- of the package name. -->
+ <!-- ================================================================== -->
+ <xsl:template name="packagelist">
+ <h2>Packages</h2>
+ Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.
+ <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
+ <xsl:call-template name="testsuite.test.header"/>
+ <!-- list all packages recursively -->
+ <xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
+ <xsl:sort select="@package"/>
+ <xsl:variable name="testsuites-in-package" select="/testsuites/testsuite[./@package = current()/@package]"/>
+ <xsl:variable name="testCount" select="sum($testsuites-in-package/@tests)"/>
+ <xsl:variable name="errorCount" select="sum($testsuites-in-package/@errors)"/>
+ <xsl:variable name="failureCount" select="sum($testsuites-in-package/@failures)"/>
+ <xsl:variable name="timeCount" select="sum($testsuites-in-package/@time)"/>
+
+ <!-- write a summary for the package -->
+ <tr valign="top">
+ <!-- set a nice color depending if there is an error/failure -->
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="$failureCount > 0">Failure</xsl:when>
+ <xsl:when test="$errorCount > 0">Error</xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+ <td><a href="#{@package}"><xsl:value-of select="@package"/></a></td>
+ <td><xsl:value-of select="$testCount"/></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ <td><xsl:value-of select="$failureCount"/></td>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="$timeCount"/>
+ </xsl:call-template>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </xsl:template>
+
+
+ <!-- ================================================================== -->
+ <!-- Write a package level report -->
+ <!-- It creates a table with values from the document: -->
+ <!-- Name | Tests | Errors | Failures | Time -->
+ <!-- ================================================================== -->
+ <xsl:template name="packages">
+ <!-- create an anchor to this package name -->
+ <xsl:for-each select="/testsuites/testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
+ <xsl:sort select="@package"/>
+ <a name="{@package}"></a>
+ <h3>Package <xsl:value-of select="@package"/></h3>
+
+ <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
+ <xsl:call-template name="testsuite.test.header"/>
+
+ <!-- match the testsuites of this package -->
+ <xsl:apply-templates select="/testsuites/testsuite[./@package = current()/@package]" mode="print.test"/>
+ </table>
+ <a href="#top">Back to top</a>
+ <p/>
+ <p/>
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template name="classes">
+ <xsl:for-each select="testsuite">
+ <xsl:sort select="@name"/>
+ <!-- create an anchor to this class name -->
+ <a name="{@name}"></a>
+ <h3>TestCase <xsl:value-of select="@name"/></h3>
+
+ <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
+ <xsl:call-template name="testcase.test.header"/>
+ <!--
+ test can even not be started at all (failure to load the class)
+ so report the error directly
+ -->
+ <xsl:if test="./error">
+ <tr class="Error">
+ <td colspan="4"><xsl:apply-templates select="./error"/></td>
+ </tr>
+ </xsl:if>
+ <xsl:apply-templates select="./testcase" mode="print.test"/>
+ </table>
+ <div class="Properties">
+ <a>
+ <xsl:attribute name="href">javascript:displayProperties('<xsl:value-of select="@package"/>.<xsl:value-of select="@name"/>');</xsl:attribute>
+ Properties »
+ </a>
+ </div>
+ <p/>
+
+ <a href="#top">Back to top</a>
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template name="summary">
+ <h2>Summary</h2>
+ <xsl:variable name="testCount" select="sum(testsuite/@tests)"/>
+ <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/>
+ <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/>
+ <xsl:variable name="timeCount" select="sum(testsuite/@time)"/>
+ <xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
+ <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
+ <tr valign="top">
+ <th>Tests</th>
+ <th>Failures</th>
+ <th>Errors</th>
+ <th>Success rate</th>
+ <th>Time</th>
+ </tr>
+ <tr valign="top">
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="$failureCount > 0">Failure</xsl:when>
+ <xsl:when test="$errorCount > 0">Error</xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+ <td><xsl:value-of select="$testCount"/></td>
+ <td><xsl:value-of select="$failureCount"/></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ <td>
+ <xsl:call-template name="display-percent">
+ <xsl:with-param name="value" select="$successRate"/>
+ </xsl:call-template>
+ </td>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="$timeCount"/>
+ </xsl:call-template>
+ </td>
+
+ </tr>
+ </table>
+ <table border="0" width="95%">
+ <tr>
+ <td style="text-align: justify;">
+ Note: <i>failures</i> are anticipated and checked for with assertions while <i>errors</i> are unanticipated.
+ </td>
+ </tr>
+ </table>
+ </xsl:template>
+
+ <!--
+ Write properties into a JavaScript data structure.
+ This is based on the original idea by Erik Hatcher (ehatcher at apache.org)
+ -->
+ <xsl:template match="properties">
+ cur = TestCases['<xsl:value-of select="../@package"/>.<xsl:value-of select="../@name"/>'] = new Array();
+ <xsl:for-each select="property">
+ <xsl:sort select="@name"/>
+ cur['<xsl:value-of select="@name"/>'] = '<xsl:call-template name="JS-escape"><xsl:with-param name="string" select="@value"/></xsl:call-template>';
+ </xsl:for-each>
+ </xsl:template>
+
+<!-- Page HEADER -->
+<xsl:template name="pageHeader">
+ <h1>Unit Test Results</h1>
+ <table width="100%">
+ <tr>
+ <td align="left"></td>
+ <td align="right">Designed for use with <a href='http://www.junit.org'>JUnit</a> and <a href='http://jakarta.apache.org/ant'>Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+</xsl:template>
+
+<xsl:template match="testsuite" mode="header">
+ <tr valign="top">
+ <th width="80%">Name</th>
+ <th>Tests</th>
+ <th>Errors</th>
+ <th>Failures</th>
+ <th nowrap="nowrap">Time(s)</th>
+ </tr>
+</xsl:template>
+
+<!-- class header -->
+<xsl:template name="testsuite.test.header">
+ <tr valign="top">
+ <th width="80%">Name</th>
+ <th>Tests</th>
+ <th>Errors</th>
+ <th>Failures</th>
+ <th nowrap="nowrap">Time(s)</th>
+ </tr>
+</xsl:template>
+
+<!-- method header -->
+<xsl:template name="testcase.test.header">
+ <tr valign="top">
+ <th>Name</th>
+ <th>Status</th>
+ <th width="80%">Type</th>
+ <th nowrap="nowrap">Time(s)</th>
+ </tr>
+</xsl:template>
+
+
+<!-- class information -->
+<xsl:template match="testsuite" mode="print.test">
+ <tr valign="top">
+ <!-- set a nice color depending if there is an error/failure -->
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="@failures[.> 0]">Failure</xsl:when>
+ <xsl:when test="@errors[.> 0]">Error</xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <!-- print testsuite information -->
+ <td><a href="#{@name}"><xsl:value-of select="@name"/></a></td>
+ <td><xsl:value-of select="@tests"/></td>
+ <td><xsl:value-of select="@errors"/></td>
+ <td><xsl:value-of select="@failures"/></td>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="@time"/>
+ </xsl:call-template>
+ </td>
+ </tr>
+</xsl:template>
+
+<xsl:template match="testcase" mode="print.test">
+ <tr valign="top">
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="failure | error">Error</xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+ <td><xsl:value-of select="@name"/></td>
+ <xsl:choose>
+ <xsl:when test="failure">
+ <td>Failure</td>
+ <td><xsl:apply-templates select="failure"/></td>
+ </xsl:when>
+ <xsl:when test="error">
+ <td>Error</td>
+ <td><xsl:apply-templates select="error"/></td>
+ </xsl:when>
+ <xsl:otherwise>
+ <td>Success</td>
+ <td></td>
+ </xsl:otherwise>
+ </xsl:choose>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="@time"/>
+ </xsl:call-template>
+ </td>
+ </tr>
+</xsl:template>
+
+
+<xsl:template match="failure">
+ <xsl:call-template name="display-failures"/>
+</xsl:template>
+
+<xsl:template match="error">
+ <xsl:call-template name="display-failures"/>
+</xsl:template>
+
+<!-- Style for the error and failure in the tescase template -->
+<xsl:template name="display-failures">
+ <xsl:choose>
+ <xsl:when test="not(@message)">N/A</xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@message"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <!-- display the stacktrace -->
+ <code>
+ <br/><br/>
+ <xsl:call-template name="br-replace">
+ <xsl:with-param name="word" select="."/>
+ </xsl:call-template>
+ </code>
+ <!-- the later is better but might be problematic for non-21" monitors... -->
+ <!--pre><xsl:value-of select="."/></pre-->
+</xsl:template>
+
+<xsl:template name="JS-escape">
+ <xsl:param name="string"/>
+ <xsl:choose>
+ <xsl:when test="contains($string,"'")">
+ <xsl:value-of select="substring-before($string,"'")"/>\'<xsl:call-template name="JS-escape">
+ <xsl:with-param name="string" select="substring-after($string,"'")"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="contains($string,'\')">
+ <xsl:value-of select="substring-before($string,'\')"/>\\<xsl:call-template name="JS-escape">
+ <xsl:with-param name="string" select="substring-after($string,'\')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$string"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+<!--
+ template that will convert a carriage return into a br tag
+ @param word the text from which to convert CR to BR tag
+-->
+<xsl:template name="br-replace">
+ <xsl:param name="word"/>
+ <xsl:choose>
+ <xsl:when test="contains($word,'
')">
+ <xsl:value-of select="substring-before($word,'
')"/>
+ <br/>
+ <xsl:call-template name="br-replace">
+ <xsl:with-param name="word" select="substring-after($word,'
')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$word"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="display-time">
+ <xsl:param name="value"/>
+ <xsl:value-of select="format-number($value,'0.000')"/>
+</xsl:template>
+
+<xsl:template name="display-percent">
+ <xsl:param name="value"/>
+ <xsl:value-of select="format-number($value,'0.00%')"/>
+</xsl:template>
+
+</xsl:stylesheet>
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/junit-noframes.xsl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/log.xsl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/log.xsl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/log.xsl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,247 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:output method="html" indent="yes" encoding="US-ASCII"/>
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 2000-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", "Ant", 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 at 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
+ <http://www.apache.org/>.
+ -->
+
+<!--
+
+ The purpose have this XSL is to provide a nice way to look at the output
+ from the Ant XmlLogger (ie: ant -listener org.apache.tools.ant.XmlLogger )
+
+ @author <a href="mailto:sbailliez at apache.org">Stephane Bailliez</a>
+
+-->
+<xsl:decimal-format decimal-separator="." grouping-separator="," />
+
+<xsl:template match="/">
+<html>
+ <head>
+ <style type="text/css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin: 0;
+ font:normal 100% arial,helvetica,sanserif;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ table.status {
+ font:bold 80% arial,helvetica,sanserif;
+ background-color:#525D76;
+ color:#ffffff;
+ }
+ table.log tr td, tr th {
+ font-size: 80%;
+ }
+ .error {
+ color:red;
+ }
+ .warn {
+ color:brown;
+ }
+ .info {
+ color:gray;
+ }
+ .debug{
+ color:gray;
+ }
+ .failed {
+ font-size:80%;
+ background-color: red;
+ color:#FFFFFF;
+ font-weight: bold
+ }
+ .complete {
+ font-size:80%;
+ background-color: #525D76;
+ color:#FFFFFF;
+ font-weight: bold
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ border: none
+ }
+ h3 {
+ font:bold 80% arial,helvetica,sanserif;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <!-- jakarta logo -->
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td valign="top" class="bannercell">
+ <a href="http://jakarta.apache.org/">
+ <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
+ </a>
+ </td>
+ <td style="text-align:right;vertical-align:bottom">
+ <a href="htp://jakarta.apache.org/ant">Jakarta Ant</a>
+ </td>
+ </tr>
+ </table>
+
+ <table border="0" width="100%">
+ <tr><td><hr noshade="yes" size="1"/></td></tr>
+ </table>
+
+ <xsl:apply-templates select="build"/>
+
+ <!-- FOOTER -->
+ <table width="100%">
+ <tr><td><hr noshade="yes" size="1"/></td></tr>
+ <tr><td>
+ <div align="center"><font color="#525D76" size="-1"><em>
+ Copyright © 2000-2002, Apache Software Foundation
+ </em></font></div>
+ </td></tr>
+ </table>
+ </body>
+</html>
+</xsl:template>
+
+<xsl:template match="build">
+ <!-- build status -->
+ <table width="100%">
+ <xsl:attribute name="class">
+ <xsl:if test="@error">failed</xsl:if>
+ <xsl:if test="not(@error)">complete</xsl:if>
+ </xsl:attribute>
+ <tr>
+ <xsl:if test="@error">
+ <td nowrap="yes">Build Failed</td>
+ </xsl:if>
+ <xsl:if test="not(@error)">
+ <td nowrap="yes">Build Complete</td>
+ </xsl:if>
+ <td style="text-align:right" nowrap="yes">Total Time: <xsl:value-of select="@time"/></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <xsl:if test="@error">
+ <tt><xsl:value-of select="@error"/></tt><br/>
+ <i style="font-size:80%">See the <a href="#stacktrace" alt="Click for details">stacktrace</a>.</i>
+ </xsl:if>
+ </td>
+ </tr>
+ </table>
+ <table border="1" cellspacing="2" cellpadding="3" width="100%" style="font-size:80%">
+ <tr class="a"><td width="1">ant.file</td><td><xsl:value-of select="substring-after(message[contains(text(),'ant.file')], '->')"/></td></tr>
+ <tr class="b"><td width="1">ant.version</td><td><xsl:value-of select="substring-after(message[contains(text(),'ant.version')], '->')"/></td></tr>
+ <tr class="a"><td width="1">java.version</td><td><xsl:value-of select="substring-after(message[contains(text(),'java.vm.version')], '->')"/></td></tr>
+ <tr class="b"><td width="1">os.name</td><td><xsl:value-of select="substring-after(message[contains(text(),'os.name')], '->')"/></td></tr>
+ </table>
+ <!-- build information -->
+ <h3>Build events</h3>
+ <table class="log" border="1" cellspacing="2" cellpadding="3" width="100%">
+ <tr>
+ <th nowrap="yes" align="left" width="1%">target</th>
+ <th nowrap="yes" align="left" width="1%">task</th>
+ <th nowrap="yes" align="left">message</th>
+ </tr>
+ <xsl:apply-templates select=".//message[@priority != 'debug']"/>
+ </table>
+ <p>
+ <!-- stacktrace -->
+ <xsl:if test="stacktrace">
+ <a name="stacktrace"/>
+ <h3>Error details</h3>
+ <table width="100%">
+ <tr><td>
+ <pre><xsl:value-of select="stacktrace"/></pre>
+ </td></tr>
+ </table>
+ </xsl:if>
+ </p>
+</xsl:template>
+
+<!-- report every message but those with debug priority -->
+<xsl:template match="message[@priority!='debug']">
+ <tr valign="top">
+ <!-- alternated row style -->
+ <xsl:attribute name="class">
+ <xsl:if test="position() mod 2 = 1">a</xsl:if>
+ <xsl:if test="position() mod 2 = 0">b</xsl:if>
+ </xsl:attribute>
+ <td nowrap="yes" width="1%"><xsl:value-of select="../../@name"/></td>
+ <td nowrap="yes" style="text-align:right" width="1%">[ <xsl:value-of select="../@name"/> ]</td>
+ <td class="{@priority}" nowrap="yes">
+ <xsl:value-of select="text()"/>
+ </td>
+ </tr>
+</xsl:template>
+
+</xsl:stylesheet>
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/log.xsl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/maudit-frames.xsl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/maudit-frames.xsl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/maudit-frames.xsl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,547 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:lxslt="http://xml.apache.org/xslt"
+ xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
+ extension-element-prefixes="redirect">
+<xsl:output method="html" indent="yes" encoding="US-ASCII"/>
+<xsl:decimal-format decimal-separator="." grouping-separator="," />
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 2001-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", "Ant", 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 at 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
+ <http://www.apache.org/>.
+ -->
+<!--
+
+ Stylesheet to transform an XML file generated by the Ant MAudit task into
+ a set of JavaDoc-like HTML page to make pages more convenient to be browsed.
+
+ It use the Xalan redirect extension to write to multiple output files.
+
+ @author Stephane Bailliez <a href="mailto:sbailliez at apache.org"/>
+-->
+
+<xsl:param name="output.dir" select="'.'"/>
+
+
+<xsl:template match="classes">
+ <!-- create the index.html -->
+ <redirect:write file="{$output.dir}/index.html">
+ <xsl:call-template name="index.html"/>
+ </redirect:write>
+
+ <!-- create the stylesheet.css -->
+ <redirect:write file="{$output.dir}/stylesheet.css">
+ <xsl:call-template name="stylesheet.css"/>
+ </redirect:write>
+
+ <!-- create the overview-packages.html at the root -->
+ <redirect:write file="{$output.dir}/overview-summary.html">
+ <xsl:apply-templates select="." mode="overview.packages"/>
+ </redirect:write>
+
+ <!-- create the all-packages.html at the root -->
+ <redirect:write file="{$output.dir}/overview-frame.html">
+ <xsl:apply-templates select="." mode="all.packages"/>
+ </redirect:write>
+
+ <!-- create the all-classes.html at the root -->
+ <redirect:write file="{$output.dir}/allclasses-frame.html">
+ <xsl:apply-templates select="." mode="all.classes"/>
+ </redirect:write>
+
+ <!-- process all packages -->
+ <xsl:for-each select="./class[not(./@package = preceding-sibling::class/@package)]">
+ <xsl:call-template name="package">
+ <xsl:with-param name="name" select="@package"/>
+ </xsl:call-template>
+ </xsl:for-each>
+</xsl:template>
+
+
+<xsl:template name="package">
+ <xsl:param name="name"/>
+ <xsl:variable name="package.dir">
+ <xsl:if test="not($name = '')"><xsl:value-of select="translate($name,'.','/')"/></xsl:if>
+ <xsl:if test="$name = ''">.</xsl:if>
+ </xsl:variable>
+ <!--Processing package <xsl:value-of select="@name"/> in <xsl:value-of select="$output.dir"/> -->
+ <!-- create a classes-list.html in the package directory -->
+ <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
+ <xsl:call-template name="classes.list">
+ <xsl:with-param name="name" select="$name"/>
+ </xsl:call-template>
+ </redirect:write>
+
+ <!-- create a package-summary.html in the package directory -->
+ <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
+ <xsl:call-template name="package.summary">
+ <xsl:with-param name="name" select="$name"/>
+ </xsl:call-template>
+ </redirect:write>
+
+ <!-- for each class, creates a @name.html -->
+ <!-- @bug there will be a problem with inner classes having the same name, it will be overwritten -->
+ <xsl:for-each select="/classes/class[@package = $name]">
+ <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
+ <xsl:apply-templates select="." mode="class.details"/>
+ </redirect:write>
+ </xsl:for-each>
+</xsl:template>
+
+<xsl:template name="index.html">
+<HTML>
+ <HEAD><TITLE>Audit Results.</TITLE></HEAD>
+ <FRAMESET cols="20%,80%">
+ <FRAMESET rows="30%,70%">
+ <FRAME src="overview-frame.html" name="packageListFrame"/>
+ <FRAME src="allclasses-frame.html" name="classListFrame"/>
+ </FRAMESET>
+ <FRAME src="overview-summary.html" name="classFrame"/>
+ </FRAMESET>
+ <noframes>
+ <H2>Frame Alert</H2>
+ <P>
+ This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
+ </P>
+ </noframes>
+</HTML>
+</xsl:template>
+
+
+<!-- this is the stylesheet css to use for nearly everything -->
+<xsl:template name="stylesheet.css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin-left: 10;
+ margin-right: 10;
+ font:normal 80% arial,helvetica,sanserif;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ font-weight:bold;
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ font-size:100%;
+ border: none
+ }
+ table.log tr td, tr th {
+
+ }
+ h2 {
+ font-weight:bold;
+ font-size:140%;
+ margin-bottom: 5;
+ }
+ h3 {
+ font-size:100%;
+ font-weight:bold;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+</xsl:template>
+
+
+<!-- print the violations of the class -->
+<xsl:template match="class" mode="class.details">
+ <xsl:variable name="package.name" select="@package"/>
+ <HTML>
+ <HEAD>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="$package.name"/>
+ </xsl:call-template>
+ </HEAD>
+ <BODY>
+ <xsl:call-template name="pageHeader"/>
+ <H3>Class <xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3>
+
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:call-template name="class.audit.header"/>
+ <xsl:apply-templates select="." mode="print.audit"/>
+ </table>
+
+ <H3>Violations</H3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:call-template name="violation.audit.header"/>
+ <xsl:apply-templates select="./violation" mode="print.audit">
+ <xsl:sort data-type="number" select="@line"/>
+ </xsl:apply-templates>
+ </table>
+ <xsl:call-template name="pageFooter"/>
+ </BODY>
+ </HTML>
+</xsl:template>
+
+
+<!-- list of classes in a package -->
+<xsl:template name="classes.list">
+ <xsl:param name="name"/>
+ <HTML>
+ <HEAD>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="$name"/>
+ </xsl:call-template>
+ </HEAD>
+ <BODY>
+ <table width="100%">
+ <tr>
+ <td nowrap="nowrap">
+ <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="$name"/></a></H2>
+ </td>
+ </tr>
+ </table>
+
+ <h2>Classes</h2>
+ <TABLE WIDTH="100%">
+ <xsl:apply-templates select="/classes/class[./@package = $name]" mode="classes.list">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </TABLE>
+ </BODY>
+ </HTML>
+</xsl:template>
+<!-- the class to list -->
+<xsl:template match="class" mode="classes.list">
+ <tr>
+ <td nowrap="nowrap">
+ <!-- @bug naming to fix for inner classes -->
+ <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
+ </td>
+ </tr>
+</xsl:template>
+
+
+<!--
+ Creates an all-classes.html file that contains a link to all package-summary.html
+ on each class.
+-->
+<xsl:template match="classes" mode="all.classes">
+ <html>
+ <head>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name"/>
+ </xsl:call-template>
+ </head>
+ <body>
+ <h2>Classes</h2>
+ <table width="100%">
+ <xsl:apply-templates select=".//class" mode="all.classes">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="class" mode="all.classes">
+ <!-- (ancestor::package)[last()] is buggy in MSXML3 ? -->
+ <xsl:variable name="package.name" select="@package"/>
+ <tr>
+ <td nowrap="nowrap">
+ <a target="classFrame">
+ <xsl:attribute name="href">
+ <xsl:if test="not($package.name='')">
+ <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
+ </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ </tr>
+</xsl:template>
+
+
+<!--
+ Creates an html file that contains a link to all package-summary.html files on
+ each package existing on testsuites.
+ @bug there will be a problem here, I don't know yet how to handle unnamed package :(
+-->
+<xsl:template match="classes" mode="all.packages">
+ <html>
+ <head>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name"/>
+ </xsl:call-template>
+ </head>
+ <body>
+ <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
+ <h2>Packages</h2>
+ <table width="100%">
+ <xsl:apply-templates select="class[not(./@package = preceding-sibling::class/@package)]" mode="all.packages">
+ <xsl:sort select="@package" order="ascending"/>
+ </xsl:apply-templates>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="class" mode="all.packages">
+ <tr>
+ <td nowrap="nowrap">
+ <a href="{translate(@package,'.','/')}/package-summary.html" target="classFrame">
+ <xsl:value-of select="@package"/>
+ </a>
+ </td>
+ </tr>
+</xsl:template>
+
+
+<xsl:template match="classes" mode="overview.packages">
+ <html>
+ <head>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name"/>
+ </xsl:call-template>
+ </head>
+ <body onload="open('allclasses-frame.html','classListFrame')">
+ <xsl:call-template name="pageHeader"/>
+ <h3>Summary</h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Audited classes</th>
+ <th>Reported classes</th>
+ <th>Violations</th>
+ </tr>
+ <tr class="a">
+ <td><xsl:value-of select="@audited"/></td>
+ <td><xsl:value-of select="@reported"/></td>
+ <td><xsl:value-of select="@violations"/></td>
+ </tr>
+ </table>
+ <table border="0" width="100%">
+ <tr>
+ <td style="text-align: justify;">
+ Note: Rules checked have originated from style guidelines suggested by the language designers,
+ experience from the Java development community and insite experience. Violations are generally
+ reported with a reference to the <a href="http://java.sun.com/docs/books/jls/second_edition/html/jTOC.doc.html">Java Language Specifications</a> (JLS x.x.x)
+ and Metamata Audit rules (x.x).
+ Please consult these documents for additional information about violations.
+ <p/>
+ Rules checked also enforce adherence to <a href="http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html">Sun Java coding guidelines</a> in use at Jakarta.
+ <p/>
+ One should note that these violations do not necessary underline errors but should be used
+ as an indication for <i>possible</i> errors. As always, use your best judgment and review
+ them carefully, it might save you hours of debugging.
+ </td>
+ </tr>
+ </table>
+
+ <h3>Packages</h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:call-template name="class.audit.header"/>
+ <xsl:for-each select="class[not(./@package = preceding-sibling::class/@package)]">
+ <xsl:sort select="@package" order="ascending"/>
+ <tr>
+ <xsl:call-template name="alternate-row"/>
+ <td><a href="{translate(@package,'.','/')}/package-summary.html"><xsl:value-of select="@package"/></a></td>
+ <td><xsl:value-of select="sum(/classes/class[./@package = current()/@package]/@violations)"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ <xsl:call-template name="pageFooter"/>
+ </body>
+ </html>
+</xsl:template>
+
+
+<xsl:template name="package.summary">
+ <xsl:param name="name"/>
+ <HTML>
+ <HEAD>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="$name"/>
+ </xsl:call-template>
+ </HEAD>
+ <BODY>
+ <xsl:attribute name="onload">open('package-frame.html','classListFrame')</xsl:attribute>
+ <xsl:call-template name="pageHeader"/>
+ <h3>Package <xsl:value-of select="$name"/></h3>
+
+ <!--table border="0" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:call-template name="class.metrics.header"/>
+ <xsl:apply-templates select="." mode="print.metrics"/>
+ </table-->
+
+ <xsl:if test="count(/classes/class[./@package = $name]) > 0">
+ <H3>Classes</H3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:call-template name="class.audit.header"/>
+ <xsl:apply-templates select="/classes/class[./@package = $name]" mode="print.audit">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </xsl:if>
+ <xsl:call-template name="pageFooter"/>
+ </BODY>
+ </HTML>
+</xsl:template>
+
+
+<!--
+ transform string like a.b.c to ../../../
+ @param path the path to transform into a descending directory path
+-->
+<xsl:template name="path">
+ <xsl:param name="path"/>
+ <xsl:if test="contains($path,'.')">
+ <xsl:text>../</xsl:text>
+ <xsl:call-template name="path">
+ <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="not(contains($path,'.')) and not($path = '')">
+ <xsl:text>../</xsl:text>
+ </xsl:if>
+</xsl:template>
+
+
+<!-- create the link to the stylesheet based on the package name -->
+<xsl:template name="create.stylesheet.link">
+ <xsl:param name="package.name"/>
+ <LINK REL ="stylesheet" TYPE="text/css" TITLE="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></LINK>
+</xsl:template>
+
+<!-- Page HEADER -->
+<xsl:template name="pageHeader">
+
+ <!-- jakarta logo -->
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="bannercell" rowspan="2">
+ <a href="http://jakarta.apache.org/">
+ <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
+ </a>
+ </td>
+ <td style="text-align:right"><h2>Source Code Audit</h2></td>
+ </tr>
+ <tr>
+ <td style="text-align:right">Designed for use with <a href='http://www.webgain.com/products/quality_analyzer/'>Webgain QA/Metamata Audit</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+</xsl:template>
+
+<!-- Page HEADER -->
+<xsl:template name="pageFooter">
+ <table width="100%">
+ <tr><td><hr noshade="yes" size="1"/></td></tr>
+ <tr><td>
+ <div align="center"><font color="#525D76" size="-1"><em>
+ Copyright © 1999-2001, Apache Software Foundation
+ </em></font></div>
+ </td></tr>
+ </table>
+</xsl:template>
+
+
+<!-- class header -->
+<xsl:template name="class.audit.header">
+ <tr>
+ <th width="80%">Name</th>
+ <th>Violations</th>
+ </tr>
+</xsl:template>
+
+<!-- method header -->
+<xsl:template name="violation.audit.header">
+ <tr>
+ <th>Line</th>
+ <th>Message</th>
+ </tr>
+</xsl:template>
+
+
+<!-- class information -->
+<xsl:template match="class" mode="print.audit">
+ <tr>
+ <xsl:call-template name="alternate-row"/>
+ <td><a href="{@name}.html"><xsl:value-of select="@name"/></a></td>
+ <td><xsl:apply-templates select="@violations"/></td>
+ </tr>
+</xsl:template>
+
+<xsl:template match="violation" mode="print.audit">
+ <tr>
+ <xsl:call-template name="alternate-row"/>
+ <td><xsl:value-of select="@line"/></td>
+ <td><xsl:apply-templates select="@message"/></td>
+ </tr>
+</xsl:template>
+
+<!-- alternated row style -->
+<xsl:template name="alternate-row">
+<xsl:attribute name="class">
+ <xsl:if test="position() mod 2 = 1">a</xsl:if>
+ <xsl:if test="position() mod 2 = 0">b</xsl:if>
+</xsl:attribute>
+</xsl:template>
+
+</xsl:stylesheet>
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/maudit-frames.xsl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/mmetrics-frames.xsl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/mmetrics-frames.xsl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/mmetrics-frames.xsl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,1070 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:lxslt="http://xml.apache.org/xslt"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
+ exclude-result-prefixes="xalan"
+ extension-element-prefixes="redirect">
+<xsl:output method="html" indent="yes" encoding="US-ASCII"/>
+<xsl:decimal-format decimal-separator="." grouping-separator="," />
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 2001-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", "Ant", 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 at 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
+ <http://www.apache.org/>.
+ -->
+<!--
+ @author Stephane Bailliez <a href="mailto:sbailliez at apache.org"/>
+ -->
+<xsl:param name="output.dir" select="'.'"/>
+
+<!-- default max value for the metrics -->
+<xsl:param name="vg.max" select="10"/>
+<xsl:param name="loc.max" select="1000"/>
+<xsl:param name="dit.max" select="10"/>
+<xsl:param name="noa.max" select="250"/>
+<xsl:param name="nrm.max" select="50"/>
+<xsl:param name="nlm.max" select="250"/>
+<xsl:param name="wmc.max" select="250"/>
+<xsl:param name="rfc.max" select="50"/>
+<xsl:param name="dac.max" select="10"/>
+<xsl:param name="fanout.max" select="10"/>
+<xsl:param name="cbo.max" select="15"/>
+<xsl:param name="lcom.max" select="10"/>
+<xsl:param name="nocl.max" select="10"/>
+
+
+<!-- create a tree fragment to speed up processing -->
+<xsl:variable name="doctree.var">
+ <xsl:element name="classes">
+ <xsl:for-each select=".//class">
+ <xsl:element name="class">
+ <xsl:attribute name="package">
+ <xsl:value-of select="(ancestor::package)[last()]/@name"/>
+ </xsl:attribute>
+ <xsl:copy-of select="@*"/>
+ <xsl:attribute name="name">
+ <xsl:apply-templates select="." mode="class.name"/>
+ </xsl:attribute>
+ <xsl:copy-of select="method"/>
+ </xsl:element>
+ </xsl:for-each>
+ </xsl:element>
+</xsl:variable>
+
+<xsl:variable name="doctree" select="xalan:nodeset($doctree.var)"/>
+
+<xsl:template match="metrics">
+
+ <!-- create the index.html -->
+ <redirect:write file="{$output.dir}/index.html">
+ <xsl:call-template name="index.html"/>
+ </redirect:write>
+
+ <!-- create the stylesheet.css -->
+ <redirect:write file="{$output.dir}/stylesheet.css">
+ <xsl:call-template name="stylesheet.css"/>
+ </redirect:write>
+
+ <redirect:write file="{$output.dir}/metrics-reference.html">
+ <xsl:call-template name="metrics-reference.html"/>
+ </redirect:write>
+
+ <!-- create the overview-packages.html at the root -->
+ <redirect:write file="{$output.dir}/overview-summary.html">
+ <xsl:apply-templates select="." mode="overview.packages"/>
+ </redirect:write>
+
+ <!-- create the all-packages.html at the root -->
+ <redirect:write file="{$output.dir}/overview-frame.html">
+ <xsl:apply-templates select="." mode="all.packages"/>
+ </redirect:write>
+
+ <!-- create the all-classes.html at the root -->
+ <redirect:write file="{$output.dir}/allclasses-frame.html">
+ <xsl:apply-templates select="." mode="all.classes"/>
+ </redirect:write>
+
+ <!-- process all packages -->
+ <xsl:apply-templates select=".//package"/>
+</xsl:template>
+
+
+<xsl:template match="package">
+ <xsl:variable name="package.name" select="@name"/>
+ <xsl:variable name="package.dir">
+ <xsl:if test="not($package.name = 'unnamed package')"><xsl:value-of select="translate($package.name,'.','/')"/></xsl:if>
+ <xsl:if test="$package.name = 'unnamed package'">.</xsl:if>
+ </xsl:variable>
+ <!-- create a classes-list.html in the package directory -->
+ <redirect:write file="{$output.dir}/{$package.dir}/package-frame.html">
+ <xsl:apply-templates select="." mode="classes.list"/>
+ </redirect:write>
+
+ <!-- create a package-summary.html in the package directory -->
+ <redirect:write file="{$output.dir}/{$package.dir}/package-summary.html">
+ <xsl:apply-templates select="." mode="package.summary"/>
+ </redirect:write>
+
+ <!-- for each class, creates a @name.html -->
+ <!-- @bug there will be a problem with inner classes having the same name, it will be overwritten -->
+ <xsl:for-each select="$doctree/classes/class[@package = current()/@name]">
+ <!--Processing <xsl:value-of select="$class.name"/><xsl:text> </xsl:text> -->
+ <redirect:write file="{$output.dir}/{$package.dir}/{@name}.html">
+ <xsl:apply-templates select="." mode="class.details"/>
+ </redirect:write>
+ </xsl:for-each>
+</xsl:template>
+
+<!-- little trick to compute the classname for inner and non inner classes -->
+<!-- this is all in one line to avoid CRLF in the name -->
+<xsl:template match="class" mode="class.name">
+ <xsl:if test="parent::class"><xsl:apply-templates select="parent::class" mode="class.name"/>.<xsl:value-of select="@name"/></xsl:if><xsl:if test="not(parent::class)"><xsl:value-of select="@name"/></xsl:if>
+</xsl:template>
+
+
+<xsl:template name="index.html">
+<HTML>
+ <HEAD><TITLE>Metrics Results.</TITLE></HEAD>
+ <FRAMESET cols="20%,80%">
+ <FRAMESET rows="30%,70%">
+ <FRAME src="overview-frame.html" name="packageListFrame"/>
+ <FRAME src="allclasses-frame.html" name="classListFrame"/>
+ </FRAMESET>
+ <FRAME src="overview-summary.html" name="classFrame"/>
+ </FRAMESET>
+ <noframes>
+ <H2>Frame Alert</H2>
+ <P>
+ This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
+ </P>
+ </noframes>
+</HTML>
+</xsl:template>
+
+<!-- this is the stylesheet css to use for nearly everything -->
+<xsl:template name="metrics-reference.html">
+<html>
+<head>
+<link title="Style" type="text/css" rel="stylesheet" href="stylesheet.css"/>
+</head>
+<body style="text-align:justify;">
+<h2>Metrics Reference</h2>
+<a href="#V(G)">V(G)</a> |
+<a href="#LOC">LOC</a> |
+<a href="#DIT">DIT</a> |
+<a href="#NOA">NOA</a> |
+<a href="#NRM">NRM</a> |
+<a href="#NLM">NLM</a> |
+<a href="#WMC">WMC</a> |
+<a href="#RFC">RFC</a> |
+<a href="#DAC">DAC</a> |
+<a href="#FANOUT">FANOUT</a> |
+<a href="#CBO">CBO</a> |
+<a href="#LCOM">LCOM</a> |
+<a href="#NOC">NOC</a>
+
+<a name="V(G)"/>
+<h3>Cyclomatic Complexity - V(G)</h3>
+This metric was introduced in the 1970s to measure the amount of control
+flow complexity or branching complexity in a module such as a
+subroutine. It gives the number of paths that may be taken through the
+code, and was initially developed to give some measure of the cost of
+producing a test case for the module by executing each path.
+<p/>
+Methods with a high cyclomatic complexity tend to be more difficult to
+understand and maintain. In general the more complex the methods of an
+application, the more difficult it will be to test it, and this will adversely
+affect its reliability.
+<p/>
+V(G) is a measure of the control flow complexity of a method or
+constructor. It counts the number of branches in the body of the method,
+defined as:
+<ul>
+<li>while statements;</li>
+<li>if statements;</li>
+<li>for statements.</li>
+</ul>
+
+The metric can also be configured to count each case of a switch
+statement as well.
+
+<a name="LOC"/>
+<h3>Lines of Code - LOC</h3>
+
+This is perhaps the simplest of all the metrics to define and compute.
+Counting lines has a long history as a software metric dating from before
+the rise of structured programming, and it is still in widespread use today.
+The size of a method affects the ease with which it can be understood, its
+reusability and its maintainability. There are a variety of ways that the size
+can be calculated. These include counting all the lines of code, the number
+of statements, the blank lines of code, the lines of commentary, and the
+lines consisting only of syntax such as block delimiters.
+<p/>
+This metric can also be used for sizing other constructs as well, for
+example, the overall size of a Java class or package can be measured by
+counting the number of source lines it consists of.
+<p/>
+LOC can be used to determine the size of a compilation unit (source file),
+class or interface, method, constructor, or field. It can be configured to
+ignore:
+<ul>
+<li>blank lines;</li>
+<li>lines consisting only of comments;</li>
+<li>lines consisting only of opening and closing braces.</li>
+</ul>
+
+<a name="DIT"/>
+<h3>Depth of Inheritance Hierarchy - DIT</h3>
+
+This metric calculates how far down the inheritance hierarchy a class is
+declared. In Java all classes have java.lang.Object as their ultimate
+superclass, which is defined to have a depth of 1. So a class that
+immediately extends java.lang.Object has a metric value of 2; any of its
+subclasses will have a value of 3, and so on.
+<p/>
+A class that is deep within the tree inherits more methods and state
+variables, thereby increasing its complexity and making it difficult to
+predict its behavior. It can be harder to understand a system with many
+inheritance layers.
+<p/>
+DIT is defined for classes and interfaces:
+<ul>
+<li>all interface types have a depth of 1;</li>
+<li>the class java.lang.Object has a depth of 1;</li>
+<li>all other classes have a depth of 1 + the depth of their super class.</li>
+</ul>
+
+<a name="NOA"/>
+<h3>Number of Attributes - NOA</h3>
+
+The number of distinct state variables in a class serves as one measure of
+its complexity. The more state a class represents the more difficult it is to
+maintain invariants for it. It also hinders comprehensibility and reuse.
+<p/>
+In Java, state can be exposed to subclasses through protected fields, which
+entails that the subclass also be aware of and maintain any invariants. This
+interference with the class's data encapsulation can be a source of defects
+and hidden dependencies between the state variables.
+<p/>
+NOA is defined for classes and interfaces. It counts the number of fields
+declared in the class or interface.
+
+<a name="NRM"/>
+<h3>Number of Remote Methods - NRM</h3>
+
+NRM is defined for classes. A remote method call is defined as an
+invocation of a method that is not declared in any of:
+<ul>
+<li>the class itself;</li>
+<li>a class or interface that the class extends or implements;</li>
+<li>a class or method that extends the class.</li>
+</ul>
+
+The value is the count of all the remote method calls in all of the methods
+and constructors of the class.
+
+<a name="NLM"/>
+<h3>Number of Local Methods - NLM</h3>
+
+NLM is defined for classes and interfaces. A local method is defined as a
+method that is declared in the class or interface. NLM can be configured to
+include the local methods of all of the class's superclasses. Methods with
+public, protected, package and private visibility can be independently
+counted by setting configuration parameters.
+
+<a name="WMC"/>
+<h3>Weighted Methods per Class - WMC</h3>
+
+If the number of methods in a class can be determined during the design
+and modeling phase of a project, it can be used as a predictor of how
+much time and effort is needed to develop, debug and maintain it. This
+metric can be further refined by incorporating a weighting for the
+complexity of each method. The usual weighting is given by the cyclomatic
+complexity of the method.
+<p/>
+The subclasses of a class inherit all of its public and protected methods,
+and possibly its package methods as well, so the number of methods a
+class has directly impacts the complexity of its subclasses. Classes with
+large numbers of methods are often specific to a particular application,
+reducing the ability to reuse them.
+<p/>
+The definition of WMC is based upon NLM, and it provides the same
+configuration parameters for counting inherited methods and of varying
+visibility. The main difference is that NLM always counts each method as 1,
+whereas WMC will weight each method. There are two weighting schemes:
+<ul>
+<li>V(G) the cyclomatic complexity of the method is used as its weight.
+ Methods from class files are given a V(G) of 1.</li>
+<li>the arity, or the number of parameters of the method are used to
+ determine the weight.</li>
+</ul>
+
+<a name="RFC"/>
+<h3>Response For Class - RFC</h3>
+
+The response set of a class is the set of all methods that can be invoked as
+a result of a message sent to an object of the class. This includes methods
+in the class's inheritance hierarchy and methods that can be invoked on
+other objects. The Response For Class metric is defined to be size of the
+response set for the class. A class which provides a larger response set is
+considered to be more complex than one with a smaller response set.
+<p/>
+One reason for this is that if a method call on a class can result in a large
+number of different method calls on the target and other classes, then it
+can be harder to test the behavior of the class and debug problems. It will
+typically require a deeper understanding of the potential interactions that
+objects of the class can have with the rest of the system.
+<p/>
+RFC is defined as the sum of NLM and NRM for the class. The local methods
+include all of the public, protected, package and private methods, but not
+methods declared only in a superclass.
+
+<a name="DAC"/>
+<h3>Data Abstraction Coupling - DAC</h3>
+
+DAC is defined for classes and interfaces. It counts the number of reference
+types that are used in the field declarations of the class or interface. The
+component types of arrays are also counted. Any field with a type that is
+either a supertype or a subtype of the class is not counted.
+
+<a name="FANOUT"/>
+<h3>Fan Out - FANOUT</h3>
+
+FANOUT is defined for classes and interfaces, constructors and methods. It
+counts the number of reference types that are used in:
+<ul>
+<li>field declarations;</li>
+<li>formal parameters and return types;</li>
+<li>throws declarations;</li>
+<li>local variables.</li>
+</ul>
+
+The component types of arrays are also counted. Any type that is either a
+supertype or a subtype of the class is not counted.
+
+<a name="CBO"/>
+<h3>Coupling Between Objects - CBO</h3>
+
+When one object or class uses another object or class they are said to be
+coupled. One major source of coupling is that between a superclass and a
+subclass. A coupling is also introduced when a method or field in another
+class is accessed, or when an object of another class is passed into or out
+of a method invocation. Coupling Between Objects is a measure of the
+non-inheritance coupling between two objects.
+<p/>
+A high value of coupling reduces the modularity of the class and makes
+reuse more difficult. The more independent a class is the more likely it is
+that it will be possible to reuse it in another part of the system. When a
+class is coupled to another class it becomes sensitive to changes in that
+class, thereby making maintenance for difficult. In addition, a class that is
+overly dependent on other classes can be difficult to understand and test in
+isolation.
+<p/>
+CBO is defined for classes and interfaces, constructors and methods. It
+counts the number of reference types that are used in:
+<ul>
+<li>field declarations</li>
+<li>formal parameters and return types</li>
+<li>throws declarations</li>
+<li>local variables</li>
+</ul>
+
+It also counts:
+<ul>
+<li>types from which field and method selections are made</li>
+</ul>
+
+The component types of arrays are also counted. Any type that is either a
+supertype or a subtype of the class is not counted.
+
+<a name="LCOM"/>
+<h3>Lack of Cohesion Of Methods - LCOM</h3>
+
+The cohesion of a class is the degree to which its methods are related to
+each other. It is determined by examining the pattern of state variable
+accesses within the set of methods. If all the methods access the same state
+variables then they have high cohesion; if they access disjoint sets of
+variables then the cohesion is low. An extreme example of low cohesion
+would be if none of the methods accessed any of the state variables.
+
+If a class exhibits low method cohesion it indicates that the design of the
+class has probably been partitioned incorrectly, and could benefit by being
+split into more classes with individually higher cohesion. On the other
+hand, a high value of cohesion (a low lack of cohesion) implies that the
+class is well designed. A cohesive class will tend to provide a high degree
+of encapsulation, whereas a lack of cohesion decreases encapsulation and
+increases complexity.
+<p/>
+Another form of cohesion that is useful for Java programs is cohesion
+between nested and enclosing classes. A nested class that has very low
+cohesion with its enclosing class would probably better designed as a peer
+class rather than a nested class.
+<p/>
+LCOM is defined for classes. Operationally, LCOM takes each pair of
+methods in the class and determines the set of fields they each access. If
+they have disjoint sets of field accesses increase the count P by one. If they
+share at least one field access then increase Q by one. After considering
+each pair of methods,
+LCOM = (P > Q) ? (P - Q) : 0
+<p/>
+Indirect access to fields via local methods can be considered by setting a
+metric configuration parameter.
+
+<a name="NOC"/>
+<h3>Number Of Classes - NOC</h3>
+
+The overall size of the system can be estimated by calculating the number
+of classes it contains. A large system with more classes is more complex
+than a smaller one because the number of potential interactions between
+objects is higher. This reduces the comprehensibility of the system which
+in turn makes it harder to test, debug and maintain.
+<p/>
+If the number of classes in the system can be projected during the initial
+design phase of the project it can serve as a base for estimating the total
+effort and cost of developing, debugging and maintaining the system.
+<p/>
+The NOC metric can also usefully be applied at the package and class level
+as well as the total system.
+<p/>
+NOCL is defined for class and interfaces. It counts the number of classes or
+interfaces that are declared. This is usually 1, but nested class declarations
+will increase this number.
+</body>
+</html>
+</xsl:template>
+
+<!-- this is the stylesheet css to use for nearly everything -->
+<xsl:template name="stylesheet.css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin-left: 10;
+ margin-right: 10;
+ font:normal 80% arial,helvetica,sanserif;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ font-weight:bold;
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ font-size:100%;
+ border: none
+ }
+ table.log tr td, tr th {
+
+ }
+ h2 {
+ font-weight:bold;
+ font-size:140%;
+ margin-bottom: 5;
+ }
+ h3 {
+ font-size:100%;
+ font-weight:bold;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+ .Error {
+ font-weight:bold; color:red;
+ }
+
+</xsl:template>
+
+<!-- print the metrics of the class -->
+<xsl:template match="class" mode="class.details">
+ <!--xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/-->
+ <xsl:variable name="package.name" select="@package"/>
+ <HTML>
+ <HEAD>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="$package.name"/>
+ </xsl:call-template>
+ </HEAD>
+ <BODY>
+ <xsl:call-template name="pageHeader"/>
+
+ <H3>Class <xsl:if test="not($package.name = 'unnamed package')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:call-template name="all.metrics.header"/>
+ <xsl:apply-templates select="." mode="print.metrics"/>
+ </table>
+
+ <H3>Methods</H3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:call-template name="method.metrics.header"/>
+ <xsl:apply-templates select="method" mode="print.metrics"/>
+ </table>
+
+ <xsl:call-template name="pageFooter"/>
+ </BODY>
+ </HTML>
+</xsl:template>
+
+
+<!-- list of classes in a package -->
+<xsl:template match="package" mode="classes.list">
+ <HTML>
+ <HEAD>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="@name"/>
+ </xsl:call-template>
+ </HEAD>
+ <BODY>
+ <table width="100%">
+ <tr>
+ <td nowrap="nowrap">
+ <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2>
+ </td>
+ </tr>
+ </table>
+
+ <H2>Classes</H2>
+ <TABLE WIDTH="100%">
+ <!-- xalan-nodeset:nodeset for Xalan 1.2.2 -->
+ <xsl:for-each select="$doctree/classes/class[@package = current()/@name]">
+ <xsl:sort select="@name"/>
+ <tr>
+ <td nowrap="nowrap">
+ <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </TABLE>
+ </BODY>
+ </HTML>
+</xsl:template>
+
+
+<!--
+ Creates an all-classes.html file that contains a link to all package-summary.html
+ on each class.
+-->
+<xsl:template match="metrics" mode="all.classes">
+ <html>
+ <head>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="''"/>
+ </xsl:call-template>
+ </head>
+ <body>
+ <h2>Classes</h2>
+ <table width="100%">
+ <xsl:for-each select="$doctree/classes/class">
+ <xsl:sort select="@name"/>
+ <xsl:apply-templates select="." mode="all.classes"/>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="class" mode="all.classes">
+ <xsl:variable name="package.name" select="@package"/>
+ <xsl:variable name="class.name" select="@name"/>
+ <tr>
+ <td nowrap="nowrap">
+ <a target="classFrame">
+ <xsl:attribute name="href">
+ <xsl:if test="not($package.name='unnamed package')">
+ <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text>
+ </xsl:if>
+ <xsl:value-of select="$class.name"/><xsl:text>.html</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of select="$class.name"/>
+ </a>
+ </td>
+ </tr>
+</xsl:template>
+
+<!--
+ Creates an html file that contains a link to all package-summary.html files on
+ each package existing on testsuites.
+ @bug there will be a problem here, I don't know yet how to handle unnamed package :(
+-->
+<xsl:template match="metrics" mode="all.packages">
+ <html>
+ <head>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="./package/@name"/>
+ </xsl:call-template>
+ </head>
+ <body>
+ <h2><a href="overview-summary.html" target="classFrame">Home</a></h2>
+ <h2>Packages</h2>
+ <table width="100%">
+ <xsl:apply-templates select=".//package[not(./@name = 'unnamed package')]" mode="all.packages">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="package" mode="all.packages">
+ <tr>
+ <td nowrap="nowrap">
+ <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame">
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ </tr>
+</xsl:template>
+
+
+<xsl:template match="metrics" mode="overview.packages">
+ <html>
+ <head>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="''"/>
+ </xsl:call-template>
+ </head>
+ <body onload="open('allclasses-frame.html','classListFrame')">
+ <xsl:call-template name="pageHeader"/>
+ <h3>Summary</h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th><a href="metrics-reference.html#V(G)">V(G)</a></th>
+ <th><a href="metrics-reference.html#LOC">LOC</a></th>
+ <th><a href="metrics-reference.html#DIT">DIT</a></th>
+ <th><a href="metrics-reference.html#NOA">NOA</a></th>
+ <th><a href="metrics-reference.html#NRM">NRM</a></th>
+ <th><a href="metrics-reference.html#NLM">NLM</a></th>
+ <th><a href="metrics-reference.html#WMC">WMC</a></th>
+ <th><a href="metrics-reference.html#RFC">RFC</a></th>
+ <th><a href="metrics-reference.html#DAC">DAC</a></th>
+ <th><a href="metrics-reference.html#FANOUT">FANOUT</a></th>
+ <th><a href="metrics-reference.html#CBO">CBO</a></th>
+ <th><a href="metrics-reference.html#LCOM">LCOM</a></th>
+ <th><a href="metrics-reference.html#NOCL">NOCL</a></th>
+ </tr>
+ <xsl:apply-templates select="." mode="print.metrics"/>
+ </table>
+ <table border="0" width="100%">
+ <tr>
+ <td style="text-align: justify;">
+ Note: Metrics evaluate the quality of software by analyzing the program source and quantifying
+ various kind of complexity. Complexity is a common source of problems and defects in software.
+ High complexity makes it more difficult to develop, understand, maintain, extend, test and debug
+ a program.
+ <p/>
+ The primary use of metrics is to focus your attention on those parts of code that potentially are
+ complexity hot spots. Once the complex areas your program have been uncovered, you can take remedial
+ actions.
+ For additional information about metrics and their meaning, please consult
+ Metamata Metrics manual.
+ </td>
+ </tr>
+ </table>
+
+ <h3>Packages</h3>
+ <table border="0" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:call-template name="all.metrics.header"/>
+ <xsl:for-each select=".//package[not(@name = 'unnamed package')]">
+ <xsl:sort select="@name" order="ascending"/>
+ <xsl:apply-templates select="." mode="print.metrics"/>
+ </xsl:for-each>
+ </table>
+ <!-- @bug there could some classes at this level (classes in unnamed package) -->
+ <xsl:call-template name="pageFooter"/>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="package" mode="package.summary">
+ <HTML>
+ <HEAD>
+ <xsl:call-template name="create.stylesheet.link">
+ <xsl:with-param name="package.name" select="@name"/>
+ </xsl:call-template>
+ </HEAD>
+ <body onload="open('package-frame.html','classListFrame')">
+ <xsl:call-template name="pageHeader"/>
+ <!-- create an anchor to this package name -->
+ <h3>Package <xsl:value-of select="@name"/></h3>
+
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:call-template name="all.metrics.header"/>
+ <xsl:apply-templates select="." mode="print.metrics"/>
+ </table>
+
+ <table border="0" width="100%">
+ <tr>
+ <td style="text-align: justify;">
+ Note: Metrics evaluate the quality of software by analyzing the program source and quantifying
+ various kind of complexity. Complexity is a common source of problems and defects in software.
+ High complexity makes it more difficult to develop, understand, maintain, extend, test and debug
+ a program.
+ <p/>
+ The primary use of metrics is to focus your attention on those parts of code that potentially are
+ complexity hot spots. Once the complex areas your program have been uncovered, you can take remedial
+ actions.
+ For additional information about metrics and their meaning, please consult
+ Metamata Metrics manual.
+ </td>
+ </tr>
+ </table>
+
+ <xsl:variable name="classes-in-package" select="$doctree/classes/class[@package = current()/@name]"/>
+ <xsl:if test="count($classes-in-package) > 0">
+ <H3>Classes</H3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <xsl:call-template name="all.metrics.header"/>
+ <xsl:for-each select="$classes-in-package">
+ <xsl:sort select="@name"/>
+ <xsl:apply-templates select="." mode="print.metrics"/>
+ </xsl:for-each>
+ </table>
+ </xsl:if>
+
+ <xsl:call-template name="pageFooter"/>
+ </body>
+ </HTML>
+</xsl:template>
+
+
+<!--
+ transform string like a.b.c to ../../../
+ @param path the path to transform into a descending directory path
+-->
+<xsl:template name="path">
+ <xsl:param name="path"/>
+ <xsl:if test="contains($path,'.')">
+ <xsl:text>../</xsl:text>
+ <xsl:call-template name="path">
+ <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="not(contains($path,'.')) and not($path = '')">
+ <xsl:text>../</xsl:text>
+ </xsl:if>
+</xsl:template>
+
+
+<!-- create the link to the stylesheet based on the package name -->
+<xsl:template name="create.stylesheet.link">
+ <xsl:param name="package.name"/>
+ <LINK REL ="stylesheet" TYPE="text/css" TITLE="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></LINK>
+</xsl:template>
+
+
+<!-- Page Header -->
+<xsl:template name="pageHeader">
+
+ <!-- jakarta logo -->
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="bannercell" rowspan="2">
+ <a href="http://jakarta.apache.org/">
+ <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
+ </a>
+ </td>
+ <td style="text-align:right"><h2>Source Code Metrics</h2></td>
+ </tr>
+ <tr>
+ <td style="text-align:right">Designed for use with <a href='http://www.webgain.com/products/quality_analyzer/'>Webgain QA/Metamata Metrics</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+</xsl:template>
+
+<!-- Page Footer -->
+<xsl:template name="pageFooter">
+ <table width="100%">
+ <tr><td><hr noshade="yes" size="1"/></td></tr>
+ <tr><td>
+ <div align="center"><font color="#525D76" size="-1"><em>
+ Copyright © 1999-2001, Apache Software Foundation
+ </em></font></div>
+ </td></tr>
+ </table>
+</xsl:template>
+
+<!-- class header -->
+<xsl:template name="all.metrics.header">
+ <tr>
+ <th width="80%">Name</th>
+ <th nowrap="nowrap">V(G)</th>
+ <th>LOC</th>
+ <th>DIT</th>
+ <th>NOA</th>
+ <th>NRM</th>
+ <th>NLM</th>
+ <th>WMC</th>
+ <th>RFC</th>
+ <th>DAC</th>
+ <th>FANOUT</th>
+ <th>CBO</th>
+ <th>LCOM</th>
+ <th>NOCL</th>
+ </tr>
+</xsl:template>
+
+<!-- method header -->
+<xsl:template name="method.metrics.header">
+ <tr>
+ <th width="80%">Name</th>
+ <th nowrap="nowrap">V(G)</th>
+ <th>LOC</th>
+ <th>FANOUT</th>
+ <th>CBO</th>
+ </tr>
+</xsl:template>
+
+<!-- method information -->
+<xsl:template match="method" mode="print.metrics">
+ <tr>
+ <xsl:call-template name="alternate-row"/>
+ <td><xsl:apply-templates select="@name"/></td>
+ <td><xsl:apply-templates select="@vg"/></td>
+ <td><xsl:apply-templates select="@loc"/></td>
+ <td><xsl:apply-templates select="@fanout"/></td>
+ <td><xsl:apply-templates select="@cbo"/></td>
+ </tr>
+</xsl:template>
+
+<!-- class information -->
+<xsl:template match="class" mode="print.metrics">
+ <tr>
+ <xsl:call-template name="alternate-row"/>
+ <td><a href="{@name}.html"><xsl:value-of select="@name"/></a></td>
+ <td><xsl:apply-templates select="@vg"/></td>
+ <td><xsl:apply-templates select="@loc"/></td>
+ <td><xsl:apply-templates select="@dit"/></td>
+ <td><xsl:apply-templates select="@noa"/></td>
+ <td><xsl:apply-templates select="@nrm"/></td>
+ <td><xsl:apply-templates select="@nlm"/></td>
+ <td><xsl:apply-templates select="@wmc"/></td>
+ <td><xsl:apply-templates select="@rfc"/></td>
+ <td><xsl:apply-templates select="@dac"/></td>
+ <td><xsl:apply-templates select="@fanout"/></td>
+ <td><xsl:apply-templates select="@cbo"/></td>
+ <td><xsl:apply-templates select="@lcom"/></td>
+ <td><xsl:apply-templates select="@nocl"/></td>
+ </tr>
+</xsl:template>
+
+<xsl:template match="file|package" mode="print.metrics">
+ <tr>
+ <xsl:call-template name="alternate-row"/>
+ <td>
+ <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame">
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ <td><xsl:apply-templates select="@vg"/></td>
+ <td><xsl:apply-templates select="@loc"/></td>
+ <td><xsl:apply-templates select="@dit"/></td>
+ <td><xsl:apply-templates select="@noa"/></td>
+ <td><xsl:apply-templates select="@nrm"/></td>
+ <td><xsl:apply-templates select="@nlm"/></td>
+ <td><xsl:apply-templates select="@wmc"/></td>
+ <td><xsl:apply-templates select="@rfc"/></td>
+ <td><xsl:apply-templates select="@dac"/></td>
+ <td><xsl:apply-templates select="@fanout"/></td>
+ <td><xsl:apply-templates select="@cbo"/></td>
+ <td><xsl:apply-templates select="@lcom"/></td>
+ <td><xsl:apply-templates select="@nocl"/></td>
+ </tr>
+</xsl:template>
+
+<xsl:template match="metrics" mode="print.metrics">
+ <tr>
+ <xsl:call-template name="alternate-row"/>
+ <!-- the global metrics is the top package metrics -->
+ <td><xsl:apply-templates select="./package/@vg"/></td>
+ <td><xsl:apply-templates select="./package/@loc"/></td>
+ <td><xsl:apply-templates select="./package/@dit"/></td>
+ <td><xsl:apply-templates select="./package/@noa"/></td>
+ <td><xsl:apply-templates select="./package/@nrm"/></td>
+ <td><xsl:apply-templates select="./package/@nlm"/></td>
+ <td><xsl:apply-templates select="./package/@wmc"/></td>
+ <td><xsl:apply-templates select="./package/@rfc"/></td>
+ <td><xsl:apply-templates select="./package/@dac"/></td>
+ <td><xsl:apply-templates select="./package/@fanout"/></td>
+ <td><xsl:apply-templates select="./package/@cbo"/></td>
+ <td><xsl:apply-templates select="./package/@lcom"/></td>
+ <td><xsl:apply-templates select="./package/@nocl"/></td>
+ </tr>
+</xsl:template>
+
+<!-- alternated row style -->
+<xsl:template name="alternate-row">
+<xsl:attribute name="class">
+ <xsl:if test="position() mod 2 = 1">a</xsl:if>
+ <xsl:if test="position() mod 2 = 0">b</xsl:if>
+</xsl:attribute>
+</xsl:template>
+
+
+<!-- how to display the metrics with their max value -->
+<!-- @todo the max values must be external to the xsl -->
+
+ <xsl:template match="@vg">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$vg.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@loc">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$loc.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@dit">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$dit.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@noa">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$noa.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@nrm">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$nrm.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@nlm">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$nlm.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@wmc">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$wmc.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@rfc">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$rfc.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@dac">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$dac.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@fanout">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$fanout.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@cbo">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$cbo.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@lcom">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$lcom.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@nocl">
+ <xsl:call-template name="display-value">
+ <xsl:with-param name="value" select="current()"/>
+ <xsl:with-param name="max" select="$nocl.max"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template name="display-value">
+ <xsl:param name="value"/>
+ <xsl:param name="max"/>
+ <xsl:if test="$value > $max">
+ <xsl:attribute name="class">Error</xsl:attribute>
+ </xsl:if>
+ <xsl:value-of select="$value"/>
+ </xsl:template>
+
+</xsl:stylesheet>
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/mmetrics-frames.xsl
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/tagdiff.xsl
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/tagdiff.xsl (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/tagdiff.xsl 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,324 @@
+<!-- a stylesheet to display changelogs ala netbeans -->
+
+<xsl:stylesheet
+
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+
+ version="1.0">
+
+
+
+ <xsl:param name="title"/>
+
+ <xsl:param name="module"/>
+
+ <xsl:param name="cvsweb"/>
+
+
+
+ <xsl:output method="html" indent="yes"/>
+
+
+
+ <!-- Copy standard document elements. Elements that
+
+ should be ignored must be filtered by apply-templates
+
+ tags. -->
+
+ <xsl:template match="*">
+
+ <xsl:copy>
+
+ <xsl:copy-of select="attribute::*[. != '']"/>
+
+ <xsl:apply-templates/>
+
+ </xsl:copy>
+
+ </xsl:template>
+
+
+
+ <xsl:template match="tagdiff">
+
+ <HTML>
+
+ <HEAD>
+
+ <TITLE><xsl:value-of select="$title"/></TITLE>
+
+ </HEAD>
+
+ <BODY link="#000000" alink="#000000" vlink="#000000" text="#000000">
+
+ <style type="text/css">
+
+ body, p {
+
+ font-family: verdana,arial,helvetica;
+
+ font-size: 80%;
+
+ color:#000000;
+
+ }
+
+ .dateAndAuthor {
+
+ font-family: verdana,arial,helvetica;
+
+ font-size: 80%;
+
+ font-weight: bold;
+
+ text-align:left;
+
+ background:#a6caf0;
+
+ }
+
+ tr, td{
+
+ font-family: verdana,arial,helvetica;
+
+ font-size: 80%;
+
+ background:#eeeee0;
+
+ }
+
+ </style>
+
+ <h1>
+
+ <a name="top"><xsl:value-of select="$title"/></a>
+
+ </h1>
+
+ Tagdiff between <xsl:value-of select="@startTag"/> <xsl:value-of select="@startDate"/> and
+
+ <xsl:value-of select="@endTag"/> <xsl:value-of select="@endDate"/>
+
+ <p align="right">Designed for use with <a href="http://jakarta.apache.org">Ant</a>.</p>
+
+ <hr size="2"/>
+
+ <a name="TOP"/>
+
+ <table width="100%">
+
+ <tr>
+
+ <td align="right">
+
+ <a href="#New">New Files</a> |
+
+ <a href="#Modified">Modified Files</a> |
+
+ <a href="#Removed">Removed Files</a>
+
+ </td>
+
+ </tr>
+
+ </table>
+
+ <TABLE BORDER="0" WIDTH="100%" CELLPADDING="3" CELLSPACING="1">
+
+ <xsl:call-template name="show-entries">
+
+ <xsl:with-param name="title">New Files</xsl:with-param>
+
+ <xsl:with-param name="anchor">New</xsl:with-param>
+
+ <xsl:with-param name="entries" select=".//entry[file/revision][not(file/prevrevision)]"/>
+
+ </xsl:call-template>
+
+
+
+ <xsl:call-template name="show-entries">
+
+ <xsl:with-param name="title">Modified Files</xsl:with-param>
+
+ <xsl:with-param name="anchor">Modified</xsl:with-param>
+
+ <xsl:with-param name="entries" select=".//entry[file/revision][file/prevrevision]"/>
+
+ </xsl:call-template>
+
+
+
+ <xsl:call-template name="show-entries">
+
+ <xsl:with-param name="title">Removed Files</xsl:with-param>
+
+ <xsl:with-param name="anchor">Removed</xsl:with-param>
+
+ <xsl:with-param name="entries" select=".//entry[not(file/revision)][not(file/prevrevision)]"/>
+
+ </xsl:call-template>
+
+ </TABLE>
+
+
+
+ </BODY>
+
+ </HTML>
+
+ </xsl:template>
+
+
+
+ <xsl:template name="show-entries">
+
+ <xsl:param name="title"/>
+
+ <xsl:param name="anchor"/>
+
+ <xsl:param name="entries"/>
+
+ <TR>
+
+ <TD colspan="2" class="dateAndAuthor">
+
+ <a>
+
+ <xsl:attribute name="name"><xsl:value-of select="$anchor"/></xsl:attribute>
+
+ <xsl:value-of select="$title"/> - <xsl:value-of select="count($entries)"/> entries
+
+ </a>
+
+ <a href="#TOP">(back to top)</a>
+
+ </TD>
+
+ </TR>
+
+ <TR>
+
+ <TD width="20">
+
+ <xsl:text> </xsl:text>
+
+ </TD>
+
+ <TD>
+
+ <ul>
+
+ <xsl:apply-templates select="$entries"/>
+
+ </ul>
+
+ </TD>
+
+ </TR>
+
+ </xsl:template>
+
+
+
+ <xsl:template match="entry">
+
+ <xsl:apply-templates select="file"/>
+
+ </xsl:template>
+
+
+
+ <xsl:template match="date">
+
+ <i><xsl:value-of select="."/></i>
+
+ </xsl:template>
+
+
+
+ <xsl:template match="time">
+
+ <i><xsl:value-of select="."/></i>
+
+ </xsl:template>
+
+
+
+ <xsl:template match="author">
+
+ <i>
+
+ <a>
+
+ <xsl:attribute name="href">mailto:<xsl:value-of select="."/></xsl:attribute>
+
+ <xsl:value-of select="."/>
+
+ </a>
+
+ </i>
+
+ </xsl:template>
+
+
+
+ <xsl:template match="file">
+
+ <li>
+
+ <a target="_new">
+
+ <xsl:attribute name="href"><xsl:value-of select="$cvsweb"/><xsl:value-of select="$module" />/<xsl:value-of select="name" /></xsl:attribute>
+
+ <xsl:value-of select="name" />
+
+ </a>
+
+ <xsl:if test="string-length(prevrevision) > 0 or string-length(revision) > 0">
+
+ <xsl:text> </xsl:text>
+
+ <a target="_new">
+
+ <xsl:choose>
+
+ <xsl:when test="string-length(prevrevision) = 0 ">
+
+ <xsl:attribute name="href"><xsl:value-of select="$cvsweb"/><xsl:value-of select="$module" />/<xsl:value-of select="name" />?rev=<xsl:value-of select="revision" />&content-type=text/x-cvsweb-markup</xsl:attribute>
+
+ </xsl:when>
+
+ <xsl:otherwise>
+
+ <xsl:attribute name="href"><xsl:value-of select="$cvsweb"/><xsl:value-of select="$module" />/<xsl:value-of select="name" />?r1=<xsl:value-of select="revision" />&r2=<xsl:value-of select="prevrevision"/>&diff_format=h</xsl:attribute>
+
+ </xsl:otherwise>
+
+ </xsl:choose> (<xsl:value-of select="revision"/>)
+
+ </a>
+
+ </xsl:if>
+
+ </li>
+
+ </xsl:template>
+
+
+
+ <!-- Any elements within a msg are processed,
+
+ so that we can preserve HTML tags. -->
+
+ <xsl:template match="msg">
+
+ <b><xsl:apply-templates/></b>
+
+ </xsl:template>
+
+
+
+</xsl:stylesheet>
+
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/tagdiff.xsl
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/templates
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Modified: labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/templates/mbean-custom.j
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/templates/mbean-custom.j 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/templates/mbean-custom.j 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,5 +1,5 @@
<XDtClass:ifHasClassTag tagName="jmx:mbean" paramName="name">
//default object name
- public static final javax.management.ObjectName OBJECT_NAME = org.jboss.mx.util.ObjectNameFactory.create("<XDtClass:classTagValue tagName="jmx:mbean" paramName="name"/>");
+ public static final javax.management.ObjectName OBJECT_NAME = org.jboss.util.jmx.ObjectNameFactory.create("<XDtClass:classTagValue tagName="jmx:mbean" paramName="name"/>");
</XDtClass:ifHasClassTag>
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/templates/mbean-custom.j
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/templates/mbean-custom.xdt
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/templates/mbean-custom.xdt (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/etc/xdoclet/templates/mbean-custom.xdt 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,5 @@
+
+<XDtClass:ifHasClassTag tagName="jmx:mbean" paramName="name">
+ //default object name
+ public static final javax.management.ObjectName OBJECT_NAME = org.jboss.util.jmx.ObjectNameFactory.create("<XDtClass:classTagValue tagName="jmx:mbean" paramName="name"/>");
+</XDtClass:ifHasClassTag>
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/examples
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Added: labs/jbossbuild/buildmagic/trunk/tools/examples/build.bat
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/examples/build.bat (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/examples/build.bat 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,54 @@
+ at echo off
+rem
+rem Invokes a script of the same name in the 'tools' module.
+rem
+rem The 'tools' module is expected to be a peer directory of the directory
+rem in which this script lives.
+rem
+rem @author Jason Dillon <jason at planet57.com>
+rem
+
+rem $Id$
+
+setlocal
+
+set PROGNAME=%~nx0
+set DIRNAME=%~dp0
+
+rem Legacy shell support
+if x%PROGNAME%==x set PROGNAME=build.bat
+if x%DIRNAME%==x set DIRNAME=.\
+
+set MODULE_ROOT=%DIRNAME%
+if x%TOOLS_ROOT%==x set TOOLS_ROOT=%DIRNAME%..\tools
+set TARGET=%TOOLS_ROOT%\bin\build.bat
+set ARGS=%*
+
+rem Start'er up yo
+goto main
+
+:debug
+if not x%DEBUG%==x echo %PROGNAME%: %*
+goto :EOF
+
+:main
+call :debug PROGNAME=%PROGNAME%
+call :debug DIRNAME=%DIRNAME%
+call :debug TOOLS_ROOT=%TOOLS_ROOT%
+call :debug TARGET=%TARGET%
+
+if exist %TARGET% call :call-script & goto :EOF
+rem else fail, we can not go on
+
+echo %PROGNAME%: *ERROR* The target executable does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%: %TARGET%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools' module
+echo %PROGNAME%: and make sure it is up to date.
+goto :EOF
+
+:call-script
+call :debug Executing %TARGET% %ARGS%
+call %TARGET% %ARGS%
+goto :EOF
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/examples/build.bat
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: labs/jbossbuild/buildmagic/trunk/tools/examples/build.sh
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/examples/build.sh (rev 0)
+++ labs/jbossbuild/buildmagic/trunk/tools/examples/build.sh 2008-08-19 22:06:02 UTC (rev 21628)
@@ -0,0 +1,49 @@
+#!/bin/sh
+##
+## Invokes a script of the same name in the 'tools' module.
+##
+## The 'tools' module is expected to be a peer directory of the directory
+## in which this script lives.
+##
+## @author Jason Dillon <jason at planet57.com>
+##
+
+# $Id$
+
+PROGNAME=`basename $0`
+DIRNAME=`dirname $0`
+
+# Buss it yo
+main() {
+ if [ "x$TOOLS_ROOT" = "x" ]; then
+ TOOLS_ROOT=`cd $DIRNAME/../tools && pwd`
+ fi
+
+ MODULE_ROOT=`cd $DIRNAME; pwd`
+ export TOOLS_ROOT MODULE_ROOT DEBUG TRACE
+
+ # Where is the target script?
+ target="$TOOLS_ROOT/bin/$PROGNAME"
+ if [ ! -f "$target" ]; then
+ echo "${PROGNAME}: *ERROR* The target executable does not exist:"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: $target"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: Please make sure you have checked out the 'tools' module"
+ echo "${PROGNAME}: and make sure it is up to date."
+ exit 2
+ fi
+
+ # Get busy yo!
+ if [ "x$DEBUG" != "x" ]; then
+ echo "${PROGNAME}: Executing: /bin/sh $target $@"
+ fi
+ if [ "x$TRACE" = "x" ]; then
+ exec /bin/sh $target "$@"
+ else
+ exec /bin/sh -x $target "$@"
+ fi
+}
+
+# Lets get ready to rumble!
+main "$@"
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/examples/build.sh
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/lib
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/README
===================================================================
--- labs/jbossbuild/buildmagic/trunk/tools/lib/README 2008-08-19 16:23:13 UTC (rev 21627)
+++ labs/jbossbuild/buildmagic/trunk/tools/lib/README 2008-08-19 22:06:02 UTC (rev 21628)
@@ -1,14 +0,0 @@
-Please refer to the Ant manual under Installing Ant / Library
-Dependencies for a list of the jar requirements for various optional
-tasks and features.
-
-This directory contains xercesImpl.jar from the 2.6.1 release of
-Apache Xerces. For more information or newer releases see
-<http://xml.apache.org/xerces2-j/>. See the file LICENSE.xerces for
-the terms of distribution.
-
-It also contains xml-apis.jar from the 2.6.1 release of Apache Xerces.
-For more information or newer releases see
-<http://xml.apache.org/commons/>. See the files LICENSE.dom and
-LICENSE.sax for the terms of distribution.
-
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/ant-javamail.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/ant-junit.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/ant-launcher.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/ant-nodeps.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/ant-trax.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/ant-xslp.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/tools/lib/ant.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/tools/lib/buildmagic-tasks.jar
===================================================================
(Binary files differ)
Added: labs/jbossbuild/buildmagic/trunk/tools/lib/crimson.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/lib/crimson.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/jbossbuild.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/jdtCompilerAdapter.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/tools/lib/junit.jar
===================================================================
(Binary files differ)
Added: labs/jbossbuild/buildmagic/trunk/tools/lib/optional.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/lib/optional.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/org.eclipse.jdt.core_3.1.0.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/pretty.jar
===================================================================
(Binary files differ)
Added: labs/jbossbuild/buildmagic/trunk/tools/lib/remote-mbeanserver.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/lib/remote-mbeanserver.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: labs/jbossbuild/buildmagic/trunk/tools/lib/resolver.jar
===================================================================
(Binary files differ)
Added: labs/jbossbuild/buildmagic/trunk/tools/lib/saxon.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossbuild/buildmagic/trunk/tools/lib/saxon.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossbuild/buildmagic/trunk/tools/lib/xalan.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/tools/lib/xercesImpl.jar
===================================================================
(Binary files differ)
Modified: labs/jbossbuild/buildmagic/trunk/tools/lib/xml-apis.jar
===================================================================
(Binary files differ)
More information about the jboss-svn-commits
mailing list