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.
토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.
조회 수
답글
좋아요 수
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?
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.
조회 수
답글
좋아요 수
Hi @lukasz-m Sir,
Good Day!
I have checked but I was not able to find the xml that is referred in the given blog under ACS Commons.
I can see the below mentioned nodes only.
/apps/acs-commons/config/com.adobe.acs.commons.users.impl.EnsureServiceUser-AutomaticPackageReplication
/apps/acs-commons/config/com.adobe.acs.commons.users.impl.EnsureServiceUser-FileFetch
/apps/acs-commons/config/com.adobe.acs.commons.users.impl.EnsureServiceUser-RemoteAssets
/apps/acs-commons/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-acs-commons
I am now checking with the second option, I will get back to you with my comments.
Thank You.
조회 수
답글
좋아요 수
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.
조회 수
답글
좋아요 수
@Nitesh-Chavan Did you find the suggestions helpful? If you need more information, please let us know. If a response resolved your issue, kindly mark it as correct to help others in the future. Alternatively, if you discovered a solution on your own, we'd appreciate it if you could share it with the community. Thank you.
조회 수
답글
좋아요 수
조회 수
Likes
답글
조회 수
Likes
답글