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.oclc.os.SRW.SRWOpenSearchDatabase.java

@Override
public void init(String dbname, String srwHome, String dbHome, String dbPropertiesFileName,
        Properties dbProperties, HttpServletRequest request) throws Exception {
    log.debug("entering SRWOpenSearchDatabase.init, dbname=" + dbname);
    super.initDB(dbname, srwHome, dbHome, dbPropertiesFileName, dbProperties);

    String urlStr = dbProperties.getProperty("SRWOpenSearchDatabase.OpenSearchDescriptionURL");
    author = dbProperties.getProperty("SRWOpenSearchDatabase.author");
    contact = dbProperties.getProperty("SRWOpenSearchDatabase.contact");
    description = dbProperties.getProperty("SRWOpenSearchDatabase.description");
    restrictions = dbProperties.getProperty("SRWOpenSearchDatabase.restrictions");
    title = dbProperties.getProperty("SRWOpenSearchDatabase.title");
    defaultSchemaName = dbProperties.getProperty("SRWOpenSearchDatabase.defaultSchemaName");
    defaultSchemaID = dbProperties.getProperty("SRWOpenSearchDatabase.defaultSchemaID");
    itemsPerPage = Integer.parseInt(dbProperties.getProperty("SRWOpenSearchDatabase.itemsPerPage", "0"));
    URL url = new URL(urlStr);
    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    StringBuilder sb = new StringBuilder();
    String inputLine;//from  w w  w.  java  2s  .  c  o m
    while ((inputLine = in.readLine()) != null)
        sb.append(inputLine).append('\n');
    in.close();
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(sb.toString())));
    XPathFactory xPathfactory = XPathFactory.newInstance();
    XPath xpath = xPathfactory.newXPath();
    XPathExpression expr;
    if (contact == null) {
        expr = xpath.compile("/OpenSearchDescription/Contact");
        contact = (String) expr.evaluate(document, XPathConstants.STRING);
    }
    if (description == null) {
        expr = xpath.compile("/OpenSearchDescription/Description");
        description = (String) expr.evaluate(document, XPathConstants.STRING);
    }
    if (restrictions == null) {
        expr = xpath.compile("/OpenSearchDescription/SyndicationRight");
        restrictions = (String) expr.evaluate(document, XPathConstants.STRING);
        if (restrictions != null)
            restrictions = "SynticationRight=" + restrictions;
        expr = xpath.compile("/OpenSearchDescription/Attribution");
        String attribution = (String) expr.evaluate(document, XPathConstants.STRING);
        if (attribution != null)
            if (restrictions != null)
                restrictions = restrictions + ", Attribution=" + attribution;
            else
                restrictions = "Attribution=" + attribution;
    }
    if (title == null) {
        expr = xpath.compile("/OpenSearchDescription/LongName");
        title = (String) expr.evaluate(document, XPathConstants.STRING);
    }
    expr = xpath.compile("/OpenSearchDescription/Url");
    NodeList nl = (NodeList) expr.evaluate(document, XPathConstants.NODESET);
    NamedNodeMap attrs;
    String template, type;
    if (nl.getLength() == 0) {
        throw new InstantiationException("No OpenSearchDescription/Url found in " + url);
    }
    for (int i = 0; i < nl.getLength(); i++) {
        Node n = nl.item(i);
        attrs = n.getAttributes();
        n = attrs.getNamedItem("template");
        template = n.getTextContent();
        log.debug("template=" + template);
        n = attrs.getNamedItem("type");
        type = n.getTextContent();
        log.info("<Url type='" + type + "' template='" + template + "'/>");
        if ("application/rss+xml".equals(type)) {
            addSchema("RSS2.0", "rss", "http://europa.eu/rapid/conf/RSS20.xsd", "RSS Items", template);
        }
    }
    log.debug("leaving SRWOpenSearchDatabase.init");
}

From source file:org.envirocar.app.storage.DbAdapterImpl.java

private void openConnection() throws InstantiationException {
    mDbHelper = new DatabaseHelper(mCtx);
    mDb = mDbHelper.getWritableDatabase();

    if (mDb == null)
        throw new InstantiationException("Database object is null");
}

From source file:ORG.oclc.os.SRW.SRWDatabase.java

