Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 4 commits
  • 30 files changed
  • 0 comments
  • 1 contributor

Showing 30 changed files with 264 additions and 165 deletions. Show diff stats Hide diff stats

  1. +21 0 core/api/src/main/java/org/qi4j/api/activation/ActivationException.java
  2. +4 1 core/api/src/main/java/org/qi4j/api/association/GenericAssociationInfo.java
  3. +1 1  core/api/src/main/java/org/qi4j/api/composite/ConstructorDescriptor.java
  4. +1 1  core/api/src/main/java/org/qi4j/api/composite/PropertyMapper.java
  5. +38 9 core/api/src/main/java/org/qi4j/api/entity/EntityReference.java
  6. +1 1  core/api/src/main/java/org/qi4j/api/mixin/MixinDescriptor.java
  7. +3 0  core/api/src/main/java/org/qi4j/api/property/InvalidPropertyTypeException.java
  8. +4 4 core/api/src/main/java/org/qi4j/api/property/Numbers.java
  9. +12 0 core/api/src/main/java/org/qi4j/api/service/ServiceReference.java
  10. +1 1  core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectDescriptor.java
  11. +9 1 core/api/src/main/java/org/qi4j/api/structure/ApplicationDescriptor.java
  12. +3 0  core/api/src/main/java/org/qi4j/api/structure/Layer.java
  13. +7 1 core/api/src/main/java/org/qi4j/api/structure/LayerDescriptor.java
  14. +23 1 core/api/src/main/java/org/qi4j/api/structure/Module.java
  15. +2 1  core/api/src/main/java/org/qi4j/api/type/CollectionType.java
  16. +1 1  core/api/src/main/java/org/qi4j/api/type/EnumType.java
  17. +2 1  core/api/src/main/java/org/qi4j/api/type/MapType.java
  18. +1 1  core/api/src/main/java/org/qi4j/api/type/ValueCompositeType.java
  19. +3 2 core/api/src/main/java/org/qi4j/api/type/ValueType.java
  20. +6 3 core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkException.java
  21. +3 0  core/api/src/main/java/org/qi4j/api/util/Classes.java
  22. +8 0 core/api/src/main/java/org/qi4j/api/util/Dates.java
  23. +4 4 core/runtime/src/main/java/org/qi4j/runtime/composite/AbstractModifierModel.java
  24. +25 0 core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodModel.java
  25. +3 3 core/runtime/src/main/java/org/qi4j/runtime/composite/ConstructorModel.java
  26. +5 5 core/runtime/src/main/java/org/qi4j/runtime/composite/MixinModel.java
  27. +1 1  core/runtime/src/main/java/org/qi4j/runtime/composite/SideEffectModel.java
  28. +25 57 core/runtime/src/test/java/org/qi4j/test/ASMTest.java
  29. +26 25 libraries.gradle
  30. +21 40 libraries/rest-client/src/test/java/org/qi4j/library/rest/client/RssReaderTest.java
21 core/api/src/main/java/org/qi4j/api/activation/ActivationException.java
... ... @@ -1,7 +1,28 @@
  1 +/*
  2 + * Copyright 2013 Niclas Hedhman.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  13 + * implied.
  14 + *
  15 + * See the License for the specific language governing permissions and
  16 + * limitations under the License.
  17 + */
1 18 package org.qi4j.api.activation;
2 19
  20 +/**
  21 + * Thrown when unable to activate.
  22 + */
