Skip to content

Instantly share code, notes, and snippets.

@nateyolles
Created May 25, 2017 20:54
Show Gist options
  • Save nateyolles/c3d29da6a9dcb36d3648c40c8f7909b2 to your computer and use it in GitHub Desktop.
Save nateyolles/c3d29da6a9dcb36d3648c40c8f7909b2 to your computer and use it in GitHub Desktop.
Sample OSGi servlet in AEM
@Component(
immediate = true,
service = Servlet.class,
property = {
"sling.servlet.resourceTypes=project/components/component"
}
)
@Designate(ocd = SampleOsgiServlet.Configuration.class)
public class SampleOsgiServlet extends SlingSafeMethodsServlet {
@Activate
protected void Activate(Configuration config) {
boolean enabled = config.servletname_enabled();
}
@ObjectClassDefinition(name="OSGi Annotation Demo Servlet")
public @interface Configuration {
@AttributeDefinition(
name = "Enable",
description = "Enable the servlet"
)
boolean servletname_enabled() default false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment