Project

General

Profile

« Previous | Next » 

Revision 45127

codebase used to migrate to java8 the production system

View differences:

modules/cnr-enabling-hcm-service/trunk/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-enabling-hcm-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-enabling-hcm-service"}
modules/cnr-enabling-hcm-service/trunk/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriptionListFactory.java
1
package eu.dnetlib.enabling.hcm.sn;
2

  
3
import java.util.List;
4

  
5
import org.springframework.beans.factory.FactoryBean;
6
import org.springframework.beans.factory.annotation.Autowired;
7

  
8
import eu.dnetlib.enabling.actions.SubscriptionAction;
9

  
10
/**
11
 * This class acts as a simple registry of msro subscription actions.
12
 * 
13
 * <p>
14
 * Subscription actions are autodetected using spring autowiring from the current application context and are available for the manager for
15
 * handling subscriptions and delivering notification to particular code interested in those notifications.
16
 * </p>
17
 * 
18
 * @author marko
19
 * 
20
 */
21
@SuppressWarnings("rawtypes")
22
public class HCMSubscriptionListFactory implements FactoryBean {
23

  
24
	/**
25
	 * actions. Spring injects all the declared SubscriptionActions here.
26
	 */
27
	@Autowired(required = false)
28
	private List<SubscriptionAction> actions;
29

  
30
	public List<SubscriptionAction> getActions() {
31
		return actions;
32
	}
33

  
34
	public void setActions(final List<SubscriptionAction> actions) {
35
		this.actions = actions;
36
	}
37

  
38
	/**
39
	 * {@inheritDoc}
40
	 * 
41
	 * @see org.springframework.beans.factory.FactoryBean#getObject()
42
	 */
43
	@Override
44
	public Object getObject() {
45
		return getActions();
46
	}
47

  
48
	@Override
49
	public Class<?> getObjectType() {
50
		return null;
51
	}
52

  
53
	@Override
54
	public boolean isSingleton() {
55
		return false;
56
	}
57
}
modules/cnr-enabling-hcm-service/trunk/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriber.java
1
package eu.dnetlib.enabling.hcm.sn;
2

  
3
import eu.dnetlib.enabling.is.sn.rmi.ISSNException;
4

  
5
/**
6
 * This component takes care of subscribing the MSRO service to interesting events.
7
 * 
8
 * @author marko
9
 *
10
 */
11
public interface HCMSubscriber {
12
	/**
13
	 * performs the subscription.
14
	 * @throws ISSNException could happen
15
	 */
16
	void subscribeAll() throws ISSNException;
17
}
modules/cnr-enabling-hcm-service/trunk/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriberImpl.java
1
package eu.dnetlib.enabling.hcm.sn;
2

  
3
import java.util.List;
4

  
5
import javax.annotation.PostConstruct;
6
import javax.annotation.Resource;
7
import javax.xml.ws.Endpoint;
8
import javax.xml.ws.wsaddressing.W3CEndpointReference;
9

  
10
import org.apache.commons.logging.Log;
11
import org.apache.commons.logging.LogFactory;
12
import org.springframework.beans.factory.annotation.Required;
13

  
14
import eu.dnetlib.enabling.actions.SubscriptionAction;
15
import eu.dnetlib.enabling.is.sn.rmi.ISSNException;
16
import eu.dnetlib.enabling.is.sn.rmi.ISSNService;
17
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
18
import eu.dnetlib.soap.EndpointReferenceBuilder;
19

  
20
/**
21
 * This component takes care of subscribing the SubscriptionAction(s) to interesting events.
22
 * 
23
 * @author claudio
24
 * 
25
 */
