diff --git a/.idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6_2_SNAPSHOT.xml b/.idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6_2_SNAPSHOT.xml
deleted file mode 100644
index 9268027..0000000
--- a/.idea/libraries/Maven__net_mantucon_baracus_baracus_framework_apklib_0_6_2_SNAPSHOT.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_baracus_baracus_framework_apklib_0_8.xml b/.idea/libraries/Maven__org_baracus_baracus_framework_apklib_0_8.xml
new file mode 100644
index 0000000..50c7c51
--- /dev/null
+++ b/.idea/libraries/Maven__org_baracus_baracus_framework_apklib_0_8.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..3b00020
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,125 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b85f2f1..13920b5 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,26 +1,27 @@
-
+
+
-
+
\ No newline at end of file
diff --git a/README b/README
index 365ab63..b296420 100644
--- a/README
+++ b/README
@@ -1 +1,8 @@
-This file was created by IntelliJ IDEA 12.1.6 for binding GitHub repository
\ No newline at end of file
+BUILDING THE EXAMPLES
+
+You MUST set the sdk path (I am developing and compiling under several machines, so there are profiles!) and activate
+Your matching profile on a maven build.
+
+Example : Windows Machine, Android SDK under C:\sdk\android\
+-> Modify the pom's android.sdk.path in the windows profile and build the app via mvn clean install -Pwindows
+
diff --git a/baracus-tutorial.iml b/baracus-tutorial.iml
index 7d84ed9..420d537 100644
--- a/baracus-tutorial.iml
+++ b/baracus-tutorial.iml
@@ -8,22 +8,30 @@
- true
+ true
+
+ /res-overlay
+
-
+
-
+
+
+
+
+
+
-
+
@@ -34,7 +42,6 @@
-
+
-
-
+
\ No newline at end of file
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/AndroidManifest.xml b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/AndroidManifest.xml
deleted file mode 100644
index c2e380f..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/AndroidManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/META-INF/MANIFEST.MF b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/META-INF/MANIFEST.MF
deleted file mode 100644
index 48b2803..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,4 +0,0 @@
-Manifest-Version: 1.0
-Archiver-Version: Plexus Archiver
-Created-By: 22.0-b10 (Oracle Corporation)
-
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/BuildConfig.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/BuildConfig.java
deleted file mode 100644
index 2e4a184..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/BuildConfig.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/*___Generated_by_IDEA___*/
-
-/** Automatically generated file. DO NOT MODIFY */
-package net.mantucon.baracus;
-
-public final class BuildConfig {
- public final static boolean DEBUG = true;
-}
\ No newline at end of file
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/Manifest.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/Manifest.java
deleted file mode 100644
index 1a69e1d..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/Manifest.java
+++ /dev/null
@@ -1,7 +0,0 @@
-/*___Generated_by_IDEA___*/
-
-package net.mantucon.baracus;
-
-/* This stub is for using by IDE only. It is NOT the Manifest class actually packed into APK */
-public final class Manifest {
-}
\ No newline at end of file
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/R.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/R.java
deleted file mode 100644
index d403991..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/gen/net/mantucon/baracus/R.java
+++ /dev/null
@@ -1,7 +0,0 @@
-/*___Generated_by_IDEA___*/
-
-package net.mantucon.baracus;
-
-/* This stub is for using by IDE only. It is NOT the R class actually packed into APK */
-public final class R {
-}
\ No newline at end of file
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/attrs.xml b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/attrs.xml
deleted file mode 100644
index 7eb4f32..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/attrs.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/strings.xml b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/strings.xml
deleted file mode 100644
index 63f815e..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/res/values/strings.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- This field must not be empty
- $1 is not an integer
- $1 is not a decimal number
- Number must be greater than zero
- The date must not be before today
-
-
\ No newline at end of file
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/annotations/Bean.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/annotations/Bean.java
deleted file mode 100644
index f075599..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/annotations/Bean.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package net.mantucon.baracus.annotations;
-
-/**
- *
- * Bean annotation denoting a bean as a component or a variable as an injection target.
- *
- *
- * Because baracus relies on type based injection
- * this annotation has only a documentary character
- * in order to enable you to mark variables a bean injection
- * targets. If you leave it out, it has no effect on the injection
- * process which is relying on types.
- *
- * Use this bean to document components and injection targets as well.
- *
- */
-public @interface Bean {
-}
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/AnnotationScanner.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/AnnotationScanner.java
deleted file mode 100644
index 3d9c938..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/AnnotationScanner.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package net.mantucon.baracus.context;
-
-import android.content.Context;
-import android.content.ContextWrapper;
-import dalvik.system.DexClassLoader;
-import dalvik.system.DexFile;
-import dalvik.system.PathClassLoader;
-import net.mantucon.baracus.util.Logger;
-
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * Annotation scanner
- *
- * Disfunctional on some android versions. do not use yet!
- *
- */
-
-@Deprecated
-public class AnnotationScanner {
-
- private AnnotationScanner() { }
-
- private static final Logger logger = new Logger(AnnotationScanner.class);
-
- public static List> getClassesAnnotatedWith(Class theAnnotation, Context context){
-
- // In theory, the class loader is not required to be a PathClassLoader
- Field field = null;
- List> candidates = new ArrayList>();
- String sourceDir = context.getApplicationInfo().sourceDir;
- try {
- DexFile dex = new DexFile(sourceDir);
- PathClassLoader classLoader2 = new PathClassLoader(sourceDir, Thread.currentThread().getContextClassLoader());
- DexClassLoader classLoader = new DexClassLoader(sourceDir, new ContextWrapper(context).getCacheDir().getAbsolutePath(), null, classLoader2);
-
- Enumeration entries = dex.entries();
- while (entries.hasMoreElements()) {
- // Each entry is a class name, like "foo.bar.MyClass"
- String entry = entries.nextElement();
- if (!entry.contains("$")) {
-
- try {
- // Load the class
-// Class> entryClass = dex.loadClass(entry, classLoader);
- Class> entryClass = classLoader.loadClass(entry);//dexFile.loadClass(entry, classLoader);
-
- logger.debug("FOUND CLASS $1", entry);
- if (entryClass == null) {
- logger.error("WARNING! Class of $1 is NULL!",entry);
- }
- if (entryClass != null && entryClass.getAnnotation(theAnnotation) != null) {
- logger.error("ADDED CLASS " + entryClass.getName());
- candidates.add(entryClass);
- }
- }catch (IllegalAccessError e) {
- logger.error("Exception during scan on $1",entry);
- }
- }
- }
-
- }catch (IOException e ) {
- throw new RuntimeException(e);
- }catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- return candidates;
- }
-
- public static boolean carriesAnnotation(Class> clazz, Class> annotation) {
- for (Annotation a : clazz.getAnnotations()) {
- logger.error("$1 carries $2",clazz.getSimpleName(),a.getClass().getName());
- if (a.getClass().getName().equals(annotation.getName())) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BaracusApplicationContext.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BaracusApplicationContext.java
deleted file mode 100644
index d3325a1..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BaracusApplicationContext.java
+++ /dev/null
@@ -1,709 +0,0 @@
-package net.mantucon.baracus.context;
-
-import android.R;
-import android.app.Activity;
-import android.app.Application;
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.TextView;
-import net.mantucon.baracus.dao.BaracusOpenHelper;
-import net.mantucon.baracus.dao.ConfigurationDao;
-import net.mantucon.baracus.errorhandling.CustomErrorHandler;
-import net.mantucon.baracus.errorhandling.ErrorHandlingFactory;
-import net.mantucon.baracus.errorhandling.ErrorSeverity;
-import net.mantucon.baracus.errorhandling.StandardErrorHandler;
-import net.mantucon.baracus.orm.AbstractModelBase;
-import net.mantucon.baracus.signalling.*;
-import net.mantucon.baracus.util.Logger;
-import net.mantucon.baracus.validation.ValidationFactory;
-import net.mantucon.baracus.validation.Validator;
-import sun.misc.MessageUtils;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import static net.mantucon.baracus.util.StringUtil.join;
-
-/**
- * Created with IntelliJ IDEA.
- * User: marcus
- * Date: 10.07.12
- * Time: 06:05
- *
- *
- * Base Application Context class. In order to use BARACUS you must inherit this class.
- * use the registerBeanClass() function to add all Your bean classes. Implement Initializable and
- * Destroyable interface in order to have creation / destruction lifecycle management support.
- *
- *
- * Example Context Implementation :
-
- {@code
-
- public class ApplicationContext extends BaracusApplicationContext{
-
- static {
- registerBeanClass(BankDao.class);
- ...
- }
-
-
- private static final Logger logger = new Logger(ApplicationContext.class);
-
- private ApplicationContext() {
- // protection constructor
- }
-
-
- }
-
- To make use of Your class as an app container, You must register it in the
- AndroidManifest.xml's application tag :
-
- {@code
-
-
-
-
- }
-
-
-
- *
- */
-public abstract class BaracusApplicationContext extends Application {
-
- // infrastructure beans
-
- // DB Access
- private static SQLiteDatabase db;
- private static BaracusOpenHelper baracusOpenHelper;
-
-
- private static boolean semaphore = false;
- private static int refCount = 0;
-
- // Awareness Refs, event handlers
- protected final static Map, DeleteAwareComponent> deleteListeners = new HashMap, DeleteAwareComponent>();
- protected final static Map, DataSetChangeAwareComponent> changeListener = new HashMap, DataSetChangeAwareComponent>();
- protected final static Map, Set> dataListener = new HashMap, Set>();
- protected final static Map, Set>> eventConsumers = new HashMap, Set>>();
-
- private static final Logger logger = new Logger(BaracusApplicationContext.class);
-
- private static volatile BaracusApplicationContext __instance = null;
-
- private static ActivityLifecycleCallbacks callbacks;
-
- private static final BeanContainer beanContainer = new BeanContainer();
-
- private static ValidationFactory validationFactory;
- private static ErrorHandlingFactory errorHandlingFactory;
-
-
- static{
- registerBeanClass(ConfigurationDao.class);
- registerBeanClass(ValidationFactory.class);
- registerBeanClass(ErrorHandlingFactory.class);
- }
-
- private static String databasePath;
-
- public BaracusApplicationContext() {
- if (__instance != null) {
- throw new ContainerAlreadyStartedException();
- }
- __instance = this;
- make();
- }
-
- /**
- * Context is not built up yet
- */
- public static class ContextNotYetCreatedException extends RuntimeException {
- ContextNotYetCreatedException (String reason) {
- super(reason);
- }
- }
-
- public static class ContainerAlreadyStartedException extends RuntimeException {
- }
-
- /**
- * thrown, if a unlocateable resource is requested
- */
- private static final class BadResourceAccessException extends RuntimeException {
- public BadResourceAccessException(Throwable throwable) {
- super(throwable);
- }
- }
-
- private static boolean init=false;
- public static synchronized void initApplicationContext() {
- if (!init) {
- beanContainer.createInstances();
-// beanContainer.holdBean(Context.class, __instance); // Inject a context simply
- beanContainer.performInjections();
- beanContainer.performPostConstuct();
- beanContainer.treatKnownUiComponents();
-
- validationFactory = getBean(ValidationFactory.class);
- errorHandlingFactory = getBean(ErrorHandlingFactory.class);
-
- init = true;
- }
- }
-
- public static synchronized void make() {
- if (!semaphore) {
- semaphore = true;
- callbacks = new ActivityLifecycleCallbacks() {
- @Override
- public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
- logger.debug("onActivityCreated called for $1",activity.getClass().getName());
- BeanContainer.addExistingActivity(activity);
-// beanContainer.holdBean(activity.getClass(), activity);
- if (!init) {
- logger.debug("build application context");
- initApplicationContext();
- }
- beanContainer.performInjection(activity);
-
- }
-
- @Override
- public void onActivityStarted(Activity activity) {
- logger.debug("onActivityStarted called for $1",activity.getClass().getName());
- BeanContainer.addActiveActivity(activity);
- }
-
- @Override
- public void onActivityResumed(Activity activity) {
- logger.debug("onActivityResumed called for $1",activity.getClass().getName());
- BeanContainer.removePausedActivity(activity);
- }
-
- @Override
- public void onActivityPaused(Activity activity) {
- logger.debug("onActivityPaused called for $1",activity.getClass().getName());
- BeanContainer.addPausedActivity(activity);
- }
-
- @Override
- public void onActivityStopped(Activity activity) {
- logger.debug("onActivityStopped called for $1",activity.getClass().getName());
- BeanContainer.removeActiveActivity(activity);
- beanContainer.performOutjection(activity);
- }
-
- @Override
- public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
- logger.debug("onActivitySaveInstanceState called for $1",activity.getClass().getName());
-
-// beanContainer.performOutjection(activity.getClass());
- }
-
- @Override
- public void onActivityDestroyed(Activity activity) {
- logger.debug("onActivityDestroyed called for $1",activity.getClass().getName());
- BeanContainer.removeExistingActivity(activity);
- }
- };
-
- __instance.registerActivityLifecycleCallbacks(callbacks);
-
-
-
- }
-
- semaphore = false;
-
- refCount++;
- }
-
- /**
- * register a bean class managed by the container A managed bean
- * can implement the lifecycle interfaces Initializable (for post-
- * construction management) and Destroyable (for pre-destroy management).
- *
- * @param theClazz
- */
- public final static void registerBeanClass(Class> theClazz) {
- beanContainer.registerBeanClass(theClazz);
- }
-
- /**
- * resolve a string and replace parameters by passed strings
- * e.g. resolveString(R.string.foo,4711)
- * @param msgId - the android string resource id
- * @param vars - the variables replacing $1,$2...$n in the string
- * @return the substituted string
- */
- public static String resolveString(Integer msgId, String... vars) {
- String rawMsg = __instance.getApplicationContext().getString(msgId);
-
- if (vars != null && vars.length > 0) {
-
- int i = 1;
- for (String parm : vars) {
- rawMsg = rawMsg.replace("$" + i, parm);
- ++i;
- }
- }
-
- return rawMsg;
- }
-
- /**
- * resolve a string and replace parameters by passed strings
- * e.g. resolveString(R.string.foo,4711)
- * single parameter function to avoid array wrapping in case of single parameters
- *
- * @param msgId - the android string resource id
- * @param var - the variables replacing $1,$2...$n in the string
- * @return the substituted string
- */
- public static String resolveString(Integer msgId, String var) {
- String rawMsg = __instance.getApplicationContext().getString(msgId);
- rawMsg = rawMsg.replace("$1", var);
- return rawMsg;
- }
-
- /**
- * destroys the application context and shreds all beans. this function allows you
- * to shut down the entire bean context in your application without restarting it
- *
- * @param force - set to true, and all references are ignored
- */
- public static synchronized void destroy(boolean force) {
- refCount--;
- if (refCount == 0 || force) {
-
- beanContainer.shutdownContext();
-
- __instance.unregisterActivityLifecycleCallbacks(callbacks);
-
- connectDbHandle().close();
- deleteListeners.clear();
- changeListener.clear();
-
- db = null;
- validationFactory = null;
- errorHandlingFactory = null;
-
- semaphore = false;
- init = false;
- System.gc();
- }
- }
-
-
- /**
- * register a deletion listener implementing the DeleteAwareComponent interface. This listener
- * is called automatically on the deletion of the associated class. notice, if a delete listener
- * causes in exception in the callback processing, it will be automatically removed from the listener table
- * @param clazz - the class
- * @param dac - the delete listener
- */
- public static synchronized void registerDeleteListener(Class extends AbstractModelBase> clazz, DeleteAwareComponent dac) {
- logger.debug("Registered DeleteListener $1 for class $2", clazz.getSimpleName(), dac.getClass().getSimpleName());
- deleteListeners.put(clazz, dac);
- }
-
- /**
- * emit a delete event on the passed model class
- * @param clazz - the class to raise the event for
- */
- public static synchronized void emitDeleteEvent(Class extends AbstractModelBase> clazz) {
- if (deleteListeners.containsKey(clazz)) {
- DeleteAwareComponent> dac = deleteListeners.get(clazz);
- try {
- dac.onDelete();
- } catch (Exception e) {
- logger.error("Caught exception while emitting delete event", e);
- deleteListeners.remove(clazz);
- }
- }
- }
-
- /**
- * register a change listener on the entity. @see registerDeleteListener. same restrictions, same behaviour
- * but this time for change events
- * @param clazz
- * @param dac
- */
- public static synchronized void registerSetChangeListener(Class extends AbstractModelBase> clazz, DataSetChangeAwareComponent dac) {
- logger.debug("Registered SetChangeListener $1 for class $2", clazz.getSimpleName(), dac.getClass().getSimpleName());
- changeListener.put(clazz, dac);
- }
-
- /**
- * emits a change event
- * @param clazz
- */
- public static synchronized void emitSetChangeEvent(Class extends AbstractModelBase> clazz) {
- if (changeListener.containsKey(clazz)) {
- DataSetChangeAwareComponent> dac = changeListener.get(clazz);
- try {
- dac.onChange();
- } catch (Exception e) {
- logger.error("Caught exception while emitting change set event", e);
- changeListener.remove(clazz);
- }
- }
- }
-
-
- /**
- * register a change listener on the entity. @see registerDeleteListener. same restrictions, same behaviour
- * but this time for change events
- *
- * @param clazz
- * @param dac
- */
- public static synchronized void registerDataChangeListener(Class extends AbstractModelBase> clazz, DataChangeAwareComponent dac) {
- logger.debug("Registered SetChangeListener $1 for class $2", clazz.getSimpleName(), dac.getClass().getSimpleName());
- Set set = dataListener.get(clazz);
- if (set == null) {
- set = new HashSet();
- dataListener.put(clazz, set);
- }
- set.add(dac);
- }
-
- /**
- * emits a change event on a single data object to all registered event recipients
- *
- * @param changedItem - the changed item
- */
- public static synchronized void emitDataChangeEvent(AbstractModelBase changedItem) {
-
- if (changedItem != null) {
- if (dataListener.containsKey(changedItem.getClass())) {
- Set dac = dataListener.get(changedItem.getClass());
- if (dac != null && dac.size() > 0) {
- for (DataChangeAwareComponent component : dac) {
- try {
- component.onChange(changedItem);
- } catch (Exception e) {
- logger.error("Caught exception while emitting change set event", e);
- dac.remove(component);
- }
- }
- }
- }
- }
- }
-
- /**
- * register a generic listener for a generic event.
- *
- * @param eventClass - the event class
- * @param handler - the handler
- */
- public static synchronized void registerGenericListener(Class extends GenericEvent> eventClass, GenericEventAwareComponent> handler) {
- logger.debug("Registered Generic Listener $1 for class $2", eventClass.getSimpleName(), handler.getClass().getSimpleName());
- Set> set = eventConsumers.get(eventClass);
- if (set == null) {
- set = new HashSet>();
- eventConsumers.put(eventClass, set);
- }
- set.add(handler);
- }
-
- /**
- * Free all consumers of an generic event
- * @param eventClass
- */
- public static synchronized void freeGenericListeners(Class extends GenericEvent> eventClass){
- Set> set = eventConsumers.get(eventClass);
- if (set != null) {
- set.clear();
- }
- }
-
- /**
- * Free all consumers of data change event
- * @param forClazz - the model class whose event listeners should be removed
- */
- public static synchronized void freeDataChangeListeners(Class extends AbstractModelBase> forClazz){
- Set set = dataListener.get(forClazz);
- if (set != null) {
- set.clear();
- }
- }
-
-
-
- /**
- * emit a generic event to all registered listeners
- * @param event
- */
- public static synchronized void emitGenericEvent(GenericEvent event) {
- Set> receivers = eventConsumers.get(event.getClass());
- if (receivers != null) {
- for (GenericEventAwareComponent receiver : receivers) {
- try {
- receiver.handleEvent(event);
- } catch (Exception e) {
- logger.error("Caught exception while emitting generic event", e);
- receivers.remove(receiver);
- }
- }
- }
- }
-
-
-
-
- /**
- * @return the android context
- */
- public static synchronized Context getContext() {
- return __instance.getApplicationContext();
- }
-
- /**
- * @return the absolute path to the database
- */
- public static String getDatabasePath() {
- return databasePath;
- }
-
- /**
- * @return a db handle. notice, if you implement DAOs you do not need this functions, the db context is injected automatically!
- */
- public static synchronized SQLiteDatabase connectDbHandle() {
- if (db == null) {
- db = connectOpenHelper().getWritableDatabase();
- databasePath = db.getPath();
- }
-
- return db;
- }
-
- /**
- * @return the open helper. currently needed by the dao.
- */
- public static synchronized BaracusOpenHelper connectOpenHelper() {
- if (baracusOpenHelper == null) {
- for (Object o : beanContainer.beanMap.values()) {
- if (BaracusOpenHelper.class.isAssignableFrom(o.getClass())) {
- baracusOpenHelper = (BaracusOpenHelper) o;
- }
- }
- if (baracusOpenHelper == null) {
- throw new ContextNotYetCreatedException("You must implement an OpenHelper deriving BaracusOpenHelper and register it to Your context!");
- }
- }
- return baracusOpenHelper;
- }
-
- /**
- * register a named validator for performing field validation in forms.
- *
- * @param name - the name of the validator
- * @param validator - the validator instance
- */
- public static synchronized void registerValidator(String name, Validator> validator) {
- validationFactory.registerValidator(name, validator);
- }
-
- /**
- * register a named validator using the simple class name (FooBarValidator -> fooBarValidator)
- * @param validator - the validator instance
- */
- public static void registerValidator(Validator> validator) {
- validationFactory.registerValidator(validator);
- }
-
- /**
- * make sure, that all named validators put into the comma seperated list are available
- * inside the context
- *
- * @param validatorList
- */
- public static synchronized void verifyValidators(String validatorList) {
- validationFactory.verifyValidators(validatorList);
- }
-
- /**
- * removes all errors from the view set before and then performs
- * validations on the passed view and applies all errors to the
- * view. use viewHasErrors() to ask, if there are any issues bound to the
- * view
- *
- * @param view - the view to process
- */
- public static synchronized void validateView(View view) {
- resetErrors(view);
- validationFactory.validateView(view);
- errorHandlingFactory.applyErrorsOnView(view);
- }
-
- /**
- * registers an onFocusChangeListener to all view elements implementing
- * the @see ConstrainedView interface to perform on-the-fly-validation.
- * If you want Your View to be able to receive a validation callback
- * - e.g. in order to manage the visibility of an OK-Button or sth. -
- * Your View must implement the @see ValidatableView interface in
- * order to receive a validation notification callbacks.
- *
- * If you implement a @see ManagedFragment, simply call
- * the enableFocusChangeBasedValidation() function in the onCreate-method
- *
- * @param view - the view to register
- */
- public static void registerValidationListener(View view) {
- validationFactory.registerValidationListener(view);
- }
-
- /**
- * register a custom error handler. Use this stuff only, if You want to use specific view components
- * to handle Your errors, if you want to use standard android handling for any component,
- * use the registerStandardErrorHandler() function instead!
- * @param handler - the handler instance
- */
- public static synchronized void registerCustomErrorHandler(CustomErrorHandler handler) {
- errorHandlingFactory.registerCustomErrorHandler(handler);
- }
-
- /**
- * register a standard error handler. Using a standard error handler will make use
- * of the android standard error handling.
- *
- * @param handler - the handler instance
- */
- public static synchronized void registerStandardErrorHandler(StandardErrorHandler handler) {
- errorHandlingFactory.registerStandardErrorHandler(handler);
- }
-
-
- /**
- * return true, if the passed view instance contains errors. Error handling should be always
- * done on the root view of a form!
- *
- * @param container - the form view containing malicious components
- * @return true, if any error is bound to the form instance
- */
- public static boolean viewHasErrors(View container) {
- return errorHandlingFactory.viewHasErrors(container);
- }
-
- /**
- * map all bound errors to all findeable receivers on the container.
- * @param container - the container to map errors for
- */
- public static void applyErrorsOnView(View container) {
- errorHandlingFactory.applyErrorsOnView(container);
- }
-
- /**
- * adds an error to the passed view. use this function only, if want to perform manual form
- * validation! if you rely on automatic validation and error routing, simply call validateView
- *
- * @param container - the container view
- * @param affectedResource - the resource id of the component, where the error occured
- * @param messageId - the message id to display
- * @param severity - the severity of the problem (currently unused)
- * @param params - the parameters to be mapped to the resource resolution
- */
- public static void addErrorToView(View container, int affectedResource, int messageId, ErrorSeverity severity, String... params) {
- errorHandlingFactory.addErrorToView(container, affectedResource, messageId, severity, params);
- }
-
- /**
- * clear all errors of the view container
- *
- * @param container - the container
- */
- public static void resetErrors(View container) {
- errorHandlingFactory.resetErrors(container);
- }
-
- /**
- * unregister all error handlers for a view. this should be called implicitly by the
- * @see ManagedFragment and the
- * @see ManagedActivity class
- *
- * If you are using own extension, make sure that you call this function before destroying
- * the view in order to avoid memory leaks
- *
- * @param v
- */
- public static void unregisterErrorhandlersForView(View v) {
- errorHandlingFactory.unregisterCustomErrorHandlersForView(v);
- }
-
-
- /**
- * returns the baracus application context instance. notice,
- * normally you should not need this instance and fully rely
- * on the automated injection mechanisms
- *
- * @return the baracus application context instance
- */
- public static BaracusApplicationContext getInstance() {
- return __instance;
- }
-
- /**
- * @param clazz - the class of the bean to be returned
- * @param - class parametrizer
- * @return the instance of the bean or null
- */
- public static T getBean(Class clazz) {
- return (T) BeanContainer.clazzMap.get(clazz);
- }
-
- /**
- * run a type based dependency injection on the passed object
- * @param o - the object where injection shall be performed on
- */
- public synchronized static void performInjectionsOn(Object o) {
- if (!semaphore) {
- beanContainer.performInjection(o);
- }
- }
-
- /**
- * creates a bean instance not cached by the container - no singleton! -
- * for your personal transient use. does not support custom constructors!
- * @param clazz - the class to be instantiaten
- * @param the type
- * @return an instance of T with all refs to components injected
- */
- public static T createPrototypeBean(Class clazz) {
- try {
- T instance = beanContainer.instantiatePojo(clazz);
- performInjectionsOn(instance);
- return instance;
- } catch (Exception e) {
- throw new Exceptions.IntantiationException(e);
- }
- }
-
- /**
- * resolve the passed name into a android resource ID, this means
- * the number representation in R.id.
- *
- * @param name - the name of a view component (e.g. btnOk)
- * @return the ID (eg -47236333)
- */
- public static final int getResource(String name) {
- try {
- Field f = R.layout.class.getField(name);
- return f.getInt(null);
- } catch (Exception e) {
- logger.error("ERROR!", e);
- throw new BadResourceAccessException(e);
- }
- }
-}
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BeanContainer.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BeanContainer.java
deleted file mode 100644
index 00ffdcb..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/BeanContainer.java
+++ /dev/null
@@ -1,388 +0,0 @@
-package net.mantucon.baracus.context;
-
-import android.app.Activity;
-import android.app.Fragment;
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import net.mantucon.baracus.dao.BaracusOpenHelper;
-import net.mantucon.baracus.lifecycle.Destroyable;
-import net.mantucon.baracus.lifecycle.Initializeable;
-import net.mantucon.baracus.util.Logger;
-
-import net.mantucon.baracus.context.Exceptions.*;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-/**
- *
- * Bean container carrying all bean instances order to keep the
- * Application somewhat tight.
- *
- */
-public class BeanContainer {
-
- private static final Logger logger = new Logger(BeanContainer.class);
-
- // We are carrying a className to Object map and a Class to Object map
- // this is simply done to avoid too many type based questions
- protected final static Map beanMap = new HashMap();
- protected final static Map, Object> clazzMap= new HashMap, Object>();
-
- // fragment holder. registering all fragments as bean will cause them
- // to be held here. Registering fragments as bean makes them become
- // injection capable and being used as a injection target
- protected final static Set knownFragments = new HashSet();
-
- // stats maps for handling context events
- protected final static Map, Object> activeActivitiesMap= new HashMap, Object>();
- protected final static Map, Object> pausedActivitiesMap= new HashMap, Object>();
- protected final static Map, Object> existingActivitiesMap= new HashMap, Object>();
-
-
- /**
- * Exception while destroying a bean. thrown if a shutdown caused
- * an error
- */
- public static class BeanDestructionException extends RuntimeException {
- BeanDestructionException(Throwable reason) {
- super(reason);
- }
- }
-
-
- /**
- * instanciate all registered beans
- */
- void createInstances() {
- for (Class> clazz : clazzMap.keySet()) {
- if (clazzMap.get(clazz) == null) {
- try {
- instantiateSingletonBean(clazz);
- logger.debug("Instantiation of $1 succeded.", clazz.getName());
- } catch (Exception e) {
- logger.debug("Instantiation of $1 failed. Reason : $2", clazz.getName(), e.getMessage());
- throw new Exceptions.IntantiationException(e);
- }
- }
- }
- }
-
- /**
- * perform postconstruct method on all bean instances implementing Initializeable
- */
- void performPostConstuct() {
- for (Object o : beanMap.values()) {
- if (o instanceof Initializeable) {
- logger.debug("Running Post Construction method on $1",o.getClass().getName());
- ((Initializeable) o).postConstruct();
- }
- }
- }
-
- /**
- * perform all bean injections on all beans
- */
- void performInjections() {
- for (Class> clazz : clazzMap.keySet()) {
- performInjection(clazz);
- }
-
- //To change body of created methods use File | Settings | File Templates.
- }
-
- /**
- * locate the passed class instance and call injection
- * @param clazz - the class whose cached singleton instance shall be injected with components
- */
- void performInjection(Class> clazz) {
- Object o = clazzMap.get(clazz);
- performInjection(o);
- }
-
- /**
- * perform injection on the passed object instance
- * @param o
- */
- void performInjection(Object o) {
- Class> clazz = o.getClass();
- for (Field field : getAllDeclaredFields(clazz)) {
- String type = field.getType().getName();
- for (Class> clazz2 : clazzMap.keySet()) {
- if (type.equals(clazz2.getName())) {
- field.setAccessible(true);
- logger.debug("$1.$2 candidate is $3",clazz.getName(),field.getName(),clazz2.getName());
- try {
- field.set(o, clazzMap.get(clazz2));
- } catch (IllegalAccessException e) {
- throw new InjectionException("Failed to set "+clazz.getName()+"."+field.getName()+" with bean "+clazz2.getName(),e);
- }
- } else if (type.equals(SQLiteDatabase.class.getName())) {
- field.setAccessible(true);
- logger.debug("$1.$2 candidate is $3",clazz.getName(),field.getName(),clazz2.getName());
- try {
- field.set(o, BaracusApplicationContext.getInstance().connectDbHandle());
- } catch (IllegalAccessException e) {
- throw new InjectionException("OMG SQLite injection issued a major clusterfuck",e);
- }
- } else if (type.equals(BaracusOpenHelper.class.getName())) {
- field.setAccessible(true);
- logger.debug("$1.$2 candidate is $3",clazz.getName(),field.getName(),clazz2.getName());
- try {
- field.set(o, BaracusApplicationContext.getInstance().connectOpenHelper());
- } catch (IllegalAccessException e) {
- throw new InjectionException("OMG OpenHelper injection issued a major clusterfuck",e);
- }
- } else if (type.equals(Context.class.getName())) {
- field.setAccessible(true);
- logger.debug("$1.$2 candidate is $3",clazz.getName(),field.getName(),clazz2.getName());
- try {
- field.set(o, BaracusApplicationContext.getInstance());
- } catch (IllegalAccessException e) {
- throw new InjectionException("OMG Context injection issued a major clusterfuck",e);
- }
- }
- }
- }
- }
-
- /**
- * @param clazz - the class to scan
- * @return all fields of all types
- */
- Field[] getAllDeclaredFields(Class> clazz) {
- ArrayList fields = new ArrayList();
-
- fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
-
- Class> superclass = clazz;
-
- while ((superclass = superclass.getSuperclass()) != null) {
- fields.addAll(Arrays.asList(superclass.getDeclaredFields()));
- }
-
- return fields.toArray(new Field[fields.size()]);
- }
-
- /**
- * nullify component refs in all beans
- */
- void performDestruction() {
- for (Class> clazz : clazzMap.keySet()) {
- performOutjection(clazz);
- }
-
- for (Class> clazz : clazzMap.keySet()) {
- removeBean(clazz);
- }
- }
-
- /**
- * tidy upp all managed references of clazz in order to avoid loitering objects
- * @param clazz
- */
- void performOutjection(Class> clazz) {
- Object o = clazzMap.get(clazz);
- if (o == null) {
- logger.warn("Warning! Object of type $1 was already nulled!",clazz.getName());
- } else {
- performOutjection(o);
- }
- }
-
- void performOutjection(Object o) {
- Class> clazz = o.getClass();
- for (Field field : getAllDeclaredFields(clazz)) {
- String type = field.getType().getName();
- for (Class> clazz2 : clazzMap.keySet()) {
- if (type.equals(clazz2.getName())) {
- field.setAccessible(true);
- logger.debug("$1.$2 nullified",clazz.getName(),field.getName(),clazz2.getName());
- try {
- field.set(o, null);
- } catch (IllegalAccessException e) {
- throw new BeanDestructionException(e);
- }
- }
- }
- }
- }
-
-
- /**
- * instanciate a bean class. if the bean class has got a constructor carrying the android Context,
- * this constructor is used to pass the context. Otherwise, your bean has to implement a default
- * constructor!
- *
- * @param theClazz - the clazz to instanciate
- * @throws InstantiationException
- * @throws IllegalAccessException
- * @throws java.lang.reflect.InvocationTargetException
- */
- void instantiateSingletonBean(Class> theClazz) throws InstantiationException, IllegalAccessException, InvocationTargetException {
- Object result = instantiatePojo(theClazz);
- holdBean(theClazz, result);
- }
-
- /**
- * create an instance of the passed class regarding the application context contructor
- *
- * @param theClazz
- * @return
- * @throws InstantiationException
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- T instantiatePojo(Class theClazz) throws InstantiationException, IllegalAccessException, InvocationTargetException {
- T result = null;
- for (Constructor c : theClazz.getConstructors()) {
- Class>[] parameterTypes = c.getParameterTypes();
- if (parameterTypes == null || parameterTypes.length == 0) {
- // default Constructor
- result = theClazz.newInstance();
- break;
- } else if (parameterTypes.length == 1 && parameterTypes[0].equals(Context.class)) {
- result = (T) c.newInstance(BaracusApplicationContext.getContext());
- break;
- }
- }
-
- if (result == null) {
- throw new InstantiationException(theClazz.getName()+" could not be instantiated. Please provide a) a public default constructor or b) a public constructor takinng the Android Context as it's only parameter!");
- }
- return result;
- }
-
- /**
- * put the bean into the holders
- * @param theClazz
- * @param o
- */
- void holdBean(Class> theClazz, Object o) {
- beanMap.put(theClazz.getName(), o);
- clazzMap.put(theClazz ,o);
- if (o instanceof Fragment) {
- knownFragments.add((Fragment)o);
- }
- }
-
- /**
- * remove the bean class from the holders
- * @param theClazz
- */
- void removeBean(Class> theClazz) {
- beanMap.put(theClazz.getName(), null);
- clazzMap.put(theClazz, null);
- }
-
- /**
- * register a bean class managed by the container A managed bean
- * can implement the lifecycle interfaces Initializable (for post-
- * construction management) and Destroyable (for pre-destroy management).
- *
- * @param theClazz
- */
- final void registerBeanClass(Class> theClazz) {
- final String clazzName = theClazz.getName();
- if (!beanMap.containsKey(clazzName)) {
- try {
- holdBean(theClazz,null);
-
- } catch (Exception e) {
- throw new RegistrationException(e);
- }
- }
- }
-
- /**
- * Shred the beans.
- */
- synchronized void shutdownContext() {
- for (Object o : beanMap.values()) {
- if (o instanceof Destroyable) {
- ((Destroyable) o).onDestroy();
- }
- }
- performDestruction();
- System.gc();
- }
-
- private void unregisterClasses() {
- for (Class> c : clazzMap.keySet()) {
- removeBean(c);
- }
- }
-
- static void addActiveActivity(Activity activity){
- addActivity(activity,activeActivitiesMap);
- }
- static void addExistingActivity(Activity activity){
- addActivity(activity,existingActivitiesMap);
- }
- static void addPausedActivity(Activity activity){
- addActivity(activity,pausedActivitiesMap);
- }
-
- static void removeActiveActivity(Activity activity){
- removeActivity(activity,activeActivitiesMap);
- }
- static void removeExistingActivity(Activity activity){
- removeActivity(activity,existingActivitiesMap);
- }
- static void removePausedActivity(Activity activity){
- removeActivity(activity,pausedActivitiesMap);
- }
-
- static void printStats() {
- logger.info("EXSTING $1", existingActivitiesMap.size());
- logger.info("ACTIVE $1", activeActivitiesMap.size());
- logger.info("RESUMED $1", pausedActivitiesMap.size());
- }
-
-
- private static void addActivity(final Activity activity, final Map, Object> map ) {
-
- if (map.containsKey(activity.getClass())) {
- logger.debug("Activity class $1 already in keyset", activity.getClass().getName());
- }
-
- if (map.containsValue(activity)) {
- logger.debug("Activity $1 already in values",activity);
- }
-
- map.put(activity.getClass(),activity);
- printStats();
- }
-
- private static void removeActivity(final Activity activity, final Map, Object> map ) {
-
- if (!map.containsKey(activity.getClass())) {
- logger.debug("Activity class $1 not in keyset", activity.getClass().getName());
- }
-
- if (!map.containsValue(activity)) {
- logger.debug("Activity $1 not in values",activity);
- }
-
- map.remove(activity.getClass());
- printStats();
- }
-
-
- public void treatKnownUiComponents() {
- for (Object o : activeActivitiesMap.values()) {
- performInjection(o);
- }
-
- for (Fragment f : knownFragments) {
- try {
- performInjection(f);
- } catch (Exception e) {
- logger.debug("$1 has caused an injection problem and is going to be removed from list.");
- knownFragments.remove(f);
- }
- }
- }
-
-}
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/Exceptions.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/Exceptions.java
deleted file mode 100644
index 1df2e74..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/Exceptions.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package net.mantucon.baracus.context;
-
-public class Exceptions {
- /**
- * Bean instanciation fucked up. Thrown when the instantiation of
- * a bean caised an errer
- */
- final static class IntantiationException extends RuntimeException {
- IntantiationException(Throwable reason) {
- super(reason);
- }
- }
-
-
- /**
- * Registration of a bean failed.
- */
- final static class RegistrationException extends RuntimeException {
- RegistrationException(Throwable reason) {
- super(reason);
- }
- }
-
- /**
- * Injection of a bean caused an error
- */
- final static class InjectionException extends RuntimeException {
- InjectionException(Throwable reason) {
- super(reason);
- }
- InjectionException(String msg, Throwable reason) {
- super(msg, reason);
- }
- }
-}
\ No newline at end of file
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedActivity.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedActivity.java
deleted file mode 100644
index ae97dcd..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedActivity.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package net.mantucon.baracus.context;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.View;
-
-/**
- * Created with IntelliJ IDEA.
- * User: marcus
- * Date: 23.09.13
- * Time: 08:34
- * To change this template use File | Settings | File Templates.
- */
-public class ManagedActivity extends Activity{
-
- protected View underlyingView;
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- this.underlyingView = getWindow().getDecorView().findViewById(android.R.id.content);
- }
-
- @Override
- protected void onDestroy() {
- BaracusApplicationContext.unregisterErrorhandlersForView(underlyingView);
- super.onDestroy();
- }
-
-}
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedFragment.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedFragment.java
deleted file mode 100644
index c347037..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/context/ManagedFragment.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package net.mantucon.baracus.context;
-
-import android.app.Fragment;
-import android.view.View;
-import android.widget.EditText;
-
-/**
- * Created with IntelliJ IDEA.
- * User: marcus
- * Date: 17.05.13
- *
- * This class is needed in order to juxtaposition the reinstantiaon of Fragment beans
- * by android e.g. when a device rotate happens - unless I have found something
- * more appropriate for it (Hooking into the lifecycle in android handling the fragments
- * must be possible)
- *
- * Simple inherit this class and register it as usual as a Fragment bean and all accesses
- * to injected beans will work fine :)
- *
- */
-public abstract class ManagedFragment extends Fragment {
-
- // set this View from derived classes if You want to use automatic error handling
- protected View view;
-
- public ManagedFragment() {
- BaracusApplicationContext.performInjectionsOn(this);
- }
-
- @Override
- public void onDestroyView() {
- if (view != null) { // if you use the automatic error routing extension, you MUST set the view
- // when inflating the form. Notice, this is normally done in the
- // onCreateView function. If You do not set the view field when inflating
- // a new view, you will create memory leaks, because all bound errorHandlers
- // cannot be marked for removal by the garbage collector because they are
- // held in the application context bound to the containing view instance!
- BaracusApplicationContext.unregisterErrorhandlersForView(this.view);
- }
- super.onDestroyView();
- }
-
- /**
- * enables the validation of the view onFocusChanged
- * If you want Your View to
- * be able to receive a validation callback - e.g. in order to manage the
- * visibility of an OK-Button or sth. - Your View must implement
- * the @see ValidatableView interface in order to receive a validation
- * notification.
- *
- * Notice, You must set the underlying view instance to enable this feature!
- *
- */
- public void enableFocusChangeBasedValidation() {
- BaracusApplicationContext.registerValidationListener(this.view);
- }
-}
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaracusOpenHelper.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaracusOpenHelper.java
deleted file mode 100644
index 5c4914b..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaracusOpenHelper.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package net.mantucon.baracus.dao;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import net.mantucon.baracus.lifecycle.Destroyable;
-import net.mantucon.baracus.migr8.MigrationStep;
-import net.mantucon.baracus.migr8.ModelVersion000;
-import net.mantucon.baracus.util.Logger;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- * OpenHelper base class used to manage Your database within baracus.
- * Automatic database management includes context & connection management plus
- * database creation and automatic migration support.
- *
- * You must implement this class providing a target version, a database name and the
- * android context. Also, You must add it to the beans using Your ApplicationContext!
- *
- *
- *
- *
- *
- * Example:
- *
-
- {@code
- public class OpenHelper extends BaracusOpenHelper {
-
- public static final String DATABASE_NAME = "my_application.db"; // database name
- public static final int TARGET_DATABASE_VERSION = 110; // target versiion
-
- static {
- upgradeSteps.put(100, new ModelVersion100()); // one upgrade since initial version
- // here you can add all migration steps. please
- // be sure to apply increasing numbers.
- }
-
-
- public OpenHelper(Context mContext) {
- super(mContext, DATABASE_NAME, TARGET_DATABASE_VERSION);
- }
-
- public MigrationStep getInitialModel() {
- return new ModelVersion100();
- }
-}
-
- *
- *
- */
-public abstract class BaracusOpenHelper extends SQLiteOpenHelper implements Destroyable {
-
- /**
- * Exception preventing us from reusing a version number. This can to severe damage on Your
- * database. Do not rebind Migration objects
- */
- public static class VersionNumberAlreadyBoundException extends IllegalArgumentException {
- public VersionNumberAlreadyBoundException(String s) {
- super(s);
- }
- }
-
- private final Logger logger = new Logger(getClass()); // Logger
-
- protected static Map upgradeSteps = new HashMap(); // Here are the upgrade steps
-
- private final String databaseName; // set this value via constructor in order to define the db name
-
- /* set this value via constructor in order to set the target version
- we are going to iterate all bound version migrators from initialVersion
- until target version
- */
- private final int targetDatabaseVersion;
-
- static {
- upgradeSteps.put(110, new ModelVersion000());
- }
-
- /**
- * Open Helper for the android database
- *
- * @param mContext - the android context
- * @param databaseName - the database name of your app
- * @param targetDatabaseVersion the target version. automatic migration will be done until this version
- */
- protected BaracusOpenHelper(Context mContext, String databaseName, int targetDatabaseVersion) {
- super(mContext, databaseName, null, targetDatabaseVersion);
- this.databaseName = databaseName;
- this.targetDatabaseVersion = targetDatabaseVersion;
- }
-
- /**
- * Creation function . do not edit. do not override. it takes care of the creation of your
- * database
- *
- * @param db
- */
- @Override
- public final void onCreate(SQLiteDatabase db) {
-
- MigrationStep initialModel = getInitialModel();
- initialModel.applyVersion(db);
-
- onUpgrade(db, initialModel.getModelVersionNumber(), targetDatabaseVersion);
-
- }
-
-
- public MigrationStep getInitialModel(){
- return new ModelVersion000();
- }
-
- /**
- * use this method in order to add further migration steps to your db.
- * each release with database changes should bring a migration step
- *
- * you should not change the prior defined steps any more. this will
- * make your database safe for creation and migration on
- * a brand new target system.
- *
- * @param step - the migration step
- */
- protected static final void addMigrationStep(MigrationStep step) {
- if (upgradeSteps.containsKey(step.getModelVersionNumber())) {
- throw new VersionNumberAlreadyBoundException("The version number "+step.getModelVersionNumber()+" is already present in migration object list!");
- }
- upgradeSteps.put(step.getModelVersionNumber(), step);
- }
-
- /**
- * Do not modify this function. Do not override. It takes care of your database
- * migration.
- *
- * @param db - database ref
- * @param oldVersion - the current version
- * @param newVersion - the version to migrate to
- */
- @Override
- public final void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- for (int i = oldVersion+1 ; i <= newVersion; ++i) {
- MigrationStep step = upgradeSteps.get(i);
- if (step != null) {
- logger.info("Applying Version $1",i);
- step.applyVersion(db);
- } else {
- logger.debug("No Version for $1",i);
- }
- }
- }
-
- public void onDestroy() {
-
- try {
- this.close();
- } catch (Exception e) {
- logger.error("On destroy failed", e);
- }
-
- }
-
- public String getDatabaseName() {
- return databaseName;
- }
-
-
-}
\ No newline at end of file
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaseDao.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaseDao.java
deleted file mode 100644
index 5b973b7..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/BaseDao.java
+++ /dev/null
@@ -1,390 +0,0 @@
-package net.mantucon.baracus.dao;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import net.mantucon.baracus.annotations.Bean;
-import net.mantucon.baracus.context.BaracusApplicationContext;
-import net.mantucon.baracus.orm.AbstractModelBase;
-import net.mantucon.baracus.orm.Field;
-import net.mantucon.baracus.orm.FieldList;
-import net.mantucon.baracus.orm.Timestamped;
-import net.mantucon.baracus.util.Logger;
-
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * DAO Base Class. If You want to make use of DAOs, You must derive this class to manage a
- * POJO deriving AbstractModelBase
- *
- * @param
- * @see ConfigurationDao for an example DAO.
- */
-public abstract class BaseDao{
-
- @Bean
- private SQLiteDatabase db;
-
- private final Logger logger = new Logger(this.getClass());
-
- protected final Class managedClass;
-
- /**
- * Rowmapper component providing the object mapping functions
- * example :
-
- RowMapper rowMapper = new RowMapper() {
-
- @Override
- public ConfigurationParameter from(Cursor c) {
- ConfigurationParameter result = new ConfigurationParameter();
- result.setId(c.getLong(idCol.fieldIndex));
- result.setConfigParameter(c.getString(configParamCol.fieldIndex));
- result.setConfigParameterValue(c.getString(configParamValueCol.fieldIndex));
- result.setTransient(false);
- return result;
- }
-
- @Override
- public String getAffectedTable() { return TABLE_CONFIGURATION; }
-
- @Override
- public FieldList getFieldList() { return ConfigurationParameter.fieldList; }
-
- @Override
- public Field getNameField() {
- return ConfigurationParameter.configParamCol;
- }
-
- public ContentValues getContentValues(ConfigurationParameter parm) {
- ContentValues result = new ContentValues();
- if (parm.getId() != null) { result.put(idCol.fieldName, parm.getId()); }
- if (parm.getConfigParameter() != null) { result.put(configParamCol.fieldName, parm.getConfigParameter()); }
- if (parm.getConfigParameterValue()!= null) { result.put(configParamValueCol.fieldName, parm.getConfigParameterValue()); }
- return result;
- }
- };
-
- * @param
- */
- public static interface RowMapper {
- /**
- * maps the cursor content to a model bean (aka entity bean)
- * @param c - the cursor
- * @return the model bean
- * @see ConfigurationDao.RowMapper
- */
- T from(Cursor c);
-
- /**
- * @return the affected table name
- * @see ConfigurationDao.RowMapper
- */
- String getAffectedTable();
-
- /**
- * @return the field list of your model bean
- * @see ConfigurationDao.RowMapper
- * @see net.mantucon.baracus.model.ConfigurationParameter
- */
- FieldList getFieldList();
-
- /**
- * just for convinience, if your model has an unique name identifier (e.g. bankName(
- * you can return this field. a matching dao then automatically has got a getByName function
- * @return the name field
- * @see ConfigurationDao.RowMapper
- *
- */
- Field getNameField();
-
- /**
- * makes a SQLite content values object out of your model bean in order to
- * perform an update or an insert on the entity.
- *
- * @param item - the model bean
- * @return the content values object
- * @see ConfigurationDao.RowMapper
- */
- ContentValues getContentValues(T item);
- }
-
- /**
- * Lock-in Constructor. Replaces the deprecated getManagedClass() function in order to save
- * performance
- * @param managedClass - the model class Your Dao manages
- */
- protected BaseDao(Class managedClass) {
- this.managedClass = managedClass;
- }
-
- /**
- * performs a delete operation on the db
- * @param model
- * @return
- */
- public int delete(final AbstractModelBase model){
- int result=0;
- if (!model.isTransient()) {
- result = db.delete(model.getTableName(), AbstractModelBase.idCol.fieldName + " = ?", new String[]{model.getId().toString()});
- BaracusApplicationContext.emitDeleteEvent(managedClass);
- model.setTransient(true);
- } else {
- logger.warn("Warning. You tried to delete a transient entity of type $1. No operation performed!.",model.getClass().getName());
- result = -1;
- }
- return result;
- }
-
- /**
- * fetches an model bean out the db using the Long id.
- * @param id - the id
- * @return the model bean;
- */
- public T getById(Long id) {
-
- RowMapper rowMapper = getRowMapper();
- Cursor c = null;
- T result = null;
- try {
- c = db.query(true, rowMapper.getAffectedTable(), rowMapper.getFieldList().getFieldNames(), AbstractModelBase.idCol.fieldName + "= ?", new String[]{id.toString()}, null, null, null, null);
- if (!c.isAfterLast() && c.moveToNext() ) {
- result = rowMapper.from(c);
- } else {
- result = null;
- }
- } finally {
- if (c != null && !c.isClosed()) {
- c.close();
- }
- }
- return result;
- }
-
- /**
- * return a unique item identified by it's name (e.g. Bank.bankName). To make use of this feature,
- * Your rowmapper must return a proper name column in the getNameCol function (@see ConfigurationDao.RowMapper)
- *
- * @param name - the name String
- * @return the object identified by this name
- */
- public T getByName(String name) {
- logger.trace("get object by name $1",name);
-
- RowMapper rowMapper = getRowMapper();
- Field nameField = rowMapper.getNameField();
-
- if (nameField == null) {
- throw new UnsupportedOperationException("NAME FIELD IS NOT DEFINED FOR THIS TYPE : "+rowMapper.getAffectedTable()+". You have to implement Your RowMapper's getNameField function properly to make use of this feature.");
- }
- Cursor c = null;
- T result = null;
- try {
-
- c = db.query(true, rowMapper.getAffectedTable(), rowMapper.getFieldList().getFieldNames(), nameField + "= ?", new String[]{name}, null, null, null, null);
- if (!c.isAfterLast() && c.moveToNext() ) {
- result = rowMapper.from(c);
- } else {
- result = null;
- }
- } finally {
- if (c != null && !c.isClosed()) {
- c.close();
- }
- }
- return result;
- }
-
- /**
- * @return all entities of Your type in database.
- */
- public List loadAll() {
- RowMapper rowMapper = getRowMapper();
- Cursor c = null;
- List result = new LinkedList();
- try {
- c = db.query(true, rowMapper.getAffectedTable(), rowMapper.getFieldList().getFieldNames(), null, null, null, null, null, null);
- result = iterateCursor(c);
-
- } catch (Exception e) {
- logger.error("An Error has occured",e);
- } finally{
- if (c != null && !c.isClosed()) {
- c.close();
- }
- }
- return result;
- }
-
- /**
- * Transaction handle. Enables You to have transactions with sqlite in a jdbc-alike way.
- * You can get it by calling the beginTransaction function
- */
- public final class TxHandle {
- private final SQLiteDatabase db;
-
- private TxHandle(SQLiteDatabase db){
- this.db = db;
- }
-
- public final void commit() {
- this.db.setTransactionSuccessful();
- this.db.endTransaction();
- }
-
- public final void rollback() {
- this.db.endTransaction();
- }
-
- }
-
- /**
- * starts a new sqlite transaction
- * @return the transaction handle
- */
- public TxHandle getTransaction() {
- db.beginTransaction();
- return new TxHandle(db);
- }
-
- /**
- * save an item without reusing an existing transaction (autocommit)
- *
- * @param item - the model bean to save
- */
- public void save(T item) {
- save(item,null);
- }
-
- /**
- * save an item in a running transaction. requires you later to call txHandle.commit() in
- * order to commit the transaction.
- *
- * @param item - the model bean
- * @param handle - the transaction handle
- */
- public void save(T item, TxHandle handle) {
- logger.trace("save object $1",item);
-
- boolean requiresSetChange = false;
- boolean requiresInstanceChange = false;
-
- RowMapper rowMapper = getRowMapper();
- ContentValues cv = rowMapper.getContentValues(item);
-
- boolean localTransaction = handle == null;
- if (localTransaction) {
- db.beginTransaction();
- }
-
- try {
- if (item.getId() == null || item.isTransient()) {
- if (item instanceof Timestamped) {
- Timestamped t = (Timestamped) item;
- t.setCreationDate(new Date());
- t.setLastModificationDate(new Date());
- }
- long key = db.insert(rowMapper.getAffectedTable(), null, cv);
- item.setId(key);
- item.setTransient(false);
- requiresSetChange = true;
- } else {
- if (item instanceof Timestamped) {
- Timestamped t = (Timestamped) item;
- if (t.getCreationDate() == null) { t.setCreationDate(new Date()); }
- t.setLastModificationDate(new Date());
- }
- db.update(rowMapper.getAffectedTable(), cv, AbstractModelBase.idCol.fieldName + "= ?", new String[]{item.getId().toString()});
- requiresInstanceChange = true;
- }
- if (localTransaction) {
- db.setTransactionSuccessful();
- }
- } finally {
- if (localTransaction) {
- db.endTransaction();
- }
- }
-
- if (requiresSetChange) {
- BaracusApplicationContext.emitSetChangeEvent(managedClass);
- }
-
- if (requiresInstanceChange) {
- BaracusApplicationContext.emitDataChangeEvent(item);
- }
- }
-
- /**
- * clears the entire table
- */
- public void deleteAll() {
- RowMapper rowMapper = getRowMapper();
- db.delete(rowMapper.getAffectedTable(), null, null);
-
- }
-
- /**
- * iterate the cursor in order to have a list of entity afterwards
- *
- * @param c - the cursor
- * @return - all mapped entities
- */
- protected List iterateCursor(Cursor c) {
- RowMapper rowMapper = getRowMapper();
- List result = new LinkedList();
- while (!c.isAfterLast() && c.moveToNext() ) {
- result.add(rowMapper.from(c));
- }
- return result;
- }
-
- /**
- * @return the rowmapper implemented by you. @see ConfigurationDao.RowMapper
- */
- public abstract RowMapper getRowMapper();
-
-
- /**
- * save the entire list of entity beans without transaction (autocommit)
- *
- * @param list - the list of beans
- */
- public void saveAll(List list) {
- saveAll(list,null);
- }
-
- /**
- * save the entire list of entity beans in a transaction. requires you to
- * call the txHandle.commit() later
- *
- * @param list - the list of beans
- * @param handle - the tx handle
- */
- public void saveAll(final List list, final TxHandle handle) {
- final boolean localTransaction = handle == null;
- final TxHandle txHandle = localTransaction ? getTransaction() : handle;
- try {
- for (T item : list) {
- save(item,handle);
- }
-
- if (localTransaction) {
- txHandle.commit();
- }
- }catch (RuntimeException e){
- if (localTransaction) {
- txHandle.rollback();
- }
- }
- }
-
- /**
- * @return the db reference
- */
- protected SQLiteDatabase getDb() {
- return db;
- }
-}
diff --git a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/ConfigurationDao.java b/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/ConfigurationDao.java
deleted file mode 100644
index f0d4f1a..0000000
--- a/gen-external-apklibs/net.mantucon.baracus_baracus-framework_0.6.2-SNAPSHOT/src/net/mantucon/baracus/dao/ConfigurationDao.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package net.mantucon.baracus.dao;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import net.mantucon.baracus.annotations.Bean;
-import net.mantucon.baracus.model.ConfigurationParameter;
-import net.mantucon.baracus.orm.AbstractModelBase;
-import net.mantucon.baracus.orm.Field;
-import net.mantucon.baracus.orm.FieldList;
-
-import static net.mantucon.baracus.model.ConfigurationParameter.*;
-import static net.mantucon.baracus.orm.AbstractModelBase.idCol;
-/**
- *
- * Configuration DAO component
- *
- *
- * This component is a fully functional configuration dao ready to use in order
- * to store in-application key-value-pairs. It is recommended to wrap
- * access to the key-value-pairs into a service bean which is used
- * to return type-safe variables (e.g. "myCount" in configuration is held as string "99")
- * but in your app your service should take care of the type and return myCount as an integer
- * value
- *
- *