Skip to content

Commit

Permalink
writeLocalizedDescriptions can be static, ConfigPropertyNode.write too
Browse files Browse the repository at this point in the history
- they dont use anything of the object

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Sep 18, 2022
1 parent 58f3a86 commit 5dd0e71
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ protected void writeResourceDescriptors(Node parentNode, Iterator<ResourceDescri
/**
* writes iocalized descriptions (if any) to the DOM node
*/
protected void writeLocalizedDescriptions(Node node, Descriptor desc) {
protected static void writeLocalizedDescriptions(Node node, Descriptor desc) {
LocalizedInfoNode localizedNode = new LocalizedInfoNode();
localizedNode.writeLocalizedMap(node, TagNames.DESCRIPTION, desc.getLocalizedDescriptions());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public Node writeDescriptor(Node parent, MessageListener msgListener) {
RequiredConfigNode reqNode = new RequiredConfigNode();
actSpecNode = reqNode.writeDescriptor(actSpecNode, msgListener);

ConfigPropertyNode configPropertyNode = new ConfigPropertyNode();
configPropertyNode.writeDescriptor(actSpecNode, msgListener);
ConfigPropertyNode.write(actSpecNode, msgListener);
return parent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ public Node writeDescriptor(Node parent, Descriptor descriptor) {
appendTextChild(adminObjectNode, ConnectorTagNames.ADMIN_OBJECT_INTERFACE, adminObject.getAdminObjectInterface());
appendTextChild(adminObjectNode, ConnectorTagNames.ADMIN_OBJECT_CLASS, adminObject.getAdminObjectClass());

ConfigPropertyNode config = new ConfigPropertyNode();
adminObjectNode = config.writeDescriptor(adminObjectNode, adminObject);
ConfigPropertyNode.write(adminObjectNode, element);
}

return parent;
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, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -26,17 +27,15 @@
import com.sun.enterprise.deployment.node.DescriptorFactory;
import com.sun.enterprise.deployment.xml.ConnectorTagNames;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import org.glassfish.deployment.common.Descriptor;
import org.w3c.dom.Node;

/**
* This node is responsible for handling the Connector DTD related config-property XML tag
*
* @author Sheetal Vartak
* @version
* @author Sheetal Vartak
*/
public class ConfigPropertyNode extends DeploymentDescriptorNode<ConnectorConfigProperty> {

Expand Down Expand Up @@ -67,44 +66,34 @@ protected Map<String, String> getDispatchTable() {
@Override
public ConnectorConfigProperty getDescriptor() {
if (config == null) {
config = (ConnectorConfigProperty) DescriptorFactory.getDescriptor(getXMLPath());
config = DescriptorFactory.getDescriptor(getXMLPath());
}
return config;
}

/**
* write the descriptor class to a DOM tree and return it
*
* @param parent node for the DOM tree
* @param descriptor to write
* @return the DOM tree top node
*/
public Node writeDescriptor(Node parent, Descriptor descriptor) {
if (!(descriptor instanceof ConnectorDescriptor)
&& !(descriptor instanceof AdminObject)
&& !(descriptor instanceof ConnectionDefDescriptor)
&& !(descriptor instanceof OutboundResourceAdapter)
&& !(descriptor instanceof MessageListener)) {
throw new IllegalArgumentException(
getClass() + " cannot handle descriptors of type " + descriptor.getClass());
}
final Iterator<ConnectorConfigProperty> configProps;
if (descriptor instanceof ConnectorDescriptor) {
configProps = ((ConnectorDescriptor) descriptor).getConfigProperties().iterator();
} else if (descriptor instanceof ConnectionDefDescriptor) {
configProps = ((ConnectionDefDescriptor) descriptor).getConfigProperties().iterator();
} else if (descriptor instanceof AdminObject) {
configProps = ((AdminObject) descriptor).getConfigProperties().iterator();
} else if (descriptor instanceof OutboundResourceAdapter) {
configProps = ((OutboundResourceAdapter) descriptor).getConfigProperties().iterator();
} else if (descriptor instanceof MessageListener) {
configProps = ((MessageListener) descriptor).getConfigProperties().iterator();
} else {
return parent;
}
// config property info
while (configProps.hasNext()) {
ConnectorConfigProperty cfg = configProps.next();

public static Node write(Node parent, AdminObject descriptor) {
return write(parent, descriptor.getConfigProperties());
}


public static Node write(Node parent, ConnectionDefDescriptor descriptor) {
return write(parent, descriptor.getConfigProperties());
}


public static Node write(Node parent, ConnectorDescriptor descriptor) {
return write(parent, descriptor.getConfigProperties());
}


public static Node write(Node parent, MessageListener descriptor) {
return write(parent, descriptor.getConfigProperties());
}


private static Node write(Node parent, final Set<ConnectorConfigProperty> configProps) {
for (ConnectorConfigProperty cfg : configProps) {
Node configNode = appendChild(parent, ConnectorTagNames.CONFIG_PROPERTY);
writeLocalizedDescriptions(configNode, cfg);
appendTextChild(configNode, ConnectorTagNames.CONFIG_PROPERTY_NAME, cfg.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ public Node writeDescriptor(Node parent, Descriptor desc) {
appendTextChild(conNode, ConnectorTagNames.MANAGED_CONNECTION_FACTORY,
con.getManagedConnectionFactoryImpl());

ConfigPropertyNode config = new ConfigPropertyNode();
conNode = config.writeDescriptor(conNode, con);
ConfigPropertyNode.write(conNode, con);

appendTextChild(conNode, ConnectorTagNames.CONNECTION_FACTORY_INTF, con.getConnectionFactoryIntf());
appendTextChild(conNode, ConnectorTagNames.CONNECTION_FACTORY_IMPL, con.getConnectionFactoryImpl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ public Node writeDescriptor(Node connectorNode, Descriptor descriptor) {

appendTextChild(raNode, ConnectorTagNames.RESOURCE_ADAPTER_CLASS, conDesc.getResourceAdapterClass());

// config-property
ConfigPropertyNode config = new ConfigPropertyNode();
raNode = config.writeDescriptor(raNode, conDesc);
ConfigPropertyNode.write(raNode, connDescriptor);

if (conDesc.getOutBoundDefined() == true) {
// outbound RA info
Expand Down

0 comments on commit 5dd0e71

Please sign in to comment.