26
public class HCMSubscriberImpl implements HCMSubscriber {
27

  
28
	/**
29
	 * logger.
30
	 */
31
	private static final Log log = LogFactory.getLog(HCMSubscriberImpl.class);
32

  
33
	/**
34
	 * notification endpoint (normally the msro service).
35
	 */
36
	private Endpoint endpoint;
37

  
38
	/**
39
	 * service locator.
40
	 */
41
	private UniqueServiceLocator serviceLocator;
42

  
43
	/**
44
	 * injected EPR builder.
45
	 */
46
	@Resource(name = "jaxwsEndpointReferenceBuilder")
47
	private EndpointReferenceBuilder<Endpoint> eprBuilder;
48

  
49
	/**
50
	 * subscription actions.
51
	 */
52
	private List<SubscriptionAction> actions;
53

  
54
	@PostConstruct
55
	public void printList() {
56
		log.info(getActions());
57
	}
58

  
59
	/**
60
	 * {@inheritDoc}
61
	 * 
62
	 * @throws ISSNException
63
	 *             could happen
64
	 * @see eu.dnetlib.enabling.hcm.sn.HCMSubscriber#subscribeAll()
65
	 */
66
	@Override
67
	public void subscribeAll() throws ISSNException {
68

  
69
		final W3CEndpointReference endpointReference = eprBuilder
70
				.getEndpointReference(getEndpoint());
71

  
72
		if (getActions() != null) {
73
			for (final SubscriptionAction action : getActions()) {
74
				log.info("dynamically subscribing to "
75
						+ action.getTopicExpression());
76
				serviceLocator.getService(ISSNService.class, true).subscribe(endpointReference,
77
						action.getTopicExpression(), 0);
78
			}
79
		}
80
	}
81

  
82
	public void setEndpoint(final Endpoint endpoint) {
83
		this.endpoint = endpoint;
84
	}
85

  
86
	public Endpoint getEndpoint() {
87
		return endpoint;
88
	}
89

  
90
	public void setEprBuilder(
91
			final EndpointReferenceBuilder<Endpoint> eprBuilder) {
92
		this.eprBuilder = eprBuilder;
93
	}
94

  
95
	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
96
		return eprBuilder;
97
	}
98

  
99
	public List<SubscriptionAction> getActions() {
100
		return actions;
101
	}
102

  
103
	@Required
104
	public void setActions(final List<SubscriptionAction> actions) {
105
		this.actions = actions;
106
	}
107

  
108
	public UniqueServiceLocator getServiceLocator() {
109
		return serviceLocator;
110
	}
111

  
112
	@Required
113
	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
114
		this.serviceLocator = serviceLocator;
115
	}
116

  
117
}
modules/cnr-enabling-hcm-service/trunk/src/main/java/eu/dnetlib/enabling/hcm/HostingContextManagerServiceImpl.java
1
package eu.dnetlib.enabling.hcm;
2

  
3
import org.apache.commons.logging.Log;
4
import org.apache.commons.logging.LogFactory;
5
import org.springframework.beans.factory.annotation.Required;
6

  
7
import eu.dnetlib.enabling.hcm.rmi.HostingContextManagerService;
8
import eu.dnetlib.enabling.tools.AbstractBaseService;
9
import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
10

  
11
/**
12
 * CNR HostingContextManagerService implementation. Will conflict with NKUA! yes this is ok.
13
 * 
14
 * @author marko
15
 * 
16
 */
17
public class HostingContextManagerServiceImpl extends AbstractBaseService implements HostingContextManagerService {
18

  
19
	/**
20
	 * logger.
21
	 */
22
	private static final Log log = LogFactory.getLog(HostingContextManagerServiceImpl.class); // NOPMD by marko on 11/24/08 5:02 PM
23

  
24
	/**
25
	 * notification handler.
26
	 */
27
	private NotificationHandler notificationHandler; // NOPMD
28

  
29
	@Override
30
	public void notify(String subscrId, String topic, String isId, String message) {
31
		if (log.isDebugEnabled()) {
32
			log.debug("---- service got notification ----");
33
			log.debug("subscrId: " + subscrId);
34
			log.debug("topic " + topic);
35
			log.debug("isId " + isId);
36
			log.debug("msg: " + message);
37
			log.debug("____ now processing the notification ____");
38
		}
39
		getNotificationHandler().notified(subscrId, topic, isId, message);
40
	}
41

  
42
	/**
43
	 * {@inheritDoc}
44
	 * 
45
	 * @see eu.dnetlib.enabling.tools.AbstractBaseService#start()
46
	 */
47
	@Override
48
	public void start() {
49
		log.info("staring hosting context manager");
50
	}
51

  
52
	public NotificationHandler getNotificationHandler() {
53
		return notificationHandler;
54
	}
55

  
56
	@Required
57
	public void setNotificationHandler(NotificationHandler notificationHandler) {
58
		this.notificationHandler = notificationHandler;
59
	}
60

  
61
}
modules/cnr-enabling-hcm-service/trunk/src/main/resources/eu/dnetlib/enabling/hcm/applicationContext-hcm.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
5
	xmlns:util="http://www.springframework.org/schema/util" xmlns:template="http://dnetlib.eu/springbeans/template"
6
	xmlns:t="http://dnetlib.eu/springbeans/t"
7
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
8
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
9
		http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
10
		http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd
11
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
12
	
13
	<!--  beans -->
14
	
15
	<bean id="hcmService"
16
		class="eu.dnetlib.enabling.hcm.HostingContextManagerServiceImpl"
17
		init-method="start" destroy-method="stop"  
18
		p:notificationHandler-ref="hcmNotificationHandler"/>
