Skip to content

Commit

Permalink
development of services handling API proposed in issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Bifulco Luigi authored and Bifulco Luigi committed Jul 3, 2015
1 parent a09cd5d commit fc1aec3
Show file tree
Hide file tree
Showing 5 changed files with 635 additions and 792 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Service {

public String name();

}
2 changes: 2 additions & 0 deletions appify/appify-core/src/main/java/it/appify/api/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
public interface Service {

public void start();

public void stop();

}
40 changes: 25 additions & 15 deletions appify/appify-core/src/main/java/it/appify/app/AbstractWebApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
*/
package it.appify.app;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;

import com.google.gwt.dom.client.Element;
//TODO: add an update and store method
//for enqueue all read&write request Scheduler.get().scheduleDeferred(
//new ScheduledCommand() {

import it.appify.api.AppVisibility;
import it.appify.api.AppVisibility.VisibilityCallback;
import it.appify.api.Battery;
Expand All @@ -31,6 +42,7 @@
import it.appify.api.PageManager.Transitions;
import it.appify.api.Service;
import it.appify.api.Storage;
import it.appify.app.service.ServiceManager;
import it.appify.appvisibility.SinglePageAppVisibility;
import it.appify.logging.ConsoleLogger;
import it.appify.screenorientation.WebScreenOrientation;
Expand All @@ -39,17 +51,6 @@
import it.appify.view.WebModelView;
import it.appify.view.WebPage;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;

import com.google.gwt.dom.client.Element;
//TODO: add an update and store method
//for enqueue all read&write request Scheduler.get().scheduleDeferred(
//new ScheduledCommand() {

public abstract class AbstractWebApp<AppState> implements WebApp<AppState> {

protected AppVisibility visibility;
Expand Down Expand Up @@ -102,17 +103,20 @@ public void onPageShow(Page<Element> page) {

@Override
public void onPageReady(Page<Element> page) {
ConsoleLogger.getConsoleLogger().log("AbstractWebApp onPageReady: " + mainPage + " - " + page.getPageId() + " - " + firstLoad);
ConsoleLogger.getConsoleLogger()
.log("AbstractWebApp onPageReady: " + mainPage + " - " + page.getPageId() + " - " + firstLoad);

/**/
List<ControllerHolder<?>> controllers = pageControllers.get(page.getPageId());
if (controllers != null) {
for (ControllerHolder<?> controllerHolder : controllers) {
ConsoleLogger.getConsoleLogger().log("injecting elements: " + controllerHolder.pageId + " - " + controllerHolder.viewId + " - " + controllerHolder.fieldName);
ConsoleLogger.getConsoleLogger().log("injecting elements: " + controllerHolder.pageId + " - "
+ controllerHolder.viewId + " - " + controllerHolder.fieldName);
controllerHolder.injectViewElements();
}
} else {
ConsoleLogger.getConsoleLogger().log("warning control holders injectViewElements no elements: " + controllers + " - " + page.getPageId());
ConsoleLogger.getConsoleLogger().log("warning control holders injectViewElements no elements: "
+ controllers + " - " + page.getPageId());
}
// if occurs first load of main page it's a good idea to start app
// services
Expand Down Expand Up @@ -157,7 +161,8 @@ public void onHidden() {
controllerHolder.callPageReadyHandler();
}
} else {
ConsoleLogger.getConsoleLogger().log("warning callPageReadyHandler no elements: " + ctrlHolders + " - " + page.getPageId());
ConsoleLogger.getConsoleLogger()
.log("warning callPageReadyHandler no elements: " + ctrlHolders + " - " + page.getPageId());
}
}

Expand Down Expand Up @@ -478,6 +483,11 @@ public void done() {
public boolean isVisible() {
return visibility.isAppVisible();
}

@Override
public Service getService(String name){
return ServiceManager.getService(name);
}

protected abstract WebModelView<AppState> getAppStateModelView();

Expand Down
3 changes: 3 additions & 0 deletions appify/appify-core/src/main/java/it/appify/app/WebApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import it.appify.api.ApplicationCache;
import it.appify.api.Battery;
import it.appify.api.Geolocation;
import it.appify.api.Service;
import it.appify.api.Storage;
import it.appify.screenorientation.WebScreenOrientation;
import it.appify.view.WebPage;
Expand Down Expand Up @@ -78,6 +79,8 @@ public interface AppListener<AppState> {

public boolean isVisible();

public Service getService(String name);




Expand Down
Loading

0 comments on commit fc1aec3

Please sign in to comment.