Skip to Content
author's profile photo
Former Member

Problem with Portal Service

Hi All

I have developed a portal service which captures the KM events and call the event handler based on the event type. Service is working fine immediately after deployment. If i try sometime later,the desired funtion is not achieved though the service status is shown as <b>started</b> in portal.

I have registered for the events in afterInit() method as follows:

public void afterInit()

{

try {

//Registering the resource to the KM event

EventHandler handler = new EventHandler();

handler.register();

} catch (Exception e) {

e.printStackTrace();

}

}

I have also specified the property <b>startup</b> as true in the service-config section of portalapp.xml.

<b>portalapp.xml:</b>

=================

<?xml version="1.0" encoding="utf-8"?>

<application>

<application-config>

<property name="PrivateSharingReference" value="com.sap.portal.htmlb,com.sap.km.application"/>

</application-config>

<components/>

<services>

<service name="TestService">

<service-config>

<property name="className" value="com.test.TestService"/>

<property name="startup" value="true"/>

</service-config>

<service-profile>

<property name="MyProperty" value="true"/>

</service-profile>

</service>

</services>

</application>

Any solution to solve this problem?

Thanks in advance.

Regards,

Yoga

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    author's profile photo
    Former Member
    Posted on Sep 27, 2007 at 05:00 PM

    check if u have defined valid unique KEY in your service.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Couldn't make out what the issue was in your code. The portalapp.xml seems to be fine. I have a following piece of code that does the same job and it works fine with me. Find below the code.

      Following is the code for the Event Handler I have written.

      	static class MyEventReceiver implements IResourceEventReceiver
      	{
      		
      		private static IResourceEvent DELETE_EVENT = new ResourceEvent(ResourceEvent.DELETE, null);   
      		private static IResourceEvent MOVE_EVENT   = new ResourceEvent(ResourceEvent.MOVE, null);   
      		private static IResourceEvent RENAME_EVENT = new ResourceEvent(ResourceEvent.RENAME, null);
      		private static IResourceEvent COLLECTION_CREATE_EVENT = new ResourceEvent(ResourceEvent.CREATE_COLLECTION, null);
      		private static IResourceEvent COLLECTION_COPY_EVENT = new ResourceEvent(ResourceEvent.COPY, null);
      		private static IStatemanagementEvent PUBLISH_EVENT = new StatemanagementEvent(StatemanagementEvent.PUBLISH,null);
         		ILogger log = PortalRuntime.getLogger();
      		
      		  public void register(IResource resource) throws WcmException 
      		  { 
      		   IResourceEventBroker broker = resource.getRepositoryManager().getEventBroker();     
      		   if( broker == null ) return; 
      
      			  broker.register(this, DELETE_EVENT, IEventBroker.PRIO_MIN, true);     
      			  broker.register(this, MOVE_EVENT, IEventBroker.PRIO_MIN, true);     
      			  broker.register(this, RENAME_EVENT, IEventBroker.PRIO_MIN, true);   
      			  broker.register(this, COLLECTION_CREATE_EVENT, IEventBroker.PRIO_MIN, true);
      			  broker.register(this, COLLECTION_COPY_EVENT, IEventBroker.PRIO_MIN, true);
      			  broker.register(this, PUBLISH_EVENT, IEventBroker.PRIO_MIN,true);
      			  
      		  } 
      
      		  public void unregister(IResource resource) throws WcmException 
      		  { 
      		   IResourceEventBroker broker = resource.getRepositoryManager().getEventBroker();     
      		   if( broker == null ) return; 
      
      		   broker.unregister(this, DELETE_EVENT);     
      		   broker.unregister(this, MOVE_EVENT);     
      		   broker.unregister(this, RENAME_EVENT);   
      		   broker.unregister(this, COLLECTION_CREATE_EVENT);
      		   broker.unregister(this, COLLECTION_COPY_EVENT);
      		   broker.unregister(this,PUBLISH_EVENT);
      		  } 
                        
                        public void received(IEvent event) 
      		  {
                                 // event handling code goes here.
                        }
      }
      

      The following code is for registering the event listener. I have done it in the init() however, is should not be a problem if you do it in the afterInit() as well.

      IResource resource = 
      							  (IResource)iResFactory.getResource(resourceId,resContext);
      					  eventReceiver = new MyEventReceiver();
      					  			eventReceiver.register(resource);						  	
      				} catch (Exception e) {
      					// TODO: handle exception
      				}
      

      Moreover, I have unregistered the code in the destroy method of hte service.

      Hope this helps.

      Pradeep.