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


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 1997-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:
027:        package org.cougaar.logistics.plugin.policy;
028:
029:        import java.util.Set;
030:        import java.util.Collections;
031:        import org.cougaar.core.relay.*;
032:        import org.cougaar.core.mts.MessageAddress;
033:        import org.cougaar.core.util.UID;
034:        import org.cougaar.planning.ldm.policy.Policy;
035:        import org.cougaar.core.util.UniqueObject;
036:        import java.util.HashSet;
037:
038:        /**
039:         * class to hold instance of Policy using Relay to propagate itself to a given role
040:         */
041:        public class LogisticsPolicy extends java.lang.Object implements 
042:                Relay.Source, Relay.Target, UniqueObject {
043:
044:            private MessageAddress source;
045:            private String authority;
046:            private HashSet _targets = new HashSet();
047:            private Policy policy;
048:            private UID uid;
049:            private String role;
050:
051:            /**
052:             * constructor
053:             * @param policy Policy for LogisticsPolicy to hold
054:             * @param source MessageAddress of Organization which is sending the LogisticsPolicy
055:             * @param target Set of MessageAddresses which the LogisticsPolicy to be delivered
056:             * @param authority name of the originator of this LogisticsPolicy
057:             * @param role Role to which the Policy should be propagated
058:             */
059:            public LogisticsPolicy(Policy policy, MessageAddress source,
060:                    Set target, String authority, String role) {
061:                this .policy = policy;
062:                this .source = source;
063:                this .authority = authority;
064:                this ._targets.addAll(target);
065:                this .role = role;
066:            }
067:
068:            /**
069:             * constructor used by Factory
070:             * @param other LogisticsPolicy which prompted the creation of this new one
071:             * @param src MessageAddress of sender of the LogisticsPolicy
072:             */
073:
074:            protected LogisticsPolicy(LogisticsPolicy other, MessageAddress src) {
075:                this (other.getPolicy(), src, Collections.EMPTY_SET, other
076:                        .getAuthority(), other.getRole());
077:                this .setUID(other.getUID());
078:            }
079:
080:            /**
081:             * method to retrieve role to which this LogisticsPolicy is to be propagated
082:             */
083:
084:            public String getRole() {
085:                return role;
086:            }
087:
088:            /**
089:             * method to retrieve originator
090:             */
091:            public String getAuthority() {
092:                return authority;
093:            }
094:
095:            /**
096:             * method to retrieve the sender
097:             */
098:            public MessageAddress getSource() {
099:                return source;
100:            }
101:
102:            /**
103:             * method to set sender
104:             * @param ma MessageAddress of sender
105:             */
106:            public void setSource(MessageAddress ma) {
107:                this .source = ma;
108:            }
109:
110:            /**
111:             * returns null
112:             */
113:            public Object getResponse() {
114:                return null;
115:            }
116:
117:            /**
118:             * returns Relay.NO_CHANGE
119:             */
120:            public int updateResponse(MessageAddress t, Object response) {
121:                return Relay.NO_CHANGE;
122:            }
123:
124:            /**
125:             * returns Relay.NO_CHANGE
126:             */
127:            public int updateContent(Object content, Token token) {
128:                return NO_CHANGE;
129:            }
130:
131:            /**
132:             * returns this
133:             */
134:            public Object getContent() {
135:                return this ;
136:            }
137:
138:            /**
139:             * method to get Set of MessageAddresses of destinations for this LogisticsPolicy
140:             */
141:            public Set getTargets() {
142:                if (_targets != null) {
143:                    return _targets;
144:                } else {
145:                    return Collections.EMPTY_SET;
146:                }
147:            }
148:
149:            //	public void addTargets(Set newTargets) {
150:            //		if (_targets.isEmpty()) {
151:            //			_targets = newTargets;
152:            //		} else {
153:            //			this._targets.addAll(newTargets);
154:            //		}
155:            //		if (_targets != null){
156:            //			d.print("addTargets - all targets: " + this._targets.toString());
157:            //		} else d.print("addTargets - targets are null");
158:            //	}
159:
160:            /**
161:             * method to set targets
162:             * @param newTargets Set of MessageAddresses to direct this LogisticsPolicy
163:             */
164:            public void setTargets(Set newTargets) {
165:                this ._targets = new HashSet(newTargets);
166:            }
167:
168:            public void addTarget(MessageAddress target) {
169:                if (_targets == null) {
170:                    _targets = new HashSet();
171:                }
172:                if (_targets instanceof  HashSet) {
173:                }
174:                _targets.add(target);
175:            }
176:
177:            /**
178:             * method to get UID
179:             */
180:            public UID getUID() {
181:                return uid;
182:            }
183:
184:            /**
185:             * method to set UID
186:             * @param uid new UID for the LogisticsPolicy
187:             */
188:            public void setUID(UID uid) {
189:                this .uid = uid;
190:            }
191:
192:            /**
193:             * method to get Policy from within the LogisticsPolicy
194:             */
195:            public Policy getPolicy() {
196:                return policy;
197:            }
198:
199:            /**
200:             * Factory to create new LogisticsPolicies
201:             */
202:            private static final class SimpleRelayFactory implements 
203:                    TargetFactory, java.io.Serializable {
204:
205:                public static final SimpleRelayFactory INSTANCE = new SimpleRelayFactory();
206:
207:                private SimpleRelayFactory() {
208:                }
209:
210:                /**
211:                 * method to create new instance of LogisticsPolicy
212:                 * @param uid UID
213:                 * @param source MessageAddress of sender
214:                 * @param content
215:                 * @param token
216:                 */
217:                public Relay.Target create(UID uid, MessageAddress source,
218:                        Object content, Token token) {
219:                    LogisticsPolicy p = null;
220:                    try {
221:                        p = (LogisticsPolicy) content;
222:                    } catch (ClassCastException cce) {
223:                        ;
224:                    }
225:                    return new LogisticsPolicy(p, source);
226:                }
227:
228:                private Object readResolve() {
229:                    return INSTANCE;
230:                }
231:            };
232:
233:            /**
234:             * method to retrieve instance of SimpleRelayFactory
235:             */
236:            public TargetFactory getTargetFactory() {
237:                return SimpleRelayFactory.INSTANCE;
238:
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.