Source Code Cross Referenced for CreateGenericWsConnection.java in  » Groupware » LibreSource » org » libresource » so6 » core » exec » 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 » Groupware » LibreSource » org.libresource.so6.core.exec 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * LibreSource
003:         * Copyright (C) 2004-2008 Artenum SARL / INRIA
004:         * http://www.libresource.org - contact@artenum.com
005:         *
006:         * This file is part of the LibreSource software, 
007:         * which can be used and distributed under license conditions.
008:         * The license conditions are provided in the LICENSE.TXT file 
009:         * at the root path of the packaging that enclose this file. 
010:         * More information can be found at 
011:         * - http://dev.libresource.org/home/license
012:         *
013:         * Initial authors :
014:         *
015:         * Guillaume Bort / INRIA
016:         * Francois Charoy / Universite Nancy 2
017:         * Julien Forest / Artenum
018:         * Claude Godart / Universite Henry Poincare
019:         * Florent Jouille / INRIA
020:         * Sebastien Jourdain / INRIA / Artenum
021:         * Yves Lerumeur / Artenum
022:         * Pascal Molli / Universite Henry Poincare
023:         * Gerald Oster / INRIA
024:         * Mariarosa Penzi / Artenum
025:         * Gerard Sookahet / Artenum
026:         * Raphael Tani / INRIA
027:         *
028:         * Contributors :
029:         *
030:         * Stephane Bagnier / Artenum
031:         * Amadou Dia / Artenum-IUP Blois
032:         * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033:         */package org.libresource.so6.core.exec;
034:
035:        import org.libresource.so6.core.Workspace;
036:        import org.libresource.so6.core.WsConnection;
037:        import org.libresource.so6.core.client.AuthenticationException;
038:        import org.libresource.so6.core.client.ClientI;
039:        import org.libresource.so6.core.client.LocalException;
040:        import org.libresource.so6.core.client.ServerException;
041:        import org.libresource.so6.core.client.UnableToContactServerException;
042:        import org.libresource.so6.core.engine.Ignore;
043:        import org.libresource.so6.core.engine.util.CryptUtil;
044:        import org.libresource.so6.core.net.DataflowClientI;
045:
046:        import java.io.File;
047:        import java.io.FileWriter;
048:        import java.io.IOException;
049:
050:        import java.lang.reflect.Method;
051:
052:        import java.util.Iterator;
053:        import java.util.Properties;
054:
055:        /**
056:         * @author smack
057:         */
058:        public class CreateGenericWsConnection {
059:            public final static String LS_CLIENT_NAME = "org.libresource.so6.core.client.ClientIServletImpl";
060:            public final static String FS_CLIENT_NAME = "org.libresource.so6.core.client.DummyClient";
061:            private Workspace ws;
062:            private WsConnection wsc;
063:            private String wscPath;
064:            private String path;
065:            private String login;
066:            private String password;
067:            private String queueId;
068:            private String wsName;
069:            private String clientName;
070:            private Properties props;
071:
072:            public CreateGenericWsConnection(String basePath, String wsName,
073:                    String clientName, String login, String password,
074:                    String queueId, Properties personalProps) {
075:                this .path = basePath;
076:                this .queueId = queueId;
077:                this .wsName = wsName;
078:                this .login = login;
079:                this .password = password;
080:                this .clientName = clientName;
081:                this .props = personalProps;
082:            }
083:
084:            public String executeLocalCreation() throws IOException,
085:                    LocalException {
086:                ws = Workspace.createWorkspace(path);
087:
088:                Properties prop = new Properties();
089:                prop.setProperty(ClientI.SO6_QUEUE_ID, queueId);
090:                prop.setProperty(ClientI.SO6_LOGIN, "" + login);
091:                prop.setProperty(ClientI.SO6_PASSWORD, CryptUtil.encode(""
092:                        + password));
093:
094:                if (props != null) {
095:                    for (Iterator i = props.keySet().iterator(); i.hasNext();) {
096:                        String key = (String) i.next();
097:                        String value = props.getProperty(key);
098:                        prop.setProperty(key, value);
099:                    }
100:                } else {
101:                    String[] ops;
102:
103:                    try {
104:                        Method m = Class.forName(clientName).getMethod(
105:                                "getInternalPropertyList", new Class[] {});
106:                        ops = (String[]) m.invoke(null, new Object[] {});
107:                    } catch (Exception e) {
108:                        throw new LocalException(e);
109:                    }
110:
111:                    for (int i = 0; i < ops.length; i++) {
112:                        String value = System.getProperties().getProperty(
113:                                ops[i]);
114:
115:                        if (value != null) {
116:                            prop.setProperty(ops[i], value);
117:                        }
118:                    }
119:                }
120:
121:                wscPath = ws.createConnection(prop, clientName, wsName);
122:
123:                return wscPath;
124:            }
125:
126:            public String executeRemoteCreation() throws Exception,
127:                    IOException, LocalException, AuthenticationException,
128:                    ServerException, UnableToContactServerException {
129:                wsc = new WsConnection(wscPath);
130:
131:                if (wsc.getClient() instanceof  DataflowClientI) {
132:                    String wscId = ((DataflowClientI) wsc.getClient())
133:                            .addWsConnection(ws.getId(), queueId, wsName,
134:                                    wscPath).trim();
135:                    wsc.setProperty(DataflowClientI.SO6_CONNECTION_ID, wscId);
136:
137:                    return wscId;
138:                }
139:
140:                return null;
141:            }
142:
143:            public void execute() throws Exception, IOException,
144:                    LocalException, AuthenticationException, ServerException,
145:                    UnableToContactServerException {
146:                execute(null);
147:            }
148:
149:            public void execute(String ignoreFile) throws Exception,
150:                    IOException, LocalException, AuthenticationException,
151:                    ServerException, UnableToContactServerException {
152:                executeLocalCreation();
153:                executeRemoteCreation();
154:
155:                if (ignoreFile != null) {
156:                    FileWriter fw = new FileWriter(wsc.getPath()
157:                            + File.separator + Ignore.ignoreFile);
158:                    fw.write(ignoreFile);
159:                    fw.close();
160:                }
161:            }
162:
163:            /**
164:             * @return Returns the synchronizerURI.
165:             */
166:            public String getQueueId() {
167:                return queueId;
168:            }
169:
170:            /**
171:             * @param synchronizerURI
172:             *            The synchronizerURI to set.
173:             */
174:            public void setQueueId(String queueId) {
175:                this .queueId = queueId;
176:            }
177:
178:            /**
179:             * @return Returns the ws.
180:             */
181:            public Workspace getWs() {
182:                return ws;
183:            }
184:
185:            /**
186:             * @param ws
187:             *            The ws to set.
188:             */
189:            public void setWs(Workspace ws) {
190:                this .ws = ws;
191:            }
192:
193:            /**
194:             * @return Returns the wsc.
195:             */
196:            public WsConnection getWsc() {
197:                return wsc;
198:            }
199:
200:            /**
201:             * @param wsc
202:             *            The wsc to set.
203:             */
204:            public void setWsc(WsConnection wsc) {
205:                this .wsc = wsc;
206:            }
207:
208:            /**
209:             * @return Returns the wscPath.
210:             */
211:            public String getWscPath() {
212:                return wscPath;
213:            }
214:
215:            /**
216:             * @param wscPath
217:             *            The wscPath to set.
218:             */
219:            public void setWscPath(String wscPath) {
220:                this .wscPath = wscPath;
221:            }
222:
223:            /**
224:             * @return Returns the wsName.
225:             */
226:            public String getWsName() {
227:                return wsName;
228:            }
229:
230:            /**
231:             * @param wsName
232:             *            The wsName to set.
233:             */
234:            public void setWsName(String wsName) {
235:                this .wsName = wsName;
236:            }
237:
238:            /**
239:             * @return Returns the clientName.
240:             */
241:            public String getClientName() {
242:                return clientName;
243:            }
244:
245:            /**
246:             * @param clientName
247:             *            The clientName to set.
248:             */
249:            public void setClientName(String clientName) {
250:                this .clientName = clientName;
251:            }
252:
253:            /**
254:             * @return Returns the login.
255:             */
256:            public String getLogin() {
257:                return login;
258:            }
259:
260:            /**
261:             * @param login
262:             *            The login to set.
263:             */
264:            public void setLogin(String login) {
265:                this .login = login;
266:            }
267:
268:            /**
269:             * @return Returns the password.
270:             */
271:            public String getPassword() {
272:                return password;
273:            }
274:
275:            /**
276:             * @param password
277:             *            The password to set.
278:             */
279:            public void setPassword(String password) {
280:                this .password = password;
281:            }
282:
283:            /**
284:             * @return Returns the path.
285:             */
286:            public String getPath() {
287:                return path;
288:            }
289:
290:            /**
291:             * @param path
292:             *            The path to set.
293:             */
294:            public void setPath(String path) {
295:                this .path = path;
296:            }
297:
298:            public static void main(String[] args) throws Exception {
299:                if (args.length != 3) {
300:                    System.err
301:                            .println("Usage: path wsName clientName login password queueId");
302:                    System.err.println(" (1) path: path to share");
303:                    System.err.println(" (2) wsName: workspace name");
304:                    System.err
305:                            .println(" (2) clientName: class name of the client to use");
306:                    System.err.println(" (3) login: ");
307:                    System.err.println(" (4) password: ");
308:                    System.err.println(" (5) queueId: URI or file path");
309:                } else {
310:                    CreateGenericWsConnection ws = new CreateGenericWsConnection(
311:                            args[0], args[1], args[2], args[3], args[4],
312:                            args[5], null);
313:                    ws.execute();
314:                }
315:            }
316:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.