KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jacorb.notification.servant;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1999-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
24 import org.apache.avalon.framework.configuration.Configuration;
25 import org.jacorb.notification.MessageFactory;
26 import org.jacorb.notification.OfferManager;
27 import org.jacorb.notification.SubscriptionManager;
28 import org.jacorb.notification.engine.TaskProcessor;
29 import org.jacorb.notification.interfaces.Message;
30 import org.omg.CORBA.ORB JavaDoc;
31 import org.omg.CosEventChannelAdmin.AlreadyConnected;
32 import org.omg.CosEventComm.Disconnected;
33 import org.omg.CosNotification.StructuredEvent;
34 import org.omg.CosNotifyChannelAdmin.ProxyConsumerHelper;
35 import org.omg.CosNotifyChannelAdmin.ProxyType;
36 import org.omg.CosNotifyChannelAdmin.StructuredProxyPushConsumerOperations;
37 import org.omg.CosNotifyChannelAdmin.StructuredProxyPushConsumerPOATie;
38 import org.omg.CosNotifyChannelAdmin.SupplierAdmin;
39 import org.omg.CosNotifyComm.StructuredPushSupplier;
40 import org.omg.PortableServer.POA JavaDoc;
41 import org.omg.PortableServer.Servant JavaDoc;
42
43 /**
44  * @author Alphonse Bendt
45  * @version $Id: StructuredProxyPushConsumerImpl.java,v 1.12 2005/04/27 10:45:46 alphonse.bendt Exp $
46  */

47
48 public class StructuredProxyPushConsumerImpl extends AbstractProxyConsumer implements
49         StructuredProxyPushConsumerOperations
50 {
51     private StructuredPushSupplier pushSupplier_;
52
53     ////////////////////////////////////////
54

55     public StructuredProxyPushConsumerImpl(IAdmin admin, ORB JavaDoc orb, POA JavaDoc poa, Configuration conf,
56             TaskProcessor taskProcessor, MessageFactory mf, SupplierAdmin supplierAdmin,
57             OfferManager offerManager, SubscriptionManager subscriptionManager)
58     {
59         super(admin, orb, poa, conf, taskProcessor, mf, supplierAdmin, offerManager, subscriptionManager);
60     }
61
62     public ProxyType MyType()
63     {
64         return ProxyType.PUSH_STRUCTURED;
65     }
66
67     public void push_structured_event(StructuredEvent structuredEvent) throws Disconnected
68     {
69         checkStillConnected();
70         Message _mesg = getMessageFactory().newMessage(structuredEvent, this);
71
72         checkMessageProperties(_mesg);
73         processMessage(_mesg);
74     }
75
76     public void disconnect_structured_push_consumer()
77     {
78         destroy();
79     }
80
81     protected void disconnectClient()
82     {
83         logger_.info("disconnect structured_push_supplier");
84
85         pushSupplier_.disconnect_structured_push_supplier();
86
87         pushSupplier_ = null;
88     }
89
90     public void connect_structured_push_supplier(StructuredPushSupplier supplier)
91             throws AlreadyConnected
92     {
93         checkIsNotConnected();
94
95         connectClient(supplier);
96
97         pushSupplier_ = supplier;
98
99         logger_.info("connect structured_push_supplier");
100     }
101
102     public synchronized Servant JavaDoc getServant()
103     {
104         if (thisServant_ == null)
105         {
106             thisServant_ = new StructuredProxyPushConsumerPOATie(this);
107         }
108         return thisServant_;
109     }
110
111     public org.omg.CORBA.Object JavaDoc activate()
112     {
113         return ProxyConsumerHelper.narrow(getServant()._this_object(getORB()));
114     }
115 }
Popular Tags