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.yunmel.syncretic.core.BaseService.java

/**
 * ????(??)/*  w w  w . ja  va  2  s.co  m*/
 * 
 * @param bean class
 * @param fields 
 * @param values 
 * @return -1?
 */
public <M extends BaseEntity> int beforeDelete(Class<M> bean, Map<String, Object> params) {
    String mapperName = StringUtils.uncapitalize(bean.getSimpleName()) + "Mapper";
    Mapper<M> mapper = SpringUtils.getBean(mapperName);
    M m = null;
    try {
        m = bean.newInstance();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    m.setAll(params);
    int count = mapper.selectCount(m);
    return count > 0 ? -1 : count;
}

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

/**
 * For each spout in the topology, create multiple objects (according to the parallelism)
 * /* w  ww. jav a 2s . c  o m*/
 * @param topo Topology
 * @throws ClassNotFoundException 
 */
private void createSpoutInstances(Topology topo, Config config) throws ClassNotFoundException {
    for (String key : topo.getSpouts().keySet()) {
        StringIntPair 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 = (IRichSpout) Class.forName(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());
            } 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.DistributedCluster.java

/**
 * For each bolt in the topology, create multiple objects (according to the parallelism)
 * //  w ww .j  av a 2  s. c o  m
 * @param topo Topology
 * @throws ClassNotFoundException 
 */
private void createBoltInstances(Topology topo, Config config) throws ClassNotFoundException {
    for (String key : topo.getBolts().keySet()) {
        StringIntPair bolt = topo.getBolt(key);

        OutputCollector collector = new OutputCollector(context);

        boltStreams.put(key, new ArrayList<IRichBolt>());
        int localExecutors = bolt.getRight();
        for (int i = 0; i < localExecutors; i++)
            try {
                IRichBolt newBolt = (IRichBolt) Class.forName(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());
            } catch (InstantiationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }
}

From source file:org.deviceconnect.android.deviceplugin.irkit.settings.activity.IRKitSettingActivity.java

@Override
public Fragment createPage(final int position) {

    Fragment page;//  w w w. j  a  v a  2 s . c om
    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:com.jada.browser.YuiImageBrowser.java

public void init() throws ServletException {
    try {//from  w  ww.  j a  va2  s  . c o  m
        if (!externalInit) {
            YuiImageBrowser.baseDir = getInitParameter("baseDir");
            String smClassName = getInitParameter("securityMangerClassName");
            if (smClassName != null && smClassName.trim().length() > 0) {
                YuiImageBrowser.securityManager = (SecurityManager) Class.forName(smClassName).newInstance();
            }
            String s = getInitParameter("maxsize");
            if (s != null && s.length() > 0) {
                maxsize = Integer.parseInt(s);
            }
        }
    } catch (InstantiationException e) {
        e.printStackTrace();
        throw new ServletException(e);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
        throw new ServletException(e);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        throw new ServletException(e);
    }
}

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

public <M extends BaseEntity> boolean unique(Class<M> bean, String checkField, Object value, Object id,
        Map<String, Object> params) {
    String mapperName = StringUtils.uncapitalize(bean.getSimpleName()) + "Mapper";
    Mapper<M> mapper = SpringUtils.getBean(mapperName);
    M m = null;// w w w. ja  va  2s .  c  o  m
    try {
        m = bean.newInstance();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    if (id != null) {
        m.set("id", id);
    }
    m.set(checkField, value);
    if (params != null) {
        m.setAll(params);
    }
    // int count = mapper.selectCount(m);
    if (id != null) {
        List<M> lists = mapper.select(m);
        if (lists.size() >= 2) {
            return false;
        } else if ((lists.size() == 1)) {
            return lists.get(0).get("id").toString().equals(id + "");
        } else {
            return true;
        }
    } else {
        int count = mapper.selectCount(m);
        return count <= 0 ? true : false;
    }
}

From source file:org.n52.movingcode.runtime.processors.ProcessorFactory.java

/**
 * Loader for processor classes. Uses dynamic class loading and returns {@link AbstractProcessor}. If the
 * class loading and instantiation should fail for some reason NULL is returned.
 * // www  .j  av  a 2s.c  o  m
 * @param processorClassName
 * @param scratchworkspace
 * @param mcp
 * @param properties
 * @return {@link AbstractProcessor}
 */
private AbstractProcessor loadProcessor(String processorClassName, final File scratchworkspace,
        final MovingCodePackage mcp, final PropertyMap properties) {

    try {
        // load class
        Class<?> processorClass = ProcessorFactory.class.getClassLoader().loadClass(processorClassName);
        // get a suitable constructor
        Constructor<?> processorConstructor = processorClass.getDeclaredConstructor(File.class,
                MovingCodePackage.class, PropertyMap.class);
        // return new Object
        return (AbstractProcessor) processorConstructor.newInstance(scratchworkspace, mcp, properties);

    } 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();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        // catch everything else
        e.printStackTrace();
    }
    return null;
}

From source file:org.wso2.carbon.appmgt.impl.idp.WebAppIdPFactory.java

public WebAppIdPManager getIdpManager() throws AppManagementException {
    if (idpManager == null) {
        String className = config.getFirstProperty(AppMConstants.SSO_CONFIGURATION_IDENTITY_PROVIDER_MANAGER);
        try {/*from w w w .j a va 2s. c o m*/
            idpManager = (WebAppIdPManager) Class.forName(className)
                    .getConstructor(AppManagerConfiguration.class).newInstance(config);
        } catch (InstantiationException e) {
            log.error(e);
            throw new AppManagementException(e.getMessage());
        } catch (IllegalAccessException e) {
            log.error(e);
            throw new AppManagementException(e.getMessage());
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            log.error(e);
            throw new AppManagementException(e.getMessage());
        } catch (NoSuchMethodException e) {
            log.error(e);
            throw new AppManagementException(e.getMessage());
        } catch (SecurityException e) {
            log.error(e);
            throw new AppManagementException(e.getMessage());
        } catch (ClassNotFoundException e) {
            log.error(e);
            throw new AppManagementException(e.getMessage());
        }
    }
    return idpManager;
}

From source file:com.example.android.wardrobe.HomeActivity.java

/**
 * A simple pager adapter that represents 5 {@link SingleViewPagerFragment} objects, in
 * sequence./*from w  w w  . j ava 2  s .c om*/
 */
/*private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
        
   private Context context;
   private List list;
        
   public ScreenSlidePagerAdapter(Context context, FragmentManager fm, List list) {
 super(fm);
 this.context = context;
 this.list = list;
   }
        
   @Override
   public Fragment getItem(int position) {
 String imagePath = "";
 if(list.get(position) instanceof Shirt) {
    imagePath = ((Shirt) list.get(position)).getImagePath();
 } else {
    imagePath = ((Pant) list.get(position)).getImagePath();
 }
 return SingleViewPagerFragment.create(imagePath);
   }
        
   @Override
   public int getCount() {
 return list.size();
   }
}*/

public void onActionSelected(Menu action) {

    try {
        showContent();
        FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
        currentFragment = (Fragment) action.getKlass().newInstance();
        t.replace(R.id.content, currentFragment);
        t.commit();

        leftMenuFragment.notifyDataChanged();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

}

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

@Override
protected void onCreate(Bundle b) {
    super.onCreate(b);

    clearFragCache();/* w  w w.j a v  a2s  .  c  om*/

    if (b != null) {
        this.current_frag = b.getString("current_frag");
        Bundle fragcache_bundle = b.getBundle("fragCache");
        Set<String> keyset = fragcache_bundle.keySet();
        for (String key : keyset) {
            try {
                @SuppressWarnings("unchecked")
                Class<PhishBaseActivity> fragClass = (Class<PhishBaseActivity>) Class.forName(key);
                PhishBaseActivity newinstance = fragClass.newInstance();
                Bundle current_bundle = fragcache_bundle.getBundle(key);
                newinstance.onCreate(current_bundle);
                addToFragCache(newinstance);
            } 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();
            }
        }
    }

    setContentView(R.layout.main);

    if (!BackendControllerImpl.getInstance().isInitDone()) {
        BackendControllerImpl.getInstance().init(this, this);
    }
    BackendControllerImpl.getInstance().clearOnLevelChangeListener();
    BackendControllerImpl.getInstance().clearOnLevelstateChangeListener();
    BackendControllerImpl.getInstance().addOnLevelChangeListener(this);
    BackendControllerImpl.getInstance().addOnLevelstateChangeListener(this);

    clearFragCache();

    showMainMenu();

    BackendControllerImpl.getInstance().onUrlReceive(getIntent().getData());
}