Source Code Cross Referenced for MonologFactoryProxyImpl.java in  » Development » Monolog » org » objectweb » util » monolog » wrapper » remote » lib » 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 » Development » Monolog » org.objectweb.util.monolog.wrapper.remote.lib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (C) 2001-2005 France Telecom R&D
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */package org.objectweb.util.monolog.wrapper.remote.lib;
018:
019:        import org.objectweb.util.monolog.Monolog;
020:        import org.objectweb.util.monolog.api.Handler;
021:        import org.objectweb.util.monolog.api.Level;
022:        import org.objectweb.util.monolog.api.Logger;
023:        import org.objectweb.util.monolog.api.MonologFactory;
024:        import org.objectweb.util.monolog.api.TopicalLogger;
025:        import org.objectweb.util.monolog.file.monolog.PropertiesConfAccess;
026:        import org.objectweb.util.monolog.wrapper.remote.api.LoggerInfo;
027:        import org.objectweb.util.monolog.wrapper.remote.api.MonologFactoryProxy;
028:
029:        import java.net.MalformedURLException;
030:        import java.net.UnknownHostException;
031:        import java.rmi.Naming;
032:        import java.rmi.RemoteException;
033:        import java.rmi.server.UnicastRemoteObject;
034:        import java.util.HashMap;
035:        import java.util.Map;
036:        import java.util.Properties;
037:
038:        /**
039:         * This class implements the MonologFactoryProxy interface as remote object. It
040:         * permits to configure loggers, handlers and levels on a monolog factory
041:         * 
042:         * @author S.Chassande-Barrioz
043:         */
044:        public class MonologFactoryProxyImpl extends UnicastRemoteObject
045:                implements  MonologFactoryProxy {
046:
047:            private MonologFactory mf;
048:
049:            /**
050:             * Build a remote object managing the default MonologFactory registered
051:             * as current int the Monolog class.
052:             */
053:            public MonologFactoryProxyImpl() throws RemoteException {
054:                this (Monolog.initialize());
055:            }
056:
057:            /**
058:             * Build a remote object managing a MonologFactory.
059:             * @param mf is the monolog factory instance encapsulated into this remote 
060:             * object.
061:             */
062:            public MonologFactoryProxyImpl(MonologFactory mf)
063:                    throws RemoteException {
064:                super ();
065:                this .mf = mf;
066:            }
067:
068:            /**
069:             * Build a remote object managing a MonologFactory. This object is registerd
070:             * into the RMI registry of the current host.
071:             * @param mf is the monolog factory instance encapsulated into this remote 
072:             * object.
073:             * @param rmiName is the name under which this remote object will be 
074:             * registered
075:             */
076:            public MonologFactoryProxyImpl(MonologFactory mf, String rmiName)
077:                    throws RemoteException {
078:                super ();
079:                this .mf = mf;
080:                register(rmiName);
081:            }
082:
083:            /**
084:             * Register this object into the RMI registry of the current host.
085:             * @param name is the name under which this remote object will be 
086:             * registered 
087:             * @throws RemoteException
088:             */
089:            public void register(String name) throws RemoteException {
090:                try {
091:                    register(java.net.InetAddress.getLocalHost(), name);
092:                } catch (UnknownHostException e) {
093:                    throw new RemoteException(e.getMessage());
094:                }
095:            }
096:
097:            /**
098:             * Register this object into a RMI registry.
099:             * @param name is the name under which this remote object will be 
100:             * registered
101:             * @param host is the name of the host containing the RMI registry where
102:             * this object has to be registered. 
103:             * @throws RemoteException
104:             */
105:            public void register(java.net.InetAddress host, String name)
106:                    throws RemoteException {
107:                try {
108:                    Naming.rebind("rmi://" + host + "/" + name, this );
109:                } catch (MalformedURLException e) {
110:                    throw new RemoteException(e.getMessage());
111:                }
112:            }
113:
114:            public boolean defineLevel(String name, int value)
115:                    throws RemoteException {
116:                return mf.defineLevel(name, value) != null;
117:            }
118:
119:            public boolean defineLevel(String name, String value)
120:                    throws RemoteException {
121:                return mf.defineLevel(name, value) != null;
122:            }
123:
124:            public void removeLevel(String name) throws RemoteException {
125:                mf.removeLevel(name);
126:            }
127:
128:            public Level getLevel(String name) throws RemoteException {
129:                return mf.getLevel(name);
130:            }
131:
132:            public Level getLevel(int value) throws RemoteException {
133:                return mf.getLevel(value);
134:            }
135:
136:            public Level[] getLevels() throws RemoteException {
137:                return mf.getLevels();
138:            }
139:
140:            public int compareTo(String levelname1, String levelname2)
141:                    throws RemoteException {
142:                Level l1 = mf.getLevel(levelname1);
143:                if (l1 == null) {
144:                    return Integer.MAX_VALUE;
145:                }
146:                Level l2 = mf.getLevel(levelname2);
147:                if (l1 == null) {
148:                    return Integer.MIN_VALUE;
149:                }
150:                return l1.compareTo(l2);
151:            }
152:
153:            public boolean createHandler(String hn, String handlertype)
154:                    throws RemoteException {
155:                return mf.createHandler(hn, handlertype) != null;
156:            }
157:
158:            public boolean removeHandler(String handlername)
159:                    throws RemoteException {
160:                return mf.removeHandler(handlername) == null;
161:            }
162:
163:            public String[] getHandlerNames() throws RemoteException {
164:                Handler[] hs = mf.getHandlers();
165:                String[] hns = new String[hs.length];
166:                for (int i = 0; i < hs.length; i++) {
167:                    hns[i] = hs[i].getName();
168:                }
169:                return hns;
170:            }
171:
172:            public Map getHandlerAttributes(String handlername)
173:                    throws RemoteException {
174:                Handler h = mf.getHandler(handlername);
175:                String[] ans = h.getAttributeNames();
176:                Map m = new HashMap(ans.length);
177:                for (int i = 0; i < ans.length; i++) {
178:                    m.put(ans[i], h.getAttribute(ans[i]));
179:                }
180:                return m;
181:            }
182:
183:            public Map getAllHandlerAttributes() throws RemoteException {
184:                Handler[] hs = mf.getHandlers();
185:                Map m = new HashMap(hs.length);
186:                for (int i = 0; i < hs.length; i++) {
187:                    m.put(hs[i], getHandlerAttributes(hs[i].getName()));
188:                }
189:                return m;
190:            }
191:
192:            public void setHandlerAttribute(String handlername,
193:                    String attributeName, String value) throws RemoteException {
194:                Handler h = mf.getHandler(handlername);
195:                if (h == null) {
196:                    throw new RemoteException("No handler '" + handlername
197:                            + "' found.");
198:                }
199:                h.setAttribute(attributeName, value);
200:            }
201:
202:            public LoggerInfo getLogger(String loggername)
203:                    throws RemoteException {
204:                return new LoggerInfo((TopicalLogger) mf.getLogger(loggername));
205:            }
206:
207:            public LoggerInfo getLogger(String loggername,
208:                    String resourceBundleName) throws RemoteException {
209:                return new LoggerInfo((TopicalLogger) mf.getLogger(loggername,
210:                        resourceBundleName));
211:            }
212:
213:            public String getResourceBundleName() throws RemoteException {
214:                return mf.getResourceBundleName();
215:            }
216:
217:            public void setResourceBundleName(String resourceBundleName)
218:                    throws RemoteException {
219:                mf.setResourceBundleName(resourceBundleName);
220:            }
221:
222:            public LoggerInfo[] getLoggers() throws RemoteException {
223:                Logger[] ls = mf.getLoggers();
224:                LoggerInfo[] lis = new LoggerInfo[ls.length];
225:                for (int i = 0; i < ls.length; i++) {
226:                    lis[i] = new LoggerInfo((TopicalLogger) ls[i]);
227:                }
228:                return lis;
229:            }
230:
231:            public void addHandlerToLogger(String handlername, String loggerName)
232:                    throws RemoteException {
233:                Handler h = mf.getHandler(handlername);
234:                if (h == null) {
235:                    throw new RemoteException("No handler '" + handlername
236:                            + "' found.");
237:                }
238:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
239:                try {
240:                    l.addHandler(h);
241:                } catch (Exception e) {
242:                    throw new RemoteException(e.getMessage());
243:                }
244:            }
245:
246:            public void removeHandlerFromLogger(String handlerName,
247:                    String loggerName) throws RemoteException {
248:                Handler h = mf.getHandler(handlerName);
249:                if (h == null) {
250:                    return;
251:                }
252:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
253:                try {
254:                    l.removeHandler(h);
255:                } catch (Exception e) {
256:                    throw new RemoteException(e.getMessage());
257:                }
258:            }
259:
260:            public void removeAllHandlersFromLogger(String loggerName)
261:                    throws RemoteException {
262:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
263:                try {
264:                    l.removeAllHandlers();
265:                } catch (Exception e) {
266:                    throw new RemoteException(e.getMessage());
267:                }
268:            }
269:
270:            public void setAdditivity(boolean a, String loggerName)
271:                    throws RemoteException {
272:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
273:                l.setAdditivity(a);
274:            }
275:
276:            public void setLoggerLevel(int level, String loggerName)
277:                    throws RemoteException {
278:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
279:                l.setIntLevel(level);
280:            }
281:
282:            public void setLoggerLevel(String levelName, String loggerName)
283:                    throws RemoteException {
284:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
285:                Level level = mf.getLevel(levelName);
286:                if (level != null) {
287:                    l.setLevel(level);
288:                }
289:            }
290:
291:            public void addTopicToLogger(String topic, String loggerName)
292:                    throws RemoteException {
293:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
294:                try {
295:                    l.addTopic(topic);
296:                } catch (Exception e) {
297:                    throw new RemoteException(e.getMessage());
298:                }
299:            }
300:
301:            public void removeTopicFromLogger(String topic, String loggerName)
302:                    throws RemoteException {
303:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
304:                try {
305:                    l.removeTopic(topic);
306:                } catch (Exception e) {
307:                    throw new RemoteException(e.getMessage());
308:                }
309:            }
310:
311:            public Properties getMonologProperties() throws RemoteException {
312:                Properties p = new Properties();
313:                try {
314:                    PropertiesConfAccess.store(p, mf);
315:                } catch (Exception e) {
316:                    throw new RemoteException(e.getMessage());
317:                }
318:                return p;
319:            }
320:
321:            public void setMonologProperties(Properties p)
322:                    throws RemoteException {
323:                try {
324:                    PropertiesConfAccess.load(p, mf);
325:                } catch (Exception e) {
326:                    throw new RemoteException(e.getMessage());
327:                }
328:            }
329:
330:        }
w___w__w_._j_a___v__a_2___s___._co__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.