Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frascati
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
114
Issues
114
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
frascati
frascati
Commits
78df5d60
Commit
78df5d60
authored
Feb 22, 2010
by
Lionel Seinturier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support annotations defined in inherited classes (requested by Philippe.)
parent
93b11a30
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
43 deletions
+60
-43
tinfi/RELEASE_NOTES.txt
tinfi/RELEASE_NOTES.txt
+1
-0
tinfi/runtime/oo/src/main/java/org/ow2/frascati/tinfi/control/content/ContentClassMetaData.java
.../frascati/tinfi/control/content/ContentClassMetaData.java
+4
-3
tinfi/runtime/oo/src/main/java/org/ow2/frascati/tinfi/reflect/Util.java
...oo/src/main/java/org/ow2/frascati/tinfi/reflect/Util.java
+55
-40
No files found.
tinfi/RELEASE_NOTES.txt
View file @
78df5d60
...
...
@@ -3,6 +3,7 @@ Tinfi 1.3
* fix for services and references with generic types (reported by Philippe)
* support inherited non public field injection point in component
implementations (requested by Philippe)
* support annotations defined in inherited classes (requested by Philippe)
* remove @EagerDestroy
* new @Start and @Stop annotations for triggering actions when a component is
started and stopped (requested by Philippe and Jonathan)
...
...
tinfi/runtime/oo/src/main/java/org/ow2/frascati/tinfi/control/content/ContentClassMetaData.java
View file @
78df5d60
...
...
@@ -176,12 +176,12 @@ public class ContentClassMetaData {
/*
* Retrieve the scope policy of the content class.
*/
scope
=
fcContentClass
.
getAnnotation
(
Scope
.
class
);
scope
=
Util
.
getAnnotation
(
fcContentClass
,
Scope
.
class
);
/*
* Retrieve the scope eager init policy of the content class, if any.
*/
eagerinit
=
fcContentClass
.
getAnnotation
(
EagerInit
.
class
);
eagerinit
=
Util
.
getAnnotation
(
fcContentClass
,
EagerInit
.
class
);
if
(
eagerinit
!=
null
)
{
if
(
scope
==
null
||
!
scope
.
value
().
equals
(
"COMPOSITE"
)
)
{
String
msg
=
...
...
@@ -194,7 +194,8 @@ public class ContentClassMetaData {
/*
* Retrieve the conversation attributes of the content class.
*/
convattr
=
fcContentClass
.
getAnnotation
(
ConversationAttributes
.
class
);
convattr
=
Util
.
getAnnotation
(
fcContentClass
,
ConversationAttributes
.
class
);
if
(
convattr
!=
null
)
{
String
ma
=
convattr
.
maxAge
();
convMaxAge
=
convDurationToMilli
(
ma
);
...
...
tinfi/runtime/oo/src/main/java/org/ow2/frascati/tinfi/reflect/Util.java
View file @
78df5d60
...
...
@@ -30,10 +30,8 @@ import java.lang.reflect.Field;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.objectweb.fractal.api.Component
;
import
org.objectweb.fractal.api.NoSuchInterfaceException
;
...
...
@@ -41,11 +39,6 @@ import org.objectweb.fractal.juliac.runtime.ClassLoaderFcItf;
import
org.objectweb.fractal.juliac.runtime.ClassLoaderItf
;
import
org.objectweb.fractal.juliac.runtime.Juliac
;
import
org.ow2.frascati.tinfi.TinfiRuntimeException
;
import
org.ow2.frascati.tinfi.reflect.AnnotatedElementFilter
;
import
org.ow2.frascati.tinfi.reflect.Filter
;
import
org.ow2.frascati.tinfi.reflect.Filters
;
import
org.ow2.frascati.tinfi.reflect.SetterMethodFilter
;
import
org.ow2.frascati.tinfi.reflect.UnAnnotatedElementFilter
;
/**
* Utility methods.
...
...
@@ -111,26 +104,14 @@ public class Util {
}
/**
* Return all fields, declared ones whatever their access modifier is and
* inherited public ones, in the specified class.
* Return all fields declared by the specified class and all fields declared
* by parent classes, except {@link java.lang.Object}, of the specified
* class. All fields are included whatever their access modifier is.
*
* @param cl the class
* @since 1.1.2
*/
private
static
Field
[]
getAllFields
(
Class
<?>
cl
)
{
/*
* Declared private to avoid regressions due to a change in the
* semantics of the method. This method used to return declared and
* public inherited fields. Since 1.3, this method returns all fields.
*
* This method is used by getAllAnnotatedSettersAndFields().
*
* We can move back this method to public as soon as we are sure that
* it is not used in other locations than the previous one where the
* change could introduce regressions.
*/
public
static
Field
[]
getAllFields
(
Class
<?>
cl
)
{
List
<
Field
>
result
=
new
ArrayList
<
Field
>();
addAllFields
(
cl
,
result
);
return
result
.
toArray
(
new
Field
[
result
.
size
()]);
...
...
@@ -162,34 +143,43 @@ public class Util {
}
/**
* Return all methods, declared ones whatever their access modifier is and
* inherited public ones, in the specified class.
* Return all methods declared by the specified class and all methods
* declared by parent classes, except {@link java.lang.Object}, of the
* specified class. All methods are included whatever their access modifier
* is.
*
* @param cl the class
* @since 1.1.2
*/
public
static
Method
[]
getAllMethods
(
Class
<?>
cl
)
{
/*
* Use a set instead to accomodate duplicate insertions of public
* declared elements, e.g. public methods which are returned both by
* getDeclaredMethods and getMethods.
*/
Set
<
Method
>
result
=
new
HashSet
<
Method
>();
List
<
Method
>
result
=
new
ArrayList
<
Method
>();
addAllMethods
(
cl
,
result
);
return
result
.
toArray
(
new
Method
[
result
.
size
()]);
}
/**
* Add to the specified list, all methods declared by the specified class
* and all methods declared by parent classes, except {@link
* java.lang.Object}, of the specified class. All methods are included
* whatever their access modifier is.
*
* @param cl the class
* @param list the list where methods are to be added
* @since 1.3
*/
public
static
void
addAllMethods
(
Class
<?>
cl
,
List
<
Method
>
list
)
{
// Declared methods
Method
[]
methods
=
cl
.
getDeclaredMethods
();
for
(
Method
method
:
methods
)
{
result
.
add
(
method
);
}
// Inherited public methods
methods
=
cl
.
getMethods
();
for
(
Method
method
:
methods
)
{
result
.
add
(
method
);
list
.
add
(
method
);
}
return
result
.
toArray
(
new
Method
[
result
.
size
()]);
// Recurse in the parent class up to java.lang.Object
Class
<?>
supercl
=
cl
.
getSuperclass
();
if
(
!
supercl
.
equals
(
Object
.
class
)
)
{
addAllMethods
(
supercl
,
list
);
}
}
/**
...
...
@@ -224,6 +214,31 @@ public class Util {
return
aos
;
}
/**
* Return the annotation of type <code>annotationClass</code> associated
* with <code>cl</code>. If no such annotation exists, recurse into the
* inheritance hierarchy up to {@link java.lang.Object}. Return
* <code>null</code> if no such annotation is found.
*/
public
static
<
A
extends
Annotation
>
A
getAnnotation
(
Class
<?>
cl
,
Class
<
A
>
annotationClass
)
{
A
annot
=
cl
.
getAnnotation
(
annotationClass
);
if
(
annot
!=
null
)
{
return
annot
;
}
// Recurse in the parent class up to java.lang.Object
Class
<?>
supercl
=
cl
.
getSuperclass
();
if
(
!
supercl
.
equals
(
Object
.
class
)
)
{
annot
=
getAnnotation
(
supercl
,
annotationClass
);
return
annot
;
}
// No such annotation found
return
null
;
}
/**
* Return the getter method corresponding to the specified setter.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment