[java-metadata-aggregator COMMIT] in /trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata: FirstItemIdIte...
noreply at shibboleth.net
noreply at shibboleth.net
Sun Oct 30 00:51:04 BST 2011
Author: lajoie
Date: Sun Oct 30 00:51:04 2011
New Revision: 156
URL: http://svn.shibboleth.net/view/java-metadata-aggregator?rev=156&view=rev
Log:
introduce, and use, a naming strategy when logging item information
Added:
trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/FirstItemIdItemIdentificationStrategy.java (with props)
trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/ItemIdentificationStrategy.java (with props)
Modified:
trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java
trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemMetadataFilterStage.java
trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemMetadataTerminationStage.java
trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/StatusMetadataLoggingStage.java
Modified: trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java
URL: http://svn.shibboleth.net/view/java-metadata-aggregator/trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java?rev=156&r1=155&r2=156&view=diff
==============================================================================
--- trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java (original)
+++ trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java Sun Oct 30 00:51:04 2011
@@ -17,7 +17,6 @@
package net.shibboleth.metadata.pipeline;
-import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -25,10 +24,12 @@
import java.util.List;
import java.util.Map;
+import net.shibboleth.metadata.FirstItemIdItemIdentificationStrategy;
import net.shibboleth.metadata.Item;
+import net.shibboleth.metadata.ItemIdentificationStrategy;
import net.shibboleth.metadata.ItemMetadata;
-import net.shibboleth.metadata.ItemSerializer;
+import org.opensaml.util.Assert;
import org.opensaml.util.collections.CollectionSupport;
import org.opensaml.util.collections.LazyList;
@@ -41,8 +42,8 @@
/** {@link ItemMetadata} classes that, if the an {@Item} contains, will cause the {@link Item} to be selected. */
private Collection<Class<ItemMetadata>> selectionRequirements = Collections.emptyList();
- /** {@link ItemSerializer} used to serialize Items out to log messages. */
- private ItemSerializer<Item<?>> itemSerializer;
+ /** Strategy used to generate {@link Item} identifiers for logging purposes. */
+ private ItemIdentificationStrategy identifierStrategy = new FirstItemIdItemIdentificationStrategy();
/**
* Gets the {@link ItemMetadata} classes that, if the an {@Item} contains, will cause the {@link Item} to be
@@ -72,25 +73,25 @@
}
/**
- * Gets the {@link ItemSerializer} used to serialize Items out to log messages.
+ * Gets the strategy used to generate {@link Item} identifiers for logging purposes.
*
- * @return {@link ItemSerializer} used to serialize Items out to log messages, may be null
+ * @return strategy used to generate {@link Item} identifiers for logging purposes
*/
- public ItemSerializer<Item<?>> getItemSerializer() {
- return itemSerializer;
+ public ItemIdentificationStrategy getItemIdentifierStrategy() {
+ return identifierStrategy;
}
-
+
/**
- * Sets the {@link ItemSerializer} used to serialize Items out to log messages.
+ * Sets the strategy used to generate {@link Item} identifiers for logging purposes.
*
- * @param serializer {@link ItemSerializer} used to serialize Items out to log messages, may be null
+ * @param strategy strategy used to generate {@link Item} identifiers for logging purposes, can not be null
*/
- public synchronized void setItemSerializer(ItemSerializer<Item<?>> serializer) {
+ public synchronized void setIdentifierStrategy(ItemIdentificationStrategy strategy) {
if(isInitialized()){
return;
}
- itemSerializer = serializer;
+ identifierStrategy = Assert.isNotNull(strategy, "Item identification strategy can not be null");
}
/** {@inheritDoc} */
@@ -116,24 +117,6 @@
}
/**
- * Serializes the given item if a {@link ItemSerializer} is available.
- *
- * @param item the item to serialize
- *
- * @return the serialized form of the item, or null if the item or item serializer was null
- */
- protected String serializeItem(Item<?> item) {
- if (item == null || getItemSerializer() == null) {
- return null;
- }
-
- LazyList singletonItem = CollectionSupport.toList(item);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- getItemSerializer().serialize(singletonItem, out);
- return out.toString();
- }
-
- /**
[... 136 lines stripped ...]
More information about the commits
mailing list