Package org.jpox

Examples of org.jpox.PersistenceConfiguration


     */
    protected MappedStoreManager(String key, ClassLoaderResolver clr, OMFContext omfContext)
    {
        super(key, clr, omfContext);

        PersistenceConfiguration conf = omfContext.getPersistenceConfiguration();
        if (readOnlyDatastore || fixedDatastore)
        {
            autoCreateTables = false;
            autoCreateColumns = false;
            autoCreateConstraints = false;
        }
        else
        {
            boolean autoCreateSchema = conf.getBooleanProperty("org.jpox.autoCreateSchema");
            if (autoCreateSchema)
            {
                autoCreateTables = true;
                autoCreateColumns = true;
                autoCreateConstraints = true;
            }
            else
            {
                autoCreateColumns = conf.getBooleanProperty("org.jpox.autoCreateColumns");
                autoCreateTables = conf.getBooleanProperty("org.jpox.autoCreateTables");
                autoCreateConstraints = conf.getBooleanProperty("org.jpox.autoCreateConstraints");
            }
        }
        autoCreateWarnOnError = conf.getBooleanProperty("org.jpox.autoCreateWarnOnError");

        validateTables = conf.getBooleanProperty("org.jpox.validateTables");
        if (!validateTables)
        {
            validateColumns = false;
        }
        else
        {
            validateColumns = conf.getBooleanProperty("org.jpox.validateColumns");
        }
        validateConstraints = conf.getBooleanProperty("org.jpox.validateConstraints");
    }
