Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions boms/tomee-microprofile/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -919,27 +919,27 @@
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-asm9-shaded</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-bundleutils</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-finder-shaded</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-naming</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-reflect</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.bitbucket.b_c</groupId>
Expand Down
10 changes: 5 additions & 5 deletions boms/tomee-plume/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -949,27 +949,27 @@
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-asm9-shaded</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-bundleutils</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-finder-shaded</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-naming</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-reflect</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.bitbucket.b_c</groupId>
Expand Down
10 changes: 5 additions & 5 deletions boms/tomee-plus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -959,27 +959,27 @@
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-asm9-shaded</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-bundleutils</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-finder-shaded</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-naming</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-reflect</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.bitbucket.b_c</groupId>
Expand Down
10 changes: 5 additions & 5 deletions boms/tomee-webprofile/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -614,27 +614,27 @@
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-asm9-shaded</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-bundleutils</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-finder-shaded</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-naming</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-reflect</artifactId>
<version>4.28</version>
<version>4.30</version>
</dependency>
<dependency>
<groupId>org.bitbucket.b_c</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
import jakarta.enterprise.inject.spi.BeanManager;
import jakarta.enterprise.inject.spi.DefinitionException;
import jakarta.enterprise.inject.spi.DeploymentException;
import jakarta.jms.Queue;
import javax.management.DynamicMBean;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanRegistrationException;
Expand Down Expand Up @@ -227,6 +228,7 @@
import java.lang.instrument.Instrumentation;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
Expand Down Expand Up @@ -260,6 +262,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;

import static org.apache.openejb.util.Classes.ancestors;

