Source Code Cross Referenced for COSNotificationService.java in  » Collaboration » JacORB » org » jacorb » notification » jmx » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » JacORB » org.jacorb.notification.jmx 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *        JacORB - a free Java ORB
003:         *
004:         *   Copyright (C) 1999-2004 Gerald Brose
005:         *
006:         *   This library is free software; you can redistribute it and/or
007:         *   modify it under the terms of the GNU Library General Public
008:         *   License as published by the Free Software Foundation; either
009:         *   version 2 of the License, or (at your option) any later version.
010:         *
011:         *   This library is distributed in the hope that it will be useful,
012:         *   but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *   Library General Public License for more details.
015:         *
016:         *   You should have received a copy of the GNU Library General Public
017:         *   License along with this library; if not, write to the Free
018:         *   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
019:         *
020:         */
021:
022:        package org.jacorb.notification.jmx;
023:
024:        import java.io.IOException;
025:        import java.util.Properties;
026:
027:        import javax.management.MBeanServer;
028:
029:        import org.apache.avalon.framework.logger.Logger;
030:        import org.jacorb.notification.AbstractChannelFactory;
031:        import org.jacorb.notification.ConsoleMain;
032:        import org.jacorb.notification.EventChannelFactoryImpl;
033:        import org.jacorb.notification.conf.Attributes;
034:        import org.jacorb.notification.util.LogUtil;
035:        import org.nanocontainer.remoting.jmx.DynamicMBeanProvider;
036:        import org.nanocontainer.remoting.jmx.JMXExposingComponentAdapterFactory;
037:        import org.omg.CORBA.IntHolder;
038:        import org.omg.CORBA.ORB;
039:        import org.omg.CosNotification.Property;
040:        import org.picocontainer.MutablePicoContainer;
041:        import org.picocontainer.defaults.CachingComponentAdapterFactory;
042:        import org.picocontainer.defaults.ComponentAdapterFactory;
043:        import org.picocontainer.defaults.ConstructorInjectionComponentAdapterFactory;
044:        import org.picocontainer.defaults.DefaultPicoContainer;
045:
046:        /**
047:         * @jmx.mbean   name="COSNotificationServiceMBean" 
048:         *              description="Control the JacORB Notification Service"
049:         * 
050:         * @author Alphonse Bendt
051:         * @version $Id: COSNotificationService.java,v 1.4 2005/10/28 10:53:58 alphonse.bendt Exp $
052:         */
053:        public class COSNotificationService implements 
054:                COSNotificationServiceMBean {
055:            private AbstractChannelFactory factory_;
056:
057:            private final MutablePicoContainer container_;
058:
059:            private final static String STARTED = "EventChannelFactory was started";
060:
061:            private final static String RUNNING = "EventChannelFactory is running";
062:
063:            private final static String NOT_RUNNING = "EventChannelFactory is not running";
064:
065:            private final static String STOPPED = "EventChannelFactory was stopped";
066:
067:            private final static String IOR_DEFAULT = "IOR:0";
068:
069:            private final static String CORBALOC_DEFAULT = "<undefined>";
070:
071:            private final Logger logger_ = LogUtil.getLogger(getClass()
072:                    .getName());
073:
074:            private final Properties properties_;
075:
076:            private final ORB optionalORB_;
077:
078:            public COSNotificationService(ORB orb, MBeanServer mbeanServer,
079:                    DynamicMBeanProvider mbeanProvider, String[] args) {
080:                super ();
081:
082:                optionalORB_ = orb;
083:                properties_ = ConsoleMain.parseProperties(args);
084:
085:                DynamicMBeanProvider _decoratedProvider = new UnregisterObjectNameProviderDecorator(
086:                        mbeanServer, mbeanProvider);
087:
088:                ComponentAdapterFactory _defaultCAF = new JMXExposingComponentAdapterFactory(
089:                        new ConstructorInjectionComponentAdapterFactory(),
090:                        mbeanServer,
091:                        new DynamicMBeanProvider[] { _decoratedProvider });
092:
093:                ComponentAdapterFactory _cachingCAF = new CachingComponentAdapterFactory(
094:                        _defaultCAF);
095:
096:                container_ = new DefaultPicoContainer(_cachingCAF);
097:                container_.registerComponentInstance(
098:                        ComponentAdapterFactory.class, _defaultCAF);
099:            }
100:
101:            /**
102:             * @jmx.managed-operation description="create a new channel"
103:             */
104:            public String createChannel() {
105:                try {
106:                    if (factory_ != null) {
107:                        EventChannelFactoryImpl factory = (EventChannelFactoryImpl) factory_;
108:
109:                        IntHolder id = new IntHolder();
110:
111:                        factory.create_channel(new Property[0],
112:                                new Property[0], id);
113:
114:                        return "Created Channel id=" + id.value;
115:                    }
116:
117:                    return NOT_RUNNING;
118:                } catch (Exception e) {
119:                    logger_.error("Error creating Channel", e);
120:
121:                    throw new RuntimeException("Create channel failed: "
122:                            + e.getMessage());
123:                }
124:            }
125:
126:            public String start() {
127:                if (factory_ != null) {
128:                    return RUNNING;
129:                }
130:
131:                try {
132:                    factory_ = AbstractChannelFactory.newFactory(optionalORB_,
133:                            container_, properties_);
134:
135:                    return STARTED;
136:                } catch (Exception e) {
137:                    logger_.error("Error starting Service", e);
138:
139:                    throw new RuntimeException("Start failed: "
140:                            + e.getMessage());
141:                }
142:            }
143:
144:            public String stop() {
145:                if (factory_ != null) {
146:                    factory_.dispose();
147:                    factory_ = null;
148:
149:                    return STOPPED;
150:                }
151:                return NOT_RUNNING;
152:            }
153:
154:            /**
155:             * @jmx.managed-attribute   description="IOR to access the EventChannelFactory" 
156:             *                          access = "read-only"
157:             */
158:            public String getIOR() {
159:                return (factory_ == null) ? IOR_DEFAULT : factory_.getIOR();
160:            }
161:
162:            /**
163:             * @jmx.managed-attribute   description="Corbaloc to access the EventChannelFactory 
164:             *                          access = "read-only"
165:             */
166:            public String getCorbaloc() {
167:                return (factory_ == null) ? CORBALOC_DEFAULT : factory_
168:                        .getCorbaLoc();
169:            }
170:
171:            /**
172:             * @jmx.managed-attribute   description = "Filename the IOR should be written to" 
173:             *                          access = "read-write"
174:             */
175:            public String getIORFile() {
176:                return properties_.getProperty(Attributes.IOR_FILE);
177:            }
178:
179:            /**
180:             * @jmx.managed-attribute
181:             */
182:            public void setIORFile(String filename) throws IOException {
183:                properties_.setProperty(Attributes.IOR_FILE, filename);
184:
185:                if (factory_ != null) {
186:                    factory_.writeIOR(filename);
187:                }
188:            }
189:
190:            /**
191:             * @jmx.managed-attribute   description = "NameService Entry (Optional)" 
192:             *                          access = "read-write"
193:             */
194:            public String getCOSNamingEntry() {
195:                StringBuffer name = new StringBuffer(properties_.getProperty(
196:                        Attributes.REGISTER_NAME_ID, "<undefined>"));
197:
198:                final String nameKind = properties_
199:                        .getProperty(Attributes.REGISTER_NAME_KIND);
200:                if (nameKind != null) {
201:                    name.append('.');
202:                    name.append(nameKind);
203:                }
204:                return name.toString();
205:            }
206:
207:            /**
208:             * @jmx.managed-attribute
209:             */
210:            public void setCOSNamingEntry(String registerName) {
211:                ConsoleMain.addCOSNamingName(properties_, registerName);
212:
213:                if (factory_ != null) {
214:                    try {
215:                        factory_.unregisterName();
216:                        factory_.registerName(properties_);
217:                    } catch (Exception e) {
218:                        logger_.error("Error changing COSNaming entry", e);
219:
220:                        throw new RuntimeException(
221:                                "Changing the COSNaming entry failed: "
222:                                        + e.getMessage());
223:                    }
224:                }
225:            }
226:
227:            public org.omg.CORBA.Object getEventChannelFactory() {
228:                return factory_.activate();
229:            }
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.