KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > queue > PushIncomingHandlerImpl


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: dream@objectweb.org
20  *
21  * Initial developer(s): Vivien Quema
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.queue;
26
27 import java.util.Map JavaDoc;
28
29 import org.objectweb.dream.AbstractComponent;
30 import org.objectweb.dream.InterruptedPushException;
31 import org.objectweb.dream.Push;
32 import org.objectweb.dream.PushException;
33 import org.objectweb.dream.message.Message;
34 import org.objectweb.fractal.api.NoSuchInterfaceException;
35 import org.objectweb.fractal.api.control.IllegalBindingException;
36 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
37
38 /**
39  * Abstract implementation of a Push incoming handler.
40  */

41 public class PushIncomingHandlerImpl extends AbstractComponent implements Push
42 {
43
44   // Client interface
45
protected Buffer bufferItf;
46
47   // ---------------------------------------------------------------------------
48
// Implementation of the Push interface.
49
// ---------------------------------------------------------------------------
50

51   /**
52    * @see org.objectweb.dream.Push#push(org.objectweb.dream.message.Message,
53    * java.util.Map)
54    */

55   public void push(Message message, Map JavaDoc context) throws PushException
56   {
57     try
58     {
59       bufferItf.add(message);
60     }
61     catch (InterruptedException JavaDoc e)
62     {
63       throw new InterruptedPushException("Interrupted while adding a message",
64           e);
65     }
66   }
67
68   // ---------------------------------------------------------------------------
69
// Implementation of the BindingController interface.
70
// ---------------------------------------------------------------------------
71

72   /**
73    * @see org.objectweb.fractal.api.control.BindingController#bindFc(String,
74    * Object)
75    */

76   public synchronized void bindFc(String JavaDoc clientItfName, Object JavaDoc serverItf)
77       throws NoSuchInterfaceException, IllegalBindingException,
78       IllegalLifeCycleException
79   {
80     super.bindFc(clientItfName, serverItf);
81     if (clientItfName.equals(Buffer.ITF_NAME))
82     {
83       bufferItf = (Buffer) serverItf;
84     }
85   }
86
87   /**
88    * @see org.objectweb.fractal.api.control.BindingController#listFc()
89    */

90   public String JavaDoc[] listFc()
91   {
92     return new String JavaDoc[]{Buffer.ITF_NAME};
93   }
94
95 }
Popular Tags