Skip to content

Commit dc445b7

Browse files
committed
Removed unused import
1 parent d4b5918 commit dc445b7

12 files changed

+930
-1
lines changed

build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
<target name="compile" depends="init,init-build,copy-dependencies" description="Compiles the source into the build directory">
6060
<mkdir dir="${build.classes}"/>
61-
<javac debug="true" source="5" srcdir="${src}" destdir="${build.classes}">
61+
<javac debug="true" source="6" srcdir="${src}" destdir="${build.classes}">
6262
<classpath refid="default-classpath" />
6363
</javac>
6464
</target>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* jabsorb - a Java to JavaScript Advanced Object Request Broker
3+
* http://www.jabsorb.org
4+
*
5+
* Copyright 2007-2009 The jabsorb team
6+
*
7+
* based on original code from
8+
* JSON-RPC-Client, a Java client extension to JSON-RPC-Java
9+
* (C) Copyright CodeBistro 2007, Sasha Ovsankin <sasha at codebistro dot com>
10+
*
11+
* Licensed under the Apache License, Version 2.0 (the "License");
12+
* you may not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing, software
18+
* distributed under the License is distributed on an "AS IS" BASIS,
19+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
* See the License for the specific language governing permissions and
21+
* limitations under the License.
22+
*
23+
*/
24+
package org.jabsorb.client.async;
25+
26+
import java.util.HashMap;
27+
import java.util.Map;
28+
29+
import org.jabsorb.JSONSerializer;
30+
import org.jabsorb.client.ClientError;
31+
import org.jabsorb.serializer.request.fixups.FixupsCircularReferenceHandler;
32+
import org.jabsorb.serializer.response.fixups.FixupCircRefAndNonPrimitiveDupes;
33+
34+
/**
35+
* A factory to create proxies for access to remote Jabsorb services.
36+
*/
37+
public class AsyncClient {
38+
39+
/**
40+
* Maps proxy keys to proxies
41+
*/
42+
private final Map<Object, String> proxyMap;
43+
44+
/**
45+
* The serializer instance to use.
46+
*/
47+
private final JSONSerializer serializer;
48+
49+
/**
50+
* The transport session to use for this connection
51+
*/
52+
private final AsyncSession session;
53+
54+
/**
55+
* Create a client given a session
56+
*
57+
* @param session
58+
* transport session to use for this connection
59+
*/
60+
public AsyncClient(final AsyncSession session) {
61+
try {
62+
this.session = session;
63+
this.proxyMap = new HashMap<Object, String>();
64+
// TODO: this might need a better way of initialising it
65+
this.serializer = new JSONSerializer(
66+
FixupCircRefAndNonPrimitiveDupes.class,
67+
new FixupsCircularReferenceHandler());
68+
this.serializer.registerDefaultSerializers();
69+
} catch (final Exception e) {
70+
throw new ClientError(e);
71+
}
72+
}
73+
74+
/**
75+
* Create a proxy for communicating with the remote service.
76+
*
77+
* @param key
78+
* the remote object key
79+
* @param klass
80+
* the class of the interface the remote object should adhere to
81+
* @return created proxy
82+
*/
83+
public Object openProxy(final String key, final Class<?> klass) {
84+
final Object result = java.lang.reflect.Proxy.newProxyInstance(
85+
klass.getClassLoader(), new Class[] { klass, AsyncProxy.class }, new AsyncProxyHandler(key, session, serializer));
86+
87+
proxyMap.put(result, key);
88+
return result;
89+
}
90+
91+
/**
92+
* Dispose of the proxy that is no longer needed
93+
*
94+
* @param proxy
95+
* The proxy to close
96+
*/
97+
public void closeProxy(final Object proxy) {
98+
proxyMap.remove(proxy);
99+
}
100+
101+
/**
102+
* Allow access to the serializer
103+
*
104+
* @return The serializer for this class
105+
*/
106+
public JSONSerializer getSerializer() {
107+
return serializer;
108+
}
109+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
*
3+
*/
4+
package org.jabsorb.client.async;
5+
6+
import java.lang.reflect.Method;
7+
import java.util.concurrent.Future;
8+
9+
/**
10+
* <p>This interface is implemented by proxies genereted with
11+
* {@link AsyncClient#openProxy(String, Class)}. Its InvocationHandler provides
12+
* the required functionality.
13+
* </p>
14+
* <p>
15+
* The methods of this interface provide a means to get and act upon results
16+
* from asynchronous proxies generated by AscyncClient, which always return null
17+
* immediately.
18+
* </p>
19+
* <p>
20+
* You can check wether some proxy object implements this intereface using
21+
* <code>instanceof</code>
22+
* </p>
23+
*
24+
* @author matthijs
25+
*/
26+
public interface AsyncProxy {
27+
public Future<Object> getFutureResult();
28+
29+
public void setResultCallback(AsyncResultCallback<Object, Object, Method> resultCallback);
30+
}

0 commit comments

Comments
 (0)