Skip to content

Commit

Permalink
Archive types moved to DOL
Browse files Browse the repository at this point in the history
- Fixes the issue when DOL used nulls because singletons weren't found in HK2
- Affected appclient, tests, validations, processing descriptors, etc.

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Mar 19, 2023
1 parent 0deee93 commit 96e9429
Show file tree
Hide file tree
Showing 44 changed files with 530 additions and 286 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -28,6 +28,7 @@
import org.glassfish.api.deployment.archive.ArchiveDetector;
import org.glassfish.api.deployment.archive.ArchiveHandler;
import org.glassfish.api.deployment.archive.ArchiveType;
import org.glassfish.api.deployment.archive.CarArchiveType;
import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.hk2.api.ServiceLocator;
import org.jvnet.hk2.annotations.Service;
Expand All @@ -39,7 +40,7 @@
*
* @author sanjeeb.sahoo@oracle.com
*/
@Service(name = CarType.ARCHIVE_TYPE)
@Service(name = CarArchiveType.ARCHIVE_TYPE)
@Singleton
public class CarDetector implements ArchiveDetector {
private static final String CAR_DETECTOR_RANK_PROP = "glassfish.car.detector.rank";
Expand All @@ -49,8 +50,6 @@ public class CarDetector implements ArchiveDetector {
private ServiceLocator serviceLocator;
@Inject
private AppClientSniffer sniffer;
@Inject
private CarType archiveType;
private ArchiveHandler archiveHandler;

private static final Logger LOG = Logger.getLogger(CarDetector.class.getName());
Expand Down Expand Up @@ -94,14 +93,14 @@ public ArchiveHandler getArchiveHandler() {
} catch (IOException e) {
throw new RuntimeException(e);
}
archiveHandler = serviceLocator.getService(ArchiveHandler.class, CarType.ARCHIVE_TYPE);
archiveHandler = serviceLocator.getService(ArchiveHandler.class, CarArchiveType.ARCHIVE_TYPE);
}
return archiveHandler;
}
}

