Source Code Cross Referenced for RMICacheManagerPeerProvider.java in  » Cache » ehcache » net » sf » ehcache » distribution » 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 » Cache » ehcache » net.sf.ehcache.distribution 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  Copyright 2003-2007 Luck Consulting Pty Ltd
003:         *
004:         *  Licensed under the Apache License, Version 2.0 (the "License");
005:         *  you may not use this file except in compliance with the License.
006:         *  You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         *  Unless required by applicable law or agreed to in writing, software
011:         *  distributed under the License is distributed on an "AS IS" BASIS,
012:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         *  See the License for the specific language governing permissions and
014:         *  limitations under the License.
015:         */package net.sf.ehcache.distribution;
016:
017:        import net.sf.ehcache.CacheException;
018:        import net.sf.ehcache.CacheManager;
019:        import net.sf.ehcache.Ehcache;
020:        import org.apache.commons.logging.Log;
021:        import org.apache.commons.logging.LogFactory;
022:
023:        import java.net.MalformedURLException;
024:        import java.rmi.Naming;
025:        import java.rmi.NotBoundException;
026:        import java.rmi.RemoteException;
027:        import java.util.Collections;
028:        import java.util.Date;
029:        import java.util.HashMap;
030:        import java.util.List;
031:        import java.util.Map;
032:
033:        /**
034:         * A provider of Peer RMI addresses.
035:         *
036:         * @author Greg Luck
037:         * @version $Id: RMICacheManagerPeerProvider.java 519 2007-07-27 07:11:45Z gregluck $
038:         */
039:        public abstract class RMICacheManagerPeerProvider implements 
040:                CacheManagerPeerProvider {
041:
042:            private static final Log LOG = LogFactory
043:                    .getLog(RMICacheManagerPeerProvider.class.getName());
044:
045:            /**
046:             * Contains a RMI URLs of the form: "//" + hostName + ":" + port + "/" + cacheName;
047:             */
048:            protected final Map peerUrls = Collections
049:                    .synchronizedMap(new HashMap());
050:
051:            /**
052:             * The CacheManager this peer provider is associated with.
053:             */
054:            protected CacheManager cacheManager;
055:
056:            /**
057:             * Constructor
058:             *
059:             * @param cacheManager
060:             */
061:            public RMICacheManagerPeerProvider(CacheManager cacheManager) {
062:                this .cacheManager = cacheManager;
063:            }
064:
065:            /**
066:             * Empty constructor
067:             */
068:            public RMICacheManagerPeerProvider() {
069:                //nothing to do
070:            }
071:
072:            /**
073:             * {@inheritDoc}
074:             */
075:            public abstract void init();
076:
077:            /**
078:             * Register a new peer
079:             *
080:             * @param rmiUrl
081:             */
082:            public abstract void registerPeer(String rmiUrl);
083:
084:            /**
085:             * Gets the cache name out of the url
086:             * @param rmiUrl
087:             * @return the cache name as it would appear in ehcache.xml
088:             */
089:            static String extractCacheName(String rmiUrl) {
090:                return rmiUrl.substring(rmiUrl.lastIndexOf('/') + 1);
091:            }
092:
093:            /**
094:             * Unregisters a peer
095:             *
096:             * @param rmiUrl
097:             */
098:            public final synchronized void unregisterPeer(String rmiUrl) {
099:                peerUrls.remove(rmiUrl);
100:            }
101:
102:            /**
103:             * @return a list of {@link net.sf.ehcache.distribution.CachePeer} peers for the given cache, excluding the local peer.
104:             */
105:            public abstract List listRemoteCachePeers(Ehcache cache)
106:                    throws CacheException;
107:
108:            /**
109:             * Whether the entry should be considered stale. This will depend on the type of RMICacheManagerPeerProvider.
110:             * <p/>
111:             * @param date the date the entry was created
112:             * @return true if stale
113:             */
114:            protected abstract boolean stale(Date date);
115:
116:            /**
117:             * The use of one-time registry creation and Naming.rebind should mean we can create as many listeneres as we like.
118:             * They will simply replace the ones that were there.
119:             */
120:            public CachePeer lookupRemoteCachePeer(String url)
121:                    throws MalformedURLException, NotBoundException,
122:                    RemoteException {
123:                return (CachePeer) Naming.lookup(url);
124:            }
125:
126:            /**
127:             * Providers may be doing all sorts of exotic things and need to be able to clean up on dispose.
128:             *
129:             * @throws net.sf.ehcache.CacheException
130:             */
131:            public void dispose() throws CacheException {
132:                //nothing to do.
133:            }
134:
135:            /**
136:             * The cacheManager this provider is bound to
137:             */
138:            public final CacheManager getCacheManager() {
139:                return cacheManager;
140:            }
141:
142:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.