Source Code Cross Referenced for FileBindingLifeCycle.java in  » Workflow-Engines » Dalma » com » sun » jbi » binding » file » 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 » Workflow Engines » Dalma » com.sun.jbi.binding.file 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (c) 2004-2005 Sun Microsystems Inc., All Rights Reserved.
002:
003:        /*
004:         * FileBindingLifeCycle.java
005:         * SUN PROPRIETARY/CONFIDENTIAL.
006:         * This software is the proprietary information of Sun Microsystems, Inc.
007:         * Use is subject to license terms.
008:         *
009:         */
010:        package com.sun.jbi.binding.file;
011:
012:        import com.sun.jbi.binding.file.util.ConfigData;
013:        import com.sun.jbi.binding.file.util.ConfigReader;
014:        import com.sun.jbi.binding.file.util.StringTranslator;
015:
016:        import java.io.File;
017:
018:        import java.util.logging.Logger;
019:
020:        import javax.jbi.component.ComponentContext;
021:        import javax.jbi.messaging.DeliveryChannel;
022:        import javax.jbi.messaging.MessagingException;
023:
024:        /**
025:         * This is the Lifecycle class of the File Binding.  The init and the start()
026:         * methods of this class  are invoked by  the framework when the component  is
027:         * started
028:         *
029:         * @author Sun Microsystems, Inc.
030:         */
031:        public class FileBindingLifeCycle implements 
032:                javax.jbi.component.ComponentLifeCycle, FileBindingResources {
033:            /**
034:             * Binding context.
035:             */
036:            private ComponentContext mContext = null;
037:
038:            /**
039:             * Binding Channel Object
040:             */
041:            private DeliveryChannel mChannel;
042:
043:            /**
044:             * Deployment registry.
045:             */
046:            private DeploymentRegistry mRegistry;
047:
048:            /**
049:             * Manages the endpoints.
050:             */
051:            private EndpointManager mManager;
052:
053:            /**
054:             * Resolver object.
055:             */
056:            private FileBindingResolver mResolver;
057:
058:            /**
059:             * Deployer object.
060:             */
061:            private FileBindingSUManager mSUManager;
062:
063:            /**
064:             * File receiver object for receiving messages from NMS.
065:             */
066:            private FileReceiver mFileReceiver;
067:
068:            /**
069:             * Logger Object
070:             */
071:            private Logger mLog;
072:
073:            /**
074:             * Helper for i18n.
075:             */
076:            private StringTranslator mTranslator;
077:
078:            /**
079:             * Thread for file receiver.
080:             */
081:            private Thread mReceiverThread;
082:
083:            /**
084:             * Flag to hold the result of init
085:             */
086:            private boolean mInitSuccess = false;
087:
088:            /**
089:             * Get the ObjectName for any MBean that is provided for managing this
090:             * binding. In this case, there is none, so a null is returned.
091:             *
092:             * @return ObjectName is always null.
093:             */
094:            public javax.management.ObjectName getExtensionMBeanName() {
095:                return null;
096:            }
097:
098:            /**
099:             * Sets the resolver.
100:             *
101:             * @param resolver resolver object.
102:             */
103:            public void setResolver(FileBindingResolver resolver) {
104:                mResolver = resolver;
105:            }
106:
107:            /**
108:             * Sets the SU Manager.
109:             *
110:             * @param manager su manager.
111:             */
112:            public void setSUManager(FileBindingSUManager manager) {
113:                mSUManager = manager;
114:            }
115:
116:            /**
117:             * Initialize the File BC. This performs initialization required by the
118:             * File BC but does not make it ready to process messages.  This method is
119:             * called immediately after installation of the File BC.  It is also
120:             * called when the JBI framework is starting up, and any time  the BC is
121:             * being restarted after previously being shut down through  a call to
122:             * shutdown().
123:             *
124:             * @param jbiContext the JBI environment context
125:             *
126:             * @throws javax.jbi.JBIException if the BC is unable to initialize.
127:             */
128:            public void init(javax.jbi.component.ComponentContext jbiContext)
129:                    throws javax.jbi.JBIException {
130:                FileBindingContext fbccontext = FileBindingContext
131:                        .getInstance();
132:                fbccontext.setContext(jbiContext);
133:
134:                Logger logger = jbiContext.getLogger("binding.file", null);
135:                fbccontext.setLogger(logger);
136:
137:                // jbiContext.
138:                mLog = fbccontext.getLogger();
139:                mTranslator = new StringTranslator();
140:                mLog.info(mTranslator.getString(FBC_INIT_START));
141:
142:                if (null == jbiContext) {
143:                    throw new javax.jbi.JBIException(mTranslator
144:                            .getString(FBC_INVALID_BINDINGCONTEXT));
145:                }
146:
147:                mContext = jbiContext;
148:
149:                try {
150:                    mManager = new EndpointManager();
151:                    mSUManager.setValues(mManager, mResolver);
152:                } catch (Exception e) {
153:                    e.printStackTrace();
154:                    throw new javax.jbi.JBIException(mTranslator
155:                            .getString(FBC_INIT_FAILED), e);
156:                }
157:
158:                try {
159:                    mRegistry = DeploymentRegistry.getInstance();
160:                } catch (Exception e) {
161:                    e.printStackTrace();
162:                }
163:
164:                /* This a guard variable to check if init is a success
165:                 * Nothing should be done in start in case init is a failure
166:                 */
167:                mInitSuccess = true;
168:            }
169:
170:            /**
171:             * Shutdown the BC. This performs cleanup before the BC is terminated. Once
172:             * this has been called, init() must be called before the BC can be
173:             * started again with a call to start().
174:             *
175:             * @throws javax.jbi.JBIException if the BC is unable to shut down.
176:             */
177:            public void shutDown() throws javax.jbi.JBIException {
178:                mLog.info(mTranslator.getString(FBC_SHUTDOWN_BEGIN));
179:                mSUManager = null;
180:                mRegistry.clearRegistry();
181:                mLog.info(mTranslator.getString(FBC_SHUTDOWN_END));
182:            }
183:
184:            /**
185:             * Start the File BC. This makes the File BC ready to process messages.
186:             * This method is called after init() completes when the JBI framework is
187:             * starting up, and when the BC is being restarted after a previous call
188:             * to shutdown(). If stop() was called previously but shutdown() was not,
189:             * start() can be called without a call to init().
190:             *
191:             * @throws javax.jbi.JBIException if the BC is unable to start.
192:             */
193:            public void start() throws javax.jbi.JBIException {
194:                mLog.info(mTranslator.getString(FBC_START_BEGIN));
195:
196:                if (!mInitSuccess) {
197:                    mLog.severe(mTranslator.getString(FBC_INIT_FAILED));
198:
199:                    return;
200:                }
201:
202:                String compRoot = mContext.getInstallRoot();
203:                String schemaFile = compRoot + File.separatorChar
204:                        + ConfigData.SCHEMA_FILE;
205:
206:                if (compRoot == null) {
207:                    mLog.severe(mTranslator.getString(FBC_INVALID_COMPROOT));
208:
209:                    return;
210:                }
211:
212:                try {
213:                    mChannel = mContext.getDeliveryChannel();
214:
215:                    //mChannel.setResolver(mResolver);
216:                } catch (MessagingException me) {
217:                    mLog.severe(mTranslator
218:                            .getString(FBC_BINDINGCHANNEL_FAILED)
219:                            + me.getMessage());
220:
221:                    return;
222:                }
223:
224:                mFileReceiver = new FileReceiver(mChannel);
225:                mReceiverThread = new Thread(mFileReceiver);
226:                mReceiverThread.start();
227:                mLog.info(mTranslator.getString(FBC_START_END));
228:            }
229:
230:            /**
231:             * Stop the BC. This makes the BC stop accepting messages for processing.
232:             * After a call to this method, start() can be called again without first
233:             * calling init().
234:             *
235:             * @throws javax.jbi.JBIException if the BC is unable to stop.
236:             */
237:            public void stop() throws javax.jbi.JBIException {
238:                mLog.info(mTranslator.getString(FBC_STOP_BEGIN));
239:
240:                try {
241:                    if (mReceiverThread != null) {
242:                        mFileReceiver.stopReceiving();
243:                        mReceiverThread.interrupt();
244:                        mReceiverThread.join();
245:                    }
246:
247:                    if (mChannel != null) {
248:                        mChannel.close();
249:                    }
250:                } catch (Exception e) {
251:                    e.printStackTrace();
252:                }
253:
254:                mLog.info(mTranslator.getString(FBC_STOP_END));
255:            }
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.