List of usage examples for java.lang Class getCanonicalName
public String getCanonicalName()
From source file:info.archinnov.achilles.internal.metadata.discovery.AchillesBootstrapper.java
public void addInterceptorsToEntityMetas(List<Interceptor<?>> interceptors, Map<Class<?>, EntityMeta> entityMetaMap) { for (Interceptor<?> interceptor : interceptors) { Class<?> entityClass = propertyParser.inferEntityClassFromInterceptor(interceptor); EntityMeta entityMeta = entityMetaMap.get(entityClass); Validator.validateBeanMappingTrue(entityMeta != null, "The entity class '%s' is not found", entityClass.getCanonicalName()); entityMeta.addInterceptor(interceptor); }/*from www. j a va 2 s.c o m*/ }
From source file:org.apache.drill.common.util.AbstractDynamicBean.java
public <T> T getWith(Class<T> c) { try {/*from w w w. j ava 2 s .c om*/ return getMapper().treeToValue(objectNode, c); } catch (JsonProcessingException e) { throw new LogicalPlanParsingException( String.format("Failure while trying to convert late bound json type to type of %s.", c.getCanonicalName()), e); } }
From source file:info.archinnov.achilles.entity.parsing.PropertyParser.java
private EmbeddedIdProperties extractEmbeddedIdProperties(Class<?> keyClass) { log.trace("Parsing compound key class", keyClass.getCanonicalName()); EmbeddedIdProperties embeddedIdProperties = null; embeddedIdProperties = compoundKeyParser.parseEmbeddedId(keyClass); log.trace("Built compound key properties", embeddedIdProperties); return embeddedIdProperties; }
From source file:com.threewks.thundr.jrebel.ThundrJRebelPlugin.java
@SuppressWarnings("unchecked") private void registerListener() { // Set up the reload listener final Set<String> watchedClasses = loadWatchedClassList(); ReloaderFactory.getInstance().addClassReloadListener(new ClassEventListener() { @Override/*from ww w .j a v a2s . co m*/ public void onClassEvent(int eventType, Class klass) { try { Class applicationModuleClass = Class.forName(BaseModuleClassName); if (applicationModuleClass.isAssignableFrom(klass) || watchedClasses.contains(klass.getCanonicalName())) { Logger.info("%s was modified. InjectionContext will be reloaded on next request...", klass.getCanonicalName()); ThundrServletReloader.markDirty(); } } catch (Exception e) { Logger.error("Error marking ApplicationModule for reloading: %s", ExceptionUtils.getStackTrace(e)); } } @Override public int priority() { return 0; } }); }
From source file:hu.bme.mit.sette.tools.jpet.JPetRunner.java
@Override protected void runOne(Snippet snippet, File infoFile, File outputFile, File errorFile) throws IOException, SetteConfigurationException { // TODO extract, make more clear File pet = getTool().getPetExecutable(); File testCaseXml = getTool().getTestCaseXmlFile(getRunnerProjectSettings(), snippet); FileUtils.forceMkdir(testCaseXml.getParentFile()); StringBuilder jPetName = new StringBuilder(); jPetName.append(JavaFileUtils.packageNameToFilename(snippet.getContainer().getJavaClass().getName())); jPetName.append('.'); jPetName.append(snippet.getMethod().getName()); // params//from w w w . j a v a 2 s.co m jPetName.append('('); for (Class<?> param : snippet.getMethod().getParameterTypes()) { System.err.println(param.getName() + "-" + param.getCanonicalName()); jPetName.append(JPetTypeConverter.fromJava(param)); } jPetName.append(')'); // return type System.err.println(snippet.getMethod().getReturnType().getName() + "-" + snippet.getMethod().getReturnType().getCanonicalName()); jPetName.append(JPetTypeConverter.fromJava(snippet.getMethod().getReturnType())); // TODO better way to create command // create command List<String> cmd = new ArrayList<>(); cmd.add(pet.getAbsolutePath()); cmd.add(jPetName.toString()); cmd.add("-cp"); cmd.add("build"); cmd.add("-c"); cmd.add("bck"); cmd.add("10"); cmd.add("-td"); cmd.add("num"); cmd.add("-d"); cmd.add("-100000"); cmd.add("100000"); cmd.add("-l"); cmd.add("ff"); cmd.add("-v"); cmd.add("2"); cmd.add("-w"); cmd.add("-tr"); cmd.add("statements"); cmd.add("-cc"); cmd.add("yes"); cmd.add("-xml"); cmd.add(testCaseXml.getCanonicalPath()); System.out.println(" command: " + StringUtils.join(cmd, ' ')); // run process ProcessRunner pr = new ProcessRunner(); pr.setCommand(cmd); ; pr.setWorkingDirectory(getRunnerProjectSettings().getBaseDirectory()); pr.setTimeoutInMs(getTimeoutInMs()); pr.setPollIntervalInMs(RunnerProjectRunner.POLL_INTERVAL); OutputWriter l = new OutputWriter(cmd.toString(), infoFile, outputFile, errorFile); pr.addListener(l); pr.execute(); }
From source file:info.archinnov.achilles.internal.metadata.parsing.EmbeddedIdParser.java
private Integer extractReversedClusteredKey(Class<?> embeddedIdClass) { log.debug("Extract reversed clustering component from embedded id class {} ", embeddedIdClass.getCanonicalName()); @SuppressWarnings("unchecked") Set<Field> candidateFields = getFields(embeddedIdClass, ReflectionUtils.<Field>withAnnotation(Order.class)); List<Integer> reversedFields = new LinkedList<Integer>(); for (Field candidateField : candidateFields) { Order orderAnnotation = candidateField.getAnnotation(Order.class); if (orderAnnotation.reversed()) { reversedFields.add(orderAnnotation.value()); }//from www . j a v a2 s.c o m } Validator.validateBeanMappingTrue(reversedFields.size() <= 1, "There should be at most 1 field annotated with @Order(reversed=true) for the @EmbeddedId class '%s'", embeddedIdClass.getCanonicalName()); return reversedFields.size() > 0 ? reversedFields.get(0) : null; }
From source file:info.archinnov.achilles.helper.EntityIntrospector.java
public Field getInheritedPrivateFields(Class<?> type, Class<?> annotation, String name) { log.debug("Find private field with name {} having annotation {} from hierarchy for entity class {}", name, annotation.getCanonicalName(), type.getCanonicalName()); Class<?> i = type;/*from www . jav a 2 s . c o m*/ while (i != null && i != Object.class) { for (Field declaredField : i.getDeclaredFields()) { if (filter.matches(declaredField, annotation, name)) { log.trace("Found inherited private field : {}", declaredField); return declaredField; } } i = i.getSuperclass(); } return null; }
From source file:com.mmnaseri.dragonfly.runtime.session.impl.AbstractSessionPreparator.java
private void registerEntities(Collection<SessionInitializationEventHandler> eventHandlers) { log.info("Finding entity classes ..."); final List<Class> entityClasses = new ArrayList<Class>(); for (LookupSource source : entityDefinitionSources) { Collections.addAll(entityClasses, source.getClasses(basePackages)); }/*from ww w . j a v a 2 s . c o m*/ for (SessionInitializationEventHandler eventHandler : eventHandlers) { eventHandler.beforeRegisteringEntities(entityDefinitionContext, entityClasses); } for (Class entityClass : entityClasses) { log.debug("Registering entity " + entityClass.getCanonicalName()); //noinspection unchecked final ImmutableEntityDefinition<Object> entityDefinition = new ImmutableEntityDefinition<Object>( entityClass, Collections.<Class<?>, Class<?>>emptyMap()); for (SessionInitializationEventHandler eventHandler : eventHandlers) { eventHandler.beforeRegisteringEntity(entityDefinitionContext, entityDefinition); } entityDefinitionContext.addDefinition(entityDefinition); for (SessionInitializationEventHandler eventHandler : eventHandlers) { eventHandler.afterRegisteringEntity(entityDefinitionContext, entityDefinition); } } for (SessionInitializationEventHandler eventHandler : eventHandlers) { eventHandler.afterRegisteringEntities(entityDefinitionContext, entityClasses); } }
From source file:org.createnet.raptor.auth.service.services.AclManagerService.java
@Override public <T> boolean isPermissionGranted(Class<T> clazz, Serializable identifier, Sid sid, Permission permission) {//from www .ja v a 2 s. c om ObjectIdentity identity = new ObjectIdentityImpl(clazz.getCanonicalName(), identifier); MutableAcl acl = (MutableAcl) aclService.readAclById(identity); boolean isGranted = false; try { log.debug("Check if {} can {} on {}:{}", sid, RaptorPermission.toLabel(permission), clazz, identifier); isGranted = acl.isGranted(Arrays.asList(permission), Arrays.asList(sid), false); log.debug("{} {}ALLOWED {} on {}:{}", sid, (isGranted ? "" : "NOT "), RaptorPermission.toLabel(permission), clazz, identifier); } catch (NotFoundException e) { log.info("Unable to find an ACE for {} on {}:{} - {}", RaptorPermission.toLabel(permission), clazz, identifier, e.getMessage()); } catch (UnloadedSidException e) { log.error("Unloaded Sid for {} on {}:{} - {}", RaptorPermission.toLabel(permission), clazz, identifier, e.getMessage(), e); } return isGranted; }
From source file:de.matzefratze123.heavyspleef.core.FlagManager.java
public void addFlag(AbstractFlag<?> flag) { Class<?> clazz = flag.getClass(); Validate.isTrue(clazz.isAnnotationPresent(Flag.class), "Flag class " + clazz.getCanonicalName() + " must annotate " + Flag.class.getCanonicalName()); Flag flagAnnotation = clazz.getAnnotation(Flag.class); //Generate the full path StringBuilder pathBuilder = new StringBuilder(); Flag lastParentFlagData = flagAnnotation; while (lastParentFlagData != null) { pathBuilder.insert(0, lastParentFlagData.name()); Class<? extends AbstractFlag<?>> parentClass = lastParentFlagData.parent(); lastParentFlagData = parentClass.getAnnotation(Flag.class); if (lastParentFlagData != null) { pathBuilder.insert(0, ":"); }//from w w w. java 2 s . c o m } String path = pathBuilder.toString(); if (flags.containsKey(path)) { return; } flags.put(path, flag); if (clazz.isAnnotationPresent(BukkitListener.class)) { Bukkit.getPluginManager().registerEvents(flag, plugin); } if (flagAnnotation.hasGameProperties()) { Map<GameProperty, Object> flagGamePropertiesMap = new EnumMap<GameProperty, Object>(GameProperty.class); flag.defineGameProperties(flagGamePropertiesMap); if (!flagGamePropertiesMap.isEmpty()) { GamePropertyBundle properties = new GamePropertyBundle(flag, flagGamePropertiesMap); propertyBundles.add(properties); } } }