public static synchronized void createDB(final String dbname, Properties properties, String context,
        HttpServletRequest request) throws InstantiationException {
    log.debug("Enter: initDB, dbname=" + dbname);
    String dbn = "db." + dbname;

    srwProperties = properties;//from   w  ww.ja  v a2  s  . c  om
    srwHome = properties.getProperty("SRW.Home");
    servletContext = context;
    if (srwHome != null && !srwHome.endsWith("/"))
        srwHome = srwHome + "/";
    log.debug("SRW.Home=" + srwHome);
    Properties dbProperties = new Properties();
    String dbHome = properties.getProperty(dbn + ".home"), dbPropertiesFileName = null;
    if (dbHome != null) {
        if (!dbHome.endsWith("/"))
            dbHome = dbHome + "/";
        log.debug("dbHome=" + dbHome);
    }

    String className = properties.getProperty(dbn + ".class");
    log.debug("className=" + className);
    if (className == null) {
        // let's see if there's a fallback database to use
        className = properties.getProperty("db.default.class");
        if (className == null)
            throw new InstantiationException("No " + dbn + ".class entry in properties file");
        dbn = "db.default";
    }
    if (className.equals("ORG.oclc.os.SRW.SRWPearsDatabase")) {
        log.info(
                "** Warning ** the class ORG.oclc.os.SRW.SRWPearsDatabase has been replaced with ORG.oclc.os.SRW.Pears.SRWPearsDatabase");
        log.info("              Please correct the server's properties file");
        className = "ORG.oclc.os.SRW.Pears.SRWPearsDatabase";
        log.debug("new className=" + className);
    } else if (className.equals("ORG.oclc.os.SRW.SRWRemoteDatabase")) {
        log.info(
                "** Warning ** the class ORG.oclc.os.SRW.SRWRemoteDatabase has been replaced with ORG.oclc.os.SRW.ParallelSearching.SRWRemoteDatabase");
        log.info("              Please correct the server's properties file");
        className = "ORG.oclc.os.SRW.ParallelSearching.SRWRemoteDatabase";
        log.debug("new className=" + className);
    } else if (className.equals("ORG.oclc.os.SRW.Pears.SRWRemoteDatabase")) {
        log.info(
                "** Warning ** the class ORG.oclc.os.SRW.Pears.SRWRemoteDatabase has been replaced with ORG.oclc.os.SRW.ParallelSearching.SRWRemoteDatabase");
        log.info("              Please correct the server's properties file");
        className = "ORG.oclc.os.SRW.ParallelSearching.SRWRemoteDatabase";
        log.debug("new className=" + className);
    } else if (className.equals("ORG.oclc.os.SRW.SRWMergeDatabase")) {
        log.info(
                "** Warning ** the class ORG.oclc.os.SRW.SRWMergeDatabase has been replaced with ORG.oclc.os.SRW.ParallelSearching.SRWMergeDatabase");
        log.info("              Please correct the server's properties file");
        className = "ORG.oclc.os.SRW.ParallelSearching.SRWMergeDatabase";
        log.debug("new className=" + className);
    } else if (className.equals("ORG.oclc.os.SRW.Pears.SRWMergeDatabase")) {
        log.info(
                "** Warning ** the class ORG.oclc.os.SRW.Pears.SRWMergeDatabase has been replaced with ORG.oclc.os.SRW.ParallelSearching.SRWMergeDatabase");
        log.info("              Please correct the server's properties file");
        className = "ORG.oclc.os.SRW.ParallelSearching.SRWMergeDatabase";
        log.debug("new className=" + className);
    } else if (className.equals("ORG.oclc.os.SRW.SRWDLuceneDatabase")) {
        log.info(
                "** Warning ** the class ORG.oclc.os.SRW.SRWLuceneDatabase has been replaced with ORG.oclc.os.SRW.DSpaceLucene.SRWLuceneDatabase");
        log.info("              Please correct the server's properties file");
        className = "ORG.oclc.os.SRW.DSpaceLucene.SRWLuceneDatabase";
        log.debug("new className=" + className);
    }
    SRWDatabase db = null;
    try {
        log.debug("creating class " + className);
        Class dbClass = Class.forName(className);
        log.debug("creating instance of class " + dbClass);
        db = (SRWDatabase) dbClass.newInstance();
        log.debug("class created");
    } catch (Exception e) {
        log.error("Unable to create Database class " + className + " for database " + dbname);
        log.error(e, e);
        throw new InstantiationException(e.getMessage());
    }

    dbPropertiesFileName = properties.getProperty("propsfilePath")
            + properties.getProperty(dbn + ".configuration");
    if (db.hasaConfigurationFile() || dbPropertiesFileName != null) {
        if (dbPropertiesFileName == null) {
            throw new InstantiationException("No " + dbn + ".configuration entry in properties file");
        }

        try {
            log.debug("Reading database configuration file: " + dbPropertiesFileName);
            InputStream is = Utilities.openInputStream(dbPropertiesFileName, dbHome, srwHome);
            dbProperties.load(is);
            dbProperties.put("relativePath", dbPropertiesFileName.replaceFirst("(.*\\/).*", "$1"));
            is.close();
        } catch (java.io.FileNotFoundException e) {
            log.error("Unable to open database configuration file!");
            log.error(e);
        } catch (Exception e) {
            log.error("Unable to load database configuration file!");
            log.error(e, e);
        }
        makeUnqualifiedIndexes(dbProperties);
        try {
            db.init(dbname, srwHome, dbHome, dbPropertiesFileName, dbProperties, request);
        } catch (InstantiationException e) {
            throw e;
        } catch (Exception e) {
            log.error("Unable to initialize database " + dbname);
            log.error(e, e);
            throw new InstantiationException(e.getMessage());
        }
        if (request != null) {
            StringBuilder urlStr = new StringBuilder("http://").append(request.getServerName());
            if (request.getServerPort() != 80)
                urlStr.append(":").append(request.getServerPort());
            urlStr.append('/');
            String contextPath = request.getContextPath();
            if (contextPath != null && contextPath.length() > 1) {
                urlStr.append(contextPath.substring(1));
            }
            int pathInfoIndex = Integer.parseInt(properties.getProperty("pathInfoIndex", "1"));
            String path = request.getPathInfo();
            StringBuilder newPath = new StringBuilder();
            if (path != null) {
                StringTokenizer st = new StringTokenizer(path, "/");
                for (int i = 0; st.hasMoreTokens(); i++)
                    if (i == pathInfoIndex - 1) {
                        newPath.append('/').append(dbname);
                        st.nextToken();
                    } else
                        newPath.append('/').append(st.nextToken());
            }
            urlStr.append(request.getServletPath()).append(newPath.toString());
            db.baseURL = urlStr.toString();
        }
        String temp = dbProperties.getProperty("maximumRecords");
        if (temp == null)
            temp = dbProperties.getProperty("configInfo.maximumRecords");
        if (temp != null) {
            try {
                db.setMaximumRecords(Integer.parseInt(temp));
            } catch (NumberFormatException e) {
                log.error("bad value for maximumRecords: \"" + temp + "\"");
                log.error("maximumRecords parameter ignored");
            }
        }
        temp = dbProperties.getProperty("numberOfRecords");
        if (temp == null)
            temp = dbProperties.getProperty("configInfo.numberOfRecords");
        if (temp != null) {
            try {
                db.setNumberOfRecords(Integer.parseInt(temp));
            } catch (NumberFormatException e) {
                log.error("bad value for numberOfRecords: \"" + temp + "\"");
                log.error("numberOfRecords parameter ignored");
            }
        }
        temp = dbProperties.getProperty("defaultResultSetTTL");
        if (temp == null)
            temp = dbProperties.getProperty("configInfo.resultSetTTL");
        if (temp != null) {
            try {
                db.setDefaultResultSetTTL(Integer.parseInt(temp));
            } catch (NumberFormatException e) {
                log.error("bad value for defaultResultSetTTL: \"" + temp + "\"");
                log.error("defaultResultSetTTL parameter ignored");
            }
        } else
            db.setDefaultResultSetTTL(300);

        temp = dbProperties.getProperty("letDefaultsBeDefault");
        if (temp != null && temp.equals("true"))
            db.letDefaultsBeDefault = true;
    } else { // default settings
        try {
            db.init(dbname, srwHome, dbHome, "(no database configuration file specified)", dbProperties,
                    request);
        } catch (Exception e) {
            log.error("Unable to create Database class " + className + " for database " + dbname);
            log.error(e, e);
            throw new InstantiationException(e.getMessage());
        }
        db.setDefaultResultSetTTL(300);
        log.info("no configuration file needed or specified");
    }

    if (!(db instanceof SRWDatabasePool)) {
        LinkedList<SRWDatabase> queue = dbs.get(dbname);
        if (queue == null)
            queue = new LinkedList<SRWDatabase>();
        queue.add(db);
        if (log.isDebugEnabled())
            log.debug(dbname + " has " + queue.size() + " copies");
        dbs.put(dbname, queue);
    }
    log.debug("Exit: initDB");
    return;
}

