Source Code Cross Referenced for ServiceUnitInfo.java in  » ESB » open-esb » com » sun » jbi » ui » common » 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 » open esb » com.sun.jbi.ui.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)ServiceUnitInfo.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.ui.common;
030:
031:        import com.sun.jbi.ui.common.ServiceAssemblyDD.ServiceUnitDD;
032:        import java.io.PrintWriter;
033:        import java.io.StringWriter;
034:        import java.util.ArrayList;
035:        import java.util.Collections;
036:        import java.util.Comparator;
037:        import java.util.List;
038:        import org.w3c.dom.Element;
039:        import org.w3c.dom.NodeList;
040:
041:        /** This class represents the ServiceUnitInfo in the service assembly info list xml
042:         *
043:         * @author Sun Microsystems, Inc.
044:         */
045:        public class ServiceUnitInfo {
046:
047:            /** status  Unknown.  */
048:            public static final String UNKNOWN_STATE = "Unknown";
049:            /** status Deployed. */
050:            public static final String SHUTDOWN_STATE = "Shutdown";
051:            /** status Deployed. */
052:            public static final String STARTED_STATE = "Started";
053:            /** status Deployed. */
054:            public static final String STOPPED_STATE = "Stopped";
055:
056:            /**
057:             * Holds value of property name.
058:             */
059:            private String mName;
060:
061:            /**
062:             * Holds value of property description.
063:             */
064:            private String mDescription;
065:
066:            /**
067:             * Holds value of property targetId.
068:             */
069:            private String mDeployedOn;
070:
071:            /**
072:             * Holds value of property state.
073:             */
074:            private String mState;
075:
076:            /** Creates a new instance of JBIComponentInfo */
077:            public ServiceUnitInfo() {
078:                this ("", "", "", UNKNOWN_STATE);
079:            }
080:
081:            /**
082:             * Creates a new instance of SunAssemblyInfo
083:             * @param deployedOn deployedOn.
084:             * @param state state.
085:             * @param name name
086:             * @param description description
087:             */
088:            public ServiceUnitInfo(String name, String description,
089:                    String deployedOn, String state) {
090:                this .mName = name;
091:                this .mDescription = description;
092:                this .mDeployedOn = deployedOn;
093:                this .mState = state;
094:            }
095:
096:            /**
097:             * Getter for property aliasName.
098:             * @return Value of property aliasName.
099:             */
100:            public String getName() {
101:                return this .mName;
102:            }
103:
104:            /**
105:             * Setter for property aliasName.
106:             * @param name New value of property aliasName.
107:             */
108:            public void setName(String name) {
109:                this .mName = name;
110:            }
111:
112:            /**
113:             * Getter for property description.
114:             * @return Value of property description.
115:             */
116:            public String getDescription() {
117:                return this .mDescription;
118:            }
119:
120:            /**
121:             * Setter for property description.
122:             * @param description New value of property description.
123:             */
124:            public void setDescription(String description) {
125:                this .mDescription = description;
126:            }
127:
128:            /**
129:             * Getter for property targetId.
130:             * @return Value of property targetId.
131:             */
132:            public String getTargetName() {
133:                return this .getDeployedOn();
134:            }
135:
136:            /**
137:             * Getter for property targetId.
138:             * @return Value of property targetId.
139:             */
140:            public String getDeployedOn() {
141:                return this .mDeployedOn;
142:            }
143:
144:            /**
145:             * Setter for property targetId.
146:             * @param deployedOn deployedOn.
147:             */
148:            public void setDeployedOn(String deployedOn) {
149:                this .mDeployedOn = deployedOn;
150:            }
151:
152:            /**
153:             * Getter for property state.
154:             * @return Value of property state.
155:             */
156:            public String getState() {
157:                return this .mState;
158:            }
159:
160:            /**
161:             * Setter for property status.
162:             * @param state status
163:             */
164:            public void setState(String state) {
165:                this .mState = state;
166:            }
167:
168:            /** string value
169:             * @return string value
170:             */
171:            public String toString() {
172:                return "Name = " + this .getName() + "\nDescription = "
173:                        + this .getDescription() + "\nState = "
174:                        + this .getState() + "\nDeployed On = "
175:                        + this .getDeployedOn();
176:
177:            }
178:
179:            /** xml text
180:             * @return xml text
181:             */
182:            public String toXmlString() {
183:                return "<service-unit-info \n" + "name=\"" + this .getName()
184:                        + "\" \n" + "state=\"" + this .getState() + "\" \n"
185:                        + "deployed-on=\"" + this .getDeployedOn() + "\" >\n"
186:                        + "<description>" + this .getDescription()
187:                        + "</description> \n" + "</service-unit-info>";
188:            }
189:
190:            /**
191:             * return sub assembly info object
192:             * @return object
193:             * @param suInfoEl xml element.
194:             */
195:            public static ServiceUnitInfo createServiceUnitInfo(Element suInfoEl) {
196:
197:                ServiceUnitInfo info = new ServiceUnitInfo();
198:
199:                if (suInfoEl == null) {
200:                    return null;
201:                }
202:
203:                String name = suInfoEl.getAttribute("name");
204:                info.setName(name);
205:
206:                String state = suInfoEl.getAttribute("state");
207:                info.setState(state);
208:
209:                String deployedOn = suInfoEl.getAttribute("deployed-on");
210:                info.setDeployedOn(deployedOn);
211:
212:                String desc = null;
213:                Element descEl = DOMUtil.UTIL.getElement(suInfoEl,
214:                        "description");
215:                if (descEl != null) {
216:                    desc = DOMUtil.UTIL.getTextData(descEl);
217:                }
218:                info.setDescription(desc);
219:
220:                return info;
221:            }
222:
223:            /**
224:             * return component info object
225:             * @return object
226:             * @param suInfoElList xml element.
227:             */
228:            public static List createServiceUnitInfoList(NodeList suInfoElList) {
229:                ArrayList suInfoList = new ArrayList();
230:
231:                if (suInfoElList == null) {
232:                    return suInfoList; // return empty list
233:                }
234:
235:                int size = suInfoElList.getLength();
236:
237:                for (int i = 0; i < size; ++i) {
238:                    Element suInfoEl = (Element) suInfoElList.item(i);
239:                    if (suInfoEl != null) {
240:                        ServiceUnitInfo suInfo = createServiceUnitInfo(suInfoEl);
241:                        suInfoList.add(suInfo);
242:                    }
243:                }
244:
245:                ServiceUnitInfo.sort(suInfoList);
246:                return suInfoList;
247:
248:            }
249:
250:            /**
251:             * write to xml text
252:             * @return xml text
253:             * @param suInfoList xml element.
254:             */
255:            public static String writeAsXmlText(List suInfoList) {
256:                StringWriter stringWriter = new StringWriter();
257:                PrintWriter writer = new PrintWriter(stringWriter, true);
258:                if (suInfoList != null) {
259:                    int size = suInfoList.size();
260:                    for (int i = 0; i < size; ++i) {
261:                        ServiceUnitInfo info = (ServiceUnitInfo) suInfoList
262:                                .get(i);
263:                        writer.println(info.toXmlString());
264:                    }
265:                }
266:                try {
267:                    writer.close();
268:                    stringWriter.close();
269:                } catch (Exception ex) {
270:                    // ignore as it will never happen for strings unless runtime exp as mem exp
271:                }
272:                return stringWriter.toString();
273:            }
274:
275:            /**
276:             * creates the info from jbi.xml
277:             * @return info object
278:             * @param suDD su dd.
279:             */
280:            public static ServiceUnitInfo createFromServiceUnitDD(
281:                    ServiceUnitDD suDD) {
282:
283:                ServiceUnitInfo suInfo = new ServiceUnitInfo();
284:
285:                suInfo.setName(suDD.getName());
286:                suInfo.setDescription(suDD.getDescription());
287:                suInfo.setDeployedOn(suDD.getTargetName());
288:
289:                return suInfo;
290:            }
291:
292:            /**
293:             * sorts list.
294:             * @param suInfoList su info list.
295:             */
296:            public static void sort(List suInfoList) {
297:                try {
298:                    Collections.sort(suInfoList, new Comparator() {
299:                        public int compare(Object o1, Object o2) {
300:                            return ((ServiceUnitInfo) o1).getName().compareTo(
301:                                    ((ServiceUnitInfo) o2).getName());
302:                        }
303:                    });
304:                } catch (ClassCastException ccEx) {
305:                    // log and
306:                    // do nothing.
307:                } catch (UnsupportedOperationException unsupEx) {
308:                    // log and 
309:                    // do nothing.
310:                }
311:            }
312:
313:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.