Hi,
Good Day!
I have a question, in our AEM as a Managed Service instance we have 2 Create Asset Servlet. which are interfering with each other. Basically if both of the servlets are in running condition, we are not able to upload any asset.
AEM default Asset upload servlet ----> com.day.cq.dam.core.impl.servlet.CreateAssetServlet
Custom built servlet -----> com.custombuilt.aem.servlets.CreateAssetServlet
The mentioned custom built servlet for asset upload is interfering with the default servlet. We have to disable it whenever our author server is getting restarted.
For some reason we cannot remove the mentioned servlet in a new AEM build, is there a way to permanently disable the custom built servlet without removing it.
Thank You in advance.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
HI @Nitesh-Chavan ,
It seems you want to trigger the custom servlet when your instance is completely up, AEM is built on OSGi, and you can listen to lifecycle events to determine when the instance is active. Implement an OSGi component that listens for the FrameworkEvent.STARTED
event, which indicates that the OSGi framework has started.
Sample code:
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
@Component(immediate = true)
public class InstanceActiveListener implements FrameworkListener {
@Activate
protected void activate(BundleContext bundleContext) {
bundleContext.addFrameworkListener(this);
}
@Override
public void frameworkEvent(FrameworkEvent event) {
if (event.getType() == FrameworkEvent.STARTED) {
// Trigger your servlet logic here
triggerServlet();
}
}
private void triggerServlet() {
// Logic to trigger the servlet
}
}
-Tarun
Can you share the use case of Custom built servlet? When is it needed? Why It can't be deleted? Is it in use somewhere?
Views
Replies
Total Likes
Hi @Nitesh-Chavan,
You can consider to use OSGi Component Disabler from ACS Commons, to disable CreateAssetServlet or any other OSGi component.
In case you can not use ACS Commons, you can implement similar mechanism in your project base on ACS Commons implementation:
We have ACS Commons in our environment, But I was not aware that we can disable the OSGi Component using it.
I will check these blog, and I will get back to you if I have any questions.
Thank You.
Views
Replies
Total Likes
Define a lower service ranking for the Custom Servlet. It would assure that the OOTB one is prioritized by OSGi . Example:
@Component(service = Servlet.class,
property = { Constants.SERVICE_DESCRIPTION + "=Custom Asset Create servlet", Constants.SERVICE_RANKING+ ":Integer=-700"
"sling.servlet.methods=" + HttpConstants.METHOD_GET, "sling.servlet.paths=" + "/bin/createpage" })
If you want to learn more about Service Ranking, visit https://sling.apache.org/documentation/the-sling-engine/servlets.html#servlet-resolution-order-1
I will check service ranking blog, and I will get back to you if I have any questions.
Views
Replies
Total Likes