Package org.apache.turbine.services

Examples of org.apache.turbine.services.InitializationException


                    String newPath =
                            config.getServletContext().getRealPath((String) subVal);

                    if (newPath == null)
                    {
                      throw new InitializationException("Could not translate path " + subVal);
                    }

                    subVal = newPath;
                    log.debug("Now: " + subVal);
                }

                loaderConf.addProperty(subProperty + "." + subKey,
                        subVal);
            }

            log.info("Added " + key + " as a component");
        }

        try
        {
            ComponentLoader cl = new ComponentLoader(loaderConf);
            components = cl.load();
            setInit(true);
        }
        catch (Exception e)
        {
            log.error("Component Service failed: ", e);
            throw new InitializationException("ComponentService failed: ", e);
        }
    }
View Full Code Here


            factoryService = (FactoryService) TurbineServices.getInstance().
                    getService(FactoryService.SERVICE_NAME);
        }
        catch (Exception e)
        {
            throw new InitializationException(
                    "Failed to get a Factory object: ", e);
        }

        setInit(true);
    }
View Full Code Here

        }
        catch (Exception e)
        {
            log.error("Failed to initialize JDNI contexts!", e);

            throw new InitializationException(
                    "Failed to initialize JDNI contexts!");
        }
    }
View Full Code Here

        }
        catch (Exception e)
        {
            log.error("Failed to initialize JDNI contexts!", e);

            throw new InitializationException(
                    "Failed to initialize JDNI contexts!");
        }
    }
View Full Code Here

                    throw new IllegalArgumentException(CACHE_CHECK_FREQUENCY + " must be >0");
                }
            }
            catch (Exception x)
            {
                throw new InitializationException(
                        "Failed to initialize TurbineGlobalCacheService", x);
            }
        }

        try
        {
            cache = new Hashtable(cacheInitialSize);

            // Start housekeeping thread.
            Thread housekeeping = new Thread(this);
            // Indicate that this is a system thread. JVM will quit only when there
            // are no more active user threads. Settings threads spawned internally
            // by Turbine as daemons allows commandline applications using Turbine
            // to terminate in an orderly manner.
            housekeeping.setDaemon(true);
            housekeeping.start();

            setInit(true);
        }
        catch (Exception e)
        {
            throw new InitializationException(
                    "TurbineGlobalCacheService failed to initialize", e);
        }
    }
View Full Code Here

                        classLoaders.add(
                                loadClass((String) loaders.get(i)).newInstance());
                    }
                    catch (Exception x)
                    {
                        throw new InitializationException(
                                "No such class loader '" +
                                (String) loaders.get(i) +
                                "' for TurbineFactoryService", x);
                    }
                }
View Full Code Here

        factoryService = TurbineFactory.getService();

        if (factoryService == null)
        {
            throw new InitializationException("Factory Service is not configured"
                    + " but required for the Pool Service!");
        }

        setInit(true);
    }
