Resolves checkstyle issues for semaphore servant serverless service-layer service-locator (#1079)
* Reduces checkstyle errors in semaphore * Reduces checkstyle errors in servant * Reduces checkstyle errors in serverless * Reduces checkstyle errors in service-layer * Reduces checkstyle errors in service-locator
This commit is contained in:
committed by
Ilkka Seppälä
parent
37599eb48f
commit
390795154f
@ -23,19 +23,15 @@
|
||||
|
||||
package com.iluwatar.servicelayer.app;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.iluwatar.servicelayer.magic.MagicService;
|
||||
import com.iluwatar.servicelayer.magic.MagicServiceImpl;
|
||||
import com.iluwatar.servicelayer.spell.Spell;
|
||||
import com.iluwatar.servicelayer.spell.SpellDao;
|
||||
import com.iluwatar.servicelayer.spell.SpellDaoImpl;
|
||||
import com.iluwatar.servicelayer.spellbook.Spellbook;
|
||||
import com.iluwatar.servicelayer.spellbook.SpellbookDao;
|
||||
import com.iluwatar.servicelayer.spellbook.SpellbookDaoImpl;
|
||||
import com.iluwatar.servicelayer.wizard.Wizard;
|
||||
import com.iluwatar.servicelayer.wizard.WizardDao;
|
||||
import com.iluwatar.servicelayer.wizard.WizardDaoImpl;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -43,28 +39,27 @@ import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
* Service layer defines an application's boundary with a layer of services that establishes a set
|
||||
* of available operations and coordinates the application's response in each operation.
|
||||
* <p>
|
||||
* Enterprise applications typically require different kinds of interfaces to the data they store
|
||||
* and the logic they implement: data loaders, user interfaces, integration gateways, and others.
|
||||
* Despite their different purposes, these interfaces often need common interactions with the
|
||||
* application to access and manipulate its data and invoke its business logic. The interactions may
|
||||
* be complex, involving transactions across multiple resources and the coordination of several
|
||||
*
|
||||
* <p>Enterprise applications typically require different kinds of interfaces to the data they
|
||||
* store and the logic they implement: data loaders, user interfaces, integration gateways, and
|
||||
* others. Despite their different purposes, these interfaces often need common interactions with
|
||||
* the application to access and manipulate its data and invoke its business logic. The interactions
|
||||
* may be complex, involving transactions across multiple resources and the coordination of several
|
||||
* responses to an action. Encoding the logic of the interactions separately in each interface
|
||||
* causes a lot of duplication.
|
||||
* <p>
|
||||
* The example application demonstrates interactions between a client ({@link App}) and a service (
|
||||
* {@link MagicService}). The service is implemented with 3-layer architecture (entity, dao,
|
||||
* service). For persistence the example uses in-memory H2 database which is populated on each
|
||||
* application startup.
|
||||
*
|
||||
* <p>The example application demonstrates interactions between a client ({@link App}) and a
|
||||
* service ({@link MagicService}). The service is implemented with 3-layer architecture (entity,
|
||||
* dao, service). For persistence the example uses in-memory H2 database which is populated on each
|
||||
* application startup.
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
*
|
||||
* Program entry point.
|
||||
*
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
@ -75,7 +70,7 @@ public class App {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize data
|
||||
* Initialize data.
|
||||
*/
|
||||
public static void initData() {
|
||||
// spells
|
||||
@ -180,7 +175,7 @@ public class App {
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the data
|
||||
* Query the data.
|
||||
*/
|
||||
public static void queryData() {
|
||||
var service =
|
||||
|
@ -28,37 +28,35 @@ import javax.persistence.InheritanceType;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
|
||||
/**
|
||||
*
|
||||
* Base class for entities.
|
||||
*
|
||||
*/
|
||||
@MappedSuperclass
|
||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
|
||||
public abstract class BaseEntity {
|
||||
|
||||
/**
|
||||
* Indicates the unique id of this entity
|
||||
* Indicates the unique id of this entity.
|
||||
*
|
||||
* @return The id of the entity, or 'null' when not persisted
|
||||
*/
|
||||
public abstract Long getId();
|
||||
|
||||
/**
|
||||
* Set the id of this entity
|
||||
* Set the id of this entity.
|
||||
*
|
||||
* @param id The new id
|
||||
*/
|
||||
public abstract void setId(Long id);
|
||||
|
||||
/**
|
||||
* Get the name of this entity
|
||||
* Get the name of this entity.
|
||||
*
|
||||
* @return The name of the entity
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* Set the name of this entity
|
||||
* Set the name of this entity.
|
||||
*
|
||||
* @param name The new name
|
||||
*/
|
||||
|
@ -26,11 +26,9 @@ package com.iluwatar.servicelayer.common;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Dao interface.
|
||||
*
|
||||
* @param <E>
|
||||
*
|
||||
* @param <E> Type of Entity
|
||||
*/
|
||||
public interface Dao<E extends BaseEntity> {
|
||||
|
||||
|
@ -23,23 +23,18 @@
|
||||
|
||||
package com.iluwatar.servicelayer.common;
|
||||
|
||||
import com.iluwatar.servicelayer.hibernate.HibernateUtil;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import com.iluwatar.servicelayer.hibernate.HibernateUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* Base class for Dao implementations.
|
||||
*
|
||||
* @param <E>
|
||||
*
|
||||
* @param <E> Type of Entity
|
||||
*/
|
||||
public abstract class DaoBaseImpl<E extends BaseEntity> implements Dao<E> {
|
||||
|
||||
|
@ -26,7 +26,6 @@ package com.iluwatar.servicelayer.hibernate;
|
||||
import com.iluwatar.servicelayer.spell.Spell;
|
||||
import com.iluwatar.servicelayer.spellbook.Spellbook;
|
||||
import com.iluwatar.servicelayer.wizard.Wizard;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.slf4j.Logger;
|
||||
@ -40,7 +39,7 @@ public final class HibernateUtil {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HibernateUtil.class);
|
||||
|
||||
/**
|
||||
* The cached session factory
|
||||
* The cached session factory.
|
||||
*/
|
||||
private static volatile SessionFactory sessionFactory;
|
||||
|
||||
|
@ -23,17 +23,14 @@
|
||||
|
||||
package com.iluwatar.servicelayer.magic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.iluwatar.servicelayer.spell.Spell;
|
||||
import com.iluwatar.servicelayer.spellbook.Spellbook;
|
||||
import com.iluwatar.servicelayer.wizard.Wizard;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Service interface.
|
||||
*
|
||||
*/
|
||||
public interface MagicService {
|
||||
|
||||
|
@ -23,20 +23,17 @@
|
||||
|
||||
package com.iluwatar.servicelayer.magic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.iluwatar.servicelayer.spell.Spell;
|
||||
import com.iluwatar.servicelayer.spell.SpellDao;
|
||||
import com.iluwatar.servicelayer.spellbook.Spellbook;
|
||||
import com.iluwatar.servicelayer.spellbook.SpellbookDao;
|
||||
import com.iluwatar.servicelayer.wizard.Wizard;
|
||||
import com.iluwatar.servicelayer.wizard.WizardDao;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Service implementation.
|
||||
*
|
||||
*/
|
||||
public class MagicServiceImpl implements MagicService {
|
||||
|
||||
@ -45,7 +42,7 @@ public class MagicServiceImpl implements MagicService {
|
||||
private SpellDao spellDao;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*/
|
||||
public MagicServiceImpl(WizardDao wizardDao, SpellbookDao spellbookDao, SpellDao spellDao) {
|
||||
this.wizardDao = wizardDao;
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
package com.iluwatar.servicelayer.spell;
|
||||
|
||||
import com.iluwatar.servicelayer.common.BaseEntity;
|
||||
import com.iluwatar.servicelayer.spellbook.Spellbook;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
@ -31,13 +33,8 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.iluwatar.servicelayer.common.BaseEntity;
|
||||
import com.iluwatar.servicelayer.spellbook.Spellbook;
|
||||
|
||||
/**
|
||||
*
|
||||
* Spell entity.
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "SPELL")
|
||||
@ -54,13 +51,14 @@ public class Spell extends BaseEntity {
|
||||
@JoinColumn(name = "SPELLBOOK_ID_FK", referencedColumnName = "SPELLBOOK_ID")
|
||||
private Spellbook spellbook;
|
||||
|
||||
public Spell() {}
|
||||
public Spell() {
|
||||
}
|
||||
|
||||
public Spell(String name) {
|
||||
this();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -68,7 +66,7 @@ public class Spell extends BaseEntity {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -26,9 +26,7 @@ package com.iluwatar.servicelayer.spell;
|
||||
import com.iluwatar.servicelayer.common.Dao;
|
||||
|
||||
/**
|
||||
*
|
||||
* SpellDao interface.
|
||||
*
|
||||
*/
|
||||
public interface SpellDao extends Dao<Spell> {
|
||||
|
||||
|
@ -24,16 +24,11 @@
|
||||
package com.iluwatar.servicelayer.spell;
|
||||
|
||||
import com.iluwatar.servicelayer.common.DaoBaseImpl;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
/**
|
||||
*
|
||||
* SpellDao implementation.
|
||||
*
|
||||
*/
|
||||
public class SpellDaoImpl extends DaoBaseImpl<Spell> implements SpellDao {
|
||||
|
||||
|
@ -23,9 +23,11 @@
|
||||
|
||||
package com.iluwatar.servicelayer.spellbook;
|
||||
|
||||
import com.iluwatar.servicelayer.common.BaseEntity;
|
||||
import com.iluwatar.servicelayer.spell.Spell;
|
||||
import com.iluwatar.servicelayer.wizard.Wizard;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@ -36,14 +38,8 @@ import javax.persistence.ManyToMany;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.iluwatar.servicelayer.common.BaseEntity;
|
||||
import com.iluwatar.servicelayer.spell.Spell;
|
||||
import com.iluwatar.servicelayer.wizard.Wizard;
|
||||
|
||||
/**
|
||||
*
|
||||
* Spellbook entity.
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "SPELLBOOK")
|
||||
@ -71,7 +67,7 @@ public class Spellbook extends BaseEntity {
|
||||
this();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -79,7 +75,7 @@ public class Spellbook extends BaseEntity {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -26,9 +26,7 @@ package com.iluwatar.servicelayer.spellbook;
|
||||
import com.iluwatar.servicelayer.common.Dao;
|
||||
|
||||
/**
|
||||
*
|
||||
* SpellbookDao interface.
|
||||
*
|
||||
*/
|
||||
public interface SpellbookDao extends Dao<Spellbook> {
|
||||
|
||||
|
@ -23,17 +23,12 @@
|
||||
|
||||
package com.iluwatar.servicelayer.spellbook;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import com.iluwatar.servicelayer.common.DaoBaseImpl;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import com.iluwatar.servicelayer.common.DaoBaseImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
* SpellbookDao implementation.
|
||||
*
|
||||
*/
|
||||
public class SpellbookDaoImpl extends DaoBaseImpl<Spellbook> implements SpellbookDao {
|
||||
|
||||
|
@ -23,9 +23,10 @@
|
||||
|
||||
package com.iluwatar.servicelayer.wizard;
|
||||
|
||||
import com.iluwatar.servicelayer.common.BaseEntity;
|
||||
import com.iluwatar.servicelayer.spellbook.Spellbook;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@ -34,13 +35,8 @@ import javax.persistence.Id;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.iluwatar.servicelayer.common.BaseEntity;
|
||||
import com.iluwatar.servicelayer.spellbook.Spellbook;
|
||||
|
||||
/**
|
||||
*
|
||||
* Wizard entity.
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "WIZARD")
|
||||
@ -64,7 +60,7 @@ public class Wizard extends BaseEntity {
|
||||
this();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -72,7 +68,7 @@ public class Wizard extends BaseEntity {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -26,9 +26,7 @@ package com.iluwatar.servicelayer.wizard;
|
||||
import com.iluwatar.servicelayer.common.Dao;
|
||||
|
||||
/**
|
||||
*
|
||||
* WizardDao interface.
|
||||
*
|
||||
*/
|
||||
public interface WizardDao extends Dao<Wizard> {
|
||||
|
||||
|
@ -23,18 +23,15 @@
|
||||
|
||||
package com.iluwatar.servicelayer.wizard;
|
||||
|
||||
import com.iluwatar.servicelayer.common.DaoBaseImpl;
|
||||
import com.iluwatar.servicelayer.spellbook.Spellbook;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
import com.iluwatar.servicelayer.common.DaoBaseImpl;
|
||||
import com.iluwatar.servicelayer.spellbook.Spellbook;
|
||||
|
||||
/**
|
||||
*
|
||||
* WizardDao implementation.
|
||||
*
|
||||
*/
|
||||
public class WizardDaoImpl extends DaoBaseImpl<Wizard> implements WizardDao {
|
||||
|
||||
|
Reference in New Issue
Block a user