You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2010/06/07 22:08:05 UTC
svn commit: r952400 - in
/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans:
annotation/ boot/ component/
Author: struberg
Date: Mon Jun 7 20:08:05 2010
New Revision: 952400
URL: http://svn.apache.org/viewvc?rev=952400&view=rev
Log:
OWB-275 cleanup code
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnyLiteral.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/ApplicationScopeLiteral.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NewLiteral.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/SessionScopeLiteral.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnyLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnyLiteral.java?rev=952400&r1=952399&r2=952400&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnyLiteral.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnyLiteral.java Mon Jun 7 20:08:05 2010
@@ -21,6 +21,6 @@ package org.apache.webbeans.annotation;
import javax.enterprise.inject.Any;
import javax.enterprise.util.AnnotationLiteral;
-public class AnyLiteral extends AnnotationLiteral<Any> implements Any{
-
+public class AnyLiteral extends AnnotationLiteral<Any> implements Any
+{
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/ApplicationScopeLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/ApplicationScopeLiteral.java?rev=952400&r1=952399&r2=952400&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/ApplicationScopeLiteral.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/ApplicationScopeLiteral.java Mon Jun 7 20:08:05 2010
@@ -19,11 +19,10 @@
package org.apache.webbeans.annotation;
import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.context.RequestScoped;
import javax.enterprise.util.AnnotationLiteral;
/**
- * {@link RequestScoped} literal annotation.
+ * {@link javax.enterprise.context.RequestScoped} literal annotation.
*
* @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
* @since 1.0
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NewLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NewLiteral.java?rev=952400&r1=952399&r2=952400&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NewLiteral.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/NewLiteral.java Mon Jun 7 20:08:05 2010
@@ -29,21 +29,22 @@ import javax.enterprise.util.AnnotationL
*/
public class NewLiteral extends AnnotationLiteral<New> implements New
{
- private Class<?> clazz = null;
-
- public NewLiteral()
- {
- this.clazz = New.class;
- }
-
- public NewLiteral(Class<?> clazz)
- {
- this.clazz = clazz;
- }
+ private Class<?> clazz = null;
- /** {@inheritDoc} */
+ public NewLiteral()
+ {
+ this.clazz = New.class;
+ }
+
+ public NewLiteral(Class<?> clazz)
+ {
+ this.clazz = clazz;
+ }
+
+ /** {@inheritDoc} */
@Override
- public Class<?> value() {
+ public Class<?> value()
+ {
return clazz;
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/SessionScopeLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/SessionScopeLiteral.java?rev=952400&r1=952399&r2=952400&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/SessionScopeLiteral.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/SessionScopeLiteral.java Mon Jun 7 20:08:05 2010
@@ -18,12 +18,11 @@
*/
package org.apache.webbeans.annotation;
-import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.util.AnnotationLiteral;
/**
- * {@link RequestScoped} literal annotation.
+ * {@link javax.enterprise.context.RequestScoped} literal annotation.
*
* @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
* @since 1.0
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java?rev=952400&r1=952399&r2=952400&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/boot/Bootstrap.java Mon Jun 7 20:08:05 2010
@@ -28,7 +28,7 @@ import org.apache.webbeans.spi.Container
public class Bootstrap
{
- private static final WebBeansLogger logger = WebBeansLogger.getLogger(Bootstrap.class);
+ private static final WebBeansLogger log = WebBeansLogger.getLogger(Bootstrap.class);
private CountDownLatch latch = new CountDownLatch(1);
@@ -38,13 +38,13 @@ public class Bootstrap
public void init(Properties properties)
{
- logger.info(OWBLogConst.INFO_0006);
+ log.info(OWBLogConst.INFO_0006);
this.containerLifecycle = LifecycleFactory.getInstance().getLifecycle();
}
public void start() throws Exception
{
- logger.info(OWBLogConst.INFO_0005);
+ log.info(OWBLogConst.INFO_0005);
long begin = System.currentTimeMillis();
containerLifecycle.startApplication(this.properties);
@@ -57,14 +57,14 @@ public class Bootstrap
});
- logger.info(OWBLogConst.INFO_0001, Long.toString(System.currentTimeMillis() - begin));
+ log.info(OWBLogConst.INFO_0001, Long.toString(System.currentTimeMillis() - begin));
this.latch.await();
- logger.info(OWBLogConst.INFO_0008);
+ log.info(OWBLogConst.INFO_0008);
containerLifecycle.stopApplication(this.properties);
- logger.info(OWBLogConst.INFO_0009);
+ log.info(OWBLogConst.INFO_0009);
}
public static void main(String []args) throws Exception
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java?rev=952400&r1=952399&r2=952400&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java Mon Jun 7 20:08:05 2010
@@ -66,7 +66,7 @@ import org.apache.webbeans.util.WebBeans
public abstract class AbstractInjectionTargetBean<T> extends AbstractOwbBean<T> implements InjectionTargetBean<T>
{
/** Logger instance */
- private final WebBeansLogger logger = WebBeansLogger.getLogger(getClass());
+ private final static WebBeansLogger log = WebBeansLogger.getLogger(AbstractInjectionTargetBean.class);
/** Bean observable method */
private Set<Method> observableMethods = new HashSet<Method>();
@@ -252,7 +252,10 @@ public abstract class AbstractInjectionT
// Call Post Construct
if (WebBeansUtil.isContainsInterceptorMethod(getInterceptorStack(), InterceptorType.POST_CONSTRUCT))
{
- InvocationContextImpl impl = new InvocationContextImpl(null, instance, null, null, InterceptorUtil.getInterceptorMethods(getInterceptorStack(), InterceptorType.POST_CONSTRUCT), InterceptorType.POST_CONSTRUCT);
+ InvocationContextImpl impl = new InvocationContextImpl(null, instance, null, null,
+ InterceptorUtil.getInterceptorMethods(getInterceptorStack(),
+ InterceptorType.POST_CONSTRUCT),
+ InterceptorType.POST_CONSTRUCT);
impl.setCreationalContext(ownerCreationalContext);
try
{
@@ -261,7 +264,7 @@ public abstract class AbstractInjectionT
catch (Exception e)
{
- logger.error(OWBLogConst.ERROR_0008, e, "@PostConstruct.");
+ log.error(OWBLogConst.ERROR_0008, e, "@PostConstruct.");
throw new WebBeansException(e);
}
}
@@ -288,7 +291,10 @@ public abstract class AbstractInjectionT
{
if (WebBeansUtil.isContainsInterceptorMethod(getInterceptorStack(), InterceptorType.PRE_DESTROY))
{
- InvocationContextImpl impl = new InvocationContextImpl(null, instance, null, null, InterceptorUtil.getInterceptorMethods(getInterceptorStack(), InterceptorType.PRE_DESTROY), InterceptorType.PRE_DESTROY);
+ InvocationContextImpl impl = new InvocationContextImpl(null, instance, null, null,
+ InterceptorUtil.getInterceptorMethods(getInterceptorStack(),
+ InterceptorType.PRE_DESTROY),
+ InterceptorType.PRE_DESTROY);
impl.setCreationalContext(creationalContext);
try
{
@@ -296,7 +302,7 @@ public abstract class AbstractInjectionT
}
catch (Exception e)
{
- logger.error(OWBLogConst.ERROR_0008, e, "@PreDestroy.");
+ log.error(OWBLogConst.ERROR_0008, e, "@PreDestroy.");
throw new WebBeansException(e);
}
}
@@ -323,8 +329,10 @@ public abstract class AbstractInjectionT
//InjectionPoint.
else
{
- Bean<?> injectionPointBean = getManager().getBeans(InjectionPoint.class, new DefaultLiteral()).iterator().next();
- Object reference = getManager().getReference(injectionPointBean, InjectionPoint.class, getManager().createCreationalContext(injectionPointBean));
+ Bean<?> injectionPointBean = getManager().getBeans(InjectionPoint.class, new DefaultLiteral())
+ .iterator().next();
+ Object reference = getManager().getReference(injectionPointBean, InjectionPoint.class,
+ getManager().createCreationalContext(injectionPointBean));
ClassUtil.setField(instance, field, reference);
}
@@ -362,7 +370,7 @@ public abstract class AbstractInjectionT
}
/**
- * Injects all {@link Initializer} methods of the bean instance.
+ * Injects all {@link javax.inject.Inject} methods of the bean instance.
*
* @param instance bean instance
* @param creationalContext creational context instance
@@ -398,7 +406,8 @@ public abstract class AbstractInjectionT
{
service = ServiceLoader.getService(ResourceInjectionService.class);
- }catch(Exception e)
+ }
+ catch(Exception e)
{
// When running in tests
}
@@ -410,8 +419,9 @@ public abstract class AbstractInjectionT
}
catch (Exception e)
{
- logger.error(OWBLogConst.ERROR_0023, instance);
- throw new WebBeansException(MessageFormat.format(logger.getTokenString(OWBLogConst.ERROR_0023), instance), e);
+ log.error(OWBLogConst.ERROR_0023, instance);
+ throw new WebBeansException(MessageFormat.format(
+ log.getTokenString(OWBLogConst.ERROR_0023), instance), e);
}
}
}
@@ -486,7 +496,7 @@ public abstract class AbstractInjectionT
/**
* Add new injected method.
*
- * @param field new injected method
+ * @param method new injected method
*/
public void addInjectedMethod(Method method)
{
@@ -506,7 +516,7 @@ public abstract class AbstractInjectionT
/**
* Add new injected method.
*
- * @param field new injected method
+ * @param method new injected method
*/
public void addInjectedMethodToSuper(Method method)
{
@@ -550,7 +560,7 @@ public abstract class AbstractInjectionT
*/
protected WebBeansLogger getLogger()
{
- return this.logger;
+ return this.log;
}
/**
@@ -594,7 +604,8 @@ public abstract class AbstractInjectionT
WebBeansDecorator<?> decorator = (WebBeansDecorator<?>)dec;
if(!decorator.isPassivationCapable())
{
- throw new WebBeansConfigurationException(MessageFormat.format(logger.getTokenString(OWBLogConst.EXCEPT_0015), toString()));
+ throw new WebBeansConfigurationException(MessageFormat.format(
+ log.getTokenString(OWBLogConst.EXCEPT_0015), toString()));
}
else
{
@@ -609,7 +620,8 @@ public abstract class AbstractInjectionT
WebBeansInterceptor<?> interceptor = (WebBeansInterceptor<?>)interceptorData.getWebBeansInterceptor();
if(!interceptor.isPassivationCapable())
{
- throw new WebBeansConfigurationException(MessageFormat.format(logger.getTokenString(OWBLogConst.EXCEPT_0016), toString()));
+ throw new WebBeansConfigurationException(MessageFormat.format(
+ log.getTokenString(OWBLogConst.EXCEPT_0016), toString()));
}
else
{
@@ -623,13 +635,15 @@ public abstract class AbstractInjectionT
Class<?> interceptorClass = interceptorData.getInterceptorClass();
if(!Serializable.class.isAssignableFrom(interceptorClass))
{
- throw new WebBeansConfigurationException(MessageFormat.format(logger.getTokenString(OWBLogConst.EXCEPT_0016), toString()));
+ throw new WebBeansConfigurationException(MessageFormat.format(
+ log.getTokenString(OWBLogConst.EXCEPT_0016), toString()));
}
else
{
if(!OWBInjector.checkInjectionPointForInterceptorPassivation(interceptorClass))
{
- throw new WebBeansConfigurationException(MessageFormat.format(logger.getTokenString(OWBLogConst.EXCEPT_0017), toString(), interceptorClass));
+ throw new WebBeansConfigurationException(MessageFormat.format(
+ log.getTokenString(OWBLogConst.EXCEPT_0017), toString(), interceptorClass));
}
}
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java?rev=952400&r1=952399&r2=952400&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java Mon Jun 7 20:08:05 2010
@@ -31,7 +31,6 @@ import javax.enterprise.context.Dependen
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.CreationException;
import javax.enterprise.inject.Disposes;
-import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import org.apache.webbeans.config.OWBLogConst;
@@ -49,8 +48,7 @@ import org.apache.webbeans.util.WebBeans
*
* @version $Rev$ $Date$
*
- * @see OwbBean
- * @see Bean
+ * @see javax.enterprise.inject.spi.Bean
*/
public abstract class AbstractOwbBean<T> implements OwbBean<T>
{
@@ -151,7 +149,8 @@ public abstract class AbstractOwbBean<T>
{
if(!(creationalContext instanceof CreationalContextImpl))
{
- creationalContext = CreationalContextFactory.getInstance().wrappedCreationalContext(creationalContext, this);
+ creationalContext = CreationalContextFactory.getInstance().wrappedCreationalContext(
+ creationalContext, this);
}
InjectionTargetWrapper<T> wrapper = getManager().getInjectionTargetWrapper(this);
@@ -232,11 +231,13 @@ public abstract class AbstractOwbBean<T>
//Destory dependent instances
creationalContext.release();
- }catch(Exception e)
+ }
+ catch(Exception e)
{
logger.fatal(OWBLogConst.FATAL_0001, this);
e.printStackTrace();
- }finally
+ }
+ finally
{
CreationalContextImpl.currentRemoveObject.set(null);
CreationalContextImpl.currentRemoveObject.remove();
@@ -265,15 +266,15 @@ public abstract class AbstractOwbBean<T>
}
/**
- * TODO there are probably other infos which must get added to make the id unique!
- * If not, it will crash in {@link BeanManagerImpl#addPassivationInfo(javax.enterprise.inject.spi.Bean)}
- * anyway.
+ * get the unique Id of the bean. This will get used as reference on
+ * passivation.
*
* {@inheritDoc}
*/
public String getId()
{
- if (!isEnabled() || returnType.equals(Object.class)) {
+ if (!isEnabled() || returnType.equals(Object.class))
+ {
// if the Bean is disabled, either by rule, or by
// annotating it @Typed() as Object, then it is not serializable
return null;
@@ -412,9 +413,13 @@ public abstract class AbstractOwbBean<T>
public void setName(String name)
{
if (this.name == null)
+ {
this.name = name;
+ }
else
+ {
throw new UnsupportedOperationException("Component name is not null, is " + this.name);
+ }
}
/*
@@ -661,7 +666,8 @@ public abstract class AbstractOwbBean<T>
{
continue;
}
- throw new WebBeansConfigurationException("Passivation capable beans must satisfy passivation capable dependencies. " +
+ throw new WebBeansConfigurationException(
+ "Passivation capable beans must satisfy passivation capable dependencies. " +
"Bean : " + toString() + " does not satisfy.");
}
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java?rev=952400&r1=952399&r2=952400&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java Mon Jun 7 20:08:05 2010
@@ -111,7 +111,8 @@ public abstract class AbstractProducerBe
Annotation[] anns = new Annotation[this.ownerComponent.getQualifiers().size()];
anns = this.ownerComponent.getQualifiers().toArray(anns);
- Bean<?> specialize = WebBeansUtil.getMostSpecializedBean(getManager(), (AbstractOwbBean<T>) this.ownerComponent);
+ Bean<?> specialize = WebBeansUtil.getMostSpecializedBean(getManager(),
+ (AbstractOwbBean<T>) this.ownerComponent);
if (specialize != null)
{
@@ -135,15 +136,19 @@ public abstract class AbstractProducerBe
Annotation[] anns = new Annotation[this.ownerComponent.getQualifiers().size()];
anns = this.ownerComponent.getQualifiers().toArray(anns);
- Bean<?> specialize = WebBeansUtil.getMostSpecializedBean(getManager(), (AbstractOwbBean<T>) this.ownerComponent);
+ Bean<?> specialize = WebBeansUtil.getMostSpecializedBean(getManager(),
+ (AbstractOwbBean<T>) this.ownerComponent);
if (specialize != null)
{
- parentInstance = getManager().getContext(specialize.getScope()).get((Bean<Object>)specialize,(CreationalContext<Object>) creationalContext);
+ parentInstance = getManager().getContext(specialize.getScope()).
+ get((Bean<Object>)specialize,(CreationalContext<Object>) creationalContext);
}
else
{
- parentInstance = getManager().getContext(this.ownerComponent.getScope()).get((Bean<Object>)this.ownerComponent,(CreationalContext<Object>) creationalContext);
+ parentInstance = getManager().getContext(
+ ownerComponent.getScope()).get((Bean<Object>)ownerComponent,
+ (CreationalContext<Object>) creationalContext);
}
return parentInstance;