Package org.jpox.plugin

Examples of org.jpox.plugin.ConfigurationElement


                ",Name=StoreManagerRuntime";
            mgntServer.registerMBean(this.storeManagerRuntime, mbeanName);
        }

        // Factory for connections - transactional
        ConfigurationElement cfElem = omfContext.getPluginManager().getConfigurationElementForExtension(
            "org.jpox.store_connectionfactory",
            new String[] {"datastore", "transactional"}, new String[] {storeManagerKey, "true"});
        if (cfElem != null)
        {
            txConnectionFactoryName = cfElem.getAttribute("name");
            try
            {
                ConnectionFactory cf = (ConnectionFactory)omfContext.getPluginManager().createExecutableExtension(
                    "org.jpox.store_connectionfactory",
                    new String[] {"datastore", "transactional"},
                    new String[] {storeManagerKey, "true"}, "class-name",
                    new Class[] {OMFContext.class, String.class},
                    new Object[] {omfContext, "tx"});
                omfContext.getConnectionFactoryRegistry().registerConnectionFactory(txConnectionFactoryName, cf);
                if (JPOXLogger.CONNECTION.isDebugEnabled())
                {
                    JPOXLogger.CONNECTION.debug(LOCALISER.msg("032018", txConnectionFactoryName));
                }
            }
            catch (Exception e)
            {
                throw new JPOXException("Error creating transactional connection factory", e).setFatal();
            }
        }
        else
        {
            throw new JPOXException("Error creating transactional connection factory. No connection factory plugin defined");
        }

        // Factory for connections - nontransactional
        cfElem = omfContext.getPluginManager().getConfigurationElementForExtension(
            "org.jpox.store_connectionfactory",
            new String[] {"datastore", "transactional"}, new String[] {storeManagerKey, "false"});
        if (cfElem != null)
        {
            nontxConnectionFactoryName = cfElem.getAttribute("name");
            try
            {
                ConnectionFactory cf = (ConnectionFactory)omfContext.getPluginManager().createExecutableExtension(
                    "org.jpox.store_connectionfactory",
                    new String[] {"datastore", "transactional"},
View Full Code Here


     * @param strategy The strategy
     * @return Whether it is supported.
     */
    public boolean supportsValueStrategy(String strategy)
    {
        ConfigurationElement elem =
            omfContext.getPluginManager().getConfigurationElementForExtension(
                "org.jpox.store_valuegenerator",
                new String[]{"name", "unique"},
                new String[] {strategy, "true"});
        if (elem != null)
View Full Code Here

        // Others are per class/field. Others have a user-defined name.
        // The name that they are cached under relates to what they use.
        // Generate the name for PoidManager to use the strategy for this field/class.
        String poidGeneratorName = null;
        String generatorNameKeyInManager = null;
        ConfigurationElement elem =
            omfContext.getPluginManager().getConfigurationElementForExtension("org.jpox.store_valuegenerator",
                new String[]{"name", "unique"}, new String[] {strategyName, "true"});
        if (elem != null)
        {
            // Unique value generator so set the key in PoidManager to the value generator name itself
            poidGeneratorName = elem.getAttribute("name");
            generatorNameKeyInManager = poidGeneratorName;
        }
        else
        {
            // Not a unique (datastore-independent) generator so try just for this datastore
            elem = omfContext.getPluginManager().getConfigurationElementForExtension("org.jpox.store_valuegenerator",
                new String[]{"name", "datastore"}, new String[] {strategyName, storeManagerKey});
            if (elem != null)
            {
                // Set the generator name (for use by the PoidManager)
                poidGeneratorName = elem.getAttribute("name");
            }
        }
        if (generatorNameKeyInManager == null)
        {
            // Value generator is not unique so set based on class/field
            if (absoluteFieldNumber >= 0)
            {
                // Require generation for a field so use field name for the generator symbolic name
                generatorNameKeyInManager = mmd.getFullFieldName();
            }
            else
            {
                // Require generation for a datastore id field so use the class name for the generator symbolic name
                generatorNameKeyInManager = cmd.getFullClassName();
            }
        }

        // Try to find the generator from the PoidManager if we already have it managed
        PoidGenerator generator = poidManager.getPoidGenerator(generatorNameKeyInManager);
        if (generator == null)
        {
            if (poidGeneratorName == null)
            {
                // No available value-generator for the specified strategy for this datastore
                throw new JPOXUserException(LOCALISER.msg("038004", strategy));
            }

            // Set up the default properties available for all value generators
            Properties props = getPropertiesForGenerator(cmd, absoluteFieldNumber, om, sequenceMetaData,
                tableGeneratorMetaData);

            Class cls = null;
            if (elem != null)
            {
                cls = omfContext.getPluginManager().loadClass(elem.getExtension().getPlugin().getSymbolicName(),
                    elem.getAttribute("class-name"));
            }
            if (cls == null)
            {
                throw new JPOXException("Cannot create Poid Generator for strategy " + poidGeneratorName);
            }
View Full Code Here

            // Create if not already present
            String implCreatorName = persistenceConfig.getStringProperty("org.jpox.implementationCreatorName");
            try
            {
                Class cls = null;
                ConfigurationElement elem =
                    getPluginManager().getConfigurationElementForExtension("org.jpox.implementation_creator",
                        "name", implCreatorName);
                if (elem != null)
                {
                    try
                    {
                        cls = Class.forName(elem.getAttribute("class-name"), true,
                            ObjectManagerFactoryImpl.class.getClassLoader());
                        ic = (ImplementationCreator)cls.newInstance();
                    }
                    catch (Exception e)
                    {
View Full Code Here

                this.mconn = null;
            }
        };

        Class cls = null;
        ConfigurationElement elem =
            objectMgr.getOMFContext().getPluginManager().getConfigurationElementForExtension(
                "org.jpox.store_valuegenerator",
                new String[]{"name", "datastore"},
                new String[] {poidGeneratorName, storeManager.getStoreManagerKey()});
        if (elem != null)
        {
            cls = objectMgr.getOMFContext().getPluginManager().loadClass(
                elem.getExtension().getPlugin().getSymbolicName(), elem.getAttribute("class-name"));
        }
        if (cls == null)
        {
            throw new JPOXException("Cannot create Poid Generator for strategy "+poidGeneratorName);
        }
View Full Code Here

                        throw new JDODataStoreException(msg, e);
                    }
                }
            };
        Class cls = null;
        ConfigurationElement elem =
            objectMgr.getOMFContext().getPluginManager().getConfigurationElementForExtension("org.jpox.store_valuegenerator",
                new String[]{"name", "datastore"}, new String[] {poidGeneratorName, storeManager.getStoreManagerKey()});
        if (elem != null)
        {
            cls = objectMgr.getOMFContext().getPluginManager().loadClass(elem.getExtension().getPlugin().getSymbolicName(), elem.getAttribute("class-name"));
        }
        if( cls == null )
        {
            throw new JPOXException("Cannot create Poid Generator for strategy "+poidGeneratorName);
        }
View Full Code Here

            strategyName = cmd.getIdentityMetaData().getValueStrategy().getCustomName();
        }

        // Check the POID type being stored
        Class poidClass = Long.class;
        ConfigurationElement elem =
            storeMgr.getOMFContext().getPluginManager().getConfigurationElementForExtension(
                "org.jpox.store_valuegenerator",
                new String[]{"name", "unique"}, new String[] {strategyName, "true"});
        if (elem == null)
        {
            // Not datastore-independent, so try for this datastore
            elem = storeMgr.getOMFContext().getPluginManager().getConfigurationElementForExtension(
                    "org.jpox.store_valuegenerator",
                    new String[]{"name", "datastore"}, new String[] {strategyName, storeMgr.getStoreManagerKey()});
        }
        if (elem != null)
        {
            // Set the generator name (for use by the PoidManager)
            String generatorClassName = elem.getAttribute("class-name");
            Class generatorClass =
                getStoreManager().getOMFContext().getClassLoaderResolver(null).classForName(generatorClassName);
            try
            {
                Method storageClassMethod = generatorClass.getMethod("getStorageClass", null);
View Full Code Here

     * @param clr ClassLoader resolver for resolving the adapter class
     * @return the adapater class
     */
    protected Class getAdapterClass(PluginManager pluginMgr, String adapterClassName, String productName, ClassLoaderResolver clr)
    {
        ConfigurationElement highestMatchingAdapter = null;
        int highestPriority = Integer.MIN_VALUE;
        Extension[] ex = pluginMgr.getExtensionPoint("org.jpox.store_datastoreadapter").getExtensions();
        for (int i = 0; i < ex.length; i++)
        {
            ConfigurationElement[] confElm = ex[i].getConfigurationElements();
            for (int c = 0; c < confElm.length; c++)
            {
                if (adapterClassName != null)
                {
                    //if the user selected adapter is defined by one of the plug-ins use the classloader of the plug-in
                    if (confElm[c].getAttribute("class-name").equals(adapterClassName))
                    {
                        return pluginMgr.loadClass(confElm[c].getExtension().getPlugin().getSymbolicName(), confElm[c].getAttribute("class-name"));
                    }
                }
                else
                {
                    String vendorId = confElm[c].getAttribute("vendor-id");
                    if (productName.toLowerCase().indexOf(vendorId.toLowerCase()) >= 0)
                    {
                        int priority = Integer.parseInt(confElm[c].getAttribute("priority"));
                        if (priority >= highestPriority)
                        {
                            if (priority > highestPriority && highestMatchingAdapter != null)
                            {
                                JPOXLogger.DATASTORE.warn(LOCALISER.msg("051002",
                                    highestMatchingAdapter.getAttribute("class-name"), highestMatchingAdapter.getAttribute("vendor-id"),
                                    String.valueOf(priority), confElm[c].getAttribute("class-name")));
                            }
                            highestMatchingAdapter = confElm[c];
                            highestPriority = priority;
                        }
                    }
                }
            }
        }

        if (adapterClassName != null)
        {
            //if the user selected adapter was not found in one of the plug-ins, load from the ClassLoaderResolver
            return clr.classForName(adapterClassName, false);
        }

        if (highestMatchingAdapter != null)
        {
            return pluginMgr.loadClass(highestMatchingAdapter.getExtension().getPlugin().getSymbolicName(), highestMatchingAdapter.getAttribute("class-name"));                       
        }

        return null;
    }
View Full Code Here

TOP

Related Classes of org.jpox.plugin.ConfigurationElement

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.