SlideShare une entreprise Scribd logo
1  sur  57
Télécharger pour lire hors ligne
OPENSHIFT
Workshop
PRESENTED
BY
Shekhar
Gulati
Developing Modern Java Web
Applications with Java EE 7 and
AngularJS
WHO AM I?
•  Shekhar	
  Gula+	
  -­‐-­‐	
  OpenShi1	
  Developer	
  Evangelist	
  
	
  
•  Java	
  /	
  JavaScript	
  /	
  Python	
  /	
  NoSQL	
  /	
  Cloud	
  Guy	
  
	
  
•  TwiEer	
  Handle	
  :	
  shekhargula*	
  
	
  
•  Github	
  :	
  h,ps://github.com/shekhargula*	
  
•  Author	
  of	
  30	
  technologies	
  in	
  30	
  days	
  blog	
  series	
  
h,ps://www.openshi9.com/blogs/learning-­‐30-­‐
technologies-­‐in-­‐30-­‐days-­‐a-­‐developer-­‐challenge	
  
l  Define	
  Modern	
  Web	
  Applica+on	
  
l  Introduce	
  Java	
  EE	
  7	
  
l  GeRng	
  Started	
  with	
  Java	
  EE	
  7	
  
l  OpenShi1	
  for	
  Java(EE)	
  Developers	
  
l  Write	
  HackerPins	
  Applica+on	
  REST	
  Backend	
  
l  Look	
  at	
  AngularJS	
  
l  Write	
  HackerPins	
  AngularJS	
  Frontend	
  
l  Deploy	
  to	
  OpenShi1	
  
AGENDA
http://www.hackerpins.com/
CODE DU JOUR
https://github.com/shekhargulati/hackerpins-
drdobbsindia-conference
Modern	
  Web	
  Applica*on	
  
 What	
  make’s	
  a	
  modern	
  web	
  applica*on?	
  
•  Exposes	
  REST	
  JSON	
  web	
  services	
  
•  Single	
  backend	
  and	
  mul+ple	
  front	
  ends	
  
•  Embraces	
  HTML	
  5	
  	
  
•  GeoLoca+on,	
  Local	
  Storage,	
  Web	
  Sockets	
  
•  Single	
  page	
  web	
  applica+on	
  
•  Uses	
  MV*	
  JavaScript	
  framework	
  
•  Stateless	
  so	
  that	
  you	
  can	
  scale	
  horizontally	
  
•  Uses	
  OAuth	
  
