KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > notification > servant > ProxyPushConsumerImpl


1 package org.jacorb.notification.servant;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2004 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import org.apache.avalon.framework.configuration.Configuration;
24 import org.jacorb.notification.MessageFactory;
25 import org.jacorb.notification.OfferManager;
26 import org.jacorb.notification.SubscriptionManager;
27 import org.jacorb.notification.engine.TaskProcessor;
28 import org.jacorb.notification.interfaces.Message;
29 import org.omg.CORBA.Any JavaDoc;
30 import org.omg.CORBA.ORB JavaDoc;
31 import org.omg.CosEventChannelAdmin.AlreadyConnected;
32 import org.omg.CosEventComm.Disconnected;
33 import org.omg.CosEventComm.PushSupplier;
34 import org.omg.CosNotifyChannelAdmin.ProxyConsumerHelper;
35 import org.omg.CosNotifyChannelAdmin.ProxyPushConsumerOperations;
36 import org.omg.CosNotifyChannelAdmin.ProxyPushConsumerPOATie;
37 import org.omg.CosNotifyChannelAdmin.ProxyType;
38 import org.omg.CosNotifyChannelAdmin.SupplierAdmin;
39 import org.omg.PortableServer.POA JavaDoc;
40 import org.omg.PortableServer.Servant JavaDoc;
41
42 /**
43  * @author Alphonse Bendt
44  * @version $Id: ProxyPushConsumerImpl.java,v 1.12 2005/04/27 10:45:46 alphonse.bendt Exp $
45  */

46
47 public class ProxyPushConsumerImpl extends AbstractProxyConsumer implements
48         ProxyPushConsumerOperations
49 {
50     private PushSupplier pushSupplier_;
51
52     ////////////////////////////////////////
53

54     public ProxyPushConsumerImpl(IAdmin admin, ORB JavaDoc orb, POA JavaDoc poa, Configuration conf,
55             TaskProcessor taskProcessor, MessageFactory messageFactory,
56             SupplierAdmin supplierAdmin, OfferManager offerManager,
57             SubscriptionManager subscriptionManager)
58     {
59         super(admin, orb, poa, conf, taskProcessor, messageFactory, supplierAdmin, offerManager,
60                 subscriptionManager);
61     }
62
63     public ProxyType MyType()
64     {
65         return ProxyType.PUSH_ANY;
66     }
67
68     public void disconnect_push_consumer()
69     {
70         destroy();
71     }
72
73     protected void disconnectClient()
74     {
75         if (pushSupplier_ != null)
76         {
77             pushSupplier_.disconnect_push_supplier();
78             pushSupplier_ = null;
79         }
80     }
81
82     /**
83      * Supplier sends data to the consumer (this object) using this call.
84      */

85     public void push(Any JavaDoc event) throws Disconnected
86     {
87         checkStillConnected();
88
89         logger_.debug("push Any into the Channel");
90
91         Message _mesg = getMessageFactory().newMessage(event, this);
92
93         checkMessageProperties(_mesg);
94
95         processMessage(_mesg);
96     }
97
98     public void connect_any_push_supplier(org.omg.CosEventComm.PushSupplier pushSupplier)
99             throws AlreadyConnected
100     {
101         logger_.info("connect any_push_supplier");
102
103         checkIsNotConnected();
104
105         pushSupplier_ = pushSupplier;
106
107         connectClient(pushSupplier);
108     }
109
110     public synchronized Servant JavaDoc getServant()
111     {
112         if (thisServant_ == null)
113         {
114             thisServant_ = new ProxyPushConsumerPOATie(this);
115         }
116
117         return thisServant_;
118     }
119
120     public org.omg.CORBA.Object JavaDoc activate()
121     {
122         return ProxyConsumerHelper.narrow(getServant()._this_object(getORB()));
123     }
124 }
Popular Tags