KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > core > util > byteable > ByteableRegistry


1 /*
2  * Copyright 2002 by
3  * <a HREF="http://www.coridan.com">Coridan</a>
4  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is "MantaRay" (TM).
17  *
18  * The Initial Developer of the Original Code is Amir Shevat.
19  * Portions created by the Initial Developer are Copyright (C) 2006
20  * Coridan Inc. All Rights Reserved.
21  *
22  * Contributor(s): all the names of the contributors are added in the source
23  * code where applicable.
24  *
25  * Alternatively, the contents of this file may be used under the terms of the
26  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
27  * provisions of LGPL are applicable instead of those above. If you wish to
28  * allow use of your version of this file only under the terms of the LGPL
29  * License and not to allow others to use your version of this file under
30  * the MPL, indicate your decision by deleting the provisions above and
31  * replace them with the notice and other provisions required by the LGPL.
32  * If you do not delete the provisions above, a recipient may use your version
33  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
34  
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Lesser General Public License as published by the Free Software Foundation;
39  * either version 2.1 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
44  * License for more details.
45  */

46 /*
47  * Created on Feb 12, 2004
48  * Manta LTD
49  */

50 package org.mr.core.util.byteable;
51
52 import java.util.HashMap JavaDoc;
53
54 import javax.jms.JMSException JavaDoc;
55
56 import org.apache.commons.logging.Log;
57 import org.apache.commons.logging.LogFactory;
58 import org.mr.api.jms.MantaFileMessage;
59 import org.mr.api.jms.MantaXADescriptor;
60 import org.mr.core.net.SimpleMantaAddress;
61 import org.mr.core.net.TransportInfo;
62 import org.mr.core.protocol.DeadEndRecipient;
63 import org.mr.indexing.messages.AgentRoleChanged;
64 import org.mr.indexing.messages.AgentTransportsChanged;
65 import org.mr.indexing.messages.ServiceParticipationChanged;
66 import org.mr.kernel.services.ServiceActorInfoContainer;
67 import org.mr.kernel.services.queues.QueueMaster;
68
69 /**
70  * ByteableRegistry: all byteable objects need to register to this registry on system load
71  * in order for the input/output streams to be able to transfer these object to
72  * a file or network
73  * @since Feb 12, 2004
74  * @version 1.0
75  * @author Amir Shevat
76  *
77  *
78  */

