Author: rmannibucau Date: Tue Aug 12 08:08:47 2014 New Revision: 1617431 URL: http://svn.apache.org/r1617431 Log: fixing info tree
Added: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ExclusionInfo.java Removed: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/ExclusionInfo.java Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/BeansInfo.java tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBBeanInfoService.java tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/BeansInfo.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/BeansInfo.java?rev=1617431&r1=1617430&r2=1617431&view=diff ============================================================================== --- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/BeansInfo.java (original) +++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/BeansInfo.java Tue Aug 12 08:08:47 2014 @@ -17,19 +17,16 @@ package org.apache.openejb.assembler.classic; -import javax.xml.bind.annotation.XmlTransient; -import java.net.URL; +import java.net.URI; import java.util.ArrayList; -import java.util.HashMap; +import java.util.LinkedList; import java.util.List; -import java.util.Map; /** * @version $Rev$ $Date$ */ public class BeansInfo extends InfoObject { - public final List<String> interceptors = new ArrayList<String>(); public final List<String> decorators = new ArrayList<String>(); public final List<String> alternativeClasses = new ArrayList<String>(); @@ -42,16 +39,17 @@ public class BeansInfo extends InfoObjec public String version = "1.1"; public String discoveryMode; - public final Map<String, ExclusionInfo> excludes = new HashMap<>(); - - // TODO: rework these two maps to make then more adapted to info tree - // Tip: get a real CompositeBeansInfo and each BeansInfo has a List<String> classes and a discovery mode - // to remove these maps - // NB: doesn't only need to change it here but also in DeploymentLoader and AnnotationDeployer - - @XmlTransient // ClassListInfo instead of transient? - public final Map<URL, List<String>> managedClasses = new HashMap<>(); + public final List<ExclusionEntryInfo> excludes = new LinkedList<>(); + public final List<BDAInfo> bdas = new LinkedList<>(); - @XmlTransient // ClassListInfo wouldn't work since we need a key for this field + this is mainly a built info, not a tree info - public final Map<URL, String> discoveryModeByUrl = new HashMap<>(); + public static class ExclusionEntryInfo extends InfoObject { + public String name; + public ExclusionInfo exclusion; + } + + public static class BDAInfo extends InfoObject { + public final List<String> managedClasses = new ArrayList<String>(); + public String discoveryMode; + public URI uri; + } } Added: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ExclusionInfo.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ExclusionInfo.java?rev=1617431&view=auto ============================================================================== --- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ExclusionInfo.java (added) +++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ExclusionInfo.java Tue Aug 12 08:08:47 2014 @@ -0,0 +1,29 @@ +/* + * 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.openejb.assembler.classic; + +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +public class ExclusionInfo extends InfoObject { + public final List<String> availableClasses = new LinkedList<>(); + public final List<String> notAvailableClasses = new LinkedList<>(); + public final List<String> systemPropertiesPresence = new LinkedList<>(); + public final Properties systemProperties = new Properties(); +} Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java?rev=1617431&r1=1617430&r2=1617431&view=diff ============================================================================== --- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java (original) +++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java Tue Aug 12 08:08:47 2014 @@ -42,11 +42,11 @@ import org.apache.webbeans.spi.BeanArchi import org.apache.webbeans.spi.ScannerService; import java.lang.annotation.Annotation; +import java.net.MalformedURLException; import java.net.URL; import java.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; import static java.util.Arrays.asList; @@ -183,20 +183,23 @@ public class CdiScanner implements Scann final BeanArchiveService beanArchiveService = webBeansContext.getBeanArchiveService(); final boolean openejb = OpenEJBBeanInfoService.class.isInstance(beanArchiveService); - final Map<URL, String> discoveryModes = beans.discoveryModeByUrl; - for (final Map.Entry<URL, List<String>> next : beans.managedClasses.entrySet()) { - final List<String> value = next.getValue(); - - final URL key = next.getKey(); + for (final BeansInfo.BDAInfo next : beans.bdas) { final BeanArchiveService.BeanArchiveInformation information; if (openejb) { final OpenEJBBeanInfoService beanInfoService = OpenEJBBeanInfoService.class.cast(beanArchiveService); - final String mode = discoveryModes.get(key); - information = beanInfoService.createBeanArchiveInformation(beans, classLoader, mode == null? "ALL" : mode); // this fallback is 100% for tests, TODO: get rid of it (AppComposer) + information = beanInfoService.createBeanArchiveInformation(beans, classLoader, next.discoveryMode == null? "ALL" : next.discoveryMode); // this fallback is 100% for tests, TODO: get rid of it (AppComposer) // TODO: log a warn is discoveryModes.get(key) == null - beanInfoService.getBeanArchiveInfo().put(key, information); + try { + beanInfoService.getBeanArchiveInfo().put(next.uri.toURL(), information); + } catch (final MalformedURLException e) { + throw new IllegalStateException(e); + } } else { - information = beanArchiveService.getBeanArchiveInformation(key); + try { + information = beanArchiveService.getBeanArchiveInformation(next.uri.toURL()); + } catch (MalformedURLException e) { + throw new IllegalStateException(e); + } } final boolean scanModeAnnotated = BeanArchiveService.BeanDiscoveryMode.ANNOTATED.equals(information.getBeanDiscoveryMode()); @@ -204,7 +207,7 @@ public class CdiScanner implements Scann final boolean isNotEarWebApp = startupObject.getWebContext() == null; if (!noScan) { - for (final String name : value) { + for (final String name : next.managedClasses) { if (information.isClassExcluded(name)) { continue; } Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBBeanInfoService.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBBeanInfoService.java?rev=1617431&r1=1617430&r2=1617431&view=diff ============================================================================== --- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBBeanInfoService.java (original) +++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/cdi/OpenEJBBeanInfoService.java Tue Aug 12 08:08:47 2014 @@ -17,7 +17,6 @@ package org.apache.openejb.cdi; import org.apache.openejb.assembler.classic.BeansInfo; -import org.apache.openejb.assembler.classic.ExclusionInfo; import org.apache.openejb.loader.SystemInstance; import org.apache.webbeans.exception.WebBeansConfigurationException; import org.apache.webbeans.spi.BeanArchiveService; @@ -55,17 +54,16 @@ public class OpenEJBBeanInfoService impl information.getAlternativeClasses().addAll(info.alternativeClasses); information.getAlternativeStereotypes().addAll(info.alternativeStereotypes); - for (final Map.Entry<String, ExclusionInfo> exclusionInfo : info.excludes.entrySet()) { - final ExclusionInfo value = exclusionInfo.getValue(); + for (final BeansInfo.ExclusionEntryInfo exclusionInfo : info.excludes) { boolean skip = false; - for (final String n : value.availableClasses) { + for (final String n : exclusionInfo.exclusion.availableClasses) { if (!isClassAvailable(loader, n)) { skip = true; break; } } if (!skip) { - for (final String n : value.notAvailableClasses) { + for (final String n : exclusionInfo.exclusion.notAvailableClasses) { if (isClassAvailable(loader, n)) { skip = true; break; @@ -73,7 +71,7 @@ public class OpenEJBBeanInfoService impl } } if (!skip) { - for (final String n : value.systemPropertiesPresence) { + for (final String n : exclusionInfo.exclusion.systemPropertiesPresence) { // our system instance is more powerful here if (SystemInstance.get().getProperty(n) == null) { skip = true; @@ -82,9 +80,9 @@ public class OpenEJBBeanInfoService impl } } if (!skip) { - for (final String n : value.systemProperties.stringPropertyNames()) { + for (final String n : exclusionInfo.exclusion.systemProperties.stringPropertyNames()) { // our system instance is more powerful here - if (!value.systemProperties.getProperty(n).equals(SystemInstance.get().getProperty(n))) { + if (!exclusionInfo.exclusion.systemProperties.getProperty(n).equals(SystemInstance.get().getProperty(n))) { skip = true; break; } @@ -94,7 +92,7 @@ public class OpenEJBBeanInfoService impl continue; } - final String name = exclusionInfo.getKey(); + final String name = exclusionInfo.name; if (name.endsWith(".*")) { information.addClassExclude(name.substring(0, name.length() - 2)); } Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java?rev=1617431&r1=1617430&r2=1617431&view=diff ============================================================================== --- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java (original) +++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java Tue Aug 12 08:08:47 2014 @@ -100,6 +100,8 @@ import org.apache.openejb.util.LogCatego import org.apache.openejb.util.Logger; import org.apache.openejb.util.Messages; +import java.net.URISyntaxException; +import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -116,8 +118,8 @@ public class EjbJarInfoBuilder { public static Messages messages = new Messages("org.apache.openejb.util.resources"); public static Logger logger = Logger.getInstance(LogCategory.OPENEJB, "org.apache.openejb.util.resources"); - private final List<String> deploymentIds = new ArrayList<String>(); - private final List<String> securityRoles = new ArrayList<String>(); + private final List<String> deploymentIds = new ArrayList<>(); + private final List<String> securityRoles = new ArrayList<>(); public EjbJarInfo buildInfo(final EjbModule jar) throws OpenEJBException { @@ -243,7 +245,11 @@ public class EjbJarInfoBuilder { throw new IllegalArgumentException("Not supported: " + config); } } - ejbJar.beans.excludes.put(exclude.getName(), exclusionInfo); + + final BeansInfo.ExclusionEntryInfo exclusionEntryInfo = new BeansInfo.ExclusionEntryInfo(); + exclusionEntryInfo.name = exclude.getName(); + exclusionEntryInfo.exclusion = exclusionInfo; + ejbJar.beans.excludes.add(exclusionEntryInfo); } } @@ -251,17 +257,30 @@ public class EjbJarInfoBuilder { ejbJar.beans.decorators.addAll(beans.getDecorators()); ejbJar.beans.alternativeClasses.addAll(beans.getAlternativeClasses()); ejbJar.beans.alternativeStereotypes.addAll(beans.getAlternativeStereotypes()); - ejbJar.beans.managedClasses.putAll(beans.getManagedClasses()); ejbJar.beans.duplicatedAlternativeClasses.addAll(beans.getDuplicatedAlternatives().getClasses()); ejbJar.beans.duplicatedAlternativeStereotypes.addAll(beans.getDuplicatedAlternatives().getStereotypes()); ejbJar.beans.duplicatedInterceptors.addAll(beans.getDuplicatedInterceptors()); ejbJar.beans.duplicatedDecorators.addAll(beans.getDuplicatedDecorators()); + final Map<URL, String> discoveryModeByUrl = new HashMap<>(); if (CompositeBeans.class.isInstance(beans)) { - ejbJar.beans.discoveryModeByUrl.putAll(CompositeBeans.class.cast(beans).getDiscoveryByUrl()); + discoveryModeByUrl.putAll(CompositeBeans.class.cast(beans).getDiscoveryByUrl()); } else { - ejbJar.beans.discoveryModeByUrl.put(null, beans.getBeanDiscoveryMode()); + discoveryModeByUrl.put(null, beans.getBeanDiscoveryMode()); + } + for (final Map.Entry<URL, List<String>> next : beans.getManagedClasses().entrySet()) { + final URL key = next.getKey(); + + final BeansInfo.BDAInfo bdaInfo = new BeansInfo.BDAInfo(); + bdaInfo.managedClasses.addAll(next.getValue()); + bdaInfo.discoveryMode = discoveryModeByUrl.get(key); + try { + bdaInfo.uri = key == null ? null : key.toURI(); + } catch (final URISyntaxException e) { + bdaInfo.uri = null; + } + ejbJar.beans.bdas.add(bdaInfo); } }