View Javadoc

1   /**********************************************************************
2    * RemotingRequest.java
3    * created on 23.07.2006 by netseeker
4    * $Source: /cvsroot/ejoe/EJOE/src/de/netseeker/ejoe/request/RemotingRequest.java,v $
5    * $Date: 2007/11/17 10:57:01 $
6    * $Revision: 1.3 $
7    *
8    * ====================================================================
9    *
10   *  Copyright 2006 netseeker aka Michael Manske
11   *
12   *  Licensed under the Apache License, Version 2.0 (the "License");
13   *  you may not use this file except in compliance with the License.
14   *  You may obtain a copy of the License at
15   *
16   *      http://www.apache.org/licenses/LICENSE-2.0
17   *
18   *  Unless required by applicable law or agreed to in writing, software
19   *  distributed under the License is distributed on an "AS IS" BASIS,
20   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21   *  See the License for the specific language governing permissions and
22   *  limitations under the License.
23   * ====================================================================
24   *
25   * This file is part of the EJOE framework.
26   * For more information on the author, please see
27   * <http://www.manskes.de/>.
28   *
29   *********************************************************************/
30  
31  package de.netseeker.ejoe.request;
32  
33  import java.io.Serializable;
34  import java.util.HashMap;
35  import java.util.Map;
36  
37  import de.netseeker.ejoe.util.ContentStringBuilder;
38  
39  /***
40   * @author netseeker
41   * @since 0.3.9.1
42   */
43  public class RemotingRequest implements Serializable, IRequest
44  {
45      /***
46       * 
47       */
48      private static final long  serialVersionUID = 1L;
49  
50      public static final String UNIQUE_NAME      = "de.netseeker.ejoe.request.RemotingRequest";
51  
52      private String             clazz;
53  
54      private String             method;
55  
56      private Object[]           args;
57  
58      /***
59       * Creates a empty RemotingRequest
60       */
61      public RemotingRequest()
62      {
63      }
64  
65      /***
66       * Creates a new RemotingRequest
67       * 
68       * @param clazz package path and class name, eg. com.test.TestClass
69       * @param method method or constructor name, which should be invoced
70       * @param args the arguments for the targeted method/construtor
71       */
72      public RemotingRequest(String clazz, String method, final Object[] args)
73      {
74          this.clazz = clazz;
75          this.method = method;
76          this.args = args;
77      }
78  
79      /***
80       * @return the args
81       */
82  
83      public Object[] getArgs()
84      {
85          return args;
86      }
87  
88      /***
89       * @param args the arguments to set
90       */
91      public void setArgs( Object[] args )
92      {
93          this.args = args;
94      }
95  
96      /***
97       * @return the targeted class
98       */
99      public String getClazz()
100     {
101         return clazz;
102     }
103 
104     /***
105      * @param clazz the class to set
106      */
107     public void setClazz( String clazz )
108     {
109         this.clazz = clazz;
110     }
111 
112     /***
113      * @return the method
114      */
115     public String getMethod()
116     {
117         return method;
118     }
119 
120     /***
121      * @param method the method to set
122      */
123     public void setMethod( String method )
124     {
125         this.method = method;
126     }
127 
128     /***
129      * @return a map containing class, method and arguments
130      */
131     public Map getRequestData()
132     {
133         Map data = new HashMap();
134         data.put( "targetClass", getClazz() );
135         data.put( "targetMethod", getMethod() );
136         data.put( "arguments", getArgs() );
137         return data;
138     }
139 
140     /*
141      * (non-Javadoc)
142      * 
143      * @see java.lang.Object#toString()
144      */
145     public String toString()
146     {
147         return ((getClass() != null) ? getClazz() : "null") + '#' + ((getMethod() != null) ? getMethod() : "null")
148                 + "( " + ContentStringBuilder.toString( getArgs() ) + " )";
149     }
150 
151     /*
152      * (non-Javadoc)
153      * 
154      * @see de.netseeker.ejoe.request.IRequest#getUniqueName()
155      */
156     public String getUniqueName()
157     {
158         return UNIQUE_NAME;
159     }
160 }