/** * Retrieves an object given a key. * * @param key - if not found, will return null * @return Returns the property. */ public Object getProperty(String key) { Object obj = properties == null ? null : properties.get(key); if (obj!=null) { // Assume that a property which is read may be updated. // i.e. The object pointed to by 'value' may be modified after it is read if(!isClusteringCheckDone) { isClusteringCheckDone = true; isClusteringOn = needPropertyDifferences(); } if(isClusteringOn) { addPropertyDifference(key, obj, false); } } else if (parent!=null) { obj = parent.getProperty(key); } return obj; }
/** * Retrieves an object given a key. The retrieved property will not be replicated to * other nodes in the clustered scenario. * * @param key - if not found, will return null * @return Returns the property. */ public Object getPropertyNonReplicable(String key) { Object obj = properties == null ? null : properties.get(key); if ((obj == null) && (parent != null)) { obj = parent.getPropertyNonReplicable(key); } return obj; }
/** * Store a property in this context * * @param key * @param value */ public void setProperty(String key, Object value) { initPropertiesMap(); while (true) { try { properties.put(key, value); break; } catch (ConcurrentModificationException cme) { } } if(!isClusteringCheckDone) { isClusteringCheckDone = true; isClusteringOn = needPropertyDifferences(); } if(isClusteringOn) { addPropertyDifference(key, value, false); } if (DEBUG_ENABLED) { debugPropertySet(key, value); } }
/** * Retrieves an object given a key. Only searches at this level * i.e. getLocalProperty on MessageContext does not look in * the OperationContext properties map if a local result is not * found. * * @param key - if not found, will return null * @return Returns the property. */ public Object getLocalProperty(String key) { Object obj = properties == null ? null : properties.get(key); if ((obj == null) && (parent != null)) { // This is getLocalProperty() don't search the hierarchy. } else { if(!isClusteringCheckDone) { isClusteringCheckDone = true; isClusteringOn = needPropertyDifferences(); } if(isClusteringOn) { // Assume that a property is which is read may be updated. // i.e. The object pointed to by 'value' may be modified after it is read addPropertyDifference(key, obj, false); } } return obj; }
if (!includeAllProperties) { synchronized (context) { Map diffs = context.getPropertyDifferences(); for (Object o : diffs.keySet()) { String key = (String) o; for (Iterator iter = context.getPropertyNames(); iter.hasNext();) { String key = (String) iter.next(); Object value = context.getPropertyNonReplicable(key); if (isSerializable(value)) {
private static void fillProperties(UpdateStateCommand updateCmd, AbstractContext context, String[] propertyNames) throws ClusteringFault { Map diffs = context.getPropertyDifferences(); for (String key : propertyNames) { Object prop = context.getPropertyNonReplicable(key); // First check whether it is serializable if (isSerializable(prop)) { if (log.isDebugEnabled()) { log.debug("sending property =" + key + "-" + prop); } PropertyDifference diff = (PropertyDifference) diffs.get(key); if (diff != null) { diff.setValue(prop); updateCmd.addProperty(diff); // Remove the diff? diffs.remove(key); } } else { String msg = "Trying to replicate non-serializable property " + key + " in context " + context; throw new ClusteringFault(msg); } } }
@SuppressWarnings("unchecked") protected InMemoryBeanMgr(InMemoryStorageManager mgr, AbstractContext context, String key) { if(LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("Entry: InMemoryBeanMgr " + this.getClass() + " <innit> " + mgr + ", " + context + ", " + key); this.mgr = mgr; Object obj = context.getProperty(key); if (obj != null) { table = (ConcurrentHashMap<String, T>) obj; } else { table = new ConcurrentHashMap<String, T>(); context.setProperty(key, table); } if(LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("Exit: InMemoryBeanMgr " + this.getClass() + " <init> " + this); }
/** * Replicate all serializable properties stored in the given <code>abstractContext</code>. * * @param abstractContext The AbstractContext which holds the properties to be replicated * @throws ClusteringFault If replication fails */ public static void replicate(AbstractContext abstractContext) throws ClusteringFault { if (!canReplicate(abstractContext)) { return; } log.debug("Going to replicate state in " + abstractContext + "..."); StateManager stateManager = getStateManager(abstractContext); if (stateManager != null && !abstractContext.getPropertyDifferences().isEmpty()) { synchronized (abstractContext) { // This IDEA/FindBugs warning can be ignored stateManager.updateContext(abstractContext); } } }
/** * This will do a copy of the given properties to the current properties * table. * * @param props The table of properties to copy */ public void mergeProperties(Map<String, Object> props) { if (props != null) { initPropertiesMap(); for (Iterator<String> iterator = props.keySet().iterator(); iterator.hasNext();) { String key = iterator.next(); Object value = props.get(key); while (true) { try { properties.put(key, value); break; } catch (ConcurrentModificationException cme) { } } if (DEBUG_ENABLED) { debugPropertySet((String) key, value); } } } }
mergeProperties(properties); } else { iterator.hasNext();) { Entry<String, Object> entry = iterator.next(); debugPropertySet((String) entry.getKey(), entry.getValue());
Object obj = super.getProperty(name); if (obj != null) { return obj;
/** * @return The properties * @deprecated Use {@link #getPropertyNames()}, {@link #getProperty(String)}, * {@link #setProperty(String, Object)} & {@link #removeProperty(String)}instead. */ public Map<String, Object> getProperties() { initPropertiesMap(); return properties; }
private static ClusteringAgent getClusterManager(AbstractContext abstractContext) { return abstractContext.getRootContext().getAxisConfiguration().getClusteringAgent(); }
/** * Constructor (package access, should only be used by ServiceGroupContext) * * @param axisService the AxisService for which to create a context * @param serviceGroupContext the parent ServiceGroupContext */ ServiceContext(AxisService axisService, ServiceGroupContext serviceGroupContext) { super(serviceGroupContext); this.serviceGroupContext = serviceGroupContext; this.axisService = axisService; this.configContext = (ConfigurationContext) parent.getParent(); }
public Object getLocalProperty(String name, boolean searchOptions) { if (DEBUG_ENABLED) { checkActivateWarning("getProperty"); } // search in my own options Object obj = super.getLocalProperty(name); if (obj != null) { return obj; } if (searchOptions) { obj = options.getProperty(name); if (obj != null) { return obj; } } // tough return null; }
if (!includeAllProperties) { synchronized (context) { Map diffs = context.getPropertyDifferences(); for (Object o : diffs.keySet()) { String key = (String) o; for (Iterator iter = context.getPropertyNames(); iter.hasNext();) { String key = (String) iter.next(); Object value = context.getPropertyNonReplicable(key); if (isSerializable(value)) {
private static void fillProperties(UpdateStateCommand updateCmd, AbstractContext context, String[] propertyNames) throws ClusteringFault { Map diffs = context.getPropertyDifferences(); for (String key : propertyNames) { Object prop = context.getPropertyNonReplicable(key); // First check whether it is serializable if (isSerializable(prop)) { if (log.isDebugEnabled()) { log.debug("sending property =" + key + "-" + prop); } PropertyDifference diff = (PropertyDifference) diffs.get(key); if (diff != null) { diff.setValue(prop); updateCmd.addProperty(diff); // Remove the diff? diffs.remove(key); } } else { String msg = "Trying to replicate non-serializable property " + key + " in context " + context; throw new ClusteringFault(msg); } } }
/** * Retrieves an object given a key. Only searches at this level * i.e. getLocalProperty on MessageContext does not look in * the OperationContext properties map if a local result is not * found. * * @param key - if not found, will return null * @return Returns the property. */ public Object getLocalProperty(String key) { Object obj = properties == null ? null : properties.get(key); if ((obj == null) && (parent != null)) { // This is getLocalProperty() don't search the hierarchy. } else { if(!isClusteringCheckDone) { isClusteringCheckDone = true; isClusteringOn = needPropertyDifferences(); } if(isClusteringOn) { // Assume that a property is which is read may be updated. // i.e. The object pointed to by 'value' may be modified after it is read addPropertyDifference(key, obj, false); } } return obj; }
/** * Replicate all serializable properties stored in the given <code>abstractContext</code>. * * @param abstractContext The AbstractContext which holds the properties to be replicated * @throws ClusteringFault If replication fails */ public static void replicate(AbstractContext abstractContext) throws ClusteringFault { if (!canReplicate(abstractContext)) { return; } log.debug("Going to replicate state in " + abstractContext + "..."); StateManager stateManager = getStateManager(abstractContext); if (stateManager != null && !abstractContext.getPropertyDifferences().isEmpty()) { synchronized (abstractContext) { // This IDEA/FindBugs warning can be ignored stateManager.updateContext(abstractContext); } } }
/** * This will do a copy of the given properties to the current properties * table. * * @param props The table of properties to copy */ public void mergeProperties(Map<String, Object> props) { if (props != null) { initPropertiesMap(); for (Iterator<String> iterator = props.keySet().iterator(); iterator.hasNext();) { String key = iterator.next(); Object value = props.get(key); while (true) { try { properties.put(key, value); break; } catch (ConcurrentModificationException cme) { } } if (DEBUG_ENABLED) { debugPropertySet((String) key, value); } } } }