com.sap.aii.mapping.api

Class DynamicConfiguration

java.lang.Object
  extended by com.sap.aii.mapping.api.DynamicConfiguration

public abstract class DynamicConfiguration
extends Object

A DynamicConfiguration is a map containing adapter specific message attributes. It associates DynamicConfigurationKeys with string values.
Here is an example of a java mapping that changes the DynamicConfiguration and copies the payload.

  package test.dynamic;
  
  import java.io.*;
  import java.util.*;
  import com.sap.aii.mapping.api.*;
 
  public class DynamicMapping implements StreamTransformation {

  private static final DynamicConfigurationKey KEY_FILENAME =
      DynamicConfigurationKey.create(
          "http://sap.com/xi/XI/System/File", 
          "filename");

  private Map param;
 
  public void setParameter(Map param) {
      this.param = param;
  }

  public void execute(InputStream in, OutputStream out) 
      throws StreamTransformationException {

      // copy payload
      copyPayload(in, out);

      // access dynamic configuration
      DynamicConfiguration conf = (DynamicConfiguration) param.get( 
          StreamTransformationConstants.DYNAMIC_CONFIGURATION);
 
      // read value
      String valueOld = conf.get(KEY_FILENAME);
      if (valueOld == null) {
          throw new StreamTransformationException(
              "Filename is missing. ");
      }
 
      // compute new value
      String valueNew = valueOld.replaceAll("input", "output");
 
      // set new value
      conf.put(KEY_FILENAME, valueNew);
  }

  private void copyPayload(InputStream in, OutputStream out) 
      throws StreamTransformationException { 
         
         int c;
         try {
             c = in.read();
             while (c != -1) {
                 out.write(c);
                 c = in.read();
             }
         } catch (IOException e) {
             throw new StreamTransformationException(e.getMessage());
         }
     }
  }
 

Since:
SAP NetWeaver '04 SPS 14
See Also:
DynamicConfigurationKey

Constructor Summary
DynamicConfiguration()
           
 
Method Summary
abstract  boolean containsKey(DynamicConfigurationKey key)
          Returns true if this map contains an entry for the specified key, and false otherwise.
abstract  String get(DynamicConfigurationKey key)
          Returns the value for the specified key.
abstract  Iterator getKeys()
          Returns an iterator over all keys of this DynamicConfiguration.
abstract  Iterator getKeys(String namespace)
          Returns an iterator over the keys with the specified namespace.
abstract  String put(DynamicConfigurationKey key, String value)
          Associates the specified value with the specified key.
abstract  String remove(DynamicConfigurationKey key)
          Removes the entry for this key if it is present.
abstract  void removeAll()
          Removes all entries from the DynamicConfiguration.
abstract  void removeNamespace(String namespace)
          Removes the entries whose keys have the specified namespace.
abstract  int size()
          Returns the number of entries of this DynamicConfiguration.
abstract  int size(String namespace)
          Returns the number of entries with the specified namespace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicConfiguration

public DynamicConfiguration()
Method Detail

get

public abstract String get(DynamicConfigurationKey key)
Returns the value for the specified key. Returns null if the DynamicConfiguration contains no mapping for this key.

Parameters:
key - key whose associated value is to be returned.
Returns:
the value for specified key, or null if the map contains no mapping for this key.

getKeys

public abstract Iterator getKeys()
Returns an iterator over all keys of this DynamicConfiguration. The objects returned by the iterators next method are instances of DynamicConfigurationKey.

The keys are returned in no particular order. If the DynamicConfiguration is modified while the iteration over its keys is in progress, the results of the iteration is undefined. The Iterator.remove method removes the corresponding entry from the DynamicConfiguration.

Returns:
an iterator over the keys of this DynamicConfiguration.

size

public abstract int size()
Returns the number of entries of this DynamicConfiguration.

Returns:
the number of entries of this DynamicConfiguration.

getKeys

public abstract Iterator getKeys(String namespace)
Returns an iterator over the keys with the specified namespace. The objects returned by the iterators next method are instances of DynamicConfigurationKey.

The keys are returned in no particular order. If the DynamicConfiguration is modified while the iteration over its keys is in progress, the results of the iteration is undefined. The Iterator.remove method removes the corresponding entry from the DynamicConfiguration.

Parameters:
namespace - the namespace
Returns:
an iterator over the keys with the specified namespace.

size

public abstract int size(String namespace)
Returns the number of entries with the specified namespace.

Parameters:
namespace - the namespace
Returns:
the number of entries with the specified namespace.

containsKey

public abstract boolean containsKey(DynamicConfigurationKey key)
Returns true if this map contains an entry for the specified key, and false otherwise.

Parameters:
key - key whose presence in this map is to be tested.
Returns:
true if this map contains an entry for the specified key, and false otherwise.

put

public abstract String put(DynamicConfigurationKey key,
                           String value)
Associates the specified value with the specified key. If the map previously contained a mapping for this key, the old value is replaced by the specified value.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key.
Throws:
IllegalArgumentException - if the key or value is null, or if the value is too long.

remove

public abstract String remove(DynamicConfigurationKey key)
Removes the entry for this key if it is present.

Parameters:
key - key whose mapping is to be removed from the map.
Returns:
previous value associated with the specified key, or null if there was no mapping for this key.

removeNamespace

public abstract void removeNamespace(String namespace)
Removes the entries whose keys have the specified namespace.

Parameters:
namespace - the namespace

removeAll

public abstract void removeAll()
Removes all entries from the DynamicConfiguration.

Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] SAP_XIAF [sap.com] com.sap.aii.mapping.lib.facade api BC-XI


Copyright 2014 SAP AG Complete Copyright Notice