KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > notification > TypedEventChannelFactoryImpl


1 package org.jacorb.notification;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2003 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.ConfigurationException;
24 import org.jacorb.notification.container.CORBAObjectComponentAdapter;
25 import org.jacorb.notification.servant.ITypedEventChannel;
26 import org.omg.CORBA.IntHolder JavaDoc;
27 import org.omg.CORBA.ORB JavaDoc;
28 import org.omg.CORBA.UserException JavaDoc;
29 import org.omg.CosNotification.Property;
30 import org.omg.CosNotification.UnsupportedAdmin;
31 import org.omg.CosNotification.UnsupportedQoS;
32 import org.omg.CosNotifyChannelAdmin.ChannelNotFound;
33 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannel;
34 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannelFactory;
35 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannelFactoryHelper;
36 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannelFactoryOperations;
37 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannelFactoryPOATie;
38 import org.omg.CosTypedNotifyChannelAdmin.TypedEventChannelHelper;
39 import org.omg.PortableServer.Servant JavaDoc;
40 import org.picocontainer.ComponentAdapter;
41 import org.picocontainer.MutablePicoContainer;
42 import org.picocontainer.PicoContainer;
43 import org.picocontainer.defaults.CachingComponentAdapter;
44
45 /**
46  * @author Alphonse Bendt
47  * @version $Id: TypedEventChannelFactoryImpl.java,v 1.8 2005/05/04 13:58:47 alphonse.bendt Exp $
48  */

49
50 public class TypedEventChannelFactoryImpl extends AbstractChannelFactory implements
51         TypedEventChannelFactoryOperations
52 {
53     public TypedEventChannelFactoryImpl(PicoContainer container, ORB JavaDoc orb) throws UserException JavaDoc
54     {
55         super(container, orb);
56
57         container_.registerComponent(new CORBAObjectComponentAdapter(
58                 TypedEventChannelFactory.class, TypedEventChannelFactoryHelper.narrow(thisRef_)));
59     }
60
61     public TypedEventChannel create_typed_channel(Property[] qosProps, Property[] adminProps,
62             IntHolder JavaDoc intHolder) throws UnsupportedAdmin, UnsupportedQoS
63     {
64         try
65         {
66             AbstractEventChannel _channel = create_channel_servant(intHolder, qosProps, adminProps);
67
68             addToChannels(intHolder.value, _channel);
69
70             return TypedEventChannelHelper.narrow(_channel.activate());
71         } catch (ConfigurationException e)
72         {
73             logger_.fatalError("error creating typed channel", e);
74
75             throw new org.omg.CORBA.INTERNAL JavaDoc();
76         }
77     }
78
79     protected AbstractEventChannel newEventChannel()
80     {
81         final MutablePicoContainer _container = newContainerForChannel();
82
83         ComponentAdapter typedChannelComponentAdapter = componentAdapterFactory_
84                 .createComponentAdapter(ITypedEventChannel.class, TypedEventChannelImpl.class, null);
85
86         _container.registerComponent(new CachingComponentAdapter(typedChannelComponentAdapter));
87
88         return (AbstractEventChannel) _container.getComponentInstance(ITypedEventChannel.class);
89     }
90
91     public int[] get_all_typed_channels()
92     {
93         return getAllChannels();
94     }
95
96     public TypedEventChannel get_typed_event_channel(int id) throws ChannelNotFound
97     {
98         return TypedEventChannelHelper.narrow(get_event_channel_servant(id));
99     }
100
101     public Servant JavaDoc getServant()
102     {
103         return new TypedEventChannelFactoryPOATie(this);
104     }
105
106     public String JavaDoc getObjectName()
107     {
108         return "_ECFactory";
109     }
110
111     protected String JavaDoc getShortcut()
112     {
113         return "NotificationService";
114     }
115
116     protected org.omg.CORBA.Object JavaDoc create_abstract_channel(Property[] admin, Property[] qos,
117             IntHolder JavaDoc id) throws UnsupportedQoS, UnsupportedAdmin
118     {
119         return create_typed_channel(admin, qos, id);
120     }
121 }
Popular Tags