KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > config > ConnectionInfoConfigItem


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.config;
5
6 import com.tc.config.schema.L2ConfigForL1.L2Data;
7 import com.tc.config.schema.dynamic.ConfigItem;
8 import com.tc.config.schema.dynamic.DerivedConfigItem;
9 import com.tc.net.core.ConnectionInfo;
10 import com.tc.util.Assert;
11 import com.tc.util.stringification.OurStringBuilder;
12
13 /**
14  * Returns a {@link ConnectionInfo} array from the L2 data.
15  */

16 public class ConnectionInfoConfigItem extends DerivedConfigItem {
17   public ConnectionInfoConfigItem(ConfigItem l2DataConfigItem) {
18     super(new ConfigItem[] { l2DataConfigItem });
19   }
20
21   protected Object JavaDoc createValueFrom(ConfigItem[] fromWhich) {
22     Assert.eval(fromWhich.length == 1);
23
24     L2Data[] l2Data = (L2Data[]) fromWhich[0].getObject();
25     ConnectionInfo[] out = new ConnectionInfo[l2Data.length];
26
27     for (int i = 0; i < out.length; ++i) {
28       out[i] = new ConnectionInfo(l2Data[i].host(), l2Data[i].dsoPort());
29     }
30
31     return out;
32   }
33
34   public String JavaDoc toString() {
35     return new OurStringBuilder(this, OurStringBuilder.COMPACT_STYLE).appendSuper(super.toString()).toString();
36   }
37 }
Popular Tags