当前位置: 首页>>代码示例>>Java>>正文


Java Activate类代码示例

本文整理汇总了Java中aQute.bnd.annotation.component.Activate的典型用法代码示例。如果您正苦于以下问题:Java Activate类的具体用法?Java Activate怎么用?Java Activate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Activate类属于aQute.bnd.annotation.component包,在下文中一共展示了Activate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: activate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
  public void activate(ComponentContext ctx) {
context = ctx.getBundleContext();
instance = this;

MThread.asynchron(new Runnable(){

	@Override
	public void run() {
		Sop.waitForApi(CherryApi.class, 10000);
		log.i("will initial deploy cherry resources");
		context.addBundleListener(CherryDeployServlet.this);
		refreshAll(SENSIVITY.CHECK);
	}
	
});
  }
 
开发者ID:mhus,项目名称:cherry-web,代码行数:18,代码来源:CherryDeployServlet.java

示例2: doActivate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
public void doActivate(ComponentContext ctx) {
	log.info("Start");
	context = ctx.getBundleContext();
	context.addBundleListener(this);
	context.addServiceListener(this);
	
	// configuration
	Hashtable<String, Object> properties = new Hashtable<String, Object>();
	properties.put(Constants.SERVICE_PID, CONFIG_PID);
	configUpdaterReg = context.registerService(ManagedService.class.getName(), new ConfigUpdater(this) , properties);
	
	if (enabled) refreshAll();
	
	
}
 
开发者ID:mhus,项目名称:mhus-osgi-tools,代码行数:17,代码来源:BundleWatchImpl.java

示例3: doActivate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
	public void doActivate(ComponentContext ctx) {
		
//	    pwc = new PersistentWatchConfig();
//	    pwc.register(ctx.getBundleContext());
		
		timer = MOsgi.getTimer();
		timerTask = new TimerTask() {
			
			@Override
			public void run() {
				doTask();
			}
		};
		timer.schedule(timerTask, 10000, 60000);
	}
 
开发者ID:mhus,项目名称:mhus-osgi-tools,代码行数:17,代码来源:PersistentWatchImpl.java

示例4: doActivate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
public void doActivate(ComponentContext ctx) {
	tracker = new MServiceTracker<MoManagerService>(MoManagerService.class) {
		
		@Override
		protected void removeService(ServiceReference<MoManagerService> reference, MoManagerService service) {
			MoManagerAdminImpl.this.removeService(service);
		}
		
		@Override
		protected void addService(ServiceReference<MoManagerService> reference, MoManagerService service) {
			try {
				MoManagerAdminImpl.this.addService(service);
			} catch (Exception e) {
				log().e(reference,e);
			}
		}
	};
	tracker.start();
}
 
开发者ID:mhus,项目名称:mhus-osgi-tools,代码行数:21,代码来源:MoManagerAdminImpl.java

示例5: activate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
  public void activate(ComponentContext ctx) {
props = new Properties();
File f = new File ("etc/rootservlet.properties");
if (f.exists()) {
	log.info("Load config file " + f);
	try {
		FileInputStream is = new FileInputStream(f);
		props.load(is);
		is.close();
	} catch (IOException e) {
		log.warning(e.toString());
	}
} else {
	log.warning("Config file not found");
}
  }
 
开发者ID:mhus,项目名称:mhus-osgi-tools,代码行数:18,代码来源:RootServlet.java

示例6: activate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
void activate() throws Throwable {
	try {
		RmiConfiguration rmc = new RmiConfiguration() {

			@Override
			public boolean isCorbaCompliant() {
				return false;
			}

			@Override
			public void init() throws RmiConfigurationException {
			}
		};
		jotm = new org.objectweb.jotm.Jotm(true, false, rmc);
		delegate = jotm.getTransactionManager();
	} catch (Throwable t) {
		t.printStackTrace();
		throw t;
	}
}
 
开发者ID:osgi,项目名称:bundles,代码行数:22,代码来源:JotmImpl.java

示例7: activate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
/**
 * Awfully simple. Just use the Data Source Factory to create a Data Source.
 * We delegate all the XA Data Source calls t this Data Source.
 * 
 * @param properties the DS properties (also from Config admin)
 * @throws Exception
 */
@Activate
void activate(BundleContext context, Map<String, Object> properties) throws Exception {
	config = Converter.cnv(Config.class, properties);
	assert config.url() != null;

	Properties props = new Properties();

	props.put(DataSourceFactory.JDBC_URL, config.url());

	if (config.user() != null && config._password() != null) {
		props.setProperty(DataSourceFactory.JDBC_USER, config.user());
		props.setProperty(DataSourceFactory.JDBC_PASSWORD, config._password());
	}

	ds = dsf.createXADataSource(props);
	if ( migrator != null) 
		migrator.migrate(config.name(), ds);
	
	if ( poolProvider != null)
		ds = poolProvider.pool(ds, properties);
	
	registration = context.registerService(XADataSource.class.getName(), ds, new Hashtable<String, Object>(
			properties));
}
 
开发者ID:osgi,项目名称:bundles,代码行数:32,代码来源:XADataSourceFactory.java

示例8: activate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
void activate(Map<String,Object> properties) {

	Configuration config = Configurable.createConfigurable(Configuration.class, properties);
	int coreSize = config.coreSize();
	int maxSize = config.maximumPoolSize();
	long keepAlive = config.keepAliveTime();
	int cores = Runtime.getRuntime().availableProcessors();

	if (coreSize < 10 * cores)
		coreSize = 30;

	if (maxSize <= coreSize)
		maxSize = coreSize * 4;

	if (keepAlive < 10 || keepAlive > 1000)
		keepAlive = 300;

	es = new ThreadPoolExecutor(coreSize, maxSize, keepAlive, TimeUnit.SECONDS, queue, //
			new ThreadPoolExecutor.CallerRunsPolicy());
}
 
开发者ID:osgi,项目名称:bundles,代码行数:22,代码来源:ExecutorImpl.java

示例9: activate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
public void activate(Map<String, String> properties) {
	log.info("activating service");
	Properties dbProps = new Properties();
	dbProps.put(DataSourceFactory.JDBC_DATABASE_NAME, properties.get("dbname"));
	dbProps.put(DataSourceFactory.JDBC_USER, properties.get("user"));
	dbProps.put(DataSourceFactory.JDBC_PASSWORD, properties.get("password"));
	dbProps.put(DataSourceFactory.JDBC_SERVER_NAME, properties.get("server"));
	dbProps.put(DataSourceFactory.JDBC_PORT_NUMBER, properties.get("port"));
	try {
		dataSource = dataSourceFactory.createDataSource(dbProps);
		// Or
		// dataSourceFactory.createConnectionPoolDataSource(dbProps);
	} catch (SQLException e) {
		e.printStackTrace();
	}
	executeSQL(true, "5555555555", "foo");
	log.info("Added stuff");
}
 
开发者ID:bpedman,项目名称:osgi-jdbc-example,代码行数:20,代码来源:ServiceWithDbAccess.java

示例10: activate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
void activate(BundleContext bundleContext) {
	ServiceTracker logServiceTracker = new ServiceTracker(bundleContext, LogService.class.getName(), null);
	logServiceTracker.open();
	
	LogService logService = (LogService) logServiceTracker.getService();
	
	if(logService != null)
        logService.log(LogService.LOG_INFO, "[" + this.getClass().getName() + "] Testing the logServiceWritter!");

}
 
开发者ID:maldiny,项目名称:OSGI-en-Castellano,代码行数:12,代码来源:LogServiceWritter.java

示例11: activate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
void activate(BundleContext bundleContext) {
	ServiceTracker logServiceTracker = new ServiceTracker(bundleContext, LogService.class.getName(), null);
	logServiceTracker.open();
	
	LogService logService = (LogService) logServiceTracker.getService();
	
	ServiceReference ref = bundleContext.getServiceReference(org.osgi.service.log.LogReaderService.class.getName());
    if (ref != null)
    {
      org.osgi.service.log.LogReaderService reader = (org.osgi.service.log.LogReaderService)bundleContext.getService(ref);
      reader.addLogListener(new LogListenerImpl(logService));
    }
}
 
开发者ID:maldiny,项目名称:OSGI-en-Castellano,代码行数:15,代码来源:LogServiceReader.java

示例12: activate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
public final void activate(final BundleContext bundleContext, final Map<String, ?> properties) {
    final SourceBean incoming = new SourceBean();

    incoming.setAge(35);
    incoming.setFirstName("Antonio Maria");
    incoming.setLastName("Sanchez");
    final TargetBean result = mapper.map(incoming, TargetBean.class);

    System.out.println("and the winner is: " + result);

}
 
开发者ID:antoniomaria,项目名称:karaf4-eclipselink-jpa,代码行数:13,代码来源:MappingHello.java

示例13: start

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
public void start(BundleContext context, Map<String, Object> config) throws Exception {
    _context = context;

    Dictionary<String, Object> cmdProps = new Hashtable<>();
    cmdProps.put("osgi.command.scope", "osgidb");
    cmdProps.put("osgi.command.function", new String[]{"list", "reset", "config"});
    _context.registerService(DbActivator.class, this, cmdProps);

    updated(config);
}
 
开发者ID:kscarr73,项目名称:OsgiDb,代码行数:12,代码来源:DbActivator.java

示例14: activate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
void activate(final BundleContext bundleContext) throws InvalidSyntaxException {
    serviceTracker = new ServiceTracker<>(bundleContext, ComponentInstaller.class.getName(),
            new ServiceTrackerCustomizer<ComponentInstaller, ComponentInstaller>() {

                @Override
                public ComponentInstaller addingService(ServiceReference<ComponentInstaller> serviceRef) {
                    ComponentInstaller componentInstaller = bundleContext.getService(serviceRef);
                    Object nameProp = serviceRef.getProperty("component.name"); //$NON-NLS-1$
                    if (nameProp instanceof String) {
                        LOGGER.info("Registered the component: " + nameProp + "(" //$NON-NLS-1$//$NON-NLS-2$
                                + componentInstaller.getClass().getCanonicalName() + ")"); //$NON-NLS-1$
                        componentInstaller.install(DefinitionRegistryOsgi.this);
                    } else {// no name set so issue a warning
                        LOGGER.warn("Failed to register the following component because it is unnamed: " //$NON-NLS-1$
                                + serviceRef.getClass().getCanonicalName());
                    }
                    return componentInstaller;
                }

                @Override
                public void modifiedService(ServiceReference<ComponentInstaller> arg0,
                        ComponentInstaller componentInstaller) {
                    // not handled for now
                }

                @Override
                public void removedService(ServiceReference<ComponentInstaller> arg0, ComponentInstaller componentInstaller) {
                    // No any un-install yet from the service
                }
            });
    serviceTracker.open();
}
 
开发者ID:Talend,项目名称:components,代码行数:34,代码来源:DefinitionRegistryOsgi.java

示例15: activate

import aQute.bnd.annotation.component.Activate; //导入依赖的package包/类
@Activate
  public void activate(ComponentContext ctx) {
  	ctx.getBundleContext().addBundleListener(this);
  	instance = this;
  	globalSession.setInvalidator(new Invalidator<String, MProperties>() {

	@Override
	public boolean isInvalid(String key, MProperties value, long time, long accessed) {
		return 
			System.currentTimeMillis() - time > sessionTimeout.value() 
			||
			globalSession.size() > sessionMaxSize.value() && accessed < 2 && System.currentTimeMillis() - time > 10000;
	}
});
  }
 
开发者ID:mhus,项目名称:cherry-web,代码行数:16,代码来源:InternalCherryApiImpl.java


注:本文中的aQute.bnd.annotation.component.Activate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。