2 Replies Latest reply on Mar 28, 2013 1:17 AM by maruthid

    How to Access CRX Node from a JAVA file?


      Hi All,


      If my developing a class to be used in OSGi service,  what should i do a class to be used as OSGI serive?


      Thanks !

        • 1. Re: How to Access CRX Node from a JAVA file?
          Veena_07 Level 4

          Hi Sachin


               Sorry but your question is not clear. Can you please clearly say what is ur requirement






          • 2. Re: How to Access CRX Node from a JAVA file?
            maruthid Level 1

            To make your class as service use annotations. like


            @Component(label = "This will show up as lebel in osgi console", description = "description of the service", metatype = true, immediate = true)


            public class NameofImplementationclass {


            //Below are 2 default method implementaions which will help to get admin session on activation and logging out on deactivation



                      protected void activate(ComponentContext componentContext) {

                                try {

              adminSession = repository.loginAdministrative(repository


                                } catch (Exception e) {

              log.error("exception in service activation", e.getMessage);





                      protected void deactivate(ComponentContext componentContext) {

              if (adminSession != null) {


              log.info("service is deactivated admis session logged out");







            For accessing node

            get the admin session in your service on activation of the service. Activation method will be called once this service is activated in osgi as shown in above code

            adminSession = repository.loginAdministrative(repository



            Get resource resolver


            ResourceResolver rr = resolverFactory.getResourceResolver(session);


            By using this resolver you resolve paths to resources etc like