Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 1 commit
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
3  java/src/main/java/com/wineshop/services/VineyardRepository.java
@@ -2,12 +2,13 @@
import org.granite.messaging.service.annotations.RemoteDestination;
import org.granite.tide.data.DataEnabled;
+import org.granite.tide.data.DataEnabled.PublishMode;
import org.granite.tide.spring.data.FilterableJpaRepository;
import com.wineshop.entities.Vineyard;
@RemoteDestination
-@DataEnabled
+@DataEnabled(topic="wineshopTopic", publish=PublishMode.ON_SUCCESS)
public interface VineyardRepository
extends FilterableJpaRepository<Vineyard, Long> {
}
View
12 javafx/src/main/java/com/wineshop/client/Login.java
@@ -32,6 +32,7 @@
import javax.inject.Inject;
+import org.granite.client.tide.data.DataObserver;
import org.granite.client.tide.events.TideEvent;
import org.granite.client.tide.events.TideEventObserver;
import org.granite.client.tide.javafx.spring.Identity;
@@ -60,6 +61,9 @@
@Inject
private Identity identity;
+ @Inject
+ private DataObserver wineshopTopic;
+
@SuppressWarnings("unused")
@FXML
@@ -88,7 +92,13 @@ public void initialize(URL url, ResourceBundle rb) {
@Override
public void handleEvent(TideEvent event) {
- if (ServerSession.SESSION_EXPIRED.equals(event.getType())) {
+ if (ServerSession.LOGIN.equals(event.getType())) {
+ wineshopTopic.subscribe();
+ }
+ else if (ServerSession.LOGOUT.equals(event.getType())) {
+ wineshopTopic.unsubscribe();
+ }
+ else if (ServerSession.SESSION_EXPIRED.equals(event.getType())) {
labelMessage.setVisible(true);
labelMessage.setText("Session expired");
}
View
10 javafx/src/main/java/com/wineshop/client/Main.java
@@ -32,6 +32,7 @@
import org.granite.client.tide.ContextManager;
import org.granite.client.tide.collections.javafx.PagedQuery;
+import org.granite.client.tide.data.DataObserver;
import org.granite.client.tide.data.EntityManager;
import org.granite.client.tide.javafx.JavaFXApplication;
import org.granite.client.tide.javafx.JavaFXServerSessionStatus;
@@ -154,6 +155,15 @@ public App init() {
public ManagedEntity<Vineyard> vineyard(EntityManager entityManager) {
return new ManagedEntity<Vineyard>(entityManager);
}
+
+ /**
+ * Client declaration of the data publishing topic
+ */
+ @Bean
+ public DataObserver wineshopTopic(ServerSession serverSession,
+ EntityManager entityManager) {
+ return new DataObserver(serverSession, entityManager);
+ }
}
/**
View
3  webapp/src/main/webapp/WEB-INF/spring/app-config.xml
@@ -49,4 +49,7 @@
<!-- Publish JPA changes though AOP so even changes happening outside GraniteDS are dispatched -->
<graniteds:tide-data-publishing-advice mode="aspectj"/>
+ <!-- Topic destination for publishing data updates -->
+ <graniteds:messaging-destination id="wineshopTopic" no-local="true" session-selector="true"/>
+
</beans>

No commit comments for this range

Something went wrong with that request. Please try again.