Expand Down Expand Up @@ -1408,6 +1411,9 @@ public static void mergeServices(final AppInfo appInfo) throws URISyntaxExceptio
if (si.constructorArgs != null && !si.constructorArgs.isEmpty()) {
query.put("constructor", Join.join(",", si.constructorArgs));
}
if (si.constructorArgTypes != null && !si.constructorArgTypes.isEmpty()) {
query.put("constructor-types", Join.join(",", si.constructorArgTypes));
}
appInfo.properties.put(si.id, "new://Service?" + URISupport.createQueryString(query));
if (si.properties != null) {
for (final String k : si.properties.stringPropertyNames()) {
Expand Down Expand Up @@ -3737,8 +3743,19 @@ private static void unusedProperty(final String id, final String property) {
}

public static ObjectRecipe prepareRecipe(final ServiceInfo info) {
final String[] constructorArgs = info.constructorArgs.toArray(new String[info.constructorArgs.size()]);
final ObjectRecipe serviceRecipe = new ObjectRecipe(info.className, info.factoryMethod, constructorArgs, null);
final String[] constructorArgs = info.constructorArgs.toArray(new String[0]);
final Class[] constructorArgTypes = info.constructorArgTypes.stream()
.map(it -> {
try {
return getClassForType(it);
} catch (final ClassNotFoundException e) {
throw new OpenEJBRuntimeException(e);
}
})
.toArray(Class[]::new);

final ObjectRecipe serviceRecipe = new ObjectRecipe(info.className, info.factoryMethod,
constructorArgs, constructorArgTypes.length > 0 ? constructorArgTypes : null); //if empty, treat as not set
serviceRecipe.allow(Option.CASE_INSENSITIVE_PROPERTIES);
serviceRecipe.allow(Option.IGNORE_MISSING_PROPERTIES);
serviceRecipe.allow(Option.PRIVATE_PROPERTIES);
Expand Down Expand Up @@ -3795,6 +3812,27 @@ private URL toUrl(final String jarPath) throws OpenEJBException {
}
}

private static Class<?> getClassForType(String typeName) throws ClassNotFoundException {
if (typeName.endsWith("[]")) {
final String elementType = typeName.substring(0, typeName.length() - 2);
final Class<?> elementClass = getClassForType(elementType); // recursion
return Array.newInstance(elementClass, 0).getClass();
}

return switch (typeName) {
case "boolean" -> boolean.class;
case "byte" -> byte.class;
case "char" -> char.class;
case "short" -> short.class;
case "int" -> int.class;
case "long" -> long.class;
case "float" -> float.class;
case "double" -> double.class;
case "void" -> void.class;
default -> Class.forName(typeName); // regular case
};
}

private static class PersistenceClassLoaderHandlerImpl implements PersistenceClassLoaderHandler {
private static final AtomicBoolean logged = new AtomicBoolean(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ServiceInfo extends InfoObject {
public String classpathAPI;
public Properties properties;
public final List<String> constructorArgs = new ArrayList<>();
public final List<String> constructorArgTypes = new ArrayList<>();
public Properties unsetProperties; // keep it in the model to be able to investigate it dumping Infos

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,7 @@ private ResourceInfo copy(final ResourceInfo a) {
b.description = a.description;
b.factoryMethod = a.factoryMethod;
b.constructorArgs.addAll(a.constructorArgs);
b.constructorArgTypes.addAll(a.constructorArgTypes);
b.originAppName = a.originAppName;
b.types.addAll(a.types);
b.properties = new SuperProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.openejb.Extensions;
import org.apache.openejb.OpenEJBException;
import org.apache.openejb.OpenEJBRuntimeException;
import org.apache.openejb.Vendor;
import org.apache.openejb.api.Proxy;
import org.apache.openejb.api.resource.PropertiesResourceProvider;
Expand Down Expand Up @@ -106,6 +107,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Array;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
Expand All @@ -122,6 +124,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;

import static org.apache.openejb.config.DeploymentsResolver.DEPLOYMENTS_CLASSPATH_PROPERTY;
import static org.apache.openejb.config.ServiceUtils.implies;
Expand Down Expand Up @@ -794,6 +797,7 @@ public static Object toConfigDeclaration(final String id, final URI uri) throws
service.setProvider(map.remove("provider"));
service.setClassName(map.remove("class-name"));
service.setConstructor(map.remove("constructor"));
service.setConstructorArgTypes(map.remove("constructor-types"));
service.setFactoryName(map.remove("factory-name"));
service.setPropertiesProvider(map.remove("properties-provider"));
service.setTemplate(map.remove("template"));
Expand Down Expand Up @@ -1289,7 +1293,8 @@ public <T extends ServiceInfo> T configureService(org.apache.openejb.config.Serv
info.factoryMethod = provider.getFactoryName();
info.id = service.getId();
info.properties = props;
info.constructorArgs.addAll(parseConstructorArgs(provider));
info.constructorArgs.addAll(parseList(provider.getConstructor()));
info.constructorArgTypes.addAll(parseList(provider.getConstructorTypes()));
if (info instanceof ResourceInfo && service instanceof Resource) {
final ResourceInfo ri = ResourceInfo.class.cast(info);
final Resource resource = Resource.class.cast(service);
Expand Down Expand Up @@ -1458,6 +1463,7 @@ private ServiceProvider resolveServiceProvider(final org.apache.openejb.config.S
provider.getTypes().add(service.getType());
provider.setClassName(service.getClassName());
provider.setConstructor(service.getConstructor());
provider.setConstructorTypes(service.getConstructorArgTypes());
provider.setFactoryName(service.getFactoryName());
return provider;
}
Expand Down Expand Up @@ -1598,12 +1604,11 @@ protected static Class<? extends ContainerInfo> getContainerInfoType(final Strin
return containerTypes.get(ctype);
}

private List<String> parseConstructorArgs(final ServiceProvider service) {
final String constructor = service.getConstructor();
if (constructor == null) {
private List<String> parseList(final String raw) {
if (raw == null) {
return Collections.emptyList();
}
return Arrays.asList(constructor.split("[ ,]+"));
return Arrays.asList(raw.split("[ ,]+"));
}

protected List<String> getResourceIds() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public interface Service {

String getConstructor();

String getConstructorArgTypes();

String getFactoryName();

void setClasspath(String classpath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ private void inherit(final ServiceProvider child, final ServiceProvider parent)
if (n(child.getConstructor())) {
child.setConstructor(parent.getConstructor());
}
if (n(child.getConstructorTypes())) {
child.setConstructorTypes(parent.getConstructorTypes());
}
if (n(child.getFactoryName())) {
child.setFactoryName(parent.getFactoryName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public abstract class AbstractService implements Service {
@XmlAttribute(name = "constructor")
protected String constructor;

@XmlAttribute(name = "constructor-types")
protected String constructorArgTypes;

/**
* Mutually exclusive with 'provider'
*/
Expand Down Expand Up @@ -231,6 +234,15 @@ public void setConstructor(final String constructor) {
this.constructor = constructor;
}

@Override
public String getConstructorArgTypes() {
return constructorArgTypes;
}

public void setConstructorArgTypes(String constructorArgTypes) {
this.constructorArgTypes = constructorArgTypes;
}

public String getFactoryName() {
return factoryName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ public void startElement(final String uri, final String localName, final String
provider.setService(att.getValue("", "service"));
provider.setFactoryName(att.getValue("", "factory-name"));
provider.setConstructor(att.getValue("", "constructor"));
provider.setConstructorTypes(att.getValue("", "constructor-types"));
provider.setClassName(att.getValue("", "class-name"));
provider.setParent(att.getValue("", "parent"));
final String typesString = att.getValue("", "types");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* &lt;attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" /&gt;
* &lt;attribute name="provider-type" use="required" type="{http://www.openejb.org/Service/Configuration}ProviderTypes" /&gt;
* &lt;attribute name="constructor" type="{http://www.w3.org/2001/XMLSchema}string" /&gt;
* &lt;attribute name="constructor-types" type="{http://www.w3.org/2001/XMLSchema}string" /&gt;
* &lt;attribute name="factory-name" type="{http://www.w3.org/2001/XMLSchema}string" /&gt;
* &lt;/extension&gt;
* &lt;/simpleContent&gt;
Expand All @@ -64,6 +65,8 @@ public class ServiceProvider {
protected String className;
@XmlAttribute(name = "constructor")
protected String constructor;
@XmlAttribute(name = "constructor-types")
protected String constructorTypes;
@XmlAttribute
protected String description;
@XmlAttribute(name = "display-name")
Expand Down Expand Up @@ -162,6 +165,26 @@ public void setConstructor(final String value) {
this.constructor = value;
}

/**
* Gets the value of the constructorTypes property.
*
* @return possible object is
* {@link String }
*/
public String getConstructorTypes() {
return constructorTypes;
}

/**
* Sets the value of the constructorTypes property.
*
* @param value allowed object is
* {@link String }
*/
public void setConstructorTypes(final String value) {
this.constructorTypes = value;
}

/**
* Gets the value of the description property.
*
Expand Down
Loading