Skip to content

Commit

Permalink
Fixed mistake I did in ResourceContainerContextImpl
Browse files Browse the repository at this point in the history
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Sep 18, 2022
1 parent b9be6ff commit d1247f3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public EjbReferenceDescriptor getEjbReference(String name) {
EjbReferenceDescriptor ejbRef = app.getEjbReferenceByName(name);
// Make sure it's added to the container context.
addEjbReferenceDescriptor(ejbRef);
return ejbRef;
} catch (IllegalArgumentException ee) {
}
}
Expand Down Expand Up @@ -145,6 +146,7 @@ public ResourceReferenceDescriptor getResourceReference(String name) {
ResourceReferenceDescriptor resourceRef = app.getResourceReferenceByName(name);
// Make sure it's added to the container context.
addResourceReferenceDescriptor(resourceRef);
return resourceRef;
} catch (IllegalArgumentException ee) {
}
}
Expand Down Expand Up @@ -213,6 +215,7 @@ public ResourceEnvReferenceDescriptor getResourceEnvReference(String name) {
ResourceEnvReferenceDescriptor resourceEnvRef = app.getResourceEnvReferenceByName(name);
// Make sure it's added to the container context.
addResourceEnvReferenceDescriptor(resourceEnvRef);
return resourceEnvRef;
} catch (IllegalArgumentException ee) {
}
}
Expand Down Expand Up @@ -254,6 +257,7 @@ public EnvironmentProperty getEnvEntry(String name) {
EnvironmentProperty envEntry = app.getEnvironmentPropertyByName(name);
// Make sure it's added to the container context.
addEnvEntryDescriptor(envEntry);
return envEntry;
} catch (IllegalArgumentException ee) {
}
}
Expand Down Expand Up @@ -297,6 +301,7 @@ public EntityManagerFactoryReferenceDescriptor getEntityManagerFactoryReference(
EntityManagerFactoryReferenceDescriptor emfRefDesc = app.getEntityManagerFactoryReferenceByName(name);
// Make sure it's added to the container context.
addEntityManagerFactoryReferenceDescriptor(emfRefDesc);
return emfRefDesc;
} catch (IllegalArgumentException ee) {
}
}
Expand Down Expand Up @@ -338,6 +343,7 @@ public EntityManagerReferenceDescriptor getEntityManagerReference(String name) {
EntityManagerReferenceDescriptor emRefDesc = app.getEntityManagerReferenceByName(name);
// Make sure it's added to the container context.
addEntityManagerReferenceDescriptor(emRefDesc);
return emRefDesc;
} catch (IllegalArgumentException ee) {
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public EnvEntriesValidator() {
}

public void validateEnvEntries(JndiNameEnvironment env) {
LOG.log(Level.FINER, "validateEnvEntries: {0}", env);
if (env instanceof WebBundleDescriptor) {
Enumeration<EnvironmentProperty> envEntries = ((WebBundleDescriptor) env).getEnvironmentEntries();
validateSimpleEnvEntries(env, envEntries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1975,8 +1975,7 @@ public final EnvironmentProperty getEnvironmentPropertyByName(String name) {
if (env != null) {
return env.getEnvironmentPropertyByName(name);
}
for (Object element : this.getEnvironmentProperties()) {
EnvironmentProperty ev = (EnvironmentProperty) element;
for (EnvironmentProperty ev : this.getEnvironmentProperties()) {
if (ev.getName().equals(name)) {
return ev;
}
Expand Down Expand Up @@ -2020,7 +2019,7 @@ public final void addEnvironmentProperty(EnvironmentProperty environmentProperty
@Override
public final void removeEnvironmentProperty(EnvironmentProperty environmentProperty) {
if (env == null) {
this.getEnvironmentProperties().remove(environmentProperty);
getEnvironmentProperties().remove(environmentProperty);
} else {
env.removeEnvironmentProperty(environmentProperty);
}
Expand Down Expand Up @@ -2330,9 +2329,9 @@ public Set<MethodDescriptor> getMethodDescriptors() {
}

/**
* Returns the full set of transactional business method descriptors I have.
* @return the full set of transactional business method descriptors I have.
*/
public Set getTxBusinessMethodDescriptors() {
public Set<MethodDescriptor> getTxBusinessMethodDescriptors() {
Set<MethodDescriptor> txBusMethods = getBusinessMethodDescriptors();
if (isTimedObject()) {
if (timedObjectMethod != null) {
Expand All @@ -2343,6 +2342,7 @@ public Set getTxBusinessMethodDescriptors() {
return txBusMethods;
}


/**
* Returns the full set of security business method descriptors I have.
*/
Expand All @@ -2351,8 +2351,9 @@ public Set<MethodDescriptor> getSecurityBusinessMethodDescriptors() {
return getBusinessMethodDescriptors();
}


/**
* Returns the set of local/remote/no-interface view business method descriptors I have.
* @return the set of local/remote/no-interface view business method descriptors I have.
*/
public Set<MethodDescriptor> getClientBusinessMethodDescriptors() {
return getLocalRemoteBusinessMethodDescriptors();
Expand Down Expand Up @@ -2423,7 +2424,7 @@ private Set<MethodDescriptor> getBusinessMethodDescriptors() {
return methods;
}

protected void addAllInterfaceMethodsIn(Collection<MethodDescriptor> methodDescriptors, Class c, String methodIntf) {
protected void addAllInterfaceMethodsIn(Collection<MethodDescriptor> methodDescriptors, Class<?> c, String methodIntf) {
Method[] methods = c.getMethods();
for (Method method : methods) {
if (method.getDeclaringClass() != java.lang.Object.class) {
Expand Down Expand Up @@ -2472,7 +2473,7 @@ protected Collection<MethodDescriptor> getTransactionMethods(ClassLoader classLo
}

/**
* Return the set of method objects representing no-interface view
* @return the set of method objects representing no-interface view
*/
public Set<Method> getOptionalLocalBusinessMethods() {
Set<Method> methods = new HashSet<>();
Expand All @@ -2496,15 +2497,15 @@ public Set<Method> getOptionalLocalBusinessMethods() {
public abstract String getContainerFactoryQualifier();

/**
* Return the set of method objects on my home and remote interfaces.
* @return the set of method objects on my home and remote interfaces.
*/

public Vector<Method> getMethods() {
return getMethods(getEjbBundleDescriptor().getClassLoader());
}

/**
* Return the ejb method objects, i.e. the methods on the home and remote interfaces.
* @return the ejb method objects, i.e. the methods on the home and remote interfaces.
*/
public Vector<Method> getMethods(ClassLoader classLoader) {
try {
Expand Down Expand Up @@ -2643,13 +2644,9 @@ public void print(StringBuffer toStringBuffer) {
}
}

private void printDescriptorSet(Set descSet, StringBuffer sbuf) {
for (Object obj : descSet) {
if (obj instanceof Descriptor) {
((Descriptor) obj).print(sbuf);
} else {
sbuf.append(obj);
}
private void printDescriptorSet(Set<? extends Descriptor> descSet, StringBuffer sbuf) {
for (Descriptor obj : descSet) {
obj.print(sbuf);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ private void addCommonWebBundleDescriptor(WebBundleDescriptor wbd, boolean defau
super.addBundleDescriptor(wbd);

WebBundleDescriptorImpl webBundleDescriptor = (WebBundleDescriptorImpl) wbd;
for (WebComponentDescriptor webComponentDesc :webBundleDescriptor.getWebComponentDescriptors())
{
for (WebComponentDescriptor webComponentDesc : webBundleDescriptor.getWebComponentDescriptors()) {
// don't modify the original one
WebComponentDescriptorImpl webComponentDescriptor = new WebComponentDescriptorImpl(webComponentDesc);
// set web bundle to null so that the urlPattern2ServletName
Expand Down Expand Up @@ -565,17 +564,16 @@ protected ServiceReferenceDescriptor _getServiceReferenceByName(String name) {

@Override
protected void combineServiceReferenceDescriptors(JndiNameEnvironment env) {
for (Object oserviceRef : env.getServiceReferenceDescriptors()) {
ServiceReferenceDescriptor serviceRef = (ServiceReferenceDescriptor) oserviceRef;
for (ServiceReferenceDescriptor serviceRef : env.getServiceReferenceDescriptors()) {
ServiceReferenceDescriptor sr = _getServiceReferenceByName(serviceRef.getName());
if (sr != null) {
combineInjectionTargets(sr, serviceRef);
} else {
if (env instanceof WebBundleDescriptor &&
((WebBundleDescriptor)env).isConflictServiceReference()) {
if (env instanceof WebBundleDescriptor && ((WebBundleDescriptor) env).isConflictServiceReference()) {
throw new IllegalArgumentException(localStrings.getLocalString(
"web.deployment.exceptionconflictserviceref",
"There are more than one service references defined in web fragments with the same name, but not overrided in web.xml"));
"web.deployment.exceptionconflictserviceref",
"There are more than one service references defined in web fragments"
+ " with the same name, but not overrided in web.xml"));
} else {
addServiceReferenceDescriptor(serviceRef);
}
Expand Down

0 comments on commit d1247f3

Please sign in to comment.