SlideShare a Scribd company logo
APACHE DELTASPIKE
THE CDITOOLBOX
@antoine_sd
ANTOINE SABOT-DURAND
• Senior Software Engineer @Red Hat
• Java & OSS :
• CDI co-spec lead
• CDI community development
• Apache Deltaspike committer
• @antoine_sd
AGENDA
• What is Apache Deltaspike?
• Deltaspike Core
• Deltaspike Modules
• Conclusion
WHAT IS APACHE DELTASPIKE
CDI & DELTASPIKE
• CDI is a specification. It doesn’t provide business features
• but it includes a powerful hook to add these business features
• The “portable extensions” feature is this hook
• Thanks to it, CDI can be easily enhanced with new high level features
APACHE DELTASPIKE IS…
• A collection of ready to use extensions to help you in your projects
• A toolbox to help you develop new CDI portable extensions
• A great way to learn how to develop your own extension by
browsing the source code
• The most obvious entry point to CDI eco-system
WHERE DOES IT COMES FROM?
Font: Avenir Light
Font-size: 64pt
Letter-spacing: 410
RGB: 51,181 229
HEX: #35b4e3
C=66.45 M=8.61 Y=1.97 K=0
Miscellaneous CDI Initiatives
TESTED WITH
• CDI 1.0, 1.1, 1.2
• JBoss Weld 1.1.3 to 2.2.8
• OpenWebBeans 1.1.1 to 1.2.7
• JBoss AS 7.x,WildFly 8.x
• JBoss EAP 6.x
• TomEE 1.0.x - 1.7.x
• GlassFish 3.x, 4.x
• Weblogic 12c
A BIT OF HISTORY
Dec 2011 Feb 2012 May 2013 June 2014
ProjectLaunch
rel.0.1
rel.0.4(outofincubator)
rel.1.0
Dec 2014
rel.1.2.1
WHAT’S INCLUDED?
Apache Deltaspike is organized in the following modules
Container control provides a portable way to boot CDI container
Core Module core features and helpers. Used by all other modules below
Partial Bean Module develop generic handler to choose code dynamically at runtime
Scheduler Module add job scheduling with Quartz or any other scheduler
Security Module add security checking. Integration of 3rd party security framework
BeanValidation Module CDI integration for BeanValidation 1.0
JPA Module Enhance JPA integration for CDI 1.0. Mostly useless in Java EE 7
Data Module Implements repository pattern removing JPA boilerplate code
Servlet Module Enhance Servlet integration for CDI 1.0. Mostly useless in Java EE 7
JSF Module Enhance JSF by adding CDI scopes, typesafe view config, etc…
Test control provide a test solution for CDI based on Junit
MODULES AND DEPENDENCIES
Partial Bean Core
Bean
Validation
JPAData
Security
JSF
Scheduler Servlet
Test CTRL
Containers
CTRL
ADDING DELTASPIKETOYOUR POM.XML
<dependency>

<groupId>org.apache.deltaspike.core</groupId>

<artifactId>deltaspike-core-api</artifactId>

<version>1.2.1</version>

<scope>compile</scope>

</dependency>



<dependency>

<groupId>org.apache.deltaspike.core</groupId>

<artifactId>deltaspike-core-impl</artifactId>

<version>1.2.1</version>

<scope>runtime</scope>

</dependency>
DELTASPIKE CORE
CONFIGURATION 1/2
• DeltaSpike provides a powerful configuration API / SPI
• It doesn’t depend on CDI, thus it can be used in portable extension
• The entry point is the ConfigResolver class
• ConfigSource SPI allows to add new configuration source
• Each config has a priority (ordinal).This highest is picked first
CONFIGURATION 2/2
Out of the Box Config Sources
ConfigSource Priority Notes
System properties 400
Environment properties 300
JNDI values 200 java:comp/env/deltaspike
Properties files value 100 META-INF/apache-deltaspike.properties
CONFIGURATION USAGE
//ConfigResolver can be used directly without CDI dependency (useful in extensions)

String dbUserName = ConfigResolver.getPropertyValue("databaseconfig.username");
…
//Config can also be used in CDI mode and typeSafe config

@Inject

@ConfigProperty(name = "endpoint.poll.interval")

private Integer p; // DS provides conversion for String, Integer, Long, Boolean, Float
…
//But you can provide your own ConfigProperty producer to perform custom conversion

@ApplicationScoped

public class MyConfigPropertyProducer extends BaseConfigPropertyProducer {

@Produces @ConfigProperty(name = "ignored")

public MyType produceStringConfiguration(InjectionPoint injectionPoint) {
String strValue = getStringPropertyValue(injectionPoint);
…
}

}
PROJECT STAGES
• Allows to use implementations depending on current environment
• You can defined your owned stage or used the provided ones
• Pre-defined project stages:
• UnitTest, Development, SystemTest, IntegrationTest, Staging, Production
• Project Stage is configured thru DS configuration mechanism
PROJECT STAGE EXAMPLE
//Setting project stage with environment property
-Dorg.apache.deltaspike.ProjectStage=Development
…
//Using project stage

@Inject

private ProjectStage projectStage;

