Example usage for java.lang Class getCanonicalName

List of usage examples for java.lang Class getCanonicalName

Introduction

In this page you can find the example usage for java.lang Class getCanonicalName.

Prototype

public String getCanonicalName() 

Source Link

Document

Returns the canonical name of the underlying class as defined by the Java Language Specification.

Usage

From source file:com.skcraft.launcher.builder.PackageBuilder.java

private <V> V read(File path, Class<V> clazz) throws IOException {
    try {/*from  ww w .  j  av  a 2s .c o  m*/
        if (path == null) {
            return clazz.newInstance();
        } else {
            return mapper.readValue(path, clazz);
        }
    } catch (InstantiationException e) {
        throw new IOException("Failed to create " + clazz.getCanonicalName(), e);
    } catch (IllegalAccessException e) {
        throw new IOException("Failed to create " + clazz.getCanonicalName(), e);
    }
}

From source file:de.fischer.thotti.core.configuration.ConfigDenormalizer.java

private String getFQCNFromHolder(ThottiAnnotationHolder<NDTest> holder) {
    AnnotatedElement element = holder.getOrigin();

    assert element instanceof Method : "Only methods are currently supported.";

    Method method = (Method) element;

    Class clazz = method.getDeclaringClass();

    assert clazz.isInterface() == false : "Annotation of interfaces is not supported.";

    return clazz.getCanonicalName();
}

From source file:com.scaleoutsoftware.soss.hserver.hadoop.SubmittedJob.java

@Override
public Object call() throws Exception {
    try {//from w  ww.  ja  va 2 s  .  c om
        //Only run if we have splits
        if (inputSplits.size() > 0) {
            synchronized (_lock) {
                if (grid == null) {
                    InvocationGridBuilder gridBuilder = HServerJob.getInvocationGridBuilder(jobID.toString(),
                            jobConf);

                    if (jobConf.getJar() != null) {
                        //File stream will be closed by IG builder
                        Path defaultJar = new Path(jobConf.getJar());
                        gridBuilder.addJar("job.jar", fileSystem.open(defaultJar));
                        LOG.info("Adding a job jar to the IG. Size = "
                                + fileSystem.getFileStatus(defaultJar).getLen());
                    } else {
                        //If we do not have the main JAR, try adding mapper/reducer/combiner
                        for (String property : classLookupCandidateProperties) {
                            Class clazz = jobConf.getClass(property, null);
                            if (clazz != null && !clazz.getCanonicalName().startsWith("org.apache.hadoop")) {
                                gridBuilder.addClass(clazz);
                            }
                        }
                    }

                    //Hive case, multiple IG workers
                    LOG.warn("MAPPER = " + jobConf.get("mapred.mapper.class", ""));
                    if (jobConf.get("mapred.mapper.class", "")
                            .equals("org.apache.hadoop.hive.ql.exec.mr.ExecMapper")) {
                        LOG.warn("Starting IG in Hive mode (multiple worker JVMs).");
                        gridBuilder.setOneWorkerPerCore(true);
                        jobConf.setInt("mapred.hserver.maxslots", 1);
                    }

                    String javaOpts = jobConf.get("mapred.child.java.opts", "");
                    if (javaOpts.length() > 0) {
                        LOG.warn("Parsed child JVM parameters:" + javaOpts);
                        gridBuilder.setJVMParameters(javaOpts);
                    }

                    //Adding libjars
                    addJarsFromConfigurationProperty(gridBuilder, configuration, "tmpjars");

                    grid = gridBuilder.load();
                }
            }
            LOG.info("Reusing invocation grid for MR job.");
            JobScheduler.getInstance().runPredefinedJob(jobID, jobConf, newApi, inputSplits.get(0).getClass(),
                    inputSplits, splitLocations, grid);

        }
        return null;
    } finally {
        //We no longer need staging directory
        fileSystem.delete(jobSubmitDirectoryPath, true);
    }
}

From source file:com.qcadoo.view.internal.CustomMethodHolder.java

