List of usage examples for java.lang Class getCanonicalName
public String getCanonicalName()
From source file:com.reversemind.hypergate.example.spring.TestBuildServerFromSpringContext.java
@Test public void testSpringContext() throws InterruptedException { ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/hypergate-server-context.xml"); IPayloadProcessor payloadProcessor = (IPayloadProcessor) context.getBean("serverPayloadProcessor"); Map<Class, Class> map = payloadProcessor.getPojoMap(); Set<Class> set = map.keySet(); for (Class clazz : set) { LOG.debug(clazz.getCanonicalName() + "|" + map.get(clazz).getCanonicalName()); }//from www . j a v a2 s . c om ServerFactory.Builder serverBuilder = (ServerFactory.Builder) context .getBean("simpleHyperGateServerBuilder"); assertNotNull(serverBuilder); LOG.info("serverBuilder: " + serverBuilder); IHyperGateServer hyperGateServer = serverBuilder.build(); assertNotNull(hyperGateServer); hyperGateServer.start(); Thread.sleep(1000); hyperGateServer.shutdown(); assertTrue(!hyperGateServer.isRunning()); }
From source file:org.fcrepo.transform.http.responses.JsonObjectProvider.java
@Override public ObjectMapper getContext(final Class<?> aClass) { LOGGER.debug("Object mapping for: {}", aClass.getCanonicalName()); return defaultObjectMapper; }
From source file:com.graphaware.importer.domain.Neo4jPropertyContainer.java
private synchronized void initializeForClass(Class<?> clazz) { if (CACHE.containsKey(clazz.getCanonicalName())) { return;/* ww w . j a va 2 s . c o m*/ } Set<Pair<Field, String>> fieldsAndNames = new HashSet<>(); for (Field field : ReflectionUtils.getAllFields(clazz)) { Neo4jProperty annotation = field.getAnnotation(Neo4jProperty.class); if (annotation == null) { continue; } String fieldName = StringUtils.isEmpty(annotation.name()) ? field.getName() : annotation.name(); fieldsAndNames.add(new Pair<>(field, fieldName)); field.setAccessible(true); } CACHE.put(clazz.getCanonicalName(), fieldsAndNames); }
From source file:com.netflix.simianarmy.aws.SimpleDBRecorder.java
/** * Value to enum. Converts a "name|type" string back to an enum. * * @param value//from www.ja va 2s . com * the value * @return the enum */ private static <T extends NamedType> T valueToEnum(Class<T> type, String value) { // parts = [enum value, enum class type] String[] parts = value.split("\\|", 2); if (parts.length < 2) { throw new RuntimeException("value " + value + " does not appear to be an internal enum format"); } Class<?> enumClass; try { enumClass = Class.forName(parts[1]); } catch (ClassNotFoundException e) { throw new RuntimeException("class for enum value " + value + " not found"); } if (!enumClass.isEnum()) { throw new RuntimeException("value " + value + " does not appear to be of an enum type"); } if (!type.isAssignableFrom(enumClass)) { throw new RuntimeException("value " + value + " cannot be assigned to a variable of this type: " + type.getCanonicalName()); } @SuppressWarnings("rawtypes") Class<? extends Enum> enumType = enumClass.asSubclass(Enum.class); @SuppressWarnings("unchecked") T enumValue = (T) Enum.valueOf(enumType, parts[0]); return enumValue; }
From source file:org.jacpfx.vertx.spring.VerticleBeanDefinition.java
public VerticleBeanDefinition(Class<?> currentSpringVerticleClass) { this.setBeanClass(currentSpringVerticleClass); this.setBeanClassName(currentSpringVerticleClass.getCanonicalName()); this.setDescription("Bean for the verticle class {" + currentSpringVerticleClass + "}"); }
From source file:com.delphix.session.module.rmi.impl.RmiMethodOrdering.java
public RmiMethodOrdering(Class<?> clazz) { Map<String, Method> methodMap = Maps.newHashMap(); for (Method m : clazz.getMethods()) { List<String> paramNames = Lists.newArrayList(); for (Class<?> paramType : m.getParameterTypes()) { paramNames.add(paramType.getCanonicalName()); }/* ww w.j av a 2s . co m*/ String str = String.format("%s(%s)", m.getName(), StringUtils.join(paramNames, ", ")); methodMap.put(str, m); } List<String> sortedNames = new ArrayList<String>(methodMap.keySet()); Collections.sort(sortedNames); for (String name : sortedNames) { Method m = methodMap.get(name); placement.put(m, methods.size()); methods.add(m); } }
From source file:com.mothsoft.alexis.dao.SourceDaoImpl.java
@SuppressWarnings("unchecked") public List<Source> list(Class<? extends Source> restrictionClass) { final String className = restrictionClass.getCanonicalName(); final List<Source> sources = this.em.createQuery("FROM " + className + " ORDER BY id ASC").getResultList(); return sources; }
From source file:io.fabric8.cxf.endpoint.JsonSchemaLookup.java
public String getSchemaForClass(Class<?> clazz) { LOG.info("Looking up schema for " + clazz.getCanonicalName()); String name = clazz.getName(); try {//from www. java2 s.c om ObjectWriter writer = mapper.writer().with(new FourSpacePrettyPrinter()); JsonSchemaGenerator jsg = new JsonSchemaGenerator(mapper); JsonSchema jsonSchema = jsg.generateSchema(clazz); return writer.writeValueAsString(jsonSchema); } catch (Exception e) { LOG.log(Level.FINEST, "Failed to generate JSON schema for class " + name, e); return ""; } }
From source file:com.mothsoft.alexis.dao.SourceDaoImpl.java
@SuppressWarnings("unchecked") public List<Source> listSourcesByOwner(Long userId, Class<? extends Source> restrictionClass) { final String className = restrictionClass.getCanonicalName(); final List<Source> sources = this.em .createQuery("FROM " + className + " s WHERE s.userId = :userId ORDER BY id ASC") .setParameter("userId", userId).getResultList(); return sources; }
From source file:com.googlecode.android_scripting.rpc.MethodDescriptor.java
@SuppressWarnings("rawtypes") private static Converter<?> converterFor(Type parameterType, Class<? extends Converter> converterClass) { if (converterClass == Converter.class) { Converter<?> converter = sConverters.get(parameterType); if (converter == null) { throw new IllegalArgumentException("No predefined converter found for " + parameterType); }//from w ww . j a v a 2s. c o m return converter; } try { Constructor<?> constructor = converterClass.getConstructor(new Class<?>[0]); return (Converter<?>) constructor.newInstance(new Object[0]); } catch (Exception e) { throw new IllegalArgumentException("Cannot create converter from " + converterClass.getCanonicalName()); } }