19
		
20
	<bean id="hcmNotificationHandler" class="eu.dnetlib.enabling.tools.blackboard.NotificationHandlerChainImpl"
21
		p:handlers-ref="dynamicSubscriptionActions">
22
		<property name="handlerExecutor">
23
			<bean class="org.springframework.core.task.SyncTaskExecutor" />
24
		</property>
25
	</bean>
26
	
27
	<bean id="dynamicSubscriptionActions"
28
		class="eu.dnetlib.enabling.hcm.sn.HCMSubscriptionListFactory" />
29
		
30
	<bean id="hcmSubscriber" class="eu.dnetlib.enabling.hcm.sn.HCMSubscriberImpl"
31
		p:endpoint-ref="hcmServiceEndpoint" p:serviceLocator-ref="uniqueServiceLocator" 
32
		p:actions-ref="dynamicSubscriptionActions" />
33
 		
34
	<bean t:id="hcmJobSchedulerAccessor"
35
		class="org.springframework.scheduling.quartz.SchedulerAccessorBean"
36
		p:scheduler-ref="jobScheduler">
37
		<property name="triggers">
38
			<list>
39
				<bean id="hcmSubscriptionTrigger"
40
					class="org.springframework.scheduling.quartz.SimpleTriggerBean"
41
					p:startDelay="6000" p:repeatCount="0">
42
					<property name="jobDetail">
43
						<bean id="hcmSubscriptionJobDetails"
44
							class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
45
							p:targetObject-ref="hcmSubscriber" p:targetMethod="subscribeAll" />
46
					</property>
47
				</bean>
48
			</list>
49
		</property>
50
	</bean>				
51

  
52
	<!-- endpoints -->
53
	<jaxws:endpoint id="hcmServiceEndpoint" implementor="#hcmService"
54
		implementorClass="eu.dnetlib.enabling.hcm.rmi.HostingContextManagerService"
55
		address="/hcm" />
56

  
57
	<template:instance name="serviceRegistrationManager"
58
		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
59
		t:name="hcmServiceRegistrationManager" t:service="hcmService"
60
		t:endpoint="hcmServiceEndpoint" t:jobScheduler="jobScheduler" />
61
</beans>
modules/cnr-enabling-hcm-service/trunk/pom.xml
1
<?xml version="1.0" ?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
	<parent>
4
		<groupId>eu.dnetlib</groupId>
5
		<artifactId>dnet-parent</artifactId>
6
		<version>1.0.0</version>
7
		<relativePath />
8
	</parent>
9
	<modelVersion>4.0.0</modelVersion>
10
	<groupId>eu.dnetlib</groupId>
11
	<artifactId>cnr-enabling-hcm-service</artifactId>
12
	<packaging>jar</packaging>
13
	<version>2.0.1-SNAPSHOT</version>
14
	<scm>
15
		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-enabling-hcm-service/trunk</developerConnection>
16
	</scm>
17
	<dependencies>
18
		<dependency>
19
			<groupId>eu.dnetlib</groupId>
20
			<artifactId>cnr-notifications-common</artifactId>
21
			<version>[2.0.0, 3.0.0)</version>
22
		</dependency>
23
	</dependencies>
24
</project>
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-1.0.0/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-enabling-hcm-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-enabling-hcm-service"}
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-1.0.0/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriptionListFactory.java
1
package eu.dnetlib.enabling.hcm.sn;
2

  
3
import java.util.List;
4

  
5
import javax.annotation.Resource;
6

  
7
import org.springframework.beans.factory.FactoryBean;
8
import org.springframework.beans.factory.annotation.Autowired;
9

  
10
import eu.dnetlib.enabling.actions.SubscriptionAction;
11

  
12
/**
13
 * This class acts as a simple registry of msro subscription actions.
14
 * 
15
 * <p>
16
 * Subscription actions are autodetected using spring autowiring from the current application context and are available for the manager for
17
 * handling subscriptions and delivering notification to particular code interested in those notifications.
18
 * </p>
19
 * 
20
 * @author marko
21
 * 
22
 */