View Full Code Here

            String LOAD_ERROR = "No pathes for XML files were specified. " +
                    "Check that the property exists in " +
                    "TurbineResources.props and were loaded.";

            log.error(LOAD_ERROR);
            throw new InitializationException(LOAD_ERROR);
        }

        Set xmlFiles = new HashSet();

        long timeStamp = 0;

        for (Iterator it = xmlPathes.iterator(); it.hasNext();)
        {
            // Files are webapp.root relative
            String xmlPath = Turbine.getRealPath((String) it.next());
            File xmlFile = new File(xmlPath);

            log.debug("Path for XML File: " + xmlFile);

            if (!xmlFile.canRead())
            {
                String READ_ERR = "Could not read input file " + xmlPath;

                log.error(READ_ERR);
                throw new InitializationException(READ_ERR);
            }

            xmlFiles.add(xmlPath);

            log.debug("Added " + xmlPath + " as File to parse");

            // Get the timestamp of the youngest file to be compared with
            // a serialized file. If it is younger than the serialized file,
            // then we have to parse the XML anyway.
            timeStamp =
                    (xmlFile.lastModified() > timeStamp) ? xmlFile.lastModified() : timeStamp;
        }

        Map serializedMap = loadSerialized(serialDataPath, timeStamp);

        if (serializedMap != null)
        {
            // Use the serialized data as XML groups. Don't parse.
            appDataElements = serializedMap;
            log.debug("Using the serialized map");
        }
        else
        {
            // Parse all the given XML files
            appDataElements = new HashMap();

            for (Iterator it = xmlFiles.iterator(); it.hasNext();)
            {
                String xmlPath = (String) it.next();
                AppData appData = null;

                log.debug("Now parsing: " + xmlPath);
                try
                {
                    XmlToAppData xmlApp = new XmlToAppData();
                    appData = xmlApp.parseFile(xmlPath);
                }
                catch (Exception e)
                {
                    log.error("Could not parse XML file " + xmlPath, e);

                    throw new InitializationException("Could not parse XML file " +
                            xmlPath, e);
                }

                appDataElements.put(appData, xmlPath);
                log.debug("Saving appData for " + xmlPath);
            }

            saveSerialized(serialDataPath, appDataElements);
        }

        try
        {
            for (Iterator it = appDataElements.keySet().iterator(); it.hasNext();)
            {
                AppData appData = (AppData) it.next();

                int maxPooledGroups = 0;
                List glist = appData.getGroups();

                String groupPrefix = appData.getGroupPrefix();

                for (int i = glist.size() - 1; i >= 0; i--)
                {
                    XmlGroup g = (XmlGroup) glist.get(i);
                    String groupName = g.getName();

                    boolean registerUnqualified = registerGroup(groupName, g, appData, true);

                    if (!registerUnqualified)
                    {
                        log.info("Ignored redefinition of Group " + groupName
                                + " or Key " + g.getKey()
                                + " from " + appDataElements.get(appData));
                    }

                    if (groupPrefix != null)
                    {
                        StringBuffer qualifiedName = new StringBuffer();
                        qualifiedName.append(groupPrefix)
                                .append(':')
                                .append(groupName);

                        // Add the fully qualified group name. Do _not_ check for
                        // the existence of the key if the unqualified registration succeeded
                        // (because then it was added by the registerGroup above).
                        if (!registerGroup(qualifiedName.toString(), g, appData, !registerUnqualified))
                        {
                            log.error("Could not register fully qualified name " + qualifiedName
                                    + ", maybe two XML files have the same prefix. Ignoring it.");
                        }
                    }

                    maxPooledGroups =
                            Math.max(maxPooledGroups,
                                    Integer.parseInt(g.getPoolCapacity()));

                }

                KeyedPoolableObjectFactory factory =
                        new Group.GroupFactory(appData);
                keyedPools.put(appData, new StackKeyedObjectPool(factory, maxPooledGroups));
            }

            setInit(true);
        }
        catch (Exception e)
        {
            throw new InitializationException(
                    "TurbineIntakeService failed to initialize", e);
        }
    }
View Full Code Here

            {
                tm = (Mapper) TurbineFactory.getInstance(mapperClass);
            }
            catch (TurbineException te)
            {
                throw new InitializationException("", te);
            }

            tm.setUseCache(useCache);
            tm.setCacheSize(mapperCacheSize[i]);
            tm.setDefaultProperty(mapperDefaultProperty[i]);
View Full Code Here

            File testDir = new File(testPath);
            if (!testDir.exists())
            {
                if (!testDir.mkdirs())
                {
                    throw new InitializationException(
                            "Could not create target directory!");
                }
            }
            repoPath = testPath;
            conf.setProperty(UploadService.REPOSITORY_KEY, repoPath);
View Full Code Here

TOP

Related Classes of org.apache.turbine.services.InitializationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.