Skip to content

Commit

Permalink
Generics around DeploymentDescriptorFile
Browse files Browse the repository at this point in the history
- more clear and fixed api: getRootXMLNode's parameter is not <T>, but
  may be another type too.
- deprecation in comments transformed to annotation

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Sep 18, 2022
1 parent 87fd0de commit d4178c2
Show file tree
Hide file tree
Showing 15 changed files with 284 additions and 305 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -21,12 +22,11 @@

public class PermissionItemDescriptor extends Descriptor {

private static final long serialVersionUID = 1L;
private String permClassName;
private String targetName;
private String actions;

private boolean statingPermIetmRead;

private PermissionsDescriptor parent;


Expand All @@ -39,7 +39,10 @@ public PermissionsDescriptor getParent() {
}

protected void setParent(PermissionsDescriptor parent) {
assert(this.parent==null);
if (this.parent != null) {
throw new IllegalStateException("Parent was already set to " + this.parent.getModuleID()
+ ", it cannot be set to " + parent.getModuleID());
}
this.parent = parent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ public boolean supportsModuleType(ArchiveType moduleType) {
return (moduleType != null && moduleType.equals(DOLUtils.carType())) && (env.getProcessType() == ProcessType.ACC) ;
}


@Override
public Object open(Archivist main, ReadableArchive archive, RootDeploymentDescriptor descriptor) throws IOException, SAXException {
if (deplLogger.isLoggable(Level.FINE)) {
deplLogger.logp(Level.FINE, "ACCPersistencerArchivist", "readPersistenceDeploymentDescriptors",
"archive = {0}", archive.getURI());
}
public RootDeploymentDescriptor open(Archivist main, ReadableArchive archive, RootDeploymentDescriptor descriptor)
throws IOException, SAXException {
deplLogger.logp(Level.FINE, "ACCPersistencerArchivist", "readPersistenceDeploymentDescriptors", "archive = {0}",
archive.getURI());

// The descriptor had better be an ApplicationClientDescriptor!
if ( ! (descriptor instanceof ApplicationClientDescriptor)) {
Expand Down Expand Up @@ -113,8 +113,8 @@ private boolean isDeployedClientAlsoStandAlone(final Attributes mainAttrs) {
return relativePathToGroupFacade == null;
}

private URI clientURI(final ReadableArchive archive,
final ApplicationClientDescriptor acDesc) throws IOException {

private URI clientURI(final ReadableArchive archive, final ApplicationClientDescriptor acDesc) throws IOException {
if (archive instanceof MultiReadableArchive) {
/*
* Getting the manifest from a MultiReadableArchive returns the
Expand All @@ -132,8 +132,7 @@ private URI clientURI(final ReadableArchive archive,
* the download directory.
*/
final URI absURIToClient = ((MultiReadableArchive) archive).getURI(1);
final String relativeURIPathToAnchorDir =
facadeMainAttrs.getValue(AppClientArchivist.GLASSFISH_ANCHOR_DIR);
final String relativeURIPathToAnchorDir = facadeMainAttrs.getValue(AppClientArchivist.GLASSFISH_ANCHOR_DIR);
final URI absURIToAnchorDir = archive.getURI().resolve(relativeURIPathToAnchorDir);
return absURIToAnchorDir.relativize(absURIToClient);
}
Expand All @@ -146,7 +145,7 @@ private boolean isStandAlone(final ApplicationClientDescriptor ac) {
* For a non-deployed app (this case), the descriptor for a stand-alone
* app client has a null application value.
*/
return (ac.getApplication() == null || ac.isStandalone());
return ac.getApplication() == null || ac.isStandalone();
}

private boolean isDeployed(final Attributes mainAttrs) throws IOException {
Expand Down Expand Up @@ -186,9 +185,6 @@ private void addOtherNondeployedScanTargets(final ReadableArchive clientArchive,
acDescr.getApplication(),
true,
candidates);



}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@
@Contract
public abstract class Archivist<T extends BundleDescriptor> {

protected static final Logger logger =
DOLUtils.getDefaultLogger();
protected static final Logger logger = DOLUtils.getDefaultLogger();

public static final String MANIFEST_VERSION_VALUE = "1.0";

Expand Down Expand Up @@ -126,8 +125,7 @@ public abstract class Archivist<T extends BundleDescriptor> {
private ConfigurationDeploymentDescriptorFile confDD;

// resources...
private static final LocalStringManagerImpl localStrings =
new LocalStringManagerImpl(Archivist.class);
private static final LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Archivist.class);

// class loader to use when validating the DOL
protected ClassLoader classLoader = null;
Expand Down Expand Up @@ -158,14 +156,12 @@ public abstract class Archivist<T extends BundleDescriptor> {
protected static final String WEB_FRAGMENT_EXTENSION = ".jar";
protected static final String EJB_EXTENSION = ".jar";
protected static final String CONNECTOR_EXTENSION = ".rar";
//Used to detect the uploaded files which always end in ".tmp"
// Used to detect the uploaded files which always end in ".tmp"
protected static final String UPLOAD_EXTENSION = ".tmp";

private static final String PROCESS_ANNOTATION_FOR_OLD_DD =
"process.annotation.for.old.dd";
private static final String PROCESS_ANNOTATION_FOR_OLD_DD = "process.annotation.for.old.dd";

private static final boolean processAnnotationForOldDD =
Boolean.getBoolean(PROCESS_ANNOTATION_FOR_OLD_DD);
private static final boolean processAnnotationForOldDD = Boolean.getBoolean(PROCESS_ANNOTATION_FOR_OLD_DD);

protected T descriptor;

Expand Down Expand Up @@ -236,8 +232,10 @@ public T getDescriptor() {
return descriptor;
}


/**
* Open a new archive file, read the deployment descriptors and annotations * and set the constructed DOL descriptor instance
* Open a new archive file, read the deployment descriptors and annotations
* and set the constructed DOL descriptor instance
*
* @param archive the archive file path
* @return the deployment descriptor for this archive
Expand Down Expand Up @@ -532,55 +530,48 @@ protected void readAnnotations(ReadableArchive archive, T descriptor,
}
}


/**
* Returns the scanner for this archivist, usually it is the scanner regitered
* @return the scanner for this archivist, usually it is the scanner regitered
* with the same module type as this archivist, but subclasses can return a
* different version
*
*/
public ModuleScanner getScanner() {

Scanner scanner = null;
public ModuleScanner<?> getScanner() {
try {
scanner = habitat.getService(Scanner.class, getModuleType().toString());
if (scanner==null || !(scanner instanceof ModuleScanner)) {
logger.log(Level.SEVERE, "Cannot find module scanner for " + this.getManifest());
ModuleScanner<?> scanner = (ModuleScanner<?>) habitat.getService(Scanner.class, getModuleType().toString());
if (scanner != null) {
return scanner;
}
logger.log(Level.SEVERE, "Cannot find scanner for " + this.getModuleType());
} catch (MultiException e) {
// XXX To do
logger.log(Level.SEVERE, "Cannot find scanner for " + this.getModuleType(), e);
}
return (ModuleScanner)scanner;
return null;
}


/**
* Process annotations in a bundle descriptor, the annoation processing
* is dependent on the type of descriptor being passed.
*/
public ProcessingResult processAnnotations(T bundleDesc,
ReadableArchive archive)
throws AnnotationProcessorException, IOException {

public ProcessingResult processAnnotations(T bundleDesc, ReadableArchive archive)
throws AnnotationProcessorException, IOException {
return processAnnotations(bundleDesc, getScanner(), archive);

}


/**
* Process annotations in a bundle descriptor, the annoation processing
* is dependent on the type of descriptor being passed.
*/
protected ProcessingResult processAnnotations(RootDeploymentDescriptor bundleDesc,
ModuleScanner scanner,
ReadableArchive archive)
throws AnnotationProcessorException, IOException {

protected ProcessingResult processAnnotations(RootDeploymentDescriptor bundleDesc, ModuleScanner scanner,
ReadableArchive archive) throws AnnotationProcessorException, IOException {
if (scanner == null) {
return null;
}

AnnotatedElementHandler aeHandler =
AnnotatedElementHandlerFactory.createAnnotatedElementHandler(
bundleDesc);
AnnotatedElementHandler aeHandler = AnnotatedElementHandlerFactory.createAnnotatedElementHandler(bundleDesc);

if (aeHandler == null) {
return null;
Expand All @@ -596,7 +587,7 @@ protected ProcessingResult processAnnotations(RootDeploymentDescriptor bundleDes
scanner.process(archive, bundleDesc, classLoader, parser);

if (!scanner.getElements().isEmpty()) {
if (((BundleDescriptor)bundleDesc).isDDWithNoAnnotationAllowed()) {
if (((BundleDescriptor) bundleDesc).isDDWithNoAnnotationAllowed()) {
// if we come into this block, it means an old version
// of deployment descriptor has annotation which is not correct
// throw exception in this case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@

package com.sun.enterprise.deployment.archivist;

import org.glassfish.deployment.common.RootDeploymentDescriptor;
import com.sun.enterprise.deployment.Application;
import com.sun.enterprise.deployment.util.DOLUtils;
import org.glassfish.api.deployment.archive.ArchiveType;
import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.api.deployment.archive.Archive;
import org.xml.sax.SAXException;
import org.jvnet.hk2.annotations.Service;

import java.io.IOException;
import java.util.logging.Level;
import java.util.Map;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;

import org.glassfish.api.deployment.archive.Archive;
import org.glassfish.api.deployment.archive.ArchiveType;
import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.deployment.common.RootDeploymentDescriptor;
import org.jvnet.hk2.annotations.Service;
import org.xml.sax.SAXException;

@Service
@ExtensionsArchivistFor("jpa")
Expand All @@ -46,7 +47,7 @@ public boolean supportsModuleType(ArchiveType moduleType) {
* Spec defined pu roots are - (1)Non component jars in root of ear (2)jars in lib of ear
*/
@Override
public Object open(Archivist main, ReadableArchive earArchive, final RootDeploymentDescriptor descriptor)
public RootDeploymentDescriptor open(Archivist main, ReadableArchive earArchive, final RootDeploymentDescriptor descriptor)
throws IOException, SAXException {
if (deplLogger.isLoggable(Level.FINE)) {
deplLogger.logp(Level.FINE, "EarArchivist", "readPersistenceDeploymentDescriptors", "archive = {0}",
Expand Down

0 comments on commit d4178c2

Please sign in to comment.