activator.java

来自「OSGI_Opendoc, 基于OSGI框架Equinox的实战讲解」· Java 代码 · 共 40 行

JAVA
40
字号
package org.riawork.demo.user.validator;
/*
 * RIAWork.org
 * 
 * OSGI Opendoc Demo
 */
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.riawork.demo.service.user.Validator;
import org.riawork.demo.service.user.impl.ConfigFileValidatorImpl;
/**
 * desc: ConfigFileBundle Activator,采用传统的方式完成服务的注册
 *
 * @author jerry
 */
public class Activator implements BundleActivator {

	// --------------------------------------------Instance Variables
	
	private ServiceRegistration serviceReg=null;
	
	// --------------------------------------------Public Method
	
	/* (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		serviceReg=context.registerService(Validator.class.getName(), new ConfigFileValidatorImpl(), null);
	}

	/* (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
		if(serviceReg!=null)
			serviceReg.unregister();
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?