You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/04/10 11:23:02 UTC

svn commit: r1672594 - in /tomee/site/trunk/content/application-composer: advanced.md getting-started.md

Author: rmannibucau
Date: Fri Apr 10 09:23:02 2015
New Revision: 1672594

URL: http://svn.apache.org/r1672594
Log:
reworking code blocks

Modified:
    tomee/site/trunk/content/application-composer/advanced.md
    tomee/site/trunk/content/application-composer/getting-started.md

Modified: tomee/site/trunk/content/application-composer/advanced.md
URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/application-composer/advanced.md?rev=1672594&r1=1672593&r2=1672594&view=diff
==============================================================================
--- tomee/site/trunk/content/application-composer/advanced.md (original)
+++ tomee/site/trunk/content/application-composer/advanced.md Fri Apr 10 09:23:02 2015
@@ -7,13 +7,11 @@
 You can reuse existing file descriptors using `@Descriptors`. The name is the file name
 and the path either a classpath path or a file path:
 
-```java
-// runner if needed etc...
-@Descriptors(@Descriptor(name = "persistence.xml", path = "META-INF/persistence.xml"))
-public class MyTest {
-   //...
-}
-``̀̀
+    // runner if needed etc...
+    @Descriptors(@Descriptor(name = "persistence.xml", path = "META-INF/persistence.xml"))
+    public class MyTest {
+       //...
+    }
 
 Note: this can be put in a `@Module` method as well.
 
@@ -23,13 +21,11 @@ If you want to test a JAXRS or JAXWS ser
 
 To do so just add the needed dependency and use `@EnableServices`:
 
-```java
-// runner if needed etc...
-@EnableService("jaxrs") // jaxws supported as well
-public class MyTest {
-   //...
-}
-``̀̀
+    // runner if needed etc...
+    @EnableService("jaxrs") // jaxws supported as well
+    public class MyTest {
+       //...
+    }
 
 ## Random port
 
@@ -39,13 +35,11 @@ to be able to deploy multiple tests/proj
 To shortcut all the needed logic you can use `@RandomPort`. It is simply an injection giving
 you either the port (`int`) or the root context (`URL`):
 
-```java
-// runner, services if needed etc...
-public class MyTest {
-   @RandomPort("http")
-   private int port;
-}
-``̀̀
+    // runner, services if needed etc...
+    public class MyTest {
+       @RandomPort("http")
+       private int port;
+    }
 
 Note: you can generate this way multiple ports. The value is the name of the service it will apply on (being said http
 is an alias for httpejbd which is our embedded http layer).
@@ -62,14 +56,12 @@ is an alias for httpejbd which is our em
 
 `@Jars` allows you to add dependencies (scanned) to your application automatically (like CDI libraries):
 
-```java
-@Module
-@Classes(cdi = true, value = { C1.class, C2.class, E1.class })
-@Jars("deltaspike-")
-public WebApp app() {
-    return new WebApp();
-}
-`̀`
+    @Module
+    @Classes(cdi = true, value = { C1.class, C2.class, E1.class })
+    @Jars("deltaspike-")
+    public WebApp app() {
+        return new WebApp();
+    }
 
 ## @Default
 

Modified: tomee/site/trunk/content/application-composer/getting-started.md
URL: http://svn.apache.org/viewvc/tomee/site/trunk/content/application-composer/getting-started.md?rev=1672594&r1=1672593&r2=1672594&view=diff
==============================================================================
--- tomee/site/trunk/content/application-composer/getting-started.md (original)
+++ tomee/site/trunk/content/application-composer/getting-started.md Fri Apr 10 09:23:02 2015
@@ -9,32 +9,27 @@ To start using ApplicationComposer you n
 
 The minimum required one is `openejb-core`:
 
