openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1766728 - in /openwebbeans/microwave/trunk: microwave-core/src/main/java/org/apache/microwave/ microwave-core/src/main/java/org/apache/microwave/cxf/ microwave-doc/ microwave-doc/src/main/java/org/slf4j/ microwave-doc/src/main/jbake/conten...
Date Wed, 26 Oct 2016 19:49:58 GMT
Author: rmannibucau
Date: Wed Oct 26 19:49:57 2016
New Revision: 1766728

URL: http://svn.apache.org/viewvc?rev=1766728&view=rev
Log:
basic doc structure

Added:
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/cli.adoc
  (with props)
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/configuration.adoc
  (with props)
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-gradle/
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-gradle/index.adoc
  (with props)
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-jpa/
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-jpa/index.adoc
  (with props)
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-maven/
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-maven/index.adoc
      - copied, changed from r1766603, openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/components.adoc
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/testing/
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/testing/index.adoc
Removed:
    openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/slf4j/
    openwebbeans/microwave/trunk/microwave-jpa/README.adoc
Modified:
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/CxfCdiAutoSetup.java
    openwebbeans/microwave/trunk/microwave-doc/pom.xml
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/components.adoc
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/start.adoc

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java?rev=1766728&r1=1766727&r2=1766728&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
Wed Oct 26 19:49:57 2016
@@ -99,6 +99,10 @@ public class Microwave implements AutoCl
     private Runnable postTask;
     private boolean clearCatalinaSystemProperties;
 
+    public Microwave() {
+        this(new Builder());
+    }
+
     public Microwave(final Builder builder) {
         this.configuration = builder;
         this.ownedTempDir = new File(configuration.tempDir, "microwave_" + System.nanoTime());

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/CxfCdiAutoSetup.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/CxfCdiAutoSetup.java?rev=1766728&r1=1766727&r2=1766728&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/CxfCdiAutoSetup.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/CxfCdiAutoSetup.java
Wed Oct 26 19:49:57 2016
@@ -337,7 +337,7 @@ public class CxfCdiAutoSetup implements
 
                             final String address = Logs.singleSlash(base, info.getURITemplate().getValue());
 
-                            final String clazz = info.getResourceClass().getName();
+                            final String clazz = uproxyName(info.getResourceClass().getName());
                             classSize = Math.max(classSize, clazz.length());
                             addressSize = Math.max(addressSize, address.length());
 
@@ -367,7 +367,7 @@ public class CxfCdiAutoSetup implements
 
                         // effective logging
                         log.info("REST Application: " + endpoint.getEndpointInfo().getAddress()
+ " -> "
-                                + ofNullable(app).map(ApplicationInfo::getResourceClass).map(Class::getName).orElse(""));
+                                + ofNullable(app).map(ApplicationInfo::getResourceClass).map(Class::getName).map(CxfCdiAutoSetup::uproxyName).orElse(""));
 
                         Collections.sort(resourcesToLog);
                         final int fClassSize = classSize;
@@ -416,4 +416,11 @@ public class CxfCdiAutoSetup implements
             }
         }
     }
+
+    private static String uproxyName(final String clazz) {
+        if (clazz.contains("$$")) {
+            return clazz.substring(0, clazz.indexOf("$$"));
+        }
+        return clazz;
+    }
 }

Modified: openwebbeans/microwave/trunk/microwave-doc/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/pom.xml?rev=1766728&r1=1766727&r2=1766728&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/pom.xml (original)
+++ openwebbeans/microwave/trunk/microwave-doc/pom.xml Wed Oct 26 19:49:57 2016
@@ -59,12 +59,6 @@
       <groupId>org.jbake</groupId>
       <artifactId>jbake-core</artifactId>
       <version>2.4.0</version>
-      <exclusions>
-        <exclusion>
-          <groupId>org.slf4j</groupId>
-          <artifactId>jul-to-slf4j</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.codehaus.groovy</groupId>

Modified: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/components.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/components.adoc?rev=1766728&r1=1766727&r2=1766728&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/components.adoc (original)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/components.adoc Wed
Oct 26 19:49:57 2016
@@ -7,20 +7,37 @@
 :jbake-microwavecolor: body-pink
 :icons: font
 
-TBD
-
 == Microwave Core
 
-TBD
+Core component is the backbone of Microwave. It is based on Tomcat embedded for
+Servlet container, CXF for JAX-RS, OpenWebBeans for CDI and Log4j2 for the logging.
+
+link:microwave-core/configuration.html[Read about Microwave configuration]
+
+link:microwave-core/cli.html[Read about Microwave command line]
 
 == Microwave JPA
 
