com.sap.aii.mapping.api

Class DynamicConfiguration

java.lang.Object
  extended bycom.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.



Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.