/** * Understands and applies the following integer properties. * * <ul> * <li>max.size - setMaximumSize * <li>max.threads - setMaximumThreads * <li>timeout.idle - setIdleTimeout * <li>timeout.transaction - setTransactionTimeout * <li>tune.size - Automatically tunes queue size when "true" and transaction timeout set. * <li>tune.threads - Automatically tunes maximum thread count. * </ul> */ public synchronized void applyProperties(PropertyMap properties) { if (properties.containsKey("max.size")) { setMaximumSize(properties.getInt("max.size")); } if (properties.containsKey("max.threads")) { setMaximumThreads(properties.getInt("max.threads")); } if (properties.containsKey("timeout.idle")) { setIdleTimeout(properties.getNumber("timeout.idle").longValue()); } if (properties.containsKey("timeout.transaction")) { setTransactionTimeout(properties.getNumber("timeout.transaction").longValue()); } if ("true".equalsIgnoreCase(properties.getString("tune.size"))) { addTransactionQueueListener(new TransactionQueueSizeTuner()); } if ("true".equalsIgnoreCase(properties.getString("tune.threads"))) { addTransactionQueueListener(new TransactionQueueThreadTuner()); } }
public void testSimpleSearchOnNode() { try { final PropertyMap properties = new PropertyMap(); final PropertyKey<String> key = TestFour.stringProperty; properties.put(key, "test"); final TestFour testEntity = createTestNode(TestFour.class, properties); assertNotNull(testEntity); try (final Tx tx = app.tx()) { // check value from database assertEquals("test", testEntity.getProperty(key)); Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, "test").getResult(); assertEquals(result.size(), 1); assertEquals(result.get(0), testEntity); } } catch (FrameworkException fex) { fail("Unable to store array"); } }
@Override public void setPropertyNode(String propertyName, Node defSite) { Property property = properties.getOwnProperty(propertyName); if (property != null) { property.setNode(defSite); } }
private Object readResolve() { if (allocatorMap.size() == DEFAULT_STRATEGY.allocatorMap.size() && allocatorClassName.equals(DEFAULT_STRATEGY.allocatorClassName)) { return DEFAULT_STRATEGY; } return this; }
/** * Set a property, if the value is null, the property is removed. * * @param propertyType the property type * @param propertyValue the property value * @throws NullPointerException if the property type is null */ public <T> Response with(PropertyType<T> propertyType, T propertyValue) throws NullPointerException { if (propertyType == null) { throw new NullPointerException("No null property type allowed"); } properties.addValue(propertyType, propertyValue); return this; }
@Override public String toString() { return "AllocationStrategy[allocatorClassName=" + allocatorClassName + ", allocatorMap.size=" + allocatorMap.size() + "]"; }
@Override public void setPropertyJSDocInfo(String propertyName, JSDocInfo info) { if (info != null) { if (properties.getOwnProperty(propertyName) == null) { // If docInfo was attached, but the type of the property // was not defined anywhere, then we consider this an explicit // declaration of the property. defineInferredProperty(propertyName, getPropertyType(propertyName), null); } // The prototype property is not represented as a normal Property. // We probably don't want to attach any JSDoc to it anyway. Property property = properties.getOwnProperty(propertyName); if (property != null) { property.setJSDocInfo(info); } } }
@Override boolean defineProperty(String name, JSType type, boolean inferred, Node propertyNode) { if (hasOwnDeclaredProperty(name)) { return false; } Property newProp = new Property(name, type, inferred, propertyNode); properties.putProperty(name, newProp); return true; }
@Override JSType resolveInternal(ErrorReporter t, StaticTypedScope<JSType> scope) { setResolvedTypeInternal(this); ObjectType implicitPrototype = getImplicitPrototype(); if (implicitPrototype != null) { implicitPrototypeFallback = (ObjectType) implicitPrototype.resolve(t, scope); } for (Property prop : properties.values()) { prop.setType(safeResolve(prop.getType(), t, scope)); } return this; }
@Override public boolean removeProperty(String name) { return properties.removeProperty(name); }
public class Library { public static interface Format { String getExtension(); } public static class LglFormat implements Format { public static final String EXTENSION = ".lgl"; // $NON-NLS-1$ protected int iconColumns; public LglFormat(int iconColumns) { this.iconColumns = iconColumns; } public int getIconColumns() { return iconColumns; } @Override public String getExtension() { return EXTENSION; } } public static class LibFormat implements Format { public static final LibFormat LIB520 = new LibFormat(520); public static final LibFormat LIB500 = new LibFormat(500); public static final String EXTENSION = ".lib"; // $NON-NLS-1$ protected int version; public LibFormat(int version) { this.version = version; } public int getVersion() { return version; } @Override public String getExtension() { return EXTENSION; } } public static int randomId() { return new Random().nextInt(999000) + 1000; } public File sourceFile; public Format format; public ObservableList<Action> actions = new ActiveArrayList<Action>(); /*package*/ static int lastActionId; // only accessible to Action public enum PLibrary { CAPTION, ID, AUTHOR, VERSION, CHANGED, INFO, INIT_CODE, ADVANCED } private static final EnumMap<PLibrary, Object> DEFS = PropertyMap.makeDefaultMap( PLibrary.class, null, null /*set at init*/, null, 100, null /*set at init*/, null, null, false); public final PropertyMap<PLibrary> properties = new PropertyMap<PLibrary>(PLibrary.class, DEFS); public Library() { lastActionId = 1; put(PLibrary.ID, randomId()); put(PLibrary.CHANGED, longTimeToGmTime(System.currentTimeMillis())); } public void put(PLibrary key, Object value) { properties.put(key, value); } public <V> V get(PLibrary key) { return properties.get(key); } public static Calendar gmBaseTime() { Calendar res = Calendar.getInstance(); res.set(1899, 11, 29, 23, 59, 59); return res; } public static double longTimeToGmTime(long time) { return (time - gmBaseTime().getTimeInMillis()) / 86400000d; } }
public <V> V get(PLibrary key) { return properties.get(key); }
public void put(PLibrary key, Object value) { properties.put(key, value); }
private boolean matches(final AllocatorDescriptor desc) { return desc.getAllocatorMap().size() == allocatorMap.size() && desc.getAllocatorClassName().equals(allocatorClassName); }