
jadex.nfproperty.impl.NFPropertyRef Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nfproperty Show documentation
Show all versions of nfproperty Show documentation
Non functional properties feature
package jadex.nfproperty.impl;
import jadex.common.MethodInfo;
import jadex.core.IExternalAccess;
import jadex.future.IFuture;
import jadex.providedservice.IServiceIdentifier;
/**
* Property reference. Delegates calls to the real
* property source.
*/
public class NFPropertyRef extends AbstractNFProperty
{
// /** The value source. */
// protected INFPropertyProvider source;
/** The component of the ref. */
protected IExternalAccess comp;
/** The service identifier. */
protected IServiceIdentifier sid;
/** The method. */
protected MethodInfo method;
/**
* Create a new property ref.
*/
// public NFPropertyRef(INFPropertyProvider source, IExternalAccess comp, NFPropertyMetaInfo mi)
public NFPropertyRef(IExternalAccess comp, NFPropertyMetaInfo mi, IServiceIdentifier sid, MethodInfo method)
{
// super(new NFPropertyMetaInfo(CPULoadProperty.CPULOAD, double.class, null, true, -1, Target.Root));
super(mi);
// this.source = source;
this.sid = sid;
this.method = method;
this.comp = comp;
}
/**
* Returns the current value of the property, performs unit conversion if necessary.
*
* @param type Type of the value.
* @param unit Unit of the returned value.
*
* @return The current value of the property.
*/
// public IFuture getValue(Class unit)
public IFuture getValue(U unit)
{
throw new UnsupportedOperationException();
/*final Future ret = new Future();
// IFuture fut = source.getNFPropertyValue(getName(), unit);
IFuture fut;
if(sid==null && method==null)
{
fut = comp.getNFPropertyValue(getName(), unit);
}
else if(sid!=null && method==null)
{
fut = comp.getNFPropertyValue(sid, getName(), unit);
}
else
{
fut = comp.getMethodNFPropertyValue(sid, method, getName(), unit);
}
fut.addResultListener(new IResultListener()
{
public void resultAvailable(T result)
{
ret.setResult(result);
}
public void exceptionOccurred(Exception exception)
{
// ((INFPropertyProvider)comp.getExternalComponentFeature(INFPropertyComponentFeature.class)).removeNFProperty(getName());
// SNFPropertyProvider.removeNFProperty(comp, name)
// todo: remote case?
// source.removeNFProperty(getName());
if(sid==null && method==null)
{
comp.removeNFProperty(getName());
}
else if(sid!=null && method==null)
{
comp.removeNFProperty(sid, getName());
}
else
{
comp.removeMethodNFProperty(sid, method, getName());
}
ret.setException(exception);
}
});
return ret;*/
}
@Override
public IFuture getPrettyPrintValue()
{
throw new UnsupportedOperationException();
/*final Future ret = new Future();
IFuture fut;
if(sid==null && method==null)
{
fut = comp.getNFPropertyPrettyPrintValue(getName());
}
else if(sid!=null && method==null)
{
fut = comp.getNFPropertyPrettyPrintValue(sid, getName());
}
else
{
fut = comp.getMethodNFPropertyPrettyPrintValue(sid, method, getName());
}
fut.addResultListener(new IResultListener()
{
public void resultAvailable(String result)
{
ret.setResult(result);
}
public void exceptionOccurred(Exception exception)
{
// ((INFPropertyProvider)comp.getExternalComponentFeature(INFPropertyComponentFeature.class)).removeNFProperty(getName());
// SNFPropertyProvider.removeNFProperty(comp, name)
// todo: remote case?
// source.removeNFProperty(getName());
if(sid==null && method==null)
{
comp.removeNFProperty(getName());
}
else if(sid!=null && method==null)
{
comp.removeNFProperty(sid, getName());
}
else
{
comp.removeMethodNFProperty(sid, method, getName());
}
ret.setException(exception);
}
});
return ret;*/
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy