UFO ET IT

관리 빈과 백업 빈의 차이점

ufoet 2020. 12. 4. 21:30
반응형

관리 빈과 백업 빈의 차이점


여러 포럼에서 "관리 빈"과 "백킹 빈"이라는 용어를 발견했습니다. 많은 사람들은 둘 다 같다고 생각합니다. 그러나 약간의 차이가있는 것 같습니다. 이 두 용어의 정확한 차이점을 이해하는 데 도움이 될 수 있습니까?


내 초기 답변 변경-둘 사이에는 의미있는 차이가 없습니다. 튜토리얼은 백업 콩 나중에 관리 빈으로 선언되어 있다고 말한다. 요약하면 다음과 같습니다.

  • 백킹 빈은 컨텍스트에서 벗어난 클래스입니다.
  • 관리 Bean은 JSF 관리 Bean 기능과 함께 사용되도록 선언 될 때마다 지원 Bean입니다.

나는 "backing bean"이라는 용어를 실제로 사용하지 않았습니다. 왜냐하면 나는 그것을 사용하지 않았기 때문입니다. 따라서 "관리 빈"만 사용하는 것이 더 나을 수 있습니다. JSF 2.0 (및 CDI)에는 보유하고 @ManagedBean있으므로 Bean은 관리되는 Bean입니다.

BalusC는 "backing bean"이 정의이고 "managed bean"이 인스턴스라고 제안했습니다. 이것이 JSF 제작자의 원래 아이디어 였을 수도 있지만 지원할 가치가 없다고 생각합니다. 예를 들어 CDI와 spring은 "bean definition"과 "bean instance"에 대해 다른 용어를 사용하지 않습니다.

JSF 2.0 사양에서는 "backing bean"이라는 용어를 몇 번만 언급하며 정의가 전혀 없습니다. 그 외에도 "backing bean class"를 언급하는데, 이것은 "backing bean"! = "backing bean class"를 의미 할 수 있으며, 이는 더 많은 혼란을 가져옵니다.

결론적으로-나에게는 둘 다 상호 교환이 가능하며 "관리되는 빈"만 사용하고 싶습니다.


Managed Bean이란 무엇입니까?

JSF 구현에 의해 관리되는 JavaBean 객체를 관리 빈이라고합니다. 관리 Bean은 Bean이 작성되고 관리되는 방법을 설명합니다. 빈의 기능과는 아무 관련이 없습니다.

Backing Bean은 무엇입니까?

Backing Bean은 페이지에서 사용되는 UI 구성 요소와 관련된 JavaBeans 구성 요소입니다. Backing-bean 관리는 UI 구성 요소 개체의 정의를 애플리케이션 별 처리를 수행하고 데이터를 보유하는 개체와 분리합니다. backing bean은 페이지에서 사용되는 UI 구성 요소와 관련된 속성 및 처리 로직을 정의합니다. 각 backing-bean 속성은 구성 요소 인스턴스 또는 해당 값에 바인딩됩니다. 또한 Backing Bean은 구성 요소의 데이터 유효성 검사, 구성 요소가 실행하는 이벤트 처리 및 구성 요소가 활성화 될 때 탐색과 관련된 처리 수행과 같이 구성 요소에 대한 기능을 수행하는 메서드 집합을 정의합니다.

Backing Bean과 Managed Bean의 차이점은 무엇입니까?

Backing Bean은 매우 특별한 목적을 가진 JSF Managed Bean의 하위 유형 인 규칙 일뿐입니다. Backing Bean에는 사용법을 제외하고 다른 관리 Bean과 다른 특별한 것은 없습니다.

MB : 관리 빈; BB : 백킹 빈

1) BB : backing bean은 폼에서 참조하는 bean입니다.

MB : 관리 빈은 JSF (faces-config.xml에서)에 등록 된 백업 빈이며 필요할 때 JSF에 의해 자동으로 생성 (선택적으로 초기화)됩니다.

관리 빈의 장점은 JSF 프레임 워크가 이러한 빈을 자동으로 생성하고, 선택적으로 faces-config.xml에서 지정한 매개 변수로 초기화한다는 것입니다.

2) BB : Backing Beans는 요청 범위 에서만 정의되어야합니다.

MB : JSF에 의해 생성 된 관리 빈은 요청, 세션 또는 응용 프로그램 범위 내에 저장 될 수 있습니다 .

Backing Bean은 요청 범위에서 정의되어야하며 특정 페이지와 일대일 관계로 존재해야하며 모든 페이지 특정 이벤트 처리 코드를 보유해야합니다. 실제 시나리오에서는 여러 페이지가 뒤에서 동일한 백킹 빈을 공유해야 할 수 있습니다. backing bean은 뷰 데이터뿐만 아니라 해당 데이터와 관련된 동작도 포함합니다.


Backing Bean은 JSF UI와 결합 된 모든 Bean입니다. 관리 빈은 모든 빈입니다.


간단히 말해서,

개발자는 다음을 수행합니다.

@ManagedBean(name="managedBean")
@RequestScoped
public class BackingBean {
    // ...
}

