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.
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
Tentatively November 2012
Tentatively June 2013
DeltaSpike closes the gaps in Java EE 6.
We believe the community can create awesome CDI extensions and easily share them.
@Inject ProjectStage projectStage;
...
if (ProjectStage.Developement.equals(this.projectStage)) {
// execute during development
}
@Exclude(ifProjectStage = ProjectStage.Development.class)
public class MyBean { }
@Exclude(onExpression = "db==prodDB")
public class DevDbBean { }
@ApplicationScoped
public class SettingsBean implements Deactivatable {
@Inject @ConfigProperty(name = "property1")
private Integer intProperty1;
//...
}
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 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());
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);
@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();
}
}
@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();
}
}
@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));
}
}
}
@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");
}
}