•  Integrates	
  with	
  social	
  pla`orms	
  like	
  TwiEer,	
  Facebook,	
  Google+	
  
•  Embraces	
  Polyglot	
  Persistence	
  
•  Cloud	
  aware	
  
CAN	
  WE	
  BUILD	
  MODERN	
  WEB	
  
APPLICATIONS	
  USING	
  JAVA	
  EE?	
  
Short	
  answer	
  is…	
  
	
  
Yes	
  
This	
  session	
  will	
  try	
  to	
  convince	
  you	
  to	
  use	
  Java	
  
EE	
  7	
  for	
  your	
  next	
  web	
  app.	
  
http://www.hackerpins.com/
Choose	
  Session	
  Delivery	
  Mode	
  
1.  Hands-­‐on	
  coding	
  –	
  No	
  slides	
  –	
  J	
  
2.  Slides	
  with	
  code	
  fragments	
  –	
  L	
  
Java	
  EE	
  *meline	
  
0	
  
10	
  
12	
  
18	
  
24	
  
30	
  
38	
  
JPE	
  (1998)	
   J2EE	
  1.2	
  
(1999)	
  
J2EE	
  
1.3(2001)	
  
J2EE	
  
1.4(2001)	
  
Java	
  EE	
  
5(2006)	
  
Java	
  EE	
  
6(2009)	
  
Java	
  EE	
  
7(2013)	
  
Java	
  EE	
  Timeline	
  
Java	
  EE	
  Timeline	
  
Java	
  EE	
  6	
  changed	
  the	
  game…	
  It	
  was	
  lightweight	
  
•  Introduc+on	
  of	
  web	
  profile	
  
•  EJBs	
  can	
  be	
  packed	
  in	
  WAR	
  files	
  
•  Servlet	
  3.0	
  
•  web.xml	
  became	
  op+onal,	
  @WebServlet,	
  @WebFilter	
  
•  Type	
  safe	
  contextual	
  dependency	
  injec+on(CDI)	
  
•  DI	
  for	
  Java	
  EE,	
  event	
  support	
  
•  @Asynchronous	
  and	
  @Schedule	
  support	
  
•  	
  RESTFul	
  web	
  services	
  support	
  with	
  JAX-­‐RS	
  1.1	
  
Java	
  EE	
  7	
  –	
  Produc*vity	
  and	
  HTML	
  5	
  Focused	
  
•  Builds	
  on	
  top	
  of	
  Java	
  EE	
  6	
  
•  Embraces	
  HTML	
  5	
  
•  4	
  new	
  specs	
  
•  3	
  major	
  spec	
  updates	
  
•  6	
  minor	
  spec	
  updates	
  
•  5	
  	
  micro	
  updates	
  
The	
  Java	
  EE	
  7	
  Pla]orm	
  
Java EE 7 Platform
CDI1.1
BEANVALIDATION1.1
INTERCEPTORS1.2
CONCURRENCY1.0
JPA 2.1
JTA 1.2 EJB 3.2 JMS 2.0
WEBSOCKET
1.0
SERVLET 3.1
JSP 2.3 EL 3.0 JSF 2.2
JCA 1.7
MAIL 1.5
BATCH 1.0
JSON-P 1.0
JAX-RS 2.0
New Major updates Minor/macro updates
Our	
  modern	
  Java	
  EE	
  7	
  stack	
  
Java EE 7 Platform
CDI1.1
BEANVALIDATION1.1
INTERCEPTORS1.2
CONCURRENCY1.0
JPA 2.1
JTA 1.2 EJB 3.2
WEBSOCKET
1.0
JSON-P 1.0
JAX-RS 2.0
LETS	
  LOOK	
  AT	
  FEW	
  JAVA	
  EE	
  7	
  SPECS	
  
CDI	
  1.1-­‐-­‐	
  Context	
  and	
  Dependency	
  Injec*on	
  
	
  •  Allows	
  you	
  to	
  use	
  dependency	
  injec+on	
  in	
  Java	
  EE	
  
environment	
  without	
  third	
  party	
  libraries.	
  
•  Don’t	
  call	
  us.	
  We	
  will	
  call	
  you.	
  
•  CDI	
  container	
  manages	
  the	
  life	
  cycle	
  of	
  components.	
  
•  CDI	
  brings	
  dependency	
  injec+on,	
  context	
  and	
  scopes,	
  
interceptors,	
  loose	
  coupling	
  and	
  strong	
  typing.	
  
•  Injected	
  bean	
  lifecycle	
  depends	
  on	
  the	
  target	
  bean.	
  
•  Turns	
  nearly	
  every	
  Java	
  class	
  into	
  CDI	
  bean	
  
•  It	
  is	
  not	
  a	
  non	
  sta+c	
  inner	
  class	
  
•  It	
  is	
  a	
  concrete	
  class	
  or	
  annotated	
  with	
  decorators	
  
•  Has	
  default	
  constructor	
  with	
  no	
  parameters	
  or	
  declares	
  a	
  constructor	
  with	
  @Inject	
  
Enable	
  CDI	
  –	
  beans.xml	
  
<?xml	
  version="1.0"	
  encoding="UTF-­‐8"?>	
  
<beans	
  
	
  	
  	
  	
  	
  	
  	
  	
  xmlns="hEp://xmlns.jcp.org/xml/ns/javaee"	
  
	
  	
  	
  	
  	
  	
  	
  	
  xmlns:xsi="hEp://www.w3.org/2001/XMLSchema-­‐instance"	
  
	
  	
  	
  	
  	
  	
  	
  	
  xsi:schemaLoca+on="hEp://xmlns.jcp.org/xml/ns/javaee	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  hEp://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"	
  
	
  	
  	
  	
  	
  	
  	
  	
  bean-­‐discovery-­‐mode="all">	
  
</beans>	
  
CDI	
  Example	
  
Simple CDI Bean Injecting a bean
	
  public	
  class	
  LowercaseBeau+fier	
  implements	
  
MessageBeau+fier	
  {	
  
	
  	
  	
  	
  @Override	
  
	
  	
  	
  	
  public	
  String	
  beau+fy(String	
  message)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  message	
  !=	
  null	
  ?	
  message.toLowerCase()	
  :	
  
null;	
  
	
  	
  	
  	
  }	
  
}	
  
	
  public	
  interface	
  MessageBeau+fier	
  {	
  
	
  	
  	
  	
  public	
  String	
  beau+fy(String	
  message);	
  
	
  }	
  
	
  
	
  @Applica+onScoped	
  
	
  public	
  class	
  StatusService	
  {	
  
	
  	
  	
  	
  @Inject	
  
	
  	
  	
  	
  private	
  MessageBeau+fier	
  messageBeau+fier;	
  
	
  	
  	
  	
  public	
  Status	
  postStatus(String	
  message)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  Status	
  status	
  =	
  new	
  
Status(messageBeau+fier.beau+fy(message));	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  status;	
  
	
  	
  	
  	
  }	
  
	
  }	
  
	
  
CDI	
  	
  -­‐-­‐	
  Two	
  implementa*ons	
  MessageBeau*fier	
  
public	
  class	
  UppercaseBeau+fier	
  
implements	
  MessageBeau+fier	
  {	
  
	
  	
  	
  	
  @Override	
  
	
  	
  	
  	
  public	
  String	
  beau+fy(String	
  message)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  message	
  !=	
  null	
  ?	
  
message.toUpperCase()	
  :	
  null;	
  
	
  	
  	
  	
  }	
  
}	
  
public	
  class	
  LowercaseBeau+fier	
  
implements	
  MessageBeau+fier	
  {	
  
	
  	
  	
  	
  @Override	
  
	
  	
  	
  	
  public	
  String	
  beau+fy(String	
  message)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  message	
  !=	
  null	
  ?	
  
message.toLowerCase()	
  :	
  null;	
  
	
  	
  	
  	
  }	
  
}	
  
Code will throw exception-- Ambiguous dependencies for type
MessageBeautifier
CDI	
  –	
  Use	
  @Qualifier	
  
@Qualifier	
  
@Reten+on(Reten+onPolicy.RUNTIME)	
  
@Target({ElementType.METHOD,	
  ElementType.TYPE,	
  ElementType.FIELD})	
  
public	
  @interface	
  Beau+fier	
  {	
  
	
  	
  	
  	
  Beau+fierType	
  type();	
  
}	
  
public	
  enum	
  Beau+fierType	
  {	
  
	
  	
  	
  	
  LOWERCASE,	
  UPPERCASE	
  
}	
  
	
  
	
  
CDI	
  -­‐-­‐	
  @Qualifier	
  usage	
  
	
  @Beau+fier(type	
  =	
  
Beau+fierType.LOWERCASE)	
  
	
  public	
  class	
  LowercaseBeau+fier	
  
implements	
  MessageBeau+fier	
  {	
  
	
  	
  	
  	
  @Override	
  
	
  	
  	
  	
  public	
  String	
  beau+fy(String	
  
message)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  message	
  !=	
  null	
  ?	
  
message.toLowerCase()	
  :	
  null;	
  
	
  	
  	
  	
  }	
  
}	
  
	
  @Beau+fier(type	
  =	
  
Beau+fierType.UPPERCASE)	
  
	
  public	
  class	
  UppercaseBeau+fier	
  
implements	
  MessageBeau+fier	
  {	
  
	
  
	
  	
  	
  	
  @Override	
  
	
  	
  	
  	
  public	
  String	
  beau+fy(String	
  
message)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  message	
  !=	
  null	
  ?	
  
message.toUpperCase()	
  :	
  null;	
  
	
  	
  	
  	
  }	
  
}	
  
CDI	
  –	
  Loose	
  Coupling	
  and	
  Sta*c	
  Typing	
  
@Applica+onScoped	
  
public	
  class	
  StatusService	
  {	
  
	
  	
  	
  	
  @Inject	
  
	
  	
  	
  	
  @Beau+fier(type	
  =	
  Beau+fierType.UPPERCASE)	
  
	
  	
  	
  	
  private	
  MessageBeau+fier	
  messageBeau+fier;	
  
	
  
	
  	
  	
  	
  public	
  Status	
  postStatus(String	
  message)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  Status	
  status	
  =	
  new	
  Status(messageBeau+fier.beau+fy(message));	
  
return	
  status;	
  
	
  	
  	
  	
  }	
  
}	
  
CDI	
  1.1:	
  What’s	
  new	
  in	
  Java	
  EE	
  7?	
  
•  Finer	
  scanning	
  control	
  in	
  beans.xml	
  
•  bean-­‐discovery-­‐mode	
  aEribute	
  –	
  all,	
  none,	
  annotated	
  
•  @Vetoed	
  annota+on	
  to	
  veto	
  processing	
  of	
  a	
  package	
  or	
  class.	
  
•  You	
  can	
  use	
  @Transac+onal	
  with	
  CDI	
  beans.	
  
•  You	
  can	
  get	
  away	
  from	
  EJBs.	
  
Bean	
  Valida*on	
  
•  Specifies	
  common	
  valida+on	
  concept	
  for	
  
JavaBeans.	
  
•  Allow	
  you	
  to	
  put	
  constraints	
  on	
  data	
  to	
  make	
  
sure	
  it	
  is	
  valid.	
  
•  Annota+on	
  based	
  constraints	
  
•  Use	
  constraint	
  in	
  any	
  layer	
  
Bean	
  Valida*on	
  Example	
  
public	
  class	
  Status{	
  
	
  	
  	
  	
  @NotNull	
  	
  	
  @Size(max	
  =	
  140)	
  
	
  	
  	
  	
  private	
  String	
  message;	
  
	
  	
  	
  	
  @NotNull	
  @Past	
  
	
  	
  	
  	
  private	
  final	
  Date	
  postedAt;	
  
	
  	
  	
  	
  @UniqueUrl	
  
	
  	
  	
  	
  private	
  String	
  url;	
  
	
  	
  	
  	
  public	
  Status()	
  {}	
  
}	
  
Bean	
  Valida*on	
  1.1	
  –	
  	
  What’s	
  new	
  in	
  Java	
  EE	
  7?	
  
•  You	
  can	
  validate	
  method	
  parameters	
  and	
  return	
  types.	
  
•  Integra+on	
  with	
  JAX-­‐RS	
  
	
  
@Path(“/statuses”)
public class StatusService {
@POST @Produces(“application/json”)
public @NotNull Status postStatus(@Valid @NotNull Status status) {
// persist in database
return status;
}
}
Interceptors	
  
•  Allows	
  you	
  to	
  add	
  cross	
  cuRng	
  concerns	
  to	
  
your	
  beans.	
  
•  Lightweight	
  AOP	
  
•  You	
  can	
  use	
  them	
  to	
  intercept	
  method	
  calls,	
  
constructor	
  invoca+on,	
  Method	
  +meouts.	
  
Interceptors	
  in	
  ac*on	
  
	
  @Interceptor	
  
	
  @Loggable	
  
	
  public	
  class	
  LoggingInterceptor	
  {	
  
	
  	
  	
  	
  @Inject	
  
	
  	
  	
  	
  private	
  Logger	
  logger;	
  
	
  	
  	
  	
  @AroundInvoke	
  
	
  	
  	
  	
  public	
  Object	
  logMethodCall(Invoca+onContext	
  invoca+onContext)	
  
throws	
  Excep+on	
  {	
  
	
  logger.trace(String.format("Entering	
  method	
  %s",	
  
invoca+onContext.getMethod().getName());	
  
	
  try{	
  
	
  return	
  invoca+onContext.proceed();	
  
	
  }finally{ 	
  	
  
	
  logger.trace(String.format("Entering	
  method	
  %s",	
  
invoca+onContext.getMethod().getName());	
  
	
  
	
  @InterceptorBinding	
  
	
  @Reten+on(Reten+onPolicy.RUNTIME)	
  
	
  @Target({ElementType.TYPE,	
  
ElementType.METHOD})	
  
	
  public	
  @interface	
  Loggable	
  {	
  
	
  }	
  
	
  	
  
	
  @Loggable	
  
	
  @Applica+onScoped	
  
	
  public	
  class	
  StatusService	
  {	
  
	
  }	
  
Interceptor
InterceptorBinding and usage
Interceptors	
  1.2	
  –	
  What’s	
  new	
  in	
  Java	
  EE	
  7?	
  	
  
•  You	
  can	
  now	
  intercept	
  constructor	
  invoca+ons	
  
using	
  @AroundConstruct	
  
•  You	
  can	
  priori+ze	
  interceptors	
  using	
  @Priority.	
  
JPA	
  	
  
•  Describes	
  the	
  management	
  of	
  rela+onal	
  data	
  in	
  applica+ons.	
  
•  JPA	
  implementa+ons	
  provide	
  ORM	
  framework	
  
•  JPA	
  provides	
  an	
  API	
  to	
  perform	
  CRUD	
  opera+on	
  on	
  en++es.	
  
•  An	
  en+ty	
  is	
  a	
  POJO,	
  whose	
  state	
  is	
  mapped	
  to	
  a	
  rela+onal	
  
database.	
  
•  JPA	
  also	
  provides	
  a	
  query	
  language	
  to	
  make	
  queries	
  against	
  
en++es	
  stored	
  in	
  rela+onal	
  database.	
  
JPA	
  in	
  ac*on	
  
	
  @En+ty	
  
	
  public	
  class	
  Status	
  {	
  
	
  	
  	
  	
  @Id	
  
	
  	
  	
  	
  @GeneratedValue(strategy	
  =	
  
Genera+onType.AUTO)	
  
	
  	
  	
  	
  private	
  Long	
  id;	
  
	
  	
  	
  	
  private	
  String	
  message;	
  
	
  	
  	
  	
  private	
  final	
  Date	
  postedAt	
  =	
  new	
  Date();	
  
	
  }	
  
	
  @Stateless	
  
	
  public	
  class	
  StatusService	
  {	
  
	
  	
  	
  	
  @Inject	
  
	
  	
  	
  	
  private	
  En+tyManager	
  en+tyManager;	
  
	
  	
  	
  	
  public	
  Status	
  postStatus(String	
  message){	
  
	
  	
  	
  	
  	
  	
  	
  	
  Status	
  status	
  =	
  new	
  Status(message);	
  
	
  	
  	
  	
  	
  	
  	
  	
  en+tyManager.persist(status);	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  status;	
  
	
  	
  	
  	
  }	
  
	
  }	
  
	
  
JPA	
  2.1	
  –	
  What’s	
  new	
  in	
  Java	
  EE	
  7?	
  
•  Schema	
  genera+on	
  using	
  standard	
  proper+es.	
  
•  Use	
  @Index	
  to	
  define	
  addi+onal	
  indexes	
  in	
  
schema	
  genera+on.	
  
•  New	
  En+tyGraph	
  API	
  available	
  in	
  
En+tyManager.	
  
Web	
  Socket	
  1.0	
  	
  -­‐-­‐	
  New	
  in	
  Java	
  EE	
  7	
  
•  Bidirec+onal	
  full	
  duplex	
  messaging	
  
•  Annota+on	
  based	
  or	
  interface	
  based	
  
programming	
  model	
  
•  Server	
  and	
  Client	
  WebSocket	
  Endpoint	
  
•  Integrated	
  with	
  Java	
  EE	
  
Web	
  Sockets	
  in	
  Ac*on	
  
@ServerEndpoint("/reverse")	
  
public	
  class	
  ReverseEchoWebSocketServerEndpoint	
  {	
  
	
  	
  	
  	
  @OnOpen	
  
	
  	
  	
  	
  public	
  void	
  onOpen(){	
  
	
  	
  	
  	
  	
  	
  	
  	
  System.out.println("Connec+on	
  opened");	
  
	
  	
  	
  	
  }	
  
	
  	
  	
  	
  @OnMessage	
  
	
  	
  	
  	
  public	
  String	
  onMessage(String	
  message){	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  StringU+ls.reverse(message);	
  
	
  	
  	
  	
  }	
  
	
  	
  	
  	
  @OnClose	
  
	
  	
  	
  	
  public	
  void	
  connec+onClose(){	
  
	
  	
  	
  	
  	
  	
  	
  	
  System.out.println("Closed	
  connec+on");}	
  
	
  
	
  var	
  wsUrl	
  =	
  'hEp://localhost:8080/example/reverse’;	
  
	
  var	
  ws	
  =	
  new	
  WebSocket(wsUrl);	
  
	
  ws.onopen	
  =	
  func+on(event){};	
  
	
  ws.onclose	
  =	
  func+on(event){	
  
	
  	
  console.log("Remote	
  host	
  closed	
  or	
  refused	
  WebSocket	
  
connec+on");	
  
	
  };	
  
	
  ws.onmessage	
  =	
  func+on(event){	
  
	
  	
  	
  	
  $("textarea#outputMessage").val(event.data);	
  
	
  };	
  
	
  $(".btn").on('click',func+on(){	
  
	
  	
  	
  	
  var	
  message	
  =	
  $('textarea#inputMessage').val();	
  
	
  	
  	
  	
  ws.send(message);	
  
});	
  
Server Endpoint JavaScript Web Socket client
JSON-­‐P	
  1.0	
  
•  API	
  to	
  read	
  or	
  write	
  JSON	
  
•  Two	
  API’s	
  
•  Streaming	
  API	
  
•  Low	
  level	
  API	
  to	
  parse	
  and	
  generate	
  JSON	
  
•  Similar	
  to	
  StAX	
  API	
  in	
  XML	
  world	
  
•  Object	
  model	
  API	
  
•  High	
  level	
  API	
  
•  Similar	
  to	
  DOM	
  API	
  in	
  XML	
  world	
  
	
  
JsonReader	
  and	
  JsonWriter	
  Example	
  
JsonReader	
  jsonReader	
  =	
  Json.createReader(new	
  
StringReader(response));	
  
JsonObject	
  jsonObject	
  =	
  jsonReader.readObject();	
  
String	
  bannerImage	
  =	
  jsonObject.getString("image");	
  
String	
  descrip+on	
  =	
  jsonObject.getString("text");	
  
String	
  +tle	
  =	
  jsonObject.getString("+tle");	
  
Map<String,	
  String>	
  fetchedData	
  =	
  new	
  HashMap<>();	
  
fetchedData.put("picUrl",	
  bannerImage);	
  
fetchedData.put("descrip+on",	
  descrip+on);	
  
fetchedData.put("+tle",	
  +tle);	
  
	
  
JsonObjectBuilder	
  builder	
  =	
  Json.createObjectBuilder();	
  
	
  	
  	
  	
  	
  	
  	
  	
  builder.add("firstName",	
  "Shekhar")	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  .add("lastName",	
  "Gula+");	
  
	
  	
  	
  	
  	
  	
  	
  	
  JsonObject	
  result	
  =	
  builder.build();	
  
	
  	
  	
  	
  	
  	
  	
  	
  StringWriter	
  sw	
  =	
  new	
  StringWriter();	
  
	
  	
  	
  	
  	
  	
  	
  	
  try	
  (JsonWriter	
  writer	
  =	
  Json.createWriter(sw))	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  writer.writeObject(result);	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  	
  	
  	
  	
  sw.toString();	
  
JsonReader Example JsonWriter Example
Gefng	
  Started	
  with	
  Java	
  EE	
  7	
  	
  
Three	
  ways:	
  
1.  Use	
  Maven	
  archetype	
  
1.  Use	
  com.airhacks	
  JavaEE7	
  archetype	
  
2.  Use	
  template	
  Git	
  repository	
  
3.  Use	
  OpenShi1	
  to	
  create	
  a	
  publicly	
  accessible	
  
web	
  applica+on	
  in	
  minutes.	
  
OpenShift
OPENSHIFT	
  OVERVIEW	
  
OpenShift
is
PaaS by Red Hat
Multi-language,
Auto-Scaling,
Self-service,
Elastic,
Cloud Application Platform
l  Focus	
  on	
  code,	
  not	
  on	
  configura+on	
  
l  Speeds	
  up	
  deployment	
  
l  Scales	
  your	
  app	
  
l  Efficient	
  
l  Embraces	
  polyglot	
  programming	
  and	
  
persistence.	
  
WHY PAAS?
OUR STACK
origin
Public
Cloud
Service
On-
premise
or Private
Cloud
Software
Open
Source
Project
FLAVORS OF OPENSHIFT
l  	
  Scalable	
  Java	
  EE	
  6	
  supported	
  stack	
  via	
  JBoss	
  AS7	
  and	
  JBoss	
  EAP	
  6.	
  
l  	
  Java	
  EE	
  7	
  supported	
  via	
  WildFly	
  community	
  cartridge.	
  
l  	
  Scalable	
  Tomcat	
  6	
  and	
  Tomcat	
  7	
  support.	
  
l  	
  Hot	
  deployment.	
  
l  	
  Debugging.	
  
l  	
  Supports	
  Maven,	
  Ant,	
  and	
  Gradle.	
  
l  	
  Supports	
  con+nuous	
  integra+on	
  via	
  Jenkins.	
  
l  	
  Eclipse	
  and	
  IntelliJ	
  Idea	
  support.	
  
l  	
  Can	
  run	
  Java	
  8,	
  JeEy,	
  Tomcat	
  8,	
  Tom	
  EE,	
  etc.	
  
OPENSHIFT JAVA STORY
Demo	
  -­‐	
  Crea*ng	
  OpenShi9	
  WildFly	
  Applica*on	
  
•  Go	
  to	
  hEps://www.openshi1.com/	
  and	
  sign	
  up	
  
for	
  OpenShi1	
  Online.	
  
•  Verify	
  your	
  email	
  
•  Login	
  into	
  OpenShi1	
  web	
  console	
  
•  Search	
  for	
  WildFly	
  applica+on	
  type	
  
•  Give	
  applica+on	
  name	
  and	
  press	
  “Create	
  
Applica+on”	
  buEon.	
  
Demo	
  :	
  Add	
  MySQL	
  Cartridge	
  
	
  
	
  
	
  
Add	
  MySQL	
  5.5	
  cartridge	
  from	
  web	
  console	
  
Demo	
  :	
  Import	
  applica*on	
  in	
  Eclipse	
  
	
  
	
  
	
  
Use	
  OpenShi1	
  Eclipse	
  plugin	
  
Demo	
  :	
  Pull	
  the	
  Code	
  from	
  Github	
  Repository	
  
$	
  git	
  rm	
  -­‐rf	
  src/	
  pom.xml	
  
$	
  git	
  commit	
  -­‐am	
  “deleted	
  template	
  sourcecode”	
  
$	
  git	
  remote	
  add	
  upstream	
  -­‐m	
  master	
  hEps://
github.com/shekhargula+/hackerpins-­‐
drdobbsindia-­‐conference	
  
$	
  git	
  pull	
  -­‐s	
  recursive	
  -­‐X	
  theirs	
  upstream	
  master	
  
	
  
Demo	
  :	
  Code	
  walkthrough	
  REST	
  backend	
  
$	
  git	
  checkout	
  remotes/origin/backend	
  
•  JAX-­‐RS	
  resources	
  
•  Async	
  JAX-­‐RS	
  
•  JPA	
  layer	
  
•  CDI	
  usage	
  
•  Bean	
  valida+on	
  
AngularJS	
  –	
  in	
  one	
  slide	
  
•  Extending	
  HTML	
  to	
  add	
  dynamic	
  nature	
  so	
  that	
  we	
  can	
  build	
  
modern	
  web	
  applica+ons	
  with	
  ease.	
  
•  Brings	
  you	
  back	
  to	
  HTML	
  
•  Declara+ve	
  approach	
  
•  Eliminates	
  DOM	
  manipula+on	
  by	
  two	
  way	
  data	
  binding	
  
•  Ideal	
  for	
  building	
  single	
  page	
  web	
  applica+ons	
  
AngularJS	
  –	
  Main	
  Components	
  
•  Services	
  :	
  Objects	
  or	
  func+ons	
  to	
  carry	
  out	
  specific	
  tasks	
  
common	
  to	
  the	
  whole	
  web	
  applica+on.	
  
•  Direc+ves	
  :	
  allows	
  you	
  to	
  extend	
  HTML	
  by	
  defining	
  your	
  own	
  
project	
  specific	
  direc+ves.	
  
•  Controller	
  :	
  constructor	
  func+ons	
  that	
  define	
  the	
  app	
  business	
  
logic.	
  
•  Scope	
  :	
  contains	
  model	
  data.	
  Glues	
  controller	
  and	
  views.	
  
Angular	
  in	
  Ac*on	
  
<!DOCTYPE	
  html>	
  
<html	
  ng-­‐app>	
  
<head></head>	
  
<body>	
  
<div	
  ng-­‐init=”friends=	
  [{name:’karan'},{name:'rahul'},{name:'sameer'}]”>	
  
	
  	
  	
  	
  <ul>	
  
	
  	
  	
  	
  <li	
  ng-­‐repeat=”friend	
  in	
  friends">	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  {{friend.name}}	
  
	
  	
  	
  	
  </li>	
  
	
  	
  	
  	
  </ul>	
  
</div>	
  
<script	
  src="hEp://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>	
  
</body>	
  
</html>	
  
http://plnkr.co/edit/NU9wjQppgLMWujpH4bGU?p=preview
AngularJS:	
  Controller	
  and	
  Scope	
  in	
  Ac*on	
  
<!DOCTYPE	
  html>	
  
<html	
  ng-­‐app>	
  
<head></head>	
  
<body>	
  
<div	
  ng-­‐controller="FriendsCtrl”>	
  
	
  	
  	
  	
  <ul>	
  	
  	
  	
  	
  	
  	
  	
  <li	
  ng-­‐repeat="friend	
  in	
  friends”>{{friend.name}}	
  </li></ul>	
  
</div>	
  
<script	
  src="hEp://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>	
  
<script>	
  
	
  	
  	
  	
  func+on	
  FriendsCtrl($scope)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  $scope.friends	
  =	
  [{name:	
  'karan'},{name:	
  'rahul'},{name:	
  'sameer'}]	
  
	
  	
  	
  	
  }	
  
</script>	
  
</body>	
  
</html>	
  
http://plnkr.co/edit/1txkaBnZhy5vZuTU6W4S?p=preview
AngularJS:	
  Adding	
  func*ons	
  to	
  controllers	
  
<div	
  ng-­‐controller="FriendsCtrl”>	
  
	
  	
  	
  	
  <ul>	
  
	
  	
  	
  	
  	
  	
  	
  	
  <li	
  ng-­‐repeat="friend	
  in	
  friends">	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <a	
  ng-­‐click=hello(friend.name)>{{friend.name}}</a>	
  
	
  	
  	
  	
  	
  	
  	
  	
  </li>	
  	
  	
  	
  </ul></div>	
  
<script	
  src="hEp://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>	
  
<script>	
  
	
  	
  	
  	
  func+on	
  FriendsCtrl($scope)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  $scope.friends	
  =	
  [{name:	
  'karan'},{name:	
  'rahul'},{name:	
  'sameer'}]	
  
	
  	
  	
  	
  	
  	
  	
  	
  $scope.hello	
  =	
  func+on(name){	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  alert("Hello,	
  "+name)	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  }	
  
</script>	
  
http://plnkr.co/edit/hjGbzeo3QNBeWpVE7H03?p=preview
Demo	
  :	
  Code	
  walkthrough	
  Angular	
  frontend	
  
$	
  git	
  checkout	
  remotes/origin/frontend	
  
•  Controllers	
  
Deploy	
  to	
  OpenShi9	
  
	
  
	
  
	
  
$	
  git	
  push	
  
QUESTIONS?
DONE!

Contenu connexe

Tendances

Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008Baruch Sadogursky
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developersYakov Fain
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play FrameworkKnoldus Inc.
 
jQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksAddy Osmani
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Sumanth Chinthagunta
 
Aligning Ember.js with Web Standards
Aligning Ember.js with Web StandardsAligning Ember.js with Web Standards
Aligning Ember.js with Web StandardsMatthew Beale
 
Using React with Grails 3
Using React with Grails 3Using React with Grails 3
Using React with Grails 3Zachary Klein
 
Web sockets in Angular
Web sockets in AngularWeb sockets in Angular
Web sockets in AngularYakov Fain
 
Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Yakov Fain
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring BootJoshua Long
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptYakov Fain
 
Scala and Play with Gradle
Scala and Play with GradleScala and Play with Gradle
Scala and Play with GradleWei Chen
 
High Performance JavaScript - jQuery Conference SF Bay Area 2010
High Performance JavaScript - jQuery Conference SF Bay Area 2010High Performance JavaScript - jQuery Conference SF Bay Area 2010
High Performance JavaScript - jQuery Conference SF Bay Area 2010Nicholas Zakas
 
Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)ColdFusionConference
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework Yakov Fain
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideMek Srunyu Stittri
 

Tendances (20)

Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
Wicket Presentation @ AlphaCSP Java Web Frameworks Playoff 2008
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developers
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play Framework
 
jQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & Tricks
 
React native
React nativeReact native
React native
 
Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0 Single Page Applications with AngularJS 2.0
Single Page Applications with AngularJS 2.0
 
Aligning Ember.js with Web Standards
Aligning Ember.js with Web StandardsAligning Ember.js with Web Standards
Aligning Ember.js with Web Standards
 
Using React with Grails 3
Using React with Grails 3Using React with Grails 3
Using React with Grails 3
 
The State of Wicket
The State of WicketThe State of Wicket
The State of Wicket
 
Web sockets in Angular
Web sockets in AngularWeb sockets in Angular
Web sockets in Angular
 
Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2Reactive Thinking in Java with RxJava2
Reactive Thinking in Java with RxJava2
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Scala and Play with Gradle
Scala and Play with GradleScala and Play with Gradle
Scala and Play with Gradle
 
High Performance JavaScript - jQuery Conference SF Bay Area 2010
High Performance JavaScript - jQuery Conference SF Bay Area 2010High Performance JavaScript - jQuery Conference SF Bay Area 2010
High Performance JavaScript - jQuery Conference SF Bay Area 2010
 
Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java side
 

Similaire à Java EE 7 and AngularJS Workshop Develop Modern Web Apps

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 CODIos890
 
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in PracticeOpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in PracticeJesse Gallagher
 
Informix Java Driver Improvements 4.10.JC8
Informix Java  Driver Improvements 4.10.JC8Informix Java  Driver Improvements 4.10.JC8
Informix Java Driver Improvements 4.10.JC8Brian Hughes
 
Java EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseConJava EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseConLudovic Champenois
 
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 DeltaSpikeos890
 
Migrating to Jakarta EE 10
Migrating to Jakarta EE 10Migrating to Jakarta EE 10
Migrating to Jakarta EE 10Josh Juneau
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a bossFrancisco Ribeiro
 
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»DataArt
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
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-DurandSOAT
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpikeos890
 
JCD 2013 OCM Java Developer
JCD 2013 OCM Java DeveloperJCD 2013 OCM Java Developer
JCD 2013 OCM Java Developer益裕 張
 
OCM Java 開發人員認證與設計模式
OCM Java 開發人員認證與設計模式OCM Java 開發人員認證與設計模式
OCM Java 開發人員認證與設計模式CodeData
 
Altitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly WorkshopAltitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly WorkshopFastly
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemAndres Almiray
 
TypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkTypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkBob German
 

Similaire à Java EE 7 and AngularJS Workshop Develop Modern Web Apps (20)

Apache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI ToolboxApache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI Toolbox
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
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
 
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in PracticeOpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
 
Informix Java Driver Improvements 4.10.JC8
Informix Java  Driver Improvements 4.10.JC8Informix Java  Driver Improvements 4.10.JC8
Informix Java Driver Improvements 4.10.JC8
 
Java EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseConJava EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseCon
 
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
 
Migrating to Jakarta EE 10
Migrating to Jakarta EE 10Migrating to Jakarta EE 10
Migrating to Jakarta EE 10
 
Introduction to CDI
Introduction to CDIIntroduction to CDI
Introduction to CDI
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
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
 
Advanced Java Testing
Advanced Java TestingAdvanced Java Testing
Advanced Java Testing
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpike
 
JCD 2013 OCM Java Developer
JCD 2013 OCM Java DeveloperJCD 2013 OCM Java Developer
JCD 2013 OCM Java Developer
 
OCM Java 開發人員認證與設計模式
OCM Java 開發人員認證與設計模式OCM Java 開發人員認證與設計模式
OCM Java 開發人員認證與設計模式
 
Altitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly WorkshopAltitude San Francisco 2018: Testing with Fastly Workshop
Altitude San Francisco 2018: Testing with Fastly Workshop
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
 
TypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkTypeScript and SharePoint Framework
TypeScript and SharePoint Framework
 

Plus de Shekhar Gulati

Modern web application development with java ee 7
Modern web application development with java ee 7Modern web application development with java ee 7
Modern web application development with java ee 7Shekhar Gulati
 
Working effectively with OpenShift
Working effectively with OpenShiftWorking effectively with OpenShift
Working effectively with OpenShiftShekhar Gulati
 
Developing Great Apps with Apache Cordova
Developing Great Apps with Apache CordovaDeveloping Great Apps with Apache Cordova
Developing Great Apps with Apache CordovaShekhar Gulati
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Shekhar Gulati
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsShekhar Gulati
 
Open shift for java(ee) developers
Open shift for java(ee) developersOpen shift for java(ee) developers
Open shift for java(ee) developersShekhar Gulati
 
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...Shekhar Gulati
 
Java EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest AustriaJava EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest AustriaShekhar Gulati
 
Power up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShiftPower up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShiftShekhar Gulati
 
Bringing spatial love to your python application
Bringing spatial love to your python applicationBringing spatial love to your python application
Bringing spatial love to your python applicationShekhar Gulati
 
Building spatial back ends with Node.js and MongoDB
Building spatial back ends with Node.js and MongoDBBuilding spatial back ends with Node.js and MongoDB
Building spatial back ends with Node.js and MongoDBShekhar Gulati
 
A Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShiftA Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShiftShekhar Gulati
 
Indic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloudIndic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloudShekhar Gulati
 

Plus de Shekhar Gulati (13)

Modern web application development with java ee 7
Modern web application development with java ee 7Modern web application development with java ee 7
Modern web application development with java ee 7
 
Working effectively with OpenShift
Working effectively with OpenShiftWorking effectively with OpenShift
Working effectively with OpenShift
 
Developing Great Apps with Apache Cordova
Developing Great Apps with Apache CordovaDeveloping Great Apps with Apache Cordova
Developing Great Apps with Apache Cordova
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular js
 
Open shift for java(ee) developers
Open shift for java(ee) developersOpen shift for java(ee) developers
Open shift for java(ee) developers
 
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...
 
Java EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest AustriaJava EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest Austria
 
Power up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShiftPower up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShift
 
Bringing spatial love to your python application
Bringing spatial love to your python applicationBringing spatial love to your python application
Bringing spatial love to your python application
 
Building spatial back ends with Node.js and MongoDB
Building spatial back ends with Node.js and MongoDBBuilding spatial back ends with Node.js and MongoDB
Building spatial back ends with Node.js and MongoDB
 
A Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShiftA Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShift
 
Indic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloudIndic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloud
 

Dernier

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 

Dernier (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 

Java EE 7 and AngularJS Workshop Develop Modern Web Apps

  • 1. OPENSHIFT Workshop PRESENTED BY Shekhar Gulati Developing Modern Java Web Applications with Java EE 7 and AngularJS
  • 2. WHO AM I? •  Shekhar  Gula+  -­‐-­‐  OpenShi1  Developer  Evangelist     •  Java  /  JavaScript  /  Python  /  NoSQL  /  Cloud  Guy     •  TwiEer  Handle  :  shekhargula*     •  Github  :  h,ps://github.com/shekhargula*   •  Author  of  30  technologies  in  30  days  blog  series   h,ps://www.openshi9.com/blogs/learning-­‐30-­‐ technologies-­‐in-­‐30-­‐days-­‐a-­‐developer-­‐challenge  
  • 3. l  Define  Modern  Web  Applica+on   l  Introduce  Java  EE  7   l  GeRng  Started  with  Java  EE  7   l  OpenShi1  for  Java(EE)  Developers   l  Write  HackerPins  Applica+on  REST  Backend   l  Look  at  AngularJS   l  Write  HackerPins  AngularJS  Frontend   l  Deploy  to  OpenShi1   AGENDA http://www.hackerpins.com/
  • 6.  What  make’s  a  modern  web  applica*on?   •  Exposes  REST  JSON  web  services   •  Single  backend  and  mul+ple  front  ends   •  Embraces  HTML  5     •  GeoLoca+on,  Local  Storage,  Web  Sockets   •  Single  page  web  applica+on   •  Uses  MV*  JavaScript  framework   •  Stateless  so  that  you  can  scale  horizontally   •  Uses  OAuth   •  Integrates  with  social  pla`orms  like  TwiEer,  Facebook,  Google+   •  Embraces  Polyglot  Persistence   •  Cloud  aware  
  • 7. CAN  WE  BUILD  MODERN  WEB   APPLICATIONS  USING  JAVA  EE?  
  • 8. Short  answer  is…     Yes   This  session  will  try  to  convince  you  to  use  Java   EE  7  for  your  next  web  app.   http://www.hackerpins.com/
  • 9. Choose  Session  Delivery  Mode   1.  Hands-­‐on  coding  –  No  slides  –  J   2.  Slides  with  code  fragments  –  L  
  • 10. Java  EE  *meline   0   10   12   18   24   30   38   JPE  (1998)   J2EE  1.2   (1999)   J2EE   1.3(2001)   J2EE   1.4(2001)   Java  EE   5(2006)   Java  EE   6(2009)   Java  EE   7(2013)   Java  EE  Timeline   Java  EE  Timeline  
  • 11. Java  EE  6  changed  the  game…  It  was  lightweight   •  Introduc+on  of  web  profile   •  EJBs  can  be  packed  in  WAR  files   •  Servlet  3.0   •  web.xml  became  op+onal,  @WebServlet,  @WebFilter   •  Type  safe  contextual  dependency  injec+on(CDI)   •  DI  for  Java  EE,  event  support   •  @Asynchronous  and  @Schedule  support   •   RESTFul  web  services  support  with  JAX-­‐RS  1.1  
  • 12. Java  EE  7  –  Produc*vity  and  HTML  5  Focused   •  Builds  on  top  of  Java  EE  6   •  Embraces  HTML  5   •  4  new  specs   •  3  major  spec  updates   •  6  minor  spec  updates   •  5    micro  updates  
  • 13. The  Java  EE  7  Pla]orm   Java EE 7 Platform CDI1.1 BEANVALIDATION1.1 INTERCEPTORS1.2 CONCURRENCY1.0 JPA 2.1 JTA 1.2 EJB 3.2 JMS 2.0 WEBSOCKET 1.0 SERVLET 3.1 JSP 2.3 EL 3.0 JSF 2.2 JCA 1.7 MAIL 1.5 BATCH 1.0 JSON-P 1.0 JAX-RS 2.0 New Major updates Minor/macro updates
  • 14. Our  modern  Java  EE  7  stack   Java EE 7 Platform CDI1.1 BEANVALIDATION1.1 INTERCEPTORS1.2 CONCURRENCY1.0 JPA 2.1 JTA 1.2 EJB 3.2 WEBSOCKET 1.0 JSON-P 1.0 JAX-RS 2.0
  • 15. LETS  LOOK  AT  FEW  JAVA  EE  7  SPECS  
  • 16. CDI  1.1-­‐-­‐  Context  and  Dependency  Injec*on    •  Allows  you  to  use  dependency  injec+on  in  Java  EE   environment  without  third  party  libraries.   •  Don’t  call  us.  We  will  call  you.   •  CDI  container  manages  the  life  cycle  of  components.   •  CDI  brings  dependency  injec+on,  context  and  scopes,   interceptors,  loose  coupling  and  strong  typing.   •  Injected  bean  lifecycle  depends  on  the  target  bean.   •  Turns  nearly  every  Java  class  into  CDI  bean   •  It  is  not  a  non  sta+c  inner  class   •  It  is  a  concrete  class  or  annotated  with  decorators   •  Has  default  constructor  with  no  parameters  or  declares  a  constructor  with  @Inject  
  • 17. Enable  CDI  –  beans.xml   <?xml  version="1.0"  encoding="UTF-­‐8"?>   <beans                  xmlns="hEp://xmlns.jcp.org/xml/ns/javaee"                  xmlns:xsi="hEp://www.w3.org/2001/XMLSchema-­‐instance"                  xsi:schemaLoca+on="hEp://xmlns.jcp.org/xml/ns/javaee                                                hEp://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"                  bean-­‐discovery-­‐mode="all">   </beans>  
  • 18. CDI  Example   Simple CDI Bean Injecting a bean  public  class  LowercaseBeau+fier  implements   MessageBeau+fier  {          @Override          public  String  beau+fy(String  message)  {                  return  message  !=  null  ?  message.toLowerCase()  :   null;          }   }    public  interface  MessageBeau+fier  {          public  String  beau+fy(String  message);    }      @Applica+onScoped    public  class  StatusService  {          @Inject          private  MessageBeau+fier  messageBeau+fier;          public  Status  postStatus(String  message)  {                  Status  status  =  new   Status(messageBeau+fier.beau+fy(message));                  return  status;          }    }    
  • 19. CDI    -­‐-­‐  Two  implementa*ons  MessageBeau*fier   public  class  UppercaseBeau+fier   implements  MessageBeau+fier  {          @Override          public  String  beau+fy(String  message)  {                  return  message  !=  null  ?   message.toUpperCase()  :  null;          }   }   public  class  LowercaseBeau+fier   implements  MessageBeau+fier  {          @Override          public  String  beau+fy(String  message)  {                  return  message  !=  null  ?   message.toLowerCase()  :  null;          }   }   Code will throw exception-- Ambiguous dependencies for type MessageBeautifier
  • 20. CDI  –  Use  @Qualifier   @Qualifier   @Reten+on(Reten+onPolicy.RUNTIME)   @Target({ElementType.METHOD,  ElementType.TYPE,  ElementType.FIELD})   public  @interface  Beau+fier  {          Beau+fierType  type();   }   public  enum  Beau+fierType  {          LOWERCASE,  UPPERCASE   }      
  • 21. CDI  -­‐-­‐  @Qualifier  usage    @Beau+fier(type  =   Beau+fierType.LOWERCASE)    public  class  LowercaseBeau+fier   implements  MessageBeau+fier  {          @Override          public  String  beau+fy(String   message)  {                  return  message  !=  null  ?   message.toLowerCase()  :  null;          }   }    @Beau+fier(type  =   Beau+fierType.UPPERCASE)    public  class  UppercaseBeau+fier   implements  MessageBeau+fier  {            @Override          public  String  beau+fy(String   message)  {                  return  message  !=  null  ?   message.toUpperCase()  :  null;          }   }  
  • 22. CDI  –  Loose  Coupling  and  Sta*c  Typing   @Applica+onScoped   public  class  StatusService  {          @Inject          @Beau+fier(type  =  Beau+fierType.UPPERCASE)          private  MessageBeau+fier  messageBeau+fier;            public  Status  postStatus(String  message)  {                  Status  status  =  new  Status(messageBeau+fier.beau+fy(message));   return  status;          }   }  
  • 23. CDI  1.1:  What’s  new  in  Java  EE  7?   •  Finer  scanning  control  in  beans.xml   •  bean-­‐discovery-­‐mode  aEribute  –  all,  none,  annotated   •  @Vetoed  annota+on  to  veto  processing  of  a  package  or  class.   •  You  can  use  @Transac+onal  with  CDI  beans.   •  You  can  get  away  from  EJBs.  
  • 24. Bean  Valida*on   •  Specifies  common  valida+on  concept  for   JavaBeans.   •  Allow  you  to  put  constraints  on  data  to  make   sure  it  is  valid.   •  Annota+on  based  constraints   •  Use  constraint  in  any  layer  
  • 25. Bean  Valida*on  Example   public  class  Status{          @NotNull      @Size(max  =  140)          private  String  message;          @NotNull  @Past          private  final  Date  postedAt;          @UniqueUrl          private  String  url;          public  Status()  {}   }  
  • 26. Bean  Valida*on  1.1  –    What’s  new  in  Java  EE  7?   •  You  can  validate  method  parameters  and  return  types.   •  Integra+on  with  JAX-­‐RS     @Path(“/statuses”) public class StatusService { @POST @Produces(“application/json”) public @NotNull Status postStatus(@Valid @NotNull Status status) { // persist in database return status; } }
  • 27. Interceptors   •  Allows  you  to  add  cross  cuRng  concerns  to   your  beans.   •  Lightweight  AOP   •  You  can  use  them  to  intercept  method  calls,   constructor  invoca+on,  Method  +meouts.  
  • 28. Interceptors  in  ac*on    @Interceptor    @Loggable    public  class  LoggingInterceptor  {          @Inject          private  Logger  logger;          @AroundInvoke          public  Object  logMethodCall(Invoca+onContext  invoca+onContext)   throws  Excep+on  {    logger.trace(String.format("Entering  method  %s",   invoca+onContext.getMethod().getName());    try{    return  invoca+onContext.proceed();    }finally{      logger.trace(String.format("Entering  method  %s",   invoca+onContext.getMethod().getName());      @InterceptorBinding    @Reten+on(Reten+onPolicy.RUNTIME)    @Target({ElementType.TYPE,   ElementType.METHOD})    public  @interface  Loggable  {    }        @Loggable    @Applica+onScoped    public  class  StatusService  {    }   Interceptor InterceptorBinding and usage
  • 29. Interceptors  1.2  –  What’s  new  in  Java  EE  7?     •  You  can  now  intercept  constructor  invoca+ons   using  @AroundConstruct   •  You  can  priori+ze  interceptors  using  @Priority.  
  • 30. JPA     •  Describes  the  management  of  rela+onal  data  in  applica+ons.   •  JPA  implementa+ons  provide  ORM  framework   •  JPA  provides  an  API  to  perform  CRUD  opera+on  on  en++es.   •  An  en+ty  is  a  POJO,  whose  state  is  mapped  to  a  rela+onal   database.   •  JPA  also  provides  a  query  language  to  make  queries  against   en++es  stored  in  rela+onal  database.  
  • 31. JPA  in  ac*on    @En+ty    public  class  Status  {          @Id          @GeneratedValue(strategy  =   Genera+onType.AUTO)          private  Long  id;          private  String  message;          private  final  Date  postedAt  =  new  Date();    }    @Stateless    public  class  StatusService  {          @Inject          private  En+tyManager  en+tyManager;          public  Status  postStatus(String  message){                  Status  status  =  new  Status(message);                  en+tyManager.persist(status);                  return  status;          }    }    
  • 32. JPA  2.1  –  What’s  new  in  Java  EE  7?   •  Schema  genera+on  using  standard  proper+es.   •  Use  @Index  to  define  addi+onal  indexes  in   schema  genera+on.   •  New  En+tyGraph  API  available  in   En+tyManager.  
  • 33. Web  Socket  1.0    -­‐-­‐  New  in  Java  EE  7   •  Bidirec+onal  full  duplex  messaging   •  Annota+on  based  or  interface  based   programming  model   •  Server  and  Client  WebSocket  Endpoint   •  Integrated  with  Java  EE  
  • 34. Web  Sockets  in  Ac*on   @ServerEndpoint("/reverse")   public  class  ReverseEchoWebSocketServerEndpoint  {          @OnOpen          public  void  onOpen(){                  System.out.println("Connec+on  opened");          }          @OnMessage          public  String  onMessage(String  message){                  return  StringU+ls.reverse(message);          }          @OnClose          public  void  connec+onClose(){                  System.out.println("Closed  connec+on");}      var  wsUrl  =  'hEp://localhost:8080/example/reverse’;    var  ws  =  new  WebSocket(wsUrl);    ws.onopen  =  func+on(event){};    ws.onclose  =  func+on(event){      console.log("Remote  host  closed  or  refused  WebSocket   connec+on");    };    ws.onmessage  =  func+on(event){          $("textarea#outputMessage").val(event.data);    };    $(".btn").on('click',func+on(){          var  message  =  $('textarea#inputMessage').val();          ws.send(message);   });   Server Endpoint JavaScript Web Socket client
  • 35. JSON-­‐P  1.0   •  API  to  read  or  write  JSON   •  Two  API’s   •  Streaming  API   •  Low  level  API  to  parse  and  generate  JSON   •  Similar  to  StAX  API  in  XML  world   •  Object  model  API   •  High  level  API   •  Similar  to  DOM  API  in  XML  world    
  • 36. JsonReader  and  JsonWriter  Example   JsonReader  jsonReader  =  Json.createReader(new   StringReader(response));   JsonObject  jsonObject  =  jsonReader.readObject();   String  bannerImage  =  jsonObject.getString("image");   String  descrip+on  =  jsonObject.getString("text");   String  +tle  =  jsonObject.getString("+tle");   Map<String,  String>  fetchedData  =  new  HashMap<>();   fetchedData.put("picUrl",  bannerImage);   fetchedData.put("descrip+on",  descrip+on);   fetchedData.put("+tle",  +tle);     JsonObjectBuilder  builder  =  Json.createObjectBuilder();                  builder.add("firstName",  "Shekhar")                                .add("lastName",  "Gula+");                  JsonObject  result  =  builder.build();                  StringWriter  sw  =  new  StringWriter();                  try  (JsonWriter  writer  =  Json.createWriter(sw))  {                          writer.writeObject(result);                  }                  sw.toString();   JsonReader Example JsonWriter Example
  • 37. Gefng  Started  with  Java  EE  7     Three  ways:   1.  Use  Maven  archetype   1.  Use  com.airhacks  JavaEE7  archetype   2.  Use  template  Git  repository   3.  Use  OpenShi1  to  create  a  publicly  accessible   web  applica+on  in  minutes.  
  • 39. OpenShift is PaaS by Red Hat Multi-language, Auto-Scaling, Self-service, Elastic, Cloud Application Platform
  • 40. l  Focus  on  code,  not  on  configura+on   l  Speeds  up  deployment   l  Scales  your  app   l  Efficient   l  Embraces  polyglot  programming  and   persistence.   WHY PAAS?
  • 43. l   Scalable  Java  EE  6  supported  stack  via  JBoss  AS7  and  JBoss  EAP  6.   l   Java  EE  7  supported  via  WildFly  community  cartridge.   l   Scalable  Tomcat  6  and  Tomcat  7  support.   l   Hot  deployment.   l   Debugging.   l   Supports  Maven,  Ant,  and  Gradle.   l   Supports  con+nuous  integra+on  via  Jenkins.   l   Eclipse  and  IntelliJ  Idea  support.   l   Can  run  Java  8,  JeEy,  Tomcat  8,  Tom  EE,  etc.   OPENSHIFT JAVA STORY
  • 44. Demo  -­‐  Crea*ng  OpenShi9  WildFly  Applica*on   •  Go  to  hEps://www.openshi1.com/  and  sign  up   for  OpenShi1  Online.   •  Verify  your  email   •  Login  into  OpenShi1  web  console   •  Search  for  WildFly  applica+on  type   •  Give  applica+on  name  and  press  “Create   Applica+on”  buEon.  
  • 45. Demo  :  Add  MySQL  Cartridge         Add  MySQL  5.5  cartridge  from  web  console  
  • 46. Demo  :  Import  applica*on  in  Eclipse         Use  OpenShi1  Eclipse  plugin  
  • 47. Demo  :  Pull  the  Code  from  Github  Repository   $  git  rm  -­‐rf  src/  pom.xml   $  git  commit  -­‐am  “deleted  template  sourcecode”   $  git  remote  add  upstream  -­‐m  master  hEps:// github.com/shekhargula+/hackerpins-­‐ drdobbsindia-­‐conference   $  git  pull  -­‐s  recursive  -­‐X  theirs  upstream  master    
  • 48. Demo  :  Code  walkthrough  REST  backend   $  git  checkout  remotes/origin/backend   •  JAX-­‐RS  resources   •  Async  JAX-­‐RS   •  JPA  layer   •  CDI  usage   •  Bean  valida+on  
  • 49. AngularJS  –  in  one  slide   •  Extending  HTML  to  add  dynamic  nature  so  that  we  can  build   modern  web  applica+ons  with  ease.   •  Brings  you  back  to  HTML   •  Declara+ve  approach   •  Eliminates  DOM  manipula+on  by  two  way  data  binding   •  Ideal  for  building  single  page  web  applica+ons  
  • 50. AngularJS  –  Main  Components   •  Services  :  Objects  or  func+ons  to  carry  out  specific  tasks   common  to  the  whole  web  applica+on.   •  Direc+ves  :  allows  you  to  extend  HTML  by  defining  your  own   project  specific  direc+ves.   •  Controller  :  constructor  func+ons  that  define  the  app  business   logic.   •  Scope  :  contains  model  data.  Glues  controller  and  views.  
  • 51. Angular  in  Ac*on   <!DOCTYPE  html>   <html  ng-­‐app>   <head></head>   <body>   <div  ng-­‐init=”friends=  [{name:’karan'},{name:'rahul'},{name:'sameer'}]”>          <ul>          <li  ng-­‐repeat=”friend  in  friends">                    {{friend.name}}          </li>          </ul>   </div>   <script  src="hEp://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>   </body>   </html>   http://plnkr.co/edit/NU9wjQppgLMWujpH4bGU?p=preview
  • 52. AngularJS:  Controller  and  Scope  in  Ac*on   <!DOCTYPE  html>   <html  ng-­‐app>   <head></head>   <body>   <div  ng-­‐controller="FriendsCtrl”>          <ul>                <li  ng-­‐repeat="friend  in  friends”>{{friend.name}}  </li></ul>   </div>   <script  src="hEp://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>   <script>          func+on  FriendsCtrl($scope)  {                  $scope.friends  =  [{name:  'karan'},{name:  'rahul'},{name:  'sameer'}]          }   </script>   </body>   </html>   http://plnkr.co/edit/1txkaBnZhy5vZuTU6W4S?p=preview
  • 53. AngularJS:  Adding  func*ons  to  controllers   <div  ng-­‐controller="FriendsCtrl”>          <ul>                  <li  ng-­‐repeat="friend  in  friends">                          <a  ng-­‐click=hello(friend.name)>{{friend.name}}</a>                  </li>        </ul></div>   <script  src="hEp://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>   <script>          func+on  FriendsCtrl($scope)  {                  $scope.friends  =  [{name:  'karan'},{name:  'rahul'},{name:  'sameer'}]                  $scope.hello  =  func+on(name){                          alert("Hello,  "+name)                  }          }   </script>   http://plnkr.co/edit/hjGbzeo3QNBeWpVE7H03?p=preview
  • 54. Demo  :  Code  walkthrough  Angular  frontend   $  git  checkout  remotes/origin/frontend   •  Controllers  
  • 55. Deploy  to  OpenShi9         $  git  push  
  • 57. DONE!