From source file:ORG.oclc.os.SRW.Lucene.SRWLuceneDatabase.java

@Override
public void init(String dbname, String srwHome, String dbHome, String dbPropertiesFileName,
        Properties dbProperties, HttpServletRequest req) throws InstantiationException {
    if (log.isDebugEnabled())
        log.debug("entering SRWLuceneDatabase.init, dbname=" + dbname);

    String xmlSchemaList = dbProperties.getProperty("xmlSchemas");
    if (xmlSchemaList == null) {
        log.info("No schemas specified in SRWDatabase.props (" + dbPropertiesFileName + ")");
        log.info("The LuceneDocument schema will be automatically provided");
        dbProperties.put("xmlSchemas", "LuceneDocument");
        dbProperties.put("LuceneDocument.identifier", "info:srw/schema/1/LuceneDocument");
        dbProperties.put("LuceneDocument.location",
                "http://www.oclc.org/standards/Lucene/schema/LuceneDocument.xsd");
        dbProperties.put("LuceneDocument.namespace", "http://www.oclc.org/LuceneDocument");
        dbProperties.put("LuceneDocument.title", "Lucene records in their internal format");
    }/*from w w  w  . jav a  2s .  c  o  m*/
    super.initDB(dbname, srwHome, dbHome, dbPropertiesFileName, dbProperties);

    maxTerms = 10;
    position = 1;
    indexPath = dbProperties.getProperty("SRWLuceneDatabase.indexPath");
    log.debug("indexPath=" + indexPath);
    if (indexPath == null) {
        // let's see if we can find the right directory
        // maybe dbHome?
        try {
            if (IndexReader.indexExists(new SimpleFSDirectory(new File(dbHome))))
                indexPath = dbHome;
            else {
                File file = new File(dbHome);
                File[] dir = file.listFiles();
                for (int i = 0; i < dir.length; i++) {
                    if (dir[i].isDirectory()) {
                        if (IndexReader.indexExists(new SimpleFSDirectory(dir[i]))) {
                            indexPath = dir[i].getAbsolutePath();
                            break;
                        }
                    }
                }
            }
        } catch (Exception e) {
            log.error("Lucene indexPath not specified for database " + dbname);
            log.error("looking in dbHome " + dbHome + " or one of its subdirectories");
            throw new InstantiationException("Lucene indexPath not specified");
        }
        log.debug("indexPath=" + indexPath);
    }
    if (indexPath == null) {
        log.error("Lucene indexPath not specified for database " + dbname);
        log.error("and index not found in dbHome " + dbHome + " or one of its subdirectories");
        throw new InstantiationException("Lucene indexPath not specified");
    }
    try {
        searcher = new IndexSearcher(IndexReader.open(new SimpleFSDirectory(new File(indexPath))));
    } catch (Exception e) {
        log.error("Unable to create IndexSearcher with path=" + indexPath + " for database " + dbname);
        log.error(e, e);
        throw new InstantiationException(e.getMessage());
    }

    String translatorName = dbProperties.getProperty("SRWLuceneDatabase.CqlToLuceneQueryTranslator",
            "ORG.oclc.os.SRW.Lucene.BasicLuceneQueryTranslator");
    try {
        log.debug("creating translator " + translatorName);
        Class translatorClass = Class.forName(translatorName);
        log.debug("creating instance of class " + translatorClass);
        translator = (CqlQueryTranslator) translatorClass.newInstance();
        translator.init(dbProperties, this);
    } catch (Exception e) {
        log.error("Unable to create CqlToLuceneQueryTranslator class " + translatorName + " for database "
                + dbname);
        log.error(e, e);
        throw new InstantiationException(e.getMessage());
    }
    if (log.isDebugEnabled())
        log.debug("leaving SRWLuceneDatabase.init");
}