-TBD
+Microwave JPA provides a thin layer on top of JPA to make it easier to use JPA
+without requiring to use a full container like JavaEE or Spring. It is just a
+CDI extension.
+
+link:microwave-jpa/index.html[Read More]
 
 == Microwave Maven
 
-TBD
+Microwave provides a Maven plugin to run microwave with your preferred build tool.
+
+link:microwave-maven/index.html[Read More]
 
 == Microwave Gradle
 
-TBD
+Microwave provides a Gradle plugin to run microwave with your preferred build tool.
+
+link:microwave-gradle/index.html[Read More]
+
+== Microwave and the Testing
+
+Microwave provides two main testing integration: a JUnit one and an Arquillian Container.
+
+link:testing/index.html[Read More]

Added: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/cli.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/cli.adoc?rev=1766728&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/cli.adoc
(added)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/cli.adoc
Wed Oct 26 19:49:57 2016
@@ -0,0 +1,10 @@
+= Microwave Command Line Interface
+:jbake-date: 2016-10-24
+:jbake-type: page
+:jbake-status: published
+:jbake-microwavepdf:
+:jbake-microwavetitleicon: icon icon_puzzle_alt
+:jbake-microwavecolor: body-pink
+:icons: font
+
+TBD

Propchange: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/cli.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/configuration.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/configuration.adoc?rev=1766728&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/configuration.adoc
(added)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/configuration.adoc
Wed Oct 26 19:49:57 2016
@@ -0,0 +1,13 @@
+= Microwave Configuration
+:jbake-date: 2016-10-24
+:jbake-type: page
+:jbake-status: published
+:jbake-microwavepdf:
+:jbake-microwavetitleicon: icon icon_puzzle_alt
+:jbake-microwavecolor: body-pink
+:icons: font
+
+== Builder
+
+TBD
+

Propchange: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/configuration.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-gradle/index.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-gradle/index.adoc?rev=1766728&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-gradle/index.adoc
(added)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-gradle/index.adoc
Wed Oct 26 19:49:57 2016
@@ -0,0 +1,10 @@
+= Microwave Gradle
+:jbake-date: 2016-10-24
+:jbake-type: page
+:jbake-status: published
+:jbake-microwavepdf:
+:jbake-microwavetitleicon: icon icon_puzzle_alt
+:jbake-microwavecolor: body-pink
+:icons: font
+
+TBD
\ No newline at end of file

Propchange: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-gradle/index.adoc
------------------------------------------------------------------------------
    svn:executable = *

Added: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-jpa/index.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-jpa/index.adoc?rev=1766728&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-jpa/index.adoc
(added)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-jpa/index.adoc
Wed Oct 26 19:49:57 2016
@@ -0,0 +1,110 @@
+= Microwave JPA
+:jbake-date: 2016-10-24
+:jbake-type: page
+:jbake-status: published
+:jbake-microwavepdf:
+:jbake-microwavetitleicon: icon icon_puzzle_alt
+:jbake-microwavecolor: body-pink
+:icons: font
+
+
+The overall idea behind this module is to propose a CDI integration of JPA
+allowing to programmatically control its persistence units.
+
+Concretely you will create a persistence unit from a `PersistenceUnitBuilder`
+allowing you to fully configure your unit from CDI context including the datasource:
+
+[source,java]
+----
+@ApplicationScoped
+public class JpaConfig {
+    @Produces
+    public PersistenceUnitInfoBuilder unit(final DataSource ds) {
+        return new PersistenceUnitInfoBuilder()
+                .setUnitName("test")
+                .setDataSource(ds)
+                .setExcludeUnlistedClasses(true)
+                .addManagedClazz(User.class)
+                .addProperty("openjpa.RuntimeUnenhancedClasses", "supported")
+                .addProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema");
+    }
+}
+----
+
+TIP: if your application uses a single persistence unit this is optional and
+a default one will be created if a single DataSource bean is available as Bean<?>.
+
+The datasource can be produces as you wish using your own configuration mecanism:
+
+[source,java]
+----
+@ApplicationScoped
+public class JpaConfig {
+    @Produces // dbcp2 datasource for instance
+    @ApplicationScoped
+    public DataSource dataSource() {
+        final BasicDataSource source = new BasicDataSource();
+        source.setDriver(new Driver());
+        source.setUrl("jdbc:h2:mem:jpaextensiontest");
+        return source;
+    }
+}
+----
+
+NOTE: it is recommanded to ensure the `DataSource` is normal-scoped to not get surprises
in term of behavior.
+
+Finally you can inject your entity manager using `@Unit`. Ensure to
+decorate with `@Jpa` a class/method before using the entity manager to activate
+the jpa CDI context:
+
+[source,java]
+----
+@ApplicationScoped
+@Jpa(transactional = false)
+public class JPADao {
+    @Inject
+    @Unit(name = "test")
+    private EntityManager em;
+
+    @Jpa // with a resource local transaction
+    public User save(final User user) {
+        em.persist(user);
+        return user;
+    }
+
+    // inherit form class, no tx
+    public User find(final long id) {
+        return em.find(User.class, id);
+    }
+}
+----
+
+IMPORTANT: this integration is 100% based on `RESOURCE_LOCAL` units for now.
+
+Not that if a bean get injected an `EntityManager` it gets automatically `@Jpa(transactional=true)`
+so previous bean is equivalent to:
+
+[source,java]
+----
+@ApplicationScoped
+public class JPADao {
+    @Inject
+    @Unit(name = "test")
+    private EntityManager em;
+
+    public User save(final User user) {
+        em.persist(user);
+        return user;
+    }
+
+    @Jpa(transactional = false)
+    public User find(final long id) {
+        return em.find(User.class, id);
+    }
+}
+----
+
+== Integration with Bean Validation
+
+The extension will try to find a `ValidatorFactory` in CDI context and will provide ir to
the JPA provider
+if the `ValidationMode` is not `NONE` and a `Bean<ValidatorFactory>` exists.

