[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 18:33:54 GMT 2012
Author: lajoie
Date: Sat Jan 28 18:33:54 2012
New Revision: 220
URL: http://svn.shibboleth.net/view/utilities?rev=220&view=rev
Log:
More helper classes
Added:
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractDestructableInitializableComponent.java (with props)
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/logic/TypeCheckAndApplyPredicate.java (with props)
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/scripting/
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/scripting/EvaluableScript.java (with props)
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/scripting/package-info.java (with props)
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/AbstractInitializableComponent.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=220&r1=219&r2=220&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 18:33:54 2012
@@ -17,42 +17,30 @@
package net.shibboleth.utilities.java.support.component;
+import javax.annotation.Nonnull;
+
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.logic.Assert;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
/**
* Base class for components implementing {@link DestructableComponent}, {@link IdentifiableComponent} and
* {@link InitializableComponent}.
*/
public abstract class AbstractDestrucableIdentifiableInitializableComponent extends
- AbstractIdentifiableInitializableComponent implements DestructableComponent {
+ AbstractDestructableInitializableComponent implements IdentifiableComponent {
- /** Whether this component has been destroyed. */
- private boolean isDestroyed;
+ /** ID of this component. */
+ private String id;
/** {@inheritDoc} */
- protected synchronized void setId(String componentId) {
- if (isDestroyed) {
- throw new DestroyedComponentException();
- }
-
- super.setId(componentId);
+ public String getId() {
+ return id;
}
/** {@inheritDoc} */
- public final boolean isDestroyed() {
- return isDestroyed;
- }
-
- /** {@inheritDoc} */
- public final synchronized void destroy() {
- if (isDestroyed) {
- return;
- }
-
- doDestroy();
- isDestroyed = true;
- }
-
- /** Performs component specific destruction logic. Default implementation of this method is a no-op. */
- protected void doDestroy() {
-
+ protected synchronized void setId(@Nonnull @NotEmpty String componentId) {
+ checkDestroyed();
+ 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/AbstractInitializableComponent.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractInitializableComponent.java?rev=220&r1=219&r2=220&view=diff
==============================================================================
--- java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractInitializableComponent.java (original)
+++ java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/component/AbstractInitializableComponent.java Sat Jan 28 18:33:54 2012
@@ -37,6 +37,15 @@
doInitialize();
isInitialized = true;
}
+
+ /**
+ * Checks if this component has been initialized and, if not, throws an {@link UninitializedComponentException}.
+ */
+ protected void checkInitialized(){
+ if(!isInitialized){
+ throw new UninitializedComponentException();
+ }
+ }
/**
* Performs the initialization of the component. This method is executed within the lock on the object being
More information about the commits
mailing list