boolean isDevProjectStage = ProjectStage.Development.equals(this.projectStage);
BEAN EXCLUSION WITH @EXCLUDE
@Exclude //like CDI 1.1+ @Vetoed but limited to a class
@Exclude(ifProjectStage=Production.class) //based on project stage


@Exclude(exceptIfProjectStage=UnitTest.class) //based on project stage


@Exclude(onExpression="myProperty==myValue") //based on config value


@Exclude(onExpression="[cust exp]", interpretedBy=CustomExpInterpreter.class) //custom
EXCEPTION HANDLERS
• Based on CDI event
• ExceptionToCatchEvent class sends the exception to DS
• @ExceptionHandler marks a class as handlers container
• @Handles and ExceptionEvent<T> handle an exception
EXCEPTION HANDLER EXAMPLE
public class InventoryActions {

@PersistenceContext

private EntityManager em;

@Inject

private Event<ExceptionToCatchEvent> catchEvent;



public Integer queryForItem(Item i) {

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));

}

}

}
…
@ExceptionHandler

public class MyHandler {

void handleTheException(@Handles ExceptionEvent<Throwable> exEvent) {

// Do anything with the exception

exEvent.handleAndContinue();

}

}
INJECTABLE RESOURCE
@Inject

@InjectableResource(location = "/version.txt")

private InputStream is; //Can be customised for alternate sources



public String getVersion() throws IOException {

try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {

return br.readLine();

}

}
INTERNATIONALISATION (I18N)
package org.apache.deltaspike.example



@MessageBundle // Can only be applied on an interface

public interface SimpleMessage
// Will map the org/apache/deltaspike/example/SimpleMessage bundle

