You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ta...@apache.org on 2015/11/03 13:49:23 UTC
svn commit: r1712281 - in /openwebbeans/branches/cdi-2.0/webbeans-impl/src:
main/java/org/apache/webbeans/config/
main/java/org/apache/webbeans/container/
main/java/org/apache/webbeans/corespi/scanner/
main/java/org/apache/webbeans/xml/ main/resources/...
Author: tandraschko
Date: Tue Nov 3 12:49:22 2015
New Revision: 1712281
URL: http://svn.apache.org/viewvc?rev=1712281&view=rev
Log:
merged fixes
Modified:
openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java
openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/constructor/AroundConstructTest.java
Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1712281&r1=1712280&r2=1712281&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Tue Nov 3 12:49:22 2015
@@ -216,6 +216,8 @@ public class BeansDeployer
// Register Manager built-in component
webBeansContext.getBeanManagerImpl().addInternalBean(webBeansContext.getWebBeansUtil().getManagerBean());
+ webBeansContext.getBeanManagerImpl().getInjectionResolver().setStartup(true);
+
//Fire Event
fireBeforeBeanDiscoveryEvent();
@@ -286,6 +288,7 @@ public class BeansDeployer
// do some cleanup after the deployment
scanner.release();
webBeansContext.getAnnotatedElementFactory().clear();
+ webBeansContext.getBeanManagerImpl().getInjectionResolver().setStartup(false);
}
}
catch (UnsatisfiedResolutionException e)
Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java?rev=1712281&r1=1712280&r2=1712281&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java (original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java Tue Nov 3 12:49:22 2015
@@ -33,7 +33,7 @@ import org.apache.webbeans.logger.WebBea
/**
* Defines configuration for OpenWebBeans.
- *
+ *
* The algorithm is easy:
* <ul>
* <li>Load all properties you can find with the name (META-INF/openwebbeans/openwebbeans.properties),</li>
@@ -51,7 +51,7 @@ public class OpenWebBeansConfiguration
/**Conversation periodic delay in ms.*/
public static final String CONVERSATION_PERIODIC_DELAY = "org.apache.webbeans.conversation.Conversation.periodicDelay";
-
+
/**Timeout interval in ms*/
public static final String CONVERSATION_TIMEOUT_INTERVAL = "org.apache.webbeans.conversation.Conversation.timeoutInterval";
@@ -65,34 +65,34 @@ public class OpenWebBeansConfiguration
/**Use EJB Discovery or not*/
public static final String USE_EJB_DISCOVERY = "org.apache.webbeans.spi.deployer.useEjbMetaDataDiscoveryService";
-
+
/**Container lifecycle*/
public static final String CONTAINER_LIFECYCLE = "org.apache.webbeans.spi.ContainerLifecycle";
-
+
/**JNDI Service SPI*/
- public static final String JNDI_SERVICE = "org.apache.webbeans.spi.JNDIService";
-
+ public static final String JNDI_SERVICE = "org.apache.webbeans.spi.JNDIService";
+
/**Scanner Service*/
public static final String SCANNER_SERVICE = "org.apache.webbeans.spi.ScannerService";
/**Contexts Service*/
public static final String CONTEXTS_SERVICE = "org.apache.webbeans.spi.ContextsService";
-
+
/**Conversation Service*/
public static final String CONVERSATION_SERVICE = "org.apache.webbeans.spi.ConversationService";
-
+
/**Resource Injection Service*/
public static final String RESOURCE_INJECTION_SERVICE = "org.apache.webbeans.spi.ResourceInjectionService";
-
+
/**Security Service*/
public static final String SECURITY_SERVICE = "org.apache.webbeans.spi.SecurityService";
-
+
/**Validator Service*/
public static final String VALIDATOR_SERVICE = "org.apache.webbeans.spi.ValidatorService";
-
+
/**Transaction Service*/
public static final String TRANSACTION_SERVICE = "org.apache.webbeans.spi.TransactionService";
-
+
/**Application is core JSP*/
public static final String APPLICATION_IS_JSP = "org.apache.webbeans.application.jsp";
@@ -117,6 +117,9 @@ public class OpenWebBeansConfiguration
**/
public static final String USE_BDA_BEANSXML_SCANNER = "org.apache.webbeans.useBDABeansXMLScanner";
+ /** A list of known JARs/paths which should not be scanned for beans */
+ public static final String SCAN_EXCLUSION_PATHS = "org.apache.webbeans.scanExclusionPaths";
+
/**
* a comma-separated list of fully qualified class names that should be ignored
* when determining if a decorator matches its delegate. These are typically added by
@@ -254,7 +257,7 @@ public class OpenWebBeansConfiguration
{
return configProperties.getProperty(key);
}
-
+
/**
* Gets property value.
* @param key
@@ -265,8 +268,8 @@ public class OpenWebBeansConfiguration
{
return configProperties.getProperty(key, defaultValue);
}
-
-
+
+
/**
* Sets given property.
* @param key property name
@@ -276,7 +279,7 @@ public class OpenWebBeansConfiguration
{
configProperties.put(key, value);
}
-
+
/**
* Gets jsp property.
@@ -285,10 +288,10 @@ public class OpenWebBeansConfiguration
public boolean isJspApplication()
{
String value = getProperty(APPLICATION_IS_JSP);
-
+
return Boolean.valueOf(value);
}
-
+
/**
* Gets conversation supports property.
* @return true if supports
@@ -296,7 +299,7 @@ public class OpenWebBeansConfiguration
public boolean supportsConversation()
{
String value = getProperty(APPLICATION_SUPPORTS_CONVERSATION);
-
+
return Boolean.valueOf(value);
}
Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=1712281&r1=1712280&r2=1712281&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java (original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java Tue Nov 3 12:49:22 2015
@@ -99,6 +99,8 @@ public class InjectionResolver
*/
private Map<String, Set<Bean<?>>> resolvedBeansByName = new ConcurrentHashMap<String, Set<Bean<?>>>();
+ private boolean startup;
+
/**
* Creates a new injection resolve for given bean manager.
*
@@ -108,8 +110,14 @@ public class InjectionResolver
{
this.webBeansContext = webBeansContext;
this.alternativesManager = webBeansContext.getAlternativesManager();
+ this.startup = false;
}
+ public void setStartup(boolean startup)
+ {
+ this.startup = startup;
+ }
+
/**
* Clear caches.
*/
@@ -499,7 +507,17 @@ public class InjectionResolver
resolvedComponents = byParameterizedType;
}
}
- resolvedBeansByType.put(cacheKey, resolvedComponents);
+
+ if (startup && (resolvedComponents == null || resolvedComponents.isEmpty()))
+ {
+ // skip cache on startup when resolvedComponents are null or empty
+ // see https://issues.apache.org/jira/browse/OWB-1095
+ }
+ else
+ {
+ resolvedBeansByType.put(cacheKey, resolvedComponents);
+ }
+
if (logger.isLoggable(Level.FINE))
{
logger.log(Level.FINE, "DEBUG_ADD_BYTYPE_CACHE_BEANS", cacheKey);
Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java?rev=1712281&r1=1712280&r2=1712281&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java (original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java Tue Nov 3 12:49:22 2015
@@ -39,6 +39,7 @@ import org.apache.xbean.finder.ClassLoad
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -49,7 +50,6 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
-import static java.util.Arrays.asList;
public abstract class AbstractMetaDataDiscovery implements ScannerService
@@ -78,6 +78,8 @@ public abstract class AbstractMetaDataDi
*/
private final Map<String, URL> beanDeploymentUrls = new HashMap<String, URL>();
+ protected String[] scanningExcludes;
+
protected ClassLoader loader;
protected CdiArchive archive;
protected OwbAnnotationFinder finder;
@@ -251,47 +253,10 @@ public abstract class AbstractMetaDataDi
private int isKnownJar(final String path)
{
- for (final String p : asList(
- "/jre/lib",
- "/Contents/Home/",
- "/dt.jar",
- "/tools.jar",
- "/asm",
- "/javassist",
- "/xbean-",
- "/jconsole.jar",
- "/geronimo-",
- "/commons-",
- "/arquillian-",
- "/bsh-",
- "/shrinkwrap-",
- "/junit-",
- "/testng-",
- "/openjpa-",
- "/bcel",
- "/hamcrest",
- "/mysql-connector",
- "/testng",
- "/idea_rt",
- "/eclipse",
- "/jcommander",
- "/tomcat",
- "/catalina",
- "/jasper",
- "/jsp-api",
- "/myfaces-",
- "/servlet-api",
- "/javax",
- "/annotation-api",
- "/el-api",
- "/mojarra",
- "/sisu-guice-",
- "/sisu-inject-",
- "/aether-",
- "/plexus-",
- "/maven-",
- "/guava-",
- "/openwebbeans-"))
+ // lazy init - required when using DS CdiTestRunner
+ initScanningExcludes();
+
+ for (final String p : scanningExcludes)
{
final int i = path.indexOf(p);
if (i > 0)
@@ -342,6 +307,30 @@ public abstract class AbstractMetaDataDi
// properties are loaded.
String usage = WebBeansContext.currentInstance().getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.USE_BDA_BEANSXML_SCANNER);
isBDAScannerEnabled = Boolean.parseBoolean(usage);
+
+ initScanningExcludes();
+ }
+
+ public void initScanningExcludes()
+ {
+ if (scanningExcludes == null)
+ {
+ String scanningExcludesProperty =
+ WebBeansContext.currentInstance().getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.SCAN_EXCLUSION_PATHS);
+ ArrayList<String> scanningExcludesList = new ArrayList<String>();
+ if (scanningExcludesProperty != null)
+ {
+ for (String scanningExclude : scanningExcludesProperty.split(","))
+ {
+ scanningExclude = scanningExclude.trim();
+ if (!scanningExclude.isEmpty())
+ {
+ scanningExcludesList.add(scanningExclude);
+ }
+ }
+ }
+ scanningExcludes = scanningExcludesList.toArray(new String[scanningExcludesList.size()]);
+ }
}
/**
Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java?rev=1712281&r1=1712280&r2=1712281&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java (original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java Tue Nov 3 12:49:22 2015
@@ -50,6 +50,7 @@ import org.w3c.dom.NodeList;
public class DefaultBeanArchiveService implements BeanArchiveService
{
private static final String WEB_INF_CLASSES = "WEB-INF/classes/";
+ private static final String WEB_INF_CLASSES_MAVEN = "target/classes/";
private static final Logger logger = WebBeansLoggerFacade.getLogger(BeanArchiveService.class);
@@ -85,7 +86,8 @@ public class DefaultBeanArchiveService i
}
- if (bdaInfo == null && beanArchiveLocation.contains(WEB_INF_CLASSES))
+ if (bdaInfo == null
+ && (beanArchiveLocation.contains(WEB_INF_CLASSES) || beanArchiveLocation.contains(WEB_INF_CLASSES_MAVEN)))
{
// this is a very special case for beans.xml in a WAR file
// in this case we need to merge the 2 BDAs from WEB-INF/classes/META-INF/beans.xml and WEB-INF/beans.xml
Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1712281&r1=1712280&r2=1712281&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties (original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties Tue Nov 3 12:49:22 2015
@@ -19,13 +19,13 @@
#
# The default configuration is intended for a JDK and a simple ServletContainer
# like jetty, resin or tomcat.
-#
+#
#---------------------------------------------------------------
################################################################################################
################################### DEFAULT SPI CONFIGURATION SECTION ##########################
-################################################################################################
+################################################################################################
# this is the basic configuration, thus it has a very low ordinal of 10
configuration.ordinal=10
@@ -75,7 +75,7 @@ org.apache.webbeans.spi.SecurityService=
# Service which encapsulates the Service-Loader of Java 1.6+ to allow custom implementations to support Java 1.5
org.apache.webbeans.spi.LoaderService=org.apache.webbeans.service.DefaultLoaderService
-################################################################################################
+################################################################################################
#################################### SEVERAL CONFIGURATION PARAMETERS ##########################
################################################################################################
@@ -95,7 +95,7 @@ org.apache.webbeans.spi.deployer.useEjbM
################################## OWB Specific Injection ######################################
#If false, uses spec. defined injection with @Inject. Not recommended use as true.
-#It will be removed in future development.
+#It will be removed in future development.
org.apache.webbeans.fieldInjection.useOwbSpecificInjection=false
################################################################################################
@@ -149,3 +149,72 @@ org.apache.webbeans.web.eagerSessionInit
org.apache.webbeans.generator.javaVersion=1.6
################################################################################################
+
+######################### Bean Scanning ########################################################
+# A list of known JARs/paths which should not be scanned for beans
+org.apache.webbeans.scanExclusionPaths=/jre/lib, \
+ /Contents/Home/, \
+ /dt.jar, \
+ /tools.jar, \
+ /asm, \
+ /javassist, \
+ /xbean-, \
+ /jconsole.jar, \
+ /geronimo-, \
+ /commons-, \
+ /arquillian-, \
+ /bsh-, \
+ /shrinkwrap-, \
+ /junit-, \
+ /testng-, \
+ /openjpa-, \
+ /bcel, \
+ /hamcrest, \
+ /mysql-connector, \
+ /testng, \
+ /idea_rt, \
+ /eclipse, \
+ /jcommander, \
+ /tomcat, \
+ /catalina, \
+ /jasper, \
+ /jsp-api, \
+ /myfaces-api, \
+ /myfaces-impl, \
+ /servlet-api, \
+ /javax, \
+ /annotation-api, \
+ /el-api, \
+ /mojarra, \
+ /sisu-guice-, \
+ /sisu-inject-, \
+ /aether-, \
+ /plexus-, \
+ /maven-, \
+ /guava-, \
+ /openwebbeans-, \
+ /bcprov-jdk14-, \
+ /bcmail-jdk14-, \
+ /bctsp-jdk14-, \
+ /bcmail-jdk14-, \
+ /ss_css2-, \
+ /itext-, \
+ /pd4ml-, \
+ /xmlpull-, \
+ /log4j-, \
+ /slf4j-, \
+ /logkit, \
+ /gson-, \
+ /xstream-, \
+ /httpclient-, \
+ /httpcore-, \
+ /backport-util-concurrent-, \
+ /xml-apis, \
+ /xpp3_min-, \
+ /bval-core, \
+ /bval-jsr, \
+ /hsqldb, \
+ /quartz-2, \
+ /jetty-, \
+ /plexus-
+################################################################################################
Modified: openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/constructor/AroundConstructTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/constructor/AroundConstructTest.java?rev=1712281&r1=1712280&r2=1712281&view=diff
==============================================================================
--- openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/constructor/AroundConstructTest.java (original)
+++ openwebbeans/branches/cdi-2.0/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/constructor/AroundConstructTest.java Tue Nov 3 12:49:22 2015
@@ -19,7 +19,6 @@
package org.apache.webbeans.test.interceptors.constructor;
import org.apache.webbeans.test.AbstractUnitTest;
-import org.junit.Ignore;
import org.junit.Test;
import javax.inject.Inject;
@@ -42,7 +41,7 @@ public class AroundConstructTest extends
@Inject
private IAmBuiltWithMyConstructor bean;
- @Test @Ignore("needs CDI 1.1")
+ @Test
public void checkBeanWasBuiltWithItsConstructorAndIntercepted()
{
addInterceptor(IllGetYourConstructorInvocation.class);