private Method getMethod(final Class<?> clazz, final String methodName) {
    try {/*w w  w . j a  v a  2  s .c o  m*/
        return clazz.getMethod(methodName, expectedParameterTypes);
    } catch (SecurityException e) {
        final String msg = String.format(SECURITY_EXCEPTION_MSG, clazz.getCanonicalName(), methodName);
        throw new IllegalStateException(msg, e);
    } catch (NoSuchMethodException e) {
        final String msg = String.format(NO_SUCH_METHOD_MSG, clazz.getCanonicalName(), methodName,
                expectedReturnType, Arrays.toString(expectedParameterTypes));
        throw new IllegalStateException(msg, e);
    }
}

From source file:ch.systemsx.cisd.openbis.generic.shared.RegressionTestCase.java

protected void assertMandatoryMethodAnnotations(Class<?> clazz, String exceptions) {
    List<Class<? extends Annotation>> mandatoryAnnotations = new ArrayList<Class<? extends Annotation>>();
    mandatoryAnnotations.add(RolesAllowed.class);
    mandatoryAnnotations.add(Transactional.class);

    final String noMissingAnnotationsMsg = "Missing annotations in class " + clazz.getCanonicalName() + ":\n";
    StringBuilder problems = new StringBuilder(noMissingAnnotationsMsg);
    for (Method m : clazz.getDeclaredMethods()) {
        List<String> missingAnnotations = new ArrayList<String>();
        for (Class<? extends Annotation> c : mandatoryAnnotations) {
            if (m.getAnnotation(c) == null) {
                missingAnnotations.add(c.getSimpleName());
            }/*  ww w .j  a  v  a  2 s.  c  o m*/
        }
        if (missingAnnotations.size() > 0) {
            problems.append(String.format("%s: %s\n", m.getName(), StringUtils.join(missingAnnotations, ", ")));
        }
    }
    assertEquals(noMissingAnnotationsMsg + exceptions, problems.toString());
}

From source file:com.agileapes.gibbon.value.impl.DefaultValueReaderContext.java

@Override
public <E> E read(String text, final Class<E> type) {
    //        log.info("Reading value of type " + type.getCanonicalName() + " from input: " + text);
    try {/*from   w ww . j a va2  s  .c  o m*/
        return with(getMap().values()).filter(new ValueReaderFilter(type)).first().read(text, type);
    } catch (IndexOutOfBoundsException e) {
        throw new IllegalArgumentException("No value reader for: " + type.getCanonicalName());
    }
}

From source file:harschware.collections.ranges.ValidRange.java

private Sequence<T> getSequence(T newStart) {
    Sequence<T> sequence = null;

    Class<? extends Comparable> startClazz = start.getClass();
    String className = "harschware.collections.sequences." + startClazz.getSimpleName() + "Sequence";
    logger.debug("Sequence strategy '" + className + "' chosen for '" + startClazz.getCanonicalName() + "'");

    try {/*from w w w . java 2  s  . c om*/
        Class clazz = Class.forName(className);

        sequence = (Sequence<T>) clazz.getDeclaredConstructor(startClazz).newInstance(newStart);

    } catch (Exception e) {
        throw new UnsupportedOperationException("No Sequence found for type " + startClazz);
    } // end try/catch
    return sequence;
}

From source file:info.archinnov.achilles.internal.metadata.parsing.EmbeddedIdParser.java

