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


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 2000-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.core.examples;
027:
028:        import java.util.*;
029:        import org.cougaar.util.*;
030:        import org.cougaar.core.component.*;
031:        import org.cougaar.core.agent.*;
032:        import org.cougaar.core.domain.*;
033:        import org.cougaar.core.blackboard.*;
034:        import org.cougaar.core.persist.*;
035:        import org.cougaar.core.blackboard.*;
036:        import org.cougaar.core.service.BlackboardService;
037:
038:        /** A plugin's view of its parent component (Container).
039:         * Add a line like the following to a cluster.ini file:
040:         * <pre>
041:         * Node.AgentManager.Agent.PluginManager.Binder = org.cougaar.core.examples.PluginServiceFilter
042:         * </pre>
043:
044:         **/
045:        public class PluginServiceFilter extends ServiceFilter {
046:            //  This method specifies the Binder to use (defined later)
047:            protected Class getBinderClass(Object child) {
048:                return PluginServiceFilterBinder.class;
049:            }
050:
051:            // This is a "Wrapper" binder which installs a service filter for plugins
052:            public static class PluginServiceFilterBinder extends
053:                    ServiceFilterBinder {
054:                public PluginServiceFilterBinder(BinderFactory bf, Object child) {
055:                    super (bf, child);
056:                }
057:
058:                // this method specifies a binder proxy to use, so as to avoid exposing the binder
059:                // itself to the lower level objects.
060:                protected ContainerAPI createContainerProxy() {
061:                    return new ServiceFilterContainerProxy();
062:                }
063:
064:                // this method installs the "filtering" service broker
065:                protected ServiceBroker createFilteringServiceBroker(
066:                        ServiceBroker sb) {
067:                    return new PluginFilteringServiceBroker(sb);
068:                }
069:
070:                // this class catches requests for blackboard services, and 
071:                // installs its own service proxy.
072:                protected class PluginFilteringServiceBroker extends
073:                        FilteringServiceBroker {
074:                    public PluginFilteringServiceBroker(ServiceBroker sb) {
075:                        super (sb);
076:                    }
077:
078:                    // here's where we catch the service request for Blackboard and proxy the
079:                    // returned service.  See FilteringServiceBroker for more options.
080:                    protected Object getServiceProxy(Object service,
081:                            Class serviceClass, Object client) {
082:                        if (service instanceof  BlackboardService) {
083:                            return new BlackboardServiceProxy(
084:                                    (BlackboardService) service, client);
085:                        }
086:                        return null;
087:                    }
088:                }
089:            }
090:
091:            // this class is a proxy for the blackboard service which audits subscription
092:            // requests.
093:            private static class BlackboardServiceProxy extends
094:                    BlackboardServiceDelegate {
095:                private final Object client;
096:
097:                public BlackboardServiceProxy(BlackboardService bs,
098:                        Object client) {
099:                    super (bs);
100:                    this .client = client;
101:                }
102:
103:                public Subscriber getSubscriber() {
104:                    System.err.println("Warning: " + client
105:                            + " is calling BlackboardService.getSubscriber()!");
106:                    return super .getSubscriber();
107:                }
108:
109:                public Subscription subscribe(UnaryPredicate isMember) {
110:                    System.err.println("BlackboardService.subscribe("
111:                            + isMember + ") called by: " + client);
112:                    return super .subscribe(isMember);
113:                }
114:            }
115:
116:            // dumb delegate, could be promoted to a reusable public class
117:            private static class BlackboardServiceDelegate implements 
118:                    BlackboardService {
119:                private final BlackboardService bs;
120:
121:                public BlackboardServiceDelegate(BlackboardService bs) {
122:                    this .bs = bs;
123:                }
124:
125:                public Subscriber getSubscriber() {
126:                    return bs.getSubscriber();
127:                }
128:
129:                public Subscription subscribe(UnaryPredicate isMember) {
130:                    return bs.subscribe(isMember);
131:                }
132:
133:                public Subscription subscribe(UnaryPredicate isMember,
134:                        Collection realCollection) {
135:                    return bs.subscribe(isMember, realCollection);
136:                }
137:
138:                public Subscription subscribe(UnaryPredicate isMember,
139:                        boolean isIncremental) {
140:                    return bs.subscribe(isMember, isIncremental);
141:                }
142:
143:                public Subscription subscribe(UnaryPredicate isMember,
144:                        Collection realCollection, boolean isIncremental) {
145:                    return bs
146:                            .subscribe(isMember, realCollection, isIncremental);
147:                }
148:
149:                public Subscription subscribe(Subscription subscription) {
150:                    return bs.subscribe(subscription);
151:                }
152:
153:                public Collection query(UnaryPredicate isMember) {
154:                    return bs.query(isMember);
155:                }
156:
157:                public void unsubscribe(Subscription subscription) {
158:                    bs.unsubscribe(subscription);
159:                }
160:
161:                public int getSubscriptionCount() {
162:                    return bs.getSubscriptionCount();
163:                }
164:
165:                public int getSubscriptionSize() {
166:                    return bs.getSubscriptionSize();
167:                }
168:
169:                public int getPublishAddedCount() {
170:                    return bs.getPublishAddedCount();
171:                }
172:
173:                public int getPublishChangedCount() {
174:                    return bs.getPublishChangedCount();
175:                }
176:
177:                public int getPublishRemovedCount() {
178:                    return bs.getPublishRemovedCount();
179:                }
180:
181:                public boolean haveCollectionsChanged() {
182:                    return bs.haveCollectionsChanged();
183:                }
184:
185:                public void publishAdd(Object o) {
186:                    bs.publishAdd(o);
187:                }
188:
189:                public void publishRemove(Object o) {
190:                    bs.publishRemove(o);
191:                }
192:
193:                public void publishChange(Object o) {
194:                    bs.publishChange(o);
195:                }
196:
197:                public void publishChange(Object o, Collection changes) {
198:                    bs.publishChange(o, changes);
199:                }
200:
201:                public void openTransaction() {
202:                    bs.openTransaction();
203:                }
204:
205:                public boolean tryOpenTransaction() {
206:                    return bs.tryOpenTransaction();
207:                }
208:
209:                public void closeTransaction() throws SubscriberException {
210:                    bs.closeTransaction();
211:                }
212:
213:                public void closeTransactionDontReset()
214:                        throws SubscriberException {
215:                    bs.closeTransactionDontReset();
216:                }
217:
218:                /** @deprecated Use {@link #closeTransactionDontReset closeTransactionDontReset}
219:                 **/
220:                public void closeTransaction(boolean resetp)
221:                        throws SubscriberException {
222:                    bs.closeTransaction(resetp);
223:                }
224:
225:                public boolean isTransactionOpen() {
226:                    return bs.isTransactionOpen();
227:                }
228:
229:                public void signalClientActivity() {
230:                    bs.signalClientActivity();
231:                }
232:
233:                public SubscriptionWatcher registerInterest(
234:                        SubscriptionWatcher w) {
235:                    return bs.registerInterest(w);
236:                }
237:
238:                public SubscriptionWatcher registerInterest() {
239:                    return bs.registerInterest();
240:                }
241:
242:                public void unregisterInterest(SubscriptionWatcher w)
243:                        throws SubscriberException {
244:                    bs.unregisterInterest(w);
245:                }
246:
247:                public void setShouldBePersisted(boolean value) {
248:                    bs.setShouldBePersisted(value);
249:                }
250:
251:                public boolean shouldBePersisted() {
252:                    return bs.shouldBePersisted();
253:                }
254:
255:                public void persistNow()
256:                        throws org.cougaar.core.persist.PersistenceNotEnabledException {
257:                    bs.persistNow();
258:                }
259:
260:                public boolean didRehydrate() {
261:                    return bs.didRehydrate();
262:                }
263:
264:                public Persistence getPersistence() {
265:                    return bs.getPersistence();
266:                }
267:            }
268:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.