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: */
17: package org.apache.catalina.tribes.transport.bio;
18:
19: import org.apache.catalina.tribes.transport.DataSender;
20: import org.apache.catalina.tribes.transport.PooledSender;
21: import org.apache.catalina.tribes.Member;
22: import org.apache.catalina.tribes.ChannelException;
23: import org.apache.catalina.tribes.transport.MultiPointSender;
24: import org.apache.catalina.tribes.ChannelMessage;
25:
26: /**
27: * <p>Title: </p>
28: *
29: * <p>Description: </p>
30: *
31: * <p>Company: </p>
32: *
33: * @author not attributable
34: * @version 1.0
35: */
36: public class PooledMultiSender extends PooledSender {
37:
38: public PooledMultiSender() {
39: }
40:
41: public void sendMessage(Member[] destination, ChannelMessage msg)
42: throws ChannelException {
43: MultiPointSender sender = null;
44: try {
45: sender = (MultiPointSender) getSender();
46: if (sender == null) {
47: ChannelException cx = new ChannelException(
48: "Unable to retrieve a data sender, time out error.");
49: for (int i = 0; i < destination.length; i++)
50: cx
51: .addFaultyMember(
52: destination[i],
53: new NullPointerException(
54: "Unable to retrieve a sender from the sender pool"));
55: throw cx;
56: } else {
57: sender.sendMessage(destination, msg);
58: }
59: sender.keepalive();
60: } finally {
61: if (sender != null)
62: returnSender(sender);
63: }
64: }
65:
66: /**
67: * getNewDataSender
68: *
69: * @return DataSender
70: * @todo Implement this org.apache.catalina.tribes.transport.PooledSender
71: * method
72: */
73: public DataSender getNewDataSender() {
74: MultipointBioSender sender = new MultipointBioSender();
75: sender.transferProperties(this, sender);
76: return sender;
77: }
78:
79: }
|