Source Code Cross Referenced for AbstractModel.java in  » ESB » mule » org » mule » model » 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 » ESB » mule » org.mule.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: AbstractModel.java 11379 2008-03-17 02:46:56Z dfeist $
003:         * --------------------------------------------------------------------------------------
004:         * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
005:         *
006:         * The software in this package is published under the terms of the CPAL v1.0
007:         * license, a copy of which has been included with this distribution in the
008:         * LICENSE.txt file.
009:         */
010:
011:        package org.mule.model;
012:
013:        import org.mule.api.MuleException;
014:        import org.mule.api.MuleContext;
015:        import org.mule.api.component.LifecycleAdapterFactory;
016:        import org.mule.api.context.notification.ServerNotification;
017:        import org.mule.api.lifecycle.InitialisationException;
018:        import org.mule.api.lifecycle.LifecycleTransitionResult;
019:        import org.mule.api.model.EntryPointResolver;
020:        import org.mule.api.model.EntryPointResolverSet;
021:        import org.mule.api.model.Model;
022:        import org.mule.component.DefaultLifecycleAdapterFactory;
023:        import org.mule.context.notification.ModelNotification;
024:        import org.mule.model.resolvers.DefaultEntryPointResolverSet;
025:        import org.mule.model.resolvers.LegacyEntryPointResolverSet;
026:        import org.mule.service.DefaultServiceExceptionStrategy;
027:
028:        import java.beans.ExceptionListener;
029:        import java.util.Collection;
030:        import java.util.Iterator;
031:
032:        import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
033:
034:        import org.apache.commons.logging.Log;
035:        import org.apache.commons.logging.LogFactory;
036:
037:        /**
038:         * <code>MuleModel</code> is the default implementation of the Model. The model
039:         * encapsulates and manages the runtime behaviour of a Mule Server instance. It is
040:         * responsible for maintaining the UMOs instances and their configuration.
041:         */
042:        public abstract class AbstractModel implements  Model {
043:
044:            public static final String DEFAULT_MODEL_NAME = "main";
045:
046:            private String name = DEFAULT_MODEL_NAME;
047:            private EntryPointResolverSet entryPointResolverSet = null; // values are supplied below as required
048:            private LifecycleAdapterFactory lifecycleAdapterFactory = new DefaultLifecycleAdapterFactory();
049:            private AtomicBoolean initialised = new AtomicBoolean(false);
050:            private AtomicBoolean started = new AtomicBoolean(false);
051:            private ExceptionListener exceptionListener = new DefaultServiceExceptionStrategy();
052:
053:            protected transient Log logger = LogFactory.getLog(getClass());
054:            protected MuleContext muleContext;
055:
056:            /*
057:             * (non-Javadoc)
058:             * 
059:             * @see org.mule.api.UMOModel#getName()
060:             */
061:            public String getName() {
062:                return name;
063:            }
064:
065:            /*
066:             * (non-Javadoc)
067:             * 
068:             * @see org.mule.api.UMOModel#setName(java.lang.String)
069:             */
070:            public void setName(String name) {
071:                this .name = name;
072:            }
073:
074:            /*
075:             * (non-Javadoc)
076:             * 
077:             * @see org.mule.api.model.Model#getEntryPointResolver()
078:             */
079:            public EntryPointResolverSet getEntryPointResolverSet() {
080:                if (null == entryPointResolverSet) {
081:                    entryPointResolverSet = new LegacyEntryPointResolverSet();
082:                }
083:                return entryPointResolverSet;
084:            }
085:
086:            /*
087:             * (non-Javadoc)
088:             * 
089:             * @see org.mule.api.model.Model#setEntryPointResolver(org.mule.api.model.EntryPointResolver)
090:             */
091:            public void setEntryPointResolverSet(
092:                    EntryPointResolverSet entryPointResolverSet) {
093:                this .entryPointResolverSet = entryPointResolverSet;
094:            }
095:
096:            /**
097:             * This allows us to configure entry point resolvers incrementally
098:             *
099:             * @param entryPointResolvers Resolvers to add
100:             */
101:            public void setEntryPointResolvers(Collection entryPointResolvers) {
102:                if (null == entryPointResolverSet) {
103:                    entryPointResolverSet = new DefaultEntryPointResolverSet();
104:                }
105:                for (Iterator resolvers = entryPointResolvers.iterator(); resolvers
106:                        .hasNext();) {
107:                    entryPointResolverSet
108:                            .addEntryPointResolver((EntryPointResolver) resolvers
109:                                    .next());
110:                }
111:            }
112:
113:            /*
114:             * (non-Javadoc)
115:             *
116:             * @see org.mule.api.model.Model#getLifecycleAdapterFactory()
117:             */
118:            public LifecycleAdapterFactory getLifecycleAdapterFactory() {
119:                return lifecycleAdapterFactory;
120:            }
121:
122:            /*
123:             * (non-Javadoc)
124:             * 
125:             * @see org.mule.api.model.Model#setLifecycleAdapterFactory(org.mule.api.lifecycle.LifecycleAdapterFactory)
126:             */
127:            public void setLifecycleAdapterFactory(
128:                    LifecycleAdapterFactory lifecycleAdapterFactory) {
129:                this .lifecycleAdapterFactory = lifecycleAdapterFactory;
130:            }
131:
132:            /** Destroys any current components */
133:            public void dispose() {
134:                fireNotification(new ModelNotification(this ,
135:                        ModelNotification.MODEL_DISPOSING));
136:                fireNotification(new ModelNotification(this ,
137:                        ModelNotification.MODEL_DISPOSED));
138:            }
139:
140:            /**
141:             * Stops any registered components
142:             *
143:             * @throws MuleException if a Service fails tcomponent
144:             */
145:            public LifecycleTransitionResult stop() throws MuleException {
146:                fireNotification(new ModelNotification(this ,
147:                        ModelNotification.MODEL_STOPPING));
148:                started.set(false);
149:                fireNotification(new ModelNotification(this ,
150:                        ModelNotification.MODEL_STOPPED));
151:                return LifecycleTransitionResult.OK;
152:            }
153:
154:            /**
155:             * Starts all registered components
156:             *
157:             * @throws MuleException if any of the components fail to start
158:             */
159:            public LifecycleTransitionResult start() throws MuleException {
160:                if (!initialised.get()) {
161:                    throw new IllegalStateException("Not Initialised");
162:                }
163:
164:                if (!started.get()) {
165:                    fireNotification(new ModelNotification(this ,
166:                            ModelNotification.MODEL_STARTING));
167:                    started.set(true);
168:                    fireNotification(new ModelNotification(this ,
169:                            ModelNotification.MODEL_STARTED));
170:                } else {
171:                    logger.debug("Model already started");
172:                }
173:                return LifecycleTransitionResult.OK;
174:            }
175:
176:            public LifecycleTransitionResult initialise()
177:                    throws InitialisationException {
178:                if (!initialised.get()) {
179:                    fireNotification(new ModelNotification(this ,
180:                            ModelNotification.MODEL_INITIALISING));
181:                    initialised.set(true);
182:                    fireNotification(new ModelNotification(this ,
183:                            ModelNotification.MODEL_INITIALISED));
184:                } else {
185:                    logger.debug("Model already initialised");
186:                }
187:                return LifecycleTransitionResult.OK;
188:            }
189:
190:            public ExceptionListener getExceptionListener() {
191:                return exceptionListener;
192:            }
193:
194:            public void setExceptionListener(ExceptionListener exceptionListener) {
195:                this .exceptionListener = exceptionListener;
196:            }
197:
198:            void fireNotification(ServerNotification notification) {
199:                if (muleContext != null) {
200:                    muleContext.fireNotification(notification);
201:                } else if (logger.isDebugEnabled()) {
202:                    logger
203:                            .debug("MuleContext is not yet available for firing notifications, ignoring event: "
204:                                    + notification);
205:                }
206:            }
207:
208:            public void setMuleContext(MuleContext context) {
209:                this.muleContext = context;
210:            }
211:
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.