01: package org.jacorb.notification;
02:
03: /*
04: * JacORB - a free Java ORB
05: *
06: * Copyright (C) 1997-2003 Gerald Brose.
07: *
08: * This library is free software; you can redistribute it and/or
09: * 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 java.util.Properties;
24:
25: import org.apache.avalon.framework.configuration.Configuration;
26: import org.apache.avalon.framework.configuration.ConfigurationException;
27: import org.apache.avalon.framework.logger.Logger;
28: import org.jacorb.notification.conf.Attributes;
29:
30: /**
31: * @author Alphonse Bendt
32: * @version $Id: NotifyServer.java,v 1.3 2005/11/11 19:35:45 alphonse.bendt Exp $
33: */
34:
35: public class NotifyServer {
36: private static org.jacorb.config.Configuration configuration = null;
37:
38: private static Logger logger = null;
39:
40: /** the file name int which the IOR will be stored */
41: private static String fileName = null;
42: private static String fileNameTyped = null;
43:
44: private static Properties props = new Properties();
45:
46: public static void configure(Configuration myConfiguration) {
47: configuration = (org.jacorb.config.Configuration) myConfiguration;
48: logger = configuration.getNamedLogger("jacorb.notify");
49:
50: fileName = configuration.getAttribute(
51: "jacorb.notify.ior_filename", "./notify.ior");
52: fileNameTyped = configuration.getAttribute(
53: "jacorb.notifyTyped.ior_filename", "./notify.ior");
54: }
55:
56: public static AbstractChannelFactory newFactory(
57: org.omg.CORBA.ORB orb, org.omg.PortableServer.POA rootPOA)
58: throws Exception {
59: props.put(Attributes.ENABLE_TYPED_CHANNEL, "off");
60: props.put(Attributes.IOR_FILE, fileName);
61: props.put(Attributes.START_CHANNELS, "1");
62:
63: return AbstractChannelFactory.newFactory(orb, null, props);
64: }
65:
66: public static AbstractChannelFactory createInstance(
67: org.omg.CORBA.ORB orb, org.omg.PortableServer.POA rootPOA)
68: throws Exception {
69: AbstractChannelFactory factory = null;
70:
71: try {
72:
73: Configuration config = ((org.jacorb.orb.ORB) orb)
74: .getConfiguration();
75:
76: /* configure the name service using the ORB configuration */
77: configure(config);
78:
79: factory = newFactory(orb, rootPOA);
80: } catch (ConfigurationException e) {
81: e.printStackTrace();
82: } catch (Exception e) {
83: e.printStackTrace();
84: System.exit(1);
85: }
86:
87: return factory;
88: }
89: }
|