Example usage for java.lang.reflect Modifier isAbstract

List of usage examples for java.lang.reflect Modifier isAbstract

Introduction

In this page you can find the example usage for java.lang.reflect Modifier isAbstract.

Prototype

public static boolean isAbstract(int mod) 

Source Link

Document

Return true if the integer argument includes the abstract modifier, false otherwise.

Usage

From source file:org.jgentleframework.integration.remoting.rmi.support.RmiBinderInterceptor.java

@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {

    Remote stub = (Remote) this.binder.getStub();
    MethodInvocation invocation = new BasicMethodInvocation(obj, method, args);
    Object result = null;/*w  w w  .j a v  a2 s  .com*/
    if (Modifier.isAbstract(method.getModifiers())) {
        try {
            result = this.binder.invoke(invocation, stub);
        } catch (InvocationTargetException ex) {
            Throwable targetEx = ex.getTargetException();
            if (targetEx instanceof RemoteException) {
                RemoteException rex = (RemoteException) targetEx;
                throw ExceptionUtils.convertRmiAccessException(invocation.getMethod(), rex,
                        this.binder.isConnectFailure(rex), this.binder.getServiceName());
            } else {
                Throwable exToThrow = ex.getTargetException();
                ExceptionUtils.fillInClientStackTraceIfPossible(exToThrow);
                throw exToThrow;
            }
        } catch (NoSuchMethodException ex) {
            throw new RemoteInvocationException("No matching RMI stub method found for: " + method, ex);
        } catch (RemoteException e) {
            if (this.binder.isConnectFailure(e) && this.binder.isRefreshStubOnConnectFailure()) {
                this.binder.refreshStubAndRetryInvocation(invocation);
            } else {
                throw new RemoteInvocationException("Invocation of method [" + invocation.getMethod()
                        + "] failed in RMI service [" + this.binder.getServiceName() + "]", e);
            }
        } catch (Throwable ex) {
            if (log.isErrorEnabled()) {
                log.error("Invocation of method [" + invocation.getMethod() + "] failed in RMI service ["
                        + this.binder.getServiceName() + "]", ex);
            }
            throw new RemoteInvocationException("Invocation of method [" + invocation.getMethod()
                    + "] failed in RMI service [" + this.binder.getServiceName() + "]", ex);
        }
    }
    return result;
}

From source file:com.comcast.cereal.convert.MapCerealizer.java

private static boolean isInstantiable(Class<?> clazz) {
    boolean abs = Modifier.isAbstract(clazz.getModifiers());
    boolean hasConstuctor = ConstructorUtils.getAccessibleConstructor(clazz, new Class[0]) != null;
    return !clazz.isInterface() && !abs && hasConstuctor;
}

From source file:org.apache.syncope.client.console.init.ImplementationClassNamesLoader.java

@Override
@SuppressWarnings("unchecked")
public void load() {
    previewers = new ArrayList<>();
    extPanels = new ArrayList<>();

    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
            false);/*from www.j a  va  2s.  c  o m*/
    scanner.addIncludeFilter(new AssignableTypeFilter(AbstractBinaryPreviewer.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(AbstractExtensionPanel.class));

    for (BeanDefinition bd : scanner.findCandidateComponents(StringUtils.EMPTY)) {
        try {
            Class<?> clazz = ClassUtils.resolveClassName(bd.getBeanClassName(),
                    ClassUtils.getDefaultClassLoader());
            boolean isAbsractClazz = Modifier.isAbstract(clazz.getModifiers());

            if (AbstractBinaryPreviewer.class.isAssignableFrom(clazz) && !isAbsractClazz) {
                previewers.add((Class<? extends AbstractBinaryPreviewer>) clazz);
            } else if (AbstractExtensionPanel.class.isAssignableFrom(clazz) && !isAbsractClazz) {
                extPanels.add((Class<? extends AbstractExtensionPanel>) clazz);
            }

        } catch (Throwable t) {
            LOG.warn("Could not inspect class {}", bd.getBeanClassName(), t);
        }
    }
    previewers = Collections.unmodifiableList(previewers);
    extPanels = Collections.unmodifiableList(extPanels);

    LOG.debug("Binary previewers found: {}", previewers);
    LOG.debug("Extension panels found: {}", extPanels);
}

From source file:com.github.helenusdriver.driver.impl.UDTClassInfoImpl.java

/**
 * Instantiates a new <code>TypeClassInfoImpl</code> object.
 *
 * @author paouelle/*from  w w w  . j  a  va 2s . co  m*/
 *
 * @param  mgr the non-<code>null</code> statement manager
 * @param  clazz the class of POJO for which to get a class info object for
 * @throws NullPointerException if <code>clazz</code> is <code>null</code>
 * @throws IllegalArgumentException if <code>clazz</code> doesn't represent
 *         a valid POJO class
 */
UDTClassInfoImpl(StatementManagerImpl mgr, Class<T> clazz) {
    super(mgr, clazz, UDTEntity.class);
    org.apache.commons.lang3.Validate.isTrue(!Modifier.isAbstract(clazz.getModifiers()),
            "type entity class '%s', cannot be abstract", clazz.getSimpleName());
    this.name = findName();
}

From source file:com.stehno.sjdbcx.RepositoryFactory.java

