Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
change to support only local service
Browse files Browse the repository at this point in the history
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 <marty.schoch@gmail.com>
Reviewed-by: Chris Anderson <jchris@couchbase.com>
Reviewed-by: Dale Harvey <daleharvey@arandomurl.com>
Tested-by: Dale Harvey <daleharvey@arandomurl.com>
  • Loading branch information
mschoch authored and Dale Harvey committed Sep 5, 2011
1 parent a051e99 commit af24b11
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 60 deletions.
10 changes: 7 additions & 3 deletions README.markdown
Expand Up @@ -29,7 +29,7 @@ NOTE: You do not need the source of this repository to use Mobile Couchbase in y
1. Create a new Android project or select an existing project

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

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

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

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

## Examples

For examples please look at https://github.com/couchbase/Android-EmptyApp
For examples please look at:

* https://github.com/couchbase/Android-EmptyApp
* https://github.com/daleharvey/Android-MobileFuton
* https://github.com/couchbaselabs/AndroidGrocerySync

## Build information

Expand Down
10 changes: 9 additions & 1 deletion build.xml
Expand Up @@ -81,7 +81,15 @@
<path id="android.libraries.jars"><path refid="project.libraries.jars" /></path>

<target name="couchbase-jar" depends="compile">
<jar destfile="bin/couchbase.jar" basedir="bin/classes" excludes="**/R*"/>
<jar destfile="bin/couchbase.jar">
<fileset dir="bin/classes">
<include name="**/*"/>
<exclude name="**/R*"/>
</fileset>
<fileset dir="src">
<include name="**/*"/>
</fileset>
</jar>
</target>

<target name="dist" depends="couchbase-jar">
Expand Down
12 changes: 8 additions & 4 deletions doc/README.txt
Expand Up @@ -18,13 +18,13 @@ Now that your project supports Couchbase, starting Cocuhbase is accomplished by

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

private final ICouchbaseDelegate mCallback = new ICouchbaseDelegate.Stub() {
private final ICouchbaseDelegate mDelegate = new ICouchbaseDelegate() {
@Override
public void couchbaseStarted(String host, int port) {}

@Override
public void installing(int completed, int total) {}

@Override
public void exit(String error) {}
};
Expand Down Expand Up @@ -52,7 +52,11 @@ Now that your project supports Couchbase, starting Cocuhbase is accomplished by

## Examples

For examples please look at https://github.com/couchbase/Android-EmptyApp
For examples please look at:

* https://github.com/couchbase/Android-EmptyApp
* https://github.com/daleharvey/Android-MobileFuton
* https://github.com/couchbaselabs/AndroidGrocerySync

## Join us

Expand Down
10 changes: 1 addition & 9 deletions src/com/couchbase/android/CouchbaseMobile.java
Expand Up @@ -8,17 +8,13 @@
import java.io.OutputStream;
import java.util.ArrayList;

import com.couchbase.android.ICouchbaseDelegate;
import com.couchbase.android.ICouchbaseService;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.res.AssetManager;
import android.os.Environment;
import android.os.IBinder;
import android.os.RemoteException;

/*
* This is the minimal API for building against Android-Couchbase, its
Expand Down Expand Up @@ -141,12 +137,8 @@ private void copyIffNotExists(String name, File destination) throws IOException
private final static ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className, final IBinder service) {
try {
couchbaseService = ICouchbaseService.Stub.asInterface(service);
couchbaseService = (ICouchbaseService)service;
couchbaseService.startCouchbase(couchbaseDelegate, releaseName);
} catch (RemoteException e) {
e.printStackTrace();
}
}

@Override
Expand Down
57 changes: 26 additions & 31 deletions src/com/couchbase/android/CouchbaseService.java
Expand Up @@ -20,14 +20,12 @@

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.util.Log;

import com.couchbase.android.ICouchbaseDelegate;
import com.couchbase.android.ICouchbaseService;
import com.google.ase.Exec;

public class CouchbaseService extends Service {
Expand Down Expand Up @@ -63,30 +61,27 @@ public class CouchbaseService extends Service {
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
try {
switch (msg.what) {
case ERROR:
Exception e = (Exception) msg.obj;
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String stacktrace = sw.toString();
if (couchbaseDelegate != null) {
couchbaseDelegate.exit(stacktrace);
}
break;
case PROGRESS:
couchbaseDelegate.installing(msg.arg1, msg.arg2);
break;
case COMPLETE:
startCouchbaseService();
break;
case COUCHBASE_STARTED:
URL url = (URL) msg.obj;
couchbaseDelegate.couchbaseStarted(url.getHost(), url.getPort());
break;

switch (msg.what) {
case ERROR:
Exception e = (Exception) msg.obj;
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String stacktrace = sw.toString();
if (couchbaseDelegate != null) {
couchbaseDelegate.exit(stacktrace);
}
} catch (RemoteException e) {
e.printStackTrace();
break;
case PROGRESS:
couchbaseDelegate.installing(msg.arg1, msg.arg2);
break;
case COMPLETE:
startCouchbaseService();
break;
case COUCHBASE_STARTED:
URL url = (URL) msg.obj;
couchbaseDelegate.couchbaseStarted(url.getHost(), url.getPort());
break;
}
}
};
Expand All @@ -113,10 +108,10 @@ public IBinder onBind(Intent intent) {
/*
* implements the callbacks that clients can call into the couchbase service
*/
public class CouchbaseServiceImpl extends ICouchbaseService.Stub {
public class CouchbaseServiceImpl extends Binder implements ICouchbaseService {

@Override
public void startCouchbase(ICouchbaseDelegate cb, final String pkg) throws RemoteException {
public void startCouchbase(ICouchbaseDelegate cb, final String pkg) {
couchbaseDelegate = cb;
if (!CouchbaseInstaller.checkInstalled(pkg)) {
installCouchbase(pkg);
Expand All @@ -132,13 +127,13 @@ public void startCouchbase(ICouchbaseDelegate cb, final String pkg) throws Remot
/*
*/
@Override
public void stopCouchbase() throws RemoteException {
public void stopCouchbase() {
stop();
}
};

/* once couchbase has started we need to notify the waiting client */
void couchbaseStarted() throws RemoteException {
void couchbaseStarted() {
couchbaseDelegate.couchbaseStarted(url.getHost(), url.getPort());
}

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

}
}
12 changes: 0 additions & 12 deletions src/com/couchbase/android/ICouchbaseDelegate.aidl

This file was deleted.

33 changes: 33 additions & 0 deletions src/com/couchbase/android/ICouchbaseDelegate.java
@@ -0,0 +1,33 @@
package com.couchbase.android;

/**
*
*
*
*/
public interface ICouchbaseDelegate
{

/**
* Callback to notify when Couchbase has started
*
* @param host the host Couchbase is listening on
* @param port the port Couchbase is listening on
*/
void couchbaseStarted(String host, int port);

/**
* Callback for notifications on how the Couchbase install is progressing
*
* @param completed the number of files installed
* @param total the total number of files to install
*/
void installing(int completed, int total);

/**
* Callback for notification that Couchbase has exited
*
* @param error an error message describing the reason Couchbase exited
*/
void exit(String error);
}

0 comments on commit af24b11

Please sign in to comment.