List of usage examples for java.lang Class getCanonicalName
public String getCanonicalName()
From source file:com.pentaho.big.data.bundles.impl.shim.common.ShimBridgingClassloaderTest.java
@Test public void testLoadClassFindClass() throws ClassNotFoundException, IOException, KettleFileException { String canonicalName = ShimBridgingClassloader.class.getCanonicalName(); FileObject myFile = KettleVFS.getFileObject("ram://testLoadClassFindClass"); try (FileObject fileObject = myFile) { try (OutputStream outputStream = fileObject.getContent().getOutputStream(false)) { IOUtils.copy(//from w ww . j ava2 s.c o m getClass().getClassLoader().getResourceAsStream(canonicalName.replace(".", "/") + ".class"), outputStream); } String packageName = ShimBridgingClassloader.class.getPackage().getName(); when(bundleWiring.findEntries("/" + packageName.replace(".", "/"), ShimBridgingClassloader.class.getSimpleName() + ".class", 0)) .thenReturn(Arrays.asList(fileObject.getURL())); when(parentClassLoader.loadClass(anyString(), anyBoolean())).thenAnswer(new Answer<Class<?>>() { @Override public Class<?> answer(InvocationOnMock invocation) throws Throwable { Object[] arguments = invocation.getArguments(); return new ShimBridgingClassloader.PublicLoadResolveClassLoader(getClass().getClassLoader()) .loadClass((String) arguments[0], (boolean) arguments[1]); } }); Class<?> shimBridgingClassloaderClass = shimBridgingClassloader.loadClass(canonicalName, true); assertEquals(canonicalName, shimBridgingClassloaderClass.getCanonicalName()); assertEquals(shimBridgingClassloader, shimBridgingClassloaderClass.getClassLoader()); assertEquals(packageName, shimBridgingClassloaderClass.getPackage().getName()); Class<?> shimBridgingClassloaderClass2 = shimBridgingClassloader.loadClass(canonicalName, false); assertEquals(shimBridgingClassloaderClass, shimBridgingClassloaderClass2); } finally { myFile.delete(); } }
From source file:org.apache.drill.common.logical.JSONOptions.java
public <T> T getWith(Class<T> c) { try {/* w w w . j av a 2s. co m*/ //logger.debug("Read tree {}", root); return getMapper().treeToValue(root, c); } catch (JsonProcessingException e) { throw new LogicalPlanParsingException(String.format( "Failure while trying to convert late bound json options to type of %s. Reference was originally located at line %d, column %d.", c.getCanonicalName(), location.getLineNr(), location.getColumnNr()), e); } }
From source file:com.flipkart.foxtrot.core.querystore.actions.spi.AnalyticsLoader.java
@Override public void start() throws Exception { Reflections reflections = new Reflections("com.flipkart.foxtrot", new SubTypesScanner()); Set<Class<? extends Action>> actions = reflections.getSubTypesOf(Action.class); if (actions.isEmpty()) { throw new Exception("No analytics actions found!!"); }//from ww w . j a v a 2s.c o m List<NamedType> types = new ArrayList<>(); for (Class<? extends Action> action : actions) { AnalyticsProvider analyticsProvider = action.getAnnotation(AnalyticsProvider.class); if (null == analyticsProvider.request() || null == analyticsProvider.opcode() || analyticsProvider.opcode().isEmpty() || null == analyticsProvider.response()) { throw new Exception("Invalid annotation on " + action.getCanonicalName()); } if (analyticsProvider.opcode().equalsIgnoreCase("default")) { logger.warn("Action " + action.getCanonicalName() + " does not specify cache token. " + "Using default cache."); } register(new ActionMetadata(analyticsProvider.request(), action, analyticsProvider.cacheable(), analyticsProvider.opcode())); types.add(new NamedType(analyticsProvider.request(), analyticsProvider.opcode())); types.add(new NamedType(analyticsProvider.response(), analyticsProvider.opcode())); logger.info("Registered action: " + action.getCanonicalName()); } objectMapper.getSubtypeResolver().registerSubtypes(types.toArray(new NamedType[types.size()])); }
From source file:info.archinnov.achilles.internal.metadata.holder.PartitionComponents.java
void validatePartitionComponents(String className, Object... partitionComponentsArray) { final List<Class<?>> componentClasses = getComponentClasses(); Validator.validateTrue(isNotEmpty(partitionComponentsArray), "There should be at least one partition key component provided for querying on " + "entity '%s'", className);/* www .j a v a 2 s .c om*/ final List<Object> partitionComponents = asList(partitionComponentsArray); log.trace("Validate partition components {} for slice query on entity class {}", partitionComponents, className); Validator.validateTrue(partitionComponents.size() > 0, "There should be at least one partition key component provided for querying on entity '%s'", className); Validator.validateTrue(partitionComponents.size() <= componentClasses.size(), "The partition key components count should be less or equal to '%s' for querying on entity '%s'", componentClasses.size(), className); for (int i = 0; i < partitionComponents.size(); i++) { Object partitionKeyComponent = partitionComponents.get(i); Validator.validateNotNull(partitionKeyComponent, "The '%sth' partition key component should not be null", i + 1); Class<?> currentPartitionComponentType = partitionKeyComponent.getClass(); Class<?> expectedPartitionComponentType = componentClasses.get(i); Validator.validateTrue(isCompatibleClass(expectedPartitionComponentType, currentPartitionComponentType), "The type '%s' of partition key component '%s' for querying on entity '%s' is not valid. It should be '%s'", currentPartitionComponentType.getCanonicalName(), partitionKeyComponent, className, expectedPartitionComponentType.getCanonicalName()); } }
From source file:org.auraframework.test.source.StringSourceExternalLoader.java
@Override public final <D extends Definition, B extends Definition> DefDescriptor<D> createStringSourceDescriptor( @Nullable String namePrefix, Class<D> defClass, @Nullable DefDescriptor<B> bundle) { Map<String, Object> params = Maps.newHashMap(); params.put("namePrefix", namePrefix); params.put("defClass", defClass.getCanonicalName()); params.put("bundleName", bundle == null ? bundle : bundle.getQualifiedName()); params.put("bundleDefClass", bundle == null ? bundle : bundle.getDefType().getPrimaryInterface().getCanonicalName()); String name = invokeAction(getControllerDescriptor("createStringSourceDescriptor"), params).toString(); return definitionService.getDefDescriptor(name, defClass, bundle); }
From source file:info.archinnov.achilles.internal.metadata.parsing.PropertyParser.java
private EmbeddedIdProperties extractEmbeddedIdProperties(Class<?> keyClass) { log.trace("Parsing compound key class", keyClass.getCanonicalName()); EmbeddedIdProperties embeddedIdProperties; embeddedIdProperties = compoundKeyParser.parseEmbeddedId(keyClass); log.trace("Built compound key properties", embeddedIdProperties); return embeddedIdProperties; }
From source file:com.ebay.erl.mobius.core.mapred.MultiInputsHelpersRepository.java
public void writeToConf(JobConf conf) { Iterator<Entry<Class<? extends InputFormat>, MultiInputsHelper>> entries = this.mapping.entrySet() .iterator();// www . j a v a 2 s . com while (entries.hasNext()) { Entry<Class<? extends InputFormat>, MultiInputsHelper> anEntry = entries.next(); Class<? extends InputFormat> inputFormat = anEntry.getKey(); Class<? extends MultiInputsHelper> helper = anEntry.getValue().getClass(); if (!conf.get("mobius.multi.inputs.helpers", "").isEmpty()) { String others = conf.get("mobius.multi.inputs.helpers"); conf.set("mobius.multi.inputs.helpers", others + "," + inputFormat.getCanonicalName() + ":" + helper.getCanonicalName()); } else { conf.set("mobius.multi.inputs.helpers", inputFormat.getCanonicalName() + ":" + helper.getCanonicalName()); } } }
From source file:ca.uhn.fhir.context.RuntimePrimitiveDatatypeDefinition.java
public RuntimePrimitiveDatatypeDefinition(DatatypeDef theDef, Class<? extends IPrimitiveType<?>> theImplementingClass, boolean theStandardType) { super(theDef.name(), theImplementingClass, theStandardType); String resourceName = theDef.name(); if (isBlank(resourceName)) { throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name: " + theImplementingClass.getCanonicalName()); }/* w ww . j av a 2 s . co m*/ mySpecialization = theDef.isSpecialization(); myProfileOfType = theDef.profileOf(); if (myProfileOfType.equals(IBaseDatatype.class)) { myProfileOfType = null; } determineNativeType(theImplementingClass); }
From source file:ca.uhn.fhir.rest.client.RestfulClientFactory.java
/** * Instantiates a new client instance/*from w w w. j a v a 2s . c o m*/ * * @param theClientType * The client type, which is an interface type to be instantiated * @param theServerBase * The URL of the base for the restful FHIR server to connect to * @return A newly created client * @throws ConfigurationException * If the interface type is not an interface */ @Override public synchronized <T extends IRestfulClient> T newClient(Class<T> theClientType, String theServerBase) { validateConfigured(); if (!theClientType.isInterface()) { throw new ConfigurationException(theClientType.getCanonicalName() + " is not an interface"); } ClientInvocationHandlerFactory invocationHandler = myInvocationHandlers.get(theClientType); if (invocationHandler == null) { IHttpClient httpClient = getHttpClient(theServerBase); invocationHandler = new ClientInvocationHandlerFactory(httpClient, myContext, theServerBase, theClientType); for (Method nextMethod : theClientType.getMethods()) { BaseMethodBinding<?> binding = BaseMethodBinding.bindMethod(nextMethod, myContext, null); invocationHandler.addBinding(nextMethod, binding); } myInvocationHandlers.put(theClientType, invocationHandler); } T proxy = instantiateProxy(theClientType, invocationHandler.newInvocationHandler(this)); return proxy; }
From source file:kina.entity.CellValidator.java
/** * private constructor.// w ww . j a va 2s . c o m */ private CellValidator(java.lang.reflect.Field field) { Class<?>[] types = AnnotationUtils.getGenericTypes(field); Class<? extends AbstractType> clazz = CassandraUtils.validationClass(field); this.validatorClassName = clazz.getCanonicalName(); this.validatorKind = Kind.validatorClassToKind(clazz); cqlTypeName = MAP_JAVA_TYPE_TO_DATA_TYPE_NAME.get(this.validatorClassName); switch (this.validatorKind) { case SET: case LIST: this.validatorTypes = asList(getCollectionInnerType(types[0])); break; case MAP: this.validatorTypes = asList(getCollectionInnerType(types[0]), getCollectionInnerType(types[1])); break; default: } }