From source file:gda.data.scan.datawriter.NexusDataWriter.java

@Override
public synchronized void configureScanNumber(int _scanNumber) throws Exception {
    if (!fileNumberConfigured) {
        if (_scanNumber > 0) {
            // the scan or other datawriter has set the id
            scanNumber = _scanNumber;//from  w w  w  .j a  v a 2s  . c o  m
        } else {
            if (scanNumber <= 0) {
                setupProperties();
                // not set in a constructor so get from num tracker
                try {
                    NumTracker runNumber = new NumTracker(beamline);
                    // Get the next run number
                    scanNumber = runNumber.incrementNumber();
                } catch (IOException e) {
                    logger.error("ERROR: Could not instantiate NumTracker in NexusDataWriter().", e);
                    throw new InstantiationException(
                            "ERROR: Could not instantiate NumTracker in NexusDataWriter()." + e.getMessage());
                }
            }
        }
        //needs to use the same scan number
        if (createSrsFile) {
            srsFile.configureScanNumber(scanNumber);
        }
        fileNumberConfigured = true;
    }
}

From source file:org.xmlactions.mapping.xml_to_bean.PopulateClassFromXml.java

private void useAction(String actionName, List<KeyValue> keyvalues, Object object, String propertyName,
        Object value, XMLObject xo) throws ClassNotFoundException, InstantiationException,
        IllegalAccessException, InvocationTargetException, NoSuchMethodException, SecurityException,
        IllegalArgumentException, NoSuchFieldException {
    log.debug(actionName + " - " + object + propertyName + " - " + value);

    Class clas = Class.forName(actionName);
    Object p = clas.newInstance();
    if (!(p instanceof PopulateClassFromXmlInterface)) {
        throw new InstantiationException(
                actionName + " does not implement " + PopulateClassFromXmlInterface.class.getSimpleName());
    }/*from  ww w .j  av  a2 s.  c om*/
    PopulateClassFromXmlInterface pc = (PopulateClassFromXmlInterface) p;
    pc.performAction(keyvalues, object, propertyName, value, xo);

}

