Java Class.getName Examples

Java Class.getName - 30 examples found. These are the top rated real world Java examples of Class.getName extracted from open source projects. You can rate examples to help us improve the quality of examples.
    @Override
    protected void generateCreateInsns(MethodVisitor mv) {
      if (this.getObjectModelMetadata().getMode() == ObjectModelMode.REFERENCE) {
        Label defaultImplLabel = new Label();
        Class<?> objectModelProxyClass =
            HibernateObjectModelFactoryProvider.this.generateObjectModelProxy(
                this.getObjectModelMetadata().getObjectModelClass());

        mv.visitVarInsn(Opcodes.ALOAD, 1);
        mv.visitTypeInsn(Opcodes.INSTANCEOF, HIBERNATE_PROXY_INTERNAL_NAME);
        mv.visitJumpInsn(Opcodes.IFEQ, defaultImplLabel);

        mv.visitTypeInsn(Opcodes.NEW, objectModelProxyClass.getName().replace('.', '/'));
        mv.visitInsn(Opcodes.DUP);
        mv.visitVarInsn(Opcodes.ALOAD, 0);
        mv.visitVarInsn(Opcodes.ALOAD, 1);
        mv.visitTypeInsn(Opcodes.CHECKCAST, HIBERNATE_PROXY_INTERNAL_NAME);

        mv.visitMethodInsn(
            Opcodes.INVOKESPECIAL,
            objectModelProxyClass.getName().replace('.', '/'),
            "<init>",
            '(' + ASM.getDescriptor(ObjectModelFactory.class) + HIBERNATE_PROXY_DESC + ")V",
            false);
        mv.visitInsn(Opcodes.ARETURN);

        mv.visitLabel(defaultImplLabel);
      }
      super.generateCreateInsns(mv);
    }
  public SearchableCacheConfiguration(
      Class<?>[] classArray,
      Properties properties,
      EmbeddedCacheManager uninitializedCacheManager,
      ComponentRegistry cr) {
    this.providedServices = initializeProvidedServices(uninitializedCacheManager, cr);
    if (properties == null) {
      this.properties = new Properties();
    } else {
      this.properties = rescopeProperties(properties);
    }

    classes = new HashMap<String, Class<?>>();

    for (Class<?> c : classArray) {
      String classname = c.getName();
      classes.put(classname, c);
    }

    // deal with programmatic mapping:
    searchMapping = SearchMappingBuilder.getSearchMapping(this);

    // if we have a SearchMapping then we can predict at least those entities specified in the
    // mapping
    // and avoid further SearchFactory rebuilds triggered by new entity discovery during cache
    // events
    if (searchMapping != null) {
      Set<Class<?>> mappedEntities = searchMapping.getMappedEntities();
      for (Class<?> entity : mappedEntities) {
        classes.put(entity.getName(), entity);
      }
    }
  }
  /**
   * Returns an instance of the annotation MorphiaDatastore if the morphia configuration is ok.
   *
   * @param application Application
   * @param morphiaClass persistent morphia object
   * @return MorphiaDatastore
   */
  public static MorphiaDatastore getMongoDatastore(Application application, Class<?> morphiaClass) {
    Configuration morphiaEntityConfiguration =
        application.getConfiguration(morphiaClass).subset("morphia");
    if (morphiaEntityConfiguration.isEmpty()) {
      throw SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CONFIGURATION)
          .put("aggregate", morphiaClass.getName());
    }

    String clientName = morphiaEntityConfiguration.getString("clientName");
    if (clientName == null) {
      throw SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CLIENT)
          .put("aggregate", morphiaClass.getName());
    }

    String dbName = morphiaEntityConfiguration.getString("dbName");
    if (dbName == null) {
      throw SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_DATABASE)
          .put("aggregate", morphiaClass.getName())
          .put("clientName", clientName);
    }

    checkMongoClient(application.getConfiguration(), morphiaClass, clientName, dbName);

    return new MorphiaDatastoreImpl(clientName, dbName);
  }
  static TypeParameterMatcher generate(Class<?> type, ClassLoader classLoader) {
    final String className = "io.netty.util.internal.__matchers__." + type.getName() + "Matcher";
    try {
      try {
        return (TypeParameterMatcher) Class.forName(className, true, classLoader).newInstance();
      } catch (Exception e) {
        // Not defined in the specified class loader.
      }

      CtClass c = classPool.getAndRename(NoOpTypeParameterMatcher.class.getName(), className);
      c.setModifiers(c.getModifiers() | Modifier.FINAL);
      c.getDeclaredMethod("match").setBody("{ return $1 instanceof " + type.getName() + "; }");
      byte[] byteCode = c.toBytecode();
      c.detach();
      Method method =
          ClassLoader.class.getDeclaredMethod(
              "defineClass", String.class, byte[].class, int.class, int.class);
      method.setAccessible(true);

      Class<?> generated =
          (Class<?>) method.invoke(classLoader, className, byteCode, 0, byteCode.length);
      logger.debug("Generated: {}", generated.getName());
      return (TypeParameterMatcher) generated.newInstance();
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
  public String constructDN(final T o, final String parentDN) throws LDAPPersistException {
    final String existingDN = getEntryDN(o);
    if (existingDN != null) {
      return existingDN;
    }

    final LinkedHashMap<String, Attribute> attrMap = new LinkedHashMap<String, Attribute>(1);

    for (final FieldInfo i : rdnFields) {
      final Attribute a = i.encode(o, true);
      if (a == null) {
        throw new LDAPPersistException(
            ERR_OBJECT_HANDLER_RDN_FIELD_MISSING_VALUE.get(type.getName(), i.getField().getName()));
      }

      attrMap.put(toLowerCase(i.getAttributeName()), a);
    }

    for (final GetterInfo i : rdnGetters) {
      final Attribute a = i.encode(o);
      if (a == null) {
        throw new LDAPPersistException(
            ERR_OBJECT_HANDLER_RDN_GETTER_MISSING_VALUE.get(
                type.getName(), i.getMethod().getName()));
      }

      attrMap.put(toLowerCase(i.getAttributeName()), a);
    }

    return constructDN(o, parentDN, attrMap);
  }
  @Override
  public Statement apply(Statement statement, FrameworkMethod frameworkMethod, Object target) {

    Method method = frameworkMethod.getMethod();

    Class<?> targetClass = target.getClass();

    NewEnv newEnv = findNewEnv(method, targetClass);

    if ((newEnv == null) || (newEnv.type() == NewEnv.Type.NONE)) {
      return statement;
    }

    if (NewEnv.Type.CLASSLOADER == newEnv.type()) {
      return new RunInNewClassLoaderStatement(
          targetClass.getName(),
          getMethodKeys(targetClass, Before.class),
          method,
          getMethodKeys(targetClass, After.class));
    }

    Builder builder = new Builder();

    builder.setArguments(createArguments(method));
    builder.setBootstrapClassPath(CLASS_PATH);
    builder.setRuntimeClassPath(CLASS_PATH);

    return new RunInNewJVMStatment(
        builder.build(),
        targetClass.getName(),
        getMethodKeys(targetClass, Before.class),
        new MethodKey(method),
        getMethodKeys(targetClass, After.class));
  }