Source Code Cross Referenced for Admin.java in  » Workflow-Engines » bexee » bexee » admin » 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 » bexee » bexee.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: Admin.java,v 1.20 2004/12/09 12:34:44 kowap Exp $
003:         *
004:         * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
005:         * Berne University of Applied Sciences
006:         * School of Engineering and Information Technology
007:         * All rights reserved.
008:         */
009:        package bexee.admin;
010:
011:        import java.io.ByteArrayOutputStream;
012:        import java.io.File;
013:        import java.io.FileInputStream;
014:        import java.io.FileNotFoundException;
015:        import java.io.IOException;
016:        import java.io.InputStream;
017:        import java.rmi.RemoteException;
018:        import java.util.ArrayList;
019:        import java.util.Iterator;
020:        import java.util.List;
021:
022:        import javax.xml.rpc.ParameterMode;
023:        import javax.xml.rpc.ServiceException;
024:
025:        import org.apache.axis.client.Call;
026:        import org.apache.axis.client.Service;
027:        import org.apache.axis.encoding.XMLType;
028:        import org.apache.commons.io.CopyUtils;
029:        import org.apache.commons.logging.Log;
030:        import org.apache.commons.logging.LogFactory;
031:
032:        import bexee.util.BexeeProperties;
033:        import bexee.util.Constants;
034:
035:        /**
036:         * This class acts as a convenient Java front-end for the
037:         * {@link bexee.admin.Manager}class instead of calling the <code>Manager</code>
038:         * web service directly.
039:         * 
040:         * @version $Revision: 1.20 $, $Date: 2004/12/09 12:34:44 $
041:         * @author Patric Fornasier
042:         * @author Pawel Kowalski
043:         */
044:        public class Admin {
045:
046:            private static Log log = LogFactory.getLog(Admin.class);
047:
048:            private String url;
049:
050:            /**
051:             * Create an instance of the <code>Admin</code>
052:             *  
053:             */
054:            public Admin() {
055:                this .url = BexeeProperties.getProperty(
056:                        Constants.OPT_MANAGER_URL,
057:                        Constants.OPT_MANAGER_URL_DEF);
058:            }
059:
060:            /**
061:             * Create an instance of the <code>Admin</code> with a give
062:             * <code>URL</code> where bexee is located.
063:             * 
064:             * @param url
065:             *            bexee location
066:             */
067:            public Admin(String url) {
068:                this .url = url;
069:            }
070:
071:            /**
072:             * Deploy a BPEL business process together with its WSDL.
073:             * 
074:             * @param bpel
075:             *            BPEL document
076:             * @param wsdl
077:             *            WSDL description
078:             * @return @throws
079:             *         AdminException
080:             */
081:            public String deploy(File bpel, File wsdl) throws AdminException {
082:                return deploy(bpel, wsdl, new ArrayList());
083:            }
084:
085:            /**
086:             * Deploy a BPEL business process together with its WSDL.
087:             * 
088:             * @param bpel
089:             *            BPEL document stream
090:             * @param wsdl
091:             *            WSDL description stream
092:             * @return @throws
093:             *         AdminException
094:             */
095:            public String deploy(InputStream bpel, InputStream wsdl)
096:                    throws AdminException {
097:                return deploy(bpel, wsdl, new ArrayList());
098:            }
099:
100:            /**
101:             * Deploy a BPEL business process together with its WSDL and one partner
102:             * WSDL description.
103:             * 
104:             * @param bpel
105:             *            BPEL document
106:             * @param wsdl
107:             *            WSDL description
108:             * @param partnerWSDL
109:             *            partner WSDL description
110:             * @return @throws
111:             *         AdminException
112:             */
113:            public String deploy(File bpel, File wsdl, File partnerWSDL)
114:                    throws AdminException {
115:                List list = new ArrayList();
116:                list.add(partnerWSDL);
117:
118:                return deploy(bpel, wsdl, list);
119:            }
120:
121:            /**
122:             * Deploy a BPEL business process together with its WSDL and its partner
123:             * WSDL descriptions.
124:             * 
125:             * @param bpel
126:             *            BPEL document
127:             * @param wsdl
128:             *            WSDL description
129:             * @param partnerWSDL
130:             *            partner WSDL descriptions
131:             * @return @throws
132:             *         AdminException
133:             */
134:            public String deploy(File bpel, File wsdl, List partnerWSDL)
135:                    throws AdminException {
136:
137:                InputStream bpelIs = null;
138:                InputStream wsdlIs = null;
139:                List list = null;
140:
141:                try {
142:                    bpelIs = new FileInputStream(bpel);
143:                    wsdlIs = new FileInputStream(wsdl);
144:                    list = new ArrayList();
145:                    for (Iterator iter = partnerWSDL.iterator(); iter.hasNext();) {
146:                        File file = (File) iter.next();
147:                        list.add(new FileInputStream(file));
148:                    }
149:                } catch (FileNotFoundException e) {
150:                    throw new AdminException("Unable to locate files", e);
151:                }
152:
153:                return deploy(bpelIs, wsdlIs, list);
154:            }
155:
156:            /**
157:             * Deploys a new BPEL process to bexee.
158:             * 
159:             * @see #deploy(InputStream, InputStream, List)
160:             */
161:            public String deploy(InputStream bpel, InputStream wsdl,
162:                    InputStream partnerWSDL) throws AdminException {
163:
164:                List list = new ArrayList();
165:                list.add(partnerWSDL);
166:
167:                return deploy(bpel, wsdl, list);
168:            }
169:
170:            /**
171:             * Deploys a new BPEL process to bexee.This method will invoke the
172:             * <code>Manager</code> web service and pass it the documents.
173:             * 
174:             * @param bpel
175:             * @param wsdl
176:             * @param partnerWSDL
177:             * @return @throws
178:             *         AdminException
179:             */
180:            public String deploy(InputStream bpel, InputStream wsdl,
181:                    List partnerWSDL) throws AdminException {
182:
183:                String[] input = null;
184:                String output = null;
185:
186:                // build call
187:                Call call = createCall("deploy");
188:                call
189:                        .addParameter("input", XMLType.SOAP_ARRAY,
190:                                ParameterMode.IN);
191:                call.setReturnType(XMLType.XSD_STRING);
192:
193:                // build input parameter
194:                try {
195:                    input = buildInputArray(bpel, wsdl, partnerWSDL);
196:                } catch (IOException e) {
197:                    throw new AdminException("Unable to get all input data", e);
198:                }
199:
200:                // invoke service
201:                try {
202:                    output = (String) call.invoke(new Object[] { input });
203:                } catch (RemoteException e) {
204:                    throw new AdminException(
205:                            "Error on invoking Manager deploy()", e);
206:                }
207:
208:                return output;
209:            }
210:
211:            /**
212:             * Undeploys an existing service
213:             * 
214:             * @param name
215:             *            the name of the service to be undeployed
216:             * @return the message from the Manager service
217:             * @throws AdminException
218:             *             if something went wrong
219:             * @see {@link Manager}
220:             */
221:            public String undeploy(String name) throws AdminException {
222:
223:                String[] input = null;
224:                String output = null;
225:
226:                // build call
227:                Call call = createCall("undeploy");
228:                call
229:                        .addParameter("input", XMLType.XSD_STRING,
230:                                ParameterMode.IN);
231:                call.setReturnType(XMLType.XSD_STRING);
232:
233:                // invoke service
234:                try {
235:                    output = (String) call.invoke(new Object[] { name });
236:                } catch (RemoteException e) {
237:                    throw new AdminException(
238:                            "Error on invoking Manager undeploy()", e);
239:                }
240:
241:                return output;
242:            }
243:
244:            /**
245:             * Create Axis call to service.
246:             * 
247:             * @return a <code>Call</code> object
248:             * @throws AdminException
249:             *             if the <code>Call</code> can not be created
250:             */
251:            protected Call createCall(String operation) throws AdminException {
252:
253:                if (url == null) {
254:                    throw new AdminException(
255:                            "No url to Manager service provided");
256:                }
257:
258:                // create service and call
259:                Service service = new Service();
260:                Call call;
261:                try {
262:                    call = (Call) service.createCall();
263:                } catch (ServiceException e) {
264:                    throw new AdminException("Unable to create Call", e);
265:                }
266:                call.setTargetEndpointAddress(url);
267:                call.setOperation(operation);
268:                return call;
269:            }
270:
271:            protected String[] buildInputArray(InputStream bpel,
272:                    InputStream wsdl, List partnerWSDL) throws IOException {
273:
274:                int length = partnerWSDL == null ? 2 : partnerWSDL.size() + 2;
275:                String[] result = new String[length];
276:
277:                result[0] = getString(bpel);
278:                result[1] = getString(wsdl);
279:
280:                for (int i = 0, j = 2; i < partnerWSDL.size(); i++, j++) {
281:                    InputStream is = (InputStream) partnerWSDL.get(i);
282:                    result[j] = getString(is);
283:                }
284:
285:                return result;
286:            }
287:
288:            /**
289:             * Copies an <code>InputStream</code> into a <code>String</code>.
290:             * 
291:             * @param is
292:             *            the <code>InputStream</code> to be read from.
293:             * @return a <code>String</code>
294:             * @throws IOException
295:             *             in case of an I/O problem
296:             */
297:            protected String getString(InputStream is) throws IOException {
298:
299:                ByteArrayOutputStream out = new ByteArrayOutputStream();
300:                CopyUtils.copy(is, out);
301:                return out.toString();
302:            }
303:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.