Example usage for java.lang InstantiationException InstantiationException

List of usage examples for java.lang InstantiationException InstantiationException

Introduction

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

Prototype

public InstantiationException(String s) 

Source Link

Document

Constructs an InstantiationException with the specified detail message.

Usage

From source file:org.jboss.dashboard.security.PermissionDescriptor.java

public Permission getPermission() throws InstantiationException {
    if (permissionClass == null)
        return null;
    for (int i = 0; i < _permConstructorsTypes.length; i++) {
        try {//from  ww  w .j av a 2  s  .co  m
            Class permClass = Class.forName(permissionClass);
            Class[] constrTypes = (Class[]) _permConstructorsTypes[i];
            Constructor constr = permClass.getConstructor(constrTypes);
            Object[] constrParams = new Object[] { permissionResource, permissionActions };
            return (Permission) constr.newInstance(constrParams);
        } catch (Exception ignored) {
            log.error("Permission class not supported (" + permissionClass + ").");
        }
    }

    // If Permission can't be instantiated then throw an exception.
    throw new InstantiationException("Permission class not supported (" + permissionClass + ").");
}

From source file:ORG.oclc.os.SRW.DSpaceLucene.LuceneQueryResult.java

public RecordIterator newRecordIterator(long startPoint, int numRecs, String schemaID, ExtraDataType edt)
        throws InstantiationException {
    if (result == null)
        throw new InstantiationException("No results created");
    if (startPoint - 1 == qArgs.getStart())
        return new LuceneRecordIterator(this, startPoint, numRecs, edt, false);
    qArgs.setStart((int) (startPoint - 1));
    qArgs.setPageSize(numRecs);//from ww  w .j a  v a2 s . co m
    return new LuceneRecordIterator(new LuceneQueryResult(qArgs), startPoint, numRecs, edt, true);
}

From source file:org.apache.oodt.cas.filemgr.tools.SolrIndexer.java

/**
 * Constructor reads in the configuration and initiates the connection to the
 * Solr instance./*from w w w .  j  a v a 2s .c  o m*/
 * 
 * @param solrUrl
 *          URL for the Solr instance.
 * @param fmUrl
 *          URL for the File Manager instance.
 */
public SolrIndexer(String solrUrl, String fmUrl) throws InstantiationException {
    InputStream input = null;
    String filename;

    try {
        LOG.info("System property " + SOLR_INDEXER_CONFIG + " set to "
                + System.getProperty(SOLR_INDEXER_CONFIG));
        filename = System.getProperty(SOLR_INDEXER_CONFIG);
        if (filename != null) {
            LOG.info("Reading config from " + filename);
            input = new FileInputStream(filename);
        } else {
            LOG.info("Config file not found, reading config from classpath");
            input = SolrIndexer.class.getResourceAsStream("/indexer.properties");
        }
        config = new IndexerConfig(input);
    } catch (IOException e) {
        LOG.severe("Could not read in configuration for indexer from classpath or file");
        throw new InstantiationException(e.getMessage());
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException e) {
                // no op
            }
        }
    }

    this.solrUrl = solrUrl;
    if (this.solrUrl == null) {
        this.solrUrl = config.getProperty(SOLR_URL);
    }

    this.fmUrl = fmUrl;
    if (this.fmUrl == null) {
        this.fmUrl = config.getProperty(FILEMGR_URL);
    }

    LOG.info("Using Solr: " + this.solrUrl + " FileManager: " + this.fmUrl);

    try {
        server = new CommonsHttpSolrServer(this.solrUrl);
    } catch (MalformedURLException e) {
        LOG.severe("Could not connect to Solr server " + this.solrUrl);
        throw new InstantiationException(e.getMessage());
    }

}

From source file:hsyndicate.rest.client.SyndicateUGHttpClient.java

public SyndicateUGHttpClient(String host, int port, String sessionName, String sessionKey, API_CALL api_call)
        throws InstantiationException {
    if (host == null) {
        throw new IllegalArgumentException("host is null");
    }/*  w ww  .  j a v  a 2 s .co m*/

    if (port <= 0) {
        throw new IllegalArgumentException("port is illegal");
    }

    try {
        URI serviceURI = new URI(String.format("http://%s:%d/", host, port));
        initialize(serviceURI, sessionName, sessionKey, api_call);
    } catch (URISyntaxException ex) {
        LOG.error("exception occurred", ex);
        throw new InstantiationException(ex.getMessage());
    }
}

From source file:de.xirp.plugin.SecurePluginView.java

/**
 * Constructs a new Secure View of a plugin
 * //from  w w  w.j  a va 2s.c  o m
 * @param plugin
 *            the plugin to secure (may be a secure view, if this
 *            is the case the view is replaced with this one)
 * @throws InstantiationException
 *             if the given plugin was <code>null</code>
 */
protected SecurePluginView(IPlugable<GAbstractPluginGUI> plugin) throws InstantiationException {
    if (plugin == null) {
        throw new InstantiationException("The given plugin must not be null."); //$NON-NLS-1$
    }
    this.originalPlugin = getRealPlugin(plugin);
}

From source file:org.apache.torque.adapter.AdapterFactory.java

