diff options
author | slewis | 2009-06-11 04:54:52 +0000 |
---|---|---|
committer | slewis | 2009-06-11 04:54:52 +0000 |
commit | bbcff0df70d935fb2e9a2eee3c663f947446f65a (patch) | |
tree | ed03b7cc6a27f75a0392a56853ad3c832416e3ed /examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin | |
parent | 1a846d6c70f9bf0ddf5d33e42b009d8230a6b45d (diff) | |
download | org.eclipse.ecf-bbcff0df70d935fb2e9a2eee3c663f947446f65a.tar.gz org.eclipse.ecf-bbcff0df70d935fb2e9a2eee3c663f947446f65a.tar.xz org.eclipse.ecf-bbcff0df70d935fb2e9a2eee3c663f947446f65a.zip |
removed content in favor of org.eclipse.ecf.examples.eventadmin/eventadmin.app projects
Diffstat (limited to 'examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin')
10 files changed, 7 insertions, 400 deletions
diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.classpath b/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.classpath deleted file mode 100644 index 6f3b481ac..000000000 --- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/CDC-1.1%Foundation-1.1"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.project b/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.project deleted file mode 100644 index 0bbd8fb3f..000000000 --- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.ecf.examples.remoteservices.eventadmin</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.settings/org.eclipse.jdt.core.prefs b/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7e7a20f35..000000000 --- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,69 +0,0 @@ -#Tue Jun 09 16:09:49 PDT 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 -org.eclipse.jdt.core.compiler.compliance=1.4 -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.3 diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.settings/org.eclipse.pde.core.prefs b/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 7d46bdb76..000000000 --- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Thu May 21 22:07:05 PDT 2009 -eclipse.preferences.version=1 -pluginProject.extensions=false -resolve.requirebundle=false diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/META-INF/MANIFEST.MF b/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/META-INF/MANIFEST.MF deleted file mode 100644 index f44e78f09..000000000 --- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/META-INF/MANIFEST.MF +++ /dev/null @@ -1,18 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %bundleName -Bundle-SymbolicName: org.eclipse.ecf.examples.remoteservices.eventadmin -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: %bundleProvider -Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1, - J2SE-1.4 -Import-Package: org.eclipse.ecf.core.util, - org.eclipse.ecf.osgi.services.distribution;version="1.0.0", - org.eclipse.ecf.remoteservice, - org.eclipse.equinox.concurrent.future;version="1.0.0", - org.osgi.framework;version="1.3.0", - org.osgi.service.event;version="1.2.0", - org.osgi.util.tracker;version="1.4.2" -Require-Bundle: org.eclipse.equinox.common;bundle-version="3.5.0" -Export-Package: org.eclipse.ecf.examples.remoteservices.eventadmin -Bundle-Localization: bundle diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/about.html b/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/about.html deleted file mode 100644 index 4c79781a5..000000000 --- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/about.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> -<title>About</title> -</head> -<body lang="EN-US"> -<h2>About This Content</h2> - -<p>June 25, 2008</p> -<h3>License</h3> - -<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise -indicated below, the Content is provided to you under the terms and conditions of the -Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available -at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. -For purposes of the EPL, "Program" will mean the Content.</p> - -<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is -being redistributed by another party ("Redistributor") and different terms and conditions may -apply to your use of any object code in the Content. Check the Redistributor's license that was -provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise -indicated below, the terms and conditions of the EPL still apply to any source code in the Content -and such source code may be obtained at <a href="/">http://www.eclipse.org</a>.</p> - -</body> -</html>
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/build.properties b/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/build.properties deleted file mode 100644 index 40ab22e41..000000000 --- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/build.properties +++ /dev/null @@ -1,10 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - about.html,\ - bundle.properties -src.includes = META-INF/,\ - about.html,\ - bundle.properties,\ - src/ diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/bundle.properties b/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/bundle.properties deleted file mode 100644 index de1d72435..000000000 --- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/bundle.properties +++ /dev/null @@ -1,10 +0,0 @@ -################################################################################# -# Copyright (c) 2009 EclipseSource and others. All rights reserved. This -# program and the accompanying materials are made available under the terms of -# the Eclipse Public License v1.0 which accompanies this distribution, and is -# -# Contributors: -# EclipseSource - initial API and implementation -################################################################################# -bundleName=ECF RemoteServices EventAdmin Example -bundleProvider=Eclipse.org - ECF
\ No newline at end of file diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/readme.txt b/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/readme.txt new file mode 100644 index 000000000..6f3eea32a --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/readme.txt @@ -0,0 +1,7 @@ +The contents of this project have moved to the two projects: + +org.eclipse.ecf/examples/bundles + +org.eclipse.ecf.examples.eventadmin +org.eclipse.ecf.examples.eventadmin.app + diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/src/org/eclipse/ecf/examples/remoteservices/eventadmin/EventAdminImpl.java b/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/src/org/eclipse/ecf/examples/remoteservices/eventadmin/EventAdminImpl.java deleted file mode 100644 index 91e638472..000000000 --- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.eventadmin/src/org/eclipse/ecf/examples/remoteservices/eventadmin/EventAdminImpl.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 EclipseSource and others. All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * EclipseSource - initial API and implementation - ******************************************************************************/ -package org.eclipse.ecf.examples.remoteservices.eventadmin; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.ecf.osgi.services.distribution.IDistributionConstants; -import org.eclipse.ecf.remoteservice.IRemoteCall; -import org.eclipse.ecf.remoteservice.IRemoteService; -import org.eclipse.equinox.concurrent.future.IExecutor; -import org.eclipse.equinox.concurrent.future.IProgressRunnable; -import org.eclipse.equinox.concurrent.future.ThreadsExecutor; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Filter; -import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.ServiceReference; -import org.osgi.service.event.Event; -import org.osgi.service.event.EventAdmin; -import org.osgi.service.event.EventConstants; -import org.osgi.service.event.EventHandler; -import org.osgi.util.tracker.ServiceTracker; - -public class EventAdminImpl implements EventAdmin { - - private BundleContext context; - private IExecutor executor; - private Object executorLock = new Object(); - private ServiceTracker eventHandlerServiceTracker; - private Object eventHandlerSTLock = new Object(); - private long defaultTimeout; - - public EventAdminImpl(BundleContext context, IExecutor executor, - long defaultTimeout) { - this.context = context; - this.executor = executor; - this.defaultTimeout = defaultTimeout; - } - - protected IRemoteService getRemoteServiceForServiceReference( - ServiceReference ref) { - if (ref == null) - return null; - Object remoteProp = ref.getProperty(IDistributionConstants.REMOTE); - if (remoteProp != null && remoteProp instanceof IRemoteService) - return (IRemoteService) remoteProp; - return null; - } - - private ServiceReference[] getEventHandlerServiceReferences(Event event) { - synchronized (eventHandlerSTLock) { - if (eventHandlerServiceTracker == null) { - eventHandlerServiceTracker = new ServiceTracker(context, - EventHandler.class.getName(), null); - eventHandlerServiceTracker.open(); - } - ServiceReference[] refs = eventHandlerServiceTracker - .getServiceReferences(); - List results = new ArrayList(); - if (refs == null) - return null; - for (int i = 0; i < refs.length; i++) { - String eventFilter = (String) refs[i] - .getProperty(EventConstants.EVENT_FILTER); - Filter filter = null; - if (eventFilter != null) { - try { - filter = context.createFilter(eventFilter); - if (event.matches(filter)) - results.add(refs[i]); - } catch (InvalidSyntaxException e) { - logError("getEventHandlers eventFilter=" + eventFilter, - e); - continue; - } - } else - results.add(refs[i]); - } - return (ServiceReference[]) results - .toArray(new ServiceReference[] {}); - } - } - - protected void logError(String string, Throwable e) { - System.err.println(string); - if (e != null) - e.printStackTrace(System.err); - } - - public void postEvent(final Event event) { - ServiceReference[] refs = getEventHandlerServiceReferences(event); - if (refs == null) { - logWarning("postEvent event=" + event - + ". No service references found to post to."); - return; - } - for (int i = 0; i < refs.length; i++) { - IRemoteService remoteService = getRemoteServiceForServiceReference(refs[i]); - // If this is a remote service, then fire the EventHandler - // asynchronously via IRemoteService.fireAsync - if (remoteService != null) - fireAsync(refs[i], remoteService, createRemoteCall(event)); - // Else call the EventHandler asynchronously by using Equinox - // concurrent API - else - fireAsync(refs[i], (EventHandler) context.getService(refs[i]), - event); - } - } - - protected void logWarning(String string) { - System.out.println(string); - } - - protected IRemoteCall createRemoteCall(final Event event) { - return new IRemoteCall() { - - public String getMethod() { - return "handleEvent"; - } - - public Object[] getParameters() { - return new Object[] { event }; - } - - public long getTimeout() { - return defaultTimeout; - } - }; - } - - public void sendEvent(Event event) { - ServiceReference[] eventHandlerRefs = getEventHandlerServiceReferences(event); - if (eventHandlerRefs == null) { - logWarning("sendEvent event=" + event - + ". No service references found to post to."); - return; - } - // Now synchronously call every eventhandler - for (int i = 0; i < eventHandlerRefs.length; i++) - callSync(eventHandlerRefs[i], (EventHandler) context - .getService(eventHandlerRefs[i]), event); - } - - protected void callSync(final ServiceReference serviceReference, - final EventHandler eventHandler, final Event event) { - SafeRunner.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - logCallException( - "Exception in EventHandler.handleEvent. eventHandler=" - + eventHandler + ". serviceReference=" - + serviceReference + ". event=" + event, - exception); - } - - public void run() throws Exception { - eventHandler.handleEvent(event); - } - }); - } - - protected void fireAsync(final ServiceReference serviceReference, - final EventHandler eventHandler, final Event event) { - getExecutor().execute(new IProgressRunnable() { - public Object run(IProgressMonitor arg0) throws Exception { - eventHandler.handleEvent(event); - return null; - } - }, null); - } - - protected IExecutor getExecutor() { - synchronized (executorLock) { - if (executor == null) { - executor = new ThreadsExecutor(); - } - return executor; - } - } - - protected void fireAsync(final ServiceReference serviceReference, - final IRemoteService remoteService, final IRemoteCall call) { - SafeRunner.run(new ISafeRunnable() { - public void handleException(Throwable exception) { - logCallException( - "Exception in IRemoteService.fireAsync. IRemoteService=" - + remoteService + ". serviceReference=" - + serviceReference + ". remoteCall=" + call, - exception); - } - - public void run() throws Exception { - remoteService.fireAsync(call); - } - }); - } - - protected void logCallException(String string, Throwable t) { - System.err.println(string); - if (t != null) - t.printStackTrace(System.err); - } - - public void dispose() { - synchronized (eventHandlerSTLock) { - if (eventHandlerServiceTracker != null) { - eventHandlerServiceTracker.close(); - eventHandlerServiceTracker = null; - } - } - synchronized (executorLock) { - executor = null; - } - context = null; - } -} |