Source Code Cross Referenced for InvocationResult.java in  » ESB » mule » org » mule » api » model » 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 » mule » org.mule.api.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: InvocationResult.java 10489 2008-01-23 17:53:38Z dfeist $
003:         * --------------------------------------------------------------------------------------
004:         * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
005:         *
006:         * The software in this package is published under the terms of the CPAL v1.0
007:         * license, a copy of which has been included with this distribution in the
008:         * LICENSE.txt file.
009:         */
010:        package org.mule.api.model;
011:
012:        import org.mule.config.i18n.CoreMessages;
013:
014:        import java.lang.reflect.Method;
015:
016:        /** TODO */
017:        public class InvocationResult {
018:            /** the resover performing the invocation knows that it cannot attempt to make the invocation */
019:            public static final int STATE_INVOKE_NOT_SUPPORTED = 0;
020:
021:            /** the invocation was successful */
022:            public static final int STATE_INVOKED_SUCESSFUL = 1;
023:
024:            /** The invocation was attempted but failed */
025:            public static final int STATE_INVOKED_FAILED = 2;
026:
027:            private String errorMessage;
028:
029:            /** the name of the method called for this invocation */
030:            private String methodCalled;
031:
032:            private Object result;
033:
034:            private int state;
035:
036:            /**
037:             * Will construct an InvocationResult with a given state. The state must be either
038:             * {@link #STATE_INVOKE_NOT_SUPPORTED} if the resover performing the invocation knows that it cannot
039:             * attempt to make the invocation
040:             * {@link #STATE_INVOKED_FAILED} If an invocation attempt is made but fails
041:             * {@link #STATE_INVOKED_SUCESSFUL} If the invocation was successful
042:             *
043:             * @param state the state of the result
044:             */
045:            public InvocationResult(int state) {
046:                if (state < 0 || state > 2) {
047:                    throw new IllegalArgumentException("state");
048:                }
049:                this .state = state;
050:            }
051:
052:            /**
053:             * Creates a result with the result payload set. The state of this result will be {@link #STATE_INVOKED_SUCESSFUL}
054:             * since only in this state will a result be set.
055:             *
056:             * @param result the result of a successful invocation
057:             */
058:            public InvocationResult(Object result, Method method) {
059:
060:                this .result = result;
061:                this .state = STATE_INVOKED_SUCESSFUL;
062:                this .methodCalled = method.getName();
063:            }
064:
065:            /**
066:             * Returns the name of the method invoked, this property is only set if the state of the invocation is
067:             * {@link #STATE_INVOKED_SUCESSFUL}
068:             *
069:             * @return the name of the method invoked
070:             */
071:            public String getMethodCalled() {
072:                return methodCalled;
073:            }
074:
075:            /**
076:             * The result of this invocation
077:             *
078:             * @return an object or null if the result did not yeild a result or because the state of this invocation result
079:             *         is either {@link #STATE_INVOKE_NOT_SUPPORTED} or {@link #STATE_INVOKED_FAILED}.
080:             */
081:            public Object getResult() {
082:                return result;
083:            }
084:
085:            /**
086:             * Returns the state of this invocation. Possible values are:
087:             * {@link #STATE_INVOKE_NOT_SUPPORTED} if the resover performing the invocation knows that it cannot
088:             * attempt to make the invocation
089:             * {@link #STATE_INVOKED_FAILED} If an invocation attempt is made but fails
090:             * {@link #STATE_INVOKED_SUCESSFUL} If the invocation was successful
091:             *
092:             * @return
093:             */
094:            public int getState() {
095:                return state;
096:            }
097:
098:            /**
099:             * An optional error message can be set if the invocation state is not {@link #STATE_INVOKED_SUCESSFUL}
100:             *
101:             * @param message
102:             */
103:            public void setErrorMessage(String message) {
104:                if (state == STATE_INVOKED_SUCESSFUL) {
105:                    throw new IllegalStateException(CoreMessages
106:                            .invocationSuccessfulCantSetError().toString());
107:                }
108:                errorMessage = message;
109:            }
110:
111:            /**
112:             * Returns true if an error message has been set on this result, false otherwise
113:             *
114:             * @return true if an error message has been set on this result, false otherwise
115:             */
116:            public boolean hasError() {
117:                return errorMessage != null;
118:            }
119:
120:            /**
121:             * Returns the error message set on this result or null if none has been set
122:             *
123:             * @return the error message set on this result or null if none has been set
124:             */
125:            public String getErrorMessage() {
126:                return errorMessage;
127:            }
128:
129:            public void setErrorTooManyMatchingMethods(Object component,
130:                    Class[] argTypes, String methods,
131:                    EntryPointResolver resolver) {
132:                setErrorMessage(CoreMessages
133:                        .tooManyAcceptableMethodsOnObjectUsingResolverForTypes(
134:                                component.getClass().getName(), argTypes,
135:                                resolver).toString());
136:            }
137:
138:            public void setErrorTooManyMatchingMethods(Object component,
139:                    Class[] argTypes, EntryPointResolver resolver) {
140:                setErrorMessage(CoreMessages
141:                        .tooManyAcceptableMethodsOnObjectUsingResolverForTypes(
142:                                component.getClass().getName(), argTypes,
143:                                resolver).toString());
144:            }
145:
146:            public void setErrorNoMatchingMethods(Object component,
147:                    Class[] args, EntryPointResolver resolver) {
148:                setErrorMessage(CoreMessages
149:                        .noEntryPointFoundWithArgsUsingResolver(
150:                                component.getClass().getName(), args, resolver)
151:                        .toString());
152:            }
153:
154:            public void setErrorNoMatchingMethodsCalled(Object component,
155:                    String methods, EntryPointResolver resolver) {
156:                setErrorMessage(CoreMessages
157:                        .noMatchingMethodsOnObjectCalledUsingResolver(
158:                                component.getClass().getName(), methods,
159:                                resolver).toString());
160:            }
161:
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.