當前位置: 首頁>>代碼示例>>Java>>正文


Java EventAdmin類代碼示例

本文整理匯總了Java中org.osgi.service.event.EventAdmin的典型用法代碼示例。如果您正苦於以下問題:Java EventAdmin類的具體用法?Java EventAdmin怎麽用?Java EventAdmin使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EventAdmin類屬於org.osgi.service.event包,在下文中一共展示了EventAdmin類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: performAction

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
private void performAction(DependencyAction action, Map<MavenArtifact, ArtifactLoader> artifact2loader) throws BundleException {
	LOGGER.info("Perform " + action);
	EventAdmin eventAdmin = this.eventAdmin;
	if (eventAdmin != null)
		eventAdmin.postEvent(new DependencyActionEvent(action));

	if (action instanceof InstallAction) {
		performInstall(action.artifact, artifact2loader.get(action.artifact));
	} else if (action instanceof UpdateAction) {
		MavenArtifact target = ((UpdateAction) action).targetArtifact;
		performUpdate(action.artifact, target, artifact2loader.get(target));
	} else if (action instanceof UninstallAction) {
		performUninstall(action.artifact);
	} else {
		throw new IllegalArgumentException("Unknown action: " + action);
	}
}
 
開發者ID:to2mbn,項目名稱:LoliXL,代碼行數:18,代碼來源:PluginServiceImpl.java

示例2: notifyEventAdmins

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
@SuppressWarnings({
 "rawtypes", "unchecked"
})
private void notifyEventAdmins(String topic, Event event) {
    ServiceReference[] refs = null;
    try {
        refs = bctx.getAllServiceReferences(EventAdmin.class.getName(), null);
    } catch (InvalidSyntaxException e) {
        LOG.error("Failed to get EventAdmin: " + e.getMessage(), e);
    }

    if (refs != null) {
        LOG.debug("Publishing event to {} EventAdmins; Topic:[{}]", refs.length, topic);
        for (ServiceReference serviceReference : refs) {
            EventAdmin eventAdmin = (EventAdmin) bctx.getService(serviceReference);
            try {
                eventAdmin.postEvent(event);
            } finally {
                if (eventAdmin != null) {
                    bctx.ungetService(serviceReference);
                }
            }
        }
    }
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:26,代碼來源:EventAdminHelper.java

示例3: notify

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
public void notify(EventObject event) throws Exception {
    EventAdmin eventAdmin = tracker.getService();
    if (eventAdmin == null) {
        return;
    }

    Dictionary<String, Object> props = new Hashtable<String, Object>();
    props.put(TYPE, getType(event));
    props.put(EVENT, event);
    props.put(TIMESTAMP, System.currentTimeMillis());
    props.put(BUNDLE, bundleContext.getBundle());
    props.put(BUNDLE_SYMBOLICNAME, bundleContext.getBundle().getSymbolicName());
    props.put(BUNDLE_ID, bundleContext.getBundle().getBundleId());
    props.put(BUNDLE_VERSION, getBundleVersion(bundleContext.getBundle()));
    try {
        props.put(CAUSE, event.getClass().getMethod("getCause").invoke(event));
    } catch (Throwable t) {
        // ignore
    }
    eventAdmin.postEvent(new Event(getTopic(event), props));
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:22,代碼來源:OsgiEventAdminNotifier.java

示例4: ChannelImpl

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
public ChannelImpl ( final String storageId, final EventAdmin eventAdmin, final StorageManager manager, final ChannelProviderImpl provider, final Map<MetaKey, String> configuration )
{
    this.storageId = storageId;
    this.manager = manager;
    this.provider = provider;

    this.storageKey = new MetaKey ( "channel", storageId );

    String dir = configuration.get ( KEY_APM_DIR_OVERRIDE );
    if ( dir == null )
    {
        dir = storageId;
    }

    this.handle = manager.registerModel ( 10_000, this.storageKey, new ChannelModelProvider ( storageId, dir ) );
}
 
開發者ID:eclipse,項目名稱:packagedrone,代碼行數:17,代碼來源:ChannelImpl.java

示例5: createWampControllerAndConnectClient

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
private WampController createWampControllerAndConnectClient(Json json) {
    Publisher publisher = mock(Publisher.class);
    final Answer<Object> answer = new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            message.add(0, (String) invocation.getArguments()[2]);
            return null;
        }
    };
    doAnswer(answer).when(publisher).send(anyString(), anyString(), anyString());

    WampController controller = new WampController(json, publisher, TestConstants.PREFIX);
    controller.ea = mock(EventAdmin.class);
    controller.open(CLIENT_ID);
    assertThat(message).isNotNull();
    return controller;
}
 
