Example usage for java.lang InstantiationException printStackTrace

List of usage examples for java.lang InstantiationException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.persistent.cloudninja.utils.ProvisionConnectionUtility.java

public Connection getConnection(String url, String db_name, String db_user, String db_user_pwd) {
    Connection connection = null;
    int index = url.indexOf("=");
    String connUrl = url.substring(0, index + 1) + db_name + ";";
    try {/*from ww  w  .j a v a 2  s  .c o m*/
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
        connection = DriverManager.getConnection(connUrl, db_user, db_user_pwd);
    } catch (InstantiationException instantiationException) {
        instantiationException.printStackTrace();
    } catch (IllegalAccessException illegalAccessException) {
        illegalAccessException.printStackTrace();
    } catch (ClassNotFoundException classNotFoundException) {
        classNotFoundException.printStackTrace();
    } catch (SQLException sqlException) {
        sqlException.printStackTrace();
    }
    return connection;
}

From source file:com.soubu.CRMProject.base.mvp.presenter.FragmentPresenter.java

@Override
public void onViewStateRestored(Bundle savedInstanceState) {
    super.onViewStateRestored(savedInstanceState);
    if (viewDelegate == null) {
        try {/*from  www .  java2s  .  c om*/
            viewDelegate = getDelegateClass().newInstance();
        } catch (java.lang.InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.deviceconnect.android.deviceplugin.fabo.setting.FaBoSettingActivity.java

@Override
public Fragment createPage(final int position) {
    Fragment page;/*from  w w w.  ja v a 2  s  .com*/
    try {
        page = (Fragment) PAGES[position].newInstance();
    } catch (InstantiationException e) {
        if (BuildConfig.DEBUG) {
            e.printStackTrace();
        }
        page = null;
    } catch (IllegalAccessException e) {
        if (BuildConfig.DEBUG) {
            e.printStackTrace();
        }
        page = null;
    }

    return page;
}

From source file:jp.mathes.databaseWiki.web.DbwConfiguration.java

public DbwConfiguration() {
    InputStream resourceStream = null;
    try {/*from  w  w w  .jav a  2s. c  om*/
        Properties props = new Properties();
        resourceStream = this.getClass().getResourceAsStream("/dbw.properties");
        props.load(resourceStream);
        String backendClassName = props.getProperty("dbw.db.backend");
        this.backend = (Backend) Class.forName(backendClassName).newInstance();
        String davLogFileName = props.getProperty("dbw.dav.log");
        if (!StringUtils.isEmpty(davLogFileName)) {
            this.davLogFile = new File(davLogFileName);
        }
        this.plugins.clear();
        String pluginString = props.getProperty("dbw.wiki.plugins");
        for (String pluginName : pluginString.split(",")) {
            if (StringUtils.isEmpty(pluginName)) {
                continue;
            }
            Plugin thisPlugin = (Plugin) Class.forName("jp.mathes.databaseWiki.wiki." + pluginName.trim())
                    .newInstance();
            if (thisPlugin != null) {
                this.plugins.add(thisPlugin);
            }
        }
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(resourceStream);
    }
}

From source file:net.bafeimao.umbrella.support.data.entity.AbstractEntityParser.java

/**
 * ????????//from  w w w  . j a  v a  2 s .c o  m
 *
 * @param field 
 * @return ??
 */
protected Converter<String, ?> getConverter(Field field) {
    Class<?> fieldType = field.getType();

    if (field.getName().equals("id")) { // TODO ???
        fieldType = Long.class;
    }

    Converter<?, ?> converter = convertersByType.get(fieldType);

    if (converter == null && field.isAnnotationPresent(DataConverter.class)) {
        DataConverter anno = field.getAnnotation(DataConverter.class);
        Class<?> converterClass = anno.value();
        try {
            converter = (Converter<?, ?>) converterClass.newInstance();
            convertersByType.put(field.getType(), converter);
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    return (Converter<String, ?>) converter;
}

From source file:org.lainsoft.forge.flow.nav.GenericCommandFactory.java

/**
 * Retrives a <code>Command</code> based on an stimulus, that is 
 * the cannonical class name of a command in the form of:<br>
 * <code>/some/package/ClassName</code>.
 * @param stimulus the stimulus to be load as a command.
 * @param helper The ViewHelper to be used by the command.
 *//*from ww w  . j  av  a2  s.  c om*/
public Command getCommand(String stimulus, ViewHelper helper) {
    if (stimulus == null || stimulus.trim().equals("") || stimulus.trim().equals("/")) {
        return new CommandNotFoundCommand();
    }

    try {
        stimulus = stimulus.replaceAll("/", ".");
        log.debug("Loading>" + stimulus);

        if (internalCache.containsKey(stimulus)) {
            return (Command) ((Class) internalCache.get(stimulus)).newInstance();
        }

        Class tempCommand = null;
        internalCache.put(stimulus, (tempCommand = Class.forName(stimulus)));
        return (Command) tempCommand.newInstance();
    } catch (ClassNotFoundException cnfe) {
        if (cnfc == null)
            cnfc = new CommandNotFoundCommand();
        return cnfc;
    } catch (InstantiationException ie) {
        ie.printStackTrace();
    } catch (IllegalAccessException iae) {
        iae.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:org.eclipse.xtend.backend.types.CompositeTypesystemFactory.java

public CompositeTypesystem createTypesystemFromClass(
        Set<Class<? extends BackendTypesystem>> typeSystemClasses) {
    CompositeTypesystem cts = new CompositeTypesystem();
    for (Class<? extends BackendTypesystem> tsClass : typeSystemClasses) {
        try {//from w w w .  j  a  va  2  s.  c o m
            cts.register(tsClass.newInstance());
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return cts;
}

From source file:de.tudarmstadt.ukp.dkpro.bigdata.io.hadoop.Text2CASInputFormat.java

@Override
public RecordReader<Text, CASWritable> getRecordReader(InputSplit split, JobConf jobConf, Reporter reporter)
        throws IOException {
    DocumentTextExtractor textConverter = null;
    String textConverterClass = jobConf.get("dkpro.uima.text2casinputformat.documenttextextractor");
    if (textConverterClass != null) {
        try {//ww w . j  ava2 s  .c  o m
            textConverter = (DocumentTextExtractor) Class.forName(textConverterClass).newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    return new Text2CASRecordReader((FileSplit) split, jobConf, reporter, textConverter);
}

From source file:com.xiovr.unibot.plugin.impl.PluginLoaderImpl.java

@Override
public CryptorPlugin createCryptorPlugin() {
    CryptorPlugin cp = null;/* w w  w.  j a va2  s .  c  o m*/
    assert cpClazz != null;
    try {
        cp = cpClazz.newInstance();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return cp;
}

From source file:com.phillipsong.gittrending.ui.activity.MainActivity.java

private void initFragment(Class clazz) {
    String tag = clazz.getSimpleName();
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    Fragment fragment = getSupportFragmentManager().findFragmentByTag(tag);
    if (fragment == null) {
        try {/*ww  w. j a v a  2 s  .c o m*/
            fragment = (Fragment) clazz.newInstance();
            transaction.add(R.id.main_content, fragment, tag);
            if (mCurrentFragment != null) {
                transaction.hide(mCurrentFragment);
            }
            transaction.commit();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    } else {
        transaction.show(fragment).hide(mCurrentFragment).commit();
    }
    mCurrentFragment = fragment;
}