View Full Code Here


     * @param sm The state manager of the object to be inserted.
     * @throws JPOXDataStoreException when an error occurs in the datastore communication
     */
    public void insertObject(StateManager sm)
    {
        PersistenceConfiguration conf = storeMgr.getOMFContext().getPersistenceConfiguration();
        if (conf.getBooleanProperty("org.jpox.readOnlyDatastore"))
        {
            if (conf.getStringProperty("org.jpox.readOnlyDatastoreAction").equalsIgnoreCase("EXCEPTION"))
            {
                throw new DatastorePermissionException(LOCALISER.msg("032004",
                    StringUtils.toJVMIDString(sm.getObject())));
            }
            else
View Full Code Here

     * @param fieldNumbers The numbers of the fields to be updated.
     * @throws JPOXDataStoreException when an error occurs in the datastore communication
     */
    public void updateObject(StateManager sm, int fieldNumbers[])
    {
        PersistenceConfiguration conf = storeMgr.getOMFContext().getPersistenceConfiguration();
        if (conf.getBooleanProperty("org.jpox.readOnlyDatastore"))
        {
            if (conf.getStringProperty("org.jpox.readOnlyDatastoreAction").equalsIgnoreCase("EXCEPTION"))
            {
                throw new DatastorePermissionException(LOCALISER.msg("032006",
                    StringUtils.toJVMIDString(sm.getObject())));
            }
            else
View Full Code Here

     * @param sm The state manager of the object to be deleted.
     * @throws JPOXDataStoreException when an error occurs in the datastore communication
     */
    public void deleteObject(StateManager sm)
    {
        PersistenceConfiguration conf = storeMgr.getOMFContext().getPersistenceConfiguration();
        if (conf.getBooleanProperty("org.jpox.readOnlyDatastore"))
        {
            if (conf.getStringProperty("org.jpox.readOnlyDatastoreAction").equalsIgnoreCase("EXCEPTION"))
            {
                throw new DatastorePermissionException(LOCALISER.msg("032008",
                    StringUtils.toJVMIDString(sm.getObject())));
            }
            else
View Full Code Here

                    {
                        // Obtain a new connection
                        // Note : it may be worthwhile to use the PM's connection here however where a Sequence doesnt yet
                        // exist the connection would then be effectively dead until the end of the tx
                        // The way around this would be to find a way of checking for existence of the sequence
                        PersistenceConfiguration conf = om.getOMFContext().getPersistenceConfiguration();
                        int isolationLevel = TransactionUtils.getTransactionIsolationLevelForName(conf.getStringProperty("org.jpox.poid.transactionIsolation"));
                        this.mconn = ((RDBMSManager)storeManager).getConnection(isolationLevel);
                    }
                    catch (SQLException e)
                    {
                        String msg = LOCALISER.msg("017006", e);
View Full Code Here

     * Test the lookup of adapter from the product name.
     * @throws SQLException
     */
    public void testDatabaseProductNames() throws SQLException
    {
        OMFContext ctxt = new OMFContext(new PersistenceConfiguration(){});
        PluginManager pluginMgr = ctxt.getPluginManager();
        ClassLoaderResolver clr = ctxt.getClassLoaderResolver(null);

        RDBMSAdapterFactory factory = RDBMSAdapterFactory.getInstance();

View Full Code Here

     */
    public RDBMSManager(ClassLoaderResolver clr, OMFContext omfContext)
    {
        super("rdbms", clr, omfContext);

        PersistenceConfiguration conf = omfContext.getPersistenceConfiguration();
        checkExistTablesOrViews = conf.getBooleanProperty("org.jpox.rdbms.CheckExistTablesOrViews");

        try
        {
            connProvider = (ConnectionProvider) omfContext.getPluginManager().createExecutableExtension(
                    "org.jpox.store_connectionprovider", "name",
                    conf.getStringProperty("org.jpox.store.connectionProvider.Name"),
                    "class-name", null, null);
            if (connProvider == null)
            {
                // No provider with this name (missing plugin ?)
                throw new JPOXException(LOCALISER_RDBMS.msg("050000",
                    conf.getStringProperty("org.jpox.store.connectionProvider.Name"))).setFatal();
            }
            connProvider.setFailOnError(conf.getBooleanProperty("org.jpox.connectionProvider.FailOnError"));
        }
        catch (Exception e)
        {
            // Error creating provider
            throw new JPOXException(LOCALISER.msg("050001",
                conf.getStringProperty("org.jpox.store.connectionProvider.Name"), e.getMessage()), e).setFatal();
        }

        // Handler for persistence operations
        persistenceHandler = new RDBMSPersistenceHandler(this);

        // Retrieve the Database Adapter for this datastore
        try
        {
            ManagedConnection mc = getConnection();
            Connection conn = (Connection)mc.getConnection();
            if (conn == null)
            {
                //somehow we haven't got an exception from the JDBC driver
                //to troubleshoot the user should telnet to ip/port of database and check if he can open a connection
                //this may be due to security / firewall things.
                throw new JPOXDataStoreException(LOCALISER_RDBMS.msg("050007"));
            }

            try
            {
                dba = RDBMSAdapterFactory.getInstance().getDatastoreAdapter(clr, conn,
                    conf.getStringProperty("org.jpox.datastoreAdapterClassName"),
                    omfContext.getPluginManager());
                dba.loadDatastoreMapping(omfContext.getPluginManager(), clr);

                // Check if the user has specified DefaultCatalogName/DefaultSchemaName and whether the DBA allows it
                if (conf.hasProperty("org.jpox.mapping.Catalog") && !((RDBMSAdapter)dba).supportsCatalogsInTableDefinitions())
                {
                   JPOXLogger.DATASTORE.warn(LOCALISER_RDBMS.msg("050002",
                       conf.getStringProperty("org.jpox.mapping.Catalog")));
                }
                if (conf.hasProperty("org.jpox.mapping.Schema") && !((RDBMSAdapter)dba).supportsSchemasInTableDefinitions())
                {
                    JPOXLogger.DATASTORE.warn(LOCALISER_RDBMS.msg("050003",
                        conf.getStringProperty("org.jpox.mapping.Schema")));
                }

                // Create an identifier factory - needs the database adapter to exist first
                initialiseIdentifierFactory(omfContext);

                // Create the SQL controller
                sqlController = new SQLController(((RDBMSAdapter)dba).supportsStatementBatching(),
                    conf.getIntProperty("org.jpox.rdbms.statementBatchLimit"),
                    conf.getIntProperty("org.jpox.query.timeout"));

                if (autoStartMechanism == null)
                {
                    // No auto-start specified so use RDBMS default of SchemaTable
                    // TODO When CORE-3328 is fixed change this to "SchemaTable2"
                    autoStartMechanism = "SchemaTable";
                }

                // Initialise the Schema "Name", and "Data"
                initialiseSchema(autoStartMechanism, conf.getStringProperty("org.jpox.autoStartMechanismMode"),
                    conn, clr);
            }
            finally
            {
                mc.close();
View Full Code Here

     */
    protected void logConfiguration()
    {
        if (JPOXLogger.DATASTORE.isDebugEnabled())
        {
            PersistenceConfiguration conf = getOMFContext().getPersistenceConfiguration();

            String classNames = conf.getStringProperty("org.jpox.autoStartClassNames");
            JPOXLogger.DATASTORE.debug("======================= Datastore =========================");
            JPOXLogger.DATASTORE.debug("StoreManager : \"" + storeManagerKey + "\" (" + getClass().getName() + ")");
            JPOXLogger.DATASTORE.debug("AutoStart : mechanism=" + autoStartMechanism +
                ", mode=" + conf.getStringProperty("org.jpox.autoStartMechanismMode") +
                ((classNames != null) ? (", classes=" + classNames) : ""));
            JPOXLogger.DATASTORE.debug("Connection Pooling : " + conf.getStringProperty("org.jpox.connectionPoolingType"));
            if (identifierFactory != null)
            {
                JPOXLogger.DATASTORE.debug("Datastore Identifiers :" +
                    " factory=\"" + conf.getStringProperty("org.jpox.identifierFactory") + "\"" +
                    " case=" + identifierFactory.getNameOfIdentifierCase() +
                    (conf.hasProperty("org.jpox.mapping.Catalog") ? (" catalog=" + conf.getStringProperty("org.jpox.mapping.Catalog")) : "") +
                    (conf.hasProperty("org.jpox.mapping.Schema") ? (" schema=" + conf.getStringProperty("org.jpox.mapping.Schema")) : ""));
            }
            JPOXLogger.DATASTORE.debug("Datastore : " + (readOnlyDatastore ? "read-only" : "read-write") +
                (fixedDatastore ? ", fixed" : "") +
                (conf.getBooleanProperty("org.jpox.rdbms.useUpdateLock") ? ", useUpdateLock" : "") +
                (conf.getBooleanProperty("org.jpox.rdbms.CheckExistTablesOrViews") ? ", checkTableViewExistence" : "") +
                ", rdbmsConstraintCreateMode=" + conf.getStringProperty("org.jpox.rdbms.constraintCreateMode") +
                ", initialiseColumnInfo=" + conf.getStringProperty("org.jpox.rdbms.initializeColumnInfo"));

            // Auto-Create
            StringBuffer autoCreateOptions = null;
            if (autoCreateTables || autoCreateColumns || autoCreateConstraints)
            {
                autoCreateOptions = new StringBuffer();
                boolean first = true;
                if (autoCreateTables)
                {
                    if (!first)
                    {
                        autoCreateOptions.append(",");
                    }
                    autoCreateOptions.append("Tables");
                    first = false;
                }
                if (autoCreateColumns)
                {
                    if (!first)
                    {
                        autoCreateOptions.append(",");
                    }
                    autoCreateOptions.append("Columns");
                    first = false;
                }
                if (autoCreateConstraints)
                {
                    if (!first)
                    {
                        autoCreateOptions.append(",");
                    }
                    autoCreateOptions.append("Constraints");
                    first = false;
                }
            }

            // Validate
            StringBuffer validateOptions = null;
            if (validateTables || validateColumns || validateConstraints)
            {
                validateOptions = new StringBuffer();
                boolean first = true;
                if (validateTables)
                {
                    validateOptions.append("Tables");
                    first = false;
                }
                if (validateColumns)
                {
                    if (!first)
                    {
                        validateOptions.append(",");
                    }
                    validateOptions.append("Columns");
                    first = false;
                }
                if (validateConstraints)
                {
                    if (!first)
                    {
                        validateOptions.append(",");
                    }
                    validateOptions.append("Constraints");
                    first = false;
                }
            }

            JPOXLogger.DATASTORE.debug("Schema Control : " +
                "AutoCreate(" + (autoCreateOptions != null ? autoCreateOptions.toString() : "None") + ")" +
                ", Validate(" + (validateOptions != null ? validateOptions.toString() : "None") + ")");

            int batchLimit = conf.getIntProperty("org.jpox.rdbms.statementBatchLimit");
            JPOXLogger.DATASTORE.debug("Statement Batching : max-batch-size=" +
                (batchLimit == -1 ? "UNLIMITED" : "" + batchLimit));
            String[] queryLanguages = getOMFContext().getPluginManager().getAttributeValuesForExtension("org.jpox.store_query_query",
                "datastore", storeManagerKey, "name");
            JPOXLogger.DATASTORE.debug("Query Languages : " + StringUtils.objectArrayToString(queryLanguages));
            JPOXLogger.DATASTORE.debug("Queries : Timeout=" + conf.getIntProperty("org.jpox.query.timeout"));
            JPOXLogger.DATASTORE.debug("Queries : Results " +
                "direction=" + conf.getStringProperty("org.jpox.rdbms.query.fetchDirection") +
                ", type=" + conf.getStringProperty("org.jpox.rdbms.query.resultSetType") +
                ", concurrency=" + conf.getStringProperty("org.jpox.rdbms.query.resultSetConcurrency"));

            // Log the datastore adapter configuration
            if (dba != null)
            {
                ((RDBMSAdapter)dba).logConfiguration();
View Full Code Here

     * Relies on the datastore adapter existing before creation
     * @param omfContext ObjectManagerFactory context
     */
    protected void initialiseIdentifierFactory(OMFContext omfContext)
    {
        PersistenceConfiguration conf = omfContext.getPersistenceConfiguration();
        String idFactoryName = conf.getStringProperty("org.jpox.identifierFactory");
        String idFactoryClassName = omfContext.getPluginManager().getAttributeValueForExtension("org.jpox.store_identifierfactory",
            "name", idFactoryName, "class-name");
        if (idFactoryClassName == null)
        {
            throw new JPOXUserException(LOCALISER.msg("039003", idFactoryName)).setFatal();
        }

        try
        {
            // Create the IdentifierFactory
            Class cls = Class.forName(idFactoryClassName);
            Class[] argTypes = new Class[]
                {DatastoreAdapter.class, String.class, String.class, String.class, String.class, String.class, String.class};
            Object[] args = new Object[]
                {
                    dba,
                    conf.getStringProperty("org.jpox.mapping.Catalog"),
                    conf.getStringProperty("org.jpox.mapping.Schema"),
                    conf.getStringProperty("org.jpox.identifier.case"),
                    conf.getStringProperty("org.jpox.identifier.wordSeparator"),
                    conf.getStringProperty("org.jpox.identifier.tablePrefix"),
                    conf.getStringProperty("org.jpox.identifier.tableSuffix")
                };
            identifierFactory = (IdentifierFactory)ClassUtils.newInstance(cls, argTypes, args);
        }
        catch (ClassNotFoundException cnfe)
        {
View Full Code Here

                                  Connection conn,
                                  ClassLoaderResolver clr)
    throws Exception
    {
        // Initialise the Catalog/Schema names
        PersistenceConfiguration conf = omfContext.getPersistenceConfiguration();
        RDBMSAdapter rdba = (RDBMSAdapter)dba;
        if ((conf.hasProperty("org.jpox.mapping.Catalog") && rdba.supportsCatalogsInTableDefinitions()) ||
            (conf.hasProperty("org.jpox.mapping.Schema") && rdba.supportsSchemasInTableDefinitions()))
        {
            // User-specified catalog/schema
            catalogName = conf.getStringProperty("org.jpox.mapping.Catalog");
            schemaName = conf.getStringProperty("org.jpox.mapping.Schema");
        }
        else
        {
            // TODO Should we bother with this if the RDBMS doesnt support catalog/schema in the table identifiers ?
            // Try to find the catalog/schema from the connection
View Full Code Here

TOP

Related Classes of org.jpox.PersistenceConfiguration

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.