Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rest/Rpc dispatch interoperability #467

Merged
merged 23 commits into from Jul 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4473617
Added binding annotation to abstract dispatch module. Both dispatcher…
Chris-V Apr 7, 2014
af21c84
Code Style
Chris-V Apr 7, 2014
4a94e8e
Merge remote-tracking branch 'origin/master' into cv_dispatch_interop…
meriouma May 26, 2014
63783e0
Merge branch 'master' into cv_dispatch_interoperability
meriouma Jul 27, 2014
eebf6d0
Added RPC dispatch in CarStore to showcase dispatcher coexistence
meriouma Jul 27, 2014
9e49fdd
Merge remote-tracking branch 'origin/master' into cv_dispatch_interop…
meriouma Jul 27, 2014
637744e
Format
meriouma Jul 27, 2014
b60e69b
Merge branch 'cv_dispatch_interoperability' into mmc_dispatch_interop
meriouma Jul 27, 2014
3716713
Fixed java 1.7
meriouma Jul 27, 2014
79d3bc7
CR Fixes
meriouma Jul 27, 2014
22f54b0
CR Fixes
meriouma Jul 27, 2014
a9d6db7
Updated gwt-jackson
meriouma Jul 27, 2014
235f2e0
Fixed DispatchHooks binding when using both dispatchers
meriouma Jul 27, 2014
458c774
Allow different DispatchHooks for REST and RPC dispatchers
meriouma Jul 28, 2014
104c8e2
Merge pull request #530 from ArcBees/mmc_gwt_jackson
meriouma Jul 28, 2014
3f6b612
Changed return type of Builder to return correct type
meriouma Jul 28, 2014
29f6f50
Revert case
meriouma Jul 28, 2014
1d4b114
Merge remote-tracking branch 'origin/mmc_dispatch_interop' into mmc_d…
meriouma Jul 28, 2014
9db8804
Revert gwt.xml
meriouma Jul 28, 2014
9bb01c6
Merge pull request #532 from ArcBees/mmc_multiple_hooks
meriouma Jul 28, 2014
95b0557
Merge pull request #534 from ArcBees/mmc_dispatch_builder
meriouma Jul 29, 2014
4a1bf24
Merge pull request #531 from ArcBees/mmc_interop_hooks
meriouma Jul 29, 2014
ed3f510
Merge pull request #528 from ArcBees/mmc_dispatch_interop
meriouma Jul 29, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions gwtp-carstore/pom.xml
Expand Up @@ -14,6 +14,7 @@
<description>Simple application used for testing GWTP features.</description>

<properties>
<target.jdk>1.7</target.jdk>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<gae.home>
${settings.localRepository}/com/google/appengine/appengine-java-sdk/${gae.version}/appengine-java-sdk-${gae.version}
Expand All @@ -25,8 +26,11 @@
<gae.port>8888</gae.port>
<gae.address>127.0.0.1</gae.address>

<slf4j-api.version>1.7.7</slf4j-api.version>
<resteasy.version>3.0.8.Final</resteasy.version>
<arcbees.version>1.1.1</arcbees.version>

<objectify-gwt.version>1.0</objectify-gwt.version>
</properties>

<build>
Expand Down Expand Up @@ -133,12 +137,23 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gwtp-dispatch-rpc-client</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gwtp-dispatch-rest</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gwtp-dispatch-rpc-server-guice</artifactId>
<version>${project.version}</version>
</dependency>

