Sunday, April 24, 2022

OSGi Bundle States in AEM

OSGi is a fundamental element in the technology stack of AEM. It is used to control the composite bundles of AEM and their configuration. OSGi “provides the standardized primitives that allow applications to be constructed from small, reusable and collaborative components.

OSGi

OSGi is a Java framework for developing and deploying modular software programs and libraries. OSGi has two parts.

  •     Bundles or Plug-in
  •     Java Virtual Machine (JVM)-level service registry.

In this article, we will focus on bundle states only.

A Bundle object is the access point to define the lifecycle of an installed bundle. Each bundle installed in the OSGi environment must have an associated Bundle object.

A bundle must have a unique identity, a long, chosen by the Framework. This identity must not change during the lifecycle of a bundle, even when the bundle is updated. Uninstalling and then reinstalling the bundle must create a new unique identity.

A bundle can be in one of six states:

 

Name

Value

Description

UNINSTALLED

0x00000001

Only visible after a bundle is uninstalled; the bundle is in an unusable state but references to the bundle object may still be available and used for introspection.

INSTALLED

0x00000002

Visible if the bundle’s code dependencies are not resolved. The Framework may attempt to resolve an INSTALLED bundle’s code dependencies and move the bundle to the RESOLVED state.

RESOLVED

0x00000004

The Framework has successfully resolved the bundle’s code dependencies, but the bundle is not active. Dependencies include: the bundle’s classpath; the bundle’s package dependencies; the bundle’s required bundle dependencies;

STARTING

 0x00000008

The bundle’s start method is active. A bundle must be in this state when the bundle’s BundleActivator.start(BundleContext) is called. If the BundleActivator.start method completes without exception, then the bundle has successfully started and must move to the ACTIVE state.

STOPPING

0x00000010

The bundle’s stop method is active. A bundle must be in this state when the bundle’s BundleActivator.stop(BundleContext) method is called. When the BundleActivator.stop method completes the bundle is stopped and must move to the RESOLVED state.

ACTIVE

0x00000020

The bundle has been successfully started and activated.

 






 












OSGi bundle lifecycle



References:

https://docs.osgi.org/javadoc/r6/core/org/osgi/framework/Bundle.html

Saturday, April 23, 2022

Difference- EAR, JAR and WAR

J2EE defines three types of archives:

  • EAR
  • WAR
  • JAR

When Java applications are deployed, all of the files that constitute the Java app are compressed and packaged into a single file. While compressed files are typically given a .zip extension, the Java community instead uses .ear, .war and .jar files.

 

Under the hood, EAR, JAR and WAR files are all simply zip files that contain the various images, XML files, property files and pieces of Java code that make up a Java application.

EAR WAR JAR Difference




  • Java Archive (JAR) A JAR file encapsulates one or more Java classes, a manifest, and a descriptor. It also holds generic libraries of Java classes, resources, auxiliary files.  
  •  JAR files are the lowest level of archive. JAR files are used in J2EE for packaging EJBs and client-side Java Applications.
  • Actually, jar file contains all the .class files of our java project.

Extension- .jar

  • Web Archive (WAR) A WAR files are similar to JAR files, except that they are specifically for web applications made from Servlets, JSPs, and supporting classes. These are intended to contain complete Web applicationsWeb application contain all the web related Technologies like Html,Css, Javascript , Jsp,Servlet ,Xml etc and War file is a compressed form of web application which allows us to make that application portable. Struts and Spring based Web applications may be archived to a WAR.

·                       Extension- .war

  • Enterprise Archive (EAR) An EAR file contains all of the components that make up a particular J2EE application. are intended to contain complete enterprise applications. In this context, an enterprise application is defined as a collection of .jar files, resources, classes, and multiple Web applications. An EAR may contain one or more WAR files. EAR files can also contain connector modules packaged as RAR files and Client modules packaged as JAR files.

·                          Extension- .ear

   Summary: 

        

     An EAR file requires a fully Java Platform, Enterprise Edition (Java EE)- or Jakarta Enterprise Edition (EE)-compliant application serversuch as WebSphere or JBoss, to run. 

A WAR file only requires a Java EE Web Profile-compliant application server to run.

A JAR file only requires a Java installation. 

 

Install yarn on windows

 In this article, we will see how we can install yarn on windows. First lets understand what yarn is? Yarn is an established open-source pac...