23
@SuppressWarnings("rawtypes")
24
public class HCMSubscriptionListFactory implements FactoryBean {
25

  
26
	/**
27
	 * actions. Spring injects all the declared SubscriptionActions here.
28
	 */
29
	@Autowired(required=false)
30
	private List<SubscriptionAction> actions;
31

  
32
	public List<SubscriptionAction> getActions() {
33
		return actions;
34
	}
35

  
36
	public void setActions(final List<SubscriptionAction> actions) {
37
		this.actions = actions;
38
	}
39

  
40
	/**
41
	 * {@inheritDoc}
42
	 * 
43
	 * @see org.springframework.beans.factory.FactoryBean#getObject()
44
	 */
45
	@Override
46
	public Object getObject() {
47
		return getActions();
48
	}
49

  
50
	@Override
51
	public Class<?> getObjectType() {
52
		return null;
53
	}
54

  
55
	@Override
56
	public boolean isSingleton() {
57
		return false;
58
	}
59
}
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-1.0.0/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriber.java
1
package eu.dnetlib.enabling.hcm.sn;
2

  
3
import eu.dnetlib.enabling.is.sn.rmi.ISSNException;
4

  
5
/**
6
 * This component takes care of subscribing the MSRO service to interesting events.
7
 * 
8
 * @author marko
9
 *
10
 */
11
public interface HCMSubscriber {
12
	/**
13
	 * performs the subscription.
14
	 * @throws ISSNException could happen
15
	 */
16
	void subscribeAll() throws ISSNException;
17
}
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-1.0.0/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriberImpl.java
1
package eu.dnetlib.enabling.hcm.sn;
2

  
3
import java.util.List;
4

  
5
import javax.annotation.PostConstruct;
6
import javax.annotation.Resource;
7
import javax.xml.ws.Endpoint;
8
import javax.xml.ws.wsaddressing.W3CEndpointReference;
9

  
10
import org.apache.commons.logging.Log;
11
import org.apache.commons.logging.LogFactory;
12
import org.springframework.beans.factory.annotation.Required;
13

  
14
import eu.dnetlib.enabling.actions.SubscriptionAction;
15
import eu.dnetlib.enabling.is.sn.rmi.ISSNException;
16
import eu.dnetlib.enabling.is.sn.rmi.ISSNService;
17
import eu.dnetlib.enabling.tools.ServiceLocator;
18
import eu.dnetlib.soap.EndpointReferenceBuilder;
19

  
20
/**
21
 * This component takes care of subscribing the SubscriptionAction(s) to
22
 * interesting events.
23
 *
24
 * @author claudio
25
 *
26
 */
27
public class HCMSubscriberImpl implements HCMSubscriber {
28

  
29
	/**
30
	 * logger.
31
	 */
32
	private static final Log log = LogFactory.getLog(HCMSubscriberImpl.class); // NOPMD
33
																				// by
34
																				// marko
35
																				// on
36
																				// 11/24/08
37
																				// 5:02
38
																				// PM
39

  
40
	/**
41
	 * notification endpoint (normally the msro service).
42
	 */
43
	private Endpoint endpoint;
44

  
45
	/**
46
	 * is sn locator.
47
	 */
48
	private ServiceLocator<ISSNService> snLocator;
49

  
50
	/**
51
	 * injected EPR builder.
52
	 */
53
	@Resource(name = "jaxwsEndpointReferenceBuilder")
54
	private EndpointReferenceBuilder<Endpoint> eprBuilder;
55

  
56
	/**
57
	 * subscription actions.
58
	 */
59
	private List<SubscriptionAction> actions;
60

  
61
	@PostConstruct
62
	public void printList() {
63
		log.info(getActions());
64
	}
65

  
66
	/**
67
	 * {@inheritDoc}
68
	 *
69
	 * @throws ISSNException
70
	 *             could happen
71
	 * @see eu.dnetlib.enabling.hcm.sn.HCMSubscriber#subscribeAll()
72
	 */
73
	@Override
74
	public void subscribeAll() throws ISSNException {
75

  
76
		final W3CEndpointReference endpointReference = eprBuilder
77
				.getEndpointReference(getEndpoint());
78

  
79
		if (getActions() != null) {
80
			for (final SubscriptionAction action : getActions()) {
81
				log.info("dynamically subscribing to "
82
						+ action.getTopicExpression());
83
				snLocator.getService().subscribe(endpointReference,
84
						action.getTopicExpression(), 0);
85
			}
86
		}
87
	}
88

  
89
	public void setEndpoint(final Endpoint endpoint) {
90
		this.endpoint = endpoint;
91
	}
92

  
93
	public Endpoint getEndpoint() {
94
		return endpoint;
95
	}
96

  
97
	public void setEprBuilder(
98
			final EndpointReferenceBuilder<Endpoint> eprBuilder) {
99
		this.eprBuilder = eprBuilder;
100
	}
101

  
102
	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
103
		return eprBuilder;
104
	}
105

  
106
	public ServiceLocator<ISSNService> getSnLocator() {
107
		return snLocator;
108
	}
109

  
110
	public void setSnLocator(final ServiceLocator<ISSNService> snLocator) {
111
		this.snLocator = snLocator;
112
	}
