OW2 Consortium aspire

Rev

Rev 962 | Rev 969 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
945 nkef 1
package org.ow2.aspirerfid.ale.core;
2
 
3
 
4
import java.util.Dictionary;
5
import java.util.Hashtable;
6
 
7
import org.osgi.framework.BundleActivator;
8
import org.osgi.framework.BundleContext;
9
//import org.osgi.framework.ServiceEvent;
10
//import org.osgi.framework.ServiceListener;
11
import org.osgi.framework.ServiceRegistration;
962 nkef 12
 
13
 
14
 
945 nkef 15
import org.ow2.aspirerfid.commons.ale.wsdl.alelr.ALELRServicePortType;
16
import org.ow2.aspirerfid.commons.ale.wsdl.ale.ALEServicePortType;
957 nkef 17
import org.ow2.aspirerfid.ale.core.impl.ALELRServicePortTypeImpl;
18
import org.ow2.aspirerfid.ale.core.impl.ALEServicePortTypeImpl;
962 nkef 19
 
20
 
945 nkef 21
//import org.slf4j.Marker;
22
//import org.slf4j.MarkerFactory;
23
//import org.slf4j.helpers.*;
24
//import org.slf4j.impl.*;
25
//import org.slf4j.spi.*;
26
 
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
962 nkef 29
 
30
 
945 nkef 31
import ch.qos.logback.classic.LoggerContext;
32
import ch.qos.logback.core.util.StatusPrinter;
33
 
34
 
35
//import org.osgi.service.log.*;
36
 
37
import ch.qos.logback.classic.BasicConfigurator;
38
 
39
 
40
//import org.ow2.aspirerfid.commons.ale.model.ale.ECBoundarySpec;
41
 
42
//import org.ow2.aspirerfid.commons.ale.wsdl.alelr.ALELRService;
43
//import org.ow2.aspirerfid.commons.ale.wsdl.ale.ALEService;
44
 
45
public class Activator implements BundleActivator { // ServiceListener
968 nkef 46
 
945 nkef 47
	private ServiceRegistration aleServiceRegistration;
48
	private ServiceRegistration aleLrServiceRegistration;
968 nkef 49
;
945 nkef 50
 
957 nkef 51
    final private static String PROPERTY_BASE_NAME = "org.apache.cxf.ws";
945 nkef 52
 
53
 
54
	// public void serviceChanged(ServiceEvent serviceEvent) {
55
	// // TODO Auto-generated method stub
56
	//
57
	// }
58
 
59
 
968 nkef 60
 
945 nkef 61
 
62
 
63
	public void start(BundleContext bundleContext) throws Exception {
64
 
65
		    //Initialize the Logger
66
		    Logger logger = LoggerFactory.getLogger(Activator.class.getName());
67
		    // print Logger's internal state
68
		    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
69
		    StatusPrinter.print(lc);
70
 
957 nkef 71
 
945 nkef 72
 
957 nkef 73
		// ===================Initialize ALE Service using CXF JAX-WS frontend ===========
962 nkef 74
		Dictionary aleDictionaryProps = new Hashtable();
945 nkef 75
		String aleServiceURL = bundleContext.getProperty("org.ow2.aspirerfid.ale.core.aleServiceURL");
76
 
957 nkef 77
 
78
		aleDictionaryProps.put("service.exported.interfaces", "org.ow2.aspirerfid.commons.ale.wsdl.ale.ALEServicePortType");
945 nkef 79
		aleDictionaryProps.put("service.exported.configs", "org.apache.cxf.ws");
80
		aleDictionaryProps.put("org.apache.cxf.ws.address", aleServiceURL);
81
 
957 nkef 82
		aleDictionaryProps.put(PROPERTY_BASE_NAME + ".frontend", "jaxws");
968 nkef 83
		aleDictionaryProps.put("org.apache.cxf.ws.databinding","jaxb");
962 nkef 84
//		aleDictionaryProps.put(PROPERTY_BASE_NAME + ".service.ns", "http://ale.wsdl.ale.commons.aspirerfid.ow2.org"); // service namespace
85
		aleDictionaryProps.put(PROPERTY_BASE_NAME + ".service.name", "ALEService"); // service name
86
		aleDictionaryProps.put(PROPERTY_BASE_NAME + ".port.name", "ALEServicePort"); // port/endpoint name
957 nkef 87
		aleDictionaryProps.put(PROPERTY_BASE_NAME + ".location", "epcglobal/ale/EPCglobal-ale-1_1-ale.wsdl");
968 nkef 88
 
957 nkef 89
 
90
 
945 nkef 91
 
957 nkef 92
 
93
 
945 nkef 94
		aleServiceRegistration = bundleContext.registerService(ALEServicePortType.class.getName(),
957 nkef 95
				new ALEServicePortTypeImpl(), aleDictionaryProps);
945 nkef 96
 
97
		System.out.println("#########Service listens to : "+aleServiceURL+"  #########");
98
 
968 nkef 99
		// ===================Initialize ALELR Service (using CXF 'simple' frontend) ===========
945 nkef 100
 
962 nkef 101
		Dictionary aleLrDictionaryProps = new Hashtable();
945 nkef 102
		String aleLrServiceURL = bundleContext.getProperty("org.ow2.aspirerfid.ale.core.aleLrServiceURL");
103
 
104
		aleLrDictionaryProps.put("service.exported.interfaces", "*");
105
		aleLrDictionaryProps.put("service.exported.configs", "org.apache.cxf.ws");
106
		aleLrDictionaryProps.put("org.apache.cxf.ws.address", aleLrServiceURL);
107
 
108
		aleLrServiceRegistration = bundleContext.registerService(ALELRServicePortType.class.getName(),
957 nkef 109
				new ALELRServicePortTypeImpl(), aleLrDictionaryProps);
945 nkef 110
 
111
		System.out.println("#########Service listens to : "+aleLrServiceURL+"  #########");
112
 
113
 
114
 
962 nkef 115
 
116
 
945 nkef 117
	    logger.debug("Hello world by Logger. From : {}",Activator.class.getName());
118
 
119
	}
120
 
121
	public void stop(BundleContext arg0) throws Exception {
122
		System.out.println("Goodbye World");
123
		aleServiceRegistration.unregister();
124
		aleLrServiceRegistration.unregister();
125
 
968 nkef 126
 
945 nkef 127
	}
128
 
129
}