Source Code Cross Referenced for BaseService.java in  » ERP-CRM-Financial » ofbiz » org » ofbiz » pos » jpos » service » 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 » ERP CRM Financial » ofbiz » org.ofbiz.pos.jpos.service 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         *******************************************************************************/package org.ofbiz.pos.jpos.service;
019:
020:        import java.util.ArrayList;
021:        import java.util.List;
022:        import java.util.Iterator;
023:
024:        import jpos.services.EventCallbacks;
025:        import jpos.JposException;
026:        import jpos.JposConst;
027:        import jpos.events.DataEvent;
028:        import jpos.events.ErrorEvent;
029:        import jpos.events.DirectIOEvent;
030:        import jpos.events.OutputCompleteEvent;
031:        import jpos.events.StatusUpdateEvent;
032:        import jpos.config.JposEntry;
033:
034:        public class BaseService implements  jpos.services.BaseService,
035:                jpos.loader.JposServiceInstance {
036:
037:            public static final String module = BaseService.class.getName();
038:            protected static boolean claimed = false;
039:
040:            protected List eventQueue = new ArrayList();
041:            protected JposEntry entry = null;
042:
043:            protected boolean freezeEvents = false;
044:            protected boolean deviceEnabled = false;
045:            protected boolean eventsEnabled = true;
046:
047:            protected String deviceName = null;
048:            protected String healthText = null;
049:            protected String physicalName = null;
050:            protected String physicalDesc = null;
051:            protected String serviceDesc = null;
052:
053:            protected int serviceVer = 1007000;
054:            protected int state = JposConst.JPOS_S_CLOSED;
055:
056:            private EventCallbacks ecb = null;
057:
058:            // open/close methods
059:            public void open(String deviceName, EventCallbacks ecb)
060:                    throws JposException {
061:                this .deviceName = deviceName;
062:                this .ecb = ecb;
063:                this .healthText = "OK";
064:                this .state = JposConst.JPOS_S_IDLE;
065:                this .serviceDesc = entry.getProp(
066:                        JposEntry.DEVICE_CATEGORY_PROP_NAME).getValueAsString();
067:                this .physicalDesc = entry.getProp(
068:                        JposEntry.PRODUCT_DESCRIPTION_PROP_NAME)
069:                        .getValueAsString();
070:                this .physicalName = entry.getProp(
071:                        JposEntry.PRODUCT_NAME_PROP_NAME).getValueAsString();
072:            }
073:
074:            public void claim(int i) throws JposException {
075:                BaseService.claimed = true;
076:            }
077:
078:            public void release() throws JposException {
079:                BaseService.claimed = false;
080:            }
081:
082:            public void close() throws JposException {
083:                BaseService.claimed = false;
084:                this .freezeEvents = false;
085:                this .deviceEnabled = false;
086:                this .ecb = null;
087:                this .healthText = "CLOSED";
088:                this .state = JposConst.JPOS_S_CLOSED;
089:            }
090:
091:            // field methods
092:            public String getCheckHealthText() throws JposException {
093:                return this .healthText;
094:            }
095:
096:            public boolean getClaimed() throws JposException {
097:                return BaseService.claimed;
098:            }
099:
100:            public int getDataCount() throws JposException {
101:                return this .eventQueue.size();
102:            }
103:
104:            public boolean getDataEventEnabled() throws JposException {
105:                return this .eventsEnabled;
106:            }
107:
108:            public void setDataEventEnabled(boolean b) throws JposException {
109:                boolean fireEvents = false;
110:                if (!this .eventsEnabled && b) {
111:                    fireEvents = true;
112:                }
113:                this .eventsEnabled = b;
114:
115:                if (fireEvents) {
116:                    this .fireQueuedEvents();
117:                }
118:            }
119:
120:            public boolean getDeviceEnabled() throws JposException {
121:                return this .deviceEnabled;
122:            }
123:
124:            public void setDeviceEnabled(boolean b) throws JposException {
125:                this .deviceEnabled = b;
126:            }
127:
128:            public String getDeviceServiceDescription() throws JposException {
129:                return this .serviceDesc;
130:            }
131:
132:            public int getDeviceServiceVersion() throws JposException {
133:                return this .serviceVer;
134:            }
135:
136:            public boolean getFreezeEvents() throws JposException {
137:                return this .freezeEvents;
138:            }
139:
140:            public void setFreezeEvents(boolean b) throws JposException {
141:                this .freezeEvents = b;
142:            }
143:
144:            public String getPhysicalDeviceDescription() throws JposException {
145:                return this .physicalDesc;
146:            }
147:
148:            public String getPhysicalDeviceName() throws JposException {
149:                return this .physicalName;
150:            }
151:
152:            public int getState() throws JposException {
153:                return this .state;
154:            }
155:
156:            public void checkHealth(int i) throws JposException {
157:                // This method is not used since there is no physical device to check
158:            }
159:
160:            public void directIO(int i, int[] ints, Object o)
161:                    throws JposException {
162:                // This method is not used since there is no physical IO to be performed
163:            }
164:
165:            public void setEntry(JposEntry entry) {
166:                this .entry = entry;
167:            }
168:
169:            // JposServiceInstance
170:            public void deleteInstance() throws JposException {
171:                // TODO: Implement Me!
172:            }
173:
174:            protected void fireEvent(Object ev) {
175:                if (this .eventsEnabled && this .ecb != null) {
176:                    if (ev instanceof  DataEvent) {
177:                        this .ecb.fireDataEvent((DataEvent) ev);
178:                    } else if (ev instanceof  DirectIOEvent) {
179:                        this .ecb.fireDirectIOEvent((DirectIOEvent) ev);
180:                    } else if (ev instanceof  DirectIOEvent) {
181:                        this .ecb.fireErrorEvent((ErrorEvent) ev);
182:                    } else if (ev instanceof  DirectIOEvent) {
183:                        this .ecb
184:                                .fireOutputCompleteEvent((OutputCompleteEvent) ev);
185:                    } else if (ev instanceof  DirectIOEvent) {
186:                        this .ecb.fireStatusUpdateEvent((StatusUpdateEvent) ev);
187:                    }
188:                } else {
189:                    this .eventQueue.add(ev);
190:                }
191:            }
192:
193:            private void fireQueuedEvents() {
194:                List queuedList = new ArrayList(eventQueue);
195:                this .eventQueue = new ArrayList();
196:                Iterator i = queuedList.iterator();
197:
198:                while (i.hasNext()) {
199:                    Object obj = i.next();
200:                    i.remove();
201:                    this.fireEvent(obj);
202:                }
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.