Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargotracker discoveries part one #24335

Merged
merged 5 commits into from
Mar 8, 2023
Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -209,7 +209,7 @@ ClassLoader createConnectorClassLoader(String moduleDirectory, ClassLoader paren
* Provide the configuration of the pool
*
* @param poolInfo connection pool info
* @return ResourcePool connection pool configuration
* @return ResourcePool connection pool configuration or null if not found
*/
ResourcePool getConnectionPoolConfig(PoolInfo poolInfo);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -25,6 +26,8 @@
*/
public class ConnectorRuntimeException extends Exception {

private static final long serialVersionUID = 1718771378046959507L;

/**
* Constructor
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -426,7 +426,7 @@ public static boolean isDynamicReconfigurationEnabled(ResourcePool pool) {
if (pool instanceof PropertyBag) {
PropertyBag properties = (PropertyBag) pool;
Property property = properties.getProperty(ConnectorConstants.DYNAMIC_RECONFIGURATION_FLAG);
if (property != null) {
if (property != null && property.getValue() != null) {
try {
if (Long.parseLong(property.getValue()) > 0) {
enabled = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -384,44 +384,40 @@ public void addAdminObject(
}

ConnectorRegistry registry = ConnectorRegistry.getInstance();

ConnectorDescriptor desc = registry.getDescriptor(connectorName);

AdminObject aoDesc = null;
AdminObject adminObject = null;
// The admin-object can be identified by interface name, class name
// or the combination of the both names.
if (adminObjectClassName == null || adminObjectClassName.trim().equals("")) {
if (adminObjectClassName == null || adminObjectClassName.isBlank()) {
// get AO through interface name
List<AdminObject> adminObjects = desc.getAdminObjectsByType(adminObjectType);
if (adminObjects.size() > 1) {
String msg = localStrings.getString("aor.could_not_determine_aor_type", adminObjectType);
throw new ConnectorRuntimeException(msg);
} else {
aoDesc = adminObjects.get(0);
}
} else if (adminObjectType == null || adminObjectType.trim().equals("")) {
adminObject = adminObjects.isEmpty() ? null : adminObjects.get(0);
} else if (adminObjectType == null || adminObjectType.isBlank()) {
// get AO through class name
List<AdminObject> adminObjects = desc.getAdminObjectsByClass(adminObjectClassName);
if (adminObjects.size() > 1) {
String msg = localStrings.getString("aor.could_not_determine_aor_class", adminObjectClassName);
throw new ConnectorRuntimeException(msg);
} else {
aoDesc = adminObjects.get(0);
}
adminObject = adminObjects.isEmpty() ? null : adminObjects.get(0);
} else {
// get AO through interface name and class name
aoDesc = desc.getAdminObject(adminObjectType, adminObjectClassName);
adminObject = desc.getAdminObject(adminObjectType, adminObjectClassName);
}
if (aoDesc == null) {
if (adminObject == null) {
String msg = localStrings.getString("aor.could_not_determine_aor", adminObjectType, adminObjectClassName);
throw new ConnectorRuntimeException(msg);
}

AdministeredObjectResource aor = new AdministeredObjectResource(resourceInfo);
aor.initialize(aoDesc);
aor.initialize(adminObject);
aor.setResourceAdapter(connectorName);

ConnectorConfigProperty[] envProps = aoDesc.getConfigProperties().toArray(ConnectorConfigProperty[]::new);
ConnectorConfigProperty[] envProps = adminObject.getConfigProperties().toArray(ConnectorConfigProperty[]::new);

//Add default config properties to aor
// Override them if same config properties are provided by the user
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2022 Contributors to Eclipse Foundation. All rights reserved.
* Copyright (c) 2022, 2023 Contributors to Eclipse Foundation. All rights reserved.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -1012,6 +1012,7 @@ public void unregisterConnectorNamingEventListener(ConnectorNamingEventListener

@Override
public ResourcePool getConnectionPoolConfig(PoolInfo poolInfo) {
_logger.log(Level.FINEST, "getConnectionPoolConfig(poolInfo={0})", poolInfo);
ResourcePool pool = ResourcesUtil.createInstance().getPoolConfig(poolInfo);
if (pool != null) {
return pool;
Expand All @@ -1024,7 +1025,7 @@ public ResourcePool getConnectionPoolConfig(PoolInfo poolInfo) {
return pool;
}
}
throw new RuntimeException("No pool found by " + poolInfo);
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -285,11 +285,13 @@ public void switchOnMatching(String rarName, PoolInfo poolInfo) {
public boolean checkAndLoadPool(PoolInfo poolInfo) {
try {
ResourcePool pool = _runtime.getConnectionPoolConfig(poolInfo);
if (pool == null) {
return false;
}
DeferredResourceConfig defResConfig = getResourcesUtil().getDeferredResourceConfig(null, pool, null, null);
return loadResourcesAndItsRar(defResConfig);
} catch (ConnectorRuntimeException cre) {
Object params[] = new Object[]{poolInfo, cre};
_logger.log(Level.WARNING, "unable.to.load.connection.pool", params);
} catch (ConnectorRuntimeException e) {
_logger.log(Level.WARNING, "unable.to.load.connection.pool", new Object[]{poolInfo, e});
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -1426,12 +1426,12 @@ public void createEjbInstanceForInterceptors(Object[] params, EJBContextImpl ctx
protected EJBContextImpl createEjbInstanceAndContext() throws Exception {
EjbBundleDescriptorImpl ejbBundle = ejbDescriptor.getEjbBundleDescriptor();

CDIService.CDIInjectionContext<Object> cdiCtx = null;
Object instance = null;

EJBContextImpl ctx = _constructEJBContextImpl(null);
EjbInvocation ejbInv = null;
boolean success = false;
CDIService.CDIInjectionContext<Object> cdiCtx = null;
try {
ejbInv = createEjbInvocation(null, ctx);
invocationManager.preInvoke(ejbInv);
Expand All @@ -1444,7 +1444,9 @@ protected EJBContextImpl createEjbInstanceAndContext() throws Exception {
}

// Interceptors must be created before the ejb so they're available for around construct.
createEjbInterceptors(ctx, cdiCtx);
if (interceptorManager != null) {
createEjbInterceptors(ctx, cdiCtx);
}

if (cdiService != null && cdiService.isCDIEnabled(ejbBundle)) {
HashMap<Class, Object> ejbInfo = new HashMap<>();
Expand All @@ -1463,7 +1465,7 @@ protected EJBContextImpl createEjbInstanceAndContext() throws Exception {
} catch (Throwable th) {
try {
if (cdiCtx != null) {
// protecte against memory leak
// protect against memory leak
cdiCtx.cleanup(true);
}
} catch (Throwable ignore) {
Expand Down