113

  
114
	public List<SubscriptionAction> getActions() {
115
		return actions;
116
	}
117

  
118
	@Required
119
	public void setActions(final List<SubscriptionAction> actions) {
120
		this.actions = actions;
121
	}
122

  
123
}
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-1.0.0/src/main/java/eu/dnetlib/enabling/hcm/HostingContextManagerServiceImpl.java
1
package eu.dnetlib.enabling.hcm;
2

  
3
import org.apache.commons.logging.Log;
4
import org.apache.commons.logging.LogFactory;
5
import org.springframework.beans.factory.annotation.Required;
6

  
7
import eu.dnetlib.enabling.hcm.rmi.HostingContextManagerService;
8
import eu.dnetlib.enabling.tools.AbstractBaseService;
9
import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
10

  
11
/**
12
 * CNR HostingContextManagerService implementation. Will conflict with NKUA! yes this is ok.
13
 * 
14
 * @author marko
15
 * 
16
 */
17
public class HostingContextManagerServiceImpl extends AbstractBaseService implements HostingContextManagerService {
18

  
19
	/**
20
	 * logger.
21
	 */
22
	private static final Log log = LogFactory.getLog(HostingContextManagerServiceImpl.class); // NOPMD by marko on 11/24/08 5:02 PM
23

  
24
	/**
25
	 * notification handler.
26
	 */
27
	private NotificationHandler notificationHandler; // NOPMD
28

  
29
	@Override
30
	public void notify(String subscrId, String topic, String isId, String message) {
31
		if (log.isDebugEnabled()) {
32
			log.debug("---- service got notification ----");
33
			log.debug("subscrId: " + subscrId);
34
			log.debug("topic " + topic);
35
			log.debug("isId " + isId);
36
			log.debug("msg: " + message);
37
			log.debug("____ now processing the notification ____");
38
		}
39
		getNotificationHandler().notified(subscrId, topic, isId, message);
40
	}
41

  
42
	/**
43
	 * {@inheritDoc}
44
	 * 
45
	 * @see eu.dnetlib.enabling.tools.AbstractBaseService#start()
46
	 */
47
	@Override
48
	public void start() {
49
		log.info("staring hosting context manager");
50
	}
51

  
52
	public NotificationHandler getNotificationHandler() {
53
		return notificationHandler;
54
	}
55

  
56
	@Required
57
	public void setNotificationHandler(NotificationHandler notificationHandler) {
58
		this.notificationHandler = notificationHandler;
59
	}
60

  
61
}
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-1.0.0/src/main/resources/eu/dnetlib/enabling/hcm/applicationContext-hcm.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
5
	xmlns:util="http://www.springframework.org/schema/util" xmlns:template="http://dnetlib.eu/springbeans/template"
6
	xmlns:t="http://dnetlib.eu/springbeans/t"
7
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
8
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
9
		http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
10
		http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd
11
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
12
	
13
	<!--  beans -->
14
	
15
	<bean id="hcmService"
16
		class="eu.dnetlib.enabling.hcm.HostingContextManagerServiceImpl"
17
		init-method="start" destroy-method="stop"  
18
		p:notificationHandler-ref="hcmNotificationHandler"/>
19
		
20
	<bean id="hcmNotificationHandler" class="eu.dnetlib.enabling.tools.blackboard.NotificationHandlerChainImpl"
21
		p:handlers-ref="dynamicSubscriptionActions">
22
		<property name="handlerExecutor">
23
			<bean class="org.springframework.core.task.SyncTaskExecutor" />
24
		</property>
25
	</bean>
26
	
27
	<bean id="dynamicSubscriptionActions"
28
		class="eu.dnetlib.enabling.hcm.sn.HCMSubscriptionListFactory" />
29
		
30
	<bean id="hcmSubscriber" class="eu.dnetlib.enabling.hcm.sn.HCMSubscriberImpl"
31
		p:endpoint-ref="hcmServiceEndpoint" p:snLocator-ref="snLocator" 
32
		p:actions-ref="dynamicSubscriptionActions" />
33
 		
34
	<bean t:id="hcmJobSchedulerAccessor"
35
		class="org.springframework.scheduling.quartz.SchedulerAccessorBean"
36
		p:scheduler-ref="jobScheduler">
37
		<property name="triggers">
38
			<list>
39
				<bean id="hcmSubscriptionTrigger"
40
					class="org.springframework.scheduling.quartz.SimpleTriggerBean"
41
					p:startDelay="6000" p:repeatCount="0">
42
					<property name="jobDetail">
43
						<bean id="hcmSubscriptionJobDetails"