빈 관리 프레임 워크로서의 JSF는 다음과 같은 작업을 수행합니다.

BackingBean managedBean = new BackingBean();
externalContext.getRequestMap().put("managedBean", managedBean);

따라서 backing bean은 사용자가 개발하고 일반적으로 뷰에 연결되는 구체적인 클래스이고, 관리되는 bean은 필요에 따라 bean 관리 프레임 워크에 의해 생성되고 원하는 범위에 배치되는 구체적인 인스턴스입니다. #{managedBean}EL에서 사용할 수 있습니다 . 직접 만들고 범위에 넣을 필요가 없습니다. 그렇게했다면 프레임 워크 관리 빈 수단이 없습니다.

CDI @Named와 Spring @Component은 본질적으로 JSF와 같은 일을 @ManagedBean합니다.

JSF, CDI 및 Spring과 같은 Bean 관리 프레임 워크가 관리되는 Bean을 찾고 생성하는 방법에 대해 자세히 알아 보려면 다음 문제 해결사에서 심층적 인 통찰력을 제공해야합니다 . javax.el.PropertyNotFoundException 식별 및 해결 : Target Unreachable .

또한보십시오:


http://docs.oracle.com/javaee/5/tutorial/doc/bnaqm.html 말한다

일반적인 JavaServer Faces 애플리케이션에는 하나 이상의 지원 Bean이 포함되며, 각 Bean은 특정 페이지에서 사용되는 UI 구성 요소와 연관된 JavaServer Faces 관리 Bean입니다. 관리 빈은 빈 구성에 설명 된 관리 빈 기능을 사용하여 구성 할 수있는 JavaBeans 구성 요소 (JavaBeans 구성 요소 참조)입니다. 이 섹션에서는 애플리케이션에서 백킹 빈을 생성, 구성 및 사용하는 기본 개념을 소개합니다.

http://docs.oracle.com/javaee/6/tutorial/doc/bnaqm.html 에서는 "backing bean"에 대해 언급하지 않습니다.


Managed Beans are managed (instantiated and destroyed) by container.

Backing Beans are managed beans that back views as data models.


I would say that the backing bean is a bean used strictly for UI purposes, that is, referenced in the jsp files. After all, all beans managed by JSF container are managed beans, however there are different contexts in which they might be used. For more see accepted answer here: JSF : ManagedBean, Good place to deal with Business Logic?


Backing Bean is a kind of Managed Bean. Managed Bean is an Object (i.e. instance of a Class ), created by a container (that's why it is called managed) and of course that Object has a Class and if you feel like it, you can create as many instances of that class no matter what annotation they have with m = new MyManagedBean(), just it will be a Not-So-Managed-Bean or at least not managed by a container but managed by you :)

And backing bean is a kind of managed bean (as Santosh put it: a convention) that usually uses the JSF requestScope (but in some frameworks like ADF there is even a designated scope only for backing beans called backingBeanScope - you would have never guessed) .

And yes... The flavor of jsf managed beans that one would call BackingBeans is used to bind UIComponents and write ActionListeners, while lets say "model beans" flavor would go in the session scope for example and hold your data


I took a very good (expensive) course on JSF. What I learned there is just about what is explained in http://www.avromroyfaderman.com/2008/07/from-backing-bean-to-managed-bean/.

Perhaps this difference is not the theoretical difference or the etymology of the terms, but it is certainly a very practical way to set up your architecture, especially if you are part of a large project with multiple developers and/or need to maintain a lot of code for a long time. Basically the idea is that you put your UI Business Logic in Managed Beans. Backing beans are sparse and just support the page itself.


From this link JSF - Managed Beans

Managed Bean :

Managed Bean is a regular Java Bean class registered with JSF. In other words, Managed Beans is a java bean managed by JSF framework.

From this link Creating and Using a Backing Bean for a Web Page :

Backing Bean :

In JSF, backing beans are JavaBeans used mainly to provide UI logic and to manage data between the web tier and the business tier of the application (similar to a data transfer object). Typically you have one backing bean per JSF page. The backing bean contains the logic and properties for the UI components used on the page.

NB:

For a backing bean to be available when the application starts, you register it as a managed bean with a name and scope


Managed Bean:

A managed bean is a backing bean that has been registered with JSF (in faces-config.xml) or using Annotations. Managed Bean automatically created (and optionally initialized) by JSF when it is needed.

If you use Managed Bean in your application you have to use following syntax in JSF page to set or get values form bean

<h:inputText value="#{user.name}"/>

Backing Bean:

A bean that contains some or all component objects of a web form. Such a bean is called a backing bean for the web form.

When you use a backing bean, you need to wire up the components on the form to those on the bean. You use the binding attribute for this purpose

Example:

<h:inputText binding="#{myForm.myComponent}" .../>

Observe how we are getting or setting values to Backing bean.

Backing Beans should be defined in the request scope, exist in a one-to-one relationship with a particular page and hold all of the page specific event handling code

Hope it useful to someone.

참고URL : https://stackoverflow.com/questions/4713483/difference-between-managed-bean-and-backing-bean

반응형