![JAR search and dependency download from the Maven repository](/logo.png)
jadex.bridge.nonfunctional.NFPropertyProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-platform-bridge Show documentation
Show all versions of jadex-platform-bridge Show documentation
Jadex bridge is a base package for kernels and platforms, i.e., it is used by both and provides commonly used interfaces and classes for active components and their management.
package jadex.bridge.nonfunctional;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import jadex.bridge.ComponentResultListener;
import jadex.bridge.IComponentIdentifier;
import jadex.bridge.IExternalAccess;
import jadex.bridge.IInternalAccess;
import jadex.bridge.component.IMonitoringComponentFeature;
import jadex.bridge.service.types.monitoring.IMonitoringService.PublishEventLevel;
import jadex.bridge.service.types.monitoring.IMonitoringService.PublishTarget;
import jadex.bridge.service.types.monitoring.MonitoringEvent;
import jadex.commons.future.CounterResultListener;
import jadex.commons.future.DelegationResultListener;
import jadex.commons.future.ExceptionDelegationResultListener;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
/**
* Base impl for nf property property provider.
*/
public class NFPropertyProvider implements INFPropertyProvider
{
/** The parent. */
// protected INFPropertyProvider nfparent;
protected IComponentIdentifier parent;
/** The component. */
protected IInternalAccess component;
/** Non-functional properties. */
protected Map> nfproperties;
/**
* Create a new provider.
*/
public NFPropertyProvider(IComponentIdentifier parent, IInternalAccess component)
{
this.parent = parent;
this.component = component;
}
// /**
// * Create a new provider.
// */
// public NFPropertyProvider(INFPropertyProvider parent)
// {
// this.nfparent = parent;
// }
/**
* Returns the names of all non-functional properties of this service.
* @return The names of the non-functional properties of this service.
*/
public IFuture getNFPropertyNames()
{
return new Future(nfproperties != null? nfproperties.keySet().toArray(new String[nfproperties.size()]) : new String[0]);
}
/**
* Returns the names of all non-functional properties of this service.
* @return The names of the non-functional properties of this service.
*/
public IFuture getNFAllPropertyNames()
{
final Future ret = new Future();
final String[] myprops = nfproperties != null? nfproperties.keySet().toArray(new String[nfproperties.size()]) : new String[0];
if(getParentId()!=null)
{
// IComponentManagementService cms = getInternalAccess().getFeature(IRequiredServicesFeature.class).getLocalService(new ServiceQuery<>(IComponentManagementService.class));
getInternalAccess().getExternalAccessAsync(getParentId()).addResultListener(new ExceptionDelegationResultListener(ret)
{
public void customResultAvailable(IExternalAccess component)
{
component.getNFAllPropertyNames().addResultListener(new DelegationResultListener(ret)
{
public void customResultAvailable(String[] result)
{
Set tmp = new LinkedHashSet();
for(String p: result)
{
tmp.add(p);
}
for(String p: myprops)
{
tmp.add(p);
}
ret.setResult((String[])tmp.toArray(new String[tmp.size()]));
}
});
}
});
}
else
{
ret.setResult(myprops);
}
// getParent().addResultListener(new ExceptionDelegationResultListener(ret)
// {
// public void customResultAvailable(INFPropertyProvider parent)
// {
// if(parent!=null)
// {
// parent.getNFAllPropertyNames().addResultListener(new DelegationResultListener(ret)
// {
// public void customResultAvailable(String[] result)
// {
// Set tmp = new LinkedHashSet();
// for(String p: result)
// {
// tmp.add(p);
// }
// for(String p: myprops)
// {
// tmp.add(p);
// }
// ret.setResult((String[])tmp.toArray(new String[tmp.size()]));
// }
// });
// }
// else
// {
// ret.setResult(myprops);
// }
// }
// });
return ret;
}
/**
* Returns the meta information about a non-functional property of this service.
* @param name Name of the property.
* @return The meta information about a non-functional property of this service.
*/
public IFuture
© 2015 - 2025 Weber Informatics LLC | Privacy Policy