<commit_before>/*
 * JBoss, Home of Professional Open Source
 * Copyright 2009, Red Hat Middleware LLC, and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jboss.as.arquillian.container.common;

import java.util.jar.Manifest;

import org.jboss.arquillian.osgi.OSGiApplicationArchiveProcessor;
import org.jboss.arquillian.spi.ApplicationArchiveProcessor;
import org.jboss.arquillian.spi.TestClass;
import org.jboss.arquillian.testenricher.osgi.OSGiTestEnricher;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.shrinkwrap.api.Archive;

/**
 * An {@link ApplicationArchiveProcessor} that delegates to deployment type specific packagers.
 *
 * @author <EMAIL>
 * @author <NAME>
 * @since 17-Nov-2010
 */
public class DelegatingApplicationArchiveProcessor implements ApplicationArchiveProcessor {

    @Override
    public void process(Archive<?> appArchive, TestClass testClass) {

        ApplicationArchiveProcessor archiveProcessor = null;
        if (isBundleArchive(testClass, appArchive))
            archiveProcessor = new OSGiApplicationArchiveProcessor();
        else
            archiveProcessor = new ModuleApplicationArchiveProcessor();

        archiveProcessor.process(appArchive, testClass);
    }

    private boolean isBundleArchive(TestClass testClass, Archive<?> appArchive) {

        // Check if the test class is a valid OSGi injection target
        if (OSGiTestEnricher.isInjectionTarget(testClass.getJavaClass()))
            return true;

        // Check if the archive contains a valid OSGi manifest
        Manifest manifest = ManifestUtils.getOrCreateManifest(appArchive);
        if (BundleInfo.isValidateBundleManifest(manifest))
            return true;

        return false;
    }
}
<commit_msg>[JBAS-8900] Arquillian embedded container return after partial server startup<commit_after>/*
 * JBoss, Home of Professional Open Source
 * Copyright 2009, Red Hat Middleware LLC, and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jboss.as.arquillian.container.common;

import java.util.jar.Manifest;

import org.jboss.arquillian.osgi.OSGiApplicationArchiveProcessor;
import org.jboss.arquillian.spi.ApplicationArchiveProcessor;
import org.jboss.arquillian.spi.TestClass;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.shrinkwrap.api.Archive;

/**
 * An {@link ApplicationArchiveProcessor} that delegates to deployment type specific packagers.
 *
 * @author <EMAIL>
 * @author <NAME>
 * @since 17-Nov-2010
 */
public class DelegatingApplicationArchiveProcessor implements ApplicationArchiveProcessor {

    @Override
    public void process(Archive<?> appArchive, TestClass testClass) {

        ApplicationArchiveProcessor archiveProcessor = null;
        if (isBundleArchive(testClass, appArchive))
            archiveProcessor = new OSGiApplicationArchiveProcessor();
        else
            archiveProcessor = new ModuleApplicationArchiveProcessor();

        archiveProcessor.process(appArchive, testClass);
    }

    private boolean isBundleArchive(TestClass testClass, Archive<?> appArchive) {
        // Check if the archive contains a valid OSGi manifest
        Manifest manifest = ManifestUtils.getOrCreateManifest(appArchive);
        if (BundleInfo.isValidateBundleManifest(manifest))
            return true;

        return false;
    }
}

{'fraction_non_alphanumeric': 0.07530837481064705, 'fraction_numerical': 0.006924908028565245, 'mean_word_length': 3.9859762675296655, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5941916', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1160, 'n_words': 409}