[utilities COMMIT] in /java-support/trunk/src: main/java/net/shibboleth/utilities/java/support/component/AbstractDest...
noreply at shibboleth.net
noreply at shibboleth.net
Sat Jan 28 19:08:16 GMT 2012
Author: lajoie
Date: Sat Jan 28 19:08:16 2012
New Revision: 221
URL: http://svn.shibboleth.net/view/utilities?rev=221&view=rev
Log:
Add some more helper methods
Remove unused class
Removed:
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractIdentifiableComponent.java
java-support/trunk/src/test/java/net/shibboleth/utilities/java/support/component/AbstractIdentifiableComponentTest.java
Modified:
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractDestrucableIdentifiableInitializableComponent.java
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractDestructableInitializableComponent.java
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/xml/BasicParserPool.java
Modified: java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractDestrucableIdentifiableInitializableComponent.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractDestrucableIdentifiableInitializableComponent.java?rev=221&r1=220&r2=221&view=diff
==============================================================================
--- java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractDestrucableIdentifiableInitializableComponent.java (original)
+++ java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractDestrucableIdentifiableInitializableComponent.java Sat Jan 28 19:08:16 2012
@@ -40,7 +40,9 @@
/** {@inheritDoc} */
protected synchronized void setId(@Nonnull @NotEmpty String componentId) {
- checkDestroyed();
+ ifInitializedThrowUnmodifiabledComponentException(id);
+ ifDestroyedThrowDestroyedComponentException(id);
+
id = Assert.isNotNull(StringSupport.trimOrNull(componentId), "Component ID can not be null or empty");
}
}
Modified: java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractDestructableInitializableComponent.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractDestructableInitializableComponent.java?rev=221&r1=220&r2=221&view=diff
==============================================================================
--- java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractDestructableInitializableComponent.java (original)
+++ java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractDestructableInitializableComponent.java Sat Jan 28 19:08:16 2012
@@ -16,6 +16,10 @@
*/
package net.shibboleth.utilities.java.support.component;
+
+import javax.annotation.Nullable;
+
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
/** Base class for things that implement {@link DestructableComponent} and {@link InitializableComponent}. */
public abstract class AbstractDestructableInitializableComponent implements DestructableComponent,
@@ -58,25 +62,72 @@
}
/** Checks if this component is destroyed and, if so, throws a {@link DestroyedComponentException}. */
- protected void checkDestroyed() {
+ protected void ifDestroyedThrowDestroyedComponentException() {
+ ifDestroyedThrowDestroyedComponentException(null);
+ }
+
+ /**
+ * Checks if this component is destroyed and, if so, throws a {@link DestroyedComponentException}.
+ *
+ * @param componentId identifier of the component that has been destroyed; used to generate an exception message
+ */
+ protected void ifDestroyedThrowDestroyedComponentException(@Nullable String componentId) {
+ String trimmedId = StringSupport.trimOrNull(componentId);
+
if (isDestroyed) {
- throw new DestroyedComponentException();
- }
- }
-
- /**
- * Checks if this component has been initialized and, if not, throws an {@link UninitializedComponentException}.
- */
- protected void checkInitialized(){
- if(!isInitialized){
- throw new UninitializedComponentException();
+ if (trimmedId != null) {
+ throw new DestroyedComponentException("Component '" + trimmedId
+ + "' has already been destroyed and can no longer be used.");
+ } else {
+ throw new DestroyedComponentException();
+ }
}
}
- /** Performs {@link #checkInitialized()} and then {@link #checkDestroyed()}. */
- protected void readyCheck() {
- checkInitialized();
- checkDestroyed();
+ /** Checks if this component has been initialized and, if not, throws an {@link UninitializedComponentException}. */
+ protected void ifNotInitializedThrowUninitializedComponentException() {
+ ifNotInitializedThrowUninitializedComponentException(null);
+ }
+
+ /**
[... 57 lines stripped ...]
More information about the commits
mailing list