Source Code Cross Referenced for DefaultKeyRelayingContainer.java in  » Web-Server » JicarillaHTTP » org » jicarilla » container » 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 » Web Server » JicarillaHTTP » org.jicarilla.container 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:        The Jicarilla Software License
003:
004:        Copyright (c) 2003 Leo Simons.
005:        All rights reserved.
006:
007:        Permission is hereby granted, free of charge, to any person obtaining
008:        a copy of this software and associated documentation files (the
009:        "Software"), to deal in the Software without restriction, including
010:        without limitation the rights to use, copy, modify, merge, publish,
011:        distribute, sublicense, and/or sell copies of the Software, and to
012:        permit persons to whom the Software is furnished to do so, subject to
013:        the following conditions:
014:
015:        The above copyright notice and this permission notice shall be
016:        included in all copies or substantial portions of the Software.
017:
018:        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
019:        EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
020:        MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
021:        IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
022:        CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
023:        TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
024:        SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
025:        ==================================================================== */
026:        package org.jicarilla.container;
027:
028:        import org.jicarilla.lang.Assert;
029:        import org.jicarilla.lang.Selector;
030:        import org.jicarilla.lang.Switch;
031:
032:        /**
033:         * <p>A straightforward implementation of the {@link KeyRelayingContainer}
034:         * interface that is backed by a {@link Switch}. This implementation is not
035:         * threadsafe, and delegates most of its functionality to
036:         * {@link DefaultContainer}.</p>
037:         *
038:         * <p>You will normally not want to use this implementation directly, as the
039:         * {@link org.jicarilla.container.builder.Builder} interface and its
040:         * {@link org.jicarilla.container.builder.DefaultBuilder} implementation
041:         * provide a more convenient way to create and populate container
042:         * instances.</p>
043:         *
044:         * @author <a href="mail at leosimons dot com">Leo Simons</a>
045:         * @version $Id: DefaultKeyRelayingContainer.java,v 1.7 2004/03/23 13:37:51 lsimons Exp $
046:         */
047:        public class DefaultKeyRelayingContainer extends DefaultContainer
048:                implements  KeyRelayingContainer {
049:            // ----------------------------------------------------------------------
050:            //  Constructors
051:            // ----------------------------------------------------------------------
052:
053:            /**
054:             * @see DefaultContainer#DefaultContainer()
055:             */
056:            public DefaultKeyRelayingContainer() {
057:                // this is a shame, cause its expensive
058:                super ();
059:                super .setResolver(new DefaultKeyRelayingResolver(
060:                        new DefaultKeyRelayingResolverCallback()));
061:            }
062:
063:            /**
064:             * @see DefaultContainer#DefaultContainer(Resolver)
065:             *
066:             * @param resolver
067:             */
068:            public DefaultKeyRelayingContainer(final Resolver resolver) {
069:                super (resolver);
070:            }
071:
072:            /**
073:             * @see DefaultContainer#DefaultContainer(Resolver,Switch)
074:             *
075:             * @param resolver
076:             * @param switcher
077:             */
078:            public DefaultKeyRelayingContainer(final Resolver resolver,
079:                    final Switch switcher) {
080:                super (resolver, switcher);
081:            }
082:
083:            // ----------------------------------------------------------------------
084:            //  Interface: KeyRelayingContainer
085:            // ----------------------------------------------------------------------
086:
087:            /**
088:             * @see KeyRelayingContainer#registerAdapter(Selector,KeyAwareAdapter)
089:             *
090:             * @param selector
091:             * @param adapter
092:             * @return
093:             */
094:            public KeyRelayingContainer registerAdapter(
095:                    final Selector selector, final KeyAwareAdapter adapter) {
096:                doAddAdapter(selector, adapter);
097:                return this ;
098:            }
099:
100:            /**
101:             * @see KeyRelayingContainer#registerAdapter(Object,KeyAwareAdapter)
102:             *
103:             * @param key
104:             * @param adapter
105:             * @return
106:             */
107:            public KeyRelayingContainer registerAdapter(final Object key,
108:                    final KeyAwareAdapter adapter) {
109:                doAddAdapter(key, adapter);
110:                return this ;
111:            }
112:
113:            // ----------------------------------------------------------------------
114:            //  Inner Class: DefaultKeyRelayingResolverCallback
115:            // ----------------------------------------------------------------------
116:
117:            /**
118:             * Extension of {@link DefaultContainer.DefaultResolverCallback} that
119:             * implements handlign of {@link KeyAwareAdapter}s.
120:             */
121:            protected class DefaultKeyRelayingResolverCallback extends
122:                    DefaultContainer.DefaultResolverCallback {
123:                /**
124:                 * @see DefaultContainer.DefaultResolverCallback#providedInstance(Object,Object)
125:                 *
126:                 * @param instance
127:                 * @param adapter
128:                 */
129:                public void providedInstance(final Object instance,
130:                        final Object adapter) {
131:                    Assert
132:                            .assertTrue(
133:                                    "DefaultContainer can only handle adapters that "
134:                                            + "implement the Adapter or KeyAwareAdapter interface!",
135:                                    adapter instanceof  Adapter
136:                                            || adapter instanceof  KeyAwareAdapter);
137:
138:                    m_container.getInstanceToAdapterMap()
139:                            .put(instance, adapter);
140:                }
141:
142:                /**
143:                 * @see DefaultContainer.DefaultResolverCallback#returnedInstance(Object)
144:                 *
145:                 * @param component
146:                 * @throws Exception
147:                 */
148:                public void returnedInstance(final Object component)
149:                        throws Exception {
150:                    if (component == null)
151:                        return;
152:
153:                    final Object adapter = m_container
154:                            .getInstanceToAdapterMap().remove(component);
155:                    if (adapter != null) {
156:                        if (adapter instanceof  Adapter) {
157:                            ((Adapter) adapter).releaseInstance(component);
158:                        } else {
159:                            final KeyAwareAdapter keyAdapter = (KeyAwareAdapter) adapter;
160:                            keyAdapter.releaseInstance(component);
161:                        }
162:                    }
163:                }
164:            }
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.