You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by rm...@apache.org on 2020/07/29 06:46:13 UTC
[openwebbeans] branch master updated: [OWB-1343]
org.apache.webbeans.spi.deployer.skipVetoedOnPackages support to not even
check @Vetoed on packages (but still on classes and existing direct
package)
This is an automated email from the ASF dual-hosted git repository.
rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git
The following commit(s) were added to refs/heads/master by this push:
new d65bb91 [OWB-1343] org.apache.webbeans.spi.deployer.skipVetoedOnPackages support to not even check @Vetoed on packages (but still on classes and existing direct package)
d65bb91 is described below
commit d65bb9134d6c394e25da61534e977fccced7b10b
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Wed Jul 29 08:46:06 2020 +0200
[OWB-1343] org.apache.webbeans.spi.deployer.skipVetoedOnPackages support to not even check @Vetoed on packages (but still on classes and existing direct package)
---
.../org/apache/webbeans/config/BeansDeployer.java | 22 +++++++++++-----
.../test/concepts/vetoes/VetoedPackageTest.java | 30 +++++++++++++++++++++-
.../vetoes/vetoedpackage/package-info.java | 18 +++++++++++++
.../vetoedpackage/subpackage/VetoedBean.java | 18 +++++++++++++
4 files changed, 81 insertions(+), 7 deletions(-)
diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java b/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
index 5c25d81..9271ae2 100644
--- a/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
+++ b/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
@@ -162,6 +162,8 @@ public class BeansDeployer
private final Map<String, Boolean> packageVetoCache = new HashMap<>();
+ protected boolean skipVetoedOnPackages;
+
/**
* This BdaInfo is used for all manually added annotated types or in case
* a non-Bda-aware ScannerService got configured.
@@ -183,6 +185,8 @@ public class BeansDeployer
String usage = this.webBeansContext.getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.USE_EJB_DISCOVERY);
discoverEjb = Boolean.parseBoolean(usage);
+ skipVetoedOnPackages = Boolean.parseBoolean(this.webBeansContext.getOpenWebBeansConfiguration().getProperty(
+ "org.apache.webbeans.spi.deployer.skipVetoedOnPackages"));
defaultBeanArchiveInformation = new DefaultBeanArchiveInformation("default");
defaultBeanArchiveInformation.setBeanDiscoveryMode(BeanDiscoveryMode.ALL);
@@ -1363,17 +1367,12 @@ public class BeansDeployer
return true;
}
- ClassLoader classLoader = implClass.getClassLoader();
- if (classLoader == null)
- {
- classLoader = BeansDeployer.class.getClassLoader();
- }
-
Package pckge = implClass.getPackage();
if (pckge == null)
{
return false;
}
+
do
{
// yes we cache result with potentially different classloader but this is not portable by spec
@@ -1396,6 +1395,17 @@ public class BeansDeployer
return true;
}
+ if (skipVetoedOnPackages) // we want to avoid loadClass with this property, not cached reflection
+ {
+ return false;
+ }
+
+ ClassLoader classLoader = implClass.getClassLoader();
+ if (classLoader == null)
+ {
+ classLoader = BeansDeployer.class.getClassLoader();
+ }
+
int idx = name.lastIndexOf('.');
if (idx > 0)
{
diff --git a/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/VetoedPackageTest.java b/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/VetoedPackageTest.java
index 46f26ba..794c29e 100644
--- a/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/VetoedPackageTest.java
+++ b/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/VetoedPackageTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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.test.concepts.vetoes;
import org.apache.webbeans.test.AbstractUnitTest;
@@ -10,11 +28,21 @@ import javax.enterprise.inject.spi.Bean;
public class VetoedPackageTest extends AbstractUnitTest
{
@Test
- public void testVetoPackageLevel() throws Exception{
+ public void testVetoPackageLevel()
+ {
startContainer(VetoedBean.class);
Bean<VetoedBean> vetoedBean = getBean(VetoedBean.class);
Assert.assertNull(vetoedBean);
+ }
+ @Test
+ public void skipVetoedOnpackage()
+ {
+ addConfiguration("org.apache.webbeans.spi.deployer.skipVetoedOnPackages", "true");
+ startContainer(VetoedBean.class);
+
+ Bean<VetoedBean> vetoedBean = getBean(VetoedBean.class);
+ Assert.assertNotNull(vetoedBean);
}
}
diff --git a/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/vetoedpackage/package-info.java b/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/vetoedpackage/package-info.java
index dabb106..17a7e0f 100644
--- a/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/vetoedpackage/package-info.java
+++ b/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/vetoedpackage/package-info.java
@@ -1,3 +1,21 @@
+/*
+ * 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.
+ */
@Vetoed
package org.apache.webbeans.test.concepts.vetoes.vetoedpackage;
diff --git a/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/vetoedpackage/subpackage/VetoedBean.java b/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/vetoedpackage/subpackage/VetoedBean.java
index d2ad16c..236df67 100644
--- a/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/vetoedpackage/subpackage/VetoedBean.java
+++ b/webbeans-impl/src/test/java/org/apache/webbeans/test/concepts/vetoes/vetoedpackage/subpackage/VetoedBean.java
@@ -1,3 +1,21 @@
+/*
+ * 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.test.concepts.vetoes.vetoedpackage.subpackage;
public class VetoedBean {