開發者ID:wisdom-framework,項目名稱:wisdom-wamp,代碼行數:18,代碼來源:WampControllerPubSubTest.java

示例6: start

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
@Override
public void start(BundleContext context) throws Exception {
    log.debug("de.iew.stagediver.fx.eventbus Bundle starting");

    this.context = context;

    if (this.eventBusImpl == null) {
        this.eventBusImpl = new EventBusImpl();
    }

    if (this.eventBusServiceServiceRegistration == null) {
        this.eventBusServiceServiceRegistration = context.registerService(EventBusService.class, this.eventBusImpl, null);
    }

    this.eventAdminServiceReference = context.getServiceReference(EventAdmin.class);
    registerEventHandlerIfEventAdminIsAvailable(context);

    final String filterString = String.format("(objectClass=%s)", EventAdmin.class.getName());
    context.addServiceListener(this, filterString);
}
 
開發者ID:ventilb,項目名稱:stagediver.fx-eventbus,代碼行數:21,代碼來源:EventBusBundleActivator.java

示例7: serviceChanged

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
@Override
public void serviceChanged(ServiceEvent event) {
    final ServiceReference<EventAdmin> eventAdminServiceReference = (ServiceReference<EventAdmin>) event.getServiceReference();

    switch (event.getType()) {
        case ServiceEvent.REGISTERED:
            log.debug(String.format("The service %s is registered", eventAdminServiceReference));
            if (this.eventAdminServiceReference != null) {
                log.warn(String.format("There is already an %s service registered. Ignoring this event.", EventAdmin.class.getName()));
            } else {
                this.eventAdminServiceReference = eventAdminServiceReference;
                registerOSGIEventHandler(this.context);
            }
            break;
        case ServiceEvent.UNREGISTERING:
            log.debug(String.format("The service %s is unregistering", eventAdminServiceReference));
            if (this.eventAdminServiceReference != null) {
                unregisterOSGIEventHandler();
                this.eventAdminServiceReference = null;
            }
            break;
    }
}
 
開發者ID:ventilb,項目名稱:stagediver.fx-eventbus,代碼行數:24,代碼來源:EventBusBundleActivator.java