/**
 * Creates a new instance of the Torque database adapter associated
 * with the specified JDBC driver or adapter key and the class defined.
 *
 * @param key The fully-qualified name of the JDBC driver
 *        or a shorter form adapter key.
 * @param className The fully qualified name of the adapter class
 * @return An instance of a Torque database adapter.
 * @throws InstantiationException throws if the adapter could not be
 *         instantiated/*  w w w .  j  a v  a  2 s.  co  m*/
 */
@SuppressWarnings("unchecked")
public static Adapter create(String key, String className) throws InstantiationException {
    Class<?> adapterClass;

    try {
        adapterClass = Class.forName(className);
    } catch (ClassNotFoundException e) {
        throw new InstantiationException(
                "Could not find adapter " + className + " for key " + key + ": Check your configuration file");
    }

    try {
        Adapter adapter = (Adapter) adapterClass.newInstance();
        adapters.put(key, (Class<? extends Adapter>) adapterClass);
        return adapter;
    } catch (IllegalAccessException e) {
        throw new InstantiationException("Could not instantiate adapter for key: " + key
                + ": Assure that adapter classes are in your classpath");
    }
}

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.commonswing.AbstractExportActionPlugin.java

/**
 * Creates a progress dialog, and tries to assign a parent based on the given preview proxy.
 *
 * @return the progress dialog.// ww w . jav a2 s . c o  m
 */
protected ExportDialog createExportDialog(final String className) throws InstantiationException {
    if (className == null) {
        throw new NullPointerException("No classname given"); //$NON-NLS-1$
    }

    final Window proxy = getContext().getWindow();
    if (proxy instanceof Frame) {
        final ClassLoader classLoader = ObjectUtilities.getClassLoader(AbstractActionPlugin.class);
        try {
            final Class aClass = Class.forName(className, true, classLoader);
            final Constructor constructor = aClass.getConstructor(new Class[] { Frame.class });
            return (ExportDialog) constructor.newInstance(new Object[] { proxy });
        } catch (Exception e) {
            AbstractExportActionPlugin.logger.error(messages.getErrorString(
                    "AbstractExportActionPlugin.ERROR_0001_FAILED_EXPORT_DIALOG_CREATION", className)); //$NON-NLS-1$
        }
    } else if (proxy instanceof Dialog) {
        final ClassLoader classLoader = ObjectUtilities.getClassLoader(AbstractActionPlugin.class);
        try {
            final Class aClass = Class.forName(className, true, classLoader);
            final Constructor constructor = aClass.getConstructor(new Class[] { Dialog.class });
            return (ExportDialog) constructor.newInstance(new Object[] { proxy });
        } catch (Exception e) {
            AbstractExportActionPlugin.logger.error(
                    messages.getErrorString(
                            "AbstractExportActionPlugin.ERROR_0002_FAILED_EXPORT_DIALOG_CREATION", className), //$NON-NLS-1$
                    e);
        }
    }

    final Object fallBack = ObjectUtilities.loadAndInstantiate(className, AbstractActionPlugin.class,
            ExportDialog.class);
    if (fallBack != null) {
        return (ExportDialog) fallBack;
    }

    AbstractExportActionPlugin.logger.error(messages
            .getErrorString("AbstractExportActionPlugin.ERROR_0003_FAILED_EXPORT_DIALOG_CREATION", className)); //$NON-NLS-1$
    throw new InstantiationException(
            messages.getErrorString("AbstractExportActionPlugin.ERROR_0004_FAILED_EXPORT_DIALOG_CREATION")); //$NON-NLS-1$
}

From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.Holder.java

public synchronized Object newInstance() throws InstantiationException, IllegalAccessException {
    if (_class == null)
        throw new InstantiationException("No class for " + this);
    return _class.newInstance();
}

From source file:com.zotoh.maedr.core.Config.java

private Device addDev(String id, String type, JSONObject obj) throws Exception {
    DeviceFactory<T, R> fac = _devHandlers.get(type);
    if (fac == null) {
        throw new InstantiationException("Config: no device-factory found for type: " + type);
    }// w w w  .  j a v a  2  s .  c o m
    Device dev = null;
    try {
        dev = fac.newDevice(id, obj);
    } catch (Throwable t) {
        tlog().warn("", t);
    }
    //        if (dev==null) {
    //            throw new InstantiationException("Failed to create device type: " + type) ;
    //        }        
    if (dev != null) {
        _engine.getDeviceManager().add(dev);
    }

    return dev;
}

From source file:org.xmlactions.mapping.bean_to_xml.MapperElement.java

private Element useAction(BeanToXml beanToXml, List<KeyValue> keyvalues, String actionName, Element parent,
        Object object, String propertyName)
        throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    log.debug(actionName + " - " + object + propertyName);

    Class clas = Class.forName(actionName);
    Object p = clas.newInstance();
    if (!(p instanceof PopulateXmlFromClassInterface)) {
        throw new InstantiationException(
                actionName + " does not implement " + PopulateXmlFromClassInterface.class.getSimpleName());
    }/*from  www.  jav a 2s . c om*/
    PopulateXmlFromClassInterface pc = (PopulateXmlFromClassInterface) p;
    return pc.performElementAction(keyvalues, beanToXml, parent, object, prefix, name, getBean_ref());

}