Ignore:
Timestamp:
07/02/13 16:20:07 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

CHANGELOG:
Make ProcedureParam? hold only ValueParams?.

Use id instead of names when naming gui components internally.

Basic procedure calling in GUI.

The actual procedure call is currently only backed
by the ObjectInstance?.

Add UnimplementedException?.

Improve naming of various gui elements.

Allow easy navigating in FEST Swing testing.

Add optional explicit order attribute to FramsClassAnnotation?.

That's because java reflection does return declared members
in any specific order. That ordering is needed only for
classes that have no representation in framsticks and need
a deterministic ordering of params.

Add ControlOwner? interface.

Add test for procedure calling in Browser.

First version of ParamAnnotation? for procedures.

Development of ProcedureParam?.

Add draft version of ProcedureParam? implementation in ReflectionAccess?.

Allow viewing FramsClasses? in gui Browser.

Extract ResourceBuilder? from ModelBuilder?.

Remove internalId from Param.

It was currently completely not utilised. Whether it is still needed
after introduction of ParamAnnotation? is arguable.

Add remaining param attributes to ParamAnnotation?.

Change AutoBuilder? semantics.

AutoBuilder? returns list of objects that are to be appended
with methods @AutoAppendAnnotation?.

This allows to omit explicit addition of ModelPackage? to instance
if the instance uses ModelBuilder? (registration of ModelPackage? comes
from schema).

Fix params ordering problem in auto created FramsClasses?.

Improve ObjectInstance?.

Several fixes to ModelBuilder?.

Improve test for ObjectInstance? in Browser.

Make initialization of robot static.

With robot recreated for second browser test, the test hanged
deep in AWT.

Add base convenience base test for Browser tests.

More tests to ObjectInstance?.

Rename Dispatcher.invokeLater() to dispatch().

Add assertDispatch.

It allows assertions in other threads, than TestNGInvoker.
Assertions are gathered after each method invocation and rethrown.

Use timeOut annotation attribute for tests involving some waiting.

Remove firstTask method (merge with joinableStart).

Clean up leftovers.

Remove unused FavouritesXMLFactory (the reading part is already
completely done with generic XmlLoader?, and writing part will be done
based on the same approach if needed).
Move UserFavourite? to the com.framsticks.gui.configuration package.

Remove GenotypeBrowser? as to specific.

This functionality will be available in ObjectInstance?.

Add interface ParamsPackage?.

Package containing registration of Java classes meant to use with
ReflectionAccess? may be in Instance using configuration.

Minor changes.

Make Group immutable.

Add AutoBuilder? interface extending Builder - only those would
be used to automatically build from XML.

Fix groups in FramsClass?.

Minor naming cleanup in Registry.

Add ModelComponent? interface.

All class creating the Model are implementing that interface.

Extract Model.build into ModelBuilder?.

ModelBuilder? will be compatible with other builders
and allow using it from configuration.

Fix NeuroConnection?.

Add synchronous get operation for dispatchers.

Rename JoinableMonitor? to Monitor.

Add ObjectInstance?.

This class is mainly for demonstration
and testing purposes.

