org.glassfish.webservices.archivist.WebServicesArchivist Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.webservices.archivist;
import com.sun.enterprise.deployment.BundleDescriptor;
import com.sun.enterprise.deployment.WebServicesDescriptor;
import com.sun.enterprise.deployment.archivist.Archivist;
import com.sun.enterprise.deployment.archivist.ExtensionsArchivist;
import com.sun.enterprise.deployment.archivist.ExtensionsArchivistFor;
import com.sun.enterprise.deployment.io.ConfigurationDeploymentDescriptorFile;
import com.sun.enterprise.deployment.io.DeploymentDescriptorFile;
import com.sun.enterprise.deployment.io.runtime.WLSWebServicesDeploymentDescriptorFile;
import com.sun.enterprise.deployment.util.DOLUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.glassfish.api.deployment.archive.ArchiveType;
import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.api.deployment.archive.WritableArchive;
import org.glassfish.deployment.common.RootDeploymentDescriptor;
import org.glassfish.hk2.api.PerLookup;
import org.glassfish.webservices.io.WebServicesDeploymentDescriptorFile;
import org.jvnet.hk2.annotations.Service;
import org.xml.sax.SAXException;
/**
* Extension Archivist for webservices.
*/
@Service
@PerLookup
@ExtensionsArchivistFor("webservices")
public class WebServicesArchivist extends ExtensionsArchivist {
@Override
public DeploymentDescriptorFile getStandardDDFile(RootDeploymentDescriptor descriptor) {
if (standardDD == null) {
standardDD = new WebServicesDeploymentDescriptorFile(descriptor);
}
return standardDD;
}
/**
* @return the list of the DeploymentDescriptorFile responsible for
* handling the configuration deployment descriptors
*/
@Override
public List getConfigurationDDFiles(RootDeploymentDescriptor descriptor) {
if (confDDFiles == null) {
confDDFiles = new ArrayList<>();
confDDFiles.add(new WLSWebServicesDeploymentDescriptorFile(descriptor));
}
return confDDFiles;
}
@Override
public boolean supportsModuleType(ArchiveType moduleType) {
return DOLUtils.warType().equals(moduleType) || DOLUtils.ejbType().equals(moduleType)
|| DOLUtils.scatteredWarType().equals(moduleType);
}
@Override
public RootDeploymentDescriptor open(Archivist main, ReadableArchive archive, RootDeploymentDescriptor descriptor) throws IOException, SAXException {
BundleDescriptor bundleDescriptor = BundleDescriptor.class.cast(super.open(main, archive, descriptor));
if (bundleDescriptor != null) {
return bundleDescriptor.getWebServices();
} else if (descriptor instanceof BundleDescriptor) {
return BundleDescriptor.class.cast(descriptor).getWebServices();
} else {
throw new IllegalArgumentException("" + descriptor + " is not instance of BundleDescriptor");
}
}
@Override
public RootDeploymentDescriptor getDefaultDescriptor() {
return new WebServicesDescriptor();
}
/**
* writes the deployment descriptors (standard and runtime)
* to a JarFile using the right deployment descriptor path
*
* @param in the input archive
* @param out the abstract archive file to write to
*/
@Override
public void writeDeploymentDescriptors(Archivist main, BundleDescriptor descriptor, ReadableArchive in, WritableArchive out) throws IOException {
if (descriptor.hasWebServices()) {
super.writeDeploymentDescriptors(main, descriptor, in, out);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy