001: package org.jacorb.notification.servant;
002:
003: /*
004: * JacORB - a free Java ORB
005: *
006: * Copyright (C) 1997-2004 Gerald Brose.
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Library General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Library General Public License for more details.
017: *
018: * You should have received a copy of the GNU Library General Public
019: * License along with this library; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: */
022:
023: import org.apache.avalon.framework.configuration.Configuration;
024: import org.jacorb.notification.MessageFactory;
025: import org.jacorb.notification.OfferManager;
026: import org.jacorb.notification.SubscriptionManager;
027: import org.jacorb.notification.engine.TaskProcessor;
028: import org.jacorb.notification.interfaces.Message;
029: import org.omg.CORBA.Any;
030: import org.omg.CORBA.ORB;
031: import org.omg.CosEventChannelAdmin.AlreadyConnected;
032: import org.omg.CosEventComm.Disconnected;
033: import org.omg.CosEventComm.PushSupplier;
034: import org.omg.CosNotifyChannelAdmin.ProxyPushConsumerOperations;
035: import org.omg.CosNotifyChannelAdmin.ProxyPushConsumerPOATie;
036: import org.omg.CosNotifyChannelAdmin.ProxyType;
037: import org.omg.CosNotifyChannelAdmin.SupplierAdmin;
038: import org.omg.PortableServer.POA;
039: import org.omg.PortableServer.Servant;
040:
041: /**
042: * @jmx.mbean extends = "AbstractProxyConsumerMBean"
043: * @jboss.xmbean
044: *
045: * @author Alphonse Bendt
046: * @version $Id: ProxyPushConsumerImpl.java,v 1.15 2006/01/12 22:34:54 alphonse.bendt Exp $
047: */
048:
049: public class ProxyPushConsumerImpl extends AbstractProxyConsumer
050: implements ProxyPushConsumerOperations,
051: ProxyPushConsumerImplMBean {
052: private PushSupplier pushSupplier_;
053:
054: ////////////////////////////////////////
055:
056: public ProxyPushConsumerImpl(IAdmin admin, ORB orb, POA poa,
057: Configuration conf, TaskProcessor taskProcessor,
058: MessageFactory messageFactory, SupplierAdmin supplierAdmin,
059: OfferManager offerManager,
060: SubscriptionManager subscriptionManager) {
061: super (admin, orb, poa, conf, taskProcessor, messageFactory,
062: supplierAdmin, offerManager, subscriptionManager);
063: }
064:
065: public ProxyType MyType() {
066: return ProxyType.PUSH_ANY;
067: }
068:
069: public void disconnect_push_consumer() {
070: destroy();
071: }
072:
073: protected void disconnectClient() {
074: if (pushSupplier_ != null) {
075: pushSupplier_.disconnect_push_supplier();
076: pushSupplier_ = null;
077: }
078: }
079:
080: /**
081: * Supplier sends data to the consumer (this object) using this call.
082: */
083: public void push(Any event) throws Disconnected {
084: checkStillConnected();
085:
086: logger_.debug("push Any into the Channel");
087:
088: Message _mesg = getMessageFactory().newMessage(event, this );
089:
090: checkMessageProperties(_mesg);
091:
092: processMessage(_mesg);
093: }
094:
095: public void connect_any_push_supplier(
096: org.omg.CosEventComm.PushSupplier pushSupplier)
097: throws AlreadyConnected {
098: logger_.info("connect any_push_supplier");
099:
100: checkIsNotConnected();
101:
102: pushSupplier_ = pushSupplier;
103:
104: connectClient(pushSupplier);
105: }
106:
107: public Servant newServant() {
108: return new ProxyPushConsumerPOATie(this);
109: }
110: }
|