@Override
public void afterPropertiesSet() throws Exception {
    Assert.notNull(objectType, MISSING_TYPE_MSG);
    Assert.isTrue(objectType.isAnnotationPresent(JdbcRepository.class),
            String.format(MISSING_ANNOTATION_MSG, objectType));
    Assert.isTrue(objectType.isInterface() || Modifier.isAbstract(objectType.getModifiers()),
            INVALID_CLASS_MSG);/*from w  w  w  . j a  va 2  s . com*/

    if (implementationProviderClass == null) {
        implementationProviderClass = ReflectionImplementationProvider.class;
    }

    super.afterPropertiesSet();
}

From source file:com.github.helenusdriver.driver.impl.TypeClassInfoImpl.java

/**
 * Instantiates a new <code>TypeClassInfoImpl</code> object.
 *
 * @author paouelle/*  www  .  j a v a 2 s.co m*/
 *
 * @param  mgr the non-<code>null</code> statement manager
 * @param  rclazz the class of POJO for the root entity this POJO is a type
 * @param  clazz the class of POJO for which to get a class info object for
 * @throws NullPointerException if <code>clazz</code> is <code>null</code>
 * @throws IllegalArgumentException if <code>clazz</code> doesn't represent
 *         a valid POJO class
 */
TypeClassInfoImpl(StatementManagerImpl mgr, Class<? super T> rclazz, Class<T> clazz) {
    super(mgr, clazz, RootEntity.class); // search for ctor starting at root
    org.apache.commons.lang3.Validate.isTrue(!Modifier.isAbstract(clazz.getModifiers()),
            "type entity class '%s', cannot be abstract", clazz.getSimpleName());
    this.type = findType();
    this.rclazz = rclazz;
    // validate the type entity POJO class
    validate(rclazz);
}

From source file:edu.northwestern.bioinformatics.studycalendar.domain.delta.DeltaNodeTypeTest.java

public void testThereIsOneDeltaNodeTypePerChangeableClass() throws Exception {
    List<String> errors = new ArrayList<String>();
    for (Class<? extends Changeable> cClass : domainReflections.getSubTypesOf(Changeable.class)) {
        if (Modifier.isAbstract(cClass.getModifiers()) || cClass.isAnonymousClass())
            continue;
        try {//from   w ww.j ava2 s.  c  o m
            DeltaNodeType.valueForNodeClass(cClass);
        } catch (IllegalArgumentException iae) {
            errors.add(iae.getMessage());
        }
    }

    if (!errors.isEmpty()) {
        fail("* " + StringUtils.join(errors.iterator(), "\n* "));
    }
}

From source file:therian.module.SelfContainedTherianModule.java

@SuppressWarnings("rawtypes")
private <O extends Operator> O newInstance(Class<O> c) {
    if (c.isInterface()) {
        return null;
    }//from w  ww .j  a v a  2  s.co m
    if (Modifier.isAbstract(c.getModifiers())) {
        return null;
    }
    final Class<?>[] paramTypes;
    final Object[] args;
    if (Modifier.isStatic(c.getModifiers())) {
        paramTypes = ArrayUtils.EMPTY_CLASS_ARRAY;
        args = ArrayUtils.EMPTY_OBJECT_ARRAY;
    } else {
        paramTypes = new Class[] { getClass() };
        args = new Object[] { this };
    }
    final Constructor<O> cs = ConstructorUtils.getMatchingAccessibleConstructor(c, paramTypes);
    if (cs == null) {
        return null;
    }
    try {
        return cs.newInstance(args);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:ca.uhn.fhir.rest.param.ResourceParameter.java

public ResourceParameter(Class<? extends IResource> theParameterType, Object theProvider, Mode theMode) {
    Validate.notNull(theParameterType, "theParameterType can not be null");
    Validate.notNull(theMode, "theMode can not be null");

    myResourceType = theParameterType;/*from w  ww.  j ava 2s . c o  m*/
    myMode = theMode;

    Class<? extends IBaseResource> providerResourceType = null;
    if (theProvider instanceof IResourceProvider) {
        providerResourceType = ((IResourceProvider) theProvider).getResourceType();
    }

    if (Modifier.isAbstract(myResourceType.getModifiers()) && providerResourceType != null) {
        myResourceType = providerResourceType;
    }

}

From source file:tachyon.shell.TfsShell.java

/**
 * Uses reflection to get all the {@link TfsShellCommand} classes and store them in a map.
 *//*w ww . j  av a2  s .  co  m*/
private void loadCommands() {
    String pkgName = TfsShellCommand.class.getPackage().getName();
    Reflections reflections = new Reflections(pkgName);
    for (Class<? extends TfsShellCommand> cls : reflections.getSubTypesOf(TfsShellCommand.class)) {
        // Only instantiate a concrete class
        if (!Modifier.isAbstract(cls.getModifiers())) {
            TfsShellCommand cmd;
            try {
                cmd = CommonUtils.createNewClassInstance(cls,
                        new Class[] { TachyonConf.class, FileSystem.class },
                        new Object[] { mTachyonConf, mTfs });
            } catch (Exception e) {
                throw Throwables.propagate(e);
            }
            mCommands.put(cmd.getCommandName(), cmd);
        }
    }
}