Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
evoal-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
evoal
source
evoal-core
Commits
31da9d5e
Commit
31da9d5e
authored
1 year ago
by
Bernhard Johannes Berger
Browse files
Options
Downloads
Patches
Plain Diff
Added a method to create Components and let the framework do the type lookup and init call.
parent
62a84bc4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#280182
passed
1 year ago
Stage: Domain Specific Languages
Stage: EvoAl
Stage: Release
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/evoal/core/de.evoal.core.main/src/main/java/de/evoal/core/api/cdi/BeanFactory.java
+18
-0
18 additions, 0 deletions
...main/src/main/java/de/evoal/core/api/cdi/BeanFactory.java
with
18 additions
and
0 deletions
src/evoal/core/de.evoal.core.main/src/main/java/de/evoal/core/api/cdi/BeanFactory.java
+
18
−
0
View file @
31da9d5e
package
de.evoal.core.api.cdi
;
import
de.evoal.core.api.utils.Requirements
;
import
de.evoal.languages.model.base.Instance
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.deltaspike.core.api.provider.BeanProvider
;
...
...
@@ -61,6 +62,23 @@ public final class BeanFactory {
}
}
public
static
<
T
extends
EvoalComponent
<
T
>>
T
createComponent
(
final
Class
<
T
>
type
,
final
Instance
configuration
)
{
Requirements
.
requireNotNull
(
type
);
Requirements
.
requireNotNull
(
configuration
);
final
String
name
=
configuration
.
getDefinition
().
getName
();
log
.
info
(
"Creating bean for instance of type {}."
,
name
);
try
{
return
BeanProvider
.
getContextualReference
(
name
,
false
,
type
)
.
init
(
configuration
);
}
catch
(
final
IllegalStateException
|
IllegalArgumentException
e
)
{
log
.
error
(
"Failed to create contextual reference of type '{}' with name '{}'."
,
type
,
name
);
logInstantiationError
(
type
,
e
);
throw
e
;
}
}
public
static
void
injectFields
(
final
Object
instance
)
{
BeanProvider
.
injectFields
(
instance
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment