Skip to content

Commit af24b11

Browse files
mschochDale Harvey
authored and
Dale Harvey
committed
change to support only local service
updated README with changes to delegate updated README link to binary download updated README list of examples updated README.txt in user documentation Change-Id: I2b1d22db0f52c7e6e67959db850a25a53e2f5c77 Reviewed-on: http://review.couchbase.org/9365 Reviewed-by: Marty Schoch <[email protected]> Reviewed-by: Chris Anderson <[email protected]> Reviewed-by: Dale Harvey <[email protected]> Tested-by: Dale Harvey <[email protected]>
1 parent a051e99 commit af24b11

8 files changed

+84
-60
lines changed

README.markdown

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ NOTE: You do not need the source of this repository to use Mobile Couchbase in y
2929
1. Create a new Android project or select an existing project
3030

3131
2. Download the Android-Couchbase.zip
32-
- https://github.com/downloads/couchbase/Android-Couchbase/Android-Couchbase.zip
32+
- http://files.couchbase.com/developer-previews/mobile/android/android-couchbase-dp.zip
3333

3434
3. Extract Android-Couchbase.zip, you will see 3 files
3535
- Couchbase.zip
@@ -48,7 +48,7 @@ Now that your project supports Couchbase, starting Cocuhbase is accomplished by
4848

4949
1. Create an instance of ICouchbaseDelegate, you can implement these methods to respond to Couchbase events
5050
<pre>
51-
private final ICouchbaseDelegate mCallback = new ICouchbaseDelegate.Stub() {
51+
private final ICouchbaseDelegate mDelegate = new ICouchbaseDelegate() {
5252
@Override
5353
public void couchbaseStarted(String host, int port) {}
5454

@@ -86,7 +86,11 @@ Now that your project supports Couchbase, starting Cocuhbase is accomplished by
8686

8787
## Examples
8888

89-
For examples please look at https://github.com/couchbase/Android-EmptyApp
89+
For examples please look at:
90+
91+
* https://github.com/couchbase/Android-EmptyApp
92+
* https://github.com/daleharvey/Android-MobileFuton
93+
* https://github.com/couchbaselabs/AndroidGrocerySync
9094

9195
## Build information
9296

build.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,15 @@
8181
<path id="android.libraries.jars"><path refid="project.libraries.jars" /></path>
8282

8383
<target name="couchbase-jar" depends="compile">
84-
<jar destfile="bin/couchbase.jar" basedir="bin/classes" excludes="**/R*"/>
84+
<jar destfile="bin/couchbase.jar">
85+
<fileset dir="bin/classes">
86+
<include name="**/*"/>
87+
<exclude name="**/R*"/>
88+
</fileset>
89+
<fileset dir="src">
90+
<include name="**/*"/>
91+
</fileset>
92+
</jar>
8593
</target>
8694

8795
<target name="dist" depends="couchbase-jar">

doc/README.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ Now that your project supports Couchbase, starting Cocuhbase is accomplished by
1818

1919
1. Create an instance of ICouchbaseDelegate, you can implement these methods to respond to Couchbase events
2020

21-
private final ICouchbaseDelegate mCallback = new ICouchbaseDelegate.Stub() {
21+
private final ICouchbaseDelegate mDelegate = new ICouchbaseDelegate() {
2222
@Override
2323
public void couchbaseStarted(String host, int port) {}
24-
24+
2525
@Override
2626
public void installing(int completed, int total) {}
27-
27+
2828
@Override
2929
public void exit(String error) {}
3030
};
@@ -52,7 +52,11 @@ Now that your project supports Couchbase, starting Cocuhbase is accomplished by
5252

5353
## Examples
5454

55-
For examples please look at https://github.com/couchbase/Android-EmptyApp
55+
For examples please look at:
56+
57+
* https://github.com/couchbase/Android-EmptyApp
58+
* https://github.com/daleharvey/Android-MobileFuton
59+
* https://github.com/couchbaselabs/AndroidGrocerySync
5660

5761
## Join us
5862

src/com/couchbase/android/CouchbaseMobile.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@
88
import java.io.OutputStream;
99
import java.util.ArrayList;
1010

11-
import com.couchbase.android.ICouchbaseDelegate;
12-
import com.couchbase.android.ICouchbaseService;
13-
1411
import android.content.ComponentName;
1512
import android.content.Context;
1613
import android.content.Intent;
1714
import android.content.ServiceConnection;
1815
import android.content.res.AssetManager;
1916
import android.os.Environment;
2017
import android.os.IBinder;
21-
import android.os.RemoteException;
2218

2319
/*
2420
* This is the minimal API for building against Android-Couchbase, its
@@ -141,12 +137,8 @@ private void copyIffNotExists(String name, File destination) throws IOException
141137
private final static ServiceConnection mConnection = new ServiceConnection() {
142138
@Override
143139
public void onServiceConnected(ComponentName className, final IBinder service) {
144-
try {
145-
couchbaseService = ICouchbaseService.Stub.asInterface(service);
140+
couchbaseService = (ICouchbaseService)service;
146141
couchbaseService.startCouchbase(couchbaseDelegate, releaseName);
147-
} catch (RemoteException e) {
148-
e.printStackTrace();
149-
}
150142
}
151143

152144
@Override

src/com/couchbase/android/CouchbaseService.java

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020

2121
import android.app.Service;
2222
import android.content.Intent;
23+
import android.os.Binder;
2324
import android.os.Handler;
2425
import android.os.IBinder;
2526
import android.os.Message;
26-
import android.os.RemoteException;
2727
import android.util.Log;
2828

29-
import com.couchbase.android.ICouchbaseDelegate;
30-
import com.couchbase.android.ICouchbaseService;
3129
import com.google.ase.Exec;
3230

3331
public class CouchbaseService extends Service {
@@ -63,30 +61,27 @@ public class CouchbaseService extends Service {
6361
private final Handler mHandler = new Handler() {
6462
@Override
6563
public void handleMessage(Message msg) {
66-
try {
67-
switch (msg.what) {
68-
case ERROR:
69-
Exception e = (Exception) msg.obj;
70-
StringWriter sw = new StringWriter();
71-
e.printStackTrace(new PrintWriter(sw));
72-
String stacktrace = sw.toString();
73-
if (couchbaseDelegate != null) {
74-
couchbaseDelegate.exit(stacktrace);
75-
}
76-
break;
77-
case PROGRESS:
78-
couchbaseDelegate.installing(msg.arg1, msg.arg2);
79-
break;
80-
case COMPLETE:
81-
startCouchbaseService();
82-
break;
83-
case COUCHBASE_STARTED:
84-
URL url = (URL) msg.obj;
85-
couchbaseDelegate.couchbaseStarted(url.getHost(), url.getPort());
86-
break;
64+
65+
switch (msg.what) {
66+
case ERROR:
67+
Exception e = (Exception) msg.obj;
68+
StringWriter sw = new StringWriter();
69+
e.printStackTrace(new PrintWriter(sw));
70+
String stacktrace = sw.toString();
71+
if (couchbaseDelegate != null) {
72+
couchbaseDelegate.exit(stacktrace);
8773
}
88-
} catch (RemoteException e) {
89-
e.printStackTrace();
74+
break;
75+
case PROGRESS:
76+
couchbaseDelegate.installing(msg.arg1, msg.arg2);
77+
break;
78+
case COMPLETE:
79+
startCouchbaseService();
80+
break;
81+
case COUCHBASE_STARTED:
82+
URL url = (URL) msg.obj;
83+
couchbaseDelegate.couchbaseStarted(url.getHost(), url.getPort());
84+
break;
9085
}
9186
}
9287
};
@@ -113,10 +108,10 @@ public IBinder onBind(Intent intent) {
113108
/*
114109
* implements the callbacks that clients can call into the couchbase service
115110
*/
116-
public class CouchbaseServiceImpl extends ICouchbaseService.Stub {
111+
public class CouchbaseServiceImpl extends Binder implements ICouchbaseService {
117112

118113
@Override
119-
public void startCouchbase(ICouchbaseDelegate cb, final String pkg) throws RemoteException {
114+
public void startCouchbase(ICouchbaseDelegate cb, final String pkg) {
120115
couchbaseDelegate = cb;
121116
if (!CouchbaseInstaller.checkInstalled(pkg)) {
122117
installCouchbase(pkg);
@@ -132,13 +127,13 @@ public void startCouchbase(ICouchbaseDelegate cb, final String pkg) throws Remot
132127
/*
133128
*/
134129
@Override
135-
public void stopCouchbase() throws RemoteException {
130+
public void stopCouchbase() {
136131
stop();
137132
}
138133
};
139134

140135
/* once couchbase has started we need to notify the waiting client */
141-
void couchbaseStarted() throws RemoteException {
136+
void couchbaseStarted() {
142137
couchbaseDelegate.couchbaseStarted(url.getHost(), url.getPort());
143138
}
144139

@@ -246,4 +241,4 @@ public static String join(Collection<String> s, String delimiter) {
246241
return buffer.toString();
247242
}
248243

249-
}
244+
}

src/com/couchbase/android/ICouchbaseDelegate.aidl

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.couchbase.android;
2+
3+
/**
4+
*
5+
*
6+
*
7+
*/
8+
public interface ICouchbaseDelegate
9+
{
10+
11+
/**
12+
* Callback to notify when Couchbase has started
13+
*
14+
* @param host the host Couchbase is listening on
15+
* @param port the port Couchbase is listening on
16+
*/
17+
void couchbaseStarted(String host, int port);
18+
19+
/**
20+
* Callback for notifications on how the Couchbase install is progressing
21+
*
22+
* @param completed the number of files installed
23+
* @param total the total number of files to install
24+
*/
25+
void installing(int completed, int total);
26+
27+
/**
28+
* Callback for notification that Couchbase has exited
29+
*
30+
* @param error an error message describing the reason Couchbase exited
31+
*/
32+
void exit(String error);
33+
}

0 commit comments

Comments
 (0)