[utilities COMMIT] in /java-support/trunk/src/main/java/net/shibboleth/utilities/java/support: httpclient/HttpResourc...
noreply at shibboleth.net
noreply at shibboleth.net
Wed Mar 21 12:28:34 GMT 2012
Author: lajoie
Date: Wed Mar 21 12:28:34 2012
New Revision: 255
URL: http://svn.shibboleth.net/view/utilities?rev=255&view=rev
Log:
use ComponentSupport helper methods
fix up some synchronization issues with HttpResource
Modified:
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpResource.java
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/resource/AbstractResource.java
java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/resource/ClasspathResource.java
Modified: java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpResource.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpResource.java?rev=255&r1=254&r2=255&view=diff
==============================================================================
--- java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpResource.java (original)
+++ java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/httpclient/HttpResource.java Wed Mar 21 12:28:34 2012
@@ -28,7 +28,7 @@
import net.jcip.annotations.NotThreadSafe;
import net.jcip.annotations.ThreadSafe;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-import net.shibboleth.utilities.java.support.component.DestroyedComponentException;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Assert;
import net.shibboleth.utilities.java.support.primitive.StringSupport;
import net.shibboleth.utilities.java.support.resource.AbstractResource;
@@ -98,10 +98,9 @@
*
* @param strategy strategy used customize the {@link HttpGet} used to fetch the resource
*/
- public void setHttpGetCustomizationStrategy(@Nullable final HttpGetCustomizationStrategy strategy) {
- if (isDestroyed()) {
- throw new DestroyedComponentException();
- }
+ public synchronized void setHttpGetCustomizationStrategy(@Nullable final HttpGetCustomizationStrategy strategy) {
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
httpGetCustomizationStrategy = strategy;
}
@@ -120,19 +119,18 @@
*
* @param strategy strategy used to customize the {@link HttpResponse} before its content is returned
*/
- public void setHttpResponseCustomizationStrategy(@Nullable final HttpResponseCustomizationStrategy strategy) {
- if (isDestroyed()) {
- throw new DestroyedComponentException();
- }
+ public synchronized void setHttpResponseCustomizationStrategy(
+ @Nullable final HttpResponseCustomizationStrategy strategy) {
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
httpResponseCustomizationStrategy = strategy;
}
/** {@inheritDoc} */
protected long doGetLastModifiedTime() throws ResourceException {
- if (isDestroyed()) {
- throw new DestroyedComponentException();
- }
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
try {
final Header httpHeader = getResourceHeaders().getFirstHeader(HttpHeaders.LAST_MODIFIED);
@@ -152,9 +150,8 @@
/** {@inheritDoc} */
protected boolean doExists() throws ResourceException {
- if (isDestroyed()) {
- throw new DestroyedComponentException();
- }
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
int statusCode = getResourceHeaders().getStatusLine().getStatusCode();
@@ -167,9 +164,8 @@
/** {@inheritDoc} */
@Nonnull protected InputStream doGetInputStream() throws ResourceException {
- if (isDestroyed()) {
- throw new DestroyedComponentException();
- }
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
final HttpGet httpRequest = buildGetMethod();
Modified: java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/resource/AbstractResource.java
URL: http://svn.shibboleth.net/view/utilities/java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/resource/AbstractResource.java?rev=255&r1=254&r2=255&view=diff
==============================================================================
--- java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/resource/AbstractResource.java (original)
+++ java-support/trunk/src/main/java/net/shibboleth/utilities/java/support/resource/AbstractResource.java Wed Mar 21 12:28:34 2012
[... 113 lines stripped ...]
More information about the commits
mailing list