Annotations are like meta-tags that you can add to the code and apply to package declarations, type declarations, constructors, methods, fields, parameters, and variables. They provide helpful ways to indicate whether the methods are dependent on other methods, whether they are incomplete, whether the classes have references to other classes, and so on.
Below is a list of Junos Space SDK annotations that can be used on EJB resources.
ANNOTATION | EXAMPLE | DESCRIPTION |
---|---|---|
@Cursor | @Cursor( entityClass = CountryEntity.CLASSNAME, queryName = CountryEntity.GET_ALL_COUNTRIES ) public PagingResult<country> getCountries(PagingContext ctx) throws Exception </country> |
Applicable on an EJB method. This annotation enables paging on EJB API variables. Variables
|
@Domain |
@TransactionAttribute(TransactionAttributeType.REQUIRED) @Domain public Country addCountry(ApiContextInterface ctx, Country country) throws Exception |
All EJB APIs that create a new object need to be marked with the @Domain annotation. If this annotation is not added, the objects is created in the SYSTEM domain. We recommend that you add the @Domain annotation to all object create/add methods in the EJB session beans. If an application wants all objects to be created in the Global domain only, then set @Domain(enabled=false). Only entities that have the @ManagedObject annotation in the entity definition will have the domainId column populated. Once the API is annotated with the @Domain annotation, Junos Space will populate the domainId column of the object being created. Variables None |
@DomainWriteProtect |
@DomainWriteProtect(value = CountryEntity.CLASSNAME) public Country updateCountry(ApiContextInterface ctx, @Modifiables int countryId, Country country) throws Exception |
Each EJB method that updates or deletes an object needs to be annotated with @DomainWriteProtect. This annotation disallow update/delete actions on objects (parent domain objects) by users that have read only access (due to parent read up enabled on the subdomain). The purpose of the @DomainWriteProtect is to provide write protection on objects that are not accessible to users who do not have access to the domain to wich the object belongs. The use of @DomainWriteProtect is not required for add/insert methods. The @Modifiables annotation is required on the primary key the method. In the example, countryId is the primary key used to find the object in the database. Variables
|
@JobData |
@JobData( name = "World Cities Country Report", iconFileName = "WorldCities_ui/jssdk/world-cities_job_countries_tree_265x315.png", detailsActionURL = "/mainui/ctrl/deviceScriptManagerWeb/CMPServlet? action = net.juniper.jmp.cems.deviceScriptManagerUI.action.ScriptMgmtJobReportBuilder", detailsActionType = "grid" ) @Schedulable @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public JobInfoTO runDeployScriptsOnDevices(Collection<scriptmgmtmo> scriptMgmtMOList, ScheduleContext sctx) @JobData ( name = "World Country Report", iconFileName = "WorldCities/ui/jssdk/countries_tree_265x315.png”, detailsREST_HREF=“/api/jssdk/world-cities/job-instances/{job-id}/world-cities-results”, detailsREST_MediaType=“vnd.jssdk.world-cities.world-cities-results" ) @Schedulable @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public JobInfoTO runCountriesReport(ScheduleContext scheduleCtx) |
Applicable on schedulable APIs of an EJB. This attribute is used to display the job scheduled by the corresponding API of the EJB in the Junos Space UI. Variables
|
@Modifiables |
@DomainWriteProtect(value = CityEntity.CLASSNAME) public City updateCity(@Modifiables int cityId, City city) throws Exception |
Required on the primary key parameter when using @DomainWriteProtect to write protects objects that can be updated or deleted by an EJB method. In the example, cityId is the primary key used to find the object in the database.. |
@Schedulable |
@Schedulable @TransactionAttribute( TransactionAttributeType.REQUIRED ) public JobInfoTO getCountriesScheduledLRR(ScheduleContext scheduleCtx); throws Exception; |
Applicable on an EJB method. This annotation is used to mark the methods that can be scheduled in the future. This annotation is used by the job manager interceptor to push scheduling information. Variables None |
ANNOTATION | EXAMPLE | DESCRIPTION |
---|---|---|
@Filterable |
@Filterable(entityAttrName = "country") public String getName() { return name; } |
Applicable on the getter/setter of an EJB managed object class. This annotation enables filtering at the EJB level. @Filterable provides the name of an attribute in a JPA entity mapped to the attribute name in the managed object that is used in creating the filtering query criteria. Variables
|
@JmpNotification |
@JmpNotification(destination = "topic/WorldCitiesDatabaseChange") @XmlAccessorType(XmlAccessType.NONE) public class Country extends AbstractManagedObject implements Serializable {} |
Applicable on a managed object class in an EJB. This annotation specifies that if there is any change in the JPA entity of this managed object, the change should be published on the topic provided as the destination value. Variables
|
ANNOTATION | EXAMPLE | DESCRIPTION |
---|---|---|
@ManagedObject |
@Table(name = "CountryEntity", uniqueConstraints = { @UniqueConstraint(columnNames = "country") }) @ManagedObject(value={"net.juniper.jmp.worldcities.ejb.Country"},uri="/api/space/WorldCities/countries/{id}) public class CountryEntity extends OptimisticEntity |
Applicable on a JPA entity class. This annotation specifies the name of a managed object class for a JPA entity. Variables
|
@Sortable |
@Sortable(entityAttrName = "country") public String getName() { return name; } |
Applicable on the getter or setter of an EJB managed object class. This annotation enables sorting at the EJB level. @Sortable provides the name of the attribute in the JPA entity mapped to the attribute name in the managed object that will be used in creating the sorting query criteria. Variables
|