示例8: sendEvent

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
private void sendEvent(Event osgiEvent) {
	boolean trace = log.isTraceEnabled();
	ServiceReference ref = bundleContext.getServiceReference(EVENT_ADMIN);
	if (ref != null) {
		EventAdmin eventAdmin = (EventAdmin) bundleContext.getService(ref);
		if (eventAdmin != null) {
			if (trace) {
				StringBuilder sb = new StringBuilder();
				String[] names = osgiEvent.getPropertyNames();
				sb.append("{");
				for (int i = 0; i < names.length; i++) {
					String name = names[i];
					sb.append(name);
					sb.append("=");
					Object value = osgiEvent.getProperty(name);
					sb.append(ObjectUtils.getDisplayString(value));
					if (i < names.length - 1)
						sb.append(",");
				}
				sb.append("}");

				log.trace("Broadcasting OSGi event " + osgiEvent + " w/ props " + sb.toString());
			}
			publisher.publish(eventAdmin, osgiEvent);
		}
	} else {
		log.trace("No event admin found for broadcasting event " + osgiEvent);
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:30,代碼來源:OsgiEventDispatcher.java

示例9: Configuration

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
public Configuration(EventAdmin eventAdmin, ConfigurationAdmin cfgAdmin) {
    this.eventAdmin = eventAdmin;
    this.cfgAdmin = cfgAdmin;
    try {
        org.osgi.service.cm.Configuration cfg = this.cfgAdmin.getConfiguration("eu.hlavki.identity");
        this.properties = cfg.getProperties();
    } catch (IOException e) {
        log.warn("Can't load configuration", e);
    }
}
 
開發者ID:hlavki,項目名稱:g-suite-identity-sync,代碼行數:11,代碼來源:Configuration.java

示例10: execute

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	EventAdmin ea = ServiceUtil.getService(EventAdmin.class);
	Event stepOver = new Event(EA_TOPIC_DEBUGGING_ACTION_RESUME, Collections.emptyMap());
	ea.sendEvent(stepOver);

	// has to be null (see javadoc)
	return null;
}
 
開發者ID:VisuFlow,項目名稱:visuflow-plugin,代碼行數:10,代碼來源:DebugStepResumeHandler.java

示例11: execute

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	EventAdmin ea = ServiceUtil.getService(EventAdmin.class);
	Event stepOver = new Event(EA_TOPIC_DEBUGGING_ACTION_STEP_OVER, Collections.emptyMap());
	ea.sendEvent(stepOver);

	// has to be null (see javadoc)
	return null;
}
 
開發者ID:VisuFlow,項目名稱:visuflow-plugin,代碼行數:10,代碼來源:DebugStepOverHandler.java

示例12: EventAdminDestination

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
public EventAdminDestination(EventAdmin client, String topic, Class<T> type) {
    this.client = client;
    this.topic = topic;
    if (!(type == Map.class || type==Event.class)) {
        throw new IllegalArgumentException("Curently only Map<String, ?> and Event are supported");
    }
    this.type = type;
}
 
開發者ID:cschneider,項目名稱:reactive-components,代碼行數:9,代碼來源:EventAdminDestination.java

示例13: postEvent

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
public static void postEvent(String topic, Map<String, Object> data) {
    BundleContext bundleContext = FrameworkUtil.getBundle(EventAdminHelper.class).getBundleContext();

    if (bundleContext == null) return;

    ServiceReference ref = bundleContext.getServiceReference(EventAdmin.class.getName());
    if (ref != null)
    {
        EventAdmin eventAdmin = (EventAdmin) bundleContext.getService(ref);
        HashMap<String, Object> eventData = new HashMap<>(data);
        eventAdmin.postEvent(new Event(topic, eventData));
    }
}
 
開發者ID:andyphillips404,項目名稱:awplab-core,代碼行數:14,代碼來源:EventAdminHelper.java

示例14: registerForEvent

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
public static void registerForEvent(EventHandler eventHandler, String... topics) {
    BundleContext bundleContext = FrameworkUtil.getBundle(EventAdminHelper.class).getBundleContext();

    if (bundleContext == null) return;

    ServiceReference ref = bundleContext.getServiceReference(EventAdmin.class.getName());
    if (ref != null)
    {
        Dictionary props = new Hashtable();
        props.put(EventConstants.EVENT_TOPIC, topics);
        bundleContext.registerService(EventHandler.class.getName(), eventHandler, props);
    }
}
 
開發者ID:andyphillips404,項目名稱:awplab-core,代碼行數:14,代碼來源:EventAdminHelper.java

示例15: send

import org.osgi.service.event.EventAdmin; //導入依賴的package包/類
public void send(RemoteServiceAdminEvent rsaEvent) {
   Event event = toEvent(rsaEvent);
   ServiceReference<EventAdmin> sref = this.context.getServiceReference(EventAdmin.class);
   if (sref != null) {
       EventAdmin eventAdmin = this.context.getService(sref);
       eventAdmin.postEvent(event);
       this.context.ungetService(sref);           
   }
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:10,代碼來源:EventAdminSender.java


注:本文中的org.osgi.service.event.EventAdmin類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。