01: /*
02: * JacORB - a free Java ORB
03: *
04: * Copyright (C) 1999-2004 Gerald Brose
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Library General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Library General Public License for more details.
15: *
16: * You should have received a copy of the GNU Library General Public
17: * License along with this library; if not, write to the Free
18: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19: *
20: */
21: package org.jacorb.orb.etf;
22:
23: import org.apache.avalon.framework.configuration.*;
24:
25: import org.jacorb.orb.CDROutputStream;
26: import org.jacorb.orb.CDRInputStream;
27:
28: import org.omg.ETF.*;
29:
30: /**
31: * @author Phil Mesnier
32: * @version $Id: ProtocolAddressBase.java,v 1.3 2006/07/05 09:18:32 alphonse.bendt Exp $
33: *
34: * provides an abstraction of a protocol specific address.
35: * This is necessary to allow the ORB and other components deal with
36: * addresses generally rather than using protocol specific address elements
37: * such as IIOP-centric host and port values.
38: */
39:
40: public abstract class ProtocolAddressBase implements Cloneable,
41: Configurable {
42: protected org.jacorb.config.Configuration configuration;
43: protected String stringified = null;
44:
45: protected ProtocolAddressBase next = null;
46:
47: public void configure(Configuration configuration)
48: throws ConfigurationException {
49: this .configuration = (org.jacorb.config.Configuration) configuration;
50: }
51:
52: public abstract String toString();
53:
54: public abstract boolean fromString(String s);
55:
56: public abstract void write(CDROutputStream s);
57:
58: public byte[] toCDR() {
59: CDROutputStream out = new CDROutputStream();
60: try {
61: out.beginEncapsulatedArray();
62: this .write(out);
63: return out.getBufferCopy();
64: } finally {
65: out.close();
66: }
67: }
68:
69: // this must be defined for each subclass.
70: // static public <specifictype> read (CDRInputStream s);
71:
72: /**
73: * This function shall return an equivalent, deep-copy of the profile
74: * on the free store.
75: */
76: public ProtocolAddressBase copy() {
77: try {
78: return (ProtocolAddressBase) this .clone();
79: } catch (CloneNotSupportedException e) {
80: throw new RuntimeException("error cloning profile: " + e);
81: }
82: }
83:
84: public ProtocolAddressBase get_next() {
85: return this.next;
86: }
87:
88: }
|