Propchange: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-jpa/index.adoc
------------------------------------------------------------------------------
    svn:executable = *

Copied: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-maven/index.adoc
(from r1766603, openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/components.adoc)
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-maven/index.adoc?p2=openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-maven/index.adoc&p1=openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/components.adoc&r1=1766603&r2=1766728&rev=1766728&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/components.adoc (original)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-maven/index.adoc
Wed Oct 26 19:49:57 2016
@@ -1,4 +1,4 @@
-= Components
+= Microwave Maven
 :jbake-date: 2016-10-24
 :jbake-type: page
 :jbake-status: published
@@ -7,20 +7,4 @@
 :jbake-microwavecolor: body-pink
 :icons: font
 
-TBD
-
-== Microwave Core
-
-TBD
-
-== Microwave JPA
-
-TBD
-
-== Microwave Maven
-
-TBD
-
-== Microwave Gradle
-
-TBD
+TBD
\ No newline at end of file

Modified: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/start.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/start.adoc?rev=1766728&r1=1766727&r2=1766728&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/start.adoc (original)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/start.adoc Wed Oct 26
19:49:57 2016
@@ -6,4 +6,43 @@
 :jbake-microwavecolor: body-green
 :icons: font
 
-TBD
+== Your first application
+
+Microwave relies on JAX-RS and CDI so to start you just need to write a JAX-RS endpoint:
+
+[source,java]
+----
+@Path("kitchen")
+@ApplicationScoped
+public class HelloKitchen {
+    @GET
+    public String getMenu() {
+        return "good things";
+    }
+}
+----
+
+Then booting Microwave is as easy as launching:
+
+[source,java]
+----
+try (final Microwave microwave = new Microwave().bake()) {
+    new Scanner(System.in).nextLine();
+}
+----
+
+You should get some output containing:
+
+[source]
+----
+[19:54:55.397][INFO][main][.microwave.cxf.CxfCdiAutoSetup] REST Application: / -> org.apache.cxf.cdi.DefaultApplication
+[19:54:55.399][INFO][main][.microwave.cxf.CxfCdiAutoSetup]      Service URI: /kitchen  ->
org.app.HelloKitchen
+[19:54:55.401][INFO][main][.microwave.cxf.CxfCdiAutoSetup]               GET /kitchen/ ->
     String getMenu()
+----
+
+And you can check it works doing:
+
+[source]
+----
+curl http://localhost:8080/kitchen
+----

Added: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/testing/index.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/testing/index.adoc?rev=1766728&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/testing/index.adoc (added)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/testing/index.adoc Wed
Oct 26 19:49:57 2016
@@ -0,0 +1,16 @@
+= Microwave Testing
+:jbake-date: 2016-10-24
+:jbake-type: page
+:jbake-status: published
+:jbake-microwavepdf:
+:jbake-microwavetitleicon: icon icon_puzzle_alt
+:jbake-microwavecolor: body-pink
+:icons: font
+
+== JUnit: rules and runners
+
+TBD
+
+== Arquillian Container
+
+TBD



Mime
View raw message