Skip to content
Draft
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
42 changes: 32 additions & 10 deletions src/main/java/com/ibm/cics/bundle/parts/AbstractJavaBundlePart.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,25 @@

import org.w3c.dom.Document;
import org.w3c.dom.Element;
public abstract class AbstractJavaBundlePart extends BundlePartResource {

/**
* Defines a CICS bundle part that deploys a Java application.
*/
public abstract class AbstractJavaBundlePart extends BundlePartResource {
/** The JVM server this CICS bundle part should be deployed to */
private final String jvmServer;

/** The file containing the Java application binary */
private final File bin;

/** The extension of the Java application file (e.g. 'jar') */
private final String binExtension;

/**
* The symbolic name of the Java application. For OSGi bundles this would be the
* Bundle-SymbolicName, otherwise it is the file name of the Java application
* without the extension.
*/
private final String symbolicName;

public AbstractJavaBundlePart(
Expand All @@ -43,7 +57,8 @@ public AbstractJavaBundlePart(
File bin,
String binExtension) {
super(name, type);
if (jvmServer == null || "".equals(jvmServer)) throw new IllegalStateException("JVM server was not supplied");
if (jvmServer == null || "".equals(jvmServer))
throw new IllegalStateException("JVM server was not supplied");
this.jvmServer = jvmServer;
this.symbolicName = symbolicName;
this.bin = bin;
Expand All @@ -53,32 +68,39 @@ public AbstractJavaBundlePart(
@Override
public InputStream getContent() throws IOException {
Document bundlePart = BundlePublisher.createDocument();

Element root = bundlePart.createElement(getType().getBundlePartExtension());
bundlePart.appendChild(root);

root.setAttribute("symbolicname", symbolicName);
root.setAttribute("jvmserver", jvmServer);

addAdditionalNodes(root);

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

try {
BundlePublisher.writeDocument(bundlePart, outputStream);
return new ByteArrayInputStream(outputStream.toByteArray());
} catch (TransformerException e) {
throw new IOException(e);
}
}

@Override
public List<BundleResource> getDynamicResources() {
return Collections.singletonList(new StaticBundleResource(Paths.get(getName() + "." + binExtension), () -> new FileInputStream(bin)));
return Collections.singletonList(
new StaticBundleResource(Paths.get(getName() + "." + binExtension), () -> new FileInputStream(bin)));
}


/**
* Add any additional nodes (e.g. attributes, child elements) to the CICS bundle
* part descriptor.
*
* @param rootElement The root element of the CICS bundle part descriptor.
*/
protected void addAdditionalNodes(Element rootElement) {
//no-op
// no-op
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.ibm.cics.bundle.parts;

/*-
* #%L
* CICS Bundle Common Parent
* %%
* Copyright (C) 2026 IBM Corp.
* %%
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
* #L%
*/

import java.io.File;
import java.io.FileInputStream;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Element;

/**
* Defines a CICS Java bundle part that is deployed to a Liberty server.
*/
public abstract class AbstractLibertyApplicationBundlePart extends AbstractJavaBundlePart {
/**
* Controls whether CICS adds the 'cicsAllAuthenticated' security role to the
* application.
*/
private final boolean addCicsAllAuthenticatedRole;

/**
* The file containing application configuration to apply to the application.
*/
private final File libertyAppConfigFile;

/**
* @param name The name of the bundle part.
* @param type The type of the bundle part.
* @param symbolicName The symbolic name of the bundle part.
* @param jvmServer The JVM server the bundle part is deployed
* to.
* @param addCicsAllAuthenticatedRole Controls whether CICS adds the
* 'cicsAllAuthenticated' security role to
* the application.
* @param libertyAppConfigFile The file containing application
* configuration to apply to the application.
* @param bin The file to deploy in the bundle part.
* @param binExtension The extension of the file.
*/
public AbstractLibertyApplicationBundlePart(String name, BundlePartType type, String symbolicName, String jvmServer,
boolean addCicsAllAuthenticatedRole, File libertyAppConfigFile, File bin,
String binExtension) {
super(name, type, symbolicName, jvmServer, bin, binExtension);
this.addCicsAllAuthenticatedRole = addCicsAllAuthenticatedRole;
this.libertyAppConfigFile = libertyAppConfigFile;
}

@Override
protected void addAdditionalNodes(Element rootElement) {
// Add the appConfigFile element, if set.
if (this.libertyAppConfigFile != null) {
rootElement.setAttribute("appConfigFile", libertyAppConfigFile.getName());
}

// Add the addCICSAllAuth element, if the role shouldn't be added.
if (!this.addCicsAllAuthenticatedRole) {
rootElement.setAttribute("addCICSAllAuth", Boolean.toString(this.addCicsAllAuthenticatedRole));
}
}

@Override
public List<BundleResource> getDynamicResources() {
List<BundleResource> dynamicResources = super.getDynamicResources();

if (this.libertyAppConfigFile == null) {
// Nothing else to add, so we can return early
return dynamicResources;
}

// dynamicResource currently returns an unmodifiable list, so we need to create
// a new list with the contents of the super one to be able to add to them.
List<BundleResource> resources = new ArrayList<>(dynamicResources);

BundleResource configFileResource = new StaticBundleResource(Paths.get(this.libertyAppConfigFile.getName()),
() -> new FileInputStream(this.libertyAppConfigFile));
resources.add(configFileResource);

return resources;
}

}
15 changes: 12 additions & 3 deletions src/main/java/com/ibm/cics/bundle/parts/BundleResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@
import java.nio.file.Path;
import java.util.List;

/**
* Defines a resource within a CICS bundle.
*/
public interface BundleResource extends BundleResourceContentSupplier {

/**
* @return The path to the CICS bundle part descriptor.
*/
public Path getPath();


/**
* @return A list of the resource in this CICS bundle part that are pointed to
* by the bundle part descriptor.
*/
public List<BundleResource> getDynamicResources();

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@
import java.io.IOException;
import java.io.InputStream;

/**
* Supplies the content of a CICS bundle resource.
*/
@FunctionalInterface
public interface BundleResourceContentSupplier {

/**
* @return The contents of the resource in a stream.
* @throws IOException If the content cannot be read.
*/
public InputStream getContent() throws IOException;

}
56 changes: 46 additions & 10 deletions src/main/java/com/ibm/cics/bundle/parts/EarBundlePart.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,53 @@

import java.io.File;

public class EarBundlePart extends AbstractJavaBundlePart {

/**
* Definition of an enterprise application CICS bundle part.
* <p>
* This is defined by the <code>earbundle</code> XML element, with the
* <code>http://www.ibm.com/xmlns/prod/cics/bundle/EARBUNDLE</code> schema.
*/
public class EarBundlePart extends AbstractLibertyApplicationBundlePart {

/**
* @param symbolicName The symbolic name of the application file.
* @param jvmServer The JVM server the enterprise application is deployed to.
* @param earFile The enterprise application file this CICS bundle part
* deploys.
*/
public EarBundlePart(String symbolicName, String jvmServer, File earFile) {
this(
symbolicName,
jvmServer,
true,
null,
earFile);
}

/**
* @param symbolicName The symbolic name of the application file.
* @param jvmServer The JVM server the enterprise application
* is deployed to.
* @param addCicsAllAuthenticatedRole Controls whether CICS adds the
* 'cicsAllAuthenticated' security role to
* the enterprise application.
* @param libertyAppConfigFile The file containing application
* configuration to apply to the enterprise
* application.
* @param earFile The enterprise application file this CICS
* bundle part deploys.
*/
public EarBundlePart(String symbolicName, String jvmServer, boolean addCicsAllAuthenticatedRole,
File libertyAppConfigFile, File earFile) {
super(
symbolicName,
BundlePartType.EARBUNDLE,
symbolicName,
jvmServer,
earFile,
"ear"
);
symbolicName,
BundlePartType.EARBUNDLE,
symbolicName,
jvmServer,
addCicsAllAuthenticatedRole,
libertyAppConfigFile,
earFile,
"ear");
}

}
25 changes: 15 additions & 10 deletions src/main/java/com/ibm/cics/bundle/parts/EbaBundlePart.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@

import java.io.File;

public class EbaBundlePart extends AbstractJavaBundlePart {

public EbaBundlePart(String symbolicName, String jvmServer, File warFile) {
/**
* Definition of an enterprise bundle CICS bundle part.
* <p>
* This is defined by the <code>ebabundle</code> XML element, with the
* <code>http://www.ibm.com/xmlns/prod/cics/bundle/EBABUNDLE</code> schema.
*/
public class EbaBundlePart extends AbstractJavaBundlePart {

public EbaBundlePart(String symbolicName, String jvmServer, File ebaFile) {
super(
symbolicName,
BundlePartType.EBABUNDLE,
symbolicName,
jvmServer,
warFile,
"eba"
);
symbolicName,
BundlePartType.EBABUNDLE,
symbolicName,
jvmServer,
ebaFile,
"eba");
}

}
7 changes: 7 additions & 0 deletions src/main/java/com/ibm/cics/bundle/parts/OsgiBundlePart.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@

import org.w3c.dom.Element;


/**
* Definition of an OSGi bundle CICS bundle part.
* <p>
* This is defined by the <code>osgibundle</code> XML element, with the
* <code>http://www.ibm.com/xmlns/prod/cics/bundle/OSGIBUNDLE</code> schema.
*/
public class OsgiBundlePart extends AbstractJavaBundlePart {

private String osgiVersion;
Expand Down
54 changes: 45 additions & 9 deletions src/main/java/com/ibm/cics/bundle/parts/WarBundlePart.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,53 @@

import java.io.File;

public class WarBundlePart extends AbstractJavaBundlePart {

/**
* Definition of an web application CICS bundle part.
* <p>
* This is defined by the <code>warbundle</code> XML element, with the
* <code>http://www.ibm.com/xmlns/prod/cics/bundle/WARBUNDLE</code> schema.
*/
public class WarBundlePart extends AbstractLibertyApplicationBundlePart {

/**
* @param symbolicName The symbolic name of the application file.
* @param jvmServer The JVM server the enterprise application is deployed to.
* @param warFile The web application file this CICS bundle part
* deploys.
*/
public WarBundlePart(String symbolicName, String jvmServer, File warFile) {
this(
symbolicName,
jvmServer,
true,
null,
warFile);
}

/**
* @param symbolicName The symbolic name of the application file.
* @param jvmServer The JVM server the enterprise application
* is deployed to.
* @param addCicsAllAuthenticatedRole Controls whether CICS adds the
* 'cicsAllAuthenticated' security role to
* the web application.
* @param libertyAppConfigFile The file containing application
* configuration to apply to the web
* application.
* @param warFile The web application file this CICS bundle
* part deploys.
*/
public WarBundlePart(String symbolicName, String jvmServer, boolean addCicsAllAuthenticatedRole,
File libertyAppConfigFile, File warFile) {
super(
symbolicName,
BundlePartType.WARBUNDLE,
symbolicName,
jvmServer,
warFile,
"war"
);
symbolicName,
BundlePartType.WARBUNDLE,
symbolicName,
jvmServer,
addCicsAllAuthenticatedRole,
libertyAppConfigFile,
warFile,
"war");
}

}
Loading
Loading