You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by Gurkan Erdogdu <gu...@yahoo.com> on 2009/02/27 07:48:46 UTC

Re: svn commit: r748198 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java

Hi Mark;

Is it still valid ? 

/Gurkan




________________________________
From: "struberg@apache.org" <st...@apache.org>
To: openwebbeans-commits@incubator.apache.org
Sent: Thursday, February 26, 2009 6:29:38 PM
Subject: svn commit: r748198 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java

Author: struberg
Date: Thu Feb 26 16:29:37 2009
New Revision: 748198

URL: http://svn.apache.org/viewvc?rev=748198&view=rev
Log:
OWB-82 throw IllegalArbumentException if 2 active scopes are being registered

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java?rev=748198&r1=748197&r2=748198&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java Thu Feb 26 16:29:37 2009
@@ -118,15 +118,15 @@

         List<Context> contexts = new ArrayList<Context>();
        
-        Context standartContext = null;
+        Context standardContext = null;

-        standartContext = ContextFactory.getStandardContext(scopType);
+        standardContext = ContextFactory.getStandardContext(scopType);

-        if(standartContext != null)
+        if(standardContext != null)
         {
-            if(standartContext.isActive())
+            if(standardContext.isActive())
             {
-                contexts.add(standartContext);  
+                contexts.add(standardContext);  
             }
         }
        
@@ -422,6 +422,10 @@
         }
         else
         {
+            if (context.isActive() && containsActiveContext(contextList))
+            {
+                throw new IllegalArgumentException("There is already an active Context registered for this scope! Context=" + context);
+            }
             contextList.add(context);
         }

@@ -445,4 +449,20 @@
         return this;
     }

+    /**
+     * Check if the given contextList contains an active Context
+     * @param contextList
+     * @return <code>true</code> if the given contextList contains an active Context, <code>false</code> otherwise
+     */
+    private boolean containsActiveContext(List<Context> contextList)
+    {
+        for (Context c : contextList)
+        {
+            if (c.isActive())
+            {
+                return true;
+            }
+        }
+        return false;
+    }
}
\ No newline at end of file


      

Re: svn commit: r748198 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java

Posted by Mark Struberg <st...@yahoo.de>.
I'd say in both cases an IllegalStateException should be thrown - but let's see what Pete did in the TCK and the latest Spec.

At least both functions should throw the same Exception for the same problem ;)

LieGrue,
strub


