[webbeans-commits] Webbeans SVN: r2923 - in ri/trunk/impl/src/main/java/org/jboss/webbeans: bootstrap and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Sun Jun 28 17:39:24 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-06-28 17:39:24 -0400 (Sun, 28 Jun 2009)
New Revision: 2923

Added:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeforeShutdownImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/ProcessAnnotatedTypeImpl.java
Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AfterBeanDiscoveryImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
Log:
A bit more of chapter 11

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java	2009-06-28 21:25:03 UTC (rev 2922)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java	2009-06-28 21:39:24 UTC (rev 2923)
@@ -326,15 +326,6 @@
       }
    }
 
-   /**
-    * Registers a bean with the manager
-    * 
-    * @param bean The bean to register
-    * @return A reference to manager
-    * 
-    * @see javax.enterprise.inject.spi.BeanManager#addBean(javax.inject.manager.Bean)
-    */
-   @Deprecated
    public void addBean(Bean<?> bean)
    {
       synchronized (bean)
@@ -576,15 +567,6 @@
       return Collections.unmodifiableMap(riBeans);
    }
 
-   /**
-    * Registers a context with the manager
-    * 
-    * @param context The context to add
-    * @return A reference to the manager
-    * 
-    * @see javax.enterprise.inject.spi.BeanManager#addContext(javax.enterprise.context.spi.Context)
-    */
-   @Deprecated
    public void addContext(Context context)
    {
       contexts.put(context.getScopeType(), context);

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AfterBeanDiscoveryImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AfterBeanDiscoveryImpl.java	2009-06-28 21:25:03 UTC (rev 2922)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AfterBeanDiscoveryImpl.java	2009-06-28 21:39:24 UTC (rev 2923)
@@ -1,6 +1,7 @@
 package org.jboss.webbeans.bootstrap;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import javax.enterprise.context.spi.Context;
@@ -8,10 +9,19 @@
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.ObserverMethod;
 
+import org.jboss.webbeans.BeanManagerImpl;
+
 public class AfterBeanDiscoveryImpl implements AfterBeanDiscovery
 {
-   private List<Throwable> definitionErrors = new ArrayList<Throwable>();
    
+   private final List<Throwable> definitionErrors = new ArrayList<Throwable>();
+   private final BeanManagerImpl beanManager;
+   
+   public AfterBeanDiscoveryImpl(BeanManagerImpl beanManager)
+   {
+      this.beanManager = beanManager;
+   }
+
    public void addDefinitionError(Throwable t)
    {
       definitionErrors.add(t);
@@ -19,17 +29,17 @@
    
    public List<Throwable> getDefinitionErrors()
    {
-      return definitionErrors;
+      return Collections.unmodifiableList(definitionErrors);
    }
-
+   
    public void addBean(Bean<?> bean)
    {
-      throw new UnsupportedOperationException();
+      beanManager.addBean(bean);
    }
 
    public void addContext(Context context)
    {
-      throw new UnsupportedOperationException();
+      beanManager.addContext(context);
    }
 
    public void addObserverMethod(ObserverMethod<?, ?> observerMethod)

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeforeShutdownImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeforeShutdownImpl.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeforeShutdownImpl.java	2009-06-28 21:39:24 UTC (rev 2923)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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 org.jboss.webbeans.bootstrap;
+
+import javax.enterprise.inject.spi.BeforeShutdown;
+
+/**
+ * @author pmuir
+ *
+ */
+public class BeforeShutdownImpl implements BeforeShutdown
+{
+
+}


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeforeShutdownImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/ProcessAnnotatedTypeImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/ProcessAnnotatedTypeImpl.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/ProcessAnnotatedTypeImpl.java	2009-06-28 21:39:24 UTC (rev 2923)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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 org.jboss.webbeans.bootstrap;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+
+/**
+ * @author pmuir
+ *
+ */
+public class ProcessAnnotatedTypeImpl<X> implements ProcessAnnotatedType<X>
+{
+   
+   private AnnotatedType<X> annotatedType;
+   private boolean veto;
+
+   public ProcessAnnotatedTypeImpl(AnnotatedType<X> annotatedType)
+   {
+      this.annotatedType = annotatedType;
+   }
+
+   public AnnotatedType<X> getAnnotatedType()
+   {
+      return annotatedType;
+   }
+
+   public void setAnnotatedType(AnnotatedType<X> type)
+   {
+      if (type == null)
+      {
+         throw new IllegalArgumentException("Cannot set the type to null (if you want to stop the type being used, call veto()) " + this);
+      }
+      this.annotatedType = type;
+   }
+
+   public void veto()
+   {
+      this.veto = true;
+   }
+   
+   public boolean isVeto()
+   {
+      return veto;
+   }
+
+}


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/ProcessAnnotatedTypeImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java	2009-06-28 21:25:03 UTC (rev 2922)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java	2009-06-28 21:39:24 UTC (rev 2923)
@@ -16,6 +16,7 @@
  */
 package org.jboss.webbeans.bootstrap;
 
+import javax.enterprise.inject.spi.BeforeShutdown;
 import javax.enterprise.inject.spi.Extension;
 
 import org.jboss.webbeans.BeanManagerImpl;
@@ -256,16 +257,29 @@
       }
    }
    
-   protected void fireAfterBeanDiscoveryEvent()
+   private void fireBeforeShutdownEvent()
    {
-      AfterBeanDiscoveryImpl event = new AfterBeanDiscoveryImpl();
+      BeforeShutdown event = new BeforeShutdownImpl();
       try
       {
+         getManager().fireEvent(event);
+      }
+      catch (Exception e)
+      {
+         throw new DeploymentException(e);
+      }
+   }
+   
+   private void fireAfterBeanDiscoveryEvent()
+   {
+      AfterBeanDiscoveryImpl event = new AfterBeanDiscoveryImpl(getManager());
+      try
+      {
          manager.fireEvent(event);
       }
       catch (Exception e)
       {
-         throw new DefinitionException(e);
+         event.addDefinitionError(e);
       }
       
       if (event.getDefinitionErrors().size() > 0)
@@ -275,7 +289,7 @@
       }
    }
    
-   protected void fireAfterDeploymentValidationEvent()
+   private void fireAfterDeploymentValidationEvent()
    {
       AfterDeploymentValidationImpl event = new AfterDeploymentValidationImpl();
       
@@ -285,7 +299,7 @@
       }
       catch (Exception e)
       {
-         throw new DeploymentException(e);
+         event.addDeploymentProblem(e);
       }
       
       if (event.getDeploymentProblems().size() > 0)
@@ -347,7 +361,14 @@
    
    public void shutdown()
    {
-      manager.shutdown();
+      try
+      {
+         fireBeforeShutdownEvent();
+      }
+      finally
+      {
+         manager.shutdown();
+      }
    }
 
 }




More information about the weld-commits mailing list