View Javadoc

1   package org.jscsi.target.settings;
2   
3   
4   import java.util.Collection;
5   
6   import javax.naming.OperationNotSupportedException;
7   
8   import org.jscsi.target.settings.entry.Entry;
9   
10  
11  /**
12   * Instances of {@link ConnectionSettingsBuilderComponent} are used jointly with instances of
13   * {@link SessionSettingsBuilderComponent} for creating {@link Settings} objects.
14   * <p>
15   * {@link ConnectionSettingsBuilderComponent} objects provide all connection-specific parameters managed by the
16   * connection's {@link ConnectionSettingsNegotiator}.
17   * 
18   * @see Settings#Settings(ConnectionSettingsBuilderComponent, SessionSettingsBuilderComponent)
19   * @author Andreas Ergenzinger
20   */
21  final class ConnectionSettingsBuilderComponent {
22  
23      /**
24       * The <code>TargetName</code> parameter.
25       */
26      String targetName;
27  
28      /**
29       * The <code>DataDigest</code> parameter.
30       */
31      String dataDigest;
32  
33      /**
34       * The <code>HeaderDigest</code> parameter.
35       */
36      String headerDigest;
37  
38      /**
39       * The <code>IFMarker</code> parameter.
40       */
41      Boolean ifMarker;
42  
43      /**
44       * The <code>IFMarkInt</code> parameter.
45       */
46      Integer ifMarkInt;
47  
48      /**
49       * The <code>MaxRecvDataSegmentLength</code> parameter.
50       */
51      Integer maxRecvDataSegmentLength;
52  
53      /**
54       * The <code>OFMarker</code> parameter.
55       */
56      Boolean ofMarker;
57  
58      /**
59       * The <code>OFMarkInt</code> parameter.
60       */
61      Integer ofMarkInt;
62  
63      /**
64       * The {@link ConnectionSettingsBuilderComponent} constructor. The passed {@link Collection} must contain all
65       * connection-specific {@link Entry} objects, since the constructor will try to locate a specific {@link Entry} for
66       * each member variable and copy its current value.
67       * 
68       * @param entries a {@link Collection} containing all connection-specific {@link Entry} objects
69       */
70      ConnectionSettingsBuilderComponent (final Collection<Entry> entries) {
71          try {
72              targetName = SettingsNegotiator.getEntry(TextKeyword.TARGET_NAME, entries).getStringValue();
73              dataDigest = SettingsNegotiator.getEntry(TextKeyword.DATA_DIGEST, entries).getStringValue();
74              headerDigest = SettingsNegotiator.getEntry(TextKeyword.HEADER_DIGEST, entries).getStringValue();
75              ifMarker = SettingsNegotiator.getEntry(TextKeyword.IF_MARKER, entries).getBooleanValue();
76              ifMarkInt = SettingsNegotiator.getEntry(TextKeyword.IF_MARK_INT, entries).getIntegerValue();
77              maxRecvDataSegmentLength = SettingsNegotiator.getEntry(TextKeyword.MAX_RECV_DATA_SEGMENT_LENGTH, entries).getIntegerValue();
78              ofMarker = SettingsNegotiator.getEntry(TextKeyword.OF_MARKER, entries).getBooleanValue();
79              ofMarkInt = SettingsNegotiator.getEntry(TextKeyword.OF_MARK_INT, entries).getIntegerValue();
80          } catch (OperationNotSupportedException e) {
81              e.printStackTrace();
82          }
83      }
84  }