
com.vaadin.cdi.ViewScoped Maven / Gradle / Ivy
Show all versions of vaadin-cdi Show documentation
/*
* Copyright 2000-2013 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.cdi;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Scope;
/**
* The lifecycle of a ViewScoped component starts when the view is navigated to
* and ends when navigating to a different view or when the UI is closed.
*
* Injection with this annotation will create a direct reference to the object
* rather than a proxy.
*
* There are some limitations when not using proxies. Interceptors and
* decorators will not work. Circular referencing (that is, injecting A to B and
* B to A) will not work unless there is at least one proxy in between.
*
* The sister annotation to this is the {@link @NormalViewScoped}. Both
* annotations reference the same underlying scope, so it is possible to get
* both a proxy and a direct reference to the same object by using different
* annotations.
*/
@Scope
@Inherited
@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD,
ElementType.METHOD, ElementType.CONSTRUCTOR })
@Retention(RetentionPolicy.RUNTIME)
public @interface ViewScoped {
}