Refine search
/** * The given descriptor was processing during a * cancellation of the job * * @param d The non-null descriptor that was cancelled */ public WasCancelledException(Descriptor d) { super("A run-level service with name \"" + ((d.getName() == null) ? "" : d.getName()) + "\" and implementation " + d.getImplementation() + " was cancelled"); }
@Override public Map<String, List<String>> getMetadata() { return baseDescriptor.getMetadata(); }
@Override public DescriptorType getDescriptorType() { return baseDescriptor.getDescriptorType(); }
@Override public boolean matches(Descriptor d) { if (d.getQualifiers().contains(InjectionTarget.class.getName())) { List<String> list = d.getMetadata().get("target"); if (list != null && list.get(0).equals(targetName)) { return true; } } return false; } }
name = copyMe.getName(); scope = copyMe.getScope(); implementation = copyMe.getImplementation(); descriptorType = copyMe.getDescriptorType(); descriptorVisibility = copyMe.getDescriptorVisibility(); loader = copyMe.getLoader(); rank = copyMe.getRanking(); proxiable = copyMe.isProxiable(); proxyForSameScope = copyMe.isProxyForSameScope(); id = copyMe.getServiceId(); locatorId = copyMe.getLocatorId(); analysisName = copyMe.getClassAnalysisName(); if (copyMe.getAdvertisedContracts() != null && !copyMe.getAdvertisedContracts().isEmpty()) { contracts = new LinkedHashSet<String>(); contracts.addAll(copyMe.getAdvertisedContracts()); if (copyMe.getQualifiers() != null && !copyMe.getQualifiers().isEmpty()) { qualifiers = new LinkedHashSet<String>(); qualifiers.addAll(copyMe.getQualifiers()); if (copyMe.getMetadata() != null && !copyMe.getMetadata().isEmpty()) { metadatas = new LinkedHashMap<String, List<String>>(); metadatas.putAll(ReflectionHelper.deepCopyMetadata(copyMe.getMetadata()));
public boolean equals(Object a) { if (a == null) return false; if (!(a instanceof Descriptor)) return false; Descriptor d = (Descriptor) a; if (!GeneralUtilities.safeEquals(implementation, d.getImplementation())) return false; if (!equalOrderedCollection((contracts == null) ? EMPTY_CONTRACTS_SET : contracts, d.getAdvertisedContracts())) return false; if (!GeneralUtilities.safeEquals(name, d.getName())) return false; if (!GeneralUtilities.safeEquals(scope, d.getScope())) return false; if (!equalOrderedCollection((qualifiers == null) ? EMPTY_QUALIFIER_SET : qualifiers, d.getQualifiers())) return false; if (!GeneralUtilities.safeEquals(descriptorType, d.getDescriptorType())) return false; if (!GeneralUtilities.safeEquals(descriptorVisibility, d.getDescriptorVisibility())) return false; if (!equalMetadata((metadatas == null) ? EMPTY_METADATAS_MAP : metadatas, d.getMetadata())) return false; if (!GeneralUtilities.safeEquals(proxiable, d.isProxiable())) return false; if (!GeneralUtilities.safeEquals(proxyForSameScope, d.isProxyForSameScope())) return false; if (!GeneralUtilities.safeEquals(analysisName, d.getClassAnalysisName())) return false; return true; }
if (locator == null || descriptor == null) throw new IllegalArgumentException(); if (descriptor.getServiceId() != null && descriptor.getLocatorId() != null) { ActiveDescriptor<T> retVal = (ActiveDescriptor<T>) locator.getBestDescriptor( BuilderHelper.createSpecificDescriptorFilter(descriptor)); di = new DescriptorImpl(descriptor); final String name = descriptor.getName(); ActiveDescriptor<T> retVal = (ActiveDescriptor<T>) locator.getBestDescriptor(new IndexedFilter() {
private static void checkDescriptor(Descriptor d) { if (d == null) throw new IllegalArgumentException(); if (d.getImplementation() == null) throw new IllegalArgumentException(); if (d.getAdvertisedContracts() == null) throw new IllegalArgumentException(); if (d.getDescriptorType() == null) throw new IllegalArgumentException(); if (d.getDescriptorVisibility() == null) throw new IllegalArgumentException(); if (d.getMetadata() == null) throw new IllegalArgumentException(); if (d.getQualifiers() == null) throw new IllegalArgumentException(); }
@Provider public class ExceptionMapperFactoryFeature implements Feature { @Override public boolean configure(FeatureContext context) { final ServiceLocator locator = ServiceLocatorProvider.getServiceLocator(context); final Descriptor<?> descriptor = locator.getBestDescriptor(new Filter() { @Override public boolean matches(Descriptor d) { return d.getImplementation().equals(ExceptionMapperFactory.class.getName()); } }); ServiceLocatorUtilities.removeOneDescriptor(locator, descriptor); context.register(new AbstractBinder() { @Override public void configure() { bindAsContract(MyExceptionMapperFactory.class) .to(ExceptionMappers.class) .in(Singleton.class); } }); return true; } }
/* package */ static String getBestContract(Descriptor d) { String impl = d.getImplementation(); Set<String> contracts = d.getAdvertisedContracts(); if (contracts.contains(impl)) return impl; for (String candidate : contracts) { return candidate; } return impl; }
private ImplOnlyKey(Descriptor desc) { impl = desc.getImplementation(); type = desc.getDescriptorType(); hash = impl.hashCode() ^ type.hashCode(); }
List<String> list = descriptor.getMetadata(). get(RunLevel.RUNLEVEL_VAL_META_TAG); active = locator.reifyDescriptor(active);
@Override public void onFailure(final ErrorInformation error) throws MultiException { final String msg; switch (error.getErrorType()) { case FAILURE_TO_REIFY: msg = LocalizationMessages.HK_2_REIFICATION_ERROR( error.getDescriptor().getImplementation(), printStackTrace(error.getAssociatedException())); break; default: msg = LocalizationMessages.HK_2_UNKNOWN_ERROR(printStackTrace(error.getAssociatedException())); break; } try { Errors.warning(error.getInjectee(), msg); } catch (IllegalStateException ex) { Errors.process(new Runnable() { @Override public void run() { Errors.warning(this, LocalizationMessages.HK_2_FAILURE_OUTSIDE_ERROR_SCOPE()); Errors.warning(error.getInjectee(), msg); } }); } }
@Override public boolean matches(Descriptor d) { for (Filter filter : allFilters) { if (filter instanceof IndexedFilter) { IndexedFilter iFilter = (IndexedFilter) filter; String name = iFilter.getName(); if (name != null) { if (!GeneralUtilities.safeEquals(name, d.getName())) continue; } String contract = iFilter.getAdvertisedContract(); if (contract != null) { if (!d.getAdvertisedContracts().contains(contract)) continue; } } if (filter.matches(d)) return true; } return false; }
@Override public boolean matches(Descriptor d) { if (d.getImplementation().equals(impl) && d.getDescriptorType().equals(descriptorImpl.getDescriptorType())) { return true; } return false; }
@Override public boolean matches(Descriptor d) { if (name == null) { if (d.getName() == null) return true; return false; } return true; }
/** * This method creates a filter that will match one and only one descriptor. The passed * in descriptor must have both its serviceID and locatorId filled in, or else this * method will throw an IllegalArgumentException * * @param descriptor The descriptor from which to create a filter * @return A filter to use that will match this descriptor exactly */ public static IndexedFilter createSpecificDescriptorFilter(Descriptor descriptor) { String contract = ServiceLocatorUtilities.getBestContract(descriptor); String name = descriptor.getName(); if (descriptor.getServiceId() == null) { throw new IllegalArgumentException("The descriptor must have a specific service ID"); } if (descriptor.getLocatorId() == null) { throw new IllegalArgumentException("The descriptor must have a specific locator ID"); } return new SpecificFilterImpl(contract, name, descriptor.getServiceId(), descriptor.getLocatorId()); }
@Override public Set<String> getQualifiers() { return baseDescriptor.getQualifiers(); }
@Override public boolean matches(Descriptor d) { String scope = d.getScope(); if (scope == null) return false; if (d.getLocatorId() != locatorId) return false; return Immediate.class.getName().equals(scope); } }
@Override public String getScope() { return baseDescriptor.getScope(); }