Introducing The JBoss Developer Framework


Pete Muir
Principal Software Engineer, Red Hat, Inc.
Jason Porter
Senior Software Engineer, Red Hat, Inc.

Session Objective

By the end of this session you will understand the resources that JBoss Developer Framework offers you.

You will have seen how productive you can be with the JBoss stack.

Agenda

  • What is JBoss Developer Framework
    • Quickstarts & JBoss BOMs
    • Migration
    • Demo and overview of TicketMonster
  • Roadmap
    • What's in jdf 2.0
    • How does DeltaSpike fit in?

What is jdf?

JBoss Developer Framework shows you how to write applications using JBoss technologies

  • Learn how to write an application suitable for mobile
  • Learn how to use the Java EE 6 API with JBoss AS
  • Learn how to add the power of CDI to your browser

Highlights

  • 54 Quickstarts, focused on a single use case or API
  • Medium complexity example - TicketMonster
  • Stacks defined for Java EE, Errai, Hibernate, Arquillian, Transactions (more to come)
  • Migration guides for Spring, Seam 2 and Java EE 5

Quick plug

Wednesday @ 3:40pm

Quickstarts & JBoss BOMs

Demo

What is TicketMonster?

  • Online ticketing application
  • Medium complexity
  • Demonstrates a choice of view layers
  • Uses JBoss Data Grid to scale application

End-User requirements

  • Smooth interaction (no flicker!)
  • Fast response
  • Mobile and tablet usage

What can administrators do?

Administrator requirements

  • Easy CRUD
  • Real-time status updates

TicketMonster Architecture

Core: Java EE

  • Persistence (JPA)
  • Dependency injection (CDI)
  • Eventing
  • Transactional business components (EJB)
  • REST-ful remote access endpoints (JAX-RS)

End-user views

### HTML5+REST

  • Single page application
    • No flicker
    • Mobile optimized
  • Javascript MVC via backbone.js adds structure
  • Same architecture for mobile (jQuery Mobile) and desktop

HTML5 Architecture

Administration views

### RichFaces/JSF

  • All Java EE6 architecture
  • Rapid development through JBoss Forge
  • Richfaces adds advanced components

Monitoring views

### Errai/GWT

  • All-around Java (backend, front-end)
  • Compiled to Javascript via GWT
  • Errai adds in-browser real-time updates via CDI eventing

jdf Roadmap

jdf 2.0

Tentatively November 2012

  • DeltaSpike
  • Security
  • Mobile Native & Offline Data
  • Data Grids

jdf 2.next

Tentatively June 2013

  • More DeltaSpike
  • SSO (PicketLink)
  • Social (Agorava)
  • jbpm & Drools

Apache DeltaSpike

DeltaSpike closes the gaps in Java EE 6.

We believe the community can create awesome CDI extensions and easily share them.
  • Fragmentation
  • Duplicate work
  • location?

DeltaSpike (current) Features

v0.1-incubating

  • SE compatibility
  • Utilities
  • Author tools

v0.1-incubating

Project Stage

    @Inject ProjectStage projectStage;
    ...
    if (ProjectStage.Developement.equals(this.projectStage)) {
      // execute during development
    }

Exclude

    @Exclude(ifProjectStage = ProjectStage.Development.class)
    public class MyBean { }
    
    @Exclude(onExpression = "db==prodDB")
    public class DevDbBean { }

Config

    @ApplicationScoped
    public class SettingsBean implements Deactivatable {
        @Inject @ConfigProperty(name = "property1")
        private Integer intProperty1;
        //...
    }

v0.1-incubating (cont)

AnnotationInstanceProvider

    Map<String, Object> memberVals = new HashMap<String, Object>();
    memberVals.put("booleanValue", false);
    memberVals.put("byteValues", new byte[]{(byte) 0});
    memberVals.put("type", Object.class);
    
    TestAnnotation annotation = AnnotationInstanceProvider.of(TestAnnotation.class, memberVals);

