![JAR search and dependency download from the Maven repository](/logo.png)
jadex.nfproperty.impl.NFRootProperty Maven / Gradle / Ivy
package jadex.nfproperty.impl;
import jadex.core.IComponent;
import jadex.core.IExternalAccess;
import jadex.future.IFuture;
/**
* Injects properties on root component.
*/
public abstract class NFRootProperty extends SimpleValueNFProperty
{
/** The root access. */
protected IExternalAccess root;
/** The flag if the property has been injected to the root component. */
protected boolean injected;
/**
* Create a new property.
*/
public NFRootProperty(final IComponent comp, final NFPropertyMetaInfo mi)
{
this(comp, mi, true);
}
/**
* Create a new property.
*/
public NFRootProperty(final IComponent comp, final NFPropertyMetaInfo mi, boolean inject)
{
super(comp, mi);
if(inject)
injectPropertyToRootComponent();
}
/**
* Inject the property to the root component.
*/
protected IFuture injectPropertyToRootComponent()
{
throw new UnsupportedOperationException();
/*final Future ret = new Future();
if(!injected)
{
this.injected = true;
// Add property to root component
// IComponentManagementService cms = comp.getFeature(IRequiredServicesFeature.class).getLocalService(new ServiceQuery<>(IComponentManagementService.class));
comp.getExternalAccessAsync(comp.getId().getRoot()).addResultListener(new DefaultResultListener()
{
public void resultAvailable(IExternalAccess root)
{
NFRootProperty.this.root = root;
INFPropertyMetaInfo mi = getMetaInfo();
NFPropertyMetaInfo cmi = new NFPropertyMetaInfo(mi.getName(), mi.getType(), mi.getUnit(), mi.isDynamic(), mi.getUpdateRate(), mi.isRealtime(), Target.Root);
// ((INFPropertyProvider)root.getExternalComponentFeature(INFPropertyComponentFeature.class)).addNFProperty(new NFPropertyRef((INFPropertyProvider)comp.getExternalAccess().getExternalComponentFeature(INFPropertyComponentFeature.class), root, cmi)).addResultListener(new DelegationResultListener(ret));
NFPropertyRef pr = new NFPropertyRef(comp.getExternalAccess(), cmi, null, null);
root.addNFProperty(pr).addResultListener(new DelegationResultListener(ret));
}
});
}
else
{
ret.setResult(null);
}
return ret;*/
}
/**
* Property was removed and should be disposed.
*/
public IFuture dispose()
{
throw new UnsupportedOperationException();
/*final Future ret = new Future();
if(root!=null && injected)
{
// ((INFPropertyProvider)root.getExternalComponentFeature(INFPropertyComponentFeature.class)).removeNFProperty(getName());//.addResultListener(new DelegationResultListener(ret));
root.removeNFProperty(getName()).addResultListener(new IResultListener()
{
public void resultAvailable(Void result)
{
NFRootProperty.super.dispose().addResultListener(new DelegationResultListener(ret));
}
public void exceptionOccurred(Exception exception)
{
NFRootProperty.super.dispose().addResultListener(new DelegationResultListener(ret));
}
});
}
else
{
return super.dispose();
}
return ret;*/
}
/**
* Get the injected.
* @return The injected.
*/
public boolean isInjected()
{
return injected;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy