Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2012-2014 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in com.fitburpliance with the License. You can
* obtain a copy of the License at
* http://glassfish.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle com.fitbursignates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your com.fitburcision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package com.fitbur.glassfish.com.fitbur.model.internal;
import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.NameBinding;
import javax.ws.rs.core.Feature;
import javax.annotation.Priority;
import javax.inject.Scope;
import com.fitbur.glassfish.com.fitbur.Severity;
import com.fitbur.glassfish.com.fitbur.internal.Errors;
import com.fitbur.glassfish.com.fitbur.internal.LocalizationMessages;
import com.fitbur.glassfish.com.fitbur.internal.inject.Providers;
import com.fitbur.glassfish.com.fitbur.internal.util.Producer;
import com.fitbur.glassfish.com.fitbur.model.ContractProvider;
import com.fitbur.glassfish.com.fitbur.process.Inflector;
import com.fitbur.glassfish.hk2.utilities.Binder;
import com.fitbur.repackaged.com.fitbur.google.com.fitburmon.base.Predicate;
import com.fitbur.repackaged.com.fitbur.google.com.fitburmon.base.Predicates;
import com.fitbur.repackaged.com.fitbur.google.com.fitburmon.collect.Maps;
import com.fitbur.repackaged.com.fitbur.google.com.fitburmon.collect.Sets;
/**
* An internal Jersey container for custom com.fitburponent classes and instances.
*
* The com.fitburponent bag can automatically com.fitburpute a {@link ContractProvider contract provider} model
* for the registered com.fitburponent type and stores it with the com.fitburponent registration.
*
* The rules for managing com.fitburponents inside a com.fitburponent bag are com.fitburrived from the
* rules of JAX-RS {@link javax.ws.rs.core.Configurable} API. In short:
*
*
The iteration order of registered com.fitburponents mirrors the registration order
* of these com.fitburponents.
*
There can be only one registration for any given com.fitburponent type.
*
Existing registrations cannot be overridden (any attempt to override
* an existing registration will be rejected).
*
*
*
* @author Marek Potociar (marek.potociar at oracle.com.fitbur)
*/
public class ComponentBag {
/**
* A filtering strategy that excludes all pure meta-provider models (i.e. models that only contain
* recognized meta-provider contracts - {@link javax.ws.rs.core.Feature} and/or {@link com.fitbur.glassfish.hk2.utilities.Binder}).
*
* This filter predicate returns {@code false} for all {@link com.fitbur.glassfish.com.fitbur.model.ContractProvider contract provider models}
* that represent a model containing only recognized meta-provider contracts.
*
*/
public static final Predicate EXCLUDE_META_PROVIDERS = new Predicate() {
@Override
public boolean apply(ContractProvider model) {
final Set> contracts = model.getContracts();
if (contracts.isEmpty()) {
return true;
}
byte count = 0;
if (contracts.contains(Feature.class)) {
count++;
}
if (contracts.contains(Binder.class)) {
count++;
}
return contracts.size() > count;
}
};
/**
* A filtering strategy that includes only models that contain HK2 Binder provider contract.
*
* This filter predicate returns {@code true} for all {@link com.fitbur.glassfish.com.fitbur.model.ContractProvider contract provider models}
* that represent a provider registered to provide HK2 {@link com.fitbur.glassfish.hk2.utilities.Binder} contract.
*
*/
public static final Predicate BINDERS_ONLY = new Predicate() {
@Override
public boolean apply(ContractProvider model) {
return model.getContracts().contains(Binder.class);
}
};
/**
* A filtering strategy that excludes models with no recognized contracts.
*
* This filter predicate returns {@code false} for all {@link com.fitbur.glassfish.com.fitbur.model.ContractProvider contract provider models}
* that are empty, i.e. do not contain any recognized contracts.
*
*/
public static final Predicate EXCLUDE_EMPTY = new Predicate() {
@Override
public boolean apply(ContractProvider model) {
return !model.getContracts().isEmpty();
}
};
/**
* A filtering strategy that accepts any contract provider model.
*
* This filter predicate returns {@code true} for any contract provider model.
*
*/
public static final Predicate INCLUDE_ALL = Predicates.alwaysTrue();
/**
* Contract provider model enhancer that builds a model as is, without any
* modifications.
*/
public static final Inflector AS_IS =
new Inflector() {
@Override
public ContractProvider apply(ContractProvider.Builder builder) {
return builder.build();
}
};
/**
* Contract provider model registration strategy.
*/
private final Predicate registrationStrategy;
/**
* Registered com.fitburponent classes collection and it's immutable view.
*/
private final Set> classes;
private final Set> classesView;
/**
* Registered com.fitburponent instances collection and it's immutable view.
*/
private final Set