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:edu.upenn.cis.stormlite.LocalCluster.java

/**
 * For each bolt in the topology, create multiple objects (according to the parallelism)
 * //w w  w  .  j  a  v a2s.co  m
 * @param topo Topology
 */
private void createBoltInstances(Topology topo, Config config) {
    for (String key : topo.getBolts().keySet()) {
        Pair<Class<? extends IRichBolt>, Integer> bolt = topo.getBolt(key);

        OutputCollector collector = new OutputCollector(context);

        boltStreams.put(key, new ArrayList<IRichBolt>());
        for (int i = 0; i < bolt.getRight(); i++)
            try {
                IRichBolt newBolt = bolt.getLeft().newInstance();
                newBolt.prepare(config, context, collector);
                boltStreams.get(key).add(newBolt);
                log.debug("Created a bolt executor " + key + "/" + newBolt.getExecutorId() + " of type "
                        + bolt.getLeft().getName());
            } catch (InstantiationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }
}

From source file:edu.upenn.cis.stormlite.LocalCluster.java

/**
 * For each spout in the topology, create multiple objects (according to the parallelism)
 * /*  www. j a  v  a2  s .  com*/
 * @param topo Topology
 */
private void createSpoutInstances(Topology topo, Config config) {
    for (String key : topo.getSpouts().keySet()) {
        Pair<Class<? extends IRichSpout>, Integer> spout = topo.getSpout(key);

        SpoutOutputCollector collector = new SpoutOutputCollector(context);

        spoutStreams.put(key, new ArrayList<IRichSpout>());
        for (int i = 0; i < spout.getRight(); i++)
            try {
                IRichSpout newSpout = spout.getLeft().newInstance();

                newSpout.open(config, context, collector);
                spoutStreams.get(key).add(newSpout);
                log.debug("Created a spout executor " + key + "/" + newSpout.getExecutorId() + " of type "
                        + spout.getLeft().getName());
            } catch (InstantiationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }
}

From source file:com.alusorstroke.jjvm.MainActivity.java

private void openNavigationItem(NavItem item) {
    try {/*from w  ww.j ava2 s  . c om*/
        Fragment fragment = item.getFragment().newInstance();

        if (fragment != null) {

            //Verify if we can safely open the fragment by checking for permissions
            if (checkPermissionsHandleIfNeeded(item, fragment) && checkPurchaseHandleIfNeeded(item)) {
                String[] extra = item.getData();
                showFragment(fragment, extra, item.getText(this));
            } else {
                //We do nothing, the check method will handle this for us.
            }

        } else {
            Log.v("INFO", "Error creating fragment");
        }
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

}

From source file:com.projity.graphic.configuration.BarFormat.java

public ScheduleIntervalGenerator getScheduleIntervalGenerator() {
    if (intervalGenerator != null && scheduleIntervalGenerator == null) {
        try {// w w  w . j  a  v  a  2 s  .co m
            scheduleIntervalGenerator = (ScheduleIntervalGenerator) Class.forName(intervalGenerator)
                    .newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    return scheduleIntervalGenerator;
}

From source file:com.projity.session.LocalSession.java

public Job getLoadProjectJob(final LoadOptions opt) {
    final Job job = new Job(jobQueue, "loadProject", "Loading...", true);
    job.setCancelMonitorClosure(new Closure() {
        public void execute(Object o) {
            System.out.println("Monitor Canceled");
            jobQueue.endCriticalSection(job);
        }//from   w  w  w.ja  v  a 2  s . com
    });
    try {
        final FileImporter importer = (FileImporter) ClassUtils.forName(opt.getImporter()).newInstance();
        importer.setFileName(opt.getFileName());
        importer.setResourceMapping(opt.getResourceMapping());
        importer.setProjectFactory(ProjectFactory.getInstance());//used?
        importer.setJobQueue(jobQueue);

        job.addSwingRunnable(new JobRunnable("LocalAccess: loadProject.begin", 1.0f) {
            public Object run() throws Exception {
                ResourcePool resourcePool = null;
                if (MICROSOFT_PROJECT_IMPORTER.equals(opt.getImporter())) {
                    DataFactoryUndoController undoController = new DataFactoryUndoController();
                    resourcePool = ResourcePoolFactory.getInstance().createResourcePool("", undoController);
                    resourcePool.setLocal(importer.getResourceMapping() == null);
                    Project project = Project.createProject(resourcePool, undoController);

                    ((DefaultNodeModel) project.getTaskOutline()).setDataFactory(project);
                    importer.setProject(project);
                }
                setProgress(1.0f);
                return null;
            }
        });
        job.addJob(importer.getImportFileJob());
        job.addRunnable(new JobRunnable("LocalAccess: loadProject.end", 1.0f) {
            public Object run() throws Exception {
                Project project = importer.getProject();
                project.setFileName(opt.getFileName()); //overrides project name
                if (MICROSOFT_PROJECT_IMPORTER.equals(opt.getImporter()))
                    project.getResourcePool().setName(project.getName());
                if (Environment.getStandAlone()) { //force local in this case
                    project.setMaster(true); //local project is always master
                    project.setLocal(true);
                }
                setProgress(1.0f);
                return project;

            }
        });
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return job;
}

From source file:com.PrivacyGuard.Application.Network.FakeVPN.MyVpnService.java

public ArrayList<IPlugin> getNewPlugins() {
    ArrayList<IPlugin> ret = new ArrayList<IPlugin>();
    try {//  w  w w . ja  v a2 s . co  m
        for (Class c : pluginClass) {
            IPlugin temp = (IPlugin) c.newInstance();
            temp.setContext(this);
            ret.add(temp);
        }
        return ret;
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:jmdbtools.JMdbTools.java

private Connection connectToMySQL(String dbName, String user, String pass) {
    // Initialize MYSQL java driver
    try {/*from  w  ww  . ja  v  a  2s  .c o m*/
        Class.forName("com.mysql.jdbc.Driver").newInstance();
    } catch (InstantiationException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    } catch (IllegalAccessException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    } catch (ClassNotFoundException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }

    Connection conn = null;
    try {
        String connectionString = "jdbc:mysql://" + dbName + "?user=" + user;

        if (pass != null) {
            connectionString = connectionString + "&password=" + pass;
        }

        conn = DriverManager.getConnection(connectionString);
    } catch (SQLException e) {
        log("SQLException: " + e.getMessage(), "error");
        log("SQLState: " + e.getSQLState(), "error");
        log("VendorError: " + e.getErrorCode(), "error");
    }

    return conn;
}

From source file:com.ebay.xcelite.reader.BeanSheetReader.java

@Override
public Collection<T> read(int from) {
    rowIterator = sheet.getNativeSheet().rowIterator();

    if (rowIterator.next() == null) {
        throw new XceliteException("row in sheet is empty");
    }/*w w  w  .  jav  a  2  s.c o m*/

    int i = 0;
    while (i < from) {
        rowIterator.next();
        i++;
    }
    while (rowIterator.hasNext()) {
        Row row = rowIterator.next();
        if (isBlankRow(row))
            continue;

        T object = null;
        try {
            object = type.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        if (start(row, object)) {
            rowIterator.next();
            break;
        }
    }

    return getCollections();
}

From source file:de.tudarmstadt.informatik.secuso.phishedu2.MainActivity.java

public void switchToFragment(Class<? extends PhishBaseActivity> fragClass, Bundle arguments) {
    PhishBaseActivity newFrag;/*from   w  ww  .  j ava 2  s . com*/
    try {
        if (!fragCache.containsKey(fragClass.toString())) {
            PhishBaseActivity newinstance = fragClass.newInstance();
            addToFragCache(newinstance);
        }
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    newFrag = fragCache.get(fragClass.toString());

    if (newFrag.getArguments() != null) {
        newFrag.getArguments().clear();
        newFrag.getArguments().putAll(arguments);
    } else {
        newFrag.setArguments(arguments);
    }
    //TODO: commitAllowingStateLoss should not be needed.
    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, newFrag).commit();
    /**
     * ensure that we only run onswitchto when attached.
     * this is also called in PhishBaseActivity.onAttack() 
     */
    if (newFrag.getActivity() != null) {
        newFrag.onSwitchTo();
    }
    current_frag = newFrag.getClass().toString();
}

From source file:com.yunmel.syncretic.core.BaseService.java

/**
 * ?(?delFlag)/*w ww  .  j  ava  2s  .co m*/
 * 
 * @param bean 
 * @return ?
 */
public <M extends BaseEntity> int updateDelFlagToDelStatusById(Class<M> bean, String id) {
    String mapperName = StringUtils.uncapitalize(bean.getSimpleName()) + "Mapper";
    Mapper<M> mapper = SpringUtils.getBean(mapperName);
    M m = null;
    try {
        m = bean.newInstance();
        m.setId(id);
        m.set("delFlag", Globle.DEL_FLAG_DELETE);
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return mapper.updateByPrimaryKeySelective(m);
}