From source file:ancat.console.ConsoleModelChecker.java

/**
 * Loads the inspectors and stores them in an internal array. Inspectors that
 * cannot be instantiated are not loaded into the internal representation.
 *//*ww  w  .ja  va  2 s .c o m*/
public void prepareInspectors() throws InstantiationException {
    if (_inspectorObjects.size() > 0) {
        _logger.debug("inspectors are already initialized, function returns");
        return;
    }

    if (null != _inspectorData) {
        Iterator<Inspector> iter = _inspectorData.getInspector().iterator();

        try {
            while (iter.hasNext()) {
                Inspector i = iter.next();
                String implementation = i.getImplementation();

                Class<?> c = Class.forName(implementation);

                Object o = c.getConstructor().newInstance();

                if (o != null) {
                    _logger.debug("New object of type " + implementation + "created!");
                } else {
                    _logger.error("Object creation failed, type := " + implementation);
                    throw new InstantiationException("Object creation failed, type := " + implementation);
                }

                @SuppressWarnings("unchecked")
                GraphInspector<Vertex, Edge> io = (GraphInspector<Vertex, Edge>) o;

                /**
                 * The output of an inspector might be foreseen to be used by another
                 * inspector Therefore the 'use output' option is introduced.
                 */
                if (null != i.getUseoutput()) {
                    Inspector ii = (Inspector) i.getUseoutput();
                    io.setIdRef(ii.getId());
                }

                io.setId(i.getId());
                io.setInspectorConfiguration(i);

                _inspectorObjects.add(io);
            }
        } catch (Exception cnfe) {
            _logger.error("Error: ", cnfe);
        }

    } else {
        try {
            for (String inspector : _inspectors) {
                Class<?> c = Class.forName(inspector);

                Object o = c.getConstructor().newInstance();

                if (o != null)
                    _logger.debug("New object created!");
                else
                    _logger.error("Object creation failed!");

                @SuppressWarnings("unchecked")
                GraphInspector<Vertex, Edge> i = (GraphInspector<Vertex, Edge>) o;

                _inspectorObjects.add(i);
            }
        } catch (Exception e) {
            _logger.error("Error: ", e);
        }
    }
}

From source file:eu.larkc.core.executor.Executor.java

/**
 * This method saves the connection between inputs and outputs.
 * //ww  w  . j  a  v  a 2s .  co m
 * @throws InstantiationException
 * @throws IllegalWorkflowGraphException
 * @throws QueryEvaluationException
 * @throws MalformedQueryException
 * @throws RepositoryException
 */