@Override
public ArchiveType getArchiveType() {
return archiveType;
return CarArchiveType.CAR_ARCHIVE;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -17,24 +17,18 @@

package org.glassfish.appclient.server.connector;

import org.glassfish.api.deployment.archive.ArchiveType;
import jakarta.inject.Singleton;

import org.glassfish.api.deployment.archive.CarArchiveType;
import org.jvnet.hk2.annotations.Service;

/**
* {@link ArchiveType} .
* Application Client Connector - injectable singleton.
*
* @author sanjeeb.sahoo@oracle.com
*/
@Service(name = CarType.ARCHIVE_TYPE)
@jakarta.inject.Singleton
public class CarType extends ArchiveType {

public static final String ARCHIVE_TYPE = "car";

public static final String ARCHIVE_EXTENSION = ".car";

public CarType() {
super(ARCHIVE_TYPE, ARCHIVE_EXTENSION);
}
@Service(name = CarArchiveType.ARCHIVE_TYPE)
@Singleton
@Deprecated(forRemoval = true, since = "7.0.3")
public class CarType extends CarArchiveType {
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -40,8 +40,8 @@

import org.glassfish.api.deployment.DeploymentContext;
import org.glassfish.api.deployment.archive.ArchiveDetector;
import org.glassfish.api.deployment.archive.CarArchiveType;
import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.appclient.server.connector.CarType;
import org.glassfish.appclient.server.core.jws.JavaWebStartInfo;
import org.jvnet.hk2.annotations.Service;

Expand All @@ -52,11 +52,11 @@
/**
* @author sanjeeb.sahoo@oracle.com
*/
@Service(name = CarType.ARCHIVE_TYPE)
@Service(name = CarArchiveType.ARCHIVE_TYPE)
public class CarHandler extends AbstractArchiveHandler {

@Inject
@Named(CarType.ARCHIVE_TYPE)
@Named(CarArchiveType.ARCHIVE_TYPE)
private ArchiveDetector detector;

private static final Logger LOG = Logger.getLogger(JavaWebStartInfo.APPCLIENT_SERVER_MAIN_LOGGER,
Expand Down
Expand Up @@ -29,6 +29,7 @@
import org.glassfish.api.deployment.archive.ArchiveDetector;
import org.glassfish.api.deployment.archive.ArchiveHandler;
import org.glassfish.api.deployment.archive.ArchiveType;
import org.glassfish.api.deployment.archive.RarArchiveType;
import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.deployment.common.GenericAnnotationDetector;
import org.glassfish.hk2.api.ServiceLocator;
Expand All @@ -41,7 +42,7 @@
*
* @author sanjeeb.sahoo@oracle.com
*/
@Service(name = RarType.ARCHIVE_TYPE)
@Service(name = RarArchiveType.ARCHIVE_TYPE)
@Singleton
public class RarDetector implements ArchiveDetector {

Expand Down Expand Up @@ -78,7 +79,7 @@ public ArchiveHandler getArchiveHandler() {
} catch (IOException e) {
throw new RuntimeException(e);
}
archiveHandler = services.getService(ArchiveHandler.class, RarType.ARCHIVE_TYPE);
archiveHandler = services.getService(ArchiveHandler.class, RarArchiveType.ARCHIVE_TYPE);
}
return archiveHandler;
}
Expand Down
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -16,25 +17,17 @@

package com.sun.enterprise.connectors.connector.module;

import org.glassfish.api.deployment.archive.ArchiveType;
import jakarta.inject.Singleton;

import org.glassfish.api.deployment.archive.RarArchiveType;
import org.jvnet.hk2.annotations.Service;

/**
* {@link ArchiveType} .
* Resource Archive Type - injectable service.
*
* @author sanjeeb.sahoo@oracle.com
*/
@Service(name = RarType.ARCHIVE_TYPE)
@jakarta.inject.Singleton
public class RarType extends ArchiveType {

public static final String ARCHIVE_TYPE = "rar";


public static final String ARCHIVE_EXTENSION = ".rar";

public RarType() {
super(ARCHIVE_TYPE, ARCHIVE_EXTENSION);
}
@Service(name = RarArchiveType.ARCHIVE_TYPE)
@Singleton
public class RarType extends RarArchiveType {
}
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 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 All @@ -22,22 +23,24 @@
import com.sun.enterprise.deployment.archivist.Archivist;
import com.sun.enterprise.deployment.archivist.ArchivistFor;
import com.sun.enterprise.deployment.deploy.shared.InputJarArchive;
import com.sun.enterprise.deployment.util.*;
import com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile;
import com.sun.enterprise.deployment.io.ConnectorDeploymentDescriptorFile;
import com.sun.enterprise.deployment.io.DeploymentDescriptorFile;
import com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile;
import com.sun.enterprise.deployment.io.runtime.ConnectorRuntimeDDFile;
import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.api.deployment.archive.ArchiveType;
import com.sun.enterprise.deployment.util.ConnectorAnnotationDetector;
import com.sun.enterprise.deployment.util.ConnectorVisitor;

import org.jvnet.hk2.annotations.Service;
import org.glassfish.hk2.api.PerLookup;
import jakarta.inject.Inject;

import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.List;

import jakarta.inject.Inject;
import org.glassfish.api.deployment.archive.ArchiveType;
import org.glassfish.api.deployment.archive.RarArchiveType;
import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.hk2.api.PerLookup;
import org.jvnet.hk2.annotations.Service;

/**
* This class is responsible for handling J2EE Connector archive files.
Expand All @@ -47,7 +50,7 @@
*/
@Service
@PerLookup
@ArchivistFor(RarType.ARCHIVE_TYPE)
@ArchivistFor(RarArchiveType.ARCHIVE_TYPE)
public class ConnectorArchivist extends Archivist<ConnectorDescriptor> {

@Inject
Expand Down Expand Up @@ -84,9 +87,10 @@ public DeploymentDescriptorFile getStandardDDFile() {
* @return the list of the DeploymentDescriptorFile responsible for
* handling the configuration deployment descriptors
*/
@Override
public List<ConfigurationDeploymentDescriptorFile> getConfigurationDDFiles() {
if (confDDFiles == null) {
confDDFiles = new ArrayList<ConfigurationDeploymentDescriptorFile>();
confDDFiles = new ArrayList<>();
confDDFiles.add(new ConnectorRuntimeDDFile());
}
return confDDFiles;
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2023 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 All @@ -17,6 +17,17 @@

package com.sun.enterprise.connectors.module;

import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.appserv.connectors.internal.api.ConnectorsClassLoaderUtil;
import com.sun.appserv.connectors.internal.api.ConnectorsUtil;
import com.sun.enterprise.deploy.shared.AbstractArchiveHandler;
import com.sun.enterprise.security.perms.PermsArchiveDelegate;
import com.sun.enterprise.security.perms.SMGlobalPolicyUtil;
import com.sun.logging.LogDomains;

import jakarta.inject.Inject;
import jakarta.inject.Named;

import java.io.File;
import java.io.IOException;
import java.net.URI;
Expand All @@ -29,28 +40,17 @@

import org.glassfish.api.deployment.DeploymentContext;
import org.glassfish.api.deployment.archive.ArchiveDetector;
import org.glassfish.api.deployment.archive.RarArchiveType;
import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.loader.util.ASClassLoaderUtil;
import org.jvnet.hk2.annotations.Service;

import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
import com.sun.appserv.connectors.internal.api.ConnectorsClassLoaderUtil;
import com.sun.appserv.connectors.internal.api.ConnectorsUtil;
import com.sun.enterprise.connectors.connector.module.RarType;
import com.sun.enterprise.deploy.shared.AbstractArchiveHandler;
import com.sun.enterprise.security.perms.PermsArchiveDelegate;
import com.sun.enterprise.security.perms.SMGlobalPolicyUtil;
import com.sun.logging.LogDomains;

import jakarta.inject.Inject;
import jakarta.inject.Named;

/**
* Archive handler for resource-adapters
*
* @author Jagadish Ramu
*/
@Service(name= RarType.ARCHIVE_TYPE)
@Service(name = RarArchiveType.ARCHIVE_TYPE)
public class RarHandler extends AbstractArchiveHandler {
// This class should be moved to connector runtime along with ConnectorClassLoaderUtil.
// We should also consider merging connectors-connector with connectors-internal-api
Expand All @@ -59,7 +59,7 @@ public class RarHandler extends AbstractArchiveHandler {
private ConnectorsClassLoaderUtil loader;

@Inject
@Named(RarType.ARCHIVE_TYPE)
@Named(RarArchiveType.ARCHIVE_TYPE)
private ArchiveDetector detector;

private final Logger _logger = LogDomains.getLogger(RarHandler.class, LogDomains.RSR_LOGGER);
Expand All @@ -69,7 +69,7 @@ public class RarHandler extends AbstractArchiveHandler {
*/
@Override
public String getArchiveType() {
return RarType.ARCHIVE_TYPE;
return RarArchiveType.ARCHIVE_TYPE;
}

/**
Expand Down
Expand Up @@ -47,6 +47,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
Expand Down Expand Up @@ -1125,13 +1126,14 @@ public Set<BundleDescriptor> getBundleDescriptorsOfType(ArchiveType bundleType)
}
Set<BundleDescriptor> bundleSet = new OrderedSet<>();
for (ModuleDescriptor<BundleDescriptor> aModule : getModules()) {
if (aModule.getDescriptor().getModuleType() == bundleType) {
if (Objects.equals(aModule.getDescriptor().getModuleType(), bundleType)) {
bundleSet.add(aModule.getDescriptor());
}
for (RootDeploymentDescriptor rd : aModule.getDescriptor().getExtensionsDescriptors()) {
if (rd instanceof BundleDescriptor) {
if (((BundleDescriptor) rd).getModuleType() == bundleType) {
bundleSet.add((BundleDescriptor) rd);
BundleDescriptor bundleDescriptor = (BundleDescriptor) rd;
if (Objects.equals(bundleDescriptor.getModuleType(), bundleType)) {
bundleSet.add(bundleDescriptor);
}
}
}
Expand All @@ -1150,13 +1152,12 @@ public Set<BundleDescriptor> getBundleDescriptors() {
for (ModuleDescriptor<BundleDescriptor> aModule : getModules()) {
BundleDescriptor bundleDesc = aModule.getDescriptor();
if (bundleDesc == null) {
DOLUtils.getDefaultLogger().fine("Null descriptor for module " + aModule.getArchiveUri());
} else {
bundleSet.add(bundleDesc);
for (RootDeploymentDescriptor rd : bundleDesc.getExtensionsDescriptors()) {
if (rd instanceof BundleDescriptor) {
bundleSet.add((BundleDescriptor) rd);
}
throw new IllegalArgumentException("Null descriptor for module " + aModule);
}
bundleSet.add(bundleDesc);
for (RootDeploymentDescriptor rd : bundleDesc.getExtensionsDescriptors()) {
if (rd instanceof BundleDescriptor) {
bundleSet.add((BundleDescriptor) rd);
}
}
}
Expand Down
Expand Up @@ -16,25 +16,18 @@

package com.sun.enterprise.deployment;

import org.glassfish.api.deployment.archive.ArchiveType;
import jakarta.inject.Singleton;

import org.glassfish.api.deployment.archive.EarArchiveType;
import org.jvnet.hk2.annotations.Service;

/**
* {@link ArchiveType} .
* EAR Archive Type - injectable singleton.
*
* @author sanjeeb.sahoo@oracle.com
*/
@Service(name = EarType.ARCHIVE_TYPE)
// don't change to imports, it is easy to make a mistake and replace it with ejb's Singleton
@jakarta.inject.Singleton
public class EarType extends ArchiveType {

public static final String ARCHIVE_TYPE = "ear";

public static final String ARCHIVE_EXTENSION = ".ear";

public EarType() {
super(ARCHIVE_TYPE, ARCHIVE_EXTENSION);
}
@Service(name = EarArchiveType.ARCHIVE_TYPE)
@Singleton
@Deprecated(forRemoval = true, since = "7.0.3")
public class EarType extends EarArchiveType {
}

0 comments on commit 96e9429

Please sign in to comment.