2016-08-10 8 views
0

페이지 활성화를 수신하지만 게시 환경에서 수신 대기하는 리스너를 작성하려고합니다. 필자가 작성한 코드는 제작자 환경에서 작동하지만 게시하지 않습니다. 즉, 게시 환경에서도 복제를 수신하지 않습니다. 기본 코드를 첨부했습니다. 어떤 도움을 주셔서 감사합니다.publish aem의 복제 리스너

package com.whirlpool.portal.services.listeners; 

import org.apache.felix.scr.annotations.Component; 
import org.apache.felix.scr.annotations.Properties; 
import org.apache.felix.scr.annotations.Property; 
import org.apache.felix.scr.annotations.Service; 
import org.osgi.framework.BundleContext; 
import org.osgi.service.component.ComponentContext; 
import org.osgi.service.event.Event; 
import org.osgi.service.event.EventConstants; 
import org.osgi.service.event.EventHandler; 
import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 

import com.day.cq.replication.ReplicationAction; 
import com.day.cq.workflow.event.WorkflowEvent; 
//Sling Imports 


/** 
* Just a simple DS Component 
*/ 
@Component 
@Service 
@Properties({ 
    @Property(
      label = "Event Topics", 
      value = { ReplicationAction.EVENT_TOPIC }, 
      description = "[Required] Event Topics this event handler will to respond to.", 
      name = EventConstants.EVENT_TOPIC, 
      propertyPrivate = true 
    ), 
    @Property(
      label = "Event Filters", 
      value = "(" + ReplicationAction.PROPERTY_TYPE + "=ACTIVATE)", 
      name = EventConstants.EVENT_FILTER, 
      propertyPrivate = true 
    ) 
}) 
public class SimpleDSComponent implements Runnable, EventHandler { 

    private Logger log = LoggerFactory.getLogger(this.getClass()); 



    private BundleContext bundleContext; 


    public void handleEvent(Event event) { 

     String n[] = event.getPropertyNames(); 

     log.info(""); 

     log.info("Event occurred: {}", event.getProperty(WorkflowEvent.EVENT_TYPE)); 

     log.info("Event properties: "); 

     for(String s : n) { 

      log.info(s + " = " + event.getProperty(s)); 

     } 



     ReplicationAction action = ReplicationAction.fromEvent(event); 

     if(action != null) { 

      log.info("Replication action {} occured on {} ", action.getType().getName(), action.getPath()); 
      log.info("Tushar Replication"); 

     } 

     log.info(""); 

    } 


    public void run() { 
     log.info("Running..."); 
    } 

    protected void activate(ComponentContext ctx) { 
     this.bundleContext = ctx.getBundleContext(); 
    } 

    protected void deactivate(ComponentContext ctx) { 
     this.bundleContext = null; 
    } 

} 
+0

게시 env에서 관리자/복제 액세스 권한이있는 경우 게시 할 때 페이지를 활성화 해 볼 수 있습니까? 나는 "Activate"가 작성자에게 일어나므로 복제 이벤트가 "Activate"가 작성자에 대해 트리거되었다고 생각합니다. –

+0

게시시 수동 활성화가 유효한 사용 사례가 아니지만. 게시에서 다른 게시 서버로 활성화를 릴레이 할 때 사용되는 Replication Agent의 OnRecieve 구성이 있습니다. –

+2

활성화가 게시자의 POST 이상을 수행하지 않으므로 게시 환경의 노드에 "만들기"및 "수정"수신기가있을 것이라고 생각합니다. Sandeep이 언급 한 것처럼 activate 이벤트는 작성자에게만 발생합니다. – Thomas

답변