private void initializeInputsAndOutputs() throws InstantiationException, IllegalWorkflowGraphException,
        RepositoryException, MalformedQueryException, QueryEvaluationException {
    Map<String, Input> inputInstances = new HashMap<String, Input>();
    Map<String, Output> outputInstances = new HashMap<String, Output>();

    // initialize all outputs
    Map<String, OutputNode> outputs = sparqlWorkflowDescription.getOutputs();
    Output output;
    String outputPluginId;
    PluginManager outputPluginManager;
    Queue<SetOfStatements> outputOutputQueue;
    for (Entry<String, OutputNode> entry : outputs.entrySet()) {
        output = new Output();
        outputPluginId = entry.getValue().getPluginId();

        outputOutputQueue = new Queue<SetOfStatements>();
        outputPluginManager = pluginManagerInstances.get(outputPluginId);
        outputPluginManager.addOutputQueue(outputOutputQueue, entry.getKey());
        logger.debug("Added output queue for {} ({})", pluginInstances.get(outputPluginId).toString(),
                entry.getKey());
        output.setPathOutputQueue(outputOutputQueue);
        output.setPluginManager(outputPluginManager);

        outputInstances.put(entry.getKey(), output);
    }

    Map<String, PathNode> stringPaths = sparqlWorkflowDescription.getPaths();

    // initialize all inputs
    Map<String, InputNode> inputs = sparqlWorkflowDescription.getInputs();
    Input input;
    List<String> inputPluginIds;
    PluginManager inputPluginManager;
    Queue<SetOfStatements> inputInputQueue;
    for (Entry<String, InputNode> entry : inputs.entrySet()) {
        input = new Input();
        inputPluginIds = entry.getValue().getPluginIds();

        for (String pluginId : inputPluginIds) {
            inputPluginManager = pluginManagerInstances.get(pluginId);
            for (Entry<String, PathNode> pathEntry : stringPaths.entrySet()) {
                inputInputQueue = new Queue<SetOfStatements>();
                inputPluginManager.addInputQueue(inputInputQueue, pathEntry.getKey());
                logger.debug("Added input queue for {} ({})", pluginInstances.get(pluginId).toString(),
                        pathEntry.getKey());
                if (pathEntry.getKey().equals(entry.getKey())) {
                    input.addPathInputQueue(inputInputQueue);
                    logger.debug("Added path input queue for {} ({})", pluginInstances.get(pluginId).toString(),
                            pathEntry.getKey());
                }
            }
        }

        inputInstances.put(entry.getKey(), input);
    }

    // initialize all paths
    Input tmpInput;
    Output tmpOutput;

    for (Entry<String, PathNode> path : stringPaths.entrySet()) {
        tmpInput = inputInstances.get(path.getKey());
        tmpOutput = outputInstances.get(path.getKey());

        if (tmpInput != null && tmpOutput != null) {
            pathInstances.put(path.getKey(), new Path(path.getKey(), tmpInput, tmpOutput));
            logger.debug("Added path {}", path.getKey());
        } else {
            throw new InstantiationException("Path could not be created: input or output is null");
        }
    }
}

From source file:se.skl.skltpservices.npoadapter.mapper.AbstractMapper.java

protected void initialiseValidator(String... xsds) {
    List<Source> schemaFiles = new ArrayList<Source>();
    for (String xsd : xsds) {
        schemaFiles.add(new StreamSource(getClass().getResourceAsStream(xsd)));
    }/*from ww  w. java2s .  c  om*/

    // Note - SchemaFactory is not threadsafe
    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    try {
        // Note - Schema is threadsafe
        schema = factory.newSchema(schemaFiles.toArray(new StreamSource[schemaFiles.size()]));
    } catch (SAXException s) {
        throw new RuntimeException(
                new InstantiationException("Failed to instantiate schema: " + s.getMessage()));
    }

}

From source file:org.apache.struts.tiles.ComponentDefinition.java

/**
 * Get or create controller./*  ww w  .  ja  va 2 s .  c  om*/
 * Get controller, create it if necessary.
 * @return controller if controller or controllerType is set, null otherwise.
 * @throws InstantiationException if an error occur while instanciating Controller :
 * (classname can't be instanciated, Illegal access with instanciated class,
 * Error while instanciating class, classname can't be instanciated.
 */
public Controller getOrCreateController() throws InstantiationException {

    if (controllerInstance != null) {
        return controllerInstance;
    }

    // Do we define a controller ?
    if (controller == null && controllerType == null) {
        return null;
    }

    // check parameters
    if (controllerType != null && controller == null) {
        throw new InstantiationException("Controller name should be defined if controllerType is set");
    }

    controllerInstance = createController(controller, controllerType);

    return controllerInstance;
}