AnnotatedTypeBuilder

    AnnotatedTypeBuilder builder = new AnnotatedTypeBuilder();
    builder.readFromType(beanClass);
    String beanName = namedAnnotation.value();
    String newBeanName = beanName.substring(0, 1).toLowerCase() + beanName.substring(1);
    builder.removeFromClass(Named.class).addToClass(new NamedLiteral(newBeanName));
    processAnnotatedType.setAnnotatedType(builder.create());

BeanProvider

    MyBean bean = BeanProvider.getContextualReference("myBean", false, MyBean.class);
    MyBean bean = BeanProvider.getContextualReference(MyBean.class, false, new QualifierLiteral());
    Object bean = BeanProvider.getContextualReference("myBean", false);
    List<MyServiceInterface> myServices = BeanProvider.getContextualReferences(MyServiceInterface.class, false);
    List<MyServiceInterface> myServices = BeanProvider.getContextualReferences(MyServiceInterface.class, false, false);

DeltaSpike (current) Features

v0.2-incubating

  • Security
  • Exception Handling
  • i18n

v0.2-incubating

Security - Securing a bean method

    @ApplicationScoped 
    public class CustomAuthorizer {     
      @Secures @CustomSecurityBinding     
      public boolean doSecuredCheck(InvocationContext invocationContext, 
                                    BeanManager manager, @LoggedIn User user) throws Exception {         
        return user.isLoggedIn(); 
        // perform security check     
      } 
    }
    
    @ApplicationScoped
    public class SecuredBean1 {
        @CustomSecurityBinding
        public void doSomething(Thing thing) {
            thing.doSomething();
        }
    }

v0.2-incubating

Security - Security Parameter Binding

    @ApplicationScoped
    public class CustomAuthorizer {
        @Secures @CustomSecurityBinding
        public boolean doSecuredCheck(InvocationContext invocationContext, 
                                      BeanManager manager, @LoggedIn User user, 
                                      @CurrentThing Thing thing) throws Exception {
            return thing.hasMember(user); // perform security check against our method parameter
        }
    }
    
    @ApplicationScoped
    public class SecuredBean1 {
        @CustomSecurityBinding
        public void doSomething(@CurrentThing Thing thing) {
            thing.doSomething();
        }
    }

v0.2-incubating

Exception Handling

    @ExceptionHandler
    public class MyHandlers {
       void printExceptions(@Handles ExceptionEvent<PersistenceException> evt) {
          System.out.println("Something bad happened: " + evt.getException().getMessage());
          evt.handleAndContinue();
       }
    }
    
    public class InventoryActions {
      @PersistenceContext private EntityManager em;
      @Inject private Event<ExceptionToCatchEvent> catchEvent;
      
      public Integer queryForItem(Item item) {
        try {
          Query q = em.createQuery("SELECT i from Item i where i.id = :id");
          q.setParameter("id", item.getId());
          return q.getSingleResult();
        } catch (PersistenceException e) {
          catchEvent.fire(new ExceptionToCatchEvent(e));
        }
      }
    }

v0.2-incubating

i18n

    @MessageBundle
    public interface SimpleMessage {
        @MessageTemplate("Welcome to DeltaSpike") String welcomeToDeltaSpike();
    }
    
    @MessageBundle
    @MessageContextConfig(messageInterpolator = CustomMessageInterpolator.class)
    public interface SimpleMessage {
        // in the message bundle: welcome_to=Welcome to %s
    
        @MessageTemplate("{welcome_to}") String welcomeTo(String name);
    }
    
    //...
    public class MyBean {
        @Inject private SimpleMessage messages;
    
        public String welcomeToDeltaSpike {
            return this.messages.welcomeTo("DeltaSpike");
        }
    }

v0.3-incubating (in development)

  • JPA
  • Transaction Support

Can I get support?

Q&A