Skip to content

Commit

Permalink
Use Wrappers, as we need to wrap the whole env.
Browse files Browse the repository at this point in the history
  • Loading branch information
alesj committed Apr 9, 2014
1 parent dc5facb commit 1cddd94
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 23 deletions.
Expand Up @@ -44,7 +44,6 @@
import com.google.common.collect.Lists;
import org.jboss.capedwarf.common.async.Wrappers;
import org.jboss.capedwarf.common.threads.DirectFuture;
import org.jboss.capedwarf.common.threads.ExecutorFactory;

/**
* JBoss async DatastoreService impl.
Expand All @@ -62,7 +61,7 @@ public CapedwarfAsyncDatastoreService(DatastoreServiceConfig config) {
}

protected static <T> Future<T> wrap(final Callable<T> callable) {
return ExecutorFactory.wrap(callable);
return Wrappers.future(callable);
}

protected <T> Future<T> tx(final Callable<T> callable) {
Expand Down
Expand Up @@ -39,9 +39,9 @@
import com.google.appengine.api.images.Transform;
import org.infinispan.AdvancedCache;
import org.jboss.capedwarf.common.app.Application;
import org.jboss.capedwarf.common.async.Wrappers;
import org.jboss.capedwarf.common.infinispan.CacheName;
import org.jboss.capedwarf.common.infinispan.InfinispanUtils;
import org.jboss.capedwarf.common.threads.ExecutorFactory;
import org.jboss.capedwarf.files.ExposedFileService;
import org.jboss.capedwarf.images.transform.CapedwarfTransform;
import org.jboss.capedwarf.images.transform.CapedwarfTransformFactory;
Expand Down Expand Up @@ -109,7 +109,7 @@ public Future<Image> applyTransformAsync(Transform transform, Image image, Outpu
}

public Future<Image> applyTransformAsync(final Transform transform, final Image image, final InputSettings inputSettings, final OutputSettings outputSettings) {
return ExecutorFactory.wrap(new Callable<Image>() {
return Wrappers.future(new Callable<Image>() {
public Image call() throws Exception {
return applyTransform(transform, image, inputSettings, outputSettings);
}
Expand Down
Expand Up @@ -55,7 +55,7 @@
import org.infinispan.query.CacheQuery;
import org.infinispan.query.Search;
import org.infinispan.query.SearchManager;
import org.jboss.capedwarf.common.threads.ExecutorFactory;
import org.jboss.capedwarf.common.async.Wrappers;

/**
* @author <a href="mailto:mluksa@redhat.com">Marko Luksa</a>
Expand Down Expand Up @@ -112,7 +112,7 @@ public Future<Void> removeAsync(String... documentIds) {
}

public Future<Void> removeAsync(final Iterable<String> documentIds) {
return ExecutorFactory.wrap(new Callable<Void>() {
return Wrappers.future(new Callable<Void>() {
public Void call() throws Exception {
remove(documentIds);
return null;
Expand All @@ -125,7 +125,7 @@ public Future<Results<ScoredDocument>> searchAsync(String queryString) {
}

public Future<Results<ScoredDocument>> searchAsync(final Query query) {
return ExecutorFactory.wrap(new Callable<Results<ScoredDocument>>() {
return Wrappers.future(new Callable<Results<ScoredDocument>>() {
public Results<ScoredDocument> call() throws Exception {
return search(query);
}
Expand Down Expand Up @@ -273,7 +273,7 @@ public Schema getSchema() {
}

public Future<Void> deleteSchemaAsync() {
return ExecutorFactory.wrap(new Callable<Void>() {
return Wrappers.future(new Callable<Void>() {
public Void call() throws Exception {
deleteSchema();
return null;
Expand All @@ -290,7 +290,7 @@ public Future<Void> deleteAsync(String... strings) {
}

public Future<Void> deleteAsync(final Iterable<String> strings) {
return ExecutorFactory.wrap(new Callable<Void>() {
return Wrappers.future(new Callable<Void>() {
public Void call() throws Exception {
delete(strings);
return null;
Expand All @@ -303,31 +303,31 @@ public Future<PutResponse> putAsync(Document... documents) {
}

public Future<PutResponse> putAsync(final Document.Builder... builders) {
return ExecutorFactory.wrap(new Callable<PutResponse>() {
return Wrappers.future(new Callable<PutResponse>() {
public PutResponse call() throws Exception {
return put(builders);
}
});
}

public Future<PutResponse> putAsync(final Iterable<Document> documents) {
return ExecutorFactory.wrap(new Callable<PutResponse>() {
return Wrappers.future(new Callable<PutResponse>() {
public PutResponse call() throws Exception {
return put(documents);
}
});
}

public Future<GetResponse<Document>> getRangeAsync(final GetRequest getRequest) {
return ExecutorFactory.wrap(new Callable<GetResponse<Document>>() {
return Wrappers.future(new Callable<GetResponse<Document>>() {
public GetResponse<Document> call() throws Exception {
return getRange(getRequest);
}
});
}

public Future<GetResponse<Document>> getRangeAsync(final GetRequest.Builder builder) {
return ExecutorFactory.wrap(new Callable<GetResponse<Document>>() {
return Wrappers.future(new Callable<GetResponse<Document>>() {
public GetResponse<Document> call() throws Exception {
return getRange(builder);
}
Expand Down
Expand Up @@ -35,9 +35,9 @@
import org.infinispan.Cache;
import org.infinispan.distexec.mapreduce.MapReduceTask;
import org.jboss.capedwarf.common.app.Application;
import org.jboss.capedwarf.common.async.Wrappers;
import org.jboss.capedwarf.common.infinispan.CacheName;
import org.jboss.capedwarf.common.infinispan.InfinispanUtils;
import org.jboss.capedwarf.common.threads.ExecutorFactory;

/**
* @author <a href="mailto:mluksa@redhat.com">Marko Luksa</a>
Expand Down Expand Up @@ -109,15 +109,15 @@ public GetResponse<Index> getIndexes(GetIndexesRequest.Builder builder) {
}

public Future<GetResponse<Index>> getIndexesAsync(final GetIndexesRequest getIndexesRequest) {
return ExecutorFactory.wrap(new Callable<GetResponse<Index>>() {
return Wrappers.future(new Callable<GetResponse<Index>>() {
public GetResponse<Index> call() throws Exception {
return getIndexes(getIndexesRequest);
}
});
}

public Future<GetResponse<Index>> getIndexesAsync(final GetIndexesRequest.Builder builder) {
return ExecutorFactory.wrap(new Callable<GetResponse<Index>>() {
return Wrappers.future(new Callable<GetResponse<Index>>() {
public GetResponse<Index> call() throws Exception {
return getIndexes(builder);
}
Expand Down
Expand Up @@ -60,12 +60,10 @@
import org.infinispan.query.SearchManager;
import org.jboss.capedwarf.common.app.Application;
import org.jboss.capedwarf.common.async.Wrappers;
import org.jboss.capedwarf.common.config.CapedwarfEnvironment;
import org.jboss.capedwarf.common.infinispan.CacheName;
import org.jboss.capedwarf.common.infinispan.InfinispanUtils;
import org.jboss.capedwarf.common.jms.MessageCreator;
import org.jboss.capedwarf.common.jms.ServletExecutorProducer;
import org.jboss.capedwarf.common.threads.ExecutorFactory;
import org.jboss.capedwarf.shared.config.ApplicationConfiguration;
import org.jboss.capedwarf.shared.config.QueueXml;

Expand Down Expand Up @@ -502,7 +500,7 @@ protected QueueStatistics fetchStatistics(Double deadlineInSeconds) {
}

protected <V> Future<V> wrap(Callable<V> callable) {
return ExecutorFactory.wrap(Wrappers.wrap(callable));
return Wrappers.future(Wrappers.wrap(callable));
}

public Future<TaskHandle> addAsync() {
Expand Down
Expand Up @@ -50,7 +50,6 @@
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.jboss.capedwarf.common.async.Wrappers;
import org.jboss.capedwarf.common.threads.ExecutorFactory;
import org.jboss.capedwarf.shared.compatibility.Compatibility;
import org.jboss.capedwarf.shared.components.ComponentRegistry;
import org.jboss.capedwarf.shared.components.Keys;
Expand All @@ -77,12 +76,11 @@ public Future<HTTPResponse> fetchAsync(URL url) {

public Future<HTTPResponse> fetchAsync(final HTTPRequest httpRequest) {
final HttpUriRequest request = toHttpUriRequest(httpRequest);
final Callable<HTTPResponse> callable = Wrappers.wrap(new Callable<HTTPResponse>() {
return Wrappers.future(new Callable<HTTPResponse>() {
public HTTPResponse call() throws Exception {
return fetch(request);
return fetch(request);
}
});
return ExecutorFactory.wrap(callable);
}

protected HttpUriRequest toHttpUriRequest(final HTTPRequest request) {
Expand Down

0 comments on commit 1cddd94

Please sign in to comment.