private EmbeddedIdProperties buildComponentMetas(Class<?> embeddedIdClass, Map<Integer, Field> components,
        Integer reversedField) {/*from  w  ww .j a v a 2 s. c  o m*/

    log.debug("Build components meta data for embedded id class {}", embeddedIdClass.getCanonicalName());
    EmbeddedIdPropertiesBuilder partitionKeysBuilder = new EmbeddedIdPropertiesBuilder();
    EmbeddedIdPropertiesBuilder clusteringKeysBuilder = new EmbeddedIdPropertiesBuilder();
    EmbeddedIdPropertiesBuilder embeddedIdPropertiesBuilder = new EmbeddedIdPropertiesBuilder();

    boolean hasPartitionKeyAnnotation = buildPartitionAndClusteringKeys(embeddedIdClass, components,
            reversedField, partitionKeysBuilder, clusteringKeysBuilder, embeddedIdPropertiesBuilder);

    if (!hasPartitionKeyAnnotation) {
        partitionKeysBuilder.addComponentName(clusteringKeysBuilder.removeFirstComponentName());
        partitionKeysBuilder.addComponentClass(clusteringKeysBuilder.removeFirstComponentClass());
        partitionKeysBuilder.addComponentField(clusteringKeysBuilder.removeFirstComponentField());
        partitionKeysBuilder.addComponentGetter(clusteringKeysBuilder.removeFirstComponentGetter());
        partitionKeysBuilder.addComponentSetter(clusteringKeysBuilder.removeFirstComponentSetter());
    }

    return embeddedIdPropertiesBuilder.buildEmbeddedIdProperties(partitionKeysBuilder.buildPartitionKeys(),
            clusteringKeysBuilder.buildClusteringKeys());
}

From source file:info.archinnov.achilles.internal.metadata.holder.PartitionComponents.java

void validatePartitionComponentsIn(String className, Object... partitionComponentsInArray) {
    final List<Class<?>> componentClasses = getComponentClasses();

    Validator.validateTrue(isNotEmpty(partitionComponentsInArray),
            "There should be at least one partition key component IN provided for querying on entity '%s'",
            className);//from w w  w  .  j ava  2  s  .  c om
    final List<Object> partitionComponentsIn = asList(partitionComponentsInArray);

    log.trace("Validate partition components IN {} for slice query on entity class {}", partitionComponentsIn,
            className);

    Class<?> lastPartitionComponentType = componentClasses.get(componentClasses.size() - 1);

    for (int i = 0; i < partitionComponentsIn.size(); i++) {
        Object partitionKeyComponent = partitionComponentsIn.get(i);
        Validator.validateNotNull(partitionKeyComponent,
                "The '%sth' partition key component IN should not be null", i + 1);

        Class<?> currentPartitionComponentType = partitionKeyComponent.getClass();

        Validator.validateTrue(isCompatibleClass(lastPartitionComponentType, 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,
                lastPartitionComponentType.getCanonicalName());
    }
}

From source file:org.mayocat.application.AbstractService.java

@Override
public void run(C configuration, Environment environment) throws Exception {
    configureObjectMapper();/* w  ww.  j av a 2s  . c  o  m*/

    this.initializeComponentManager(configuration, environment);
    registerServletFilters(environment);
    registerProviders(environment);
    registerResources(environment);
    registerEventListeners(environment);
    registerHealthChecks(environment);
    registerTasks(environment);
    registerManagedServices(environment);

    // Default Jersey filters
    addRequestFilter(SessionScopeCookieContainerFilter.class);
    addRequestFilter(FlashScopeCookieContainerFilter.class);
    addRequestFilter(LocalizationContainerFilter.class);
    addRequestFilter(MultitenancyContainerFilter.class);
    addResponseFilter(SessionScopeCookieContainerFilter.class);
    addResponseFilter(FlashScopeCookieContainerFilter.class);
    addResponseFilter(CorsResponseFilter.class);
    addResponseFilter(MayocatFullContextRequestFilter.class);

    // Register Jersey container response filters
    Map<String, Object> jerseyPropertiesAndFeatures = Maps.newHashMap();
    jerseyPropertiesAndFeatures.put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS,
            Joiner.on(",").join(Collections2.transform(this.requestFilters, new Function<Class, String>() {
                public String apply(Class string) {
                    return string.getCanonicalName();
                }
            })));
    jerseyPropertiesAndFeatures.put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS,
            Joiner.on(",").join(Collections2.transform(this.responseFilters, new Function<Class, String>() {
                public String apply(Class string) {
                    return string.getCanonicalName();
                }
            })));

    // Register Jersey container request filters
    environment.jersey().getResourceConfig().setPropertiesAndFeatures(jerseyPropertiesAndFeatures);

    ObservationManager observationManager = getComponentManager().getInstance(ObservationManager.class);
    observationManager.notify(new ApplicationStartedEvent(), this);
}