44
							class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
45
							p:targetObject-ref="hcmSubscriber" p:targetMethod="subscribeAll" />
46
					</property>
47
				</bean>
48
			</list>
49
		</property>
50
	</bean>				
51

  
52
	<!-- endpoints -->
53
	<jaxws:endpoint id="hcmServiceEndpoint" implementor="#hcmService"
54
		implementorClass="eu.dnetlib.enabling.hcm.rmi.HostingContextManagerService"
55
		address="/hcm" />
56

  
57
	<template:instance name="serviceRegistrationManager"
58
		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
59
		t:name="hcmServiceRegistrationManager" t:service="hcmService"
60
		t:endpoint="hcmServiceEndpoint" t:jobScheduler="jobScheduler" />
61
</beans>
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-1.0.0/pom.xml
1
<?xml version="1.0" ?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
	<parent>
4
		<groupId>eu.dnetlib</groupId>
5
		<artifactId>dnet-parent</artifactId>
6
		<version>1.0.0</version>
7
		<relativePath />
8
	</parent>
9
	<modelVersion>4.0.0</modelVersion>
10
	<groupId>eu.dnetlib</groupId>
11
	<artifactId>cnr-enabling-hcm-service</artifactId>
12
	<packaging>jar</packaging>
13
	<version>1.0.0</version>
14
	<scm>
15
		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-1.0.0</developerConnection>
16
	</scm>
17
	<dependencies>
18
		<dependency>
19
			<groupId>eu.dnetlib</groupId>
20
			<artifactId>cnr-notifications-common</artifactId>
21
			<version>[1.0.0, 2.0.0)</version>
22
		</dependency>
23
	</dependencies>
24
</project>
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-2.0.0/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-enabling-hcm-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-enabling-hcm-service"}
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-2.0.0/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriptionListFactory.java
1
package eu.dnetlib.enabling.hcm.sn;
2

  
3
import java.util.List;
4

  
5
import org.springframework.beans.factory.FactoryBean;
6
import org.springframework.beans.factory.annotation.Autowired;
7

  
8
import eu.dnetlib.enabling.actions.SubscriptionAction;
9

  
10
/**
11
 * This class acts as a simple registry of msro subscription actions.
12
 * 
13
 * <p>
14
 * Subscription actions are autodetected using spring autowiring from the current application context and are available for the manager for
15
 * handling subscriptions and delivering notification to particular code interested in those notifications.
16
 * </p>
17
 * 
18
 * @author marko
19
 * 
20
 */
21
@SuppressWarnings("rawtypes")
22
public class HCMSubscriptionListFactory implements FactoryBean {
23

  
24
	/**
25
	 * actions. Spring injects all the declared SubscriptionActions here.
26
	 */
27
	@Autowired(required = false)
28
	private List<SubscriptionAction> actions;
29

  
30
	public List<SubscriptionAction> getActions() {
31
		return actions;
32
	}
33

  
34
	public void setActions(final List<SubscriptionAction> actions) {
35
		this.actions = actions;
36
	}
37

  
38
	/**
39
	 * {@inheritDoc}
40
	 * 
41
	 * @see org.springframework.beans.factory.FactoryBean#getObject()
42
	 */
43
	@Override
44
	public Object getObject() {
45
		return getActions();
46
	}
47

  
48
	@Override
49
	public Class<?> getObjectType() {
50
		return null;
51
	}
52

  
53
	@Override
54
	public boolean isSingleton() {
55
		return false;
56
	}
57
}
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-2.0.0/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriber.java
1
package eu.dnetlib.enabling.hcm.sn;
2

  
3
import eu.dnetlib.enabling.is.sn.rmi.ISSNException;
4

  
5
/**
6
 * This component takes care of subscribing the MSRO service to interesting events.
7
 * 
8
 * @author marko
9
 *
10
 */
11
public interface HCMSubscriber {
12
	/**
13
	 * performs the subscription.
14
	 * @throws ISSNException could happen
15
	 */
16
	void subscribeAll() throws ISSNException;
17
}
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-2.0.0/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriberImpl.java
1
package eu.dnetlib.enabling.hcm.sn;
2

  
3
import java.util.List;
4

  
5
import javax.annotation.PostConstruct;
6
import javax.annotation.Resource;
7
import javax.xml.ws.Endpoint;
8
import javax.xml.ws.wsaddressing.W3CEndpointReference;
9

  
10
import org.apache.commons.logging.Log;
11
import org.apache.commons.logging.LogFactory;
12
import org.springframework.beans.factory.annotation.Required;
13

  
14
import eu.dnetlib.enabling.actions.SubscriptionAction;
15
import eu.dnetlib.enabling.is.sn.rmi.ISSNException;
16
import eu.dnetlib.enabling.is.sn.rmi.ISSNService;
17
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
18
import eu.dnetlib.soap.EndpointReferenceBuilder;
19

  
20
/**
21
 * This component takes care of subscribing the SubscriptionAction(s) to interesting events.
22
 * 
23
 * @author claudio
24
 * 
25
 */
