01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.openejb.client;
17:
18: import java.io.Externalizable;
19: import java.io.ObjectInput;
20: import java.io.IOException;
21: import java.io.ObjectOutput;
22: import java.util.List;
23: import java.util.ArrayList;
24:
25: /**
26: * @version $Rev: 607077 $ $Date: 2007-12-27 06:55:23 -0800 $
27: */
28: public class InjectionMetaData implements Externalizable {
29:
30: private final List<Injection> injections = new ArrayList<Injection>();
31:
32: public List<Injection> getInjections() {
33: return injections;
34: }
35:
36: public void addInjection(String target, String name, String jndiName) {
37: injections.add(new Injection(target, name, jndiName));
38: }
39:
40: public void readExternal(ObjectInput in) throws IOException,
41: ClassNotFoundException {
42: byte version = in.readByte(); // future use
43:
44: int size = in.readInt();
45: for (int i = 0; i < size; i++) {
46: String jndiName = (String) in.readObject();
47: String name = (String) in.readObject();
48: String target = (String) in.readObject();
49: addInjection(target, name, jndiName);
50: }
51: }
52:
53: public void writeExternal(ObjectOutput out) throws IOException {
54: // write out the version of the serialized data for future use
55: out.writeByte(1);
56:
57: out.writeInt(injections.size());
58: for (Injection injection : injections) {
59: out.writeObject(injection.getJndiName());
60: out.writeObject(injection.getName());
61: out.writeObject(injection.getTargetClass());
62: }
63: }
64:
65: }
|