jeaf.ServiceProvider.xpt Maven / Gradle / Ivy
«EXTENSION java::Naming»
«EXTENSION entity::ModelProperties»
«EXTENSION java::GeneratorCommons»
«IMPORT uml»
«IMPORT JMM»
«IMPORT java»
«IMPORT entity»
«DEFINE JEAFServiceProviderTemplate FOR JEAFServiceProvider»
«FILE packagePath()+"/"+name+".java" src_gen»
«getFileHeader()»
package «packageName()»;
«EXPAND functions::Javadoc::JavadocForType»
«EXPAND java::Helper::GenerateDeprecationAnnotation-»
public interface «name» extends «IF generalization.size > 0» «this.getAllExtendedInterfaces()» «ELSE»com.anaptecs.jeaf.core.api.ServiceProvider«ENDIF» {
«EXPAND JEAFOperation::PlainInterfaceOperation("JEAFServiceProvider", false) FOREACH this.ownedOperation»
}
«ENDFILE»
«ENDDEFINE»
«DEFINE JEAFServiceProviderImplTemplate FOR JEAFServiceProviderImpl»
«EXPAND CreateServiceProviderProperties»
«FILE packagePath()+"/"+name+"Base.java" src_gen»
«getFileHeader()»
package «packageName()»;
import com.anaptecs.jeaf.xfun.api.common.ComponentID;
«EXPAND functions::Javadoc::JavadocForType»
«EXPAND java::Helper::GenerateDeprecationAnnotation-»
abstract class «name»Base implements com.anaptecs.jeaf.core.spi.ServiceProviderImplementation, «this.getImplementedInterfaceNames()» {
«IF this.ownedAttribute.size > 0»
/**
* Reference to the object that identifies this component. The reference is never null.
*/
private static final ComponentID COMPONENT_ID;
/**
* Resource access provider enables access to the properties of the service provider.
*/
private final com.anaptecs.jeaf.xfun.api.config.Configuration configuration;
/**
* Static initializer is used to create the components ComponentID object and its trace object.
*/
static {
// Create Component ID and trace object.
Package lBasePackage = «this.name».class.getPackage();
COMPONENT_ID = new com.anaptecs.jeaf.xfun.api.common.ComponentID("«this.name»", lBasePackage.getName());
}
«ENDIF»
/**
* Constructor has reduced visibility in order to ensure that all service provider implementations are created through the factory.
*/
«this.name»Base() {
«IF this.ownedAttribute.size > 0»// Create resource access provider for properties of the component.
configuration = com.anaptecs.jeaf.xfun.api.XFun.getConfigurationProvider().getComponentConfiguration(COMPONENT_ID);«ENDIF»
}
«FOREACH this.ownedAttribute AS property»
/**
* Method returns the value of the property "«property.name»".
*
* @return {@link «property.type.name»} Value of the property "«property.name»". The method returns null if no value for the
* property is defined.
*/
«EXPAND java::Helper::GenerateDeprecationAnnotation FOR property-»
public «property.fqn()» «property.asGetter()»() {
«IF property.type.isStringType()»
return configuration.getConfigurationValue("«property.name»", java.lang.String.class);
«ELSEIF property.type.isBooleanType()»
return configuration.getConfigurationValue("«property.name»", java.lang.Boolean.class);
«ELSEIF property.type.isByteType()»
return configuration.getConfigurationValue("«property.name»", java.lang.Byte.class);
«ELSEIF property.type.isDoubleType()»
return configuration.getConfigurationValue("«property.name»", java.lang.Double.class);
«ELSEIF property.type.isFloatType()»
return configuration.getConfigurationValue("«property.name»", java.lang.Float.class);
«ELSEIF property.type.isLongType()»
return configuration.getConfigurationValue("«property.name»", java.lang.Long.class);
«ELSEIF property.type.isShortType()»
return configuration.getConfigurationValue("«property.name»", java.lang.Short.class);
«ELSE»
return configuration.getConfigurationValue("«property.name»", «property.type.getNearestPackage().fqn()».«property.type.name».class);
«ENDIF»
}
«ENDFOREACH»
}
«ENDFILE»
«FILE packagePath()+"/"+name+".java" src»
«getFileHeader()»
package «packageName()»;
«EXPAND functions::Javadoc::JavadocForType»
final class «name» extends «name»Base {
/**
* Constructor has reduced visibility in order to ensure that all service provider implementations are created through the factory.
*/
«this.name»() {
// Nothing to do.
}
/**
* This method will be called at startup by JEAF and enables the service provider to perform its specific
* initialization routines.
*
* @throws SystemException Service provider specific exception in order to show that the initialization was not
* successful.
*/
@Override
public void initialize( ) throws com.anaptecs.jeaf.xfun.api.errorhandling.SystemException {
}
/**
* Method checks the current state of the service provider. Therefore JEAF defines three different check levels:
* internal Checks, infrastructure checks and external checks. For further details about the check levels
* {@see CheckLevel}.
*
* @param pLevel Check level on which the check should be performed. The parameter is never null.
* @return {@link HealthCheckResult} Object describing the result of the check. The method may return null. This means that
* the service does not implement any checks. In order to use as less memory as possible the method should use the
* constant {@link HealthCheckResult#CHECK_OK} if no errors or warnings occurred during the check.
*/
@Override
public com.anaptecs.jeaf.xfun.api.health.HealthCheckResult check( com.anaptecs.jeaf.xfun.api.health.CheckLevel pLevel ) {
// TODO Implement checks for this service provider
return null;
}
«FOREACH this.getAllImplementedInterfaces() AS interface»
«EXPAND JEAFOperation::ServiceOperationImpl("JEAFServiceProvider", false) FOREACH interface.ownedOperation»
«ENDFOREACH»
}
«ENDFILE»
«FILE packagePath()+"/"+this.getServiceProviderFactoryName()+".java" src_gen»
«getFileHeader()»
package «packageName()»;
import com.anaptecs.jeaf.core.api.ServiceProvider;
import com.anaptecs.jeaf.core.spi.ServiceProviderImplementation;
import com.anaptecs.jeaf.core.servicechannel.api.ServiceProviderFactory;
/**
* This class is the factory class the service provider implementation {@link «name»}.
*/
@com.anaptecs.jeaf.core.annotations.ServiceProviderFactory
public final class «this.getServiceProviderFactoryName()» extends ServiceProviderFactory {
/**
* Initialize object. No actions have to be performed.
*/
public «this.getServiceProviderFactoryName()»( ) {
// Nothing to do.
}
/**
* Method creates a new instance of the service provider.
*
* @return {@link ServiceProviderImplementation} Instance of service provider. The method never returns null.
*
* @see com.anaptecs.jeaf.core.servicechannel.api.ServiceProviderFactory#createServiceProviderImplementation()
*/
@Override
public ServiceProviderImplementation createServiceProviderImplementation( ) {
return new «this.name»();
}
/**
* Method returns the interface of the service provider created by this factory.
*
* @return Class Class object of interface that belongs to the service provider that is created by this factory. The
* method never returns null.
*
* @see com.anaptecs.jeaf.core.servicechannel.api.ServiceProviderFactory#getServiceProviderInterface()
*/
@Override
public Class extends ServiceProvider> getServiceProviderInterface( ) {
return «this.getAllImplementedInterfaces().get(0).fqn()».class;
}
}
«ENDFILE»
«ENDDEFINE»
«DEFINE CreateServiceProviderProperties FOR JEAFServiceProviderImpl»
«FILE name+".properties" res»
«FOREACH this.ownedAttribute AS property»
«property.name»=«ENDFOREACH»
«ENDFILE»
«FILE name+".xml" res_gen»
«FOREACH this.ownedAttribute AS property»
«ENDFOREACH»
«ENDFILE»
«ENDDEFINE»