KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > remoting > caucho > CauchoRemoteAccessor


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.remoting.caucho;
18
19 import java.net.MalformedURLException JavaDoc;
20
21 import org.springframework.beans.factory.InitializingBean;
22 import org.springframework.remoting.support.UrlBasedRemoteAccessor;
23
24 /**
25  * Common base class for Hessian/Burlap accessors (HessianClientInterceptor
26  * and BurlapClientInterceptor), factoring out common properties.
27  *
28  * @author Juergen Hoeller
29  * @since 1.1.4
30  * @see HessianClientInterceptor
31  * @see BurlapClientInterceptor
32  */

33 public class CauchoRemoteAccessor extends UrlBasedRemoteAccessor implements InitializingBean {
34
35     private String JavaDoc username;
36
37     private String JavaDoc password;
38
39     private boolean overloadEnabled;
40
41
42     /**
43      * Set the username that this factory should use to access the remote service.
44      * Default is none.
45      * <p>The username will be sent by Hessian/Burlap via HTTP Basic Authentication.
46      * @see com.caucho.hessian.client.HessianProxyFactory#setUser
47      * @see com.caucho.burlap.client.BurlapProxyFactory#setUser
48      */

49     public void setUsername(String JavaDoc username) {
50         this.username = username;
51     }
52
53     public String JavaDoc getUsername() {
54         return username;
55     }
56
57     /**
58      * Set the password that this factory should use to access the remote service.
59      * Default is none.
60      * <p>The password will be sent by Hessian/Burlap via HTTP Basic Authentication.
61      * @see com.caucho.hessian.client.HessianProxyFactory#setPassword
62      * @see com.caucho.burlap.client.BurlapProxyFactory#setPassword
63      */

64     public void setPassword(String JavaDoc password) {
65         this.password = password;
66     }
67
68     public String JavaDoc getPassword() {
69         return password;
70     }
71
72     /**
73      * Set whether overloaded methods should be enabled for remote invocations.
74      * Default is false.
75      * @see com.caucho.hessian.client.HessianProxyFactory#setOverloadEnabled
76      * @see com.caucho.burlap.client.BurlapProxyFactory#setOverloadEnabled
77      */

78     public void setOverloadEnabled(boolean overloadEnabled) {
79         this.overloadEnabled = overloadEnabled;
80     }
81
82     public boolean isOverloadEnabled() {
83         return overloadEnabled;
84     }
85
86
87     public void afterPropertiesSet() throws MalformedURLException JavaDoc {
88         prepare();
89     }
90
91     /**
92      * Initialize the underlying Hessian/Burlap proxy for this accessor.
93      * <p>This implementation just checks whether "serviceInterface" and
94      * "serviceUrl" have been specified. Concrete initialization is added
95      * in HessianClientInterceptor and BurlapClientInterceptor.
96      * @throws java.net.MalformedURLException if thrown by Hessian/Burlap API
97      * @see HessianClientInterceptor#prepare
98      * @see BurlapClientInterceptor#prepare
99      */

100     public void prepare() throws MalformedURLException JavaDoc {
101         if (getServiceInterface() == null) {
102             throw new IllegalArgumentException JavaDoc("serviceInterface is required");
103         }
104         if (getServiceUrl() == null) {
105             throw new IllegalArgumentException JavaDoc("serviceUrl is required");
106         }
107     }
108
109 }
110
Popular Tags