26
public class HCMSubscriberImpl implements HCMSubscriber {
27

  
28
	/**
29
	 * logger.
30
	 */
31
	private static final Log log = LogFactory.getLog(HCMSubscriberImpl.class);
32

  
33
	/**
34
	 * notification endpoint (normally the msro service).
35
	 */
36
	private Endpoint endpoint;
37

  
38
	/**
39
	 * service locator.
40
	 */
41
	private UniqueServiceLocator serviceLocator;
42

  
43
	/**
44
	 * injected EPR builder.
45
	 */
46
	@Resource(name = "jaxwsEndpointReferenceBuilder")
47
	private EndpointReferenceBuilder<Endpoint> eprBuilder;
48

  
49
	/**
50
	 * subscription actions.
51
	 */
52
	private List<SubscriptionAction> actions;
53

  
54
	@PostConstruct
55
	public void printList() {
56
		log.info(getActions());
57
	}
58

  
59
	/**
60
	 * {@inheritDoc}
61
	 * 
62
	 * @throws ISSNException
63
	 *             could happen
64
	 * @see eu.dnetlib.enabling.hcm.sn.HCMSubscriber#subscribeAll()
65
	 */
66
	@Override
67
	public void subscribeAll() throws ISSNException {
68

  
69
		final W3CEndpointReference endpointReference = eprBuilder
70
				.getEndpointReference(getEndpoint());
71

  
72
		if (getActions() != null) {
73
			for (final SubscriptionAction action : getActions()) {
74
				log.info("dynamically subscribing to "
75
						+ action.getTopicExpression());
76
				serviceLocator.getService(ISSNService.class, true).subscribe(endpointReference,
77
						action.getTopicExpression(), 0);
78
			}
79
		}
80
	}
81

  
82
	public void setEndpoint(final Endpoint endpoint) {
83
		this.endpoint = endpoint;
84
	}
85

  
86
	public Endpoint getEndpoint() {
87
		return endpoint;
88
	}
89

  
90
	public void setEprBuilder(
91
			final EndpointReferenceBuilder<Endpoint> eprBuilder) {
92
		this.eprBuilder = eprBuilder;
93
	}
94

  
95
	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
96
		return eprBuilder;
97
	}
98

  
99
	public List<SubscriptionAction> getActions() {
100
		return actions;
101
	}
102

  
103
	@Required
104
	public void setActions(final List<SubscriptionAction> actions) {
105
		this.actions = actions;
106
	}
107

  
108
	public UniqueServiceLocator getServiceLocator() {
109
		return serviceLocator;
110
	}
111

  
112
	@Required
113
	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
114
		this.serviceLocator = serviceLocator;
115
	}
116

  
117
}
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-2.0.0/src/main/java/eu/dnetlib/enabling/hcm/HostingContextManagerServiceImpl.java
1
package eu.dnetlib.enabling.hcm;
2

  
3
import org.apache.commons.logging.Log;
4
import org.apache.commons.logging.LogFactory;
5
import org.springframework.beans.factory.annotation.Required;
6

  
7
import eu.dnetlib.enabling.hcm.rmi.HostingContextManagerService;
8
import eu.dnetlib.enabling.tools.AbstractBaseService;
9
import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
10

  
11
/**
12
 * CNR HostingContextManagerService implementation. Will conflict with NKUA! yes this is ok.
13
 * 
14
 * @author marko
15
 * 
16
 */