--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Fr, 27.2.2009:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: svn commit: r748198 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> An: openwebbeans-dev@incubator.apache.org
> Datum: Freitag, 27. Februar 2009, 12:21
> You mean, in both cases will we throw
> "IllegalStateException"? Or for third party
> contexts, will we throw
> "IllegalArgumentException"?
> 
> Thanks;
> 
> /Gurkan
> 
> 
> 
> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: openwebbeans-dev@incubator.apache.org
> Sent: Friday, February 27, 2009 10:41:19 AM
> Subject: Re: svn commit: r748198 -
> /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> 
> I had a discussion with Pete over at the jsr299 list about
> this yesterday:
> 
> http://markmail.org/message/3ecfzddplb4shf4i
> 
> Pete now will throw an IllegalStateException in both cases.
> Have to pull in the latest TCK today and change our
> behaviour.
> 
> In praxis this will not do much for our _current_ standard
> contexts, because imho this cannot happen for them.
> But it may happen for 3rd party contexts, so we imho have
> to implement the check. WDYT?
> 
> LieGrue,
> strub
> 
> 
> 
> --- Gurkan Erdogdu <gu...@yahoo.com> schrieb
> am Fr, 27.2.2009:
> 
> > Von: Gurkan Erdogdu <gu...@yahoo.com>
> > Betreff: Re: svn commit: r748198 -
> /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> > An: openwebbeans-dev@incubator.apache.org
> > Datum: Freitag, 27. Februar 2009, 7:48
> > Hi Mark;
> > 
> > Is it still valid ? 
> > 
> > /Gurkan
> > 
> > 
> > 
> > 
> > ________________________________
> > From: "struberg@apache.org"
> > <st...@apache.org>
> > To: openwebbeans-commits@incubator.apache.org
> > Sent: Thursday, February 26, 2009 6:29:38 PM
> > Subject: svn commit: r748198 -
> >
> /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> > 
> > Author: struberg
> > Date: Thu Feb 26 16:29:37 2009
> > New Revision: 748198
> > 
> > URL:
> http://svn.apache.org/viewvc?rev=748198&view=rev
> > Log:
> > OWB-82 throw IllegalArbumentException if 2 active
> scopes
> > are being registered
> > 
> > Modified:
> >    
> >
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> > 
> > Modified:
> >
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java?rev=748198&r1=748197&r2=748198&view=diff
> >
> ==============================================================================
> > ---
> >
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> > (original)
> > +++
> >
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> > Thu Feb 26 16:29:37 2009
> > @@ -118,15 +118,15 @@
> > 
> >          List<Context> contexts = new
> > ArrayList<Context>();
> >        
> > -        Context standartContext = null;
> > +        Context standardContext = null;
> > 
> > -        standartContext =
> > ContextFactory.getStandardContext(scopType);
> > +        standardContext =
> > ContextFactory.getStandardContext(scopType);
> > 
> > -        if(standartContext != null)
> > +        if(standardContext != null)
> >          {
> > -            if(standartContext.isActive())
> > +            if(standardContext.isActive())
> >              {
> > -                contexts.add(standartContext);  
> > +                contexts.add(standardContext);  
> >              }
> >          }
> >        
> > @@ -422,6 +422,10 @@
> >          }
> >          else
> >          {
> > +            if (context.isActive() &&
> > containsActiveContext(contextList))
> > +            {
> > +                throw new
> > IllegalArgumentException("There is already an
> active
> > Context registered for this scope! Context=" +
> > context);
> > +            }
> >              contextList.add(context);
> >          }
> > 
> > @@ -445,4 +449,20 @@
> >          return this;
> >      }
> > 
> > +    /**
> > +     * Check if the given contextList contains an
> active
> > Context
> > +     * @param contextList
> > +     * @return <code>true</code> if the
> given
> > contextList contains an active Context,
> > <code>false</code> otherwise
> > +     */
> > +    private boolean
> > containsActiveContext(List<Context> contextList)
> > +    {
> > +        for (Context c : contextList)
> > +        {
> > +            if (c.isActive())
> > +            {
> > +                return true;
> > +            }
> > +        }
> > +        return false;
> > +    }
> > }
> > \ No newline at end of file


      

Re: svn commit: r748198 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java

Posted by Gurkan Erdogdu <gu...@yahoo.com>.

You mean, in both cases will we throw "IllegalStateException"? Or for third party contexts, will we throw "IllegalArgumentException"?

Thanks;

/Gurkan



________________________________
From: Mark Struberg <st...@yahoo.de>
To: openwebbeans-dev@incubator.apache.org
Sent: Friday, February 27, 2009 10:41:19 AM
Subject: Re: svn commit: r748198 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java

I had a discussion with Pete over at the jsr299 list about this yesterday:

http://markmail.org/message/3ecfzddplb4shf4i

Pete now will throw an IllegalStateException in both cases. Have to pull in the latest TCK today and change our behaviour.

In praxis this will not do much for our _current_ standard contexts, because imho this cannot happen for them.
But it may happen for 3rd party contexts, so we imho have to implement the check. WDYT?

LieGrue,
strub



--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Fr, 27.2.2009:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: svn commit: r748198 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> An: openwebbeans-dev@incubator.apache.org
> Datum: Freitag, 27. Februar 2009, 7:48
> Hi Mark;
> 
> Is it still valid ? 
> 
> /Gurkan
> 
> 
> 
> 
> ________________________________
> From: "struberg@apache.org"
> <st...@apache.org>
> To: openwebbeans-commits@incubator.apache.org
> Sent: Thursday, February 26, 2009 6:29:38 PM
> Subject: svn commit: r748198 -
> /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> 
> Author: struberg
> Date: Thu Feb 26 16:29:37 2009
> New Revision: 748198
> 
> URL: http://svn.apache.org/viewvc?rev=748198&view=rev
> Log:
> OWB-82 throw IllegalArbumentException if 2 active scopes
> are being registered
> 
> Modified:
>    
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> 
> Modified:
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> URL:
> http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java?rev=748198&r1=748197&r2=748198&view=diff
> ==============================================================================
> ---
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> (original)
> +++
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> Thu Feb 26 16:29:37 2009
> @@ -118,15 +118,15 @@
> 
>          List<Context> contexts = new
> ArrayList<Context>();
>        
> -        Context standartContext = null;
> +        Context standardContext = null;
> 
> -        standartContext =
> ContextFactory.getStandardContext(scopType);
> +        standardContext =
> ContextFactory.getStandardContext(scopType);
> 
> -        if(standartContext != null)
> +        if(standardContext != null)
>          {
> -            if(standartContext.isActive())
> +            if(standardContext.isActive())
>              {
> -                contexts.add(standartContext);  
> +                contexts.add(standardContext);  
>              }
>          }
>        
> @@ -422,6 +422,10 @@
>          }
>          else
>          {
> +            if (context.isActive() &&
> containsActiveContext(contextList))
> +            {
> +                throw new
> IllegalArgumentException("There is already an active
> Context registered for this scope! Context=" +
> context);
> +            }
>              contextList.add(context);
>          }
> 
> @@ -445,4 +449,20 @@
>          return this;
>      }
> 
> +    /**
> +     * Check if the given contextList contains an active
> Context
> +     * @param contextList
> +     * @return <code>true</code> if the given
> contextList contains an active Context,
> <code>false</code> otherwise
> +     */
> +    private boolean
> containsActiveContext(List<Context> contextList)
> +    {
> +        for (Context c : contextList)
> +        {
> +            if (c.isActive())
> +            {
> +                return true;
> +            }
> +        }
> +        return false;
> +    }
> }
> \ No newline at end of file


      

Re: svn commit: r748198 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java

Posted by Mark Struberg <st...@yahoo.de>.
I had a discussion with Pete over at the jsr299 list about this yesterday:

http://markmail.org/message/3ecfzddplb4shf4i

Pete now will throw an IllegalStateException in both cases. Have to pull in the latest TCK today and change our behaviour.

In praxis this will not do much for our _current_ standard contexts, because imho this cannot happen for them.
But it may happen for 3rd party contexts, so we imho have to implement the check. WDYT?

LieGrue,
strub



--- Gurkan Erdogdu <gu...@yahoo.com> schrieb am Fr, 27.2.2009:

> Von: Gurkan Erdogdu <gu...@yahoo.com>
> Betreff: Re: svn commit: r748198 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> An: openwebbeans-dev@incubator.apache.org
> Datum: Freitag, 27. Februar 2009, 7:48
> Hi Mark;
> 
> Is it still valid ? 
> 
> /Gurkan
> 
> 
> 
> 
> ________________________________
> From: "struberg@apache.org"
> <st...@apache.org>
> To: openwebbeans-commits@incubator.apache.org
> Sent: Thursday, February 26, 2009 6:29:38 PM
> Subject: svn commit: r748198 -
> /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> 
> Author: struberg
> Date: Thu Feb 26 16:29:37 2009
> New Revision: 748198
> 
> URL: http://svn.apache.org/viewvc?rev=748198&view=rev
> Log:
> OWB-82 throw IllegalArbumentException if 2 active scopes
> are being registered
> 
> Modified:
>    
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> 
> Modified:
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> URL:
> http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java?rev=748198&r1=748197&r2=748198&view=diff
> ==============================================================================
> ---
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> (original)
> +++
> incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
> Thu Feb 26 16:29:37 2009
> @@ -118,15 +118,15 @@
> 
>          List<Context> contexts = new
> ArrayList<Context>();
>         
> -        Context standartContext = null;
> +        Context standardContext = null;
> 
> -        standartContext =
> ContextFactory.getStandardContext(scopType);
> +        standardContext =
> ContextFactory.getStandardContext(scopType);
> 
> -        if(standartContext != null)
> +        if(standardContext != null)
>          {
> -            if(standartContext.isActive())
> +            if(standardContext.isActive())
>              {
> -                contexts.add(standartContext);  
> +                contexts.add(standardContext);  
>              }
>          }
>         
> @@ -422,6 +422,10 @@
>          }
>          else
>          {
> +            if (context.isActive() &&
> containsActiveContext(contextList))
> +            {
> +                throw new
> IllegalArgumentException("There is already an active
> Context registered for this scope! Context=" +
> context);
> +            }
>              contextList.add(context);
>          }
> 
> @@ -445,4 +449,20 @@
>          return this;
>      }
> 
> +    /**
> +     * Check if the given contextList contains an active
> Context
> +     * @param contextList
> +     * @return <code>true</code> if the given
> contextList contains an active Context,
> <code>false</code> otherwise
> +     */
> +    private boolean
> containsActiveContext(List<Context> contextList)
> +    {
> +        for (Context c : contextList)
> +        {
> +            if (c.isActive())
> +            {
> +                return true;
> +            }
> +        }
> +        return false;
> +    }
> }
> \ No newline at end of file