3 23 public class ActivationException extends Exception
4 24 {
  25 + private static final long serialVersionUID = 1L;
5 26 public ActivationException( String message, Throwable cause )
6 27 {
7 28 super( message, cause );
5 core/api/src/main/java/org/qi4j/api/association/GenericAssociationInfo.java
@@ -13,7 +13,7 @@
13 13 * implied.
14 14 *
15 15 * See the License for the specific language governing permissions and
16   - * limitations under the License.
  16 + * limitations under the License.
17 17 */
18 18 package org.qi4j.api.association;
19 19
@@ -23,6 +23,9 @@
23 23
24 24 import static org.qi4j.api.util.Classes.typeOf;
25 25
  26 +/**
  27 + * Generic Association info.
  28 + */
26 29 public final class GenericAssociationInfo
27 30 {
28 31 public static Type associationTypeOf( AccessibleObject accessor )
2  core/api/src/main/java/org/qi4j/api/composite/ConstructorDescriptor.java
@@ -21,5 +21,5 @@
21 21 */
22 22 public interface ConstructorDescriptor
23 23 {
24   - Constructor constructor();
  24 + Constructor<?> constructor();
25 25 }
2  core/api/src/main/java/org/qi4j/api/composite/PropertyMapper.java
@@ -26,7 +26,7 @@
26 26 import org.qi4j.api.value.ValueComposite;
27 27
28 28 /**
29   - * Transfer properties to Composite properties
  29 + * Transfer java.util.Properties to Composite properties
30 30 */
31 31 public final class PropertyMapper
32 32 {
47 core/api/src/main/java/org/qi4j/api/entity/EntityReference.java
@@ -18,51 +18,77 @@
18 18 import org.qi4j.api.util.NullArgumentException;
19 19
20 20 /**
21   - * An EntityReference is identity of a specific
22   - * Entity instance. When stringified, the identity is used as-is. Example:
23   - * <pre>
24   - * 123456-abcde
25   - * </pre>
  21 + * An EntityReference is identity of a specific Entity instance.
  22 + * <p>When stringified, the identity is used as-is. Example:</p>
  23 + * <pre>123456-abcde</pre>
26 24 */
27 25 public final class EntityReference
28 26 implements Serializable
29 27 {
  28 + /**
  29 + * Parse an URI to an EntityReference.
  30 + * @param uri the URI to parse
  31 + * @return the EntityReference represented by the given URI
  32 + */
30 33 public static EntityReference parseURI( String uri )
31 34 {
32 35 String identity = uri.substring( "urn:qi4j:entity:".length() );
33 36 return new EntityReference( identity );
34 37 }
35 38
36   - public static EntityReference parseEntityReference( String id )
  39 + /**
  40 + * Parse an Entity identity to an EntityReference.
  41 + * @param identity the EntityReference identity
  42 + * @return the EntityReference represented by the given identity
  43 + */
  44 + public static EntityReference parseEntityReference( String identity )
37 45 {
38   - return new EntityReference( id );
  46 + return new EntityReference( identity );
39 47 }
40 48
41   - public static EntityReference entityReferenceFor( Object o )
  49 + /**
  50 + * @param object an EntityComposite
  51 + * @return the EntityReference for the given EntityComposite
  52 + */
  53 + public static EntityReference entityReferenceFor( Object object )
42 54 {
43   - return new EntityReference( (EntityComposite) o );
  55 + return new EntityReference( (EntityComposite) object );
44 56 }
45 57
46 58 private static final long serialVersionUID = 1L;
47 59
48 60 private String identity;
49 61
  62 + /**
  63 + * @param entityComposite a non-null EntityComposite
  64 + * @throws NullPointerException if entityComposite is null
  65 + */
50 66 public EntityReference( EntityComposite entityComposite )
51 67 {
52 68 this( entityComposite.identity().get() );
53 69 }
54 70
  71 + /**
  72 + * @param identity reference identity
  73 + * @throws NullArgumentException if identity is null or empty
  74 + */
55 75 public EntityReference( String identity )
56 76 {
57 77 NullArgumentException.validateNotEmpty( "identity", identity );
58 78 this.identity = identity;
59 79 }
60 80
  81 + /**
  82 + * @return This EntityReference identity.
  83 + */
61 84 public final String identity()
62 85 {
63 86 return identity;
64 87 }
65 88
  89 + /**
  90 + * @return An URI representation of this EntityReference.
  91 + */
66 92 public String toURI()
67 93 {
68 94 return "urn:qi4j:entity:" + identity;
@@ -91,6 +117,9 @@ public int hashCode()
91 117 return result;
92 118 }
93 119
  120 + /**
  121 + * @return This EntityReference identity.
  122 + */
94 123 @Override
95 124 public String toString()
96 125 {
2  core/api/src/main/java/org/qi4j/api/mixin/MixinDescriptor.java
@@ -19,5 +19,5 @@
19 19 */
20 20 public interface MixinDescriptor
21 21 {
22   - Class mixinClass();
  22 + Class<?> mixinClass();
23 23 }
3  core/api/src/main/java/org/qi4j/api/property/InvalidPropertyTypeException.java
@@ -3,6 +3,9 @@
3 3 import java.lang.reflect.AccessibleObject;
4 4 import org.qi4j.api.common.ConstructionException;
5 5
  6 +/**
  7 + * Thrown when attempting to subclass Property.
  8 + */
6 9 public class InvalidPropertyTypeException extends ConstructionException
7 10 {
8 11 public InvalidPropertyTypeException( AccessibleObject accessor )
8 core/api/src/main/java/org/qi4j/api/property/Numbers.java
@@ -17,10 +17,10 @@
17 17 import java.math.BigDecimal;
18 18
19 19 /**
20   - * Convenience class for mathematical operations on
21   - * numerical properties.
22   - * <p/>
23   - * add(object.number(), 5)
  20 + * Convenience class for mathematical operations on numerical properties.
  21 + * <pre>import static org.qi4j.api.property.Numbers.*;
  22 + * ...
  23 + * add( object.numberProperty(), 5 );</pre>
24 24 */
25 25 public final class Numbers
26 26 {
12 core/api/src/main/java/org/qi4j/api/service/ServiceReference.java
@@ -25,11 +25,23 @@
25 25 public interface ServiceReference<T>
26 26 extends HasTypes, ActivationEventListenerRegistration, MetaInfoHolder
27 27 {
  28 + /**
  29 + * @return the service's identity
  30 + */
28 31 String identity();
29 32
  33 + /**
  34 + * @return the actual service
  35 + */
30 36 T get();
31 37
  38 + /**
  39 + * @return TRUE if the service is active, otherwise return FALSE
  40 + */
32 41 boolean isActive();
33 42
  43 + /**
  44 + * @return TRUE if the service is available, otherwise return FALSE
  45 + */
34 46 boolean isAvailable();
35 47 }
2  core/api/src/main/java/org/qi4j/api/sideeffect/SideEffectDescriptor.java
@@ -19,5 +19,5 @@
19 19 */
20 20 public interface SideEffectDescriptor
21 21 {
22   - Class modifierClass();
  22 + Class<?> modifierClass();
23 23 }
10 core/api/src/main/java/org/qi4j/api/structure/ApplicationDescriptor.java
@@ -11,7 +11,6 @@
11 11 * limitations under the License.
12 12 *
13 13 */
14   -
15 14 package org.qi4j.api.structure;
16 15
17 16 import org.qi4j.api.Qi4j;
@@ -23,7 +22,16 @@
23 22 public interface ApplicationDescriptor
24 23 extends VisitableHierarchy<Object, Object>
25 24 {
  25 + /**
  26 + * Create a new instance of the Application.
  27 + * @param runtime Qi4j Runtime
  28 + * @param importedServiceInstances Imported Services instances
  29 + * @return a new instance of the Application.
  30 + */
26 31 Application newInstance( Qi4j runtime, Object... importedServiceInstances );
27 32
  33 + /**
  34 + * @return the Application's name
  35 + */
28 36 String name();
29 37 }
3  core/api/src/main/java/org/qi4j/api/structure/Layer.java
@@ -24,5 +24,8 @@
24 24 public interface Layer
25 25 extends ActivationEventListenerRegistration, Activation, MetaInfoHolder
26 26 {
  27 + /**
  28 + * @return the Layer's name
  29 + */
27 30 String name();
28 31 }
8 core/api/src/main/java/org/qi4j/api/structure/LayerDescriptor.java
@@ -11,7 +11,6 @@
11 11 * limitations under the License.
12 12 *
13 13 */
14   -
15 14 package org.qi4j.api.structure;
16 15
17 16 /**
@@ -19,7 +18,14 @@
19 18 */
20 19 public interface LayerDescriptor
21 20 {
  21 +
  22 + /**
  23 + * @return the Layer's name
  24 + */
22 25 String name();
23 26
  27 + /**
  28 + * @return Layers used by this Layer
  29 + */
24 30 UsedLayersDescriptor usedLayers();
25 31 }
24 core/api/src/main/java/org/qi4j/api/structure/Module.java
@@ -12,7 +12,6 @@
12 12 * limitations under the License.
13 13 *
14 14 */
15   -
16 15 package org.qi4j.api.structure;
17 16
18 17 import org.qi4j.api.activation.ActivationEventListenerRegistration;
@@ -43,15 +42,38 @@
43 42 QueryBuilderFactory,
44 43 ServiceFinder
45 44 {
  45 +
  46 + /**
  47 + * @return the Module's name
  48 + */
46 49 String name();
47 50
  51 + /**
  52 + * @return the Module's ClassLoader
  53 + */
48 54 ClassLoader classLoader();
49 55
  56 + /**
  57 + * @param typeName name of a transient composite type
  58 + * @return the descriptor for a transient composite or null if the class could not be found or the transient composite is not visible
  59 + */
50 60 TransientDescriptor transientDescriptor( String typeName );
51 61
  62 + /**
  63 + * @param typeName name of an entity composite type
  64 + * @return the descriptor for an entity composite or null if the class could not be found or the entity composite is not visible
  65 + */
52 66 EntityDescriptor entityDescriptor( String typeName );
53 67
  68 + /**
  69 + * @param typeName name of an object type
  70 + * @return the descriptor for an object or null if the class could not be found or the object is not visible
  71 + */
54 72 ObjectDescriptor objectDescriptor( String typeName );
55 73
  74 + /**
  75 + * @param typeName name of a value composite type
  76 + * @return the descriptor for a value composite or null if the class could not be found or the value composite is not visible
  77 + */
56 78 ValueDescriptor valueDescriptor( String typeName );
57 79 }
3  core/api/src/main/java/org/qi4j/api/type/CollectionType.java
@@ -20,7 +20,8 @@
20 20 import org.qi4j.api.util.Classes;
21 21
22 22 /**
23   - * Collection type. This handles Collection, List and Set types
  23 + * Collection ValueType.
  24 + * <p>This handles Collection, List and Set types.</p>
24 25 */
25 26 public final class CollectionType
26 27 extends ValueType
2  core/api/src/main/java/org/qi4j/api/type/EnumType.java
@@ -16,7 +16,7 @@
16 16 import java.lang.reflect.Type;
17 17
18 18 /**
19   - * Enumeration type
  19 + * Enum ValueType.
20 20 */
21 21 public final class EnumType
22 22 extends ValueType
3  core/api/src/main/java/org/qi4j/api/type/MapType.java
@@ -18,7 +18,8 @@
18 18 import org.qi4j.api.util.Classes;
19 19
20 20 /**
21   - * Map type. This handles instances of Map
  21 + * Map ValueType.
  22 + * <p>This handles instances of Map.</p>
22 23 */
23 24 public final class MapType
24 25 extends ValueType
2  core/api/src/main/java/org/qi4j/api/type/ValueCompositeType.java
@@ -22,7 +22,7 @@
22 22 import org.qi4j.api.value.ValueDescriptor;
23 23
24 24 /**
25   - * ValueComposite type
  25 + * ValueComposite ValueType.
26 26 */
27 27 public final class ValueCompositeType
28 28 extends ValueType
5 core/api/src/main/java/org/qi4j/api/type/ValueType.java
@@ -23,8 +23,6 @@
23 23
24 24 /**
25 25 * Base class for types of values in ValueComposites and Properties.
26   - *
27   - * TODO I think the ValueType system requires some major re-thinking.
28 26 */
29 27 public class ValueType
30 28 implements HasTypes
@@ -92,6 +90,9 @@ public static boolean isPrimitiveValueType( ValueType valueType )
92 90 return isPrimitiveValueType( valueType.mainType() );
93 91 }
94 92
  93 + /**
  94 + * @see ValueType#isPrimitiveValue(java.lang.Object)
  95 + */
95 96 public static boolean isPrimitiveValueType( Class<?> type )
96 97 {
97 98 NullArgumentException.validateNotNull( "type", type );
9 core/api/src/main/java/org/qi4j/api/unitofwork/UnitOfWorkException.java
@@ -3,19 +3,22 @@
3 3 * Licensed under the Apache License, Version 2.0 (the "License");
4 4 * you may not use this file except in compliance with the License.
5 5 * You may obtain a copy of the License at
6   - *
  6 + *
7 7 * http://www.apache.org/licenses/LICENSE-2.0
8   - *
  8 + *
9 9 * Unless required by applicable law or agreed to in writing, software
10 10 * distributed under the License is distributed on an "AS IS" BASIS,
11 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 12 * implied.
13   - *
  13 + *
14 14 * See the License for the specific language governing permissions and
15 15 * limitations under the License.
16 16 */
17 17 package org.qi4j.api.unitofwork;
18 18
  19 +/**
  20 + * Base Exception for UnitOfWork related concerns.
  21 + */
19 22 public class UnitOfWorkException
20 23 extends RuntimeException
21 24 {
3  core/api/src/main/java/org/qi4j/api/util/Classes.java
@@ -108,6 +108,9 @@ public Type map( Type aClass )
108 108 }
109 109 };
110 110
  111 + /**
  112 + * Function that extract the raw class of a type.
  113 + */
111 114 public static final Function<Type, Class<?>> RAW_CLASS = new Function<Type, Class<?>>()
112 115 {
113 116 @Override
8 core/api/src/main/java/org/qi4j/api/util/Dates.java
@@ -50,6 +50,10 @@ protected DateFormat initialValue()
50 50 }
51 51 };
52 52
  53 + /**
  54 + * @param stringDate a string representing a date as either ISO8601, @millis@ or /Date() formats
  55 + * @return a Date
  56 + */
53 57 public static Date fromString( String stringDate )
54 58 {
55 59 try
@@ -84,6 +88,10 @@ else if( stringDate.startsWith( "/Date(" ) && stringDate.endsWith( ")/" ) ) // M
84 88 }
85 89 }
86 90
  91 + /**
  92 + * @param date a Date
  93 + * @return String representation in ISO8601 UTC
  94 + */
87 95 public static String toUtcString( Date date )
88 96 {
89 97 return ISO8601_UTC.get().format( date );
8 core/runtime/src/main/java/org/qi4j/runtime/composite/AbstractModifierModel.java
@@ -37,15 +37,15 @@
37 37 public abstract class AbstractModifierModel
38 38 implements Dependencies, VisitableHierarchy<Object, Object>
39 39 {
40   - private final Class modifierClass;
  40 + private final Class<?> modifierClass;
41 41
42 42 private ConstructorsModel constructorsModel;
43 43 private InjectedFieldsModel injectedFieldsModel;
44 44 private InjectedMethodsModel injectedMethodsModel;
45 45
46   - private Class[] nextInterfaces;
  46 + private Class<?>[] nextInterfaces;
47 47
48   - public AbstractModifierModel( Class declaredModifierClass, Class instantiationClass )
  48 + public AbstractModifierModel( Class<?> declaredModifierClass, Class<?> instantiationClass )
49 49 {
50 50 this.modifierClass = instantiationClass;
51 51 constructorsModel = new ConstructorsModel( modifierClass );
@@ -55,7 +55,7 @@ public AbstractModifierModel( Class declaredModifierClass, Class instantiationCl
55 55 nextInterfaces = toArray( componentType, unique( map( RAW_CLASS, interfacesOf( declaredModifierClass ) ) ));
56 56 }
57 57
58   - public Class modifierClass()
  58 + public Class<?> modifierClass()
59 59 {
60 60 return modifierClass;
61 61 }
25 core/runtime/src/main/java/org/qi4j/runtime/composite/CompositeMethodModel.java
@@ -16,6 +16,7 @@
16 16
17 17 import java.lang.annotation.Annotation;
18 18 import java.lang.reflect.AnnotatedElement;
  19 +import java.lang.reflect.Array;
19 20 import java.lang.reflect.InvocationHandler;
20 21 import java.lang.reflect.Method;
21 22 import java.util.ArrayList;
@@ -23,6 +24,7 @@
23 24 import java.util.List;
24 25 import org.qi4j.api.common.ConstructionException;
25 26 import org.qi4j.api.composite.MethodDescriptor;
  27 +import org.qi4j.api.util.NullArgumentException;
26 28 import org.qi4j.functional.HierarchicalVisitor;
27 29 import org.qi4j.functional.VisitableHierarchy;
28 30 import org.qi4j.runtime.injection.Dependencies;
@@ -291,5 +293,28 @@ public boolean isAnnotationPresent( Class<? extends Annotation> annotationClass
291 293 {
292 294 return new Annotation[ 0 ];
293 295 }
  296 +
  297 + // @Override (Since JDK 8)
  298 + @SuppressWarnings( "unchecked" )
  299 + public <T extends Annotation> T[] getAnnotations( Class<T> annotationClass )
  300 + {
  301 + NullArgumentException.validateNotNull( "annotationClass", annotationClass );
  302 + return (T[]) Array.newInstance( annotationClass, 0 );
  303 + }
  304 +
  305 + // @Override (Since JDK 8)
  306 + public <T extends Annotation> T getDeclaredAnnotation( Class<T> annotationClass )
  307 + {
  308 + NullArgumentException.validateNotNull( "annotationClass", annotationClass );
  309 + return null;
  310 + }
  311 +
  312 + // @Override (Since JDK 8)
  313 + @SuppressWarnings( "unchecked" )
  314 + public <T extends Annotation> T[] getDeclaredAnnotations( Class<T> annotationClass )
  315 + {
  316 + NullArgumentException.validateNotNull( "annotationClass", annotationClass );
  317 + return (T[]) Array.newInstance( annotationClass, 0 );
  318 + }
294 319 }
295 320 }
6 core/runtime/src/main/java/org/qi4j/runtime/composite/ConstructorModel.java
@@ -32,11 +32,11 @@
32 32 public final class ConstructorModel
33 33 implements ConstructorDescriptor, VisitableHierarchy<Object, Object>
34 34 {
35   - private Constructor constructor;
  35 + private Constructor<?> constructor;
36 36
37 37 private InjectedParametersModel parameters;
38 38
39   - public ConstructorModel( Constructor constructor, InjectedParametersModel parameters )
  39 + public ConstructorModel( Constructor<?> constructor, InjectedParametersModel parameters )
40 40 {
41 41 this.constructor = constructor;
42 42 this.parameters = parameters;
@@ -44,7 +44,7 @@ public ConstructorModel( Constructor constructor, InjectedParametersModel parame
44 44 }
45 45
46 46 @Override
47   - public Constructor constructor()
  47 + public Constructor<?> constructor()
48 48 {
49 49 return constructor;
50 50 }
10 core/runtime/src/main/java/org/qi4j/runtime/composite/MixinModel.java
@@ -42,14 +42,14 @@
42 42 public final class MixinModel
43 43 implements MixinDescriptor, VisitableHierarchy<Object, Object>
44 44 {
45   - private final Class mixinClass;
46   - private final Class instantiationClass;
  45 + private final Class<?> mixinClass;
  46 + private final Class<?> instantiationClass;
47 47 private final ConstructorsModel constructorsModel;
48 48 private final InjectedFieldsModel injectedFieldsModel;
49 49 private final InjectedMethodsModel injectedMethodsModel;
50 50 private final Iterable<Class<?>> thisMixinTypes;
51 51
52   - public MixinModel( Class declaredMixinClass, Class instantiationClass )
  52 + public MixinModel( Class<?> declaredMixinClass, Class<?> instantiationClass )
53 53 {
54 54 injectedFieldsModel = new InjectedFieldsModel( declaredMixinClass );
55 55 injectedMethodsModel = new InjectedMethodsModel( declaredMixinClass );
@@ -62,12 +62,12 @@ public MixinModel( Class declaredMixinClass, Class instantiationClass )
62 62 }
63 63
64 64 @Override
65   - public Class mixinClass()
  65 + public Class<?> mixinClass()
66 66 {
67 67 return mixinClass;
68 68 }
69 69
70   - public Class instantiationClass()
  70 + public Class<?> instantiationClass()
71 71 {
72 72 return instantiationClass;
73 73 }
2  core/runtime/src/main/java/org/qi4j/runtime/composite/SideEffectModel.java
@@ -23,7 +23,7 @@
23 23 extends AbstractModifierModel
24 24 implements SideEffectDescriptor
25 25 {
26   - public SideEffectModel( Class sideEffectClass, Class instantiationClass )
  26 + public SideEffectModel( Class<?> sideEffectClass, Class<?> instantiationClass )
27 27 {
28 28 super( sideEffectClass, instantiationClass );
29 29 }
82 core/runtime/src/test/java/org/qi4j/test/ASMTest.java
@@ -14,88 +14,42 @@
14 14
15 15 package org.qi4j.test;
16 16
  17 +import java.io.PrintWriter;
17 18 import java.lang.reflect.InvocationTargetException;
18 19 import java.lang.reflect.Method;
19 20 import java.util.List;
  21 +import org.junit.Assert;
  22 +import org.junit.Ignore;
20 23 import org.junit.Test;
21 24 import org.objectweb.asm.AnnotationVisitor;
  25 +import org.objectweb.asm.ClassReader;
22 26 import org.objectweb.asm.ClassWriter;
23 27 import org.objectweb.asm.FieldVisitor;
24 28 import org.objectweb.asm.Label;
25 29 import org.objectweb.asm.MethodVisitor;
26 30 import org.objectweb.asm.Opcodes;
27 31 import org.objectweb.asm.Type;
28   -import org.objectweb.asm.util.ASMifierClassVisitor;
  32 +import org.objectweb.asm.util.ASMifier;
  33 +import org.objectweb.asm.util.TraceClassVisitor;
29 34 import org.qi4j.api.composite.CompositeInvoker;
30 35 import org.qi4j.runtime.composite.FragmentClassLoader;
  36 +import org.qi4j.runtime.composite.QI256Test;
31 37
32   -import static org.objectweb.asm.Opcodes.AASTORE;
33   -import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
34   -import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
35   -import static org.objectweb.asm.Opcodes.ACC_STATIC;
36   -import static org.objectweb.asm.Opcodes.ACC_SUPER;
37   -import static org.objectweb.asm.Opcodes.ACONST_NULL;
38   -import static org.objectweb.asm.Opcodes.ALOAD;
39   -import static org.objectweb.asm.Opcodes.ANEWARRAY;
40   -import static org.objectweb.asm.Opcodes.ARETURN;
41   -import static org.objectweb.asm.Opcodes.ASTORE;
42   -import static org.objectweb.asm.Opcodes.ATHROW;
43   -import static org.objectweb.asm.Opcodes.BIPUSH;
44   -import static org.objectweb.asm.Opcodes.CHECKCAST;
45   -import static org.objectweb.asm.Opcodes.DLOAD;
46   -import static org.objectweb.asm.Opcodes.DUP;
47   -import static org.objectweb.asm.Opcodes.FLOAD;
48   -import static org.objectweb.asm.Opcodes.GETFIELD;
49   -import static org.objectweb.asm.Opcodes.GETSTATIC;
50   -import static org.objectweb.asm.Opcodes.GOTO;
51   -import static org.objectweb.asm.Opcodes.ICONST_0;
52   -import static org.objectweb.asm.Opcodes.ICONST_1;
53   -import static org.objectweb.asm.Opcodes.ICONST_2;
54   -import static org.objectweb.asm.Opcodes.ICONST_3;
55   -import static org.objectweb.asm.Opcodes.ICONST_4;
56   -import static org.objectweb.asm.Opcodes.ICONST_5;
57   -import static org.objectweb.asm.Opcodes.ILOAD;
58   -import static org.objectweb.asm.Opcodes.INVOKEINTERFACE;
59   -import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
60   -import static org.objectweb.asm.Opcodes.INVOKESTATIC;
61   -import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
62   -import static org.objectweb.asm.Opcodes.IRETURN;
63   -import static org.objectweb.asm.Opcodes.LLOAD;
64   -import static org.objectweb.asm.Opcodes.NEW;
65   -import static org.objectweb.asm.Opcodes.POP;
66   -import static org.objectweb.asm.Opcodes.PUTSTATIC;
67   -import static org.objectweb.asm.Opcodes.RETURN;
68   -import static org.objectweb.asm.Opcodes.V1_6;
  38 +import static org.objectweb.asm.Opcodes.*;
69 39
70   -/**
71   - * JAVADOC
72   - */
73 40 public class ASMTest
74 41 {
75 42 @Test
76 43 public void generateASM()
77 44 throws Exception
78 45 {
79   - ASMifierClassVisitor.main( new String[]{ SomeMixin_Stubx.class.getName() } );
  46 + ASMifier.main( new String[]{ SomeMixin_Stubx.class.getName() } );
80 47 }
81 48
82 49 @Test
83   -// @Ignore
84 50 public void createClass()
85 51 throws Exception
86 52 {
87   -/*
88   - byte[] asm = generateClass();
89   -
90   - byte[] cl = FragmentClassLoader.generateClass( QI256Test.TestTransient.TestTransientMixin.class.getName() + "_Stub", QI256Test.TestTransient.TestTransientMixin.class );
91   -
92   - ClassReader cr = new ClassReader( cl );
93   - cr.accept( new ASMifierClassVisitor( new PrintWriter( System.out, true ) ),
94   - ASMifierClassVisitor.getDefaultAttributes(),
95   - 0 );
96   -*/
97   -
98   - // Assert.assertArrayEquals( asm, cl );
99 53
100 54 FragmentClassLoader classLoader = new FragmentClassLoader( SomeMixin.class.getClassLoader() );
101 55
@@ -188,9 +142,23 @@ public Object invokeComposite( Method method, Object[] args )
188 142 System.out.println( instance.testConcern() );
189 143 }
190 144
191   - // This is the code generated from the manual stub
  145 + @Test
  146 + @Ignore( "This was dead commented code, ~70% of this source file ... What should we do about this!?!" )
  147 + public void fragmentClassLoaderGenerateClassTest()
  148 + throws Exception
  149 + {
  150 + byte[] asm = generateClass();
  151 + byte[] cl = FragmentClassLoader.generateClass(
  152 + QI256Test.TestTransient.TestTransientMixin.class.getName() + "_Stub",
  153 + QI256Test.TestTransient.TestTransientMixin.class );
  154 +
  155 + new ClassReader( cl ).accept( new TraceClassVisitor( new PrintWriter( System.out, true ) ), 0 );
192 156
193   - public static byte[] generateClass()
  157 + Assert.assertArrayEquals( asm, cl );
  158 + }
  159 +
  160 + // This is the code generated from the manual stub
  161 + private static byte[] generateClass()
194 162 {
195 163 ClassWriter cw = new ClassWriter( 0 );
196 164 FieldVisitor fv;
51 libraries.gradle
... ... @@ -1,5 +1,5 @@
1 1 // Versions of Dependencies;
2   -def asmVersion = '3.3.1'
  2 +def asmVersion = '4.1'
3 3 def beanshellVersion = '2.0b4'
4 4 def bonecpVersion = '0.7.1.RELEASE'
5 5 def bouncyVersion = '1.46'
@@ -11,33 +11,33 @@ def commonsLangVersion = '2.6'
11 11 def cxfVersion = '2.5.6' // 2.7.0 - Unable to resolve dependencies!
12 12 def derbyVersion = '10.9.1.0'
13 13 def dnsJavaVersion = '2.1.1'
14   -def ehcacheVersion = '2.6.2'
15   -def elasticsearchVersion = '0.20.1'
  14 +def ehcacheVersion = '2.6.3'
  15 +def elasticsearchVersion = '0.20.5'
16 16 def freemarkerVersion = '2.3.19'
17   -def gaeVersion = '1.7.3'
18   -def groovyVersion = '2.0.5'
  17 +def gaeVersion = '1.7.5'
  18 +def groovyVersion = '2.1.0'
19 19 def guavaVersion = '13.0.1'
20   -def h2Version = '1.3.168'
21   -def hazelcastVersion = '2.4'
  20 +def h2Version = '1.3.170'
  21 +def hazelcastVersion = '2.5'
22 22 def httpClientVersion = '4.1.3' // 4.2.2 Fails to do HTTP basic auth in tests!
23 23 def javascriptVersion = '1.7R4'
24 24 def javasqlgeneratorVersion = '0.3.2'
25   -def jcloudsVersion = '1.5.3'
  25 +def jcloudsVersion = '1.5.7'
26 26 def jdbmVersion = '2.0.1'
27 27 def jdomVersion = '2.0.2'
28 28 def jedisVersion = '2.1.0'
29   -ext.jettyVersion = '8.1.8.v20121106' // 9.0.0.M2 exists
  29 +ext.jettyVersion = '8.1.9.v20130131' // 9.0.0.M5 exists
30 30 def jgoodiesLooksVersion = '2.5.2'
31 31 def jodaTimeVersion = '2.1'
32   -def jrubyVersion = '1.7.0'
  32 +def jrubyVersion = '1.7.2'
33 33 def jtaVersion = '1.1'
34   -def leveldbVersion = '0.4'
35   -def leveldbJniVersion = '1.4.1'
  34 +def leveldbVersion = '0.5'
  35 +def leveldbJniVersion = '1.6'
36 36 def liquibaseVersion = '2.0.5'
37 37 def log4jVersion = '1.2.17'
38   -def logbackVersion = '1.0.7'
39   -def mongodbVersion = '2.9.3'
40   -def mysqlVersion = '5.1.21'
  38 +def logbackVersion = '1.0.9'
  39 +def mongodbVersion = '2.10.1'
  40 +def mysqlVersion = '5.1.23'
41 41 def neoVersion = '1.3' // 1.8 exists
42 42 def neoIndexVersion = '1.3-1.3.M01' // Do not exist anymore!
43 43 def orgJsonVersion = '20130213'
@@ -46,9 +46,9 @@ def pdfboxVersion = '1.7.1'
46 46 def postgresqlVersion = '9.1-901-1.jdbc4'
47 47 def prefuseVersion = '0.21'
48 48 def rdfVersion = '2.6.6' // 2.6.9 - Application assembly fails, missing method Repository.isInitalized().
49   -def restletVersion = '2.0.15'
50   -def riakVersion = '1.0.6'
51   -def scalaVersion = '2.9.2'
  49 +def restletVersion = '2.0.15' // HTTP(S) connectors in 2.1.x serie are buggy, see https://github.com/restlet/restlet-framework-java/issues/620
  50 +def riakVersion = '1.0.7'
  51 +def scalaVersion = '2.10.0'
52 52 ext.servletVersion = '3.0.1'
53 53 def shiroVersion = '1.2.1'
54 54 def skedVersion = '1.2'
@@ -57,22 +57,22 @@ def slf4jVersion = '1.7.2'
57 57 def solrVersion = "1.4.1" // 4.0.0 - Fails to compile!
58 58 def springVersion = '3.1.2.RELEASE'
59 59 def sqliteVersion = '3.7.2'
60   -def strutsVersion = '2.3.7'
  60 +def strutsVersion = '2.3.8'
61 61 def velocityVersion = '1.7'
62 62 def voldemortVersion = '0.81' // Taken from Clojars maven repository, 0.96 not in any repository?
63 63 def wicketVersion = '1.5.8' // 6.3.0 - Samples fails to compile!
64 64 def wicketStatelessVersion = '1.5.0'
65 65 def woodstoxVersion = '4.1.4'
66 66 def wsdl4jVersion = '1.6.2'
67   -def yammerMetricsVersion = '2.1.5'
  67 +def yammerMetricsVersion = '2.2.0'
68 68
69 69 def antVersion = '1.8.4'
70 70 def junitVersion = '4.11'
71 71 def testNgVersion = '6.8'
72   -def jmockVersion = '2.5.1'
  72 +def jmockVersion = '2.6.0'
73 73 def mockitoVersion = '1.9.5'
74 74 def easyMockVersion = '3.1'
75   -def xmlunitVersion = '1.3'
  75 +def xmlunitVersion = '1.4'
76 76
77 77 // build a map of the dependency artifacts to use. Allows centralized definition of the version of artifacts to
78 78 // use. In that respect it serves a role similar to <dependencyManagement> in Maven
@@ -84,9 +84,9 @@ rootProject.ext {
84 84 ant_junit: "org.apache.ant:ant-junit:$antVersion",
85 85
86 86 // ASM
87   - asm: "asm:asm:$asmVersion",
88   - asm_util: "asm:asm-util:$asmVersion",
89   - asm_commons: "asm:asm-commons:$asmVersion",
  87 + asm: "org.ow2.asm:asm:$asmVersion",
  88 + asm_util: "org.ow2.asm:asm-util:$asmVersion",
  89 + asm_commons: "org.ow2.asm:asm-commons:$asmVersion",
90 90
91 91 // OSGi
92 92 osgi_core: "org.osgi:org.osgi.core:$osgiVersion",
@@ -108,6 +108,7 @@ rootProject.ext {
108 108 // Restlet
109 109 restlet: [
110 110 "org.restlet.jee:org.restlet:$restletVersion",
  111 + "org.restlet.jee:org.restlet.ext.ssl:$restletVersion",
111 112 "org.restlet.jee:org.restlet.ext.atom:$restletVersion",
112 113 "org.restlet.jee:org.restlet.ext.servlet:$restletVersion",
113 114 "org.restlet.jee:org.restlet.ext.slf4j:$restletVersion"
61 libraries/rest-client/src/test/java/org/qi4j/library/rest/client/RssReaderTest.java
@@ -9,7 +9,6 @@
9 9 import javax.xml.xpath.XPathExpressionException;
10 10 import javax.xml.xpath.XPathFactory;
11 11 import org.junit.Test;
12   -import org.qi4j.api.value.ValueBuilder;
13 12 import org.qi4j.bootstrap.AssemblyException;
14 13 import org.qi4j.bootstrap.ModuleAssembly;
15 14 import org.qi4j.library.rest.client.api.ContextResourceClient;
@@ -20,7 +19,6 @@
20 19 import org.qi4j.library.rest.client.spi.ResponseReader;
21 20 import org.qi4j.library.rest.client.spi.ResultHandler;
22 21 import org.qi4j.library.rest.common.ValueAssembler;
23   -import org.qi4j.library.rest.common.link.Link;
24 22 import org.qi4j.test.AbstractQi4jTest;
25 23 import org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
26 24 import org.restlet.Client;
@@ -35,12 +33,14 @@
35 33 import static org.qi4j.library.rest.client.api.HandlerCommand.*;
36 34
37 35 /**
38   - * Reads my RSS feed and prints out all comments for each entry. This is an example of how
39   - * to use the RSS client for something more generic that was not produced by Qi4j REST server library.
  36 + * Reads Qi4j Github commits on develop ATOM feed and prints out all title and detail url for each entry.
  37 + * This is an example of how to use the RSS client for something more generic that was not produced by Qi4j REST server
  38 + * library.
40 39 */
41 40 public class RssReaderTest
42 41 extends AbstractQi4jTest
43 42 {
  43 +
44 44 private ContextResourceClient crc;
45 45
46 46 @Override
@@ -56,7 +56,7 @@ public void assemble( ModuleAssembly module )
56 56 @Test
57 57 public void testReadRssFeed()
58 58 {
59   - Client client = new Client( Protocol.HTTP );
  59 + Client client = new Client( Protocol.HTTPS );
60 60 Reference ref = new Reference( "https://github.com/Qi4j/qi4j-sdk/commits/develop.atom" );
61 61 ContextResourceClientFactory contextResourceClientFactory = module.newObject( ContextResourceClientFactory.class, client );
62 62
@@ -66,7 +66,7 @@ public void testReadRssFeed()
66 66 public Object readResponse( Response response, Class<?> resultType )
67 67 throws ResourceException
68 68 {
69   - if (resultType.equals( Document.class ))
  69 + if( resultType.equals( Document.class ) )
70 70 {
71 71 try
72 72 {
@@ -80,7 +80,7 @@ public Object readResponse( Response response, Class<?> resultType )
80 80 }
81 81 }
82 82
83   - return null; //To change body of implemented methods use File | Settings | File Templates.
  83 + return null;
84 84 }
85 85 } );
86 86
@@ -89,7 +89,7 @@ public Object readResponse( Response response, Class<?> resultType )
89 89 @Override
90 90 public HandlerCommand handleResponse( Response response, ContextResourceClient client )
91 91 {
92   - // Try to restart
  92 + System.out.println( ">> REFRESH on recoverable error: " + response.getStatus() );
93 93 return refresh();
94 94 }
95 95 } ) );
@@ -107,12 +107,14 @@ public HandlerCommand handleResult( Document result, ContextResourceClient clien
107 107 {
108 108 final XPath xPath = XPathFactory.newInstance().newXPath();
109 109
110   - System.out.println( "== "+xPath.evaluate( "rss/channel/title", result )+" ==");
  110 + System.out.println( "== " + xPath.evaluate( "feed/title", result ) + " ==" );
111 111
112   - final NodeList nodes = (NodeList)xPath.evaluate( "rss/channel/item", result, XPathConstants.NODESET);
  112 + final NodeList nodes = (NodeList) xPath.evaluate( "feed/entry", result, XPathConstants.NODESET );
113 113 List<Node> items = new ArrayList<Node>();
114   - for (int i = 0; i < nodes.getLength(); i++)
  114 + for( int i = 0; i < nodes.getLength(); i++ )
  115 + {
115 116 items.add( nodes.item( i ) );
  117 + }
116 118
117 119 itemNodes = items.iterator();
118 120
@@ -127,41 +129,20 @@ public HandlerCommand handleResult( Document result, ContextResourceClient clien
127 129 private HandlerCommand processEntry( final XPath xPath )
128 130 throws XPathExpressionException
129 131 {
130   - if (!itemNodes.hasNext())
  132 + if( !itemNodes.hasNext() )
  133 + {
131 134 return null;
  135 + }
132 136
133 137 Node item = itemNodes.next();
134 138
135   - System.out.println( "-- "+xPath.evaluate( "title", item )+" --" );
136   - String commentUrl = xPath.evaluate( "commentRss", item );
  139 + String title = xPath.evaluate( "title", item );
  140 + String detailUrl = xPath.evaluate( "link/@href", item );
137 141
138   - ValueBuilder<Link> link = module.newValueBuilder( Link.class );
139   - link.prototype().rel().set( "item" );
140   - link.prototype().id().set( "item" );
141   - link.prototype().href().set( commentUrl );
  142 + System.out.println( "-- " + title + " --" );
  143 + System.out.println( "-- " + detailUrl + " --" );
142 144
143   - return query( link.newInstance() ).onSuccess( new ResultHandler<Document>()
144   - {
145   - @Override
146   - public HandlerCommand handleResult( Document result, ContextResourceClient client )
147   - {
148   - try
149   - {
150   - final NodeList comments = (NodeList)xPath.evaluate( "rss/channel/item", result, XPathConstants.NODESET);
151   - for (int i = 0; i < comments.getLength(); i++)
152   - {
153   - System.out.println( xPath.evaluate( "description", comments.item( i ) ));
154   - System.out.println( "---");
155   - }
156   -
157   - return processEntry( xPath );
158   - }
159   - catch( XPathExpressionException e )
160   - {
161   - throw new ResourceException( e );
162   - }
163   - }
164   - } );
  145 + return processEntry( xPath );
165 146 }
166 147 } );
167 148

No commit comments for this range

Something went wrong with that request. Please try again.