Source Code Cross Referenced for Base64EncoderService.java in  » XML-UI » xui32 » com » xoetrope » 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 » XML UI » xui32 » com.xoetrope.service 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.xoetrope.service;
002:
003:        import java.util.Enumeration;
004:        import java.util.Hashtable;
005:        import net.xoetrope.optional.service.ServiceContext;
006:        import net.xoetrope.optional.service.ServiceProxy;
007:        import net.xoetrope.optional.service.ServiceProxyArgs;
008:        import net.xoetrope.optional.service.ServiceProxyException;
009:        import net.xoetrope.optional.service.XRouteManager;
010:
011:        /**
012:         * Encodes the argument values using Base64 encoding and decodes the response.
013:         *
014:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
015:         * the GNU Public License (GPL), please see license.txt for more details. If
016:         * you make commercial use of this software you must purchase a commercial
017:         * license from Xoetrope.</p>
018:         * <p> $Revision: 1.10 $</p>
019:         */
020:        public class Base64EncoderService extends ServiceProxy {
021:
022:            public static final String ARG_NAME_ENCODEPARAM = "base64encode:encodeparam";
023:            public static final String ARG_NAME_OPERATION = "base64encode:operation";
024:            public static final String ARG_VALUE_SAVE = "base64encode:save";
025:            public static final String ARG_VALUE_OPEN = "base64encode:open";
026:
027:            public Base64EncoderService() {
028:                status = OK;
029:            }
030:
031:            /*public Object call() throws ServiceProxyException
032:            {
033:              try {
034:                return new String( org.apache.commons.codec.binary.Base64.decodeBase64( nextProxy.call().toString().getBytes() ) );
035:              }
036:              catch ( ServiceProxyException e ) {
037:                throw ( e );
038:              }
039:            }*/
040:
041:            /**
042:             * Base64 encodes the data before forwarding it to the next proxy.
043:             * Services should place data 
044:             * they wish to return in the ServiceContext. The RETURN_PARAM is the default
045:             * location for a single return value.
046:             * @return the status of the service call
047:             * @param context The ServiceContext contain pass and return parameters
048:             * @param method the name of the service being called
049:             * @throws net.xoetrope.optional.service.ServiceProxyException Throw an exception if there is a problem with the call
050:             */
051:            public Object call(String method, ServiceContext context)
052:                    throws ServiceProxyException {
053:                try {
054:                    boolean client = (side == XRouteManager.CLIENT_SIDE);
055:                    ServiceProxyArgs args = context.getArgs();
056:                    String operation = (String) args
057:                            .getPassParam(ARG_NAME_OPERATION);
058:                    status = STARTED;
059:
060:                    if (client) {
061:                        if (operation == null) {
062:                            Hashtable passArgs = args.getPassArgs();
063:                            Enumeration passKeys = passArgs.keys();
064:                            while (passKeys.hasMoreElements()) {
065:                                String key = (String) passKeys.nextElement();
066:                                String data = (String) passArgs.get(key);
067:                                args.setPassParam(key, new String(
068:                                        org.apache.catalina.util.Base64
069:                                                .encode(data.getBytes())));
070:                            }
071:                            callNextProxy(method, context, null);
072:                            String resValue = (String) args
073:                                    .getReturnParam(ARG_NAME_ENCODEPARAM);
074:                            args.setReturnParam(ARG_NAME_ENCODEPARAM,
075:                                    new String(org.apache.catalina.util.Base64
076:                                            .decode(resValue.getBytes()))
077:                                            .trim());
078:                        } else {
079:                            String encodeParamName = (String) args
080:                                    .getPassParam(ARG_NAME_ENCODEPARAM);
081:                            if (operation.equals(ARG_VALUE_SAVE)) {
082:                                String value = (String) args
083:                                        .getPassParam(encodeParamName);
084:                                args.setPassParam(encodeParamName,
085:                                        new String(
086:                                                org.apache.catalina.util.Base64
087:                                                        .encode(value.trim()
088:                                                                .getBytes())));
089:                                callNextProxy(method, context, null);
090:                            } else {
091:                                callNextProxy(method, context, null);
092:                                String value = (String) args
093:                                        .getReturnParam(encodeParamName);
094:                                args.setReturnParam(encodeParamName,
095:                                        new String(
096:                                                org.apache.catalina.util.Base64
097:                                                        .decode(value
098:                                                                .getBytes()))
099:                                                .trim());
100:                            }
101:                        }
102:                    } else {
103:                        if (operation == null) {
104:                            Hashtable passArgs = args.getPassArgs();
105:                            Enumeration passKeys = passArgs.keys();
106:                            while (passKeys.hasMoreElements()) {
107:                                String key = (String) passKeys.nextElement();
108:                                String data = (String) passArgs.get(key);
109:                                args.setPassParam(key, new String(
110:                                        org.apache.catalina.util.Base64
111:                                                .decode(data.getBytes())));
112:                            }
113:                            callNextProxy(method, context, null);
114:                            String resValue = (String) args
115:                                    .getReturnParam(ARG_NAME_ENCODEPARAM);
116:                            args.setReturnParam(ARG_NAME_ENCODEPARAM,
117:                                    new String(org.apache.catalina.util.Base64
118:                                            .encode(resValue.getBytes()))
119:                                            .trim());
120:                        } else {
121:                            String encodeParamName = (String) args
122:                                    .getPassParam(ARG_NAME_ENCODEPARAM);
123:                            if (operation.equals(ARG_VALUE_OPEN)) {
124:                                callNextProxy(method, context, null);
125:                                String value = (String) args
126:                                        .getReturnParam(encodeParamName);
127:                                args.setReturnParam(encodeParamName,
128:                                        new String(
129:                                                org.apache.catalina.util.Base64
130:                                                        .encode(value
131:                                                                .getBytes())));
132:                            } else {
133:                                String value = (String) args
134:                                        .getPassParam(encodeParamName);
135:                                args.setPassParam(encodeParamName, new String(
136:                                        org.apache.catalina.util.Base64
137:                                                .decode(value.getBytes()))
138:                                        .trim());
139:                                callNextProxy(method, context, null);
140:                            }
141:                        }
142:                    }
143:                    status = COMPLETE;
144:                } catch (ServiceProxyException ex) {
145:                    status = FAILED;
146:                    throw (ex);
147:                }
148:
149:                return null;
150:            }
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.