Git Product home page Git Product logo

ceylon-dddsample's Introduction

DDDSample for Ceylon and Java EE

This project is a rewrite in Ceylon of this Java EE port of the original Spring DDDSample project.

Java EE technologies used include JPA, CDI, EJB, JAX-RS, JMS, WebSocket, JSF, and Facelets.

Requirements

This project requires Ceylon 1.3.1 and WildFly 10.1.

Compiling and assembling

In the root directory of this project, compile the Ceylon source code:

ceylon compile

Next, assemble the Java EE web application:

ceylon war dddsample -R webapp --static-metamodel

The web application archive dddsample-1.0.0.war is created at the root of the project.

Deploying and running

To deploy the web application archive to WildFly, first copy the .war file to the directory:

wildfly-10.1.0.Final/standalone/deployments

Then start WildFly with the command:

wildfly-10.1.0.Final/bin/standalone.sh -c standalone-full.xml

You must explicitly specify the full configuration because this project uses JMS 2.0 which is not available in the default configuration of Wildfly.

The JPA persistence unit for the application uses the default in memory database that comes preconfigured in WildFly (java:jboss/datasources/ExampleDS).

Try it

To test the application:

  • go to http://localhost:8080/dddsample-1.0.0/,
  • click on the public landing page link,
  • type a cargo name, as suggested, in the search box, and then
  • try other links in the header of the page.

ceylon-dddsample's People

Contributors

gavinking avatar sgalles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ceylon-dddsample's Issues

Areas of discomfort related to Ceylon, noticed during the writing of ceylon-dddsample

@gavinking this is my summary

First I must say that overall I really like what Ceylon brings to a JEE application. There are areas of discomfort, but I must say that it is super pleasant to see the LOC-melt from Java to Ceylon.
And also, the JPA entities looks very good in Ceylon.

That being said, the problems now :

Ceylon WarInitializer and JPA

Ceylon WarInitializer leverages a servlet initialization to initialize Ceylon in a war. Problem is, the servlet initialization does not kick in so enough during the container startup in order to handle all cases.

For instance here a singleton EJB is used to bootstrap the model of the application in database https://github.com/sgalles/ceylon-dddsample/blob/master/source/dddsample/cargotracker/application/util/SampleDataGenerator.ceylon but this happens before the servlet init.

A workaround was added in ceylon-dddsample for this problem :

The WarInitializer servlet is deactivated, and is replaced by almost the same initialization in a portable CDI Extension https://github.com/sgalles/ceylon-dddsample/blob/master/source/dddsample/CeylonInit.java

Problem is, this scheme is not generic enough to be proposed as an alternative to the WarInitializer servlet, indeed :

  • it has a dependency on org.jboss.vfs.VirtualFile because that's the only way that I found to emulate the behavior of WarInitializer without a ServletContext available
  • Even with the help of org.jboss.vfs.VirtualFile I had to find a workaround for https://issues.jboss.org/browse/JBVFS-147 and I leverage a side effect of the implementation of org.jboss.vfs.VirtualFile. It probably means that CeylonInit is not even Wildfly-portable...

FTR Here https://groups.google.com/forum/#!msg/ceylon-users/Lbcnm3ac9PA/hJgZxcqZAwAJ @jvasileff provides a general solution to this initialization problem.

Ceylon collections not usable in JPA entities

Is suspect that not much can be done about this, but basically all collections in JPA entities must be plain Java collections, else JPA complains (IIRC it did not work when I tried to use the collection wrappers of the SDK, but I may have to check this out again).
Update : as suggested by @gavinking, Hibernate Tuplizers should help.

javax.persistence.Converter does not work in autoApply mode

It is minor, but I had to manually apply the converter declared here https://github.com/sgalles/ceylon-dddsample/blob/master/source/dddsample/cargotracker/domain/infrastructure/persistence/jpa/CeylonEnumValuesConverter.ceylon because when I tried to set autoApply=true I received strange classloader errors IIRC. Well not a big deal though, the manual mode works like a charm https://github.com/sgalles/ceylon-dddsample/blob/master/source/dddsample/cargotracker/domain/model/cargo/Delivery.ceylon#L50

FTR fixed problems

Ceylon default constructors in all JPA entities

Was fixed by :
ceylon/ceylon-spec#1405

Ceylon language types not Serializable (for passivating scope)

Was fixed by :
ceylon/ceylon-compiler#2329

JSF conversion error caused by automatic conversion ceylon.language.String -> java.util.String

Basically, because of the automatic conversion I got this error
http://stackoverflow.com/questions/9069379/validation-error-value-is-not-valid
Solved by using String? instead of String it deactivates the conversion.
https://groups.google.com/forum/#!msg/ceylon-users/5n6Oidxa-94/ZaQesjNDBgAJ

Update to Ceylon 1.3.1

Hi @sgalles, I'm trying to update the DDDSample to make use of new functionality of 1.3.1.

I think that I should be able to replace the module descriptor with this:

native("jvm")
module dddsample "1.0.0" {
	
	shared import javax.javaeeapi "7.0";
	shared import java.base "8";
	shared import ceylon.interop.java "1.3.1";
	shared import ceylon.json "1.3.1";
	
	// logging
	shared import org.slf4j.api "1.6.1";
	
}

And I think I should just be able to delete the CeylonInit portable extension, and just use --static-metamodel in ceylon war (or ceylon swarm).

However, when I tried this, I could not seem to get the app to deploy correctly on WildFly 10. It seems to get stuck waiting for the JMS queues to start. (There are no errors in the log.)

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.