<!-- GWT -->
<dependency>
Expand Down Expand Up @@ -229,6 +244,11 @@
<artifactId>objectify</artifactId>
<version>${objectify.version}</version>
</dependency>
<dependency>
<groupId>com.googlecode.objectify</groupId>
<artifactId>objectify-gwt</artifactId>
<version>${objectify-gwt.version}</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
Expand Down
Expand Up @@ -35,13 +35,12 @@
import com.gwtplatform.carstore.client.place.NameTokens;
import com.gwtplatform.carstore.client.place.ParameterTokens;
import com.gwtplatform.carstore.client.resources.LoginMessages;
import com.gwtplatform.carstore.client.rest.SessionService;
import com.gwtplatform.carstore.client.security.CurrentUser;
import com.gwtplatform.carstore.shared.dispatch.LogInRequest;
import com.gwtplatform.carstore.shared.dispatch.ActionType;
import com.gwtplatform.carstore.shared.dispatch.LogInAction;
import com.gwtplatform.carstore.shared.dispatch.LogInResult;
import com.gwtplatform.carstore.shared.dto.ActionType;
import com.gwtplatform.carstore.shared.dto.CurrentUserDto;
import com.gwtplatform.dispatch.rest.shared.RestDispatch;
import com.gwtplatform.dispatch.rpc.shared.DispatchAsync;
import com.gwtplatform.mvp.client.HasUiHandlers;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
Expand Down Expand Up @@ -69,9 +68,9 @@ interface MyProxy extends ProxyPlace<LoginPresenter> {
public static final String LOGIN_COOKIE_NAME = "LoggedInCookie";

private static final Logger logger = Logger.getLogger(LoginPresenter.class.getName());

private final PlaceManager placeManager;
private final RestDispatch dispatchAsync;
private final SessionService sessionService;
private final DispatchAsync dispatcher;
private final CurrentUser currentUser;
private final LoginMessages messages;

Expand All @@ -80,15 +79,13 @@ interface MyProxy extends ProxyPlace<LoginPresenter> {
MyView view,
MyProxy proxy,
PlaceManager placeManager,
RestDispatch dispatchAsync,
SessionService sessionService,
DispatchAsync dispatcher,
CurrentUser currentUser,
LoginMessages messages) {
super(eventBus, view, proxy, RevealType.RootLayout);

this.placeManager = placeManager;
this.dispatchAsync = dispatchAsync;
this.sessionService = sessionService;
this.dispatcher = dispatcher;
this.currentUser = currentUser;
this.messages = messages;

Expand All @@ -97,8 +94,8 @@ interface MyProxy extends ProxyPlace<LoginPresenter> {

@Override
public void login(String username, String password) {
LogInRequest loginRequest = new LogInRequest(username, password);
callServerLoginAction(loginRequest);
LogInAction logInAction = new LogInAction(username, password);
callServerLoginAction(logInAction);
}

@Override
Expand All @@ -110,8 +107,8 @@ protected void onReveal() {
}
}

private void callServerLoginAction(LogInRequest loginRequest) {
dispatchAsync.execute(sessionService.login(loginRequest), new AsyncCallback<LogInResult>() {
private void callServerLoginAction(LogInAction logInAction) {
dispatcher.execute(logInAction, new AsyncCallback<LogInResult>() {
@Override
public void onFailure(Throwable e) {
DisplayMessageEvent.fire(LoginPresenter.this, new Message(messages.unableToContactServer(),
Expand Down Expand Up @@ -190,8 +187,8 @@ private String getDomain() {

private void tryLoggingInWithCookieFirst() {
getView().setLoginButtonEnabled(false);
LogInRequest loginRequest = new LogInRequest(getLoggedInCookie());
callServerLoginAction(loginRequest);
LogInAction logInAction = new LogInAction(getLoggedInCookie());
callServerLoginAction(logInAction);
}

private String getLoggedInCookie() {
Expand Down
Expand Up @@ -66,6 +66,7 @@ interface MyProxy extends ProxyPlace<StatisticsPresenter> {
}

@Override
@SuppressWarnings("deprecation")
public void extractYear(final Date date) {
getView().setResult("");

Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.gwtplatform.carstore.client.place.NameTokens;
import com.gwtplatform.carstore.client.security.SecurityModule;
import com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule;
import com.gwtplatform.dispatch.rpc.client.gin.RpcDispatchAsyncModule;
import com.gwtplatform.mvp.client.annotations.DefaultPlace;
import com.gwtplatform.mvp.client.annotations.ErrorPlace;
import com.gwtplatform.mvp.client.annotations.UnauthorizedPlace;
Expand All @@ -31,6 +32,7 @@ protected void configure() {
install(new DefaultModule());
install(new SecurityModule());
install(new RestDispatchAsyncModule());
install(new RpcDispatchAsyncModule());

// DefaultPlaceManager Places
bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.LOGIN);
Expand Down
Expand Up @@ -18,11 +18,8 @@

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;

import com.gwtplatform.carstore.shared.dispatch.LogInRequest;
import com.gwtplatform.carstore.shared.dispatch.LogInResult;
import com.gwtplatform.carstore.shared.dto.CurrentUserDto;
import com.gwtplatform.dispatch.rest.shared.RestAction;

Expand All @@ -35,7 +32,4 @@ public interface SessionService {

@GET
RestAction<CurrentUserDto> getCurrentUser();

@POST
RestAction<LogInResult> login(LogInRequest logInRequest);
}
Expand Up @@ -22,23 +22,16 @@
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import com.google.common.collect.Lists;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.cmd.LoadType;
import com.gwtplatform.carstore.server.dao.objectify.Ofy;
import com.gwtplatform.carstore.server.dao.objectify.OfyFactory;
import com.gwtplatform.carstore.server.dao.objectify.OfyService;
import com.gwtplatform.carstore.shared.dto.Dto;

public class BaseDao<T extends Dto> {
private final Class<T> clazz;

@Inject
OfyFactory ofyFactory;

private Ofy lazyOfy;

protected BaseDao(final Class<T> clazz) {
this.clazz = clazz;
}
Expand Down Expand Up @@ -93,7 +86,7 @@ public void delete(Long id) {
public void delete(List<T> objects) {
ofy().delete().entities(objects);
}

public void deleteAll() {
List<T> entities = getAll();
ofy().delete().entities(entities);
Expand All @@ -102,20 +95,17 @@ public void deleteAll() {
public List<T> get(List<Key<T>> keys) {
return Lists.newArrayList(ofy().load().keys(keys).values());
}

public int countAll() {
return ofy().load().type(clazz).count();
}

public List<T> getSome(Integer offset, Integer limit) {
return ofy().query(clazz).offset(offset).limit(limit).list();
}

protected Ofy ofy() {
if (lazyOfy == null) {
lazyOfy = ofyFactory.begin();
}
return lazyOfy;
return OfyService.ofy();
}

protected LoadType<T> query() {
Expand Down
Expand Up @@ -17,13 +17,13 @@
package com.gwtplatform.carstore.server.dao.objectify;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;
import com.googlecode.objectify.cmd.LoadType;
import com.googlecode.objectify.util.cmd.ObjectifyWrapper;
import com.googlecode.objectify.impl.ObjectifyImpl;

public class Ofy extends ObjectifyWrapper<Ofy, OfyFactory> {
public Ofy(Objectify base) {
super(base);
public class Ofy extends ObjectifyImpl<Ofy> {
public Ofy(ObjectifyFactory factory) {
super(factory);
}

public <T> LoadType<T> query(Class<T> clazz) {
Expand Down
Expand Up @@ -16,16 +16,12 @@

package com.gwtplatform.carstore.server.dao.objectify;

import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;

import static com.gwtplatform.carstore.server.dao.objectify.OfyService.ofy;

public class OfyFactory extends ObjectifyFactory {
public OfyFactory() {
}

@Override
public Ofy begin() {
return new Ofy(ofy());
public Objectify begin() {
return new Ofy(this);
}
}
Expand Up @@ -16,7 +16,6 @@

package com.gwtplatform.carstore.server.dao.objectify;

import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;
import com.googlecode.objectify.ObjectifyService;
import com.gwtplatform.carstore.server.dao.domain.Car;
Expand All @@ -28,6 +27,7 @@

public class OfyService {
static {
ObjectifyService.setFactory(new OfyFactory());
factory().register(Car.class);
factory().register(CarProperties.class);
factory().register(Manufacturer.class);
Expand All @@ -36,8 +36,8 @@ public class OfyService {
factory().register(UserSession.class);
}

public static Objectify ofy() {
return ObjectifyService.ofy();
public static Ofy ofy() {
return (Ofy) ObjectifyService.ofy();
}

public static ObjectifyFactory factory() {
Expand Down
@@ -0,0 +1,29 @@
/**
* Copyright 2014 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.carstore.server.dispatch;

import com.gwtplatform.carstore.shared.dispatch.LogInAction;
import com.gwtplatform.dispatch.rpc.server.guice.HandlerModule;

public class DispatchModule extends HandlerModule {
@Override
protected void configureHandlers() {
install(new com.gwtplatform.dispatch.rpc.server.guice.DispatchModule());

bindHandler(LogInAction.class, LogInHandler.class);
}
}