79 public class ByteableRegistry {
80     
81     private static HashMap JavaDoc byteableMap = new HashMap JavaDoc();
82     
83     public static final String JavaDoc NULL_NAME = "n";
84     
85     /**
86      * adds a byteable object factory to the registry
87      * @param byteableName the name written by the output and read by the input
88      * @param factory the class that know how to create this object
89      */

90     public static void registerByteableFactory(String JavaDoc byteableName , Byteable factory){
91         byteableMap.put(byteableName ,factory );
92     }
93     /**
94      * called by the input in order to get the factory of a byteable
95      * @param byteableName the name written by the output and read by the input
96      * @return a factory byteable object
97      */

98     protected static Byteable getByteableFactory(String JavaDoc byteableName){
99         return (Byteable)byteableMap.get(byteableName);
100     }
101     
102     /**
103      * toString look alike
104      * @return
105      */

106     public static String JavaDoc desc(){
107         return byteableMap.toString();
108     }
109     
110     
111     public static void init(){
112         Log log=LogFactory.getLog("ByteableRegistry");
113         //registerJMXBeans();//added by lital
114
DeadEndRecipient.register();
115         org.mr.kernel.services.ServiceProducer.register();
116         org.mr.kernel.services.ServiceConsumer.register();
117         org.mr.kernel.control.ControlSignal.register();
118         org.mr.core.protocol.MantaBusMessage.register();
119         org.mr.core.util.byteable.ByteableText.register();
120         org.mr.core.util.byteable.ByteableMap.register();
121         org.mr.core.util.byteable.ByteableList.register();
122         org.mr.core.util.byteable.ByteableMapEntry.register();
123         org.mr.core.cmc.CMCResponse.register();
124         org.mr.core.cmc.CMCRequest.register();
125         org.mr.core.stats.cmc.CMCAgentStats.register();
126         org.mr.core.net.Link.register();
127         ByteableSerializable.register();
128         TransportInfo.register();
129         SimpleMantaAddress.register();
130         ByteableByteArray.register();
131         ServiceActorInfoContainer.register();
132         QueueMaster.register();
133         AgentRoleChanged.register();
134         ServiceParticipationChanged.register();
135         AgentTransportsChanged.register();
136         MantaXADescriptor.register();
137         try {
138             org.mr.api.jms.MantaMessage.register();
139         }
140         catch (JMSException JavaDoc e) {
141             if(log.isErrorEnabled())
142                 log.error("MantRay init() had an Exception ",e);
143         }
144         try{
145             org.mr.api.jms.MantaTextMessage.register();
146         }
147         catch (JMSException JavaDoc e) {
148             if(log.isErrorEnabled())
149                 log.error("MantRay init() had an Exception ",e);
150         }
151     
152         try {
153             org.mr.api.jms.MantaBytesMessage.register();
154         }
155         catch (JMSException JavaDoc e1) {
156             if(log.isErrorEnabled())
157                 log.error("init had an Exception ",e1); }
158         try {
159             org.mr.api.jms.MantaStreamMessage.register();
160         }
161         catch (JMSException JavaDoc e2) {
162             if(log.isErrorEnabled())
163                 log.error("MantRay init() had an Exception ",e2); }
164         try {
165             org.mr.api.jms.MantaMapMessage.register();
166         }
167         catch (JMSException JavaDoc e3) {
168             if(log.isErrorEnabled())
169                 log.error("MantRay init() had an Exception ",e3); }
170         try {
171             org.mr.api.jms.MantaDestination.register();
172         }
173         catch (JMSException JavaDoc e4) {
174             if(log.isErrorEnabled())
175                 log.error("MantRay init() had an Exception ",e4);
176         }
177         try {
178             org.mr.api.jms.MantaTemporaryTopic.register();
179         }
180         catch (JMSException JavaDoc e5) {
181             if(log.isErrorEnabled())
182                 log.error("MantRay init() had an Exception ",e5);
183         }
184         try {
185             org.mr.api.jms.MantaTemporaryQueue.register();
186         }
187         catch (JMSException JavaDoc e6) {
188             if(log.isErrorEnabled())
189                 log.error("MantRay init() had an Exception ",e6);
190         }
191         try {
192             org.mr.api.jms.MantaStreamMessage.register();
193         }
194         catch (JMSException JavaDoc e7) {
195             if(log.isErrorEnabled())
196                 log.error("MantRay init() had an Exception ",e7);
197         }
198         try {
199             org.mr.api.jms.MantaObjectMessage.register();
200         }
201         catch (JMSException JavaDoc e8) {
202             if(log.isErrorEnabled())
203                 log.error("MantRay init() had an Exception ",e8);
204         }
205         try {
206             org.mr.api.jms.MantaQueue.register();
207         }
208         catch (JMSException JavaDoc e9) {
209             if(log.isErrorEnabled())
210                 log.error("MantRay init() had an Exception ",e9);
211         }
212         try {
213             org.mr.api.jms.MantaTopic.register();
214         }
215         catch (JMSException JavaDoc eA) {
216             if(log.isErrorEnabled())
217                 log.error("MantRay init() had an Exception ",eA);
218         }
219         try {
220             MantaFileMessage.register();
221         }
222         catch (JMSException JavaDoc eA) {
223             if(log.isErrorEnabled())
224                 log.error("MantRay init() had an Exception ",eA);
225         }
226     }
227
228 }
229
Popular Tags