17
public class HostingContextManagerServiceImpl extends AbstractBaseService implements HostingContextManagerService {
18

  
19
	/**
20
	 * logger.
21
	 */
22
	private static final Log log = LogFactory.getLog(HostingContextManagerServiceImpl.class); // NOPMD by marko on 11/24/08 5:02 PM
23

  
24
	/**
25
	 * notification handler.
26
	 */
27
	private NotificationHandler notificationHandler; // NOPMD
28

  
29
	@Override
30
	public void notify(String subscrId, String topic, String isId, String message) {
31
		if (log.isDebugEnabled()) {
32
			log.debug("---- service got notification ----");
33
			log.debug("subscrId: " + subscrId);
34
			log.debug("topic " + topic);
35
			log.debug("isId " + isId);
36
			log.debug("msg: " + message);
37
			log.debug("____ now processing the notification ____");
38
		}
39
		getNotificationHandler().notified(subscrId, topic, isId, message);
40
	}
41

  
42
	/**
43
	 * {@inheritDoc}
44
	 * 
45
	 * @see eu.dnetlib.enabling.tools.AbstractBaseService#start()
46
	 */
47
	@Override
48
	public void start() {
49
		log.info("staring hosting context manager");
50
	}
51

  
52
	public NotificationHandler getNotificationHandler() {
53
		return notificationHandler;
54
	}
55

  
56
	@Required
57
	public void setNotificationHandler(NotificationHandler notificationHandler) {
58
		this.notificationHandler = notificationHandler;
59
	}
60

  
61
}
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-2.0.0/src/main/resources/eu/dnetlib/enabling/hcm/applicationContext-hcm.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
5
	xmlns:util="http://www.springframework.org/schema/util" xmlns:template="http://dnetlib.eu/springbeans/template"
6
	xmlns:t="http://dnetlib.eu/springbeans/t"
7
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
8
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
9
		http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
10
		http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd
11
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
12
	
13
	<!--  beans -->
14
	
15
	<bean id="hcmService"
16
		class="eu.dnetlib.enabling.hcm.HostingContextManagerServiceImpl"
17
		init-method="start" destroy-method="stop"  
18
		p:notificationHandler-ref="hcmNotificationHandler"/>
19
		
20
	<bean id="hcmNotificationHandler" class="eu.dnetlib.enabling.tools.blackboard.NotificationHandlerChainImpl"
21
		p:handlers-ref="dynamicSubscriptionActions">
22
		<property name="handlerExecutor">
23
			<bean class="org.springframework.core.task.SyncTaskExecutor" />
24
		</property>
25
	</bean>
26
	
27
	<bean id="dynamicSubscriptionActions"
28
		class="eu.dnetlib.enabling.hcm.sn.HCMSubscriptionListFactory" />
29
		
30
	<bean id="hcmSubscriber" class="eu.dnetlib.enabling.hcm.sn.HCMSubscriberImpl"
31
		p:endpoint-ref="hcmServiceEndpoint" p:serviceLocator-ref="uniqueServiceLocator" 
32
		p:actions-ref="dynamicSubscriptionActions" />
33
 		
34
	<bean t:id="hcmJobSchedulerAccessor"
35
		class="org.springframework.scheduling.quartz.SchedulerAccessorBean"
36
		p:scheduler-ref="jobScheduler">
37
		<property name="triggers">
38
			<list>
39
				<bean id="hcmSubscriptionTrigger"
40
					class="org.springframework.scheduling.quartz.SimpleTriggerBean"
41
					p:startDelay="6000" p:repeatCount="0">
42
					<property name="jobDetail">
43
						<bean id="hcmSubscriptionJobDetails"
44
							class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
45
							p:targetObject-ref="hcmSubscriber" p:targetMethod="subscribeAll" />
46
					</property>
47
				</bean>
48
			</list>
49
		</property>
50
	</bean>				
51

  
52
	<!-- endpoints -->
53
	<jaxws:endpoint id="hcmServiceEndpoint" implementor="#hcmService"
54
		implementorClass="eu.dnetlib.enabling.hcm.rmi.HostingContextManagerService"
55
		address="/hcm" />
56

  
57
	<template:instance name="serviceRegistrationManager"
58
		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
59
		t:name="hcmServiceRegistrationManager" t:service="hcmService"
60
		t:endpoint="hcmServiceEndpoint" t:jobScheduler="jobScheduler" />
61
</beans>
modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-2.0.0/pom.xml
1
<?xml version="1.0" ?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
	<parent>
4
		<groupId>eu.dnetlib</groupId>
5
		<artifactId>dnet-parent</artifactId>
6
		<version>1.0.0</version>
7
		<relativePath />
8
	</parent>
9
	<modelVersion>4.0.0</modelVersion>
10
	<groupId>eu.dnetlib</groupId>
11
	<artifactId>cnr-enabling-hcm-service</artifactId>
12
	<packaging>jar</packaging>
13
	<version>2.0.0</version>
14
	<scm>
15
		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-enabling-hcm-service/tags/cnr-enabling-hcm-service-2.0.0</developerConnection>
16
	</scm>
17
	<dependencies>
18
		<dependency>
19
			<groupId>eu.dnetlib</groupId>
20
			<artifactId>cnr-notifications-common</artifactId>
21
			<version>[2.0.0, 3.0.0)</version>
22
		</dependency>
23
	</dependencies>
24
</project>

Also available in: Unified diff