May 18, 2024, 6:27 p.m. | Mustafa Çam

DEV Community dev.to

@Named(value = "newtuto")

@ApplicationScoped

public class _04_New {



//üretilen
@Produces
public String uretilenData( @New StudentDto studentDto){
studentDto=StudentDto.builder()
.studentId(0L).studentName("student Adi")
.build();
return studentDto.getStudentName();
}

@Getter
@Inject
private String tuketilenData;


}


Bu Java kodu, CDI (Contexts and Dependency Injection) ve Lombok kütüphanesini kullanarak bir sınıf tanımlıyor. Açıklamalarıyla birlikte her bir parçanın ne işe yaradığını inceleyelim:




  • @Named(value = "newtuto"): Bu annotation, CDI tarafından yönetilen bir bean'i tanımlar ve newtuto adı altında JSF (JavaServer Faces) gibi view teknolojilerinde kullanılabilir hale getirir¹⁵.


  • @ApplicationScoped: Bu annotation, …

build builder class dependency inject injection java private public return student value

CyberSOC Technical Lead

@ Integrity360 | Sandyford, Dublin, Ireland

Cyber Security Strategy Consultant

@ Capco | New York City

Cyber Security Senior Consultant

@ Capco | Chicago, IL

Sr. Product Manager

@ MixMode | Remote, US

Corporate Intern - Information Security (Year Round)

@ Associated Bank | US WI Remote

Senior Offensive Security Engineer

@ CoStar Group | US-DC Washington, DC