Examples of PersistenceConfiguration


Examples of org.jpox.PersistenceConfiguration

     */
    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

Examples of org.jpox.PersistenceConfiguration

     */
    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

Examples of org.jpox.PersistenceConfiguration

     * 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

Examples of org.jpox.PersistenceConfiguration

                                  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

Examples of org.jpox.PersistenceConfiguration

                    ManagedConnection mconn;
                    public ManagedConnection retrieveConnection()
                    {
                        try
                        {
                            PersistenceConfiguration conf = om.getOMFContext().getPersistenceConfiguration();
                            if (conf.getStringProperty("org.jpox.poid.transactionAttribute").equalsIgnoreCase("UsePM"))
                            {
                                this.mconn = thisStoreMgr.getConnection(om);
                            }
                            else
                            {
                                int isolationLevel = TransactionUtils.getTransactionIsolationLevelForName(
                                    conf.getStringProperty("org.jpox.poid.transactionIsolation"));
                                this.mconn = thisStoreMgr.getConnection(isolationLevel);
                            }
                        }
                        catch (SQLException e)
                        {
                            String msg = LOCALISER_RDBMS.msg("050024", e.getMessage());
                            JPOXLogger.POID.error(msg);
                            throw new JPOXDataStoreException(msg, e);
                        }
                        return mconn;
                    }

                    public void releaseConnection()
                    {
                        try
                        {
                            PersistenceConfiguration conf = om.getOMFContext().getPersistenceConfiguration();
                            if (conf.getStringProperty("org.jpox.poid.transactionAttribute").equalsIgnoreCase("UsePM"))
                            {
                                mconn.release();
                            }
                            else
                            {
View Full Code Here

Examples of org.jpox.PersistenceConfiguration

     * @param resourceType either tx or nontx
     */
    public ConnectionFactoryImpl(OMFContext omfContext, String resourceType)
    {
        this.omfContext = omfContext;
        PersistenceConfiguration config = omfContext.getPersistenceConfiguration();

        if (resourceType.equals("tx"))
        {
            initDataSourceTx(config);
        }
View Full Code Here

Examples of org.jpox.PersistenceConfiguration

        super();

        storeMgr = (RDBMSManager)store_mgr;

        // Create the auto-start table in the datastore, using any user-specified name
        PersistenceConfiguration conf = storeMgr.getOMFContext().getPersistenceConfiguration();
        String tableName = conf.getStringProperty("org.jpox.rdbms.schemaTable.tableName");
        schemaTable = new SchemaTable(storeMgr, tableName);
        schemaTable.initialize(clr);

        // We need to autocreate the table and validate it being correct.
        try
View Full Code Here

Examples of org.jpox.PersistenceConfiguration

     * @return The DataSource
     * @throws Exception Thrown if an error occurs during creation
     */
    public DataSource makePooledDataSource(OMFContext omfCtx)
    {
        PersistenceConfiguration conf = omfCtx.getPersistenceConfiguration();
        return new DriverManagerDataSource(
            conf.getStringProperty("org.jpox.ConnectionDriverName"),
            conf.getStringProperty("org.jpox.ConnectionURL"),
            conf.getStringProperty("org.jpox.ConnectionUserName"),
            conf.getStringProperty("org.jpox.ConnectionPassword"),
            omfCtx.getClassLoaderResolver(null));
    }
View Full Code Here

Examples of org.jpox.PersistenceConfiguration

            qs.setParent(parentExpr);
        }
        qs.setCandidateInformation(candidateClass, candidateAlias);

        // Apply any extensions for query generation
        PersistenceConfiguration config = query.getObjectManager().getOMFContext().getPersistenceConfiguration();
        String propName = "org.jpox.rdbms.jdoql.joinType";
        String joinType = config.getStringProperty(propName);
        if (query.getExtension(propName) != null)
        {
            String type = (String)query.getExtension(propName);
            if (type.toUpperCase().equals("INNER") || type.toUpperCase().equals("LEFT OUTER"))
            {
                joinType = type.toUpperCase();
            }
        }
        if (joinType != null)
        {
            qs.addExtension(propName, joinType);
        }

        propName = "org.jpox.rdbms.jdoql.existsIncludesConstraints";
        boolean existsIncludes = config.getBooleanProperty(propName);
        if (query.getExtension(propName) != null)
        {
            existsIncludes =
                Boolean.valueOf((String)query.getExtension(propName)).booleanValue();
            qs.addExtension(propName, "" + existsIncludes);
        }
        if (existsIncludes)
        {
            qs.addExtension(propName, "true");
        }

        propName = "org.jpox.rdbms.query.containsUsesExistsAlways";
        boolean existsAlways = config.getBooleanProperty(propName);
        if (query.getExtension(propName) != null)
        {
            existsAlways =
                Boolean.valueOf((String)query.getExtension(propName)).booleanValue();
            qs.addExtension(propName, "" + existsAlways);
View Full Code Here

Examples of org.jpox.PersistenceConfiguration

    protected void prepareStatementForExecution(PreparedStatement ps)
    throws SQLException
    {
        OMFContext omfCtx = om.getOMFContext();
        MappedStoreManager storeMgr = (MappedStoreManager)omfCtx.getStoreManager();
        PersistenceConfiguration conf = omfCtx.getPersistenceConfiguration();

        // Apply any user-specified timeout
        int timeout = conf.getIntProperty("org.jpox.query.timeout");
        Object timeoutExt = query.getExtension("org.jpox.query.timeout");
        if (timeoutExt != null)
        {
            // Accept timeout as an Integer or String
            if (timeoutExt instanceof Integer)
            {
                timeout = ((Integer)timeoutExt).intValue();
            }
            else if (timeoutExt instanceof String)
            {
                timeout = TypeConversionHelper.intFromString((String)timeoutExt, 0);
            }
        }
        if (timeout > 0)
        {
            ps.setQueryTimeout(timeout);
        }

        // Apply any fetch size
        int fetchSize = 0;
        if (query.getFetchPlan().getFetchSize() > 0)
        {
            // FetchPlan has a size set so use that
            fetchSize = query.getFetchPlan().getFetchSize();
        }
        if (storeMgr.getDatastoreAdapter().supportsQueryFetchSize(fetchSize))
        {
            ps.setFetchSize(fetchSize);
        }

        // Apply any fetch direction
        String propName = "org.jpox.rdbms.query.fetchDirection";
        String fetchDir = conf.getStringProperty(propName);
        Object fetchDirExt = query.getExtension(propName);
        if (fetchDirExt != null)
        {
            fetchDir = (String)fetchDirExt;
            if (!fetchDir.equals("forward") && !fetchDir.equals("reverse") && !fetchDir.equals("unknown"))
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.