-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from ArcBees/cv_dispatch_client_common_2
Extracted common code between RPC and REST DispatchAsync
- Loading branch information
Showing
189 changed files
with
6,054 additions
and
1,950 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
...tp-dispatch-common-client/src/main/java/com/gwtplatform/dispatch/client/DispatchCall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/** | ||
* Copyright 2013 ArcBees Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.gwtplatform.dispatch.client; | ||
|
||
import com.google.gwt.http.client.Response; | ||
import com.google.gwt.user.client.rpc.AsyncCallback; | ||
import com.gwtplatform.common.client.IndirectProvider; | ||
import com.gwtplatform.dispatch.client.ExceptionHandler.Status; | ||
import com.gwtplatform.dispatch.client.actionhandler.ClientActionHandler; | ||
import com.gwtplatform.dispatch.client.actionhandler.ClientActionHandlerRegistry; | ||
import com.gwtplatform.dispatch.shared.DispatchRequest; | ||
import com.gwtplatform.dispatch.shared.SecurityCookieAccessor; | ||
import com.gwtplatform.dispatch.shared.TypedAction; | ||
|
||
/** | ||
*/ | ||
public abstract class DispatchCall<A extends TypedAction<R>, R> { | ||
private final A action; | ||
private final AsyncCallback<R> callback; | ||
private final ClientActionHandlerRegistry clientActionHandlerRegistry; | ||
private final ExceptionHandler exceptionHandler; | ||
private final SecurityCookieAccessor securityCookieAccessor; | ||
|
||
private String securityCookie; | ||
|
||
public DispatchCall(ExceptionHandler exceptionHandler, | ||
ClientActionHandlerRegistry clientActionHandlerRegistry, | ||
SecurityCookieAccessor securityCookieAccessor, | ||
A action, | ||
AsyncCallback<R> callback) { | ||
this.action = action; | ||
this.callback = callback; | ||
this.exceptionHandler = exceptionHandler; | ||
this.clientActionHandlerRegistry = clientActionHandlerRegistry; | ||
this.securityCookieAccessor = securityCookieAccessor; | ||
} | ||
|
||
public DispatchRequest execute() { | ||
securityCookie = securityCookieAccessor.getCookieContent(); | ||
|
||
IndirectProvider<ClientActionHandler<?, ?>> clientActionHandlerProvider = | ||
clientActionHandlerRegistry.find(action.getClass()); | ||
|
||
if (clientActionHandlerProvider != null) { | ||
DelegatingDispatchRequest dispatchRequest = new DelegatingDispatchRequest(); | ||
DelegatingAsyncCallback<A, R> delegatingCallback = | ||
new DelegatingAsyncCallback<A, R>(this, action, callback, dispatchRequest); | ||
|
||
clientActionHandlerProvider.get(delegatingCallback); | ||
|
||
return dispatchRequest; | ||
} else { | ||
return doExecute(); | ||
} | ||
} | ||
|
||
protected abstract DispatchRequest doExecute(); | ||
|
||
protected A getAction() { | ||
return action; | ||
} | ||
|
||
protected AsyncCallback<R> getCallback() { | ||
return callback; | ||
} | ||
|
||
protected ClientActionHandlerRegistry getClientActionHandlerRegistry() { | ||
return clientActionHandlerRegistry; | ||
} | ||
|
||
protected ExceptionHandler getExceptionHandler() { | ||
return exceptionHandler; | ||
} | ||
|
||
protected SecurityCookieAccessor getSecurityCookieAccessor() { | ||
return securityCookieAccessor; | ||
} | ||
|
||
protected String getSecurityCookie() { | ||
return securityCookie; | ||
} | ||
|
||
protected void onExecuteSuccess(R result) { | ||
callback.onSuccess(result); | ||
} | ||
|
||
protected void onExecuteSuccess(R result, Response response) { | ||
onExecuteSuccess(result); | ||
} | ||
|
||
protected void onExecuteFailure(Throwable caught) { | ||
if (exceptionHandler != null && exceptionHandler.onFailure(caught) == Status.STOP) { | ||
return; | ||
} | ||
|
||
callback.onFailure(caught); | ||
} | ||
|
||
protected void onExecuteFailure(Throwable caught, Response response) { | ||
onExecuteFailure(caught); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,6 @@ | |
|
||
/** | ||
* Interface for client side caching. | ||
* | ||
* @author Sunny Gupta | ||
*/ | ||
public interface Cache { | ||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...wtp-dispatch-common-shared/src/main/java/com/gwtplatform/dispatch/shared/TypedAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright 2013 ArcBees Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.gwtplatform.dispatch.shared; | ||
|
||
public interface TypedAction<R> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.