Source Code Cross Referenced for ComponentContext.java in  » J2EE » jfox » org » jfox » framework » component » 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 » J2EE » jfox » org.jfox.framework.component 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JFox - The most lightweight Java EE Application Server!
003:         * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
004:         *
005:         * JFox is licenced and re-distributable under GNU LGPL.
006:         */
007:        package org.jfox.framework.component;
008:
009:        import java.io.File;
010:        import java.util.HashMap;
011:        import java.util.Iterator;
012:        import java.util.Map;
013:        import java.util.Collection;
014:
015:        import org.jfox.framework.BaseException;
016:        import org.jfox.framework.BaseRuntimeException;
017:        import org.jfox.framework.ComponentId;
018:        import org.jfox.framework.Framework;
019:        import org.jfox.framework.event.ComponentEvent;
020:
021:        /**
022:         * Component 上下文
023:         * ComponentContext 和 Component 是一对一的关系
024:         * ComponentContex 和 ComponentMeta �一定是一对一的关系
025:         * 对于Non Singleton Component,一个 ComponentMeta�能对应多个Component,也就对应多个ComponentContex
026:         *
027:         * @author <a href="mailto:jfox.young@gmail.com">Young Yang</a>
028:         */
029:        public class ComponentContext {
030:
031:            //注�: 这里�能�存Component的实例,而应该�次从Module中�得,这样�能实现热部署
032:            //private Component concreteComponent;
033:
034:            private Framework framework;
035:
036:            private String moduleName;
037:
038:            private ComponentId componentId;
039:
040:            /**
041:             * 用户属性
042:             */
043:            private Map<String, Object> attributes = new HashMap<String, Object>();
044:
045:            ComponentContext(Framework framework, String module,
046:                    ComponentId componentId) {
047:                this .framework = framework;
048:                this .moduleName = module;
049:                this .componentId = componentId;
050:            }
051:
052:            private Module getModule() {
053:                return framework.getModule(getModuleName());
054:            }
055:
056:            public String getModuleName() {
057:                return moduleName;
058:            }
059:
060:            public File getModuleDir() {
061:                return getModule().getModuleDir();
062:            }
063:
064:            public Component getMyselfComponent() {
065:                try {
066:                    return getComponentById(componentId);
067:                } catch (BaseException e) {
068:                    throw new BaseRuntimeException(
069:                            "Can not get Myself Component!", e);
070:                }
071:            }
072:
073:            public ComponentId getComponentId() {
074:                return componentId;
075:            }
076:
077:            public void setAttribute(String key, Object value) {
078:                attributes.put(key, value);
079:            }
080:
081:            public Object removeAttribute(String key) {
082:                return attributes.remove(key);
083:            }
084:
085:            public Iterator<String> attributeKeys() {
086:                return attributes.keySet().iterator();
087:            }
088:
089:            public Object hasAttribute(String key) {
090:                return attributes.containsKey(key);
091:            }
092:
093:            public ExtentionPoint getExtentionPoint(String pointId) {
094:                try {
095:                    return getModule().getComponentMeta(componentId)
096:                            .getExtentionPoint(pointId);
097:                } catch (ComponentNotFoundException e) {
098:                    return null;
099:                } catch (ComponentNotExportedException e) {
100:                    return null;
101:                }
102:            }
103:
104:            /**
105:             * Component 通过 ComponentContext �以获得需�的 Component 引用
106:             *
107:             * @param componentId component Id
108:             * @throws ComponentNotFoundException e
109:             * @throws ComponentNotExportedException e
110:             */
111:            public Component getComponentById(ComponentId componentId)
112:                    throws ComponentNotFoundException,
113:                    ComponentNotExportedException {
114:                return getModule().getComponent(componentId);
115:            }
116:
117:            /**
118:             * find components by the interface/super class provided
119:             * 注�:仅在本 Module 中查找
120:             * 
121:             * @param interfaceClass interface class
122:             */
123:            public <T extends Component> Collection<T> getComponentsByInterface(
124:                    Class<T> interfaceClass) {
125:                return getModule().findComponentByInterface(interfaceClass);
126:            }
127:
128:            public <T extends Component> Collection<T> getComponentsByInterface(
129:                    Class<T> interfaceClass, String moduleName) {
130:                return getModule().findComponentByInterface(interfaceClass,
131:                        moduleName);
132:            }
133:
134:            public void fireComponentEvent(ComponentEvent componentEvent) {
135:                getModule().getFramework().getEventManager()
136:                        .fireComponentEvent(componentEvent);
137:            }
138:
139:            public static void main(String[] args) {
140:
141:            }
142:
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.