Skip to content

Instantly share code, notes, and snippets.

@chetanmeh
chetanmeh / sling-logback.xml
Last active December 28, 2015 11:49
Sample Logback xml config file to be used with Sling based application
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
@chetanmeh
chetanmeh / gmongo.groovy
Last active December 26, 2015 12:49
Oak related scripts
import com.gmongo.GMongo
import com.mongodb.util.JSON
import groovy.json.*
//https://github.com/poiati/gmongo
def mk = osgi.getService(org.apache.jackrabbit.mk.api.MicroKernel.class)
def db = GMongo.patchAndReturn(mk.store.nodes.DB)
@chetanmeh
chetanmeh / extractListenerDeatails.groovy
Last active December 26, 2015 02:49
Details about various JCR Listeners registered on an Adobe CQ instance.
import groovy.text.SimpleTemplateEngine
import org.osgi.framework.FrameworkUtil
import org.apache.jackrabbit.commons.observation.ListenerTracker
def services = osgi.getServices(org.apache.jackrabbit.api.jmx.EventListenerMBean.class,"(jmx.objectname=*)")
trackerToSessionMap = getListnerToSessionMap()
def listeners = services.collect { getDetails(it) }
def allListeners = listeners
listeners = listeners.findAll {it.class != 'org.apache.sling.installer.provider.jcr.impl.WatchedFolder'}
@chetanmeh
chetanmeh / listeners.groovy
Created October 17, 2013 10:54
Script to get JCR Listeners registered within Sling
import groovy.text.SimpleTemplateEngine
def services = osgi.getServices(org.apache.jackrabbit.api.jmx.EventListenerMBean.class,"(jmx.objectname=*)")
def listeners = services.collect { getDetails(it) }
listeners = listeners.sort {it.path}
listeners.eachWithIndex{l,i -> l.index = i+1}
def ttf = new TemplateFactory()
ttf.addColumn("index",4).addColumn("path",45).addColumn("class",100)
@chetanmeh
chetanmeh / logstash-cq.conf
Last active December 23, 2015 08:19
cq-logstash
#Logstash Config File for parsing existing Logs in Cq/Sling based application
input {
stdin {
type => "stdin-type"
}
file {
type => "cq-ci-author"
path => ["/path/crx-quickstart/logs/error.log"]
debug => false
@chetanmeh
chetanmeh / SessionSynchronizer.java
Created August 23, 2013 06:04
SessionSynchronizer - Demonstrates an example of using SessionOperationInterceptor https://issues.apache.org/jira/browse/OAK-960
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
This scripts provide details related to various caches used in Oak MongoMK module while running within Sling OSGi Container
The script is based on (JAMM) [1]. Steps are provided below
1. Download JAMM from Maven
$wget http://repo1.maven.org/maven2/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar
2. Modify the Quickstart launching by specifying agent and bootdelegation list
$java -javaagent:<path to>/jamm.jar -Dorg.apache.sling.launcher.bootdelegation=,org.github.jamm -jar
3. Deploy the Script Console jar
$wget http://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.scripting.console/1.0.0/org.apache.sling.scripting.console-1.0.0.jar
$wget http://repo1.maven.org/maven2/org/codehaus/groovy/groovy-all/2.1.3/groovy-all-2.1.3.jar
@chetanmeh
chetanmeh / .bashrc
Last active February 28, 2020 09:48
Script to launch a KDE Konsole window with multiple tabs. It is based on script provided in [Linux Journal](http://www.linuxjournal.com/content/start-and-control-konsole-dbus). It helps to bootstrap development env by launching multiple tabs with preconfigured directory and titles.
source ~/path/to/tabs.sh
load-dev(){
#Create sessi data format '<Tab Name/Title> <Profile Name> <Working Directory>'
local sessions=(
oak Shell 'clear; cd ~/git/apache/oak'
sling Shell 'clear; cd ~/git/apache/sling'
felix Shell 'clear; cd ~/git/apache/felix'
)
start_sessions sessions[@]
@chetanmeh
chetanmeh / diffIntellijTestResult.groovy
Created March 7, 2013 09:12
Script to perform diff between two Intellij test run result which are exported as xml
/**
* Utility class that diffs 2 Intellij test runs and performs diff between the two runs. It works
* on xml report created by Intellij as mentioned in http://www.jetbrains.com/idea/webhelp/export-test-results.html
*
* How to run
*
* - Run first test suite and export the result as xml
* - Run first test suite again post change and export the result as xml
*
* Run the script
@chetanmeh
chetanmeh / bundle.info
Created January 21, 2013 15:01
Felix 4.x bundle.info description
11 #Bundle Id
slinginstall:/path/to/foo.jar #Bundle original location
32 #Persistence State (INSTALLED, RESOLVED etc)
1 #Start level
1358768421064 #Last modified
0 #Refresh Count