if (locator.getBestDescriptor(BuilderHelper.createContractFilter(PROPERTY_GENERATED_INJECTOR_CLASS)) != null) return; descriptionList.add(LEAF); DescriptorImpl injectorDescriptor = BuilderHelper.link(PROPERTY_GENERATED_INJECTOR_CLASS). to(CONFIG_INJECTOR_CLASS). in(Singleton.class.getName()). injectorDescriptor.removeQualifier(Named.class.getName()); injectorDescriptor.setLoader(loader);
private static DescriptorImpl createDescriptor( String typeName, HK2Loader cl, Map<String, List<String>> metadata) { DescriptorImpl retVal = new DescriptorImpl(); retVal.setImplementation(typeName); retVal.addAdvertisedContract(typeName); retVal.setLoader(cl); retVal.setMetadata(metadata); return retVal; }
private static boolean addIfNotThere(ServiceLocator locator, DynamicConfiguration config, DescriptorImpl desc, HK2Loader loader) { IndexedFilter filter = BuilderHelper.createContractFilter(desc.getImplementation()); if (locator.getBestDescriptor(filter) != null) return false; if (loader != null) { desc.setLoader(loader); } config.bind(desc); return true; }
Context<PerThread> perThreadContext = locator.getService((new TypeLiteral<Context<PerThread>>() {}).getType()); if (perThreadContext != null) return; DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class); DynamicConfiguration config = dcs.createDynamicConfiguration(); final DescriptorImpl descriptor = BuilderHelper.link(PerThreadContext.class). to(Context.class). in(Singleton.class.getName()). descriptor.setLoader(new HK2Loader() { @Override public Class<?> loadClass(String className) throws MultiException { config.bind(descriptor, false); config.commit();
if (locator == null) throw new IllegalArgumentException(); DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class); DynamicConfiguration cd = dcs.createDynamicConfiguration(); FactoryDescriptors fds = cd.addActiveFactoryDescriptor((Class<Factory<Object>>) factoryConstant.getClass()); intermediateState.add(fds); cd = dcs.createDynamicConfiguration(); final Factory<?> constant = constants[lcv++]; Descriptor constantDescriptor = BuilderHelper.createConstantDescriptor(constant); Descriptor addProvideMethod = new DescriptorImpl(provideMethod); retVal.add(cd.bind(fdi)); cd.commit();
if (locator == null || descriptor == null) throw new IllegalArgumentException(); DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class); DynamicConfiguration config = dcs.createDynamicConfiguration(); if (descriptor.getLocatorId() != null && descriptor.getServiceId() != null) { Filter destructionFilter = BuilderHelper.createSpecificDescriptorFilter(descriptor); config.addUnbindFilter(destructionFilter); List<ActiveDescriptor<?>> goingToDie = locator.getDescriptors(destructionFilter); if (!goingToDie.isEmpty()) { AliasFilter af = new AliasFilter(goingToDie); config.addUnbindFilter(af); config.commit(); di = new DescriptorImpl(descriptor); List<ActiveDescriptor<?>> goingToDie = locator.getDescriptors(destructionFilter); if (!goingToDie.isEmpty()) { AliasFilter af = new AliasFilter(goingToDie);
fileFinder = serviceLocator.getService(DescriptorFileFinder.class); if (fileFinder == null) return descriptors; DynamicConfiguration config = dcs.createDynamicConfiguration(); DescriptorImpl descriptorImpl = new DescriptorImpl(); readOne = descriptorImpl.readObject(br); descriptors.add(config.bind(descriptorImpl, false)); config.commit();
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() {
Set<String> contracts = descriptorImpl.getAdvertisedContracts(); String contract = null; for (String candidate : contracts) { if (candidate.equals(descriptorImpl.getImplementation())) { final String fName = descriptorImpl.getName(); final DescriptorImpl fDescriptorImpl = descriptorImpl; if (serviceLocator.getBestDescriptor(new IndexedFilter() {
descriptors.add(new DescriptorImpl(d)); for (Descriptor descriptor : descriptors) { DescriptorImpl di = (descriptor instanceof DescriptorImpl) ? (DescriptorImpl) descriptor : new DescriptorImpl(descriptor) ; activeDescriptors.add(dcs.bind(descriptorImpl, false)); dcs.commit();
private void parseInHk2LocatorOrig(BufferedReader reader, Map<String, String> cliCommandNames) throws IOException { DescriptorImpl desc = new DescriptorImpl(); while (desc.readObject(reader)) { if (StringUtils.ok(desc.getName()) && desc.getAdvertisedContracts().contains(CLICommand.class.getName())) { cliCommandNames.put(desc.getName(), desc.getImplementation()); } } }
private DescriptorImpl implementationOnly(ServiceLocator serviceLocator, final DescriptorImpl descriptorImpl) { final String impl = descriptorImpl.getImplementation(); if (impl == null) return descriptorImpl; ImplOnlyKey key = new ImplOnlyKey(descriptorImpl); if (implOnlyDupSet.contains(key)) { return null; } implOnlyDupSet.add(key); if (serviceLocator.getBestDescriptor(new Filter() { @Override public boolean matches(Descriptor d) { if (d.getImplementation().equals(impl) && d.getDescriptorType().equals(descriptorImpl.getDescriptorType())) { return true; } return false; } }) != null) { return null; } return descriptorImpl; }
/** * Makes a deep copy of the incoming descriptor * * @param copyMe The descriptor to copy * @return A new descriptor with all fields copied */ public static DescriptorImpl deepCopyDescriptor(Descriptor copyMe) { return new DescriptorImpl(copyMe); }
descriptorImpl.getImplementation())) { skip = true; descriptorImpl.getImplementation()) || "com.sun.enterprise.server.logging.LogManagerService".equals( descriptorImpl.getImplementation()) || "com.sun.enterprise.v3.admin.PrivateAdminAdapter".equals( descriptorImpl.getImplementation())) { skip = true; descriptorImpl.getImplementation())) { descriptorImpl.setImplementation("org.glassfish.kernel.embedded.EmbeddedDomainXml"); descriptorImpl.setScope(PerLookup.class.getCanonicalName()); } else if ("com.sun.enterprise.v3.server.DomainXmlPersistence".equals( descriptorImpl.getImplementation())) { descriptorImpl.setImplementation("org.glassfish.kernel.embedded.EmbeddedDomainPersistence"); descriptorImpl.setScope(PerLookup.class.getCanonicalName()); } else if ("org.glassfish.web.deployment.archivist.WebArchivist".equals(descriptorImpl.getImplementation())) { descriptorImpl.setImplementation("org.glassfish.web.embed.impl.EmbeddedWebArchivist"); descriptorImpl.setScope(PerLookup.class.getCanonicalName()); } else if ("org.glassfish.web.WebEntityResolver".equals(descriptorImpl.getImplementation())) { descriptorImpl.setImplementation("org.glassfish.web.embed.impl.EmbeddedWebEntityResolver"); descriptorImpl.setScope(PerLookup.class.getCanonicalName());
DescriptorImpl descriptorImpl = new DescriptorImpl(); readOne = descriptorImpl.readObject(br);
/** * Uses the given classloader to load the class from the descriptor */ @Override public DescriptorImpl process(ServiceLocator serviceLocator, DescriptorImpl descriptorImpl) { descriptorImpl.setLoader(hk2Loader); return descriptorImpl; }
@Override public DescriptorImpl process(ServiceLocator serviceLocator, DescriptorImpl descriptorImpl) { descriptorImpl.setLoader(loader); descriptorImpl.addMetadata(BUNDLE_SYMBOLIC_NAME,osgiModule.getBundle().getSymbolicName()); descriptorImpl.addMetadata(BUNDLE_VERSION, osgiModule.getBundle().getVersion().toString()); return descriptorImpl; } }
descriptorImpl.getImplementation())) { skip = true; descriptorImpl.getImplementation()) || LogManagerService.class.getCanonicalName().equals( descriptorImpl.getImplementation()) || PrivateAdminAdapter.class.getCanonicalName().equals( descriptorImpl.getImplementation())) { skip = true; descriptorImpl.getImplementation())) { descriptorImpl.setImplementation(EmbeddedDomainXml.class .getCanonicalName()); descriptorImpl.getImplementation())) { descriptorImpl.setImplementation(EmbeddedDomainPersistence.class .getCanonicalName());