public static JVSTMBackEnd getInstance() { return (JVSTMBackEnd) FenixFramework.getConfig().getBackEnd(); }
/** * Returns the {@link Project} associated with the running application. */ public static Project getProject() { try { return Project.fromName(config.getAppName()); } catch (Exception e) { // If no appName is defined or an error occurs, // just return nothing... return null; } }
protected void setProperty(String propName, String value) { // first check if it really exists Field field = null; try { field = getField(this.getClass(), propName); } catch (ConfigError e) { // we choose to ignore unknown config properties, but we do give a loud warning logger.warn(e.getMessage()); logger.debug(e.getMessage(), e); return; } // note that lazy evaluation is used on purpose! boolean success = attemptSetPropertyUsingMethod(getSetterFor(this.getClass(), propName + SETTER_FROM_STRING), value) || attemptSetPropertyUsingField(field, value); if (!success) { throw new ConfigError(ConfigError.COULD_NOT_SET_PROPERTY, propName); } }
/** * This method is invoked by the {@link FenixFramework#initialize(Config)}. */ protected final void initialize() { checkConfig(); init(); }
public static JvstmDataGridBackEnd getInstance() { return (JvstmDataGridBackEnd) FenixFramework.getConfig().getBackEnd(); }
public static String getAppName() { return FenixFramework.getConfig().getAppName(); }
public static JvstmLockFreeBackEnd getInstance() { return (JvstmLockFreeBackEnd) FenixFramework.getConfig().getBackEnd(); }
public static String getAppName() { return FenixFramework.getConfig().getAppName(); }
public static JvstmIspnBackEnd getInstance() { return (JvstmIspnBackEnd) FenixFramework.getConfig().getBackEnd(); }
public static JvstmClusterBackEnd getInstance() { return (JvstmClusterBackEnd) FenixFramework.getConfig().getBackEnd(); }
public static <T extends DomainObject> T readDomainObject(ResultSet rs, String columnName) throws SQLException { long oid = rs.getLong(columnName); return (T) ((oid == 0) ? null : FenixFramework.getConfig().getBackEnd().fromOid(oid)); }
/** * Always gets a well-known singleton instance of {@link DomainRoot}. The intended use of this * instance is to provide a single entry point to the graph of {@link DomainObject}s. The user * of the framework may connect (via DML) any {@link DomainObject} to this class. */ public static DomainRoot getDomainRoot() { return getConfig().getBackEnd().getDomainRoot(); }
/** * Determines whether a given {@link DomainObject} is valid, meaning that its properties can be safely accessed. * * @param object * The object to verify * @return * {@code true} if the provided object is valid, {@code false} otherwise. */ public static boolean isDomainObjectValid(DomainObject object) { return getConfig().getBackEnd().isDomainObjectValid(object); }
/** * Returns whether the current Fenix Framework instance is a newly created one. * * The goal of this method is to allow applications to perform application-specific initialization, * such as presenting a configuration wizard. * * @return * {@code true} if this is a new Fenix Framework instance, {@code false} otherwise. */ public static boolean isNewInstance() { return getConfig().getBackEnd().isNewInstance(); }
/** * Subclasses of this class can overwrite this method, but they should specifically call <code>super.shutdown()</code> to * orderly shutdown the framework. */ protected void shutdown() { FenixFrameworkThread.shutdownAllThreads(); getBackEnd().shutdown(); }
public static TransactionManager getTransactionManager() { return getConfig().getBackEnd().getTransactionManager(); }
/** * Get any {@link DomainObject} given its external identifier. * * The external identifier must have been obtained by a previous invocation to {@link DomainObject#getExternalId}. If the * external identifier is tampered with (in which case a * valid {@link DomainObject} cannot be found), the result of calling this method is undefined. * * @param externalId The external identifier of the domain object to get * @return The domain object requested * */ public static <T extends DomainObject> T getDomainObject(String externalId) { return getConfig().getBackEnd().getDomainObject(externalId); }
/** * Serializes the given map to a JSON object containing a mapping between the * External Ids of the Key and Value objects. * * Uses {@link BPlusTree.LAST_KEY_REPRESENTATION} as a well-known value to * represent the Last Key. * * @param map * Map to serialize. Must be in the form [Oid, AbstractNode] * @return * A JSON Object containing the mapping */ public static String externalizeOidIndexedMap(TreeMap map) { BackEnd backend = FenixFramework.getConfig().getBackEnd(); JsonObject jsonObject = new JsonObject(); for (Object obj : map.entrySet()) { Entry<Comparable, AbstractNode> entry = (Entry<Comparable, AbstractNode>) obj; String key; if (entry.getKey().equals(BPlusTree.LAST_KEY)) { key = BPlusTree.LAST_KEY.toString(); } else { key = backend.fromOid(entry.getKey()).getExternalId(); } jsonObject.add(key, new JsonPrimitive(entry.getValue().getExternalId())); } return jsonObject.toString(); }
public static AbstractDomainObject readObjectFromRs(ResultSet rs) { // this method tries to load the object from its OID // see whether the OID column in the resultSet is already filled try { long objectOid = rs.getLong("OID"); if (objectOid != 0) { // if it is, then we may get the object by its OID and skip all the old stuff AbstractDomainObject materializedObject = FenixFramework.getConfig().getBackEnd().fromOid(objectOid); materializedObject.readFromResultSet(rs); return materializedObject; } } catch (SQLException sqle) { // we may have an SQLException if, for example, there is no OID column // in that case, simply ignore this and continue with the old code sqle.printStackTrace(); } // null means that something failed return null; } }
@Override protected void deleteDomainObject() { this.invokeDeletionListeners(); try { Field cacheField = SharedIdentityMap.class.getDeclaredField("cache"); cacheField.setAccessible(true); ConcurrentHashMap<Object, ?> cache = (ConcurrentHashMap<Object, ?>) cacheField.get(SharedIdentityMap.getCache()); cache.remove(this.getOid()); ((InMemDomainObjectValidBackEnd) FenixFramework.getConfig().getBackEnd()) .deleteObject(this.getOid()); } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); } } }