Source Code Cross Referenced for BaseServiceImpl.java in  » ESB » open-esb » com » sun » esb » management » base » services » 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.esb.management.base.services 
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:         * @(#)BaseServiceImpl.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:
030:        package com.sun.esb.management.base.services;
031:
032:        import java.io.File;
033:        import java.io.Serializable;
034:
035:        import javax.management.MBeanServerConnection;
036:
037:        import com.sun.esb.management.common.ManagementRemoteException;
038:        import com.sun.jbi.ui.common.FileTransferManager;
039:        import com.sun.jbi.ui.common.JBIResultXmlBuilder;
040:
041:        /**
042:         * Common methods for uploading and downloading files
043:         * 
044:         * @author graj
045:         */
046:        public abstract class BaseServiceImpl extends AbstractServiceImpl
047:                implements  Serializable {
048:
049:            private static final long serialVersionUID = -1L;
050:
051:            /** last uploaded object reference */
052:            protected Object mLastUploadId = null;
053:
054:            /** Constructor - Constructs a new instance of AbstractServiceImpl */
055:            public BaseServiceImpl() {
056:                super (null, false);
057:            }
058:
059:            /**
060:             * Constructor - Constructs a new instance of AbstractServiceImpl
061:             * 
062:             * @param serverConnection
063:             */
064:            public BaseServiceImpl(MBeanServerConnection serverConnection) {
065:                super (serverConnection, false);
066:            }
067:
068:            /**
069:             * Constructor - Constructs a new instance of AbstractServiceImpl
070:             * 
071:             * @param serverConnection
072:             * @param isRemoteConnection
073:             */
074:            public BaseServiceImpl(MBeanServerConnection serverConnection,
075:                    boolean isRemoteConnection) {
076:                super (serverConnection, isRemoteConnection);
077:            }
078:
079:            /**
080:             * this method uploads the local file to the server using
081:             * FileTransferManager and returns the path to the file on the server's file
082:             * system which can be used to do any operations on the file/file data on
083:             * the server side. This is used to upload components ( se, bc), shared
084:             * library or service assembly archive files to the server for remote
085:             * install/deploy commands.
086:             * 
087:             * @param localFilePath
088:             *            file path on the local file system.
089:             * @return String for file path of the uploaded file on the server file
090:             *         system
091:             * @throws ManagementRemoteException
092:             *             if error or exception occurs.
093:             */
094:            protected String uploadFile(String localFilePath)
095:                    throws ManagementRemoteException {
096:                File uploadFile = new File(localFilePath);
097:                String name = uploadFile.getName();
098:
099:                try {
100:                    FileTransferManager ftpManager = new FileTransferManager(
101:                            this .getMBeanServerConnection());
102:                    String uploadedFilePath = ftpManager
103:                            .uploadArchive(uploadFile);
104:                    this .mLastUploadId = ftpManager.getLastUploadId();
105:                    return uploadedFilePath;
106:                } catch (Exception ex) {
107:                    String jbiMgmtMsg = JBIResultXmlBuilder.createJbiResultXml(
108:                            getI18NBundle(),
109:                            "jbi.ui.client.remote.file.upload.error",
110:                            new Object[] { name }, ex);
111:                    throw new ManagementRemoteException(new Exception(
112:                            jbiMgmtMsg));
113:                } finally {
114:
115:                }
116:            }
117:
118:            /**
119:             * this method tries to remove the last uploaded file on the server. It
120:             * ingores all errrors if it can not remove file as the server will take
121:             * care of removing the files during restarts. Since this call can be called
122:             * any where we need to have local instance of ftmgr to talk to server.
123:             */
124:            protected void removeUploadedFile() {
125:                if (this .mLastUploadId == null) {
126:                    return;
127:                }
128:
129:                try {
130:                    FileTransferManager ftpManager = new FileTransferManager(
131:                            this .getMBeanServerConnection());
132:                    ftpManager.removeUploadedArchive(this .mLastUploadId);
133:                    this .mLastUploadId = null;
134:                } catch (Exception ex) {
135:                    // ignore any exceptions as removing the uploaded file is optional.
136:                } finally {
137:                    this .mLastUploadId = null;
138:                }
139:            }
140:
141:            /**
142:             * this method downloads a file from the server
143:             * @param dir  dir to download the file into
144:             * @param serverFilePath the file path in the server
145:             * @returns String the name of the downloaded file
146:             * @throws ManagementRemoteException
147:             *             if error or exception occurs.
148:             */
149:            public String downloadFile(String dir, String serverFilePath)
150:                    throws ManagementRemoteException {
151:                try {
152:                    FileTransferManager ftpManager = new FileTransferManager(
153:                            this .getMBeanServerConnection());
154:                    String fileName = new File(serverFilePath).getName();
155:                    ftpManager.downloadArchive(serverFilePath, new File(dir,
156:                            fileName));
157:                    return fileName;
158:                } catch (Exception ex) {
159:                    String jbiMgmtMsg = JBIResultXmlBuilder.createJbiResultXml(
160:                            getI18NBundle(),
161:                            "jbi.ui.client.remote.file.download.error",
162:                            new Object[] { serverFilePath }, ex);
163:                    throw new ManagementRemoteException(new Exception(
164:                            jbiMgmtMsg));
165:                } finally {
166:
167:                }
168:            }
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.