On Mon, Jun 24, 2019 at 11:02 AM jimy page <jimypage...@gmail.com> wrote: > > Thanks Woonsan for your quick response. > > I tried configuring StatisticsServlet. What I did was, in jackrabbit-webapp > I have added StatisticsServlet. > But RepositoryContext context = > (RepositoryContext)this.getServletContext().getAttribute(name);----> at > this line I am unable to retrievecontext. > This is always coming null.
jackrabbit-webapp doesn't seem to expose a RepositoryContext. So, I don't think you can use StatisticsServlet with it. You can perhaps use JackrabbitRepositoryServlet [1] in a custom web application to initialize your repository instance instead of jackrabbit-webapp. Then RepositoryContext will become available. Regards, Woonsan [1] http://jackrabbit.apache.org/api/trunk/org/apache/jackrabbit/servlet/jackrabbit/JackrabbitRepositoryServlet.html > > So I did it in a hacky way, created a new MetricsServlet overriding > StatisticsServlet's methods. > > > So my question is, what is the best way to retrieve RepositoryConfig object > ? > > The following code is giving me stat for newly created repo: > > RepositoryConfig config = null; > try { > config = RepositoryConfig.create(new File("/Users/xxxxx/repo2"));// > //**some try > // **some try ends here > } catch (ConfigurationException e) { > e.printStackTrace(); > } > RepositoryContext context = null; > try { > context = RepositoryContext.create(config); > if (context != null) { > RepositoryStatistics statistics = context.getRepositoryStatistics(); > ==========================> > > *I need help in how to instantiate RepositoryConfig, which will point to > the same repo that my jackrabbit instance is using.* > > *There is no documentation found for this :(.* > > > > *Thanks * > *Jimy* > > > > On Mon, Jun 24, 2019 at 7:01 PM Woonsan Ko <woon...@apache.org> wrote: > > > On Mon, Jun 24, 2019 at 7:19 AM jimy page <jimypage...@gmail.com> wrote: > > > > > > I have jackrabbit runnig with repo /users/xyz/repo1 > > > Inside this I have repository.xml > > > > > > > > > I want to call org.apache.jackrabbit.servlet.jackrabbit.StatisticsServlet > > > to show different metrices. > > > > > > > > > *But the problem I am facing here is: --> In order to create > > > RepositoryConfig, I need to pass in the repo folder path, but Jackrabbit > > > process is already kept it locked. What is the alternative here ?* > > > > > > *I can copy over "/Users/xyz/repository/", to some other folder and use > > > that, but my question is in that case will I get all the repository > > > information ?* > > > > I don't think so. > > If you copy the data such as directories and *recreate* a. new > > repository instance, it will show new statistics of the new running > > repository. > > I think you should just configure the StatisticsServlet on the same > > web application which initializes the repository. > > > > Regards, > > > > Woonsan > > > > > > > > ----> Here is my sample code > > > > > > HttpServletRequest request, HttpServletResponse response) > > > throws ServletException, IOException { > > > String klass = RepositoryContext.class.getName(); > > > String name = getServletConfig().getInitParameter(klass); > > > if (name == null) { > > > name = klass; > > > } > > > > > > // RepositoryContext context = (RepositoryContext) > > > // getServletContext().getAttribute(name); > > > RepositoryConfig config = null; > > > try { > > > config = RepositoryConfig.create(new > > File("/Users/xyz/repository/")); > > > //**some try > > > // **some try ends here > > > } catch (ConfigurationException e) { > > > e.printStackTrace(); > > > } > > > RepositoryContext context = null; > > > try { > > > context = RepositoryContext.create(config); > >