You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2009/07/01 22:26:23 UTC
svn commit: r790361 - in /incubator/openwebbeans/trunk/webbeans-api: ./
src/main/java/javax/enterprise/context/spi/
src/main/java/javax/enterprise/inject/
src/main/java/javax/enterprise/inject/spi/
Author: gerdogdu
Date: Wed Jul 1 20:26:23 2009
New Revision: 790361
URL: http://svn.apache.org/viewvc?rev=790361&view=rev
Log:
Reflect API changes.
Added:
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/InjectionTarget.java (with props)
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Producer.java (with props)
Modified:
incubator/openwebbeans/trunk/webbeans-api/pom.xml
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/context/spi/Contextual.java
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/context/spi/CreationalContext.java
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/spi/Bean.java
incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/spi/BeanManager.java
Modified: incubator/openwebbeans/trunk/webbeans-api/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/pom.xml?rev=790361&r1=790360&r2=790361&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/pom.xml (original)
+++ incubator/openwebbeans/trunk/webbeans-api/pom.xml Wed Jul 1 20:26:23 2009
@@ -32,7 +32,12 @@
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-interceptor_3.0_spec</artifactId>
<version>1.0.1</version>
- <scope>provided</scope>
+ <scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-el_1.0_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
Modified: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/context/spi/Contextual.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/context/spi/Contextual.java?rev=790361&r1=790360&r2=790361&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/context/spi/Contextual.java (original)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/context/spi/Contextual.java Wed Jul 1 20:26:23 2009
@@ -41,6 +41,7 @@
* in this method.
*
* @param instance already created webbeans instance
+ * @param context creational context
*/
- public void destroy(T instance);
+ public void destroy(T instance, CreationalContext<T> context);
}
Modified: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/context/spi/CreationalContext.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/context/spi/CreationalContext.java?rev=790361&r1=790360&r2=790361&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/context/spi/CreationalContext.java (original)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/context/spi/CreationalContext.java Wed Jul 1 20:26:23 2009
@@ -41,6 +41,10 @@
*/
public void push(T incompleteInstance);
+ /**
+ * Destorys all dependent objects of the instance
+ * that is being destroyed.
+ */
public void release();
}
Added: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/InjectionTarget.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/InjectionTarget.java?rev=790361&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/InjectionTarget.java (added)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/InjectionTarget.java Wed Jul 1 20:26:23 2009
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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 javax.enterprise.inject;
+
+import javax.enterprise.context.spi.CreationalContext;
+
+/**
+ * Injection related operations on the bean instance.
+ *
+ * @version $Rev$ $Date$
+ *
+ * @param <T> bean instance type info
+ */
+public interface InjectionTarget<T> extends Producer<T>
+{
+ /**
+ * Does injection on the bean instance.
+ *
+ * @param instance bean instance
+ * @param ctx creational context
+ */
+ public void inject(T instance, CreationalContext<T> ctx);
+
+ /**
+ * Calls <code>@PostConstruct</code> method if it has one.
+ *
+ * @param instance bean instance
+ */
+ public void postConstruct(T instance);
+
+ /**
+ * Calls <code>@PreDestroy</code> method if it has one.
+ *
+ * @param instance bean instance
+ */
+ public void preDestroy(T instance);
+}
\ No newline at end of file
Propchange: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/InjectionTarget.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/InjectionTarget.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Producer.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Producer.java?rev=790361&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Producer.java (added)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Producer.java Wed Jul 1 20:26:23 2009
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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 javax.enterprise.inject;
+
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+/**
+ * Provides a generic operation for producing an instance of a type.
+ *
+ * @version $Rev$ $Date$
+ *
+ * @param <T> bean instance type info
+ */
+public interface Producer<T>
+{
+ /**
+ * Returns instance of a bean.
+ *
+ * @param ctx creational context to attach and destroy dependents
+ * @return instance of a bean
+ */
+ public T produce(CreationalContext<T> ctx);
+
+ /**
+ * Dispose the bean instance.
+ *
+ * @param instance disposed instance of bean
+ */
+ public void dispose(T instance);
+
+ /**
+ * Returns bean's set of injection points
+ *
+ * @return bean's set of injection points
+ */
+ public Set<InjectionPoint> getInjectionPoints();
+}
\ No newline at end of file
Propchange: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Producer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/Producer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/spi/Bean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/spi/Bean.java?rev=790361&r1=790360&r2=790361&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/spi/Bean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/spi/Bean.java Wed Jul 1 20:26:23 2009
@@ -108,6 +108,13 @@
*
* @return bean stereotypes
*/
- public abstract Set<Annotation> getStereotypes();
+ public Set<Class<? extends Annotation>> getStereotypes();
+
+ /**
+ * Returns true if declares as policy
+ *
+ * @return true if declares as policy
+ */
+ public boolean isPolicy();
}
\ No newline at end of file
Modified: incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/spi/BeanManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/spi/BeanManager.java?rev=790361&r1=790360&r2=790361&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/spi/BeanManager.java (original)
+++ incubator/openwebbeans/trunk/webbeans-api/src/main/java/javax/enterprise/inject/spi/BeanManager.java Wed Jul 1 20:26:23 2009
@@ -13,16 +13,21 @@
*/
package javax.enterprise.inject.spi;
-import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
import java.util.List;
import java.util.Set;
+import javax.el.ELResolver;
+import javax.enterprise.context.ScopeType;
import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observer;
-import javax.enterprise.inject.TypeLiteral;
+import javax.enterprise.inject.AmbiguousResolutionException;
+import javax.enterprise.inject.InjectionException;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
/**
@@ -51,111 +56,221 @@
public interface BeanManager
{
/**
- * Resolve beans with given api type and bindings.
+ * Returns a bean instance reference for the given bean.
*
- * @param apiType api type of the bean
- * @param bindings beans bindings
- * @return the set of webbeans
+ * @param bean bean that its reference is getting
+ * @param beanType bean api type that is implemented by the proxy
+ * @param ctx creational context is used to destroy any object with scope <code>@Dependent</code>
+ * @return bean reference
+ * @throws IllegalArgumentException if given bean type is not api type of the given bean object
*/
- public <T> Set<Bean<T>> resolveByType(Class<T> apiType, Annotation... bindings);
-
+ public Object getReference(Bean<?> bean, Type beanType, CreationalContext<?> ctx);
+
/**
- * Resolves beans with given {@link TypeLiteral} generic type
- * and binding types.
+ * Gets injection point bean reference.
*
- * @param apiType bean api type
- * @param bindingTypes bean binding types
- * @return the set of resolved beans
+ * @param injectionPoint injection point definition
+ * @param ctx creational context that is passed to the {@link Bean#create(CreationalContext)} method
+ * @return bean reference
+ * @throws UnsatisfiedResolutionException if no bean found for the given injection point
+ * @throws AmbiguousResolutionException if more than one bean found
*/
- public <T> Set<Bean<T>> resolveByType(TypeLiteral<T> apiType, Annotation... bindingTypes);
-
+ public Object getInjectableReference(InjectionPoint injectionPoint, CreationalContext<?> ctx);
+
/**
- * Gets bean instance using its context.
+ * Returns a new creational context implementation.
*
- * @param type type of the bean
- * @param bindingTypes binding types of the bean
- * @return the bean instance
+ * @return new creational context
*/
- public <T> T getInstanceByType(Class<T> type, Annotation... bindingTypes);
-
+ public <T> CreationalContext<T> createCreationalContext(Contextual<T> contextual);
+
/**
- * Gets instance of the bean from its context.
+ * Returns set of beans that their api types contain
+ * given bean type and given bindings.
+ *
+ * <p>
+ * If no binding is given, <code>@Current</code> is assumed.
+ * </p>
*
- * @param type generic type of bean using {@link TypeLiteral}
- * @param bindingTypes binding types
- * @return instance of the bean
+ * @param beanType required bean type
+ * @param bindings required binding types
+ * @return set of beans
+ * @throws IllegalArgumentException given bean type is a {@link TypeVariable}
+ * @throws IllegalArgumentException given binding annotation is not a binding type
+ * @throws IllegalArgumentException same binding type is given
*/
- public <T> T getInstanceByType(TypeLiteral<T> type, Annotation... bindingTypes);
-
+ public Set<Bean<?>> getBeans(Type beanType, Annotation... bindings);
+
/**
- * Resolves the set of beans with given name.
+ * Returns set of beans with given name.
*
* @param name name of the bean
- * @return the set of resolved beans with given name
+ * @return set of beans with given name
*/
- public Set<Bean<?>> resolveByName(String name);
-
+ public Set<Bean<?>> getBeans(String name);
+
/**
- * Gets instance of the injection point.
- * <p>
- * See the specification section 5.7.1 Resolving dependencies.
- * </p>
+ * Returns bean's most specialized bean object.
*
- * @param injectionPoint injection point definition
- * @param context creational context instance
- * @return instance of the injection point or null
+ * @param <X> bean class type info
+ * @param bean bean object
+ * @return bean's most specialized bean object
*/
- public <T> T getInstanceToInject(InjectionPoint injectionPoint, CreationalContext<?> context);
-
- public <T> T getInstanceToInject(InjectionPoint injectionPoint);
-
- public Object getInstanceByName(String name);
-
- public <T> T getInstance(Bean<T> bean);
-
- public void fireEvent(Object event, Annotation... bindings);
-
- public Context getContext(Class<? extends Annotation> scopeType);
-
+ public <X> Bean<? extends X> getMostSpecializedBean(Bean<X> bean);
+
/**
- * Add new context to this activity.
+ * Returns passivation capable bean given id.
*
- * @param context new context
- * @return the this activity
+ * @param id bean id
+ * @return passivation capable bean given id
*/
- public BeanManager addContext(Context context);
-
- public BeanManager addBean(Bean<?> bean);
-
+ public Bean<?> getPassivationCapableBean(String id);
+
/**
- * Adds new interceptor to this activity.
+ * Returns a bean object that is resolved according to the type safe resolution rules.
*
- * @param interceptor new interceptor
- * @return the manager instance that this interceptor is added
+ * @param <X> bean class info
+ * @param beans set of beans
+ * @return bean that is resolved according to the type safe resolution rules
+ * @throws AmbiguousResolutionException if ambigious exists
+ */
+ public <X> Bean<? extends X> resolve(Set<Bean<? extends X>> beans);
+
+ /**
+ * Fires an event with given even object and bindings.
+ *
+ * @param event observer event object
+ * @param bindings event bindings
+ * @throws IllegalArgumentException event object contains a {@link TypeVariable}
+ * @throws IllegalArgumentException given binding annotation is not a binding type
+ * @throws IllegalArgumentException same binding type is given
+ */
+ public void fireEvent(Object event, Annotation... bindings);
+
+ /**
+ * Returns a set of observers that observe for given event type and bindings
+ *
+ * @param <T> observer type info
+ * @param event observer event type
+ * @param bindings event bindings
+ * @return set of observers that observe for given event type and bindings
+ * @throws IllegalArgumentException event object contains a {@link TypeVariable}
+ * @throws IllegalArgumentException given binding annotation is not a binding type
+ * @throws IllegalArgumentException same binding type is given
*/
- public BeanManager addInterceptor(Interceptor<?> interceptor);
-
- public BeanManager addDecorator(Decorator<?> decorator);
-
- public <T> BeanManager addObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings);
-
- public <T> BeanManager addObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings);
-
- public <T> BeanManager removeObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings);
-
- public <T> BeanManager removeObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings);
-
public <T> Set<Observer<T>> resolveObservers(T event, Annotation... bindings);
-
- public List<Interceptor<?>> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings);
-
- public List<Decorator<?>> resolveDecorators(Set<Type> types, Annotation... bindingTypes);
- public BeanManager parse(InputStream xmlStream);
+ /**
+ * Returns a list of decorator.
+ *
+ * @param types bean types of the decorated bean
+ * @param bindings decorated bean bindings
+ * @return list of decorator
+ * @throws IllegalArgumentException given binding annotation is not a binding type
+ * @throws IllegalArgumentException same binding type is given
+ * @throws IllegalArgumentException if types is empty set
+ */
+ List<Decorator<?>> resolveDecorators(Set<Type> types, Annotation... bindings);
+
+ /**
+ * Returns a list of interceptor.
+ *
+ * @param type interception type
+ * @param interceptorBindings interceptor bindings
+ * @return list of interceptor
+ * @throws IllegalArgumentException given binding annotation is not a binding type
+ * @throws IllegalArgumentException same binding type is given
+ * @throws IllegalArgumentException binding is not an interceptor binding type
+ */
+ List<Interceptor<?>> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings);
+
+ /**
+ * Validates injection point.
+ *
+ * @param injectionPoint injection point
+ * @throws InjectionException if problem exist
+ */
+ public void validate(InjectionPoint injectionPoint);
- public BeanManager createActivity();
+ /**
+ * Returns true if given type is a scope type, false otherwise.
+ *
+ * @param annotationType annotation type
+ * @return true if given type is a scope type, false otherwise
+ */
+ public boolean isScopeType(Class<? extends Annotation> annotationType);
- public BeanManager setCurrent(Class<? extends Annotation> scopeType);
+ /**
+ * Returns true if given type is a binding type, false otherwise.
+ *
+ * @param annotationType annotation type
+ * @return true if given type is a binding type, false otherwise
+ */
+ public boolean isBindingType(Class<? extends Annotation> annotationType);
+
+ /**
+ * Returns true if given type is a interceptor binding type, false otherwise.
+ *
+ * @param annotationType annotation type
+ * @return true if given type is a interceptor binding type, false otherwise
+ */
+ public boolean isInterceptorBindingType(Class<? extends Annotation> annotationType);
+
+ /**
+ * Returns true if given type is a stereotype type, false otherwise.
+ *
+ * @param annotationType annotation type
+ * @return true if given type is a stereotype, false otherwise
+ */
+ public boolean isStereotype(Class<? extends Annotation> annotationType);
+
+ /**
+ * Gets a scope type annotation.
+ *
+ * @param scopeType scope class type
+ * @return a scope type annotation
+ */
+ public ScopeType getScopeDefinition(Class<? extends Annotation> scopeType);
+
+ /**
+ * Returns a set of meta-annotations that are defined on the binding type
+ *
+ * @param bindingType binding type class
+ * @return a set of meta-annotations that are defined on the binding type
+ */
+ public Set<Annotation> getInterceptorBindingTypeDefinition(Class<? extends Annotation> bindingType);
+
+ /**
+ * Returns a set of meta-annotations that are defined on the stereotype type.
+ *
+ * @param stereotype stereotype type class
+ * @return a set of meta-annotations that are defined on the stereotype type
+ */
+ public Set<Annotation> getStereotypeDefinition(Class<? extends Annotation> stereotype);
+ /**
+ * Returns a context with given scope type.
+ *
+ * @param scopeType scope type class type
+ * @return a context with given scope type
+ */
+ public Context getContext(Class<? extends Annotation> scopeType);
+
+ /**
+ * Returns el resolver.
+ *
+ * @return el resolver
+ */
+ public ELResolver getELResolver();
+
+ /**
+ * Returns a {@link AnnotatedType} instance for the given
+ * class.
+ *
+ * @param <T> class type
+ * @param type class
+ * @return a {@link AnnotatedType} instance
+ */
+ public <T> AnnotatedType<T> createAnnotatedType(Class<T> type);
}
\ No newline at end of file