uebung5
This commit is contained in:
1 parent
1f51386b57
commit
7859b5c801
8 files changed
+254
-11
No files matched your search
@@ -0,0 +1,18 @@
|
||||
package org.example.demo.uebung5.aufgabe21;
|
||||
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.enterprise.inject.Produces;
|
||||
import jakarta.enterprise.inject.spi.InjectionPoint;
|
||||
import jakarta.inject.Singleton;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
@ApplicationScoped
|
||||
public class LoggerProducer {
|
||||
|
||||
@Produces
|
||||
public Logger produceLogger(InjectionPoint ip) {
|
||||
// Ermittelt die Klasse, in die der Logger injiziert wird
|
||||
Class<?> targetClass = ip.getMember().getDeclaringClass();
|
||||
return Logger.getLogger(targetClass);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.example.demo.uebung5.aufgabe21;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.ejb.Stateless;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
@Stateless
|
||||
public class TestLoggerService {
|
||||
|
||||
@Inject
|
||||
private Logger logger;
|
||||
|
||||
public void logBeispiel() {
|
||||
logger.info("CDI-Logger funktioniert! Diese Nachricht kommt vom injizierten Logger.");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_1.xsd">
|
||||
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_1.xsd" bean-discovery-mode="annotated">
|
||||
|
||||
</beans>
|
||||
|
||||
</beans>
|
||||
@@ -1,6 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
|
||||
version="4.0" bean-discovery-mode="annotated">
|
||||
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd" version="4.0" bean-discovery-mode="annotated">
|
||||
</beans>
|
||||
Reference in new issue
Block a user