From 5ea1b54d07bdfe276a7b67b6587a3796d5952669 Mon Sep 17 00:00:00 2001 From: Ali Hamdi Date: Thu, 13 Sep 2018 13:51:26 +0100 Subject: [PATCH 01/10] Added the module services --- pom.xml | 1 + services/pom.xml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 services/pom.xml diff --git a/pom.xml b/pom.xml index d2731d7..9fe94d5 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,7 @@ @@@name@@@ @@@description@@@ + services war packaging diff --git a/services/pom.xml b/services/pom.xml new file mode 100644 index 0000000..285150b --- /dev/null +++ b/services/pom.xml @@ -0,0 +1,18 @@ + + + + @@@artifactId@@@ + @@@groupId@@@ + 1.0.x-SNAPSHOT + + 4.0.0 + @@@groupId@@@ + @@@artifactId@@@-services + 1.0.x-SNAPSHOT + @@@name@@@ - Services + + @@@artifactId@@@-services + + \ No newline at end of file From e6e074798f9cf9305dff55327583fd6b014a0153 Mon Sep 17 00:00:00 2001 From: Ali Hamdi Date: Thu, 13 Sep 2018 13:57:46 +0100 Subject: [PATCH 02/10] Added a sample service and a sample configuration templates --- .../org/exoplatform/addons/MyService.java | 11 ++++++++ .../resources/conf/portal/configuration.xml | 26 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 services/src/main/java/org/exoplatform/addons/MyService.java create mode 100644 services/src/main/resources/conf/portal/configuration.xml diff --git a/services/src/main/java/org/exoplatform/addons/MyService.java b/services/src/main/java/org/exoplatform/addons/MyService.java new file mode 100644 index 0000000..4d63b55 --- /dev/null +++ b/services/src/main/java/org/exoplatform/addons/MyService.java @@ -0,0 +1,11 @@ +package org.exoplatform.addons; + +/** + * Created by eXo Platform SAS. + * + * @author Ali Hamdi + * @since 13/09/18 13:57 + */ + +public class MyService { +} diff --git a/services/src/main/resources/conf/portal/configuration.xml b/services/src/main/resources/conf/portal/configuration.xml new file mode 100644 index 0000000..3ac88a4 --- /dev/null +++ b/services/src/main/resources/conf/portal/configuration.xml @@ -0,0 +1,26 @@ + + + + + + From 5555fc0795efe2fb6c4f25f44b0bd53a94b7b763 Mon Sep 17 00:00:00 2001 From: Ali Hamdi Date: Thu, 13 Sep 2018 13:59:08 +0100 Subject: [PATCH 03/10] Removed comment information --- services/src/main/java/org/exoplatform/addons/MyService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/src/main/java/org/exoplatform/addons/MyService.java b/services/src/main/java/org/exoplatform/addons/MyService.java index 4d63b55..f34f14e 100644 --- a/services/src/main/java/org/exoplatform/addons/MyService.java +++ b/services/src/main/java/org/exoplatform/addons/MyService.java @@ -3,8 +3,6 @@ /** * Created by eXo Platform SAS. * - * @author Ali Hamdi - * @since 13/09/18 13:57 */ public class MyService { From bef8f4f80c50b2886a5b375457022eaa409fca51 Mon Sep 17 00:00:00 2001 From: Ali Hamdi Date: Tue, 25 Sep 2018 17:49:32 +0100 Subject: [PATCH 04/10] Added test services with configuration --- packaging/pom.xml | 22 ++++++++----- packaging/src/main/assemblies/packaging.xml | 8 ++--- pom.xml | 21 ++++++------ services/pom.xml | 28 ++++++++++++---- .../org/exoplatform/addons/MyService.java | 18 ++++++++++ .../addons/MyStartableService.java | 33 +++++++++++++++++++ .../resources/conf/portal/configuration.xml | 9 ++++- war/pom.xml | 10 +++--- 8 files changed, 114 insertions(+), 35 deletions(-) create mode 100644 services/src/main/java/org/exoplatform/addons/MyStartableService.java diff --git a/packaging/pom.xml b/packaging/pom.xml index 9304d42..acc3888 100644 --- a/packaging/pom.xml +++ b/packaging/pom.xml @@ -2,24 +2,30 @@ 4.0.0 - @@@groupId@@@ - @@@artifactId@@@ + org.exoplatform.addons.training + training-exercices-parent 1.0.x-SNAPSHOT - @@@artifactId@@@-packaging + training-exercices-packaging pom - @@@name@@@ - Packaging + Training Exercises - Packaging ${project.groupId} - @@@artifactId@@@-war - 1.0.x-SNAPSHOT + training-exercises-webapp + ${project.version} war provided + + ${project.groupId} + training-exercises-services + ${project.version} + provided + - @@@artifactId@@@ + training-exercises-packaging org.apache.maven.plugins @@ -32,7 +38,7 @@ single - @@@artifactId@@@ + training-exercises-packaging false src/main/assemblies/packaging.xml diff --git a/packaging/src/main/assemblies/packaging.xml b/packaging/src/main/assemblies/packaging.xml index 314b6b0..806b599 100644 --- a/packaging/src/main/assemblies/packaging.xml +++ b/packaging/src/main/assemblies/packaging.xml @@ -1,7 +1,7 @@ - @@@artifactId@@@-addon + training-exercises-addon zip @@ -12,17 +12,17 @@ false - ${project.groupId}:@@@artifactId@@@-war:war + ${project.groupId}:training-exercises-webapp:war provided - @@@artifactId@@@.war + training-exercises-webapp.war false - ${project.groupId}:@@@artifactId@@@-*:jar + ${project.groupId}:training-exercises-services:jar provided ${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension} diff --git a/pom.xml b/pom.xml index 9fe94d5..278c0b3 100644 --- a/pom.xml +++ b/pom.xml @@ -26,25 +26,19 @@ org.exoplatform.addons 6 - @@@groupId@@@ - @@@artifactId@@@ + org.exoplatform.addons.training + training-exercices-parent 1.0.x-SNAPSHOT pom - @@@name@@@ - @@@description@@@ + Training addon - Parent + Parent for training addon services war packaging - - scm:git:git://github.com/exo-addons/@@@git_project@@@.git - scm:git:git@github.com:exo-addons/@@@git_project@@@.git - HEAD - https://github.com/exo-addons/@@@git_project@@@ - - @@@platform_version@@@ + 5.0.1 @@ -56,6 +50,11 @@ pom import + + org.exoplatform.kernel + exo.kernel.commons + ${platform.version} + diff --git a/services/pom.xml b/services/pom.xml index 285150b..63e2390 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -3,16 +3,32 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - @@@artifactId@@@ - @@@groupId@@@ + org.exoplatform.addons.training + training-exercices-parent 1.0.x-SNAPSHOT 4.0.0 - @@@groupId@@@ - @@@artifactId@@@-services + training-exercises-services 1.0.x-SNAPSHOT - @@@name@@@ - Services + + + picocontainer + picocontainer + 1.1 + + + org.exoplatform.kernel + exo.kernel.commons + ${platform.version} + + + org.exoplatform.kernel + exo.kernel.container + ${platform.version} + + + Training Exercise - Services - @@@artifactId@@@-services + training-exercises-services \ No newline at end of file diff --git a/services/src/main/java/org/exoplatform/addons/MyService.java b/services/src/main/java/org/exoplatform/addons/MyService.java index f34f14e..27ab852 100644 --- a/services/src/main/java/org/exoplatform/addons/MyService.java +++ b/services/src/main/java/org/exoplatform/addons/MyService.java @@ -1,9 +1,27 @@ package org.exoplatform.addons; +import org.exoplatform.services.log.ExoLogger; +import org.exoplatform.services.log.Log; + /** * Created by eXo Platform SAS. * + * @author Ali Hamdi + * @since 13/09/18 15:12 */ public class MyService { + /** + * The logger. + */ + private static final Log LOG = ExoLogger.getExoLogger(MyStartableService.class); + + + public MyService() { + LOG.info("##################### Simple service started successfully !!"); + } + + public void call() { + LOG.info("###################### call function invoked !!"); + } } diff --git a/services/src/main/java/org/exoplatform/addons/MyStartableService.java b/services/src/main/java/org/exoplatform/addons/MyStartableService.java new file mode 100644 index 0000000..a5e47c3 --- /dev/null +++ b/services/src/main/java/org/exoplatform/addons/MyStartableService.java @@ -0,0 +1,33 @@ +package org.exoplatform.addons; + +import org.exoplatform.container.ExoContainerContext; +import org.exoplatform.container.PortalContainer; +import org.picocontainer.Startable; +import org.exoplatform.services.log.*; + +/** + * Created by eXo Platform SAS. + * + */ + +public class MyStartableService implements Startable { + /** + * The logger. + */ + private static final Log LOG = ExoLogger.getExoLogger(MyStartableService.class); + + @Override + public void start() { + LOG.info("&&&&&&&&&&&& My Startable service started !"); + /*PortalContainer portalContainer = (PortalContainer) ExoContainerContext.getCurrentContainer(); + LOG.info("&&&&&&&&&&&& Getting an instance of MyService !"); + MyService myService = (MyService) portalContainer.getComponentInstance(MyService.class); + LOG.info("&&&&&&&&&&&& Calling function call of MyService !"); + myService.call();*/ + } + + @Override + public void stop() { + LOG.info("&&&&&&&&&&&& My Startable service stopped !"); + } +} diff --git a/services/src/main/resources/conf/portal/configuration.xml b/services/src/main/resources/conf/portal/configuration.xml index 3ac88a4..7a941c4 100644 --- a/services/src/main/resources/conf/portal/configuration.xml +++ b/services/src/main/resources/conf/portal/configuration.xml @@ -22,5 +22,12 @@ - + + org.exoplatform.addons.MyStartableService + org.exoplatform.addons.MyStartableService + + + org.exoplatform.addons.MyService + org.exoplatform.addons.MyService + diff --git a/war/pom.xml b/war/pom.xml index 8597b1b..40f4851 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -22,14 +22,14 @@ 4.0.0 - @@@groupId@@@ - @@@artifactId@@@ + org.exoplatform.addons.training + training-exercices-parent 1.0.x-SNAPSHOT - @@@artifactId@@@-war + training-exercises-webapp war - @@@name@@@ - Webapp + Training Exercises - Webapp - @@@artifactId@@@-extension + training-exercises-extension From 7bafdbd2d7afafccf59f2b87cc989e201eac9408 Mon Sep 17 00:00:00 2001 From: Ali Hamdi Date: Tue, 25 Sep 2018 18:36:54 +0100 Subject: [PATCH 05/10] Add FavouriteEntity with Liquibase configuration --- services/pom.xml | 15 +++++ .../addons/entity/FavouriteActivity.java | 62 +++++++++++++++++++ .../addons/{ => services}/MyService.java | 3 +- .../{ => services}/MyStartableService.java | 2 +- .../src/main/resources/conf/configuration.xml | 41 ++++++++++++ ...ddon-training-rdbms.db.changelog-1.0.0.xml | 54 ++++++++++++++++ .../resources/conf/portal/configuration.xml | 15 ++--- .../webapp/WEB-INF/conf/configuration.xml | 9 ++- 8 files changed, 188 insertions(+), 13 deletions(-) create mode 100644 services/src/main/java/org/exoplatform/addons/entity/FavouriteActivity.java rename services/src/main/java/org/exoplatform/addons/{ => services}/MyService.java (85%) rename services/src/main/java/org/exoplatform/addons/{ => services}/MyStartableService.java (95%) create mode 100644 services/src/main/resources/conf/configuration.xml create mode 100644 services/src/main/resources/conf/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml diff --git a/services/pom.xml b/services/pom.xml index 63e2390..ac4546e 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -26,6 +26,21 @@ exo.kernel.container ${platform.version} + + org.exoplatform.commons + commons-api + ${platform.version} + + + org.exoplatform.social + social-component-core-jpa + 5.0.0-RC13 + + + org.exoplatform.social + social-component-core-jpa + 5.0.0-RC13 + Training Exercise - Services diff --git a/services/src/main/java/org/exoplatform/addons/entity/FavouriteActivity.java b/services/src/main/java/org/exoplatform/addons/entity/FavouriteActivity.java new file mode 100644 index 0000000..d998dbc --- /dev/null +++ b/services/src/main/java/org/exoplatform/addons/entity/FavouriteActivity.java @@ -0,0 +1,62 @@ +package org.exoplatform.addons.entity; + +import javax.persistence.*; + +import org.exoplatform.commons.api.persistence.ExoEntity; +import org.exoplatform.social.core.jpa.storage.entity.ActivityEntity; +import org.exoplatform.social.core.jpa.storage.entity.IdentityEntity; + +import java.util.Calendar; + +@Entity +@ExoEntity +@Table(name = "ADDON_FAVOURITE_ACTIVITY") +public class FavouriteActivity { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "ID") + private Long id; + @ManyToOne + @Column(name = "FAVOURITE_BY_ID") + private IdentityEntity favouriteBy; + @ManyToOne + @Column(name = "ACTIVITY_ID") + private ActivityEntity activity; + + @Temporal(value = TemporalType.TIMESTAMP) + @Column(name = "FAVOURITE_DATE") + private Calendar favouriteDate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public IdentityEntity getFavouriteBy() { + return favouriteBy; + } + + public void setFavouriteBy(IdentityEntity favouriteBy) { + this.favouriteBy = favouriteBy; + } + + public ActivityEntity getActivity() { + return activity; + } + + public void setActivity(ActivityEntity activity) { + this.activity = activity; + } + + public Calendar getFavouriteDate() { + return favouriteDate; + } + + public void setFavouriteDate(Calendar favouriteDate) { + this.favouriteDate = favouriteDate; + } +} diff --git a/services/src/main/java/org/exoplatform/addons/MyService.java b/services/src/main/java/org/exoplatform/addons/services/MyService.java similarity index 85% rename from services/src/main/java/org/exoplatform/addons/MyService.java rename to services/src/main/java/org/exoplatform/addons/services/MyService.java index 27ab852..5855dd8 100644 --- a/services/src/main/java/org/exoplatform/addons/MyService.java +++ b/services/src/main/java/org/exoplatform/addons/services/MyService.java @@ -1,5 +1,6 @@ -package org.exoplatform.addons; +package org.exoplatform.addons.services; +import org.exoplatform.addons.MyStartableService; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; diff --git a/services/src/main/java/org/exoplatform/addons/MyStartableService.java b/services/src/main/java/org/exoplatform/addons/services/MyStartableService.java similarity index 95% rename from services/src/main/java/org/exoplatform/addons/MyStartableService.java rename to services/src/main/java/org/exoplatform/addons/services/MyStartableService.java index a5e47c3..a9c4e40 100644 --- a/services/src/main/java/org/exoplatform/addons/MyStartableService.java +++ b/services/src/main/java/org/exoplatform/addons/services/MyStartableService.java @@ -1,4 +1,4 @@ -package org.exoplatform.addons; +package org.exoplatform.addons.services; import org.exoplatform.container.ExoContainerContext; import org.exoplatform.container.PortalContainer; diff --git a/services/src/main/resources/conf/configuration.xml b/services/src/main/resources/conf/configuration.xml new file mode 100644 index 0000000..61106db --- /dev/null +++ b/services/src/main/resources/conf/configuration.xml @@ -0,0 +1,41 @@ + + + + + + org.exoplatform.commons.api.persistence.DataInitializer + + SocialRDBMSChangeLogsPlugin + addChangeLogsPlugin + org.exoplatform.commons.persistence.impl.ChangeLogsPlugin + + + changelogs + Change logs of Social RDBMS + db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml + + + + + \ No newline at end of file diff --git a/services/src/main/resources/conf/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml b/services/src/main/resources/conf/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml new file mode 100644 index 0000000..56d6412 --- /dev/null +++ b/services/src/main/resources/conf/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/src/main/resources/conf/portal/configuration.xml b/services/src/main/resources/conf/portal/configuration.xml index 7a941c4..33ff018 100644 --- a/services/src/main/resources/conf/portal/configuration.xml +++ b/services/src/main/resources/conf/portal/configuration.xml @@ -21,13 +21,8 @@ --> - - org.exoplatform.addons.MyStartableService - org.exoplatform.addons.MyStartableService - - - org.exoplatform.addons.MyService - org.exoplatform.addons.MyService - - + xmlns="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd"> + + org.exoplatform.commons.persistence.impl.EntityManagerService + + \ No newline at end of file diff --git a/war/src/main/webapp/WEB-INF/conf/configuration.xml b/war/src/main/webapp/WEB-INF/conf/configuration.xml index 3ac88a4..7a941c4 100644 --- a/war/src/main/webapp/WEB-INF/conf/configuration.xml +++ b/war/src/main/webapp/WEB-INF/conf/configuration.xml @@ -22,5 +22,12 @@ - + + org.exoplatform.addons.MyStartableService + org.exoplatform.addons.MyStartableService + + + org.exoplatform.addons.MyService + org.exoplatform.addons.MyService + From f71e9a83f2187e64e7c93d14d8f5d68a4e365947 Mon Sep 17 00:00:00 2001 From: Ali Hamdi Date: Tue, 25 Sep 2018 18:42:12 +0100 Subject: [PATCH 06/10] Update configuration --- .../java/org/exoplatform/addons/services/MyService.java | 3 +-- war/src/main/webapp/META-INF/exo-conf/configuration.xml | 2 +- war/src/main/webapp/WEB-INF/conf/configuration.xml | 8 ++++---- war/src/main/webapp/WEB-INF/web.xml | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/services/src/main/java/org/exoplatform/addons/services/MyService.java b/services/src/main/java/org/exoplatform/addons/services/MyService.java index 5855dd8..16b9d6f 100644 --- a/services/src/main/java/org/exoplatform/addons/services/MyService.java +++ b/services/src/main/java/org/exoplatform/addons/services/MyService.java @@ -1,6 +1,5 @@ package org.exoplatform.addons.services; -import org.exoplatform.addons.MyStartableService; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; @@ -15,7 +14,7 @@ public class MyService { /** * The logger. */ - private static final Log LOG = ExoLogger.getExoLogger(MyStartableService.class); + private static final Log LOG = ExoLogger.getExoLogger(MyService.class); public MyService() { diff --git a/war/src/main/webapp/META-INF/exo-conf/configuration.xml b/war/src/main/webapp/META-INF/exo-conf/configuration.xml index 8758580..4743ac8 100644 --- a/war/src/main/webapp/META-INF/exo-conf/configuration.xml +++ b/war/src/main/webapp/META-INF/exo-conf/configuration.xml @@ -46,7 +46,7 @@ - @@@artifactId@@@ + training-exercises-extension diff --git a/war/src/main/webapp/WEB-INF/conf/configuration.xml b/war/src/main/webapp/WEB-INF/conf/configuration.xml index 7a941c4..00b465e 100644 --- a/war/src/main/webapp/WEB-INF/conf/configuration.xml +++ b/war/src/main/webapp/WEB-INF/conf/configuration.xml @@ -23,11 +23,11 @@ - org.exoplatform.addons.MyStartableService - org.exoplatform.addons.MyStartableService + org.exoplatform.addons.services.MyStartableService + org.exoplatform.addons.services.MyStartableService - org.exoplatform.addons.MyService - org.exoplatform.addons.MyService + org.exoplatform.addons.services.MyService + org.exoplatform.addons.services.MyService diff --git a/war/src/main/webapp/WEB-INF/web.xml b/war/src/main/webapp/WEB-INF/web.xml index 4971888..c15ecc3 100644 --- a/war/src/main/webapp/WEB-INF/web.xml +++ b/war/src/main/webapp/WEB-INF/web.xml @@ -24,7 +24,7 @@ - @@@artifactId@@@ + training-exercises-extension From 167a9e087e70406ce661d0f2771deff9675b5904 Mon Sep 17 00:00:00 2001 From: Ali Hamdi Date: Tue, 25 Sep 2018 18:47:02 +0100 Subject: [PATCH 07/10] Move changelog config to the right folder --- .../db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename services/src/main/resources/{conf => }/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml (100%) diff --git a/services/src/main/resources/conf/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml b/services/src/main/resources/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml similarity index 100% rename from services/src/main/resources/conf/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml rename to services/src/main/resources/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml From 9afef4339d610a7f21d5a4d095edbb77519a5b7e Mon Sep 17 00:00:00 2001 From: Ali Hamdi Date: Tue, 25 Sep 2018 18:49:40 +0100 Subject: [PATCH 08/10] Update the entity --- .../java/org/exoplatform/addons/entity/FavouriteActivity.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/src/main/java/org/exoplatform/addons/entity/FavouriteActivity.java b/services/src/main/java/org/exoplatform/addons/entity/FavouriteActivity.java index d998dbc..b7a76f8 100644 --- a/services/src/main/java/org/exoplatform/addons/entity/FavouriteActivity.java +++ b/services/src/main/java/org/exoplatform/addons/entity/FavouriteActivity.java @@ -18,10 +18,8 @@ public class FavouriteActivity { @Column(name = "ID") private Long id; @ManyToOne - @Column(name = "FAVOURITE_BY_ID") private IdentityEntity favouriteBy; @ManyToOne - @Column(name = "ACTIVITY_ID") private ActivityEntity activity; @Temporal(value = TemporalType.TIMESTAMP) From 93a98cbc62cdfa27c7a1828b8345228e5e01b223 Mon Sep 17 00:00:00 2001 From: Ali Hamdi Date: Tue, 25 Sep 2018 19:00:14 +0100 Subject: [PATCH 09/10] Update changelog to add primary key --- .../db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/services/src/main/resources/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml b/services/src/main/resources/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml index 56d6412..5407070 100644 --- a/services/src/main/resources/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml +++ b/services/src/main/resources/db/changelog/addon-training-rdbms.db.changelog-1.0.0.xml @@ -36,6 +36,7 @@ + From bcafbb33fc1476700e0c92647dbc588cf1a5b75d Mon Sep 17 00:00:00 2001 From: Rdid Mohamed el hadi Date: Fri, 6 Sep 2019 19:03:04 +0200 Subject: [PATCH 10/10] test --- .../exoplatform/addons/services/MyService.java | 12 +++++++----- .../addons/services/MyStartableService.java | 10 +++++----- .../main/resources/conf/portal/configuration.xml | 9 +++++++++ .../addons/services/MyServiceTest.java | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 services/src/test/org/exoplatform/addons/services/MyServiceTest.java diff --git a/services/src/main/java/org/exoplatform/addons/services/MyService.java b/services/src/main/java/org/exoplatform/addons/services/MyService.java index 16b9d6f..37f01d9 100644 --- a/services/src/main/java/org/exoplatform/addons/services/MyService.java +++ b/services/src/main/java/org/exoplatform/addons/services/MyService.java @@ -15,13 +15,15 @@ public class MyService { * The logger. */ private static final Log LOG = ExoLogger.getExoLogger(MyService.class); - - + private String message="alioua"; public MyService() { - LOG.info("##################### Simple service started successfully !!"); } - public void call() { - LOG.info("###################### call function invoked !!"); + public String getMessage() { + + + return message; } + + } diff --git a/services/src/main/java/org/exoplatform/addons/services/MyStartableService.java b/services/src/main/java/org/exoplatform/addons/services/MyStartableService.java index a9c4e40..8c9a21d 100644 --- a/services/src/main/java/org/exoplatform/addons/services/MyStartableService.java +++ b/services/src/main/java/org/exoplatform/addons/services/MyStartableService.java @@ -16,14 +16,14 @@ public class MyStartableService implements Startable { */ private static final Log LOG = ExoLogger.getExoLogger(MyStartableService.class); + public MyStartableService() { + + } + @Override public void start() { LOG.info("&&&&&&&&&&&& My Startable service started !"); - /*PortalContainer portalContainer = (PortalContainer) ExoContainerContext.getCurrentContainer(); - LOG.info("&&&&&&&&&&&& Getting an instance of MyService !"); - MyService myService = (MyService) portalContainer.getComponentInstance(MyService.class); - LOG.info("&&&&&&&&&&&& Calling function call of MyService !"); - myService.call();*/ + } @Override diff --git a/services/src/main/resources/conf/portal/configuration.xml b/services/src/main/resources/conf/portal/configuration.xml index 33ff018..374f96a 100644 --- a/services/src/main/resources/conf/portal/configuration.xml +++ b/services/src/main/resources/conf/portal/configuration.xml @@ -25,4 +25,13 @@ org.exoplatform.commons.persistence.impl.EntityManagerService + + org.exoplatform.addons.services.MyService + + + org.exoplatform.addons.services.MyStartableService + + + org.exoplatform.addons.test.MyStartableServiceTest + \ No newline at end of file diff --git a/services/src/test/org/exoplatform/addons/services/MyServiceTest.java b/services/src/test/org/exoplatform/addons/services/MyServiceTest.java new file mode 100644 index 0000000..e1f1825 --- /dev/null +++ b/services/src/test/org/exoplatform/addons/services/MyServiceTest.java @@ -0,0 +1,16 @@ +package org.exoplatform.addons.services; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class MyServiceTest { + + @Test + void getMessage() { + MyService my=new MyService(); + + assertNotNull(my.getMessage()); + assertEquals("alioua", my.getMessage()); + } +} \ No newline at end of file