{

@MessageTemplate(“{my_message}”) // Will map my_message key in bundle

String welcomeToDeltaSpike();
// For value with parameter i.e welcome_to = Welcome to %s 

@MessageTemplate("{welcome_to}")

String welcomeTo(String name);


}
CDI METADATA BUILDERS
• Creating CDI SPI metadata for you extension can be cumbersome
• Deltaspike provides builder to ease the work and reduce code verbosity
• Major builder are
• AnnotatedTypeBuilder
• BeanBuilder
• WrapperBeanBuilder
BUILDING META DATA EXAMPLES
void addTimedBinding(@Observes BeforeBeanDiscovery bbd) {

AnnotationLiteral<Nonbinding> nonbindingLiteral = new AnnotationLiteral<Nonbinding>(){};

AnnotatedTypeBuilder<Timed> atb = new AnnotatedTypeBuilder<Timed>()

.readFromType(Timed.class)

.addToMethod(Timed.class.getMethod("name"), nonbindingLiteral)

.addToMethod(Timed.class.getMethod(“absolute"),nonbindingLiteral);

bbd.addInterceptorBinding(atb.create());

}
…
public void registerGenericBeans(@Observes AfterBeanDiscovery abd) {

BeanBuilder<User> ubb = new BeanBuilder<User>(beanManager)

.readFromType(User.class)

.passivationCapable(true)

.addTypes(otherTypes);

if (weAreOnWeb)

ubb.scope(SessionScoped.class);

else

ubb.scope(ApplicationScoped.class);


abd.addBean(ubb.create());

}
DELTASPIKE MODULES
CONTAINER CONTROL
public class MainApp {

public static void main(String[] args) {



CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();

cdiContainer.boot();



// Starting the application-context enables use of @ApplicationScoped beans

ContextControl contextControl = cdiContainer.getContextControl();

contextControl.startContext(ApplicationScoped.class);



// You can use CDI here



cdiContainer.shutdown();

}

}
TEST CONTROL EXAMPLES
@RunWith(CdiTestRunner.class)

public class MyCdiTest {

@Inject

private MyBean bean;

}

…

@RunWith(CdiTestSuiteRunner.class)

@Suite.SuiteClasses({ TestX.class, TestY.class})

public class SuiteLevelContainerControl{}

…

@RunWith(CdiTestRunner.class)

@TestControl(projectStage = CustomTestStage.class)

public class TestStageControl {

@Test

@TestControl(projectStage = ProjectStage.Development.class)

public void checkDevEnv(){}

}
SECURITY
@Retention(value = RetentionPolicy.RUNTIME)

@Target({ ElementType.TYPE, ElementType.METHOD })

@Documented

@SecurityBindingType

public @interface AdminOnly {}
…
@ApplicationScoped

public class ApplicationAuthorizer {

@Secures

@AdminOnly // Binding security to permission verifier

public boolean verifyPermission(InvocationContext invocationContext,

BeanManager manager, @Logged User user) throws Exception {

return user.getRole().equalsIgnoreCase("Admin");

}

}
…
@AdminOnly

public void startAdministrativeTask() {

// Only admins can start admin tasks

}
SCHEDULER
@Scheduled(cronExpression = "0 0/10 * * * ?")

public class CdiAwareQuartzJob implements org.quartz.Job

{

@Inject

private MyService service;



@Override

public void execute(JobExecutionContext context) throws JobExecutionException

{

//...

}

}
DATA MODULE
DATA MODULE
• Data module is an implementation of the repository pattern
• At the moment it only support RDBMS thru JPA
• But it could be extended to support other data services
• It uses the “partial bean” module to dynamically create
implementation at runtime
-Eric Evans (in Domain Driven Design)
« A Repository represents all objects of a certain
type as a conceptual set. It acts like a collection,
except with more elaborate querying capability.»
REPOSITORY PATTERN DEFINITION
SIMPLE EXAMPLE
@Repository //Repo definition to put an interface

public interface UserRepository extends EntityRepository<User, Long> {



// method signature creates the JPQL with the partial bean mechanism

public User findByUsernameAndPassword(String username, char[] password);



}

…

@Repository

public interface PostRepostiory extends EntityRepository<Post, Long> {





@Query("SELECT p FROM Post AS p WHERE p.author in (?1)")

public List<Post> findByFollowing(List<User> following);



}
JPA FUNCTIONS SUPPORTED
• count();
• findAll();
• findBy(PK);
• flush();
• refresh();
• remove();
• save();
• saveAndFlush();
CONCLUSION
• More info & doc on http://deltaspike.apache.org
• Follow @Deltaspiketeam onTwitter
• Visit examples: https://deltaspike.apache.org/external.html
• & http://jboss.org/developer-materials/#!keyword=Deltaspike
• Questions ?

More Related Content

What's hot

Lambda layerをDeployする方法を調べる
Lambda layerをDeployする方法を調べるLambda layerをDeployする方法を調べる
Lambda layerをDeployする方法を調べる
shotaueda3
 
構成管理のアンチパターン
構成管理のアンチパターン構成管理のアンチパターン
構成管理のアンチパターン
akipii Oga
 
忙しい人のための Rocky Linux 入門〜Rocky LinuxはCentOSの後継者たり得るか?〜
忙しい人のための Rocky Linux 入門〜Rocky LinuxはCentOSの後継者たり得るか?〜忙しい人のための Rocky Linux 入門〜Rocky LinuxはCentOSの後継者たり得るか?〜
忙しい人のための Rocky Linux 入門〜Rocky LinuxはCentOSの後継者たり得るか?〜
Masahito Zembutsu
 
Containers + EC2 Spot: AWS Batch による大規模バッチ処理でのスポットインスタンス活用
Containers + EC2 Spot: AWS Batch による大規模バッチ処理でのスポットインスタンス活用Containers + EC2 Spot: AWS Batch による大規模バッチ処理でのスポットインスタンス活用
Containers + EC2 Spot: AWS Batch による大規模バッチ処理でのスポットインスタンス活用
Daisuke Miyamoto
 
The 7 Deadly Sins of Packet Processing - Venky Venkatesan and Bruce Richardson
The 7 Deadly Sins of Packet Processing - Venky Venkatesan and Bruce RichardsonThe 7 Deadly Sins of Packet Processing - Venky Venkatesan and Bruce Richardson
The 7 Deadly Sins of Packet Processing - Venky Venkatesan and Bruce Richardson
harryvanhaaren
 
ONNX and Edge Deployments
ONNX and Edge DeploymentsONNX and Edge Deployments
ONNX and Edge Deployments
Apache MXNet
 
週末趣味のAWS Transit Gatewayでの経路制御
週末趣味のAWS Transit Gatewayでの経路制御週末趣味のAWS Transit Gatewayでの経路制御
週末趣味のAWS Transit Gatewayでの経路制御
Namba Kazuo
 
MTのスケールアップパターン with AWS
MTのスケールアップパターン with AWSMTのスケールアップパターン with AWS
MTのスケールアップパターン with AWS
Yasuhiro Araki, Ph.D
 
Visibility With Veeam One
Visibility With Veeam OneVisibility With Veeam One
Visibility With Veeam One
Lai Yoong Seng
 
Microsoft Hyper-V
Microsoft Hyper-VMicrosoft Hyper-V
Microsoft Hyper-V
Davoud Teimouri
 
Trace memory leak with gdb (GDB로 메모리 누수 찾기)
Trace memory  leak with gdb (GDB로 메모리 누수 찾기)Trace memory  leak with gdb (GDB로 메모리 누수 찾기)
Trace memory leak with gdb (GDB로 메모리 누수 찾기)
Jun Hong Kim
 
AWS Transfer Family SFTP and FTPS
AWS Transfer Family SFTP and FTPSAWS Transfer Family SFTP and FTPS
AWS Transfer Family SFTP and FTPS
Kameda Harunobu
 
AWS Black Belt Online Seminar 2017 Amazon Aurora
AWS Black Belt Online Seminar 2017 Amazon AuroraAWS Black Belt Online Seminar 2017 Amazon Aurora
AWS Black Belt Online Seminar 2017 Amazon Aurora
Amazon Web Services Japan
 
CRC-32
CRC-32CRC-32
CRC-32
7shi
 
KVM tools and enterprise usage
KVM tools and enterprise usageKVM tools and enterprise usage
KVM tools and enterprise usage
vincentvdk
 
What CloudStackers Need To Know About LINSTOR/DRBD
What CloudStackers Need To Know About LINSTOR/DRBDWhat CloudStackers Need To Know About LINSTOR/DRBD
What CloudStackers Need To Know About LINSTOR/DRBD
ShapeBlue
 
AWS Black Belt Online Seminar 2018 AWS上の位置情報
AWS Black Belt Online Seminar 2018 AWS上の位置情報AWS Black Belt Online Seminar 2018 AWS上の位置情報
AWS Black Belt Online Seminar 2018 AWS上の位置情報
Amazon Web Services Japan
 
モヤLT_1945年7月~1945年8月:阿南惟幾と終戦の決断
モヤLT_1945年7月~1945年8月:阿南惟幾と終戦の決断モヤLT_1945年7月~1945年8月:阿南惟幾と終戦の決断
モヤLT_1945年7月~1945年8月:阿南惟幾と終戦の決断
Norihiko Matsumoto
 
Serverless Anti-Patterns
Serverless Anti-PatternsServerless Anti-Patterns
Serverless Anti-Patterns
Keisuke Nishitani
 

What's hot (20)

Lambda layerをDeployする方法を調べる
Lambda layerをDeployする方法を調べるLambda layerをDeployする方法を調べる
Lambda layerをDeployする方法を調べる
 
構成管理のアンチパターン
構成管理のアンチパターン構成管理のアンチパターン
構成管理のアンチパターン
 
忙しい人のための Rocky Linux 入門〜Rocky LinuxはCentOSの後継者たり得るか?〜
忙しい人のための Rocky Linux 入門〜Rocky LinuxはCentOSの後継者たり得るか?〜忙しい人のための Rocky Linux 入門〜Rocky LinuxはCentOSの後継者たり得るか?〜
忙しい人のための Rocky Linux 入門〜Rocky LinuxはCentOSの後継者たり得るか?〜
 
Containers + EC2 Spot: AWS Batch による大規模バッチ処理でのスポットインスタンス活用
Containers + EC2 Spot: AWS Batch による大規模バッチ処理でのスポットインスタンス活用Containers + EC2 Spot: AWS Batch による大規模バッチ処理でのスポットインスタンス活用
Containers + EC2 Spot: AWS Batch による大規模バッチ処理でのスポットインスタンス活用
 
The 7 Deadly Sins of Packet Processing - Venky Venkatesan and Bruce Richardson
The 7 Deadly Sins of Packet Processing - Venky Venkatesan and Bruce RichardsonThe 7 Deadly Sins of Packet Processing - Venky Venkatesan and Bruce Richardson
The 7 Deadly Sins of Packet Processing - Venky Venkatesan and Bruce Richardson
 
ONNX and Edge Deployments
ONNX and Edge DeploymentsONNX and Edge Deployments
ONNX and Edge Deployments
 
週末趣味のAWS Transit Gatewayでの経路制御
週末趣味のAWS Transit Gatewayでの経路制御週末趣味のAWS Transit Gatewayでの経路制御
週末趣味のAWS Transit Gatewayでの経路制御
 
MTのスケールアップパターン with AWS
MTのスケールアップパターン with AWSMTのスケールアップパターン with AWS
MTのスケールアップパターン with AWS
 
Visibility With Veeam One
Visibility With Veeam OneVisibility With Veeam One
Visibility With Veeam One
 
Microsoft Hyper-V
Microsoft Hyper-VMicrosoft Hyper-V
Microsoft Hyper-V
 
Governance for Community Interest Companies
Governance for Community Interest CompaniesGovernance for Community Interest Companies
Governance for Community Interest Companies
 
Trace memory leak with gdb (GDB로 메모리 누수 찾기)
Trace memory  leak with gdb (GDB로 메모리 누수 찾기)Trace memory  leak with gdb (GDB로 메모리 누수 찾기)
Trace memory leak with gdb (GDB로 메모리 누수 찾기)
 
AWS Transfer Family SFTP and FTPS
AWS Transfer Family SFTP and FTPSAWS Transfer Family SFTP and FTPS
AWS Transfer Family SFTP and FTPS
 
AWS Black Belt Online Seminar 2017 Amazon Aurora
AWS Black Belt Online Seminar 2017 Amazon AuroraAWS Black Belt Online Seminar 2017 Amazon Aurora
AWS Black Belt Online Seminar 2017 Amazon Aurora
 
CRC-32
CRC-32CRC-32
CRC-32
 
KVM tools and enterprise usage
KVM tools and enterprise usageKVM tools and enterprise usage
KVM tools and enterprise usage
 
What CloudStackers Need To Know About LINSTOR/DRBD
What CloudStackers Need To Know About LINSTOR/DRBDWhat CloudStackers Need To Know About LINSTOR/DRBD
What CloudStackers Need To Know About LINSTOR/DRBD
 
AWS Black Belt Online Seminar 2018 AWS上の位置情報
AWS Black Belt Online Seminar 2018 AWS上の位置情報AWS Black Belt Online Seminar 2018 AWS上の位置情報
AWS Black Belt Online Seminar 2018 AWS上の位置情報
 
モヤLT_1945年7月~1945年8月:阿南惟幾と終戦の決断
モヤLT_1945年7月~1945年8月:阿南惟幾と終戦の決断モヤLT_1945年7月~1945年8月:阿南惟幾と終戦の決断
モヤLT_1945年7月~1945年8月:阿南惟幾と終戦の決断
 
Serverless Anti-Patterns
Serverless Anti-PatternsServerless Anti-Patterns
Serverless Anti-Patterns
 

Viewers also liked

Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpikeos890
 
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpikeMyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
os890
 
CDI 2.0 is coming
CDI 2.0 is comingCDI 2.0 is coming
CDI 2.0 is coming
Antoine Sabot-Durand
 
Apache Deltaspike the CDI Toolbox (Java One 2015)
Apache Deltaspike the CDI Toolbox (Java One 2015)Apache Deltaspike the CDI Toolbox (Java One 2015)
Apache Deltaspike the CDI Toolbox (Java One 2015)
Antoine Sabot-Durand
 
Invoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamicInvoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamic
Antoine Sabot-Durand
 
The path to cdi 2.0
The path to cdi 2.0The path to cdi 2.0
The path to cdi 2.0
Antoine Sabot-Durand
 
Advanced CDI in live coding
Advanced CDI in live codingAdvanced CDI in live coding
Advanced CDI in live coding
Antoine Sabot-Durand
 
CDI 2.0 is coming
CDI 2.0 is comingCDI 2.0 is coming
CDI 2.0 is coming
Antoine Sabot-Durand
 
Going further with CDI 1.2
Going further with CDI 1.2Going further with CDI 1.2
Going further with CDI 1.2
Antoine Sabot-Durand
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Antoine Sabot-Durand
 
Mute Java EE DNA with CDI
Mute Java EE DNA with CDI Mute Java EE DNA with CDI
Mute Java EE DNA with CDI
Antoine Sabot-Durand
 
Extending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss ForgeExtending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss Forge
Antoine Sabot-Durand
 
CDI 1.1 university
CDI 1.1 universityCDI 1.1 university
CDI 1.1 university
Antoine Sabot-Durand
 
Adopt a JSR: CDI 2.0 at Devoxx UK
Adopt a JSR: CDI 2.0 at Devoxx UKAdopt a JSR: CDI 2.0 at Devoxx UK
Adopt a JSR: CDI 2.0 at Devoxx UK
Antoine Sabot-Durand
 
CDI 2.0 is upon us Devoxx
CDI 2.0 is upon us DevoxxCDI 2.0 is upon us Devoxx
CDI 2.0 is upon us Devoxx
Antoine Sabot-Durand
 
Java EE, un ami qui vous veut du bien
Java EE, un ami qui vous veut du bienJava EE, un ami qui vous veut du bien
Java EE, un ami qui vous veut du bien
Antoine Sabot-Durand
 
Apache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI ToolboxApache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI Toolbox
Virtual JBoss User Group
 
CDI In Real Life
CDI In Real LifeCDI In Real Life
CDI In Real Life
Antoine Sabot-Durand
 
The Magnificent java EE 7 in Wildfly-O-Rama
The Magnificent java EE 7 in Wildfly-O-RamaThe Magnificent java EE 7 in Wildfly-O-Rama
The Magnificent java EE 7 in Wildfly-O-Rama
Antoine Sabot-Durand
 
Devoxx Java Social and Agorava
Devoxx Java Social and AgoravaDevoxx Java Social and Agorava
Devoxx Java Social and Agorava
Antoine Sabot-Durand
 

Viewers also liked (20)

Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpike
 
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpikeMyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
 
CDI 2.0 is coming
CDI 2.0 is comingCDI 2.0 is coming
CDI 2.0 is coming
 
Apache Deltaspike the CDI Toolbox (Java One 2015)
Apache Deltaspike the CDI Toolbox (Java One 2015)Apache Deltaspike the CDI Toolbox (Java One 2015)
Apache Deltaspike the CDI Toolbox (Java One 2015)
 
Invoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamicInvoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamic
 
The path to cdi 2.0
The path to cdi 2.0The path to cdi 2.0
The path to cdi 2.0
 
Advanced CDI in live coding
Advanced CDI in live codingAdvanced CDI in live coding
Advanced CDI in live coding
 
CDI 2.0 is coming
CDI 2.0 is comingCDI 2.0 is coming
CDI 2.0 is coming
 
Going further with CDI 1.2
Going further with CDI 1.2Going further with CDI 1.2
Going further with CDI 1.2
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
 
Mute Java EE DNA with CDI
Mute Java EE DNA with CDI Mute Java EE DNA with CDI
Mute Java EE DNA with CDI
 
Extending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss ForgeExtending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss Forge
 
CDI 1.1 university
CDI 1.1 universityCDI 1.1 university
CDI 1.1 university
 
Adopt a JSR: CDI 2.0 at Devoxx UK
Adopt a JSR: CDI 2.0 at Devoxx UKAdopt a JSR: CDI 2.0 at Devoxx UK
Adopt a JSR: CDI 2.0 at Devoxx UK
 
CDI 2.0 is upon us Devoxx
CDI 2.0 is upon us DevoxxCDI 2.0 is upon us Devoxx
CDI 2.0 is upon us Devoxx
 
Java EE, un ami qui vous veut du bien
Java EE, un ami qui vous veut du bienJava EE, un ami qui vous veut du bien
Java EE, un ami qui vous veut du bien
 
Apache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI ToolboxApache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI Toolbox
 
CDI In Real Life
CDI In Real LifeCDI In Real Life
CDI In Real Life
 
The Magnificent java EE 7 in Wildfly-O-Rama
The Magnificent java EE 7 in Wildfly-O-RamaThe Magnificent java EE 7 in Wildfly-O-Rama
The Magnificent java EE 7 in Wildfly-O-Rama
 
Devoxx Java Social and Agorava
Devoxx Java Social and AgoravaDevoxx Java Social and Agorava
Devoxx Java Social and Agorava
 

Similar to Apache DeltaSpike the CDI toolbox

Make JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODIMake JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODI
os890
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
Mert Çalışkan
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
Mert Çalışkan
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
Fabio Fumarola
 
SSDT unleashed
SSDT unleashedSSDT unleashed
SSDT unleashed
GomathiNayagam S
 
Gradle plugin, take control of the build
Gradle plugin, take control of the buildGradle plugin, take control of the build
Gradle plugin, take control of the build
Eyal Lezmy
 
Database continuous integration, unit test and functional test
Database continuous integration, unit test and functional testDatabase continuous integration, unit test and functional test
Database continuous integration, unit test and functional test
Harry Zheng
 
A (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project FilesA (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project Files
David Wengier
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Drupalcon Paris
 
Dao example
Dao exampleDao example
Dao example
myrajendra
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvm
Anton Shapin
 
How to help your editor love your vue component library
How to help your editor love your vue component libraryHow to help your editor love your vue component library
How to help your editor love your vue component library
Piotr Tomiak
 
Gradle - From minutes to seconds: minimizing build times
Gradle - From minutes to seconds: minimizing build timesGradle - From minutes to seconds: minimizing build times
Gradle - From minutes to seconds: minimizing build times
Rene Gröschke
 
Liquibase – a time machine for your data
Liquibase – a time machine for your dataLiquibase – a time machine for your data
Liquibase – a time machine for your data
Neev Technologies
 
2/3 : CDI advanced - Antoine Sabot-Durand
2/3 : CDI advanced - Antoine Sabot-Durand2/3 : CDI advanced - Antoine Sabot-Durand
2/3 : CDI advanced - Antoine Sabot-Durand
SOAT
 
How (and why) to roll your own Docker SaaS
How (and why) to roll your own Docker SaaSHow (and why) to roll your own Docker SaaS
How (and why) to roll your own Docker SaaS
Ryan Crawford
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
Ortus Solutions, Corp
 
Gradle,the new build system for android
Gradle,the new build system for androidGradle,the new build system for android
Gradle,the new build system for android
zhang ghui
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
Kalkey
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
Derek Jacoby
 

Similar to Apache DeltaSpike the CDI toolbox (20)

Make JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODIMake JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODI
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
SSDT unleashed
SSDT unleashedSSDT unleashed
SSDT unleashed
 
Gradle plugin, take control of the build
Gradle plugin, take control of the buildGradle plugin, take control of the build
Gradle plugin, take control of the build
 
Database continuous integration, unit test and functional test
Database continuous integration, unit test and functional testDatabase continuous integration, unit test and functional test
Database continuous integration, unit test and functional test
 
A (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project FilesA (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project Files
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3
 
Dao example
Dao exampleDao example
Dao example
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvm
 
How to help your editor love your vue component library
How to help your editor love your vue component libraryHow to help your editor love your vue component library
How to help your editor love your vue component library
 
Gradle - From minutes to seconds: minimizing build times
Gradle - From minutes to seconds: minimizing build timesGradle - From minutes to seconds: minimizing build times
Gradle - From minutes to seconds: minimizing build times
 
Liquibase – a time machine for your data
Liquibase – a time machine for your dataLiquibase – a time machine for your data
Liquibase – a time machine for your data
 
2/3 : CDI advanced - Antoine Sabot-Durand
2/3 : CDI advanced - Antoine Sabot-Durand2/3 : CDI advanced - Antoine Sabot-Durand
2/3 : CDI advanced - Antoine Sabot-Durand
 
How (and why) to roll your own Docker SaaS
How (and why) to roll your own Docker SaaSHow (and why) to roll your own Docker SaaS
How (and why) to roll your own Docker SaaS
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
 
Gradle,the new build system for android
Gradle,the new build system for androidGradle,the new build system for android
Gradle,the new build system for android
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
 

Recently uploaded

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 

Recently uploaded (20)

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 

Apache DeltaSpike the CDI toolbox

  • 2. ANTOINE SABOT-DURAND • Senior Software Engineer @Red Hat • Java & OSS : • CDI co-spec lead • CDI community development • Apache Deltaspike committer • @antoine_sd
  • 3. AGENDA • What is Apache Deltaspike? • Deltaspike Core • Deltaspike Modules • Conclusion
  • 4. WHAT IS APACHE DELTASPIKE
  • 5. CDI & DELTASPIKE • CDI is a specification. It doesn’t provide business features • but it includes a powerful hook to add these business features • The “portable extensions” feature is this hook • Thanks to it, CDI can be easily enhanced with new high level features
  • 6. APACHE DELTASPIKE IS… • A collection of ready to use extensions to help you in your projects • A toolbox to help you develop new CDI portable extensions • A great way to learn how to develop your own extension by browsing the source code • The most obvious entry point to CDI eco-system
  • 7. WHERE DOES IT COMES FROM? Font: Avenir Light Font-size: 64pt Letter-spacing: 410 RGB: 51,181 229 HEX: #35b4e3 C=66.45 M=8.61 Y=1.97 K=0 Miscellaneous CDI Initiatives
  • 8. TESTED WITH • CDI 1.0, 1.1, 1.2 • JBoss Weld 1.1.3 to 2.2.8 • OpenWebBeans 1.1.1 to 1.2.7 • JBoss AS 7.x,WildFly 8.x • JBoss EAP 6.x • TomEE 1.0.x - 1.7.x • GlassFish 3.x, 4.x • Weblogic 12c
  • 9. A BIT OF HISTORY Dec 2011 Feb 2012 May 2013 June 2014 ProjectLaunch rel.0.1 rel.0.4(outofincubator) rel.1.0 Dec 2014 rel.1.2.1
  • 10. WHAT’S INCLUDED? Apache Deltaspike is organized in the following modules Container control provides a portable way to boot CDI container Core Module core features and helpers. Used by all other modules below Partial Bean Module develop generic handler to choose code dynamically at runtime Scheduler Module add job scheduling with Quartz or any other scheduler Security Module add security checking. Integration of 3rd party security framework BeanValidation Module CDI integration for BeanValidation 1.0 JPA Module Enhance JPA integration for CDI 1.0. Mostly useless in Java EE 7 Data Module Implements repository pattern removing JPA boilerplate code Servlet Module Enhance Servlet integration for CDI 1.0. Mostly useless in Java EE 7 JSF Module Enhance JSF by adding CDI scopes, typesafe view config, etc… Test control provide a test solution for CDI based on Junit
  • 11. MODULES AND DEPENDENCIES Partial Bean Core Bean Validation JPAData Security JSF Scheduler Servlet Test CTRL Containers CTRL
  • 14. CONFIGURATION 1/2 • DeltaSpike provides a powerful configuration API / SPI • It doesn’t depend on CDI, thus it can be used in portable extension • The entry point is the ConfigResolver class • ConfigSource SPI allows to add new configuration source • Each config has a priority (ordinal).This highest is picked first
  • 15. CONFIGURATION 2/2 Out of the Box Config Sources ConfigSource Priority Notes System properties 400 Environment properties 300 JNDI values 200 java:comp/env/deltaspike Properties files value 100 META-INF/apache-deltaspike.properties
  • 16. CONFIGURATION USAGE //ConfigResolver can be used directly without CDI dependency (useful in extensions)
 String dbUserName = ConfigResolver.getPropertyValue("databaseconfig.username"); … //Config can also be used in CDI mode and typeSafe config
 @Inject
 @ConfigProperty(name = "endpoint.poll.interval")
 private Integer p; // DS provides conversion for String, Integer, Long, Boolean, Float … //But you can provide your own ConfigProperty producer to perform custom conversion
 @ApplicationScoped
 public class MyConfigPropertyProducer extends BaseConfigPropertyProducer {
 @Produces @ConfigProperty(name = "ignored")
 public MyType produceStringConfiguration(InjectionPoint injectionPoint) { String strValue = getStringPropertyValue(injectionPoint); … }
 }
  • 17. PROJECT STAGES • Allows to use implementations depending on current environment • You can defined your owned stage or used the provided ones • Pre-defined project stages: • UnitTest, Development, SystemTest, IntegrationTest, Staging, Production • Project Stage is configured thru DS configuration mechanism
  • 18. PROJECT STAGE EXAMPLE //Setting project stage with environment property -Dorg.apache.deltaspike.ProjectStage=Development … //Using project stage
 @Inject
 private ProjectStage projectStage;
 boolean isDevProjectStage = ProjectStage.Development.equals(this.projectStage);
  • 19. BEAN EXCLUSION WITH @EXCLUDE @Exclude //like CDI 1.1+ @Vetoed but limited to a class @Exclude(ifProjectStage=Production.class) //based on project stage 
 @Exclude(exceptIfProjectStage=UnitTest.class) //based on project stage 
 @Exclude(onExpression="myProperty==myValue") //based on config value 
 @Exclude(onExpression="[cust exp]", interpretedBy=CustomExpInterpreter.class) //custom
  • 20. EXCEPTION HANDLERS • Based on CDI event • ExceptionToCatchEvent class sends the exception to DS • @ExceptionHandler marks a class as handlers container • @Handles and ExceptionEvent<T> handle an exception
  • 21. EXCEPTION HANDLER EXAMPLE public class InventoryActions {
 @PersistenceContext
 private EntityManager em;
 @Inject
 private Event<ExceptionToCatchEvent> catchEvent;
 
 public Integer queryForItem(Item i) {
 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));
 }
 }
 } … @ExceptionHandler
 public class MyHandler {
 void handleTheException(@Handles ExceptionEvent<Throwable> exEvent) {
 // Do anything with the exception
 exEvent.handleAndContinue();
 }
 }
  • 22. INJECTABLE RESOURCE @Inject
 @InjectableResource(location = "/version.txt")
 private InputStream is; //Can be customised for alternate sources
 
 public String getVersion() throws IOException {
 try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
 return br.readLine();
 }
 }
  • 23. INTERNATIONALISATION (I18N) package org.apache.deltaspike.example
 
 @MessageBundle // Can only be applied on an interface
 public interface SimpleMessage // Will map the org/apache/deltaspike/example/SimpleMessage bundle
 {
 @MessageTemplate(“{my_message}”) // Will map my_message key in bundle
 String welcomeToDeltaSpike(); // For value with parameter i.e welcome_to = Welcome to %s 
 @MessageTemplate("{welcome_to}")
 String welcomeTo(String name); 
 }
  • 24. CDI METADATA BUILDERS • Creating CDI SPI metadata for you extension can be cumbersome • Deltaspike provides builder to ease the work and reduce code verbosity • Major builder are • AnnotatedTypeBuilder • BeanBuilder • WrapperBeanBuilder
  • 25. BUILDING META DATA EXAMPLES void addTimedBinding(@Observes BeforeBeanDiscovery bbd) {
 AnnotationLiteral<Nonbinding> nonbindingLiteral = new AnnotationLiteral<Nonbinding>(){};
 AnnotatedTypeBuilder<Timed> atb = new AnnotatedTypeBuilder<Timed>()
 .readFromType(Timed.class)
 .addToMethod(Timed.class.getMethod("name"), nonbindingLiteral)
 .addToMethod(Timed.class.getMethod(“absolute"),nonbindingLiteral);
 bbd.addInterceptorBinding(atb.create());
 } … public void registerGenericBeans(@Observes AfterBeanDiscovery abd) {
 BeanBuilder<User> ubb = new BeanBuilder<User>(beanManager)
 .readFromType(User.class)
 .passivationCapable(true)
 .addTypes(otherTypes);
 if (weAreOnWeb)
 ubb.scope(SessionScoped.class);
 else
 ubb.scope(ApplicationScoped.class); 
 abd.addBean(ubb.create());
 }
  • 27. CONTAINER CONTROL public class MainApp {
 public static void main(String[] args) {
 
 CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
 cdiContainer.boot();
 
 // Starting the application-context enables use of @ApplicationScoped beans
 ContextControl contextControl = cdiContainer.getContextControl();
 contextControl.startContext(ApplicationScoped.class);
 
 // You can use CDI here
 
 cdiContainer.shutdown();
 }
 }
  • 28. TEST CONTROL EXAMPLES @RunWith(CdiTestRunner.class)
 public class MyCdiTest {
 @Inject
 private MyBean bean;
 }
 …
 @RunWith(CdiTestSuiteRunner.class)
 @Suite.SuiteClasses({ TestX.class, TestY.class})
 public class SuiteLevelContainerControl{}
 …
 @RunWith(CdiTestRunner.class)
 @TestControl(projectStage = CustomTestStage.class)
 public class TestStageControl {
 @Test
 @TestControl(projectStage = ProjectStage.Development.class)
 public void checkDevEnv(){}
 }
  • 29. SECURITY @Retention(value = RetentionPolicy.RUNTIME)
 @Target({ ElementType.TYPE, ElementType.METHOD })
 @Documented
 @SecurityBindingType
 public @interface AdminOnly {} … @ApplicationScoped
 public class ApplicationAuthorizer {
 @Secures
 @AdminOnly // Binding security to permission verifier
 public boolean verifyPermission(InvocationContext invocationContext,
 BeanManager manager, @Logged User user) throws Exception {
 return user.getRole().equalsIgnoreCase("Admin");
 }
 } … @AdminOnly
 public void startAdministrativeTask() {
 // Only admins can start admin tasks
 }
  • 30. SCHEDULER @Scheduled(cronExpression = "0 0/10 * * * ?")
 public class CdiAwareQuartzJob implements org.quartz.Job
 {
 @Inject
 private MyService service;
 
 @Override
 public void execute(JobExecutionContext context) throws JobExecutionException
 {
 //...
 }
 }
  • 32. DATA MODULE • Data module is an implementation of the repository pattern • At the moment it only support RDBMS thru JPA • But it could be extended to support other data services • It uses the “partial bean” module to dynamically create implementation at runtime
  • 33. -Eric Evans (in Domain Driven Design) « A Repository represents all objects of a certain type as a conceptual set. It acts like a collection, except with more elaborate querying capability.» REPOSITORY PATTERN DEFINITION
  • 34. SIMPLE EXAMPLE @Repository //Repo definition to put an interface
 public interface UserRepository extends EntityRepository<User, Long> {
 
 // method signature creates the JPQL with the partial bean mechanism
 public User findByUsernameAndPassword(String username, char[] password);
 
 }
 …
 @Repository
 public interface PostRepostiory extends EntityRepository<Post, Long> {
 
 
 @Query("SELECT p FROM Post AS p WHERE p.author in (?1)")
 public List<Post> findByFollowing(List<User> following);
 
 }
  • 35. JPA FUNCTIONS SUPPORTED • count(); • findAll(); • findBy(PK); • flush(); • refresh(); • remove(); • save(); • saveAndFlush();
  • 36. CONCLUSION • More info & doc on http://deltaspike.apache.org • Follow @Deltaspiketeam onTwitter • Visit examples: https://deltaspike.apache.org/external.html • & http://jboss.org/developer-materials/#!keyword=Deltaspike • Questions ?