-```xml
-<dependency>
-  <groupId>org.apache.openejb</groupId>
-  <artifactId>openejb-core</artifactId>
-  <version>${openejb.version></version>
-</dependency>
-```
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-core</artifactId>
+      <version>${openejb.version></version>
+    </dependency>
 
 If you need JAXRS services you'll add (or replace thanks to transitivity of maven) `openejb-cxf-rs`:
 
-```xml
-<dependency>
-  <groupId>org.apache.openejb</groupId>
-  <artifactId>openejb-cxf-rs</artifactId>
-  <version>${openejb.version></version>
-</dependency>
-```
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-cxf-rs</artifactId>
+      <version>${openejb.version></version>
+    </dependency>
+
 If you need JAXWS services you'll add (or replace thanks to transitivity of maven) `openejb-cxf`:
 
-```xml
-<dependency>
-  <groupId>org.apache.openejb</groupId>
-  <artifactId>openejb-cxf</artifactId>
-  <version>${openejb.version></version>
-</dependency>
-```
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-cxf</artifactId>
+      <version>${openejb.version></version>
+    </dependency>
 
 etc...
 
@@ -49,12 +44,10 @@ To do so you have two cases:
 * before TomEE 2.x: you can only write method(s) decorated with `@Module`
 * since TomEE 2.x: you can skip it and use `@Classes` directly on the ApplicationComposer class as a shortcut for:
 
-```java
-@Module
-public WebApp app() {
-    return new WebApp();
-}
-```
+    @Module
+    public WebApp app() {
+        return new WebApp();
+    }
 
 The expected returned type of these methods are in `org.apache.openejb.jee` package:
 
@@ -71,13 +64,11 @@ The expected returned type of these meth
 Note that for easiness `@Classes` was added to be able to describe a module and some scanned classes. For instance the
 following snippet will create a web application with classes C1, C2 as CDI beans and E1 as an EJB automatically:
  
-```java
-@Module
-@Classes(cdi = true, value = { C1.class, C2.class, E1.class })
-public WebApp app() {
-    return new WebApp();
-}
-`̀`
+    @Module
+    @Classes(cdi = true, value = { C1.class, C2.class, E1.class })
+    public WebApp app() {
+        return new WebApp();
+    }
 
 ### @Configuration
 
@@ -91,27 +82,23 @@ In these properties you can reuse OpenEJ
 
 Here is a sample:
 
-```java
-@Configuration
-public Properties configuration() {
-    return new PropertiesBuilder()
-        .p("db", "new://Resource?type=DataSource")
-        .p("db.JdbcUrld", "jdbc:hsqldb:mem:test")
-        .build();
-}
-`̀`
+    @Configuration
+    public Properties configuration() {
+        return new PropertiesBuilder()
+            .p("db", "new://Resource?type=DataSource")
+            .p("db.JdbcUrld", "jdbc:hsqldb:mem:test")
+            .build();
+    }
 
 Since TomEE 2.x you can also put properties on ApplicationComposer class using `@ContainerProperties` API:
 
-```java
-@ContainerProperties({
-  @ContainerProperties.Property(name = "db", value = "new://Resource?type=DataSource"),
-  @ContainerProperties.Property(name = "db.JdbcUrl", value = "jdbc:hsqldb:mem:test")
-})
-public class MyAppComposer() {
-  // ...
-}
-`̀`
+    @ContainerProperties({
+      @ContainerProperties.Property(name = "db", value = "new://Resource?type=DataSource"),
+      @ContainerProperties.Property(name = "db.JdbcUrl", value = "jdbc:hsqldb:mem:test")
+    })
+    public class MyAppComposer() {
+      // ...
+    }
 
 ### @Component
 
@@ -123,12 +110,10 @@ To do so just write a method decorated w
 Components in TomEE are stored in a container Map and the key needs to be a `Class`. This one is deduced from the returned
 type of the `@Component` method:
 
-```java
-@Component
-public SecurityService mockSecurity() {
-    return new MySecurityService();
-}
-`̀`
+    @Component
+    public SecurityService mockSecurity() {
+        return new MySecurityService();
+    }
 
 ## How to run it?
 
@@ -138,21 +123,17 @@ If you use JUnit you have mainly 2 solut
 
 * using `ApplicationComposer` runner:
 
-```java
-@RunWith(ApplicationComposer.class)
-public class MyTest {
-    // ...
-}
-`̀`
+    @RunWith(ApplicationComposer.class)
+    public class MyTest {
+        // ...
+    }
 
 * using `ApplicationComposerRule` rule:
 
-```java
-public class MyTest {
-    @Rule // or @ClassRule if you want the container/application lifecycle be bound to the class and not test methods
-    public final ApplicationComposerRule rule = new ApplicationComposerRule(this);
-}
-`̀`
+    public class MyTest {
+        @Rule // or @ClassRule if you want the container/application lifecycle be bound to the class and not test methods
+        public final ApplicationComposerRule rule = new ApplicationComposerRule(this);
+    }
 
 Tip: since TomEE 2.x ApplicationComposerRule is decomposed in 2 rules if you need: `ContainerRule` and `DeployApplication`.
 Using JUnit `RuleChain` you can chain them to get the samebehavior as `ApplicationComposerRule` or better deploy
@@ -172,36 +153,32 @@ Finally just write TestNG `@Test` method
 Since TomEE 2.x you can also use `ApplicationComposers` to directly run you ApplicationComposer model
 as a standalone application:
 
-```java
-public class MyApp {
-    public static void main(String[] args) {
-        ApplicationComposers.run(MyApp.class, args);
+    public class MyApp {
+        public static void main(String[] args) {
+            ApplicationComposers.run(MyApp.class, args);
+        }
+    
+        // @Module, @Configuration etc...
     }
 
-    // @Module, @Configuration etc...
-}
-`̀̀
-
 Tip: if `MyApp` has `@PostConstruct` methods they will be respected and if `MyApp` has a constructor taking an array
 of String it will be instantiated getting the second parameter as argument (ie you can propagate your main parameter
 to your model to modify your application depending it!)
 
 ## JUnit Sample
 
-```java
-@Classes(cdi = true, value = { MyService.class, MyOtherService.class })
-@ContainerProperties(@ContainerProperties.Property(name = "myDb", value = "new://Resource?type=DataSource"))
-@RunWith(ApplicationComposer.class)
-public class MyTest {
-    @Resource(name = "myDb")
-    private DataSource ds;
-
-    @Inject
-    private MyService service;
-
-    @Test
-    public void myTest() {
-        // do test using injections
+    @Classes(cdi = true, value = { MyService.class, MyOtherService.class })
+    @ContainerProperties(@ContainerProperties.Property(name = "myDb", value = "new://Resource?type=DataSource"))
+    @RunWith(ApplicationComposer.class)
+    public class MyTest {
+        @Resource(name = "myDb")
+        private DataSource ds;
+    
+        @Inject
+        private MyService service;
+    
+        @Test
+        public void myTest() {
+            // do test using injections
+        }
     }
-}
-`̀̀