Improve FramsServer? runner.

  • improve ExternalProcess? runner,
  • runner can kill the server but also react properly, when the server exists on it's own,
  • set default path to search for framsticks server installation,
  • add LoggingOutputListener?.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/params/Registry.java

    r88 r90  
    44
    55import com.framsticks.params.annotations.FramsClassAnnotation;
     6import com.framsticks.params.annotations.ParamAnnotation;
    67import com.framsticks.util.DoubleMap;
    78import com.framsticks.util.FramsticksException;
    89
     10import java.util.HashMap;
     11import java.util.Map;
    912import java.util.Set;
     13
     14import javax.annotation.Nonnull;
    1015
    1116/**
    1217 * Author: Piotr Śniegowski
    1318 */
     19@FramsClassAnnotation
    1420public class Registry {
    1521        private static final Logger log = Logger.getLogger(Registry.class.getName());
    1622
    17         // protected void internalRegisterClass(FramsClass framsClass, @Nullable Class<?> javaClass) {
    18         //      assert framsClass.getName() != null;
    19         //      assert framsClass.getId() != null;
    20         //      infoCacheByName.put(framsClass.getName(), framsClass);
    21         //      infoCacheById.put(framsClass.getId(), framsClass);
    22 
    23         //      if (javaClass != null) {
    24         //              reflectedClasses.put(framsClass, javaClass);
    25         //              infoCacheByJavaName.put(javaClass.getCanonicalName(), framsClass);
    26         //      }
    27         // }
    2823        protected final DoubleMap<String, Class<?>> javaClasses = new DoubleMap<>();
    2924        protected final DoubleMap<String, FramsClass> framsClasses = new DoubleMap<>();
     25        protected final Map<Class<?>, FramsClass> javaToFramsAssociation = new HashMap<>();
    3026
    31         public void registerReflectedClass(String name, String id, Class<?> reflectedClass) {
    32                 javaClasses.put(id, name, reflectedClass);
     27        /**
     28         *
     29         */
     30        public Registry() {
     31                // registerAndBuild(Registry.class);
     32                // registerAndBuild(FramsClass.class);
     33                // registerAndBuild(Param.class);
    3334        }
    3435
    35         public Registry registerAndBuild(Class<?> reflectedClass) {
    36                 register(reflectedClass);
    37                 putInfoIntoCache(FramsClass.build().forClass(reflectedClass));
     36        public void registerReflectedClass(String name, String id, Class<?> javaClass) {
     37                javaClasses.put(id, name, javaClass);
     38        }
     39
     40        public void associate(Class<?> javaClass, FramsClass framsClass) {
     41                javaToFramsAssociation.put(javaClass, framsClass);
     42        }
     43
     44        public Registry registerAndBuild(Class<?> javaClass) {
     45                register(javaClass);
     46                associate(javaClass, putFramsClass(FramsClass.build().forClass(javaClass)));
    3847                return this;
    3948        }
    4049
    41         public Registry register(Class<?> reflectedClass) {
    42                 FramsClassAnnotation a = reflectedClass.getAnnotation(FramsClassAnnotation.class);
     50        public Registry register(Class<?> javaClass) {
     51                FramsClassAnnotation a = javaClass.getAnnotation(FramsClassAnnotation.class);
    4352                if (a == null) {
    44                         throw new FramsticksException().msg("class is not annotated").arg("class", reflectedClass);
     53                        throw new FramsticksException().msg("class is not annotated").arg("class", javaClass);
    4554                }
    4655
    47                 registerReflectedClass(FramsClassBuilder.getName(a, reflectedClass), FramsClassBuilder.getId(a, reflectedClass), reflectedClass);
     56                registerReflectedClass(FramsClassBuilder.getName(a, javaClass), FramsClassBuilder.getId(a, javaClass), javaClass);
    4857                return this;
    4958        }
    5059
    51         public AccessInterface createAccess(String name, FramsClass framsClass) throws ConstructionException {
     60        public @Nonnull ReflectionAccess createAccess(Class<?> javaClass) throws ConstructionException {
     61                try {
     62                        if (!javaClasses.containsValue(javaClass)) {
     63                                throw new FramsticksException().msg("java class is not registered");
     64                        }
     65                        if (!javaToFramsAssociation.containsKey(javaClass)) {
     66                                throw new FramsticksException().msg("java class is not associated with any frams class");
     67                        }
     68                        return new ReflectionAccess(javaClass, javaToFramsAssociation.get(javaClass));
     69                }
     70                catch (FramsticksException e) {
     71                        throw new FramsticksException().msg("failed to create access for java class").arg("class", javaClass).cause(e);
     72                }
     73        }
     74
     75        public @Nonnull AccessInterface createAccess(String name, FramsClass framsClass) throws ConstructionException {
    5276                // assert framsClasses.containsValue(framsClass);
    5377                if (javaClasses.containsKey(name)) {
     
    5781        }
    5882
    59         public void putInfoIntoCache(FramsClass framsClass) {
     83        public FramsClass putFramsClass(FramsClass framsClass) {
    6084                log.debug("caching info for " + framsClass);
    6185                framsClasses.put(framsClass.getId(), framsClass.getName(), framsClass);
     86                return framsClass;
    6287        }
    6388
    64         public FramsClass getInfoFromCache(String identifier) {
    65                 if (identifier == null) {
    66                         return null;
    67                 }
     89        public FramsClass getFramsClass(@Nonnull String identifier) {
    6890                return framsClasses.get(identifier);
    6991        }
    7092
    71         public static AccessInterface wrapAccessWithListIfNeeded(CompositeParam param, AccessInterface access) {
    72                 if (access == null) {
    73                         return null;
    74                 }
     93        public static @Nonnull AccessInterface wrapAccessWithListIfNeeded(@Nonnull CompositeParam param, @Nonnull AccessInterface access) {
    7594                return param.prepareAccessInterface(access);
    7695        }
    7796
    78         public AccessInterface prepareAccess(CompositeParam param) throws ConstructionException {
     97        public @Nonnull AccessInterface prepareAccess(CompositeParam param) throws ConstructionException {
    7998                return wrapAccessWithListIfNeeded(param, createAccess(param.getContainedTypeName()));
    8099        }
    81100
    82         public AccessInterface createAccess(String name) throws ConstructionException {
    83                 if (name == null) {
    84                         return null;
     101        public @Nonnull AccessInterface createAccess(@Nonnull String name) throws ConstructionException {
     102                try {
     103                        FramsClass framsClass = getFramsClass(name);
     104                        if (framsClass == null) {
     105                                throw new ConstructionException().msg("framsclass is missing");
     106                        }
     107
     108                        return createAccess(name, framsClass);
    85109                }
    86                 FramsClass framsClass = getInfoFromCache(name);
    87                 if (framsClass == null) {
    88                         return null;
     110                catch (FramsticksException e) {
     111                        throw new FramsticksException().msg("failed to create access for name").arg("name", name).cause(e);
    89112                }
    90 
    91                 return createAccess(name, framsClass);
    92113        }
    93114
     
    96117        }
    97118
    98         public Set<FramsClass> getInfoCache() {
     119        public Set<FramsClass> getFramsClasses() {
    99120                return framsClasses.getValues();
    100121        }
    101122
     123        @ParamAnnotation
     124        public Map<String, FramsClass> getFramsClassesById() {
     125                return framsClasses.getValuesById();
     126        }
     127
     128        public void takeAllFrom(Registry source) {
     129                for (Class<?> javaClass : source.getReflectedClasses()) {
     130                        register(javaClass);
     131                }
     132                for (FramsClass framsClass : source.getFramsClasses()) {
     133                        putFramsClass(framsClass);
     134                }
     135
     136        }
     137
    102138}
Note: See TracChangeset for help on using the changeset viewer.