Example usage for java.lang InstantiationException getMessage

List of usage examples for java.lang InstantiationException getMessage

Introduction

In this page you can find the example usage for java.lang InstantiationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:app.presentation.foundation.views.BaseActivity.java

protected <T extends BaseFragment> BaseFragment replaceFragment(Class<T> clazz) {
    try {/*from  w  ww  . j  a  va  2  s. co m*/
        BaseFragment fragment = clazz.newInstance();
        getSupportFragmentManager().beginTransaction().replace(R.id.fl_fragment, fragment).commit();
        return fragment;
    } catch (InstantiationException e) {
        throw new IllegalStateException(e.getMessage());
    } catch (IllegalAccessException e) {
        throw new IllegalStateException(e.getMessage());
    }
}

From source file:org.wso2.carbon.identity.workflow.mgt.workflow.AbstractWorkflow.java

public TemplateInitializer getTemplateInitializer() throws WorkflowRuntimeException {
    TemplateInitializer templateInitializer = null;
    try {//  w w w .ja v  a 2s. c om
        templateInitializer = templateInitializerClass.newInstance();
    } catch (InstantiationException e) {
        String errorMsg = "Error occurred while initializing TemplateInitializer : " + e.getMessage();
        log.error(errorMsg);
        throw new WorkflowRuntimeException(errorMsg, e);
    } catch (IllegalAccessException e) {
        String errorMsg = "Error occurred while initializing TemplateInitializer : " + e.getMessage();
        log.error(errorMsg);
        throw new WorkflowRuntimeException(errorMsg, e);
    }
    return templateInitializer;
}

From source file:org.nuxeo.externalresource.provider.ExternalResourceProviderServiceImpl.java

@Override
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) {
    if (extensionPoint.equals(PROVIDER_DECLARATION_EP)) {
        if (contribution instanceof ExternalResourceProviderDescriptor) {
            ExternalResourceProviderDescriptor provider = (ExternalResourceProviderDescriptor) contribution;
            try {
                String providerName = provider.getName();
                if (provider.isEnabled()) {
                    ExternalResourceProvider providerInstance = provider.getClassName().newInstance();
                    providerInstances.put(providerName, providerInstance);
                } else {
                    if (providerInstances.containsKey(providerName)) {
                        providerInstances.remove(providerName);
                    }//  w ww  .j av a 2 s.  c  om
                }
            } catch (InstantiationException e) {
                log.error("Error while creating instance of provider " + provider.getName() + " :"
                        + e.getMessage());
            } catch (IllegalAccessException e) {
                log.error("Error while creating instance of provider " + provider.getName() + " :"
                        + e.getMessage());
            }

        }
    }
}

From source file:org.jadira.scanner.classpath.types.JParameter.java

@Override
public JType getType() throws ClasspathAccessException {

    Class<?> clazz;/*from w w w.  j a  va  2s .  c o  m*/
    if (enclosingOperation instanceof JConstructor || enclosingOperation instanceof JMethod) {
        MethodInfo methodInfo = ((JOperation) enclosingOperation).getMethodInfo();
        String[] paramTypeNames = JavassistMethodInfoHelper.getMethodParamTypeNames(methodInfo);
        clazz = decodeFieldType(paramTypeNames[getIndex()]);

    } else {
        throw new ClasspathAccessException("Invalid parameter index: " + index);
    }

    if (clazz.isAnnotation()) {
        try {
            return new JAnnotation<java.lang.annotation.Annotation>(
                    (java.lang.annotation.Annotation) clazz.newInstance(), this, getResolver());
        } catch (InstantiationException e) {
            throw new ClasspathAccessException("Problem instantiating annotation: " + e.getMessage(), e);
        } catch (IllegalAccessException e) {
            throw new ClasspathAccessException("Problem accessing annotation: " + e.getMessage(), e);
        }
    } else if (clazz.isInterface()) {
        return new JInterface(clazz.getName(), getResolver());
    } else {
        JClass jClass = new JClass(clazz.getName(), getResolver());
        return jClass;
    }
}

From source file:service.ExcelWorkSheetHandler.java

private T getInstance() {
    try {// ww w . j  ava2 s  .com
        return type.newInstance();
    } catch (InstantiationException ie) {
        LOG.error(ie.getMessage());
    } catch (IllegalAccessException iae) {
        LOG.error(iae.getMessage());
    } catch (Exception ex) {
        return null;
    }
    return null;
}

From source file:eionet.meta.service.VocabularyReferenceMatchServiceImpl.java

/**
 * {@inheritDoc}/*from   w  w w  .  ja  v a 2s  . c  om*/
 */
// @Transactional(rollbackFor = ServiceException.class)
@Override
public List<String> matchReferences(String[] jobIdentifiers) throws ServiceException {
    List<String> logs = new ArrayList<String>();

    if (jobIdentifiers != null && jobIdentifiers.length > 0) {
        for (String jobChunkIdentifier : jobIdentifiers) {
            Class<? extends ReferenceMatchJobChunk> clazz = jobMatchMap.get(jobChunkIdentifier);
            if (clazz != null) {
                try {
                    ReferenceMatchJobChunk jobChunk = clazz.newInstance();
                    logs.add("Starting " + jobChunkIdentifier);
                    List<String> internalLogs = jobChunk.execute();
                    logs.addAll(internalLogs);
                } catch (InstantiationException e) {
                    logs.add("Cannot create job chunk for " + jobChunkIdentifier);
                    logs.add(e.getMessage());
                } catch (IllegalAccessException e) {
                    logs.add("Cannot create job chunk for " + jobChunkIdentifier);
                    logs.add(e.getMessage());
                }
            } else {
                logs.add("No implementation set for " + jobChunkIdentifier);
            }
        }
    }
    return logs;
}

From source file:com.myjeeva.poi.ExcelWorkSheetHandler.java

private T getInstance() {
    try {//  w  ww.  ja  va 2s  . c  om
        return type.newInstance();
    } catch (InstantiationException ie) {
        LOG.error(ie.getMessage());
    } catch (IllegalAccessException iae) {
        LOG.error(iae.getMessage());
    }
    return null;
}

From source file:org.kuali.kfs.module.tem.businessobject.lookup.TravelerProfileDocLookupableHelperServiceImpl.java

/**
 * Overrides set rows so that the _rows_ always look at TravelerProfileForLookup as the business object class - we want that lookup,
 * but we want to search for TemProfiles....
 * @see org.kuali.rice.kns.lookup.AbstractLookupableHelperServiceImpl#setRows()
 *//*from   w w  w.  ja  v  a  2 s .c o m*/
@Override
protected void setRows() {
    List<String> lookupFieldAttributeList = null;
    final Class<? extends BusinessObject> businessObjectClazz = TravelerProfileForLookup.class;
    if (getBusinessObjectMetaDataService().isLookupable(businessObjectClazz)) {
        lookupFieldAttributeList = getBusinessObjectMetaDataService()
                .getLookupableFieldNames(businessObjectClazz);
    }
    if (lookupFieldAttributeList == null) {
        throw new RuntimeException("Lookup not defined for business object " + getBusinessObjectClass());
    }

    // construct field object for each search attribute
    List fields = new ArrayList();
    try {
        fields = FieldUtils.createAndPopulateFieldsForLookup(lookupFieldAttributeList, getReadOnlyFieldsList(),
                businessObjectClazz);
    } catch (InstantiationException e) {
        throw new RuntimeException("Unable to create instance of business object class" + e.getMessage());
    } catch (IllegalAccessException e) {
        throw new RuntimeException("Unable to create instance of business object class" + e.getMessage());
    }

    int numCols = getBusinessObjectDictionaryService().getLookupNumberOfColumns(businessObjectClazz);

    this.rows = FieldUtils.wrapFields(fields, numCols);
}

From source file:org.hyperic.hq.plugin.websphere.jmx.WebSphereQuery.java

public WebSphereQuery cloneInstance() {
    WebSphereQuery query;//from w ww.  j a va2s.c o  m

    try {
        query = (WebSphereQuery) this.getClass().newInstance();
    } catch (InstantiationException e) {
        throw new IllegalArgumentException(e.getMessage());
    } catch (IllegalAccessException e) {
        throw new IllegalArgumentException(e.getMessage());
    }

    query.setParent(getParent());
    query.setName(getName());
    query.setVersion(getVersion());
    query.setMBeanServer(getMBeanServer());

    return query;
}

From source file:com.impetus.kundera.mongodb.MongoDBDataHandler.java

public Object getEntityFromDocument(EntityManagerImpl em, Class<?> entityClass, EntityMetadata m,
        DBObject document) {//from   w  ww . jav  a2s  .  c o  m
    Object entity = null;
    try {
        entity = entityClass.newInstance();

        //Populate entity columns
        List<Column> columns = m.getColumnsAsList();
        for (Column column : columns) {
            PropertyAccessorHelper.set(entity, column.getField(), document.get(column.getName()));
        }

        //Populate embedded relationship object
        List<Relation> relations = m.getRelations();

        for (Relation relation : relations) {
            Class<?> embeddedEntityClass = relation.getTargetEntity(); //Embedded entity class
            Field embeddedPropertyField = relation.getProperty(); //Mapped to this property               
            boolean optional = relation.isOptional(); // Is it optional? TODO: Where to use this?                           

            EntityMetadata relMetadata = em.getMetadataManager().getEntityMetadata(embeddedEntityClass);
            relMetadata.addColumn(relMetadata.getIdColumn().getName(), relMetadata.getIdColumn()); //Add PK column

            Object embeddedObject = document.get(embeddedPropertyField.getName());

            if (embeddedObject != null) {
                if (relation.isUnary()) {
                    BasicDBObject relDBObj = (BasicDBObject) embeddedObject;
                    Object embeddedEntity = new MongoDBDataHandler().getEntityFromDocument(em,
                            embeddedEntityClass, relMetadata, relDBObj);
                    PropertyAccessorHelper.set(entity, embeddedPropertyField, embeddedEntity);
                } else if (relation.isCollection()) {
                    BasicDBList relList = (BasicDBList) embeddedObject; //List of embedded objects

                    Collection<Object> embeddedEntities = null; //Collection of embedded entities
                    if (relation.getPropertyType().equals(Set.class)) {
                        embeddedEntities = new HashSet<Object>();
                    } else if (relation.getPropertyType().equals(List.class)) {
                        embeddedEntities = new ArrayList<Object>();
                    }

                    for (int i = 0; i < relList.size(); i++) {
                        BasicDBObject relObj = (BasicDBObject) relList.get(i);
                        Object embeddedEntity = new MongoDBDataHandler().getEntityFromDocument(em,
                                embeddedEntityClass, relMetadata, relObj);
                        embeddedEntities.add(embeddedEntity);
                    }

                    PropertyAccessorHelper.set(entity, embeddedPropertyField, embeddedEntities);
                }
            }

        }

    } catch (InstantiationException e) {
        log.error("Error while instantiating " + entityClass + ". Details:" + e.getMessage());
        return entity;
    } catch (IllegalAccessException e) {
        log.error("Error while Getting entity from Document. Details:" + e.getMessage());
        return entity;
    } catch (PropertyAccessException e) {
        log.error("Error while Getting entity from Document. Details:" + e.getMessage());
        return entity;
    }
    return entity;
}