private void assertAllModifiersCovered() { Set<String> coveredModifiers = Sets.newHashSet("NONE", "DIRTY_READ", "EXCLUSIVE_READ_LOCK", "FIFO_GROUPING_POLL", "FIFO", "IF_EXISTS", "IGNORE_PARTIAL_FAILURE", "MEMORY_ONLY_SEARCH", "READ_COMMITTED", "REPEATABLE_READ"); Set<String> actualModifiers = new Constants(ReadModifiers.class).getNames(""); Assert.assertEquals("Missing modifier should be added to openspaces-core.xsd!", coveredModifiers, actualModifiers); }
/** * Returns a String representation of the given <code>ServiceReference</code>. * * @param reference OSGi service reference (can be <code>null</code>) * @return String representation of the given service reference */ public static String nullSafeToString(ServiceReference reference) { if (reference == null) return NULL_STRING; StringBuilder buf = new StringBuilder(); Bundle owningBundle = reference.getBundle(); buf.append("ServiceReference [").append(OsgiStringUtils.nullSafeSymbolicName(owningBundle)).append("] "); String clazzes[] = (String[]) reference.getProperty(org.osgi.framework.Constants.OBJECTCLASS); buf.append(ObjectUtils.nullSafeToString(clazzes)); buf.append("={"); String[] keys = reference.getPropertyKeys(); for (int i = 0; i < keys.length; i++) { if (!org.osgi.framework.Constants.OBJECTCLASS.equals(keys[i])) { buf.append(keys[i]).append('=').append(reference.getProperty(keys[i])); if (i < keys.length - 1) { buf.append(','); } } } buf.append('}'); return buf.toString(); }
/** * Returns the bundle name and symbolic name - useful when logging bundle info. * * @param bundle OSGi bundle (can be null) * @return the bundle name and symbolic name */ public static String nullSafeNameAndSymName(Bundle bundle) { if (bundle == null) return NULL_STRING; Dictionary dict = bundle.getHeaders(); if (dict == null) return NULL_STRING; StringBuilder buf = new StringBuilder(); String name = (String) dict.get(org.osgi.framework.Constants.BUNDLE_NAME); if (name == null) buf.append(NULL_STRING); else buf.append(name); buf.append(" ("); String sname = (String) dict.get(org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME); if (sname == null) buf.append(NULL_STRING); else buf.append(sname); buf.append(")"); return buf.toString(); }
/** * @param modifierName The modifier constant name as defined in the relevant Modifiers class. * @see {@link WriteModifiers}, {@link ReadModifiers}, {@link TakeModifiers}, * {@link CoutModifiers}, {@link ClearModifiers}, {@link ChangeModifiers} */ @SuppressWarnings("unchecked") public void setModifierName(String modifierName) { Constants constants = getConstants(); if (!constants.getNames("").contains(modifierName)) { throw new IllegalArgumentException("Unknown modifier: " + modifierName + " for type: " + getObjectType()); } modifier = (T) constants.asObject(modifierName); }
private void assertAllModifiersCovered() { Set<String> coveredModifiers = Sets.newHashSet("NONE", "DIRTY_READ", "EXCLUSIVE_READ_LOCK", "MEMORY_ONLY_SEARCH", "READ_COMMITTED", "REPEATABLE_READ"); Set<String> actualModifiers = new Constants(CountModifiers.class).getNames(""); Assert.assertEquals("Missing modifier should be added to openspaces-core.xsd!", coveredModifiers, actualModifiers); }
private void assertAllModifiersCovered() { Set<String> coveredModifiers = Sets.newHashSet("NONE", "EVICT_ONLY", "MEMORY_ONLY_SEARCH"); Set<String> actualModifiers = new Constants(ClearModifiers.class).getNames(""); Assert.assertEquals("Missing modifier should be added to openspaces-core.xsd!", coveredModifiers, actualModifiers); }
private void assertAllModifiersCovered() { Set<String> coveredModifiers = Sets.newHashSet("NONE", "EVICT_ONLY", "FIFO_GROUPING_POLL", "FIFO", "IF_EXISTS", "IGNORE_PARTIAL_FAILURE", "MEMORY_ONLY_SEARCH"); Set<String> actualModifiers = new Constants(TakeModifiers.class).getNames(""); Assert.assertEquals("Missing modifier should be added to openspaces-core.xsd!", coveredModifiers, actualModifiers); }
private void assertAllModifiersCovered() { Set<String> coveredModifiers = Sets.newHashSet("NONE", "MEMORY_ONLY_SEARCH", "ONE_WAY", "RETURN_PREV_ON_UPDATE", "UPDATE_ONLY", "WRITE_ONLY", "UPDATE_OR_WRITE", "PARTIAL_UPDATE"); Set<String> actualModifiers = new Constants(WriteModifiers.class).getNames(""); Assert.assertEquals("Missing modifier should be added to openspaces-core.xsd!", coveredModifiers, actualModifiers); }
private void assertAllModifiersCovered() { Set<String> coveredModifiers = Sets.newHashSet("NONE", "MEMORY_ONLY_SEARCH", "ONE_WAY", "RETURN_DETAILED_RESULTS"); Set<String> actualModifiers = new Constants(ChangeModifiers.class).getNames(""); Assert.assertEquals("Missing modifier should be added to openspaces-core.xsd!", coveredModifiers, actualModifiers); }
@Override protected void postProcess(BeanDefinitionBuilder definitionBuilder, Element element) { List<Element> eventTypes = DomUtils.getChildElementsByTagName(element, EVENT_TYPE); if (eventTypes != null && eventTypes.size() > 0) { // compute event type int eventType = 0; Constants types = new Constants(Event.class); for (Iterator<Element> iter = eventTypes.iterator(); iter.hasNext();) { Element evenTypeElement = iter.next(); eventType |= types.asNumber(DomUtils.getTextValue(evenTypeElement)).intValue(); } definitionBuilder.addPropertyValue("eventTypes", Integer.valueOf(eventType)); } List<Element> nodeTypeNames = DomUtils.getChildElementsByTagName(element, NODE_TYPE_NAME); String[] nodeTypeValues = new String[nodeTypeNames.size()]; for (int i = 0; i < nodeTypeValues.length; i++) { nodeTypeValues[i] = DomUtils.getTextValue(nodeTypeNames.get(i)); } definitionBuilder.addPropertyValue(NODE_TYPE_NAME, nodeTypeValues); List<Element> uuids = DomUtils.getChildElementsByTagName(element, UUID); String[] uuidsValues = new String[uuids.size()]; for (int i = 0; i < uuidsValues.length; i++) { uuidsValues[i] = DomUtils.getTextValue(uuids.get(i)); } definitionBuilder.addPropertyValue(UUID, uuidsValues); //TODO, reference a listenerBean, it is not a propertyReference Element eventListner = DomUtils.getChildElementByTagName(element, "listener"); String listenerBeanRefName = DomUtils.getTextValue(eventListner); definitionBuilder.addPropertyReference("listener", listenerBeanRefName); }
public void setDefaultTransactionIsolationName(String constantName) { if (constantName == null) { throw new IllegalArgumentException("Isolation name must not be null"); } Constants constants = new Constants(Connection.class); setDefaultTransactionIsolation(constants.asNumber(PREFIX_ISOLATION + constantName).intValue()); }
/** * Returns a String representation of the given * <code>ServiceReference</code>. * * @param reference OSGi service reference (can be <code>null</code>) * @return String representation of the given service reference */ public static String nullSafeToString(ServiceReference reference) { if (reference == null) return NULL_STRING; StringBuffer buf = new StringBuffer(); Bundle owningBundle = reference.getBundle(); buf.append("ServiceReference [").append(OsgiStringUtils.nullSafeSymbolicName(owningBundle)).append("] "); String clazzes[] = (String[]) reference.getProperty(org.osgi.framework.Constants.OBJECTCLASS); buf.append(ObjectUtils.nullSafeToString(clazzes)); buf.append("={"); String[] keys = reference.getPropertyKeys(); for (int i = 0; i < keys.length; i++) { if (!org.osgi.framework.Constants.OBJECTCLASS.equals(keys[i])) { buf.append(keys[i]).append('=').append(reference.getProperty(keys[i])); if (i < keys.length - 1) { buf.append(','); } } } buf.append('}'); return buf.toString(); }
/** * Returns the bundle name and symbolic name - useful when logging bundle * info. * * @param bundle OSGi bundle (can be null) * @return the bundle name and symbolic name */ public static String nullSafeNameAndSymName(Bundle bundle) { if (bundle == null) return NULL_STRING; Dictionary dict = bundle.getHeaders(); if (dict == null) return NULL_STRING; StringBuffer buf = new StringBuffer(); String name = (String) dict.get(org.osgi.framework.Constants.BUNDLE_NAME); if (name == null) buf.append(NULL_STRING); else buf.append(name); buf.append(" ("); String sname = (String) dict.get(org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME); if (sname == null) buf.append(NULL_STRING); else buf.append(sname); buf.append(")"); return buf.toString(); }
@Override public void setSystemPropertiesModeName(String constantName) throws IllegalArgumentException { super.setSystemPropertiesModeName(constantName); Constants constants = new Constants(PropertyPlaceholderConfigurer.class); this.systemPropertiesMode = constants.asNumber(constantName).intValue(); }
@Override protected Constants getConstants() { return constants; }
/** * Returns the name of the given <code>Bundle</code> in a null-safe manner. * * @param bundle OSGi bundle (can be <code>null</code>) * @return bundle name */ public static String nullSafeName(Bundle bundle) { if (bundle == null) return NULL_STRING; Dictionary headers = bundle.getHeaders(); if (headers == null) return NULL_STRING; String name = (String) headers.get(org.osgi.framework.Constants.BUNDLE_NAME); return (name == null ? NULL_STRING : name); }
/** * Returns the name of the given <code>Bundle</code> in a null-safe * manner. * * @param bundle OSGi bundle (can be <code>null</code>) * @return bundle name */ public static String nullSafeName(Bundle bundle) { if (bundle == null) return NULL_STRING; Dictionary headers = bundle.getHeaders(); if (headers == null) return NULL_STRING; String name = (String) headers.get(org.osgi.framework.Constants.BUNDLE_NAME); return (name == null ? NULL_STRING : name); }
abstract protected Constants getConstants();