/** * Ensures that even the non-standard format of metadata from the hk2-config subsystem can * be read from the service in addClasses. addClasses will now read both forms, if the * documented form fails, it'll try the hk2-config form */ @Test public void testAddClassOfInjector() { ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null); List<ActiveDescriptor<?>> added = ServiceLocatorUtilities.addClasses(locator, EjbContainerAvailabilityInjector.class); ActiveDescriptor<?> descriptor = added.get(0); Assert.assertEquals("org.jvnet.hk2.config.test.EjbContainerAvailability", ServiceLocatorUtilities.getOneMetadataField(descriptor, "target")); }
/** * Gets one value from a metadata field from the given service handle * * @param h The non-null service handle from which to get the first value in the given field * @param field The non-null field to get the first value of * @return The first value in the given field, or null if no such field exists in the descriptor */ public static String getOneMetadataField(ServiceHandle<?> h, String field) { return getOneMetadataField(h.getActiveDescriptor(), field); }
/** * Gets one value from a metadata field from the given service handle * * @param h The non-null service handle from which to get the first value in the given field * @param field The non-null field to get the first value of * @return The first value in the given field, or null if no such field exists in the descriptor */ public static String getOneMetadataField(ServiceHandle<?> h, String field) { return getOneMetadataField(h.getActiveDescriptor(), field); }
/** * Gets one value from a metadata field from the given service handle * * @param h The non-null service handle from which to get the first value in the given field * @param field The non-null field to get the first value of * @return The first value in the given field, or null if no such field exists in the descriptor */ public static String getOneMetadataField(ServiceHandle<?> h, String field) { return getOneMetadataField(h.getActiveDescriptor(), field); }
/** * Gets one value from a metadata field from the given service handle * * @param h The non-null service handle from which to get the first value in the given field * @param field The non-null field to get the first value of * @return The first value in the given field, or null if no such field exists in the descriptor */ public static String getOneMetadataField(ServiceHandle<?> h, String field) { return getOneMetadataField(h.getActiveDescriptor(), field); }
/** * Ensures that even the non-standard format of metadata from the hk2-config subsystem can * be read from the service in addClasses. addClasses will now read both forms, if the * documented form fails, it'll try the hk2-config form */ @Test public void testAddClassOfInjector() { ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null); List<ActiveDescriptor<?>> added = ServiceLocatorUtilities.addClasses(locator, EjbContainerAvailabilityInjector.class); ActiveDescriptor<?> descriptor = added.get(0); Assert.assertEquals("org.jvnet.hk2.config.test.EjbContainerAvailability", ServiceLocatorUtilities.getOneMetadataField(descriptor, "target")); }