Skip to content

Commit

Permalink
Another cleanup in DOL
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 4ee062f commit 72b727d
Show file tree
Hide file tree
Showing 33 changed files with 1,324 additions and 1,327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
public class ResourceDescriptorRegistry implements Serializable {

private static final long serialVersionUID = 1L;
private static final LocalStringManagerImpl I18N = new LocalStringManagerImpl(ResourceDescriptorRegistry.class);

private static Map<JavaEEResourceType, Set<Class<?>>> invalidResourceTypeScopes = new HashMap<>();

/*
/**
* This map contains the list of descriptors for where a particular annotation is not applicable. In future update this
* list for non applicable descriptor.
*
* e.g. ConnectionFactoryDescriptor and AdminObjectDescriptor is not allowed to define at Application Client Descriptor.
*/
private static Map<JavaEEResourceType, Set<Class<?>>> invalidResourceTypeScopes = new HashMap<>();
static {
invalidResourceTypeScopes.put(MSD, new HashSet<>());
invalidResourceTypeScopes.put(DSD, new HashSet<>());
Expand All @@ -71,18 +71,14 @@ public class ResourceDescriptorRegistry implements Serializable {
invalidResourceTypeScopes.put(MTFDD, new HashSet<>());
}

private static LocalStringManagerImpl localStrings = new LocalStringManagerImpl(ResourceDescriptorRegistry.class);

private final Map<JavaEEResourceType, Set<ResourceDescriptor>> resourceDescriptors = new HashMap<>();

/**
* This method returns all descriptors associated with the app.
*
* @return
* @return all descriptors associated with the app.
*/
public Set<ResourceDescriptor> getAllResourcesDescriptors() {
Set<ResourceDescriptor> allResourceDescriptors = new HashSet<>();

allResourceDescriptors.addAll(getResourceDescriptors(DSD));
allResourceDescriptors.addAll(getResourceDescriptors(MSD));
allResourceDescriptors.addAll(getResourceDescriptors(CFD));
Expand All @@ -93,16 +89,14 @@ public Set<ResourceDescriptor> getAllResourcesDescriptors() {
allResourceDescriptors.addAll(getResourceDescriptors(MEDD));
allResourceDescriptors.addAll(getResourceDescriptors(MSEDD));
allResourceDescriptors.addAll(getResourceDescriptors(MTFDD));

return allResourceDescriptors;
}


/**
* This method returns all valid descriptor for given class. USes 'invalidResourceTypeScopes' to validate the scope for
* givneClazz
*
* @param givenClazz - Class which is either AppClientDescriptor, Application etc.
* @return
* @return all valid descriptor for given class. USes 'invalidResourceTypeScopes' to validate
* the scope for given class.
*/
public Set<ResourceDescriptor> getAllResourcesDescriptors(Class<?> givenClazz) {
Set<ResourceDescriptor> allResourceDescriptors = new HashSet<>();
Expand All @@ -123,11 +117,9 @@ public Set<ResourceDescriptor> getAllResourcesDescriptors(Class<?> givenClazz) {
return allResourceDescriptors;
}


/**
* Return descriptor by name.
*
* @param name
* @return
* @return descriptor by name.
*/
protected ResourceDescriptor getResourcesDescriptor(String name) {
for (ResourceDescriptor resourceDescriptor : getAllResourcesDescriptors()) {
Expand All @@ -139,6 +131,7 @@ protected ResourceDescriptor getResourcesDescriptor(String name) {
return null;
}


/**
* Validate descriptor is already defined or not.
*
Expand All @@ -149,11 +142,9 @@ private boolean isDescriptorRegistered(ResourceDescriptor reference) {
return getResourcesDescriptor(reference.getName()) != null;
}


/**
* Returns descriptor based on the Resource Type.
*
* @param javaEEResourceType
* @return
* @return descriptors based on the Resource Type.
*/
public Set<ResourceDescriptor> getResourceDescriptors(JavaEEResourceType javaEEResourceType) {
Set<ResourceDescriptor> resourceDescriptorSet = resourceDescriptors.get(javaEEResourceType);
Expand All @@ -164,12 +155,9 @@ public Set<ResourceDescriptor> getResourceDescriptors(JavaEEResourceType javaEER
return resourceDescriptors.get(javaEEResourceType);
}


/**
* Return descriptors based on resource type and given name.
*
* @param javaEEResourceType
* @param name
* @return
* @return descriptors based on resource type and given name.
*/
protected ResourceDescriptor getResourceDescriptor(JavaEEResourceType javaEEResourceType, String name) {
for (ResourceDescriptor resourceDescriptor : getResourceDescriptors(javaEEResourceType)) {
Expand All @@ -181,22 +169,24 @@ protected ResourceDescriptor getResourceDescriptor(JavaEEResourceType javaEEReso
return null;
}


/**
* Adding resource descriptor for gvien reference
*
* @param reference
*/
public void addResourceDescriptor(ResourceDescriptor reference) {
if (isDescriptorRegistered(reference)) {
throw new IllegalStateException(localStrings.getLocalString("exceptionwebduplicatedescriptor",
"This app cannot have descriptor definitions of same name : [{0}]", reference.getName()));
throw new IllegalStateException(I18N.getLocalString("exceptionwebduplicatedescriptor",
"This app cannot have descriptor definitions of same name : [{0}]", reference.getName()));
}

Set<ResourceDescriptor> resourceDescriptorSet = getResourceDescriptors(reference.getResourceType());
resourceDescriptorSet.add(reference);
resourceDescriptors.put(reference.getResourceType(), resourceDescriptorSet);
}


/**
* Remove resource descriptor based on resource type and given reference
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 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 All @@ -16,22 +17,34 @@

package com.sun.enterprise.deployment;

import com.sun.enterprise.deployment.web.ContextParameter;

/**
* I am an object representing a dependency on a resource environment.
*
* @author Kenneth Saks
*/

import com.sun.enterprise.deployment.web.ContextParameter;

public interface ResourceEnvReference extends ContextParameter {

/* Gets the logical name of the destination reference */
public String getName();
public void setName(String refName);

/* Gets the type(jakarta.jms.Queue, jakarta.jms.Topic) of the destination */
public String getType();
public void setType(String refType);

/**
* @return the logical name of the destination reference
*/
@Override
String getName();

/**
* @param refName the logical name of the des+tination reference
*/
@Override
void setName(String refName);

/**
* @return the type(jakarta.jms.Queue, jakarta.jms.Topic) of the destination
*/
String getType();

/**
* @param refType the type(jakarta.jms.Queue, jakarta.jms.Topic) of the destination
*/
void setType(String refType);
}

0 comments on commit 72b727d

Please sign in to comment.