Source Code Cross Referenced for RequestImpl.java in  » Science » Cougaar12_4 » org » cougaar » community » manager » 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 » Science » Cougaar12_4 » org.cougaar.community.manager 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 2002-2004 BBNT Solutions, LLC
005:         *  under sponsorship of the Defense Advanced Research Projects
006:         *  Agency (DARPA).
007:         * 
008:         *  You can redistribute this software and/or modify it under the
009:         *  terms of the Cougaar Open Source License as published on the
010:         *  Cougaar Open Source Website (www.cougaar.org).
011:         * 
012:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015:         *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016:         *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017:         *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018:         *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019:         *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020:         *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021:         *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022:         *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023:         *  
024:         * </copyright>
025:         */
026:        package org.cougaar.community.manager;
027:
028:        import java.io.ObjectInputStream;
029:        import java.io.Serializable;
030:        import java.util.HashSet;
031:        import java.util.Set;
032:        import java.util.Collections;
033:        import javax.naming.directory.ModificationItem;
034:
035:        import org.cougaar.core.mts.MessageAddress;
036:        import org.cougaar.core.relay.Relay;
037:        import org.cougaar.core.util.UID;
038:        import org.cougaar.core.service.community.CommunityResponse;
039:        import org.cougaar.core.service.community.CommunityResponseListener;
040:        import org.cougaar.core.service.community.Entity;
041:
042:        /**
043:         * Blackboard Relay used by CommunityService to send request to remote
044:         * Community Manager.  This class should only be used by Community
045:         * Service implementations, it is not intended for use by clients.
046:         **/
047:        public class RequestImpl implements  Request, Relay.Source,
048:                Relay.Target, Serializable {
049:
050:            protected final UID uid;
051:            protected final MessageAddress source;
052:            protected final MessageAddress target;
053:
054:            protected String communityName;
055:            protected int requestType = UNDEFINED;
056:            protected Entity entity;
057:
058:            protected CommunityResponse resp;
059:            protected ModificationItem[] mods;
060:
061:            private transient Set targets;
062:            private transient Set listeners;
063:
064:            public RequestImpl(MessageAddress source, MessageAddress target,
065:                    String communityName, int reqType, Entity entity,
066:                    ModificationItem[] attrMods, UID uid,
067:                    CommunityResponseListener crl) {
068:                this .source = source;
069:                this .target = target;
070:                this .communityName = communityName;
071:                this .requestType = reqType;
072:                this .entity = entity;
073:                this .mods = attrMods;
074:                this .uid = uid;
075:                addCommunityResponseListener(crl);
076:                cacheTargets();
077:            }
078:
079:            public String getCommunityName() {
080:                return communityName;
081:            }
082:
083:            /**
084:             * Defines the type of request.
085:             * @param reqType Request type
086:             */
087:            public void setRequestType(int reqType) {
088:                this .requestType = reqType;
089:            }
090:
091:            public int getRequestType() {
092:                return this .requestType;
093:            }
094:
095:            /**
096:             * Entity for requests requiring one, such as a JOIN and LEAVE.
097:             * @param entity Affected entity
098:             */
099:            public void setEntity(Entity entity) {
100:                this .entity = entity;
101:            }
102:
103:            public Entity getEntity() {
104:                return this .entity;
105:            }
106:
107:            public void setResponse(CommunityResponse resp) {
108:                this .resp = resp;
109:            }
110:
111:            public void setAttributeModifications(ModificationItem[] mods) {
112:                this .mods = mods;
113:            }
114:
115:            public ModificationItem[] getAttributeModifications() {
116:                return mods;
117:            }
118:
119:            public void addCommunityResponseListener(
120:                    CommunityResponseListener crl) {
121:                if (listeners == null)
122:                    listeners = new HashSet();
123:                listeners.add(crl);
124:            }
125:
126:            public Set getCommunityResponseListeners() {
127:                return (listeners != null) ? listeners : Collections.EMPTY_SET;
128:            }
129:
130:            public String getRequestTypeAsString(int type) {
131:                switch (type) {
132:                case Request.UNDEFINED:
133:                    return "UNDEFINED";
134:                case Request.JOIN:
135:                    return "JOIN";
136:                case Request.LEAVE:
137:                    return "LEAVE";
138:                case Request.GET_COMMUNITY_DESCRIPTOR:
139:                    return "GET_COMMUNITY_DESCRIPTOR";
140:                case Request.MODIFY_ATTRIBUTES:
141:                    return "MODIFY_ATTRIBUTES";
142:                case Request.LIST:
143:                    return "LIST";
144:                }
145:                return "INVALID_VALUE";
146:            }
147:
148:            /**
149:             * Returns a string representation of the request
150:             * @return String - a string representation of the request.
151:             **/
152:            public String toString() {
153:                return "request=" + getRequestTypeAsString(requestType)
154:                        + " community=" + communityName + " entity="
155:                        + (entity == null ? "null" : entity.getName())
156:                        + " resp=" + resp + " source=" + this .getSource()
157:                        + " uid=" + uid;
158:            }
159:
160:            public UID getUID() {
161:                return uid;
162:            }
163:
164:            public void setUID(UID uid) {
165:                throw new UnsupportedOperationException();
166:            }
167:
168:            public MessageAddress getTarget() {
169:                return target;
170:            }
171:
172:            // Relay.Source:
173:
174:            private void cacheTargets() {
175:                targets = ((target != null) ? Collections.singleton(target)
176:                        : Collections.EMPTY_SET);
177:            }
178:
179:            public Set getTargets() {
180:                return targets;
181:            }
182:
183:            public Object getContent() {
184:                return this ;
185:            }
186:
187:            public Relay.TargetFactory getTargetFactory() {
188:                return RequestImplFactory.INSTANCE;
189:            }
190:
191:            public int updateResponse(MessageAddress t, Object response) {
192:                this .resp = (CommunityResponse) response;
193:                return Relay.RESPONSE_CHANGE;
194:            }
195:
196:            // Relay.Target:
197:
198:            public MessageAddress getSource() {
199:                return source;
200:            }
201:
202:            public Object getResponse() {
203:                return resp;
204:            }
205:
206:            public int updateContent(Object content, Token token) {
207:                return Relay.NO_CHANGE;
208:            }
209:
210:            public boolean equals(Object o) {
211:                if (o == this ) {
212:                    return true;
213:                } else if (!(o instanceof  RequestImpl)) {
214:                    return false;
215:                } else {
216:                    UID u = ((RequestImpl) o).uid;
217:                    return uid.equals(u);
218:                }
219:            }
220:
221:            public int hashCode() {
222:                return uid.hashCode();
223:            }
224:
225:            private void readObject(ObjectInputStream stream)
226:                    throws ClassNotFoundException, java.io.IOException {
227:                stream.defaultReadObject();
228:                cacheTargets();
229:            }
230:
231:            protected RequestImpl target_copy() {
232:                return new RequestImpl(source, null, communityName,
233:                        requestType, entity, mods, uid, null);
234:            }
235:
236:            /**
237:             * Simple factory implementation.
238:             */
239:            private static class RequestImplFactory implements 
240:                    Relay.TargetFactory, Serializable {
241:
242:                public static RequestImplFactory INSTANCE = new RequestImplFactory();
243:
244:                public Relay.Target create(UID uid, MessageAddress source,
245:                        Object content, Relay.Token token) {
246:                    RequestImpl ati = (RequestImpl) content;
247:                    return ati.target_copy();
248:                }
249:
250:                private Object readResolve() {
251:                    return INSTANCE;
252:                }
253:            }
254:
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.