Pixel Core Tutorial – Service Layer

Service layer is a bit more involved, as it hold following functionality

Secure methods by assigning permissions per method
Define default transaction demarcation on service methods
Export methods via DWR

In order to create a service, we will define interface (similar to persistence manager)

package com.pixelnation.gaming.engine.service.iface;

import com.pixelnation.common.service.iface.INlsService;
import com.pixelnation.common.service.iface.IService;
import com.pixelnation.gaming.engine.domain.GameDef;

public interface IGameDefService extends IService<GameDef, Integer>, INlsService
{
}

This interface extends from two other interfaces IService and INlsService. 

INlsService is required only for services working with Localizable domain objects. IService on the other hand define many utility methods that simplify implementation of custom services a breeze.

Implementation of GameDefService will take a bit of explanation

@Service
@RemoteProxy
@Transactional
public class GameDefService extends GenericService<GameDef, Integer> implements IGameDefService
{
@Autowired
private IGameDefManager m_manager;
@Autowired
[…] Read more

Pixel Core Tutorial – Persistence Layer

Now, when we created domain model, we need to add persistence layer (data managers). Data managers will provide interaction between application layer and database. They enable application to save, retrieve and delete object. In general, each domain object should have its own data manager. Also it is a good practice to create interface for each manager.

GameDef
IGameDefManager

There is nothing complex in this one. The interface should extend IPersistenceManager with generic parameters of the domain class and domain class id

package com.pixelnation.gaming.engine.persistence.iface;

import com.pixelnation.common.persistence.iface.IPersistenceManager;
import com.pixelnation.gaming.engine.domain.GameDef;

public interface IGameDefManager extends IPersistenceManager<GameDef, Integer>
{
}

GameDefManager

Same here. Just extend it from PersistenceManager and implement newly created interface (defined above). Make sure to add annotations @Repository […] Read more

Pixel Core Tutorial – Data Model

Pixel Core Tutorial – Data Model

In general Pixel Core Framework adhere to following rule – all data objects are simple POJOs with no business logic.

There are number of interfaces and annotations that add syntactic sugar, make code more readable with less repeating blocks.

public class GameDef
{
private Integer id;
private Code code;
private Boolean enabled;
private Client client;
private List<Nls> nls;
private Date created;
private Date updated;
private String updatedBy;
}

Lets go over all properties of this class

id

This is a unique identifier that will never change over lifetime of the object. It is not necessary must be integer. It could be of any type.

code

It is human readable unique identifier of the object. It is introduced for interaction with other […] Read more