Return-Path: Delivered-To: apmail-incubator-openwebbeans-commits-archive@locus.apache.org Received: (qmail 28052 invoked from network); 8 Jan 2009 19:42:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Jan 2009 19:42:07 -0000 Received: (qmail 9685 invoked by uid 500); 8 Jan 2009 19:42:07 -0000 Delivered-To: apmail-incubator-openwebbeans-commits-archive@incubator.apache.org Received: (qmail 9669 invoked by uid 500); 8 Jan 2009 19:42:07 -0000 Mailing-List: contact openwebbeans-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: openwebbeans-dev@incubator.apache.org Delivered-To: mailing list openwebbeans-commits@incubator.apache.org Received: (qmail 9658 invoked by uid 99); 8 Jan 2009 19:42:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jan 2009 11:42:06 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jan 2009 19:42:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C012B2388AFE; Thu, 8 Jan 2009 11:41:38 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r732803 [4/17] - in /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: ./ annotation/ component/ component/ejb/ component/jms/ component/xml/ config/ container/ context/ context/type/ decorator/ decorator/xml/ de... Date: Thu, 08 Jan 2009 19:41:33 -0000 To: openwebbeans-commits@incubator.apache.org From: gerdogdu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090108194138.C012B2388AFE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansScanner.java URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansScanner.java?rev=732803&r1=732802&r2=732803&view=diff ============================================================================== --- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansScanner.java (original) +++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansScanner.java Thu Jan 8 11:41:30 2009 @@ -1,18 +1,15 @@ /* - * 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. + * 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 org.apache.webbeans.config; @@ -33,209 +30,205 @@ import org.scannotation.ClasspathUrlFinder; import org.scannotation.WarUrlFinder; - /** * Configures the Web Beans Container at the enterprise application - * deployment time. - * + * deployment time. *

- * See the web beans specification section-10 for further details of how to configure - * web beans container. + * See the web beans specification section-10 for further details of how to + * configure web beans container. *

+ * * @author Gurkan Erdogdu * @since 1.0 */ public final class WebBeansScanner -{ - private WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansScanner.class); - - /**Location of the web-beans.xml files.*/ - private Map WEBBEANS_XML_LOCATIONS = new HashMap(); - - /**Location of the ejb-jar.xml files*/ - private Map EJB_XML_LOCATIONS = new HashMap(); - - /**Annotation Database*/ - private AnnotationDB ANNOTATION_DB = null; - - /**It is configured or not*/ - private boolean configure = false; - - private ServletContext servletContext = null; - - public WebBeansScanner() - { - - } - - /** - * Configure the Web Beans Container with deployment information and fills - * annotation database and web-beans.xml stream database. - * - * @throws WebBeansConfigurationException if any run time exception occurs - */ - public void scan(ServletContext servletContext) throws WebBeansConfigurationException - { - if(!configure) - { - this.servletContext = servletContext; - - configureAnnotationDB(); - configure = true; - - } - - } - - /*Configures annotation database*/ - private void configureAnnotationDB() throws WebBeansConfigurationException - { - try - { - Set arcs = getArchieves(); - URL[] urls = new URL[arcs.size()]; - arcs.toArray(urls); - - if(ANNOTATION_DB == null) - { - ANNOTATION_DB = new AnnotationDB(); - - ANNOTATION_DB.setScanClassAnnotations(true); - ANNOTATION_DB.scanArchives(urls); - ANNOTATION_DB.crossReferenceMetaAnnotations(); - - } - - }catch(Throwable e) - { - logger.error("Initializing of the WebBeans container is failed.", e); - throw new WebBeansConfigurationException(e); - } - - } - - /*Collects all URLs*/ - private Set getArchieves() throws Throwable - { - Set lists = createURLFromMarkerFile(); - URL warUrl = createURLFromWARFile(); - - if(warUrl != null) - { - lists.add(warUrl); - } - - return lists; - } - - /*Creates URLs from the marker file*/ - private Set createURLFromMarkerFile() throws Throwable - { - Set listURL = new HashSet(); - URL[] urls = null; - - //Root with web-beans.xml marker. - urls = ClasspathUrlFinder.findResourceBases("META-INF/web-beans.xml", WebBeansUtil.getCurrentClassLoader()); - - if(urls != null) - { - for(URL url : urls) - { - - URL addPath = null; - - String fileDir = url.getFile(); - if(fileDir.endsWith(".jar!/")) - { - fileDir = fileDir.substring(0, fileDir.lastIndexOf("/")) + "/META-INF/web-beans.xml"; - addPath = new URL("jar:" + fileDir); - } - else - { - addPath = new URL("file:" + url.getFile() + "META-INF/web-beans.xml"); - } - - listURL.add(url); - WEBBEANS_XML_LOCATIONS.put(addPath.getFile(), addPath.openStream()); - } - } - - //Scan for ejb-jar.xml - URL[] ejbUrls = ClasspathUrlFinder.findResourceBases("META-INF/ejb-jar.xml",WebBeansUtil.getCurrentClassLoader()); - - if(ejbUrls != null && ejbUrls.length > 0) - { - for(URL ejbUrl : ejbUrls) - { - //ok, web-beans.xml and ejb-jar.xml is in the same root - if(listURL.contains(ejbUrl)) - { - URL addPath = null; - - String fileDir = ejbUrl.getFile(); - - if(fileDir.endsWith(".jar!/")) - { - fileDir = fileDir.substring(0, fileDir.lastIndexOf("/")) + "/META-INF/ejb-jar.xml"; - addPath = new URL("jar:" + fileDir); - } - else - { - addPath = new URL("file:" + ejbUrl.getFile() + "META-INF/ejb-jar.xml"); - } - - EJB_XML_LOCATIONS.put(addPath.getFile(),addPath.openStream()); - } - } - } - - - return listURL; - } - - private URL createURLFromWARFile() throws Throwable - { - URL url = this.servletContext.getResource("/WEB-INF/web-beans.xml"); - - if(url != null) - { - WEBBEANS_XML_LOCATIONS.put(url.getFile(), url.openStream()); - - return WarUrlFinder.findWebInfClassesPath(this.servletContext); - } - - return null; - } - - /** - * Gets list of stream that points to the web-beans.xml file in - * the specific locations. - * - * @return list of stream - */ - public Map getWEBBEANS_XML_LOCATIONS() - { - return WEBBEANS_XML_LOCATIONS; - } - - /** - * Gets list of stream that points to the ejb-jar.xml file in - * the specific locations. - * - * @return list of stream - */ - public Map getEJB_XML_LOCATIONS() - { - return EJB_XML_LOCATIONS; - } - - - /** - * Gets annotated classes. - * @return annotation database - */ - public AnnotationDB getANNOTATION_DB() - { - return ANNOTATION_DB; - } +{ + private WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansScanner.class); + + /** Location of the web-beans.xml files. */ + private Map WEBBEANS_XML_LOCATIONS = new HashMap(); + + /** Location of the ejb-jar.xml files */ + private Map EJB_XML_LOCATIONS = new HashMap(); + + /** Annotation Database */ + private AnnotationDB ANNOTATION_DB = null; + + /** It is configured or not */ + private boolean configure = false; + + private ServletContext servletContext = null; + + public WebBeansScanner() + { + + } + + /** + * Configure the Web Beans Container with deployment information and fills + * annotation database and web-beans.xml stream database. + * + * @throws WebBeansConfigurationException if any run time exception occurs + */ + public void scan(ServletContext servletContext) throws WebBeansConfigurationException + { + if (!configure) + { + this.servletContext = servletContext; + + configureAnnotationDB(); + configure = true; + + } + + } + + /* Configures annotation database */ + private void configureAnnotationDB() throws WebBeansConfigurationException + { + try + { + Set arcs = getArchieves(); + URL[] urls = new URL[arcs.size()]; + arcs.toArray(urls); + + if (ANNOTATION_DB == null) + { + ANNOTATION_DB = new AnnotationDB(); + + ANNOTATION_DB.setScanClassAnnotations(true); + ANNOTATION_DB.scanArchives(urls); + ANNOTATION_DB.crossReferenceMetaAnnotations(); + + } + + } catch (Throwable e) + { + logger.error("Initializing of the WebBeans container is failed.", e); + throw new WebBeansConfigurationException(e); + } + + } + + /* Collects all URLs */ + private Set getArchieves() throws Throwable + { + Set lists = createURLFromMarkerFile(); + URL warUrl = createURLFromWARFile(); + + if (warUrl != null) + { + lists.add(warUrl); + } + + return lists; + } + + /* Creates URLs from the marker file */ + private Set createURLFromMarkerFile() throws Throwable + { + Set listURL = new HashSet(); + URL[] urls = null; + + // Root with web-beans.xml marker. + urls = ClasspathUrlFinder.findResourceBases("META-INF/web-beans.xml", WebBeansUtil.getCurrentClassLoader()); + + if (urls != null) + { + for (URL url : urls) + { + + URL addPath = null; + + String fileDir = url.getFile(); + if (fileDir.endsWith(".jar!/")) + { + fileDir = fileDir.substring(0, fileDir.lastIndexOf("/")) + "/META-INF/web-beans.xml"; + addPath = new URL("jar:" + fileDir); + } else + { + addPath = new URL("file:" + url.getFile() + "META-INF/web-beans.xml"); + } + + listURL.add(url); + WEBBEANS_XML_LOCATIONS.put(addPath.getFile(), addPath.openStream()); + } + } + + // Scan for ejb-jar.xml + URL[] ejbUrls = ClasspathUrlFinder.findResourceBases("META-INF/ejb-jar.xml", WebBeansUtil.getCurrentClassLoader()); + + if (ejbUrls != null && ejbUrls.length > 0) + { + for (URL ejbUrl : ejbUrls) + { + // ok, web-beans.xml and ejb-jar.xml is in the same root + if (listURL.contains(ejbUrl)) + { + URL addPath = null; + + String fileDir = ejbUrl.getFile(); + + if (fileDir.endsWith(".jar!/")) + { + fileDir = fileDir.substring(0, fileDir.lastIndexOf("/")) + "/META-INF/ejb-jar.xml"; + addPath = new URL("jar:" + fileDir); + } else + { + addPath = new URL("file:" + ejbUrl.getFile() + "META-INF/ejb-jar.xml"); + } + + EJB_XML_LOCATIONS.put(addPath.getFile(), addPath.openStream()); + } + } + } + + return listURL; + } + + private URL createURLFromWARFile() throws Throwable + { + URL url = this.servletContext.getResource("/WEB-INF/web-beans.xml"); + + if (url != null) + { + WEBBEANS_XML_LOCATIONS.put(url.getFile(), url.openStream()); + + return WarUrlFinder.findWebInfClassesPath(this.servletContext); + } + + return null; + } + + /** + * Gets list of stream that points to the web-beans.xml file in the specific + * locations. + * + * @return list of stream + */ + public Map getWEBBEANS_XML_LOCATIONS() + { + return WEBBEANS_XML_LOCATIONS; + } + + /** + * Gets list of stream that points to the ejb-jar.xml file in the specific + * locations. + * + * @return list of stream + */ + public Map getEJB_XML_LOCATIONS() + { + return EJB_XML_LOCATIONS; + } + + /** + * Gets annotated classes. + * + * @return annotation database + */ + public AnnotationDB getANNOTATION_DB() + { + return ANNOTATION_DB; + } } Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=732803&r1=732802&r2=732803&view=diff ============================================================================== --- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java (original) +++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java Thu Jan 8 11:41:30 2009 @@ -34,251 +34,251 @@ @SuppressWarnings("unchecked") public class InjectionResolver { - public InjectionResolver() - { + public InjectionResolver() + { - } + } - public static InjectionResolver getInstance() - { - InjectionResolver instance = (InjectionResolver) WebBeansFinder.getSingletonInstance(WebBeansFinder.SINGLETON_INJECTION_RESOLVER); - return instance; - } - - public Set> implResolveByName(String name) - { - Asserts.assertNotNull(name, "name parameter can not be null"); - - ManagerImpl manager = ManagerImpl.getManager(); - - Set> resolvedComponents = new HashSet>(); - Bean resolvedComponent = null; - Set> deployedComponents = manager.getBeans(); - - Iterator> it = deployedComponents.iterator(); - while (it.hasNext()) - { - Bean component = it.next(); - - if (component.getName() != null) - { - if (component.getName().equals(name)) - { - if (resolvedComponent == null) - { - resolvedComponent = component; - resolvedComponents.add(resolvedComponent); - } else - { - if (DeploymentTypeManager.getInstance().comparePrecedences(component.getDeploymentType(), resolvedComponent.getDeploymentType()) > 0) - { - resolvedComponents.clear(); - resolvedComponent = component; - resolvedComponents.add(resolvedComponent); - } else if (DeploymentTypeManager.getInstance().comparePrecedences(component.getDeploymentType(), resolvedComponent.getDeploymentType()) == 0) - { - resolvedComponents.add(component); - } - } - } - } - } - - return resolvedComponents; - } - - public Set> implResolveByType(Class apiType, Type[] actualTypeArguments, Annotation... binding) - { - Asserts.assertNotNull(apiType, "apiType parameter can not be null"); - Asserts.assertNotNull(binding, "binding parameter can not be null"); - - ManagerImpl manager = ManagerImpl.getManager(); - - boolean currentBinding = false; - boolean returnAll = false; - - if (binding.length == 0) - { - binding = new Annotation[1]; - binding[0] = new CurrentLiteral(); - currentBinding = true; - } - - Set> results = new HashSet>(); - Set> deployedComponents = manager.getBeans(); - - if (apiType.equals(Object.class) && currentBinding) - { - returnAll = true; - } - - Iterator> it = deployedComponents.iterator(); - - while (it.hasNext()) - { - Bean component = it.next(); - - if (returnAll) - { - results.add((Bean) component); - continue; - } - - else - { - Set> componentApiTypes = component.getTypes(); - Iterator> itComponentApiTypes = componentApiTypes.iterator(); - while (itComponentApiTypes.hasNext()) - { - Class componentApiType = itComponentApiTypes.next(); - - if (actualTypeArguments.length > 0) - { - Type[] actualArgs = null; - if (ClassUtil.isAssignable(apiType, componentApiType)) - { - /* - * Annotated Producer method or XML Defined Producer - * Method - */ - if (ProducerComponentImpl.class.isAssignableFrom(component.getClass())) - { - actualArgs = ((ProducerComponentImpl) component).getActualTypeArguments(); - if (Arrays.equals(actualArgs, actualTypeArguments)) - { - results.add((Bean) component); - break; - } - - } - - else - { - actualArgs = ClassUtil.getGenericSuperClassTypeArguments(componentApiType); - if (Arrays.equals(actualArgs, actualTypeArguments)) - { - results.add((Bean) component); - break; - } else - { - List listActualArgs = ClassUtil.getGenericSuperInterfacesTypeArguments(componentApiType); - Iterator itListActualArgs = listActualArgs.iterator(); - while (itListActualArgs.hasNext()) - { - actualArgs = itListActualArgs.next(); - - if (Arrays.equals(actualArgs, actualTypeArguments)) - { - results.add((Bean) component); - break; - } - - } - } - - } - - } - } else - { - if (apiType instanceof Class) - { - if (ClassUtil.isAssignable((Class) apiType, componentApiType)) - { - results.add((Bean) component); - break; - } - } - } - } - } - } - - results = findByBindingType(results, binding); - - if (results != null && !results.isEmpty()) - { - results = findByPrecedence(results); - } - - return results; - } - - private Set> findByPrecedence(Set> result) - { - Bean resolvedComponent = null; - Iterator> it = result.iterator(); - Set> res = new HashSet>(); - - while (it.hasNext()) - { - Bean component = it.next(); - - if (resolvedComponent == null) - { - resolvedComponent = component; - res.add(resolvedComponent); - } else - { - DeploymentTypeManager typeManager = DeploymentTypeManager.getInstance(); - - if (typeManager.comparePrecedences(component.getDeploymentType(), resolvedComponent.getDeploymentType()) < 0) - { - continue; - } else if (typeManager.comparePrecedences(component.getDeploymentType(), resolvedComponent.getDeploymentType()) > 0) - { - res.clear(); - resolvedComponent = component; - res.add(resolvedComponent); - - } else - { - res.add(component); - } - } - } - - return res; - } - - private Set> findByBindingType(Set> remainingSet, Annotation... annotations) - { - Iterator> it = remainingSet.iterator(); - Set> result = new HashSet>(); - - while (it.hasNext()) - { - Bean component = it.next(); - Set bTypes = component.getBindingTypes(); - - int i = 0; - for (Annotation annot : annotations) - { - Iterator itBindingTypes = bTypes.iterator(); - while (itBindingTypes.hasNext()) - { - Annotation bindingType = itBindingTypes.next(); - if (annot.annotationType().equals(bindingType.annotationType())) - { - if (AnnotationUtil.isAnnotationMemberExist(bindingType.annotationType(), bindingType, annot)) - { - i++; - } - } - - } - } - - if (i == annotations.length) - { - result.add(component); - i = 0; - } + public static InjectionResolver getInstance() + { + InjectionResolver instance = (InjectionResolver) WebBeansFinder.getSingletonInstance(WebBeansFinder.SINGLETON_INJECTION_RESOLVER); + return instance; + } + + public Set> implResolveByName(String name) + { + Asserts.assertNotNull(name, "name parameter can not be null"); + + ManagerImpl manager = ManagerImpl.getManager(); + + Set> resolvedComponents = new HashSet>(); + Bean resolvedComponent = null; + Set> deployedComponents = manager.getBeans(); + + Iterator> it = deployedComponents.iterator(); + while (it.hasNext()) + { + Bean component = it.next(); + + if (component.getName() != null) + { + if (component.getName().equals(name)) + { + if (resolvedComponent == null) + { + resolvedComponent = component; + resolvedComponents.add(resolvedComponent); + } else + { + if (DeploymentTypeManager.getInstance().comparePrecedences(component.getDeploymentType(), resolvedComponent.getDeploymentType()) > 0) + { + resolvedComponents.clear(); + resolvedComponent = component; + resolvedComponents.add(resolvedComponent); + } else if (DeploymentTypeManager.getInstance().comparePrecedences(component.getDeploymentType(), resolvedComponent.getDeploymentType()) == 0) + { + resolvedComponents.add(component); + } + } + } + } + } + + return resolvedComponents; + } + + public Set> implResolveByType(Class apiType, Type[] actualTypeArguments, Annotation... binding) + { + Asserts.assertNotNull(apiType, "apiType parameter can not be null"); + Asserts.assertNotNull(binding, "binding parameter can not be null"); + + ManagerImpl manager = ManagerImpl.getManager(); + + boolean currentBinding = false; + boolean returnAll = false; + + if (binding.length == 0) + { + binding = new Annotation[1]; + binding[0] = new CurrentLiteral(); + currentBinding = true; + } + + Set> results = new HashSet>(); + Set> deployedComponents = manager.getBeans(); + + if (apiType.equals(Object.class) && currentBinding) + { + returnAll = true; + } + + Iterator> it = deployedComponents.iterator(); + + while (it.hasNext()) + { + Bean component = it.next(); + + if (returnAll) + { + results.add((Bean) component); + continue; + } + + else + { + Set> componentApiTypes = component.getTypes(); + Iterator> itComponentApiTypes = componentApiTypes.iterator(); + while (itComponentApiTypes.hasNext()) + { + Class componentApiType = itComponentApiTypes.next(); + + if (actualTypeArguments.length > 0) + { + Type[] actualArgs = null; + if (ClassUtil.isAssignable(apiType, componentApiType)) + { + /* + * Annotated Producer method or XML Defined Producer + * Method + */ + if (ProducerComponentImpl.class.isAssignableFrom(component.getClass())) + { + actualArgs = ((ProducerComponentImpl) component).getActualTypeArguments(); + if (Arrays.equals(actualArgs, actualTypeArguments)) + { + results.add((Bean) component); + break; + } + + } + + else + { + actualArgs = ClassUtil.getGenericSuperClassTypeArguments(componentApiType); + if (Arrays.equals(actualArgs, actualTypeArguments)) + { + results.add((Bean) component); + break; + } else + { + List listActualArgs = ClassUtil.getGenericSuperInterfacesTypeArguments(componentApiType); + Iterator itListActualArgs = listActualArgs.iterator(); + while (itListActualArgs.hasNext()) + { + actualArgs = itListActualArgs.next(); + + if (Arrays.equals(actualArgs, actualTypeArguments)) + { + results.add((Bean) component); + break; + } + + } + } + + } + + } + } else + { + if (apiType instanceof Class) + { + if (ClassUtil.isAssignable((Class) apiType, componentApiType)) + { + results.add((Bean) component); + break; + } + } + } + } + } + } + + results = findByBindingType(results, binding); + + if (results != null && !results.isEmpty()) + { + results = findByPrecedence(results); + } + + return results; + } + + private Set> findByPrecedence(Set> result) + { + Bean resolvedComponent = null; + Iterator> it = result.iterator(); + Set> res = new HashSet>(); + + while (it.hasNext()) + { + Bean component = it.next(); + + if (resolvedComponent == null) + { + resolvedComponent = component; + res.add(resolvedComponent); + } else + { + DeploymentTypeManager typeManager = DeploymentTypeManager.getInstance(); + + if (typeManager.comparePrecedences(component.getDeploymentType(), resolvedComponent.getDeploymentType()) < 0) + { + continue; + } else if (typeManager.comparePrecedences(component.getDeploymentType(), resolvedComponent.getDeploymentType()) > 0) + { + res.clear(); + resolvedComponent = component; + res.add(resolvedComponent); + + } else + { + res.add(component); + } + } + } + + return res; + } + + private Set> findByBindingType(Set> remainingSet, Annotation... annotations) + { + Iterator> it = remainingSet.iterator(); + Set> result = new HashSet>(); + + while (it.hasNext()) + { + Bean component = it.next(); + Set bTypes = component.getBindingTypes(); + + int i = 0; + for (Annotation annot : annotations) + { + Iterator itBindingTypes = bTypes.iterator(); + while (itBindingTypes.hasNext()) + { + Annotation bindingType = itBindingTypes.next(); + if (annot.annotationType().equals(bindingType.annotationType())) + { + if (AnnotationUtil.isAnnotationMemberExist(bindingType.annotationType(), bindingType, annot)) + { + i++; + } + } + + } + } + + if (i == annotations.length) + { + result.add(component); + i = 0; + } - } + } - remainingSet = null; + remainingSet = null; - return result; - } + return result; + } } \ No newline at end of file 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=732803&r1=732802&r2=732803&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 Jan 8 11:41:30 2009 @@ -1,18 +1,15 @@ /* - * 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. + * 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 org.apache.webbeans.container; @@ -62,320 +59,317 @@ import org.apache.webbeans.util.ClassUtil; import org.apache.webbeans.util.WebBeansUtil; - /** * Implementation of the {@link WebBeansManager} contract of the web beans * container. * * @author Gurkan Erdogdu * @since 1.0 - * * @see java.webbeans.WebBeansManager */ @SuppressWarnings("unchecked") public class ManagerImpl implements Manager, Referenceable { - private Map, Context> contextMap = new ConcurrentHashMap, Context>(); - - private Set> components = new CopyOnWriteArraySet>(); - - private Set webBeansInterceptors = new CopyOnWriteArraySet(); - - private Set webBeansDecorators = new CopyOnWriteArraySet(); - - private NotificationManager notificationManager = null; - - private InjectionResolver injectionResolver = null; - - private Map, Object> proxyMap = Collections.synchronizedMap(new IdentityHashMap, Object>()); - - public ManagerImpl() - { - injectionResolver = InjectionResolver.getInstance(); - notificationManager = NotificationManager.getInstance(); - } - - public static ManagerImpl getManager() - { - ManagerImpl instance = (ManagerImpl) WebBeansFinder.getSingletonInstance(WebBeansFinder.SINGLETON_MANAGER); - - return instance; - } - - public Context getContext(Class scopType) - { - Asserts.assertNotNull(scopType, "scopeType paramter can not be null"); - - Context ctx = null; - - ctx = ContextFactory.getStandartContext(scopType); - - if(ctx == null) - { - ctx = getManager().contextMap.get(scopType); - } - - //Still null - if(ctx == null) - { - throw new ContextNotActiveException("WebBeans context with scope type annotation @" + scopType.getSimpleName() + " is not exist within current thread"); - } - - return ctx; - } - - public Manager addBean(Bean component) - { - getManager().components.add(component); - - return this; - } - - public Manager addContext(Context context) - { - addContext(context.getScopeType(), context); - - return this; - - } - - public void fireEvent(Object event, Annotation... bindings) - { - if(ClassUtil.isParametrized(event.getClass())) - { - throw new WebBeansConfigurationException("Event class : " + event.getClass().getName() + " can not be defined as generic type"); - } - - this.notificationManager.fireEvent(event, bindings); - } - - public Object getInstanceByName(String name) - { - AbstractComponent component = null; - Object object = null; - - Set> set = this.injectionResolver.implResolveByName(name); - if(set.isEmpty()) - { - return null; - } - - if(set.size() > 1) - { - throw new AmbiguousDependencyException("There are more than one WebBeans with name : " + name); - } - - component = (AbstractComponent) set.iterator().next(); - - object = getInstance(component); - - return object; - } - - public T getInstanceByType(Class type, Annotation... bindingTypes) - { - ResolutionUtil.getInstanceByTypeConditions(bindingTypes); - Set> set = resolveByType(type, bindingTypes); - - ResolutionUtil.checkResolvedBeans(set, type); - - return getInstance(set.iterator().next()); - } - - public T getInstanceByType(TypeLiteral type, Annotation... bindingTypes) - { - ResolutionUtil.getInstanceByTypeConditions(bindingTypes); - Set> set = resolveByType(type, bindingTypes); - - ResolutionUtil.checkResolvedBeans(set, type.getRawType()); - - return getInstance(set.iterator().next()); - } - - public Set> resolveByName(String name) - { - return this.injectionResolver.implResolveByName(name); - } - - public Set> resolveByType(Class apiType, Annotation... bindingTypes) - { - return this.injectionResolver.implResolveByType(apiType, new Type[0], bindingTypes); - } - - public Set> resolveByType(TypeLiteral apiType, Annotation... bindingTypes) - { - ParameterizedType ptype = (ParameterizedType)apiType.getType(); - ResolutionUtil.resolveByTypeConditions(ptype); - - Type[] args = ptype.getActualTypeArguments(); - return this.injectionResolver.implResolveByType(apiType.getRawType(),args , bindingTypes); - } - - public Set> resolveObservers(T event, Annotation... bindings) - { - return this.notificationManager.resolveObservers(event, bindings); - } - - public Set> getComponents() - { - return getManager().components; - } - - public Manager addDecorator(Decorator decorator) - { - getManager().webBeansDecorators.add(decorator); - return this; - } - - public Manager addInterceptor(Interceptor interceptor) - { - getManager().webBeansInterceptors.add(interceptor); - return this; - } - - public Manager addObserver(Observer observer, Class eventType, Annotation... bindings) - { - this.notificationManager.addObserver(observer, eventType, bindings); - return this; - } - - public Manager addObserver(Observer observer, TypeLiteral eventType, Annotation... bindings) - { - this.notificationManager.addObserver(observer, eventType, bindings); - return this; - } - - public T getInstance(Bean bean) - { - Context context = null; - DependentContext dependentContext = null; - T instance = null; - boolean isSetOnThis = false; - - try - { - dependentContext = (DependentContext)getContext(Dependent.class); - if(!dependentContext.isActive()) - { - dependentContext.setActive(true); - isSetOnThis = true; - } - - - /*@ScopeType is normal*/ - if(WebBeansUtil.isScopeTypeNormal(bean.getScopeType())) - { - if(this.proxyMap.containsKey(bean)) - { - instance = (T)this.proxyMap.get(bean); - } - else - { - instance =(T) JavassistProxyFactory.createNewProxyInstance(bean); - - this.proxyMap.put(bean, instance); - } - } - /*@ScopeType is not normal*/ - else - { - context = getContext(bean.getScopeType()); - instance = context.get(bean, true); - } - - }finally - { - if(isSetOnThis) - { - dependentContext.setActive(false); - } - } - - return instance; - } - - public Manager removeObserver(Observer observer, Class eventType, Annotation... bindings) - { - this.notificationManager.removeObserver(observer, eventType, bindings); - return this; - } - - public Manager removeObserver(Observer observer, TypeLiteral eventType, Annotation... bindings) - { - this.notificationManager.removeObserver(observer, eventType, bindings); - return this; - } - - public List resolveDecorators(Set> types, Annotation... bindingTypes) - { - WebBeansUtil.checkDecoratorResolverParams(types, bindingTypes); - Set intsSet = WebBeansDecoratorConfig.findDeployedWebBeansDecorator(types, bindingTypes); - Iterator itSet = intsSet.iterator(); - - List decoratorList = new ArrayList(); - while(itSet.hasNext()) - { - WebBeansDecorator decorator = (WebBeansDecorator)itSet.next(); - decoratorList.add(decorator); - - } - - Collections.sort(decoratorList, new DecoratorComparator()); - - return decoratorList; - - } - - public List resolveInterceptors(InterceptionType type, Annotation... interceptorBindings) - { - WebBeansUtil.checkInterceptorResolverParams(interceptorBindings); - - Set intsSet = WebBeansInterceptorConfig.findDeployedWebBeansInterceptor(interceptorBindings); - Iterator itSet = intsSet.iterator(); - - List interceptorList = new ArrayList(); - while(itSet.hasNext()) - { - WebBeansInterceptor interceptor = (WebBeansInterceptor)itSet.next(); - - if(interceptor.getMethod(type) != null) - { - interceptorList.add(interceptor); - } - - } - - Collections.sort(interceptorList, new InterceptorComparator()); - - return interceptorList; - } - - public Set> getBeans() - { - return getManager().components; - } - - public Set getInterceptors() - { - return getManager().webBeansInterceptors; - } - - public Set getDecorators() - { - return getManager().webBeansDecorators; - } - - private void addContext(Class scopeType, javax.webbeans.manager.Context context) - { - Asserts.assertNotNull(scopeType, "scopeType parameter can not be null"); - Asserts.assertNotNull(context, "context parameter can not be null"); - - getManager().contextMap.put(scopeType, context); - } - - public Reference getReference() throws NamingException - { - return new Reference(ManagerImpl.class.getName(),new StringRefAddr("ManagerImpl","ManagerImpl"),ManagerObjectFactory.class.getName(),null); - } - + private Map, Context> contextMap = new ConcurrentHashMap, Context>(); + + private Set> components = new CopyOnWriteArraySet>(); + + private Set webBeansInterceptors = new CopyOnWriteArraySet(); + + private Set webBeansDecorators = new CopyOnWriteArraySet(); + + private NotificationManager notificationManager = null; + + private InjectionResolver injectionResolver = null; + + private Map, Object> proxyMap = Collections.synchronizedMap(new IdentityHashMap, Object>()); + + public ManagerImpl() + { + injectionResolver = InjectionResolver.getInstance(); + notificationManager = NotificationManager.getInstance(); + } + + public static ManagerImpl getManager() + { + ManagerImpl instance = (ManagerImpl) WebBeansFinder.getSingletonInstance(WebBeansFinder.SINGLETON_MANAGER); + + return instance; + } + + public Context getContext(Class scopType) + { + Asserts.assertNotNull(scopType, "scopeType paramter can not be null"); + + Context ctx = null; + + ctx = ContextFactory.getStandartContext(scopType); + + if (ctx == null) + { + ctx = getManager().contextMap.get(scopType); + } + + // Still null + if (ctx == null) + { + throw new ContextNotActiveException("WebBeans context with scope type annotation @" + scopType.getSimpleName() + " is not exist within current thread"); + } + + return ctx; + } + + public Manager addBean(Bean component) + { + getManager().components.add(component); + + return this; + } + + public Manager addContext(Context context) + { + addContext(context.getScopeType(), context); + + return this; + + } + + public void fireEvent(Object event, Annotation... bindings) + { + if (ClassUtil.isParametrized(event.getClass())) + { + throw new WebBeansConfigurationException("Event class : " + event.getClass().getName() + " can not be defined as generic type"); + } + + this.notificationManager.fireEvent(event, bindings); + } + + public Object getInstanceByName(String name) + { + AbstractComponent component = null; + Object object = null; + + Set> set = this.injectionResolver.implResolveByName(name); + if (set.isEmpty()) + { + return null; + } + + if (set.size() > 1) + { + throw new AmbiguousDependencyException("There are more than one WebBeans with name : " + name); + } + + component = (AbstractComponent) set.iterator().next(); + + object = getInstance(component); + + return object; + } + + public T getInstanceByType(Class type, Annotation... bindingTypes) + { + ResolutionUtil.getInstanceByTypeConditions(bindingTypes); + Set> set = resolveByType(type, bindingTypes); + + ResolutionUtil.checkResolvedBeans(set, type); + + return getInstance(set.iterator().next()); + } + + public T getInstanceByType(TypeLiteral type, Annotation... bindingTypes) + { + ResolutionUtil.getInstanceByTypeConditions(bindingTypes); + Set> set = resolveByType(type, bindingTypes); + + ResolutionUtil.checkResolvedBeans(set, type.getRawType()); + + return getInstance(set.iterator().next()); + } + + public Set> resolveByName(String name) + { + return this.injectionResolver.implResolveByName(name); + } + + public Set> resolveByType(Class apiType, Annotation... bindingTypes) + { + return this.injectionResolver.implResolveByType(apiType, new Type[0], bindingTypes); + } + + public Set> resolveByType(TypeLiteral apiType, Annotation... bindingTypes) + { + ParameterizedType ptype = (ParameterizedType) apiType.getType(); + ResolutionUtil.resolveByTypeConditions(ptype); + + Type[] args = ptype.getActualTypeArguments(); + return this.injectionResolver.implResolveByType(apiType.getRawType(), args, bindingTypes); + } + + public Set> resolveObservers(T event, Annotation... bindings) + { + return this.notificationManager.resolveObservers(event, bindings); + } + + public Set> getComponents() + { + return getManager().components; + } + + public Manager addDecorator(Decorator decorator) + { + getManager().webBeansDecorators.add(decorator); + return this; + } + + public Manager addInterceptor(Interceptor interceptor) + { + getManager().webBeansInterceptors.add(interceptor); + return this; + } + + public Manager addObserver(Observer observer, Class eventType, Annotation... bindings) + { + this.notificationManager.addObserver(observer, eventType, bindings); + return this; + } + + public Manager addObserver(Observer observer, TypeLiteral eventType, Annotation... bindings) + { + this.notificationManager.addObserver(observer, eventType, bindings); + return this; + } + + public T getInstance(Bean bean) + { + Context context = null; + DependentContext dependentContext = null; + T instance = null; + boolean isSetOnThis = false; + + try + { + dependentContext = (DependentContext) getContext(Dependent.class); + if (!dependentContext.isActive()) + { + dependentContext.setActive(true); + isSetOnThis = true; + } + + /* @ScopeType is normal */ + if (WebBeansUtil.isScopeTypeNormal(bean.getScopeType())) + { + if (this.proxyMap.containsKey(bean)) + { + instance = (T) this.proxyMap.get(bean); + } else + { + instance = (T) JavassistProxyFactory.createNewProxyInstance(bean); + + this.proxyMap.put(bean, instance); + } + } + /* @ScopeType is not normal */ + else + { + context = getContext(bean.getScopeType()); + instance = context.get(bean, true); + } + + } finally + { + if (isSetOnThis) + { + dependentContext.setActive(false); + } + } + + return instance; + } + + public Manager removeObserver(Observer observer, Class eventType, Annotation... bindings) + { + this.notificationManager.removeObserver(observer, eventType, bindings); + return this; + } + + public Manager removeObserver(Observer observer, TypeLiteral eventType, Annotation... bindings) + { + this.notificationManager.removeObserver(observer, eventType, bindings); + return this; + } + + public List resolveDecorators(Set> types, Annotation... bindingTypes) + { + WebBeansUtil.checkDecoratorResolverParams(types, bindingTypes); + Set intsSet = WebBeansDecoratorConfig.findDeployedWebBeansDecorator(types, bindingTypes); + Iterator itSet = intsSet.iterator(); + + List decoratorList = new ArrayList(); + while (itSet.hasNext()) + { + WebBeansDecorator decorator = (WebBeansDecorator) itSet.next(); + decoratorList.add(decorator); + + } + + Collections.sort(decoratorList, new DecoratorComparator()); + + return decoratorList; + + } + + public List resolveInterceptors(InterceptionType type, Annotation... interceptorBindings) + { + WebBeansUtil.checkInterceptorResolverParams(interceptorBindings); + + Set intsSet = WebBeansInterceptorConfig.findDeployedWebBeansInterceptor(interceptorBindings); + Iterator itSet = intsSet.iterator(); + + List interceptorList = new ArrayList(); + while (itSet.hasNext()) + { + WebBeansInterceptor interceptor = (WebBeansInterceptor) itSet.next(); + + if (interceptor.getMethod(type) != null) + { + interceptorList.add(interceptor); + } + + } + + Collections.sort(interceptorList, new InterceptorComparator()); + + return interceptorList; + } + + public Set> getBeans() + { + return getManager().components; + } + + public Set getInterceptors() + { + return getManager().webBeansInterceptors; + } + + public Set getDecorators() + { + return getManager().webBeansDecorators; + } + + private void addContext(Class scopeType, javax.webbeans.manager.Context context) + { + Asserts.assertNotNull(scopeType, "scopeType parameter can not be null"); + Asserts.assertNotNull(context, "context parameter can not be null"); + + getManager().contextMap.put(scopeType, context); + + } + + public Reference getReference() throws NamingException + { + return new Reference(ManagerImpl.class.getName(), new StringRefAddr("ManagerImpl", "ManagerImpl"), ManagerObjectFactory.class.getName(), null); + } + } \ No newline at end of file Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerObjectFactory.java URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerObjectFactory.java?rev=732803&r1=732802&r2=732803&view=diff ============================================================================== --- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerObjectFactory.java (original) +++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerObjectFactory.java Thu Jan 8 11:41:30 2009 @@ -1,18 +1,15 @@ /* - * 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. + * 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 org.apache.webbeans.container; @@ -25,9 +22,9 @@ public class ManagerObjectFactory implements ObjectFactory { - public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception - { - return ManagerImpl.getManager(); - } + public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception + { + return ManagerImpl.getManager(); + } } Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java?rev=732803&r1=732802&r2=732803&view=diff ============================================================================== --- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java (original) +++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ResolutionUtil.java Thu Jan 8 11:41:30 2009 @@ -1,18 +1,15 @@ /* - * 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. + * 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 org.apache.webbeans.container; @@ -32,41 +29,41 @@ public final class ResolutionUtil { - private ResolutionUtil() - { - - } - - public static void resolveByTypeConditions(ParameterizedType type) - { - Asserts.assertNotNull(type, "type parameter can not be null"); - boolean result = ClassUtil.checkParametrizedType(type); - - if(!result) - { - throw new IllegalArgumentException("Parametrized type : " + type + " can not contain type variable or wildcard type arguments"); - } - } - - public static void getInstanceByTypeConditions(Annotation[] bindingTypes) - { - AnnotationUtil.checkBindingTypeConditions(bindingTypes); - } - - public static void checkResolvedBeans(Set> resolvedSet, Class type) - { - if(resolvedSet.isEmpty()) - { - throw new UnsatisfiedDependencyException("Api type : " + type.getName() + " is not found"); - } - - if(resolvedSet.size() > 1) - { - throw new AmbiguousDependencyException("There is more than one api type with : " + type.getName()); - } - - Bean bean = resolvedSet.iterator().next(); - WebBeansUtil.checkUnproxiableApiType(bean, bean.getScopeType().getAnnotation(ScopeType.class)); - - } + private ResolutionUtil() + { + + } + + public static void resolveByTypeConditions(ParameterizedType type) + { + Asserts.assertNotNull(type, "type parameter can not be null"); + boolean result = ClassUtil.checkParametrizedType(type); + + if (!result) + { + throw new IllegalArgumentException("Parametrized type : " + type + " can not contain type variable or wildcard type arguments"); + } + } + + public static void getInstanceByTypeConditions(Annotation[] bindingTypes) + { + AnnotationUtil.checkBindingTypeConditions(bindingTypes); + } + + public static void checkResolvedBeans(Set> resolvedSet, Class type) + { + if (resolvedSet.isEmpty()) + { + throw new UnsatisfiedDependencyException("Api type : " + type.getName() + " is not found"); + } + + if (resolvedSet.size() > 1) + { + throw new AmbiguousDependencyException("There is more than one api type with : " + type.getName()); + } + + Bean bean = resolvedSet.iterator().next(); + WebBeansUtil.checkUnproxiableApiType(bean, bean.getScopeType().getAnnotation(ScopeType.class)); + + } } Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java?rev=732803&r1=732802&r2=732803&view=diff ============================================================================== --- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java (original) +++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/AbstractContext.java Thu Jan 8 11:41:30 2009 @@ -1,18 +1,15 @@ /* - * 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. + * 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 org.apache.webbeans.context; @@ -34,8 +31,6 @@ import org.apache.webbeans.context.type.ContextTypes; import org.apache.webbeans.exception.ContextRemoveException; - - /** * Abstract implementation of the {@link WebBeansContext} interfaces. * @@ -44,198 +39,188 @@ */ public abstract class AbstractContext implements WebBeansContext { - protected boolean active; - - protected ContextTypes type; - - protected Map, Object> componentInstanceMap = null; - - protected Class scopeType; - - protected AbstractContext() - { - - } - - protected AbstractContext(Class scopeType) - { - this.scopeType = scopeType; - setComponentInstanceMap(); - - } - - protected AbstractContext(ContextTypes type) - { - this.type = type; - configureScopeType(type); - setComponentInstanceMap(); - } - - - private void configureScopeType(ContextTypes type) - { - if(type.equals(ContextTypes.APPLICATION)) - { - this.scopeType = ApplicationScoped.class; - } - else if(type.equals(ContextTypes.SESSION)) - { - this.scopeType = SessionScoped.class; - } - else if(type.equals(ContextTypes.REQUEST)) - { - this.scopeType = RequestScoped.class; - } - else if(type.equals(ContextTypes.DEPENDENT)) - { - this.scopeType = Dependent.class; - } - else if(type.equals(ContextTypes.CONVERSATION)) - { - this.scopeType = ConversationScoped.class; - } - - } - - public T get(Bean component, boolean create) - { - if(!active) - { - throw new ContextNotActiveException("WebBeans context with scope type annotation @" + getScopeType().getName() + " is not active with respect to the current thread"); - } - - return getInstance(component, create); - } - - - @SuppressWarnings("unchecked") - protected T getInstance(Bean component, boolean create) - { - Object instance = null; - - if((instance = componentInstanceMap.get(component)) != null) - { - return (T)instance; - } - else - { - if(create) - { - instance = component.create(); - if(instance != null) - { - componentInstanceMap.put(component, instance); - } - - return (T)instance; - } - } - - return null; - } - - - public void remove(Bean component) - { - removeInstance(component); - } - - /** - * Destroy the given web beans component instance. - * - * @param - * @param component web beans component - * @param instance component instance - */ - private void destroyInstance(Bean component,T instance) - { - component.destroy(instance); - } - - /** - * Destroys the context. - * - * @param - */ - @SuppressWarnings("unchecked") - public void destroy() - { - Set, Object>> entrySet = componentInstanceMap.entrySet(); - Iterator, Object>> it = entrySet.iterator(); - - Bean component = null; - while(it.hasNext()) - { - component = it.next().getKey(); - T instance = (T)componentInstanceMap.get(component); - - it.remove(); - - destroyInstance((Bean)component, instance); - } - } - - protected void removeInstance(Bean component) - { - if(componentInstanceMap.get(component) != null) - { - componentInstanceMap.remove(component); - removeInstance(component); - } - else - { - throw new ContextRemoveException("Given component with " + component + " is not found in the current context with type : " + getType().getTypeName()); - } - - } - - /** - * Gets context active flag. - * - * @return active flag - */ - public boolean isActive() - { - return active; - } - - /** - * Set component active flag. - * - * @param active active flag - */ - public void setActive(boolean active) - { - this.active = active; - } - - /** - * Type of the context - * - * @return type - */ - public ContextTypes getType() - { - return type; - } - - public Map, Object> getComponentInstanceMap() - { - return componentInstanceMap; - } - - public Class getScopeType() - { - - return this.scopeType; - } - - public void remove(Manager container, Bean component) - { - remove((Bean)component); - } - - public abstract void setComponentInstanceMap(); + protected boolean active; + + protected ContextTypes type; + + protected Map, Object> componentInstanceMap = null; + + protected Class scopeType; + + protected AbstractContext() + { + + } + + protected AbstractContext(Class scopeType) + { + this.scopeType = scopeType; + setComponentInstanceMap(); + + } + + protected AbstractContext(ContextTypes type) + { + this.type = type; + configureScopeType(type); + setComponentInstanceMap(); + } + + private void configureScopeType(ContextTypes type) + { + if (type.equals(ContextTypes.APPLICATION)) + { + this.scopeType = ApplicationScoped.class; + } else if (type.equals(ContextTypes.SESSION)) + { + this.scopeType = SessionScoped.class; + } else if (type.equals(ContextTypes.REQUEST)) + { + this.scopeType = RequestScoped.class; + } else if (type.equals(ContextTypes.DEPENDENT)) + { + this.scopeType = Dependent.class; + } else if (type.equals(ContextTypes.CONVERSATION)) + { + this.scopeType = ConversationScoped.class; + } + + } + + public T get(Bean component, boolean create) + { + if (!active) + { + throw new ContextNotActiveException("WebBeans context with scope type annotation @" + getScopeType().getName() + " is not active with respect to the current thread"); + } + + return getInstance(component, create); + } + + @SuppressWarnings("unchecked") + protected T getInstance(Bean component, boolean create) + { + Object instance = null; + + if ((instance = componentInstanceMap.get(component)) != null) + { + return (T) instance; + } else + { + if (create) + { + instance = component.create(); + if (instance != null) + { + componentInstanceMap.put(component, instance); + } + + return (T) instance; + } + } + + return null; + } + + public void remove(Bean component) + { + removeInstance(component); + } + + /** + * Destroy the given web beans component instance. + * + * @param + * @param component web beans component + * @param instance component instance + */ + private void destroyInstance(Bean component, T instance) + { + component.destroy(instance); + } + + /** + * Destroys the context. + * + * @param + */ + @SuppressWarnings("unchecked") + public void destroy() + { + Set, Object>> entrySet = componentInstanceMap.entrySet(); + Iterator, Object>> it = entrySet.iterator(); + + Bean component = null; + while (it.hasNext()) + { + component = it.next().getKey(); + T instance = (T) componentInstanceMap.get(component); + + it.remove(); + + destroyInstance((Bean) component, instance); + } + } + + protected void removeInstance(Bean component) + { + if (componentInstanceMap.get(component) != null) + { + componentInstanceMap.remove(component); + removeInstance(component); + } else + { + throw new ContextRemoveException("Given component with " + component + " is not found in the current context with type : " + getType().getTypeName()); + } + + } + + /** + * Gets context active flag. + * + * @return active flag + */ + public boolean isActive() + { + return active; + } + + /** + * Set component active flag. + * + * @param active active flag + */ + public void setActive(boolean active) + { + this.active = active; + } + + /** + * Type of the context + * + * @return type + */ + public ContextTypes getType() + { + return type; + } + + public Map, Object> getComponentInstanceMap() + { + return componentInstanceMap; + } + + public Class getScopeType() + { + + return this.scopeType; + } + + public void remove(Manager container, Bean component) + { + remove((Bean) component); + } + public abstract void setComponentInstanceMap(); } Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ApplicationContext.java URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ApplicationContext.java?rev=732803&r1=732802&r2=732803&view=diff ============================================================================== --- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ApplicationContext.java (original) +++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ApplicationContext.java Thu Jan 8 11:41:30 2009 @@ -1,18 +1,15 @@ /* - * 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. + * 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 org.apache.webbeans.context; @@ -22,7 +19,6 @@ import org.apache.webbeans.context.type.ContextTypes; - /** * Application context implementation. * @@ -31,16 +27,16 @@ */ public class ApplicationContext extends AbstractContext { - protected ApplicationContext() - { - super(ContextTypes.APPLICATION); - } - - @Override - public void setComponentInstanceMap() - { - this.componentInstanceMap = new ConcurrentHashMap, Object>(); - - } + protected ApplicationContext() + { + super(ContextTypes.APPLICATION); + } + + @Override + public void setComponentInstanceMap() + { + this.componentInstanceMap = new ConcurrentHashMap, Object>(); + + } } Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java?rev=732803&r1=732802&r2=732803&view=diff ============================================================================== --- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java (original) +++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java Thu Jan 8 11:41:30 2009 @@ -1,18 +1,15 @@ /* - * 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. + * 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 org.apache.webbeans.context; @@ -31,9 +28,8 @@ import org.apache.webbeans.context.type.ContextTypes; import org.apache.webbeans.jsf.ConversationManager; - /** - * Gets current {@link WebBeansContext} instances on the current thread context. + * Gets current {@link WebBeansContext} instances on the current thread context. * * @author Gurkan Erdogdu * @since 1.0 @@ -42,308 +38,297 @@ */ public final class ContextFactory { - private static ThreadLocal requestContext = null; - - private static ThreadLocal sessionContext = null; - - private static ThreadLocal applicationContext = null; - - private static ThreadLocal conversationContext = null; - - private static ThreadLocal dependentContext = null; - - private static ApplicationContext currentApplicationContext = null; - - private static SessionContextManager sessionCtxManager = SessionContextManager.getInstance(); - - private static ConversationManager conversationManager = ConversationManager.getInstance(); - - static - { - requestContext = new ThreadLocal(); - sessionContext = new ThreadLocal(); - applicationContext = new ThreadLocal(); - conversationContext = new ThreadLocal(); - dependentContext = new ThreadLocal(); - } - - private ContextFactory() - { - throw new UnsupportedOperationException(); - } - - /** - * Initialize requext context with the given - * request object. - * - * @param request http servlet request object - */ - public static void initRequestContext(HttpServletRequest request) - { - requestContext.set(new RequestContext());//set thread local - requestContext.get().setActive(true); - - if(request != null) - { - HttpSession session = request.getSession(); - initSessionContext(session); - } - } - - /** - * Destroys the request context and all of its - * components. - * - * @param request http servlet request object - */ - public static void destroyRequestContext(HttpServletRequest request) - { - if(requestContext != null) - { - RequestContext context = getRequestContext(); - - if(context != null) - { - context.destroy(); - } - - requestContext.remove();//unset thread local - } - } - - /** - * Creates the session context at the session start. - * - * @param session http session object - */ - public static void initSessionContext(HttpSession session) - { - String sessionId = session.getId(); - SessionContext currentSessionContext = sessionCtxManager.getSessionContextWithSessionId(sessionId); - - if(currentSessionContext == null) - { - currentSessionContext = new SessionContext(); - sessionCtxManager.addNewSessionContext(sessionId, currentSessionContext); - } - - currentSessionContext.setActive(true); - - sessionContext.set(currentSessionContext); - } - - /** - * Destroys the session context and all of its - * components at the end of the session. - * - * @param session http session object - */ - public static void destroySessionContext(HttpSession session) - { - if(sessionContext != null) - { - SessionContext context = getSessionContext(); - - if(context != null) - { - context.destroy(); - } - - sessionContext.remove();//unset thread local - - } - - sessionCtxManager.destroySessionContextWithSessionId(session.getId()); - - } - - - /** - * Creates the application context at the - * application startup - * - * @param servletContext servlet context object - */ - public static void initApplicationContext(ServletContext servletContext) - { - if(currentApplicationContext == null) - { - currentApplicationContext = new ApplicationContext(); - currentApplicationContext.setActive(true); - } - - applicationContext.set(currentApplicationContext); - - } - - /** - * Destroys the application context and all of its - * components at the end of the application. - * - *@param servletContext servlet context object - */ - public static void destroyApplicationContext(ServletContext servletContext) - { - if(applicationContext != null) - { - ApplicationContext context = getApplicationContext(); - - if(context != null) - { - context.destroy(); - } - - applicationContext.remove();//unset thread local - - } - - currentApplicationContext = null; - sessionCtxManager.destroyAllSessions(); - conversationManager.destroyAllConversations(); - } - - - public static void initConversationContext(ConversationContext context) - { - if(context == null) - { - conversationContext.set(new ConversationContext()); - } - else - { - conversationContext.set(context); - } - } - - public static void destroyConversationContext() - { - if(conversationContext != null) - { - ConversationContext context = getConversationContext(); - - if(context != null) - { - context.destroy(); - } - - conversationContext.remove(); - } - } - - - /** - * Gets the current context with given type. - * - * @return the current context - * @throws ContextNotActiveException if context is not active - */ - public static WebBeansContext getStandartContext(ContextTypes type) throws ContextNotActiveException - { - WebBeansContext context = null; - - switch (type.getName()) - { - case 0: - context = getRequestContext(); - break; - - case 1: - context = getSessionContext(); - break; - - case 2: - context = getApplicationContext(); - break; - - case 3: - context = getConversationContext(); - - case 4: - context = getDependentContext(); - - } - - return context; - } - - /** - * Gets the current context with given scope type. - * - * @return the current context - * @throws ContextNotActiveException if context is not active - */ - public static WebBeansContext getStandartContext(Class scopeType) throws ContextNotActiveException - { - WebBeansContext context = null; - - if(scopeType.equals(RequestScoped.class)) - { - context = getRequestContext(); - } - else if(scopeType.equals(SessionScoped.class)) - { - context = getSessionContext(); - } - else if(scopeType.equals(ApplicationScoped.class)) - { - context = getApplicationContext(); - } - else if (scopeType.equals(ConversationScoped.class)) - { - context = getConversationContext(); - - }else if(scopeType.equals(Dependent.class)) - { - context = getDependentContext(); - } - - return context; - } - - - /* - * Get current request ctx. - */ - private static RequestContext getRequestContext() - { - return requestContext.get(); - } - - /* - * Get current session ctx. - */ - private static SessionContext getSessionContext() - { - return sessionContext.get(); - } - - /* - * Get current application ctx. - */ - private static ApplicationContext getApplicationContext() - { - return currentApplicationContext; - } - - /* - * Get current conversation ctx. - */ - private static ConversationContext getConversationContext() - { - return conversationContext.get(); - } - - private static DependentContext getDependentContext() - { - DependentContext dependentCtx = dependentContext.get(); - - if(dependentCtx == null) - { - dependentCtx = new DependentContext(); - dependentContext.set(dependentCtx); - } - - return dependentCtx; - } + private static ThreadLocal requestContext = null; + + private static ThreadLocal sessionContext = null; + + private static ThreadLocal applicationContext = null; + + private static ThreadLocal conversationContext = null; + + private static ThreadLocal dependentContext = null; + + private static ApplicationContext currentApplicationContext = null; + + private static SessionContextManager sessionCtxManager = SessionContextManager.getInstance(); + + private static ConversationManager conversationManager = ConversationManager.getInstance(); + + static + { + requestContext = new ThreadLocal(); + sessionContext = new ThreadLocal(); + applicationContext = new ThreadLocal(); + conversationContext = new ThreadLocal(); + dependentContext = new ThreadLocal(); + } + + private ContextFactory() + { + throw new UnsupportedOperationException(); + } + + /** + * Initialize requext context with the given request object. + * + * @param request http servlet request object + */ + public static void initRequestContext(HttpServletRequest request) + { + requestContext.set(new RequestContext());// set thread local + requestContext.get().setActive(true); + + if (request != null) + { + HttpSession session = request.getSession(); + initSessionContext(session); + } + } + + /** + * Destroys the request context and all of its components. + * + * @param request http servlet request object + */ + public static void destroyRequestContext(HttpServletRequest request) + { + if (requestContext != null) + { + RequestContext context = getRequestContext(); + + if (context != null) + { + context.destroy(); + } + + requestContext.remove();// unset thread local + } + } + + /** + * Creates the session context at the session start. + * + * @param session http session object + */ + public static void initSessionContext(HttpSession session) + { + String sessionId = session.getId(); + SessionContext currentSessionContext = sessionCtxManager.getSessionContextWithSessionId(sessionId); + + if (currentSessionContext == null) + { + currentSessionContext = new SessionContext(); + sessionCtxManager.addNewSessionContext(sessionId, currentSessionContext); + } + + currentSessionContext.setActive(true); + + sessionContext.set(currentSessionContext); + } + + /** + * Destroys the session context and all of its components at the end of the + * session. + * + * @param session http session object + */ + public static void destroySessionContext(HttpSession session) + { + if (sessionContext != null) + { + SessionContext context = getSessionContext(); + + if (context != null) + { + context.destroy(); + } + + sessionContext.remove();// unset thread local + + } + + sessionCtxManager.destroySessionContextWithSessionId(session.getId()); + + } + + /** + * Creates the application context at the application startup + * + * @param servletContext servlet context object + */ + public static void initApplicationContext(ServletContext servletContext) + { + if (currentApplicationContext == null) + { + currentApplicationContext = new ApplicationContext(); + currentApplicationContext.setActive(true); + } + + applicationContext.set(currentApplicationContext); + + } + + /** + * Destroys the application context and all of its components at the end of + * the application. + * + * @param servletContext servlet context object + */ + public static void destroyApplicationContext(ServletContext servletContext) + { + if (applicationContext != null) + { + ApplicationContext context = getApplicationContext(); + + if (context != null) + { + context.destroy(); + } + + applicationContext.remove();// unset thread local + + } + + currentApplicationContext = null; + sessionCtxManager.destroyAllSessions(); + conversationManager.destroyAllConversations(); + } + + public static void initConversationContext(ConversationContext context) + { + if (context == null) + { + conversationContext.set(new ConversationContext()); + } else + { + conversationContext.set(context); + } + } + + public static void destroyConversationContext() + { + if (conversationContext != null) + { + ConversationContext context = getConversationContext(); + + if (context != null) + { + context.destroy(); + } + + conversationContext.remove(); + } + } + + /** + * Gets the current context with given type. + * + * @return the current context + * @throws ContextNotActiveException if context is not active + */ + public static WebBeansContext getStandartContext(ContextTypes type) throws ContextNotActiveException + { + WebBeansContext context = null; + + switch (type.getName()) + { + case 0: + context = getRequestContext(); + break; + + case 1: + context = getSessionContext(); + break; + + case 2: + context = getApplicationContext(); + break; + + case 3: + context = getConversationContext(); + + case 4: + context = getDependentContext(); + + } + + return context; + } + + /** + * Gets the current context with given scope type. + * + * @return the current context + * @throws ContextNotActiveException if context is not active + */ + public static WebBeansContext getStandartContext(Class scopeType) throws ContextNotActiveException + { + WebBeansContext context = null; + + if (scopeType.equals(RequestScoped.class)) + { + context = getRequestContext(); + } else if (scopeType.equals(SessionScoped.class)) + { + context = getSessionContext(); + } else if (scopeType.equals(ApplicationScoped.class)) + { + context = getApplicationContext(); + } else if (scopeType.equals(ConversationScoped.class)) + { + context = getConversationContext(); + + } else if (scopeType.equals(Dependent.class)) + { + context = getDependentContext(); + } + + return context; + } + + /* + * Get current request ctx. + */ + private static RequestContext getRequestContext() + { + return requestContext.get(); + } + + /* + * Get current session ctx. + */ + private static SessionContext getSessionContext() + { + return sessionContext.get(); + } + + /* + * Get current application ctx. + */ + private static ApplicationContext getApplicationContext() + { + return currentApplicationContext; + } + + /* + * Get current conversation ctx. + */ + private static ConversationContext getConversationContext() + { + return conversationContext.get(); + } + + private static DependentContext getDependentContext() + { + DependentContext dependentCtx = dependentContext.get(); + + if (dependentCtx == null) + { + dependentCtx = new DependentContext(); + dependentContext.set(dependentCtx); + } + + return dependentCtx; + } } \ No newline at end of file