Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Alexander Kuppe2011-01-28 21:55:23 +0000
committerMarkus Alexander Kuppe2011-01-28 21:57:34 +0000
commit336c805fe02da51f68d8c546504f414b3b6d9fcd (patch)
treef96f55013aeabbf7f91795a4f34c55253e5d5a24 /incubation
parent21ecf94035eb2ebcbc12c6b6df5a45c61c9ab30d (diff)
downloadorg.eclipse.ecf-336c805fe02da51f68d8c546504f414b3b6d9fcd.tar.gz
org.eclipse.ecf-336c805fe02da51f68d8c546504f414b3b6d9fcd.tar.xz
org.eclipse.ecf-336c805fe02da51f68d8c546504f414b3b6d9fcd.zip
ASSIGNED - bug 324215: [remoteserviceadmin] implement remote services
admin spec https://bugs.eclipse.org/bugs/show_bug.cgi?id=324215
Diffstat (limited to 'incubation')
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.classpath7
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.gitignore1
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.options27
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.project28
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.jdt.core.prefs74
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.core.prefs4
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.prefs33
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF29
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/about.html28
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/build.properties11
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/bundle.properties10
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java229
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/DebugOptions.java42
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java798
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/IDUtil.java80
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LogUtility.java95
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java349
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java207
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java197
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java358
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java405
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java442
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java60
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescription.java62
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescriptionFactory.java134
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java202
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionAdvertiser.java135
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java195
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java919
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionParseException.java31
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java50
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionWriter.java324
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/HostContainerSelector.java78
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IConsumerContainerSelector.java19
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IDiscoveredEndpointDescriptionFactory.java62
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionAdvertiser.java20
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionReader.java21
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IHostContainerSelector.java19
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IPackageVersionComparator.java19
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java30
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/LocatorServiceListener.java168
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/PackageVersionComparator.java38
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java48
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteReferenceNotFoundException.java56
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java1981
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdminEvent.java37
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ServiceInfoFactory.java229
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.classpath7
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.gitignore1
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.project28
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.jdt.core.prefs73
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.core.prefs4
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.prefs33
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF27
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/about.html28
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/build.properties8
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/bundle.properties10
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/ecf-remote-service-extra.xml26
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/ecf-remote-service-minimal.xml11
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/osgi-remote-service-extra.xml25
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/osgi-remote-service-minimal.xml10
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractDistributionTest.java246
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionWriterTest.java90
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java199
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceAccessTest.java249
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceRegisterTest.java242
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractTwoRemoteServiceAccessTest.java158
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/Activator.java48
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointDescriptionFactoryTest.java43
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointListenerTest.java38
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java44
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestService1.java23
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestServiceInterface1.java19
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestServiceInterface2.java20
74 files changed, 0 insertions, 10101 deletions
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.classpath b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.classpath
deleted file mode 100644
index 64c5e31b7..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.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/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.gitignore b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.gitignore
deleted file mode 100644
index e660fd93d..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin/
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.options b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.options
deleted file mode 100644
index 1b7c83b7f..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.options
+++ /dev/null
@@ -1,27 +0,0 @@
-# Debugging options for the org.eclipse.ecf.osgi.services.remoteserviceadmin plug-in
-
-# Turn on general debugging for the org.eclipse.ecf.osgi.services.remoteservicesadmin plug-in
-org.eclipse.ecf.osgi.services.remoteserviceadmin/debug=true
-org.eclipse.ecf.osgi.services.remoteserviceadmin/debug/filter = *
-org.eclipse.ecf.osgi.services.remoteserviceadmin/debug/flag = true
-
-# Trace when exceptions are caught
-org.eclipse.ecf.osgi.services.remoteserviceadmin/debug/exceptions/catching=true
-# Trace when exceptions are thrown
-org.eclipse.ecf.osgi.services.remoteserviceadmin/debug/exceptions/throwing=true
-
-org.eclipse.ecf.osgi.services.remoteserviceadmin/debug/remoteserviceadmin=true
-
-org.eclipse.ecf.osgi.services.remoteserviceadmin/debug/topologymanager=true
-
-org.eclipse.ecf.osgi.services.remoteserviceadmin/debug/containerselector=true
-
-org.eclipse.ecf.osgi.services.remoteserviceadmin/debug/discovery=true
-
-org.eclipse.ecf.osgi.services.remoteserviceadmin/debug/endpointdescriptionreader=true
-
-org.eclipse.ecf.osgi.services.remoteserviceadmin/debug/packageversioncomparator=true
-
-
-
-
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.project b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.project
deleted file mode 100644
index 4272128db..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.ecf.osgi.services.remoteserviceadmin</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/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.jdt.core.prefs b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 542b8dfe6..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,74 +0,0 @@
-#Sat Jan 22 17:14:11 PST 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-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=error
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-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.includeNullInfoFromAsserts=disabled
-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.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-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.suppressOptionalErrors=disabled
-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.unusedObjectAllocation=ignore
-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.5
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.core.prefs b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644
index 74f70445a..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-#Sat Jan 22 17:00:17 PST 2011
-eclipse.preferences.version=1
-pluginProject.extensions=false
-resolve.requirebundle=false
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.prefs b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.prefs
deleted file mode 100644
index 52e6c3604..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.prefs
+++ /dev/null
@@ -1,33 +0,0 @@
-#Sat Jan 22 17:43:00 PST 2011
-compilers.f.unresolved-features=1
-compilers.f.unresolved-plugins=1
-compilers.incompatible-environment=1
-compilers.p.build=1
-compilers.p.build.bin.includes=1
-compilers.p.build.encodings=2
-compilers.p.build.java.compiler=2
-compilers.p.build.java.compliance=1
-compilers.p.build.missing.output=2
-compilers.p.build.output.library=1
-compilers.p.build.source.library=1
-compilers.p.build.src.includes=1
-compilers.p.deprecated=1
-compilers.p.discouraged-class=1
-compilers.p.internal=1
-compilers.p.missing-packages=2
-compilers.p.missing-version-export-package=2
-compilers.p.missing-version-import-package=2
-compilers.p.missing-version-require-bundle=2
-compilers.p.no-required-att=0
-compilers.p.not-externalized-att=1
-compilers.p.unknown-attribute=1
-compilers.p.unknown-class=1
-compilers.p.unknown-element=1
-compilers.p.unknown-identifier=1
-compilers.p.unknown-resource=1
-compilers.p.unresolved-ex-points=0
-compilers.p.unresolved-import=0
-compilers.s.create-docs=false
-compilers.s.doc-folder=doc
-compilers.s.open-tags=1
-eclipse.preferences.version=1
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF
deleted file mode 100644
index 56dc92512..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,29 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %bundle.name
-Bundle-SymbolicName: org.eclipse.ecf.osgi.services.remoteserviceadmin
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator
-Bundle-Vendor: %bundle.provider
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-Localization: bundle
-Export-Package: org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;x-internal:=true,
- org.eclipse.ecf.osgi.services.remoteserviceadmin;version="1.0.0"
-Require-Bundle: org.eclipse.equinox.common;bundle-version="3.6.0"
-Bundle-ActivationPolicy: lazy
-Import-Package: org.eclipse.ecf.core;version="3.0.0",
- org.eclipse.ecf.core.identity,
- org.eclipse.ecf.core.security,
- org.eclipse.ecf.core.util,
- org.eclipse.ecf.discovery;version="4.0.0",
- org.eclipse.ecf.discovery.identity,
- org.eclipse.ecf.remoteservice;version="6.0.0",
- org.eclipse.ecf.remoteservice.events;version="6.0.0",
- org.eclipse.equinox.concurrent.future;version="1.0.0",
- org.eclipse.osgi.framework.eventmgr,
- org.osgi.framework;version="1.3.0",
- org.osgi.service.event,
- org.osgi.service.log,
- org.osgi.service.packageadmin,
- org.osgi.service.remoteserviceadmin;version="1.0.0",
- org.osgi.util.tracker
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/about.html b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/about.html
deleted file mode 100644
index 4c79781a5..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/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 (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). 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, &quot;Program&quot; 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 (&quot;Redistributor&quot;) 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/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/build.properties b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/build.properties
deleted file mode 100644
index 22b24fb5d..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/build.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- bundle.properties,\
- about.html,\
- .options
-jre.compilation.profile = J2SE-1.4
-javacTarget=jsr14
-src.includes = about.html,\
- bundle.properties
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/bundle.properties b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/bundle.properties
deleted file mode 100644
index 390af021a..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/bundle.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-#################################################################################
-# Copyright (c) 2010 Composent, Inc. 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:
-# Composent, Inc. - initial API and implementation
-#################################################################################
-bundle.name=ECF OSGi R4.2 Remote Service Admin
-bundle.provider=Eclipse.org - ECF \ No newline at end of file
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
deleted file mode 100644
index 62574f8c3..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;
-
-import java.util.Dictionary;
-import java.util.Properties;
-import java.util.UUID;
-
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.ecf.core.IContainerManager;
-import org.eclipse.ecf.core.util.LogHelper;
-import org.eclipse.ecf.core.util.SystemLogService;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionAdvertiser;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionLocator;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionAdvertiser;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class Activator implements BundleActivator {
-
- public static final String PLUGIN_ID = "org.eclipse.ecf.osgi.services.remoteserviceadmin"; //$NON-NLS-1$
-
- private static BundleContext context;
- private static Activator instance;
-
- static BundleContext getContext() {
- return context;
- }
-
- public static Activator getDefault() {
- return instance;
- }
-
- private ServiceRegistration remoteServiceAdminRegistration;
-
- private EndpointDescriptionLocator endpointDescriptionLocator;
- private EndpointDescriptionAdvertiser endpointDescriptionAdvertiser;
- private ServiceRegistration endpointDescriptionAdvertiserRegistration;
-
- private ServiceTracker containerManagerTracker;
- // Logging
- private ServiceTracker logServiceTracker = null;
- private LogService logService = null;
- private Object logServiceTrackerLock = new Object();
- // Sax parser
- private Object saxParserFactoryTrackerLock = new Object();
- private ServiceTracker saxParserFactoryTracker;
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext
- * )
- */
- public void start(BundleContext bundleContext) throws Exception {
- Activator.context = bundleContext;
- Activator.instance = this;
- // make remote service admin available
- Properties rsaProps = new Properties();
- rsaProps.put(RemoteServiceAdmin.SERVICE_PROP, new Boolean(true));
- remoteServiceAdminRegistration = context.registerService(
- org.osgi.service.remoteserviceadmin.RemoteServiceAdmin.class
- .getName(), new ServiceFactory() {
- public Object getService(Bundle bundle,
- ServiceRegistration registration) {
- return new RemoteServiceAdmin(bundle);
- }
-
- public void ungetService(Bundle bundle,
- ServiceRegistration registration, Object service) {
- if (service != null)
- ((RemoteServiceAdmin) service).close();
- }
- }, (Dictionary) rsaProps);
-
- // create endpoint description locator
- endpointDescriptionLocator = new EndpointDescriptionLocator(context);
- // create and register endpoint description advertiser
- final Properties properties = new Properties();
- properties.put(Constants.SERVICE_RANKING,
- new Integer(Integer.MIN_VALUE));
- endpointDescriptionAdvertiser = new EndpointDescriptionAdvertiser(
- endpointDescriptionLocator);
- endpointDescriptionAdvertiserRegistration = getContext()
- .registerService(
- IEndpointDescriptionAdvertiser.class.getName(),
- endpointDescriptionAdvertiser, (Dictionary) properties);
-
- // start endpointDescriptionLocator
- endpointDescriptionLocator.start();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext bundleContext) throws Exception {
- if (endpointDescriptionLocator != null) {
- endpointDescriptionLocator.close();
- endpointDescriptionLocator = null;
- }
- if (remoteServiceAdminRegistration != null) {
- remoteServiceAdminRegistration.unregister();
- remoteServiceAdminRegistration = null;
- }
- if (endpointDescriptionAdvertiserRegistration != null) {
- endpointDescriptionAdvertiserRegistration.unregister();
- endpointDescriptionAdvertiserRegistration = null;
- }
- if (endpointDescriptionAdvertiser != null) {
- endpointDescriptionAdvertiser.close();
- endpointDescriptionAdvertiser = null;
- }
- synchronized (saxParserFactoryTrackerLock) {
- if (saxParserFactoryTracker != null) {
- saxParserFactoryTracker.close();
- saxParserFactoryTracker = null;
- }
- }
- synchronized (logServiceTrackerLock) {
- if (logServiceTracker != null) {
- logServiceTracker.close();
- logServiceTracker = null;
- logService = null;
- }
- }
- if (containerManagerTracker != null) {
- containerManagerTracker.close();
- containerManagerTracker = null;
- }
- Activator.context = null;
- Activator.instance = null;
- }
-
- public String getFrameworkUUID() {
- if (context == null)
- return null;
- // code get and set the framework uuid property as specified in
- // r2.enterprise.pdf pg 297
- synchronized ("org.osgi.framework.uuid") { //$NON-NLS-1$
- String result = context.getProperty("org.osgi.framework.uuid"); //$NON-NLS-1$
- if (result == null) {
- UUID newUUID = UUID.randomUUID();
- result = newUUID.toString();
- System.setProperty("org.osgi.framework.uuid", //$NON-NLS-1$
- newUUID.toString());
- }
- return result;
- }
- }
-
- public SAXParserFactory getSAXParserFactory() {
- if (instance == null)
- return null;
- synchronized (saxParserFactoryTrackerLock) {
- if (saxParserFactoryTracker == null) {
- saxParserFactoryTracker = new ServiceTracker(context,
- SAXParserFactory.class.getName(), null);
- saxParserFactoryTracker.open();
- }
- return (SAXParserFactory) saxParserFactoryTracker.getService();
- }
- }
-
- public LogService getLogService() {
- if (context == null)
- return null;
- synchronized (logServiceTrackerLock) {
- if (logServiceTracker == null) {
- logServiceTracker = new ServiceTracker(context,
- LogService.class.getName(), null);
- logServiceTracker.open();
- }
- logService = (LogService) logServiceTracker.getService();
- if (logService == null)
- logService = new SystemLogService(PLUGIN_ID);
- return logService;
- }
- }
-
- public void log(IStatus status) {
- if (logService == null)
- logService = getLogService();
- if (logService != null)
- logService.log(null, LogHelper.getLogCode(status),
- LogHelper.getLogMessage(status), status.getException());
- }
-
- public void log(ServiceReference sr, IStatus status) {
- log(sr, LogHelper.getLogCode(status), LogHelper.getLogMessage(status),
- status.getException());
- }
-
- public void log(ServiceReference sr, int level, String message, Throwable t) {
- if (logService == null)
- logService = getLogService();
- if (logService != null)
- logService.log(sr, level, message, t);
- }
-
- public IContainerManager getContainerManager() {
- if (containerManagerTracker == null) {
- containerManagerTracker = new ServiceTracker(context,
- IContainerManager.class.getName(), null);
- containerManagerTracker.open();
- }
- return (IContainerManager) containerManagerTracker.getService();
- }
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/DebugOptions.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/DebugOptions.java
deleted file mode 100644
index c234bcc6c..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/DebugOptions.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;
-
-public interface DebugOptions {
-
- public static final String DEBUG = Activator.PLUGIN_ID + "/debug"; //$NON-NLS-1$
-
- public static final String EXCEPTIONS_CATCHING = DEBUG
- + "/exceptions/catching"; //$NON-NLS-1$
-
- public static final String EXCEPTIONS_THROWING = DEBUG
- + "/exceptions/throwing"; //$NON-NLS-1$
-
- public static final String METHODS_ENTERING = DEBUG + "/methods/entering"; //$NON-NLS-1$
-
- public static final String METHODS_EXITING = DEBUG + "/methods/exiting"; //$NON-NLS-1$
-
- public static final String REMOTE_SERVICE_ADMIN = DEBUG
- + "/remoteserviceadmin"; //$NON-NLS-1$
-
- public static final String TOPOLOGY_MANAGER = DEBUG + "/topologymanager"; //$NON-NLS-1$
-
- public static final String CONTAINER_SELECTOR = DEBUG
- + "/containerselector"; //$NON-NLS-1$
-
- public static final String DISCOVERY = DEBUG + "/discovery"; //$NON-NLS-1$
-
- public static final String ENDPOINT_DESCRIPTION_READER = DEBUG
- + "/endpointdescriptionreader"; //$NON-NLS-1$
-
- public static final String PACKAGE_VERSION_COMPARATOR = DEBUG
- + "/packageversioncomparator"; //$NON-NLS-1$
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java
deleted file mode 100644
index a1081f11c..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java
+++ /dev/null
@@ -1,798 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.DefaultHandler;
-
-public class EndpointDescriptionParser {
-
- private static List<String> multiValueTypes;
-
- static {
- multiValueTypes = Arrays.asList(new String[] { "String", "Long", //$NON-NLS-1$ //$NON-NLS-2$
- "long", "Double", "double", "float", "Float", "int", "Integer", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "byte", "Byte", "char", "Character", "boolean", "Boolean", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- "short", "Short" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private static final String ENDPOINT_DESCRIPTIONS = "endpoint-descriptions"; //$NON-NLS-1$
- private static final String ENDPOINT_DESCRIPTION = "endpoint-description"; //$NON-NLS-1$
- private static final String ENDPOINT_PROPERTY = "property"; //$NON-NLS-1$
- private static final String ENDPOINT_PROPERTY_NAME = "name"; //$NON-NLS-1$
- private static final String ENDPOINT_PROPERTY_VALUE = "value"; //$NON-NLS-1$
- private static final String ENDPOINT_PROPERTY_VALUETYPE = "value-type"; //$NON-NLS-1$
- private static final String ENDPOINT_PROPERTY_ARRAY = "array"; //$NON-NLS-1$
- private static final String ENDPOINT_PROPERTY_LIST = "list"; //$NON-NLS-1$
- private static final String ENDPOINT_PROPERTY_SET = "set"; //$NON-NLS-1$
- private static final String ENDPOINT_PROPERTY_XML = "xml"; //$NON-NLS-1$
-
- public static String[] noAttributes = new String[0];
-
- private XMLReader xmlReader;
- protected Locator locator = null; // document locator, if supported by the
- // parser
-
- class IgnoringHandler extends AbstractHandler {
-
- public IgnoringHandler(AbstractHandler parent) {
- super(parent);
- this.elementHandled = "IgnoringAll"; //$NON-NLS-1$
- }
-
- public void startElement(String name, Attributes attributes) {
- noSubElements(name, attributes);
- }
-
- }
-
- /**
- * Abstract base class for content handlers
- */
- abstract class AbstractHandler extends DefaultHandler {
-
- protected ContentHandler parentHandler = null;
- protected String elementHandled = null;
-
- protected StringBuffer characters = null; // character data inside an
- // element
-
- public AbstractHandler() {
- // Empty constructor for a root handler
- }
-
- public AbstractHandler(ContentHandler parentHandler) {
- this.parentHandler = parentHandler;
- xmlReader.setContentHandler(this);
- }
-
- public AbstractHandler(ContentHandler parentHandler,
- String elementHandled) {
- this.parentHandler = parentHandler;
- xmlReader.setContentHandler(this);
- this.elementHandled = elementHandled;
- }
-
- /**
- * Set the document locator for the parser
- *
- * @see org.xml.sax.ContentHandler#setDocumentLocator
- */
- public void setDocumentLocator(Locator docLocator) {
- locator = docLocator;
- }
-
- public void startElement(String uri, String localName, String qName,
- Attributes attributes) throws SAXException {
- finishCharacters();
- String name = makeSimpleName(localName, qName);
- startElement(name, attributes);
- }
-
- public abstract void startElement(String name, Attributes attributes)
- throws SAXException;
-
- public void invalidElement(String name, Attributes attributes) {
- unexpectedElement(this, name, attributes);
- new IgnoringHandler(this);
- }
-
- public void endElement(String namespaceURI, String localName,
- String qName) {
- finishCharacters();
- finished();
- // Restore the parent content handler
- xmlReader.setContentHandler(parentHandler);
- }
-
- /**
- * An implementation for startElement when there are no sub-elements
- */
- protected void noSubElements(String name, Attributes attributes) {
- unexpectedElement(this, name, attributes);
- // Create a new handler to ignore subsequent nested elements
- new IgnoringHandler(this);
- }
-
- /*
- * Save up character data until endElement or nested startElement
- *
- * @see org.xml.sax.ContentHandler#characters
- */
- public void characters(char[] chars, int start, int length) {
- if (this.characters == null) {
- this.characters = new StringBuffer();
- }
- this.characters.append(chars, start, length);
- }
-
- // Consume the characters accumulated in this.characters.
- // Called before startElement or endElement
- private String finishCharacters() {
- // common case -- no characters or only whitespace
- if (this.characters == null || this.characters.length() == 0) {
- return null;
- }
- if (allWhiteSpace(this.characters)) {
- this.characters.setLength(0);
- return null;
- }
-
- // process the characters
- try {
- String trimmedChars = this.characters.toString().trim();
- if (trimmedChars.length() == 0) {
- // this shouldn't happen due to the test for allWhiteSpace
- // above
- System.err.println("Unexpected non-whitespace characters: " //$NON-NLS-1$
- + trimmedChars);
- return null;
- }
- processCharacters(trimmedChars);
- return trimmedChars;
- } finally {
- this.characters.setLength(0);
- }
- }
-
- // Method to override in the handler of an element with CDATA.
- protected void processCharacters(String data) {
- if (data.length() > 0) {
- unexpectedCharacterData(this, data);
- }
- }
-
- private boolean allWhiteSpace(StringBuffer sb) {
- int length = sb.length();
- for (int i = 0; i < length; i += 1) {
- if (!Character.isWhitespace(sb.charAt(i))) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Called when this element and all elements nested into it have been
- * handled.
- */
- protected void finished() {
- // Do nothing by default
- }
-
- /*
- * A name used to identify the handler.
- */
- public String getName() {
- return (elementHandled != null ? elementHandled : "NoName"); //$NON-NLS-1$
- }
-
- /**
- * Parse the attributes of an element with only required attributes.
- */
- protected String[] parseRequiredAttributes(Attributes attributes,
- String[] required) {
- return parseAttributes(attributes, required, noAttributes);
- }
-
- /**
- * Parse the attributes of an element with a single optional attribute.
- */
- protected String parseOptionalAttribute(Attributes attributes,
- String name) {
- return parseAttributes(attributes, noAttributes,
- new String[] { name })[0];
- }
-
- /**
- * Parse the attributes of an element, given the list of required and
- * optional ones. Return values in same order, null for those not
- * present. Log warnings for extra attributes or missing required
- * attributes.
- */
- protected String[] parseAttributes(Attributes attributes,
- String[] required, String[] optional) {
- String[] result = new String[required.length + optional.length];
- for (int i = 0; i < attributes.getLength(); i += 1) {
- String name = attributes.getLocalName(i);
- String value = attributes.getValue(i).trim();
- int j;
- if ((j = indexOf(required, name)) >= 0) {
- result[j] = value;
- } else if ((j = indexOf(optional, name)) >= 0) {
- result[required.length + j] = value;
- } else {
- unexpectedAttribute(elementHandled, name, value);
- }
- }
- for (int i = 0; i < required.length; i += 1) {
- checkRequiredAttribute(elementHandled, required[i], result[i]);
- }
- return result;
- }
-
- }
-
- SAXParser getParser() throws ParserConfigurationException, SAXException {
- Activator a = Activator.getDefault();
- if (a == null)
- return null;
-
- SAXParserFactory factory = a.getSAXParserFactory();
- if (factory == null) {
- throw new SAXException("Unable to acquire sax parser"); //$NON-NLS-1$
- }
- factory.setNamespaceAware(true);
- factory.setValidating(false);
- try {
- factory.setFeature(
- "http://xml.org/sax/features/string-interning", true); //$NON-NLS-1$
- } catch (SAXException se) {
- // some parsers may not support string interning
- }
- SAXParser theParser = factory.newSAXParser();
- if (theParser == null) {
- throw new SAXException("Unable to create sax parser"); //$NON-NLS-1$
- }
- xmlReader = theParser.getXMLReader();
- return theParser;
- }
-
- abstract class RootHandler extends AbstractHandler {
-
- public RootHandler() {
- super();
- }
-
- public void initialize(DocHandler document, String rootName,
- Attributes attributes) {
- this.parentHandler = document;
- this.elementHandled = rootName;
- handleRootAttributes(attributes);
- }
-
- protected abstract void handleRootAttributes(Attributes attributes);
-
- }
-
- class DocHandler extends AbstractHandler {
-
- RootHandler rootHandler;
-
- public DocHandler(String rootName, RootHandler rootHandler) {
- super(null, rootName);
- this.rootHandler = rootHandler;
- }
-
- public void startElement(String name, Attributes attributes) {
- if (name.equals(elementHandled)) {
- rootHandler.initialize(this, name, attributes);
- xmlReader.setContentHandler(rootHandler);
- } else {
- this.noSubElements(name, attributes);
- }
- }
-
- }
-
- class EndpointDescriptionDocHandler extends DocHandler {
-
- public EndpointDescriptionDocHandler(String rootName,
- RootHandler rootHandler) {
- super(rootName, rootHandler);
- }
-
- public void processingInstruction(String target, String data)
- throws SAXException {
- // do nothing
- }
- }
-
- class EndpointDescriptionsHandler extends RootHandler {
-
- private List<EndpointDescription> endpointDescriptions = new ArrayList<EndpointDescription>();
- private EndpointDescriptionHandler endpointDescriptionHandler;
-
- protected void handleRootAttributes(Attributes attributes) {
- }
-
- public void startElement(String name, Attributes attributes)
- throws SAXException {
- if (ENDPOINT_DESCRIPTION.equals(name)) {
- if (endpointDescriptionHandler == null) {
- endpointDescriptionHandler = new EndpointDescriptionHandler(
- this, attributes, endpointDescriptions);
- } else {
- duplicateElement(this, name, attributes);
- }
- } else {
- invalidElement(name, attributes);
- }
- }
-
- public void endElement(String namespaceURI, String localName,
- String qName) {
- if (elementHandled.equals(localName)) {
- endpointDescriptionHandler = null;
- super.endElement(namespaceURI, localName, qName);
- }
- }
-
- public List<EndpointDescription> getEndpointDescriptions() {
- return endpointDescriptions;
- }
- }
-
- class EndpointDescriptionHandler extends AbstractHandler {
-
- private Map<String, Object> properties;
- private List<EndpointDescription> descriptions;
-
- public EndpointDescriptionHandler(ContentHandler parentHandler,
- Attributes attributes, List<EndpointDescription> descriptions) {
- super(parentHandler, ENDPOINT_DESCRIPTION);
- this.properties = new TreeMap<String, Object>(
- String.CASE_INSENSITIVE_ORDER);
- this.descriptions = descriptions;
- }
-
- public void startElement(String name, Attributes attributes)
- throws SAXException {
- if (ENDPOINT_PROPERTY.equals(name)) {
- new EndpointPropertyHandler(this, attributes, properties);
- }
- }
-
- public void endElement(String namespaceURI, String localName,
- String qName) {
- if (elementHandled.equals(localName)) {
- this.descriptions.add(new EndpointDescription(properties));
- super.endElement(namespaceURI, localName, qName);
- }
- }
-
- }
-
- abstract class MultiValueHandler extends AbstractHandler {
-
- protected String valueType;
-
- public MultiValueHandler(ContentHandler parentHandler,
- String elementHandled, String valueType) {
- super(parentHandler, elementHandled);
- this.valueType = valueType;
- }
-
- protected Object createValue(String value) {
- if (value == null)
- return null;
- if (valueType.equals("String")) { //$NON-NLS-1$
- return value;
- } else if (valueType.equals("long") || valueType.equals("Long")) { //$NON-NLS-1$ //$NON-NLS-2$
- return Long.valueOf(value);
- } else if (valueType.equals("double") || valueType.equals("Double")) { //$NON-NLS-1$ //$NON-NLS-2$
- return Double.valueOf(value);
- } else if (valueType.equals("float") || valueType.equals("Float")) { //$NON-NLS-1$ //$NON-NLS-2$
- return Float.valueOf(value);
- } else if (valueType.equals("int") || valueType.equals("Integer")) { //$NON-NLS-1$ //$NON-NLS-2$
- return Integer.valueOf(value);
- } else if (valueType.equals("byte") || valueType.equals("Byte")) { //$NON-NLS-1$ //$NON-NLS-2$
- return Byte.valueOf(value);
- } else if (valueType.equals("char") //$NON-NLS-1$
- || valueType.equals("Character")) { //$NON-NLS-1$
- char[] chars = new char[1];
- value.getChars(0, 1, chars, 0);
- return Character.valueOf(chars[0]);
- } else if (valueType.equals("boolean") //$NON-NLS-1$
- || valueType.equals("Boolean")) { //$NON-NLS-1$
- return Boolean.valueOf(value);
- } else if (valueType.equals("short") || valueType.equals("Short")) { //$NON-NLS-1$ //$NON-NLS-2$
- return Short.valueOf(value);
- }
- return null;
- }
-
- public void startElement(String name, Attributes attributes)
- throws SAXException {
- if (ENDPOINT_PROPERTY_VALUE.equals(name)) {
- characters = new StringBuffer();
- }
- }
-
- public void endElement(String namespaceURI, String localName,
- String qName) {
- if (ENDPOINT_PROPERTY_VALUE.equals(localName)) {
- Object value = createValue(processValue((characters == null) ? null
- : characters.toString()));
- if (value != null)
- addValue(value);
- characters = null;
- } else if (elementHandled.equals(localName)) {
- super.endElement(namespaceURI, localName, qName);
- }
- }
-
- private String processValue(String characters) {
- if (characters == null || characters.length() == 0)
- return null;
- if (valueType.equals("String")) //$NON-NLS-1$
- return characters;
- int startIndex = 0;
- while (Character.isWhitespace(characters.charAt(startIndex)))
- startIndex++;
- int endIndex = characters.length() - 1;
- while (Character.isWhitespace(characters.charAt(endIndex)))
- endIndex--;
- return characters.substring(startIndex, endIndex + 1);
- }
-
- protected abstract void addValue(Object value);
-
- public abstract Object getValues();
- }
-
- class ArrayMultiValueHandler extends MultiValueHandler {
-
- private List<Object> values = new ArrayList<Object>();
-
- public ArrayMultiValueHandler(ContentHandler parentHandler,
- String elementHandled, String valueType) {
- super(parentHandler, elementHandled, valueType);
- }
-
- protected Object[] createEmptyArrayOfType() {
- if (valueType.equals("String")) { //$NON-NLS-1$
- return new String[] {};
- } else if (valueType.equals("long") || valueType.equals("Long")) { //$NON-NLS-1$ //$NON-NLS-2$
- return new Long[] {};
- } else if (valueType.equals("double") || valueType.equals("Double")) { //$NON-NLS-1$ //$NON-NLS-2$
- return new Double[] {};
- } else if (valueType.equals("float") || valueType.equals("Float")) { //$NON-NLS-1$ //$NON-NLS-2$
- return new Double[] {};
- } else if (valueType.equals("int") || valueType.equals("Integer")) { //$NON-NLS-1$ //$NON-NLS-2$
- return new Integer[] {};
- } else if (valueType.equals("byte") || valueType.equals("Byte")) { //$NON-NLS-1$ //$NON-NLS-2$
- return new Byte[] {};
- } else if (valueType.equals("char") //$NON-NLS-1$
- || valueType.equals("Character")) { //$NON-NLS-1$
- return new Character[] {};
- } else if (valueType.equals("boolean") //$NON-NLS-1$
- || valueType.equals("Boolean")) { //$NON-NLS-1$
- return new Boolean[] {};
- } else if (valueType.equals("short") || valueType.equals("Short")) { //$NON-NLS-1$ //$NON-NLS-2$
- return new Short[] {};
- } else
- return null;
- }
-
- public Object getValues() {
- return values.toArray(createEmptyArrayOfType());
- }
-
- protected void addValue(Object value) {
- values.add(value);
- }
- }
-
- class ListMultiValueHandler extends MultiValueHandler {
-
- private List<Object> values = new ArrayList<Object>();
-
- public ListMultiValueHandler(ContentHandler parentHandler,
- String elementHandled, String valueType) {
- super(parentHandler, elementHandled, valueType);
- }
-
- public Object getValues() {
- return values;
- }
-
- protected void addValue(Object value) {
- values.add(value);
- }
- }
-
- class SetMultiValueHandler extends MultiValueHandler {
-
- private Set<Object> values = new HashSet<Object>();
-
- public SetMultiValueHandler(ContentHandler parentHandler,
- String elementHandled, String valueType) {
- super(parentHandler, elementHandled, valueType);
- }
-
- public Object getValues() {
- return values;
- }
-
- protected void addValue(Object value) {
- values.add(value);
- }
- }
-
- class XMLValueHandler extends AbstractHandler {
-
- private Map<String, String> nsPrefixMap = new HashMap<String, String>();
- private StringBuffer buf;
-
- public XMLValueHandler(ContentHandler parentHandler) {
- super(parentHandler, ENDPOINT_PROPERTY_XML);
- buf = new StringBuffer();
- }
-
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException {
- nsPrefixMap.put(uri, prefix);
- }
-
- public void startElement(String uri, String localName, String qName,
- Attributes attributes) throws SAXException {
- buf.append("<").append(qName); //$NON-NLS-1$
- for (Iterator<String> i = nsPrefixMap.keySet().iterator(); i
- .hasNext();) {
- String nsURI = (String) i.next();
- String prefix = (String) nsPrefixMap.get(nsURI);
- i.remove();
- if (nsURI != null) {
- buf.append(" xmlns"); //$NON-NLS-1$
- if (prefix != null)
- buf.append(":").append(prefix); //$NON-NLS-1$
- buf.append("=\"").append(nsURI).append("\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- for (int i = 0; i < attributes.getLength(); i++) {
- buf.append(" "); //$NON-NLS-1$
- buf.append(attributes.getQName(i))
- .append("=\"").append(attributes.getValue(i)).append("\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
- buf.append(">"); //$NON-NLS-1$
- characters = new StringBuffer();
- }
-
- public void startElement(String name, Attributes attributes)
- throws SAXException {
- // not used
- }
-
- public void endElement(String namespaceURI, String localName,
- String qName) {
- if (elementHandled.equals(localName)) {
- super.endElement(namespaceURI, localName, qName);
- } else {
- if (characters != null)
- buf.append(characters);
- buf.append("</").append(qName).append(">"); //$NON-NLS-1$ //$NON-NLS-2$
- characters = null;
- }
- }
-
- public String getXML() {
- return buf.toString();
- }
- }
-
- class EndpointPropertyHandler extends AbstractHandler {
-
- private Map<String, Object> properties;
- private String name;
- private String valueType = "String"; //$NON-NLS-1$
- private String value;
- private MultiValueHandler multiValueHandler;
- private XMLValueHandler xmlValueHandler;
-
- public EndpointPropertyHandler(ContentHandler parentHandler,
- Attributes attributes, Map<String, Object> properties)
- throws SAXException {
- super(parentHandler, ENDPOINT_PROPERTY);
- name = parseRequiredAttributes(attributes,
- new String[] { ENDPOINT_PROPERTY_NAME })[0];
- value = parseOptionalAttribute(attributes, ENDPOINT_PROPERTY_VALUE);
- String vt = parseOptionalAttribute(attributes,
- ENDPOINT_PROPERTY_VALUETYPE);
- if (vt != null) {
- if (!multiValueTypes.contains(vt))
- throw new SAXException("property element valueType=" + vt //$NON-NLS-1$
- + " not allowed"); //$NON-NLS-1$
- this.valueType = vt;
- }
- this.properties = properties;
- if (value != null) {
- String[] property = new String[] { name, value };
- if (isValidProperty(property)) {
- this.properties.put(property[0], property[1]);
- }
- }
- }
-
- public void startElement(String name, Attributes attributes)
- throws SAXException {
- // Should not happen if value is non-null
- if (value != null)
- throw new SAXException(
- "property element has both value attribute and sub-element"); //$NON-NLS-1$
- if (ENDPOINT_PROPERTY_ARRAY.equals(name)) {
- if (multiValueHandler == null) {
- multiValueHandler = new ArrayMultiValueHandler(this,
- ENDPOINT_PROPERTY_ARRAY, valueType);
- } else {
- duplicateElement(this, name, attributes);
- }
- } else if (ENDPOINT_PROPERTY_LIST.equals(name)) {
- if (multiValueHandler == null) {
- multiValueHandler = new ListMultiValueHandler(this,
- ENDPOINT_PROPERTY_LIST, valueType);
- } else {
- duplicateElement(this, name, attributes);
- }
- } else if (ENDPOINT_PROPERTY_SET.equals(name)) {
- if (multiValueHandler == null) {
- multiValueHandler = new SetMultiValueHandler(this,
- ENDPOINT_PROPERTY_SET, valueType);
- } else {
- duplicateElement(this, name, attributes);
- }
- } else if (ENDPOINT_PROPERTY_XML.equals(name)) {
- // xml
- if (xmlValueHandler == null) {
- xmlValueHandler = new XMLValueHandler(this);
- } else {
- duplicateElement(this, name, attributes);
- }
- } else {
- invalidElement(name, attributes);
- }
- }
-
- public void endElement(String namespaceURI, String localName,
- String qName) {
- if (elementHandled.equals(localName)) {
- if (multiValueHandler != null) {
- properties.put(name, multiValueHandler.getValues());
- multiValueHandler = null;
- } else if (xmlValueHandler != null) {
- properties.put(name, xmlValueHandler.getXML());
- xmlValueHandler = null;
- }
- super.endElement(namespaceURI, localName, qName);
- }
- }
-
- private boolean isValidProperty(String[] property) {
- return (property.length == 2 && property[0] != null && property[1] != null);
- }
- }
-
- public class EndpointDescription {
- private Map<String, Object> properties;
-
- public EndpointDescription(Map<String, Object> properties) {
- this.properties = properties;
- }
-
- public Map<String, Object> getProperties() {
- return properties;
- }
-
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("EndpointDescription [properties="); //$NON-NLS-1$
- builder.append(properties);
- builder.append("]"); //$NON-NLS-1$
- return builder.toString();
- }
-
- }
-
- public synchronized void parse(InputStream input) throws IOException {
- try {
- getParser();
- EndpointDescriptionsHandler endpointDescriptionsHandler = new EndpointDescriptionsHandler();
- xmlReader.setContentHandler(new EndpointDescriptionDocHandler(
- ENDPOINT_DESCRIPTIONS, endpointDescriptionsHandler));
- xmlReader.parse(new InputSource(input));
- endpointDescriptions = endpointDescriptionsHandler
- .getEndpointDescriptions();
- } catch (SAXException e) {
- throw new IOException(e.getMessage());
- } catch (ParserConfigurationException e) {
- throw new IOException(e.getMessage());
- } finally {
- input.close();
- }
-
- }
-
- public static String makeSimpleName(String localName, String qualifiedName) {
- if (localName != null && localName.length() > 0) {
- return localName;
- }
- int nameSpaceIndex = qualifiedName.indexOf(":"); //$NON-NLS-1$
- return (nameSpaceIndex == -1 ? qualifiedName : qualifiedName
- .substring(nameSpaceIndex + 1));
- }
-
- public void unexpectedElement(AbstractHandler handler, String element,
- Attributes attributes) {
- }
-
- public void unexpectedCharacterData(AbstractHandler handler, String cdata) {
- }
-
- public void unexpectedAttribute(String element, String attribute,
- String value) {
- }
-
- static int indexOf(String[] array, String value) {
- for (int i = 0; i < array.length; i += 1) {
- if (value == null ? array[i] == null : value.equals(array[i])) {
- return i;
- }
- }
- return -1;
- }
-
- public void checkRequiredAttribute(String element, String name, Object value) {
- }
-
- public void duplicateElement(AbstractHandler handler, String element,
- Attributes attributes) {
- // ignore the duplicate element entirely because we have already logged
- // it
- new IgnoringHandler(handler);
- }
-
- private List<EndpointDescription> endpointDescriptions;
-
- public List<EndpointDescription> getEndpointDescriptions() {
- return endpointDescriptions;
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/IDUtil.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/IDUtil.java
deleted file mode 100644
index 45f74ce6a..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/IDUtil.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.identity.IDCreateException;
-import org.eclipse.ecf.core.identity.IDFactory;
-import org.eclipse.ecf.core.identity.IIDFactory;
-import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.core.identity.StringID;
-
-public class IDUtil {
-
- public static IIDFactory getIDFactory() {
- return IDFactory.getDefault();
- }
-
- public static Namespace getNamespaceByName(String namespaceName) {
- if (namespaceName == null)
- return null;
- return getIDFactory().getNamespaceByName(namespaceName);
- }
-
- public static Namespace findNamespaceByIdName(String idName) {
- if (idName == null)
- return null;
- int colonIndex = idName.indexOf(Namespace.SCHEME_SEPARATOR);
- if (colonIndex <= 0)
- return null;
- String scheme = idName.substring(0, colonIndex);
- // First try to find the Namespace using the protocol directly
- Namespace ns = getNamespaceByName(scheme);
- return (ns == null) ? findNamespaceByScheme(scheme) : ns;
- }
-
- public static Namespace findNamespaceByScheme(String scheme) {
- if (scheme == null)
- return null;
- if (scheme.equals("ecftcp")) //$NON-NLS-1$
- return getIDFactory().getNamespaceByName(StringID.class.getName());
- List namespaces = getIDFactory().getNamespaces();
- for (Iterator i = namespaces.iterator(); i.hasNext();) {
- Namespace ns = (Namespace) i.next();
- if (scheme.equals(ns.getScheme()))
- return ns;
- }
- return null;
- }
-
- public static ID createID(String namespaceName, String idName)
- throws IDCreateException {
- Namespace ns = (namespaceName != null) ? getNamespaceByName(namespaceName)
- : findNamespaceByIdName(idName);
- if (ns == null)
- throw new IDCreateException(
- "Cannot find Namespace for namespaceName=" + namespaceName //$NON-NLS-1$
- + " and idName=" + idName); //$NON-NLS-1$
- return createID(ns, idName);
- }
-
- public static ID createID(Namespace namespace, String idName)
- throws IDCreateException {
- return getIDFactory().createID(namespace, idName);
- }
-
- public static ID createID(Namespace namespace, Object[] args)
- throws IDCreateException {
- return getIDFactory().createID(namespace, args);
- }
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LogUtility.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LogUtility.java
deleted file mode 100644
index 5d3ab96ec..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LogUtility.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ecf.core.util.Trace;
-
-public class LogUtility {
-
- public static void logError(String methodName, String debugOption,
- Class clazz, String message) {
- logError(methodName, debugOption, clazz, message, null);
- traceException(methodName, debugOption, clazz, message, null);
- }
-
- public static void logWarning(String methodName, String debugOption,
- Class clazz, String message) {
- trace(methodName, debugOption, clazz, "WARNING:" + message); //$NON-NLS-1$
- Activator.getDefault().log(
- new Status(IStatus.WARNING, Activator.PLUGIN_ID,
- IStatus.WARNING, clazz.getName() + ":" //$NON-NLS-1$
- + ((methodName == null) ? "<unknown>" //$NON-NLS-1$
- : methodName) + ":" //$NON-NLS-1$
- + ((message == null) ? "<empty>" : message), //$NON-NLS-1$
- null));
- }
-
- public static void logError(String methodName, String debugOption,
- Class clazz, String message, Throwable t) {
- if (t != null)
- traceException(methodName, debugOption, clazz, message, t);
- else
- trace(methodName, debugOption, clazz, message);
- Activator.getDefault().log(
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
- clazz.getName() + ":" //$NON-NLS-1$
- + ((methodName == null) ? "<unknown>" //$NON-NLS-1$
- : methodName) + ":" //$NON-NLS-1$
- + ((message == null) ? "<empty>" //$NON-NLS-1$
- : message), t));
- }
-
- public static void logWarning(String methodName, String debugOption,
- Class clazz, String message, Throwable t) {
- if (t != null)
- traceException(methodName, debugOption, clazz, message, t);
- else
- trace(methodName, debugOption, clazz, message);
- Activator.getDefault().log(
- new Status(IStatus.WARNING, Activator.PLUGIN_ID,
- IStatus.WARNING, clazz.getName() + ":" //$NON-NLS-1$
- + ((methodName == null) ? "<unknown>" //$NON-NLS-1$
- : methodName) + ":" //$NON-NLS-1$
- + ((message == null) ? "<empty>" //$NON-NLS-1$
- : message), t));
- }
-
- public static void logError(String methodName, String debugOption,
- Class clazz, IStatus status) {
- Throwable t = status.getException();
- if (t != null)
- traceException(methodName, debugOption, clazz, status.getMessage(),
- t);
- else
- trace(methodName, debugOption, clazz, status.getMessage());
- Activator.getDefault().log(status);
- }
-
- public static void logWarning(String methodName, String debugOption,
- Class clazz, IStatus status) {
- logError(methodName, debugOption, clazz, status);
- }
-
- public static void trace(String methodName, String debugOptions,
- Class clazz, String message) {
- Trace.trace(Activator.PLUGIN_ID, debugOptions, clazz, methodName,
- message);
- }
-
- public static void traceException(String methodName, String debugOption,
- Class clazz, String message, Throwable t) {
- Trace.catching(Activator.PLUGIN_ID, debugOption, clazz,
- ((methodName == null) ? "<unknown>" : methodName) + ":" //$NON-NLS-1$ //$NON-NLS-2$
- + ((message == null) ? "<empty>" : message), t); //$NON-NLS-1$
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java
deleted file mode 100644
index 096939f6b..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants;
-import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
-import org.eclipse.ecf.remoteservice.IRemoteServiceRegistration;
-import org.osgi.framework.ServiceReference;
-
-public class PropertiesUtil {
-
- protected static final List osgiProperties = Arrays
- .asList(new String[] {
- // OSGi properties
- org.osgi.framework.Constants.OBJECTCLASS,
- org.osgi.framework.Constants.SERVICE_ID,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID,
- org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED,
- org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_CONFIGS,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTENTS,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTERFACES,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS });
-
- protected static final List ecfProperties = Arrays.asList(new String[] {
- // ECF properties
- org.eclipse.ecf.remoteservice.Constants.OBJECTCLASS,
- org.eclipse.ecf.remoteservice.Constants.SERVICE_ID,
- RemoteConstants.DISCOVERY_DEFAULT_SERVICE_NAME_PREFIX,
- RemoteConstants.DISCOVERY_NAMING_AUTHORITY,
- RemoteConstants.DISCOVERY_PROTOCOLS,
- RemoteConstants.DISCOVERY_SCOPE,
- RemoteConstants.DISCOVERY_SERVICE_NAME,
- RemoteConstants.ENDPOINT_CONNECTTARGET_ID,
- RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE,
- RemoteConstants.ENDPOINT_IDFILTER_IDS,
- RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER,
- RemoteConstants.ENDPOINT_SERVICE_IMPORTED_CONFIGS_VALUE,
- RemoteConstants.SERVICE_EXPORTED_CONTAINER_CONNECT_CONTEXT,
- RemoteConstants.SERVICE_EXPORTED_CONTAINER_FACTORY_ARGS,
- RemoteConstants.SERVICE_EXPORTED_CONTAINER_ID,
- RemoteConstants.SERVICE_IMPORTED_VALUETYPE,
- RemoteConstants.SERVICE_TYPE });
-
- public static String verifyStringProperty(Map properties, String propName) {
- Object r = properties.get(propName);
- try {
- return (String) r;
- } catch (ClassCastException e) {
- IllegalArgumentException iae = new IllegalArgumentException(
- "property value is not a String: " + propName); //$NON-NLS-1$
- iae.initCause(e);
- throw iae;
- }
- }
-
- public static Object convertToStringPlusValue(List<String> values) {
- if (values == null)
- return null;
- int valuesSize = values.size();
- switch (valuesSize) {
- case 0:
- return null;
- case 1:
- return values.get(0);
- default:
- return values.toArray(new String[valuesSize]);
- }
- }
-
- public static String[] getStringArrayFromPropertyValue(Object value) {
- if (value == null)
- return null;
- else if (value instanceof String)
- return new String[] { (String) value };
- else if (value instanceof String[])
- return (String[]) value;
- else if (value instanceof Collection)
- return (String[]) ((Collection) value).toArray(new String[] {});
- else
- return null;
- }
-
- public static String[] getExportedInterfaces(
- ServiceReference serviceReference) {
- // Get the OSGi 4.2 specified required service property value
- Object propValue = serviceReference
- .getProperty(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTERFACES);
- // If the required property is not set then it's not being registered
- // as a remote service so we return null
- if (propValue == null)
- return null;
- boolean wildcard = propValue.equals("*"); //$NON-NLS-1$
- if (wildcard)
- return (String[]) serviceReference
- .getProperty(org.osgi.framework.Constants.OBJECTCLASS);
- else {
- final String[] stringValue = getStringArrayFromPropertyValue(propValue);
- if (stringValue != null && stringValue.length == 1
- && stringValue[0].equals("*")) { //$NON-NLS-1$
- LogUtility
- .logWarning(
- "getExportedInterfaces", //$NON-NLS-1$
- DebugOptions.TOPOLOGY_MANAGER,
- PropertiesUtil.class,
- "Service Exported Interfaces Wildcard does not accept String[\"*\"]"); //$NON-NLS-1$
- }
- return stringValue;
- }
- }
-
- public static String[] getServiceIntents(ServiceReference serviceReference,
- Map overridingProperties) {
- List results = new ArrayList();
-
- String[] intents = getStringArrayFromPropertyValue(overridingProperties
- .get(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS));
- if (intents == null) {
- intents = getStringArrayFromPropertyValue(serviceReference
- .getProperty(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS));
- }
- if (intents != null)
- results.addAll(Arrays.asList(intents));
-
- String[] exportedIntents = getStringArrayFromPropertyValue(overridingProperties
- .get(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTENTS));
- if (exportedIntents == null) {
- exportedIntents = getStringArrayFromPropertyValue(serviceReference
- .getProperty(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTENTS));
- }
- if (exportedIntents != null)
- results.addAll(Arrays.asList(exportedIntents));
-
- String[] extraIntents = getStringArrayFromPropertyValue(overridingProperties
- .get(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA));
- if (extraIntents == null) {
- extraIntents = getStringArrayFromPropertyValue(serviceReference
- .getProperty(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA));
- }
- if (extraIntents != null)
- results.addAll(Arrays.asList(extraIntents));
-
- if (results.size() == 0)
- return null;
- return (String[]) results.toArray(new String[results.size()]);
- }
-
- public static List getStringPlusProperty(Map properties, String key) {
- Object value = properties.get(key);
- if (value == null) {
- return Collections.EMPTY_LIST;
- }
-
- if (value instanceof String) {
- return Collections.singletonList((String) value);
- }
-
- if (value instanceof String[]) {
- String[] values = (String[]) value;
- List result = new ArrayList(values.length);
- for (int i = 0; i < values.length; i++) {
- if (values[i] != null) {
- result.add(values[i]);
- }
- }
- return Collections.unmodifiableList(result);
- }
-
- if (value instanceof Collection) {
- Collection values = (Collection) value;
- List result = new ArrayList(values.size());
- for (Iterator iter = values.iterator(); iter.hasNext();) {
- Object v = iter.next();
- if (v instanceof String) {
- result.add((String) v);
- }
- }
- return Collections.unmodifiableList(result);
- }
-
- return Collections.EMPTY_LIST;
- }
-
- public static Object getPropertyValue(ServiceReference serviceReference,
- String key) {
- return (serviceReference == null) ? null : serviceReference
- .getProperty(key);
- }
-
- public static Object getPropertyValue(ServiceReference serviceReference,
- Map<String, Object> overridingProperties, String key) {
- Object result = null;
- if (overridingProperties != null)
- result = overridingProperties.get(key);
- return (result != null) ? result : getPropertyValue(serviceReference,
- key);
- }
-
- public static boolean isOSGiProperty(String key) {
- return osgiProperties.contains(key)
- || key.startsWith(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_PACKAGE_VERSION_);
- }
-
- public static boolean isECFProperty(String key) {
- return ecfProperties.contains(key);
- }
-
- public static boolean isReservedProperty(String key) {
- return isOSGiProperty(key) || isECFProperty(key);
- }
-
- public static Map createMapFromDictionary(Dictionary input) {
- if (input == null)
- return null;
- Map result = new HashMap();
- for (Enumeration e = input.keys(); e.hasMoreElements();) {
- Object key = e.nextElement();
- Object val = input.get(key);
- result.put(key, val);
- }
- return result;
- }
-
- public static Dictionary createDictionaryFromMap(Map propMap) {
- if (propMap == null)
- return null;
- Dictionary result = new Properties();
- for (Iterator i = propMap.keySet().iterator(); i.hasNext();) {
- Object key = i.next();
- Object val = propMap.get(key);
- result.put(key, val);
- }
- return result;
- }
-
- public static Long getLongWithDefault(Map props, String key, Long def) {
- Object o = props.get(key);
- if (o instanceof Long)
- return (Long) o;
- if (o instanceof String)
- return Long.valueOf((String) o);
- return def;
- }
-
- public static String[] getStringArrayWithDefault(
- Map<String, Object> properties, String key, String[] def) {
- Object o = properties.get(key);
- if (o instanceof String) {
- return new String[] { (String) o };
- } else if (o instanceof String[]) {
- return (String[]) o;
- } else if (o instanceof List) {
- List l = (List) o;
- return (String[]) l.toArray(new String[l.size()]);
- }
- return def;
- }
-
- public static String getStringWithDefault(Map props, String key, String def) {
- Object o = props.get(key);
- if (o == null || (!(o instanceof String)))
- return def;
- return (String) o;
- }
-
- public static Map<String, Object> copyProperties(
- IRemoteServiceRegistration rsRegistration,
- Map<String, Object> target) {
- String[] keys = rsRegistration.getPropertyKeys();
- for (int i = 0; i < keys.length; i++)
- target.put(keys[i], rsRegistration.getProperty(keys[i]));
- return target;
- }
-
- public static Map<String, Object> copyProperties(
- Map<String, Object> source, Map<String, Object> target) {
- for (String key : source.keySet())
- target.put(key, source.get(key));
- return target;
- }
-
- public static Map<String, Object> copyNonECFProperties(
- Map<String, Object> source, Map<String, Object> target) {
- for (String key : source.keySet())
- if (!isECFProperty(key))
- target.put(key, source.get(key));
- return target;
- }
-
- public static Map<String, Object> copyNonReservedProperties(
- Map<String, Object> source, Map<String, Object> target) {
- for (String key : source.keySet())
- if (!isReservedProperty(key))
- target.put(key, source.get(key));
- return target;
- }
-
- public static Map<String, Object> copyNonECFProperties(
- ServiceReference serviceReference, Map<String, Object> target) {
- String[] keys = serviceReference.getPropertyKeys();
- for (int i = 0; i < keys.length; i++)
- if (!isECFProperty(keys[i]))
- target.put(keys[i], serviceReference.getProperty(keys[i]));
- return target;
- }
-
- public static Map<String, Object> copyNonReservedProperties(
- ServiceReference serviceReference, Map<String, Object> target) {
- String[] keys = serviceReference.getPropertyKeys();
- for (int i = 0; i < keys.length; i++)
- if (!isReservedProperty(keys[i]))
- target.put(keys[i], serviceReference.getProperty(keys[i]));
- return target;
- }
-
- public static Map<String, Object> copyNonReservedProperties(
- IRemoteServiceReference rsReference, Map<String, Object> target) {
- String[] keys = rsReference.getPropertyKeys();
- for (int i = 0; i < keys.length; i++)
- if (!isReservedProperty(keys[i]))
- target.put(keys[i], rsReference.getProperty(keys[i]));
- return target;
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java
deleted file mode 100644
index 84ddbe436..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.ecf.core.ContainerConnectException;
-import org.eclipse.ecf.core.ContainerTypeDescription;
-import org.eclipse.ecf.core.IContainer;
-import org.eclipse.ecf.core.IContainerFactory;
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.security.IConnectContext;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
-import org.eclipse.ecf.remoteservice.RemoteServiceContainer;
-
-public class AbstractConsumerContainerSelector extends
- AbstractContainerSelector {
-
- protected IRemoteServiceContainer selectExistingConsumerContainer(
- ID endpointID, String[] remoteSupportedConfigs, ID connectTargetID) {
-
- // Get all containers available
- IContainer[] containers = getContainers();
- // If none then return null
- if (containers == null)
- return null;
-
- for (int i = 0; i < containers.length; i++) {
- // Do *not* include containers with same ID as endpointID
- if (matchContainerID(containers[i], endpointID))
- continue;
-
- IRemoteServiceContainerAdapter adapter = hasRemoteServiceContainerAdapter(containers[i]);
- // Container must have adapter
- if (adapter != null
- // And it must match the connect namespace
- && matchConnectNamespace(containers[i], endpointID,
- connectTargetID)
- // and it must match the configs
- && matchSupportedConfigs(containers[i],
- remoteSupportedConfigs)
- // and the container should either not be connected or
- // already be connected to the desired endpointID
- && matchNotConnected(containers[i], endpointID,
- connectTargetID)) {
- trace("selectExistingConsumerContainer", //$NON-NLS-1$
- "MATCH of existing remote service container id=" //$NON-NLS-1$
- + containers[i].getID()
- + " endpointID=" //$NON-NLS-1$
- + endpointID
- + " remoteSupportedConfigs=" //$NON-NLS-1$
- + ((remoteSupportedConfigs == null) ? "[]" //$NON-NLS-1$
- : Arrays.asList(remoteSupportedConfigs)
- .toString()));
- return new RemoteServiceContainer(containers[i], adapter);
- } else {
- trace("selectExistingConsumerContainer", //$NON-NLS-1$
- "No match of existing remote service container id=" //$NON-NLS-1$
- + containers[i].getID()
- + " endpointID=" //$NON-NLS-1$
- + endpointID
- + " remoteSupportedConfigs=" //$NON-NLS-1$
- + ((remoteSupportedConfigs == null) ? "[]" //$NON-NLS-1$
- : Arrays.asList(remoteSupportedConfigs)
- .toString()));
- }
- }
- return null;
- }
-
- protected boolean matchNotConnected(IContainer container, ID endpointID,
- ID connectTargetID) {
- // if the container is not connected, OR it's connected to the desired
- // endpointID already then we've got a match
- ID connectedID = container.getConnectedID();
- if (connectedID == null || connectedID.equals(endpointID)
- || connectedID.equals(connectTargetID))
- return true;
- return false;
- }
-
- protected boolean matchSupportedConfigs(IContainer container,
- String[] remoteSupportedConfigs) {
- if (remoteSupportedConfigs == null)
- return false;
- ContainerTypeDescription description = getContainerTypeDescription(container);
- if (description == null)
- return false;
- return description.getImportedConfigs(remoteSupportedConfigs) != null;
- }
-
- protected void connectContainerToTarget(
- IRemoteServiceContainer rsContainer, ID connectTargetID) {
- if (connectTargetID == null)
- return;
- IContainer container = rsContainer.getContainer();
- ID connectedID = container.getConnectedID();
- // Only connect the container to the connect target when
- // it's not already connected
- if (connectedID == null) {
- // connect to target
- try {
- connectContainer(container, connectTargetID,
- getConnectContext(container, connectTargetID));
- } catch (ContainerConnectException e) {
- logException("Exception connecting container id=" //$NON-NLS-1$
- + container.getID() + " to connectTargetID=" //$NON-NLS-1$
- + connectTargetID, e);
- }
- }
- }
-
- protected IConnectContext getConnectContext(IContainer container,
- ID connectTargetID) {
- return null;
- }
-
- protected IRemoteServiceContainer createAndConfigureConsumerContainer(
- String[] remoteSupportedConfigs, Map remoteExportedProperties) {
- if (remoteSupportedConfigs == null
- || remoteSupportedConfigs.length == 0)
- return null;
- // Get container factory
- IContainerFactory containerFactory = getContainerFactory();
- if (containerFactory == null)
- return null;
- // Get all container type descriptions from factory
- List containerTypeDescriptions = containerFactory.getDescriptions();
- if (containerTypeDescriptions == null)
- return null;
-
- // Go through all containerTypeDescriptions
- for (Iterator i = containerTypeDescriptions.iterator(); i.hasNext();) {
- ContainerTypeDescription desc = (ContainerTypeDescription) i.next();
- // For each one, get the localImportedConfigs for the remote
- // supported configs
- String[] localImportedConfigs = desc
- .getImportedConfigs(remoteSupportedConfigs);
- // If their are some local imported configs for this description
- if (localImportedConfigs != null) {
- // Then get the imported config properties
- Dictionary importedConfigProperties = desc
- .getPropertiesForImportedConfigs(
- localImportedConfigs,
- PropertiesUtil
- .createDictionaryFromMap(remoteExportedProperties));
- // Then select a specific local imported config (typically the
- // first on in the array)
- String selectedConfig = selectLocalImportedConfig(
- localImportedConfigs, importedConfigProperties);
- // If we have one to use, then create the container
- if (selectedConfig != null) {
- IRemoteServiceContainer rsContainer = createContainer(
- selectedConfig,
- PropertiesUtil
- .createMapFromDictionary(importedConfigProperties));
- if (rsContainer != null) {
- trace("createAndConfigureProxyContainers", //$NON-NLS-1$
- "created new proxy container with config type=" //$NON-NLS-1$
- + selectedConfig + " and id=" //$NON-NLS-1$
- + rsContainer.getContainer().getID());
- return rsContainer;
- }
- }
- }
- }
- return null;
- }
-
- protected IRemoteServiceContainer createContainer(
- String containerTypeDescriptionName, Map properties) {
- try {
- IContainer container = (properties == null) ? getContainerFactory()
- .createContainer(containerTypeDescriptionName)
- : getContainerFactory().createContainer(
- containerTypeDescriptionName, properties);
- return new RemoteServiceContainer(container);
- } catch (Exception e) {
- logException(
- "Cannot create container with container type description name=" //$NON-NLS-1$
- + containerTypeDescriptionName, e);
- return null;
- }
- }
-
- protected String selectLocalImportedConfig(String[] localConfigTypes,
- Dictionary importedConfigProperties) {
- if (localConfigTypes == null || localConfigTypes.length == 0)
- return null;
- // By default, we'll select the first config to use...
- return localConfigTypes[0];
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java
deleted file mode 100644
index 6b90fe48a..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ecf.core.ContainerConnectException;
-import org.eclipse.ecf.core.ContainerCreateException;
-import org.eclipse.ecf.core.ContainerTypeDescription;
-import org.eclipse.ecf.core.IContainer;
-import org.eclipse.ecf.core.IContainerFactory;
-import org.eclipse.ecf.core.IContainerManager;
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.core.security.IConnectContext;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.DebugOptions;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.IDUtil;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.LogUtility;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
-import org.eclipse.ecf.remoteservice.RemoteServiceContainer;
-import org.osgi.framework.ServiceReference;
-
-public abstract class AbstractContainerSelector {
-
- public static final IRemoteServiceContainer[] EMPTY_REMOTE_SERVICE_CONTAINER_ARRAY = new IRemoteServiceContainer[] {};
-
- protected IContainerManager getContainerManager() {
- return Activator.getDefault().getContainerManager();
- }
-
- protected IContainerFactory getContainerFactory() {
- return getContainerManager().getContainerFactory();
- }
-
- protected ContainerTypeDescription[] getContainerTypeDescriptions() {
- return (ContainerTypeDescription[]) getContainerFactory()
- .getDescriptions().toArray(new ContainerTypeDescription[] {});
- }
-
- protected IContainer[] getContainers() {
- return getContainerManager().getAllContainers();
- }
-
- protected IRemoteServiceContainerAdapter hasRemoteServiceContainerAdapter(
- IContainer container) {
- return (IRemoteServiceContainerAdapter) container
- .getAdapter(IRemoteServiceContainerAdapter.class);
- }
-
- protected ContainerTypeDescription getContainerTypeDescription(
- IContainer container) {
- return getContainerManager().getContainerTypeDescription(
- container.getID());
- }
-
- protected IRemoteServiceContainer[] getRemoteServiceContainers(
- IContainer[] containers) {
- List results = new ArrayList();
- for (int i = 0; i < containers.length; i++) {
- IRemoteServiceContainerAdapter adapter = hasRemoteServiceContainerAdapter(containers[i]);
- if (adapter != null)
- results.add(new RemoteServiceContainer(containers[i], adapter));
- }
- return (IRemoteServiceContainer[]) results
- .toArray(new IRemoteServiceContainer[] {});
- }
-
- protected boolean includeContainerWithConnectNamespace(
- IContainer container, String connectNamespaceName) {
- if (connectNamespaceName != null) {
- Namespace namespace = container.getConnectNamespace();
- if (namespace != null
- && namespace.getName().equals(connectNamespaceName))
- return true;
- }
- return false;
- }
-
- protected void connectContainer(IContainer container, ID connectTargetID,
- IConnectContext connectContext) throws ContainerConnectException {
- trace("connectContainer", "Connecting container=" + container.getID() //$NON-NLS-1$ //$NON-NLS-2$
- + " to connectTargetID=" + connectTargetID); //$NON-NLS-1$
- container.connect(connectTargetID, connectContext);
- }
-
- protected String[] getSupportedConfigTypes(
- ContainerTypeDescription containerTypeDescription) {
- String[] supportedConfigs = containerTypeDescription
- .getSupportedConfigs();
- return (supportedConfigs == null) ? new String[0] : supportedConfigs;
- }
-
- protected String[] getSupportedIntents(
- ContainerTypeDescription containerTypeDescription) {
- String[] supportedIntents = containerTypeDescription
- .getSupportedIntents();
- return (supportedIntents == null) ? new String[0] : supportedIntents;
- }
-
- protected IContainer createContainer(ServiceReference serviceReference,
- ContainerTypeDescription containerTypeDescription)
- throws ContainerCreateException {
-
- IContainerFactory containerFactory = getContainerFactory();
-
- Object containerFactoryArguments = serviceReference
- .getProperty(RemoteConstants.SERVICE_EXPORTED_CONTAINER_FACTORY_ARGS);
- if (containerFactoryArguments instanceof String) {
- return containerFactory.createContainer(containerTypeDescription,
- (String) containerFactoryArguments);
- } else if (containerFactoryArguments instanceof ID) {
- return containerFactory.createContainer(containerTypeDescription,
- (ID) containerFactoryArguments);
- } else if (containerFactoryArguments instanceof Object[]) {
- return containerFactory.createContainer(containerTypeDescription,
- (Object[]) containerFactoryArguments);
- }
- return containerFactory.createContainer(containerTypeDescription);
- }
-
- protected ID createTargetID(IContainer container, String target) {
- return IDUtil.createID(container.getConnectNamespace(), target);
- }
-
- protected void disconnectContainer(IContainer container) {
- container.disconnect();
- }
-
- protected IConnectContext createConnectContext(
- ServiceReference serviceReference, IContainer container,
- Object context) {
- if (context instanceof IConnectContext)
- return (IConnectContext) context;
- return null;
- }
-
- protected void logException(String string, Exception e) {
- Activator.getDefault().log(
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, string, e));
- }
-
- protected void trace(String methodName, String message) {
- LogUtility.trace(methodName, DebugOptions.CONTAINER_SELECTOR,
- this.getClass(), message);
- }
-
- protected void traceException(String methodName, String message, Throwable t) {
- LogUtility.traceException(methodName, DebugOptions.EXCEPTIONS_CATCHING,
- this.getClass(), message, t);
- }
-
- protected void logError(String methodName, String message, Throwable t) {
- LogUtility.logError(methodName, DebugOptions.CONTAINER_SELECTOR,
- this.getClass(), message, t);
- }
-
- protected void logError(String methodName, String message) {
- LogUtility.logError(methodName, DebugOptions.CONTAINER_SELECTOR,
- this.getClass(), message);
- }
-
- protected void logWarning(String methodName, String message) {
- LogUtility.logWarning(methodName, DebugOptions.CONTAINER_SELECTOR,
- this.getClass(), message);
- }
-
- protected boolean matchConnectNamespace(IContainer container,
- ID endpointID, ID connectTargetID) {
- if (connectTargetID != null) {
- return connectTargetID.getNamespace().getName()
- .equals(container.getConnectNamespace().getName());
- }
- if (endpointID == null)
- return false;
- return endpointID.getNamespace().getName()
- .equals(container.getConnectNamespace().getName());
- }
-
- protected boolean matchContainerID(IContainer container, ID endpointID) {
- if (endpointID == null)
- return false;
- return endpointID.equals(container.getID());
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java
deleted file mode 100644
index e8d0094d9..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.ecf.core.ContainerConnectException;
-import org.eclipse.ecf.core.ContainerCreateException;
-import org.eclipse.ecf.core.ContainerTypeDescription;
-import org.eclipse.ecf.core.IContainer;
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.identity.IDCreateException;
-import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.core.security.IConnectContext;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.IDUtil;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
-import org.eclipse.ecf.remoteservice.RemoteServiceContainer;
-import org.osgi.framework.ServiceReference;
-
-public abstract class AbstractHostContainerSelector extends
- AbstractContainerSelector {
-
- private static final String NODEFAULT = "<<nodefault>>"; //$NON-NLS-1$
- protected String[] defaultConfigTypes;
-
- public AbstractHostContainerSelector(String[] defaultConfigTypes) {
- this.defaultConfigTypes = defaultConfigTypes;
- }
-
- protected Collection selectExistingHostContainers(
- ServiceReference serviceReference,
- String[] serviceExportedInterfaces,
- String[] serviceExportedConfigs, String[] serviceIntents) {
- List results = new ArrayList();
- // Get all existing containers
- IContainer[] containers = getContainers();
- // If nothing there, then return empty array
- if (containers == null || containers.length == 0)
- return results;
-
- for (int i = 0; i < containers.length; i++) {
- // Check to make sure it's a rs container adapter. If it's not go
- // onto next one
- IRemoteServiceContainerAdapter adapter = hasRemoteServiceContainerAdapter(containers[i]);
- if (adapter == null)
- continue;
- // Get container type description and intents
- ContainerTypeDescription description = getContainerTypeDescription(containers[i]);
- // If it has no description go onto next
- if (description == null)
- continue;
-
- if (matchExistingHostContainer(serviceReference, containers[i],
- adapter, description, serviceExportedConfigs,
- serviceIntents)) {
- trace("selectExistingHostContainers", "INCLUDING containerID=" //$NON-NLS-1$ //$NON-NLS-2$
- + containers[i].getID()
- + "configs=" //$NON-NLS-1$
- + ((serviceExportedConfigs == null) ? "null" : Arrays //$NON-NLS-1$
- .asList(serviceExportedConfigs).toString())
- + "intents=" //$NON-NLS-1$
- + ((serviceIntents == null) ? "null" : Arrays.asList( //$NON-NLS-1$
- serviceIntents).toString()));
- results.add(new RemoteServiceContainer(containers[i], adapter));
- } else {
- trace("selectExistingHostContainers", "EXCLUDING containerID=" //$NON-NLS-1$ //$NON-NLS-2$
- + containers[i].getID()
- + "configs=" //$NON-NLS-1$
- + ((serviceExportedConfigs == null) ? "null" : Arrays //$NON-NLS-1$
- .asList(serviceExportedConfigs).toString())
- + "intents=" //$NON-NLS-1$
- + ((serviceIntents == null) ? "null" : Arrays.asList( //$NON-NLS-1$
- serviceIntents).toString()));
- }
- }
- return results;
- }
-
- protected boolean matchHostContainerToConnectTarget(
- ServiceReference serviceReference, IContainer container) {
- String target = (String) serviceReference
- .getProperty(RemoteConstants.ENDPOINT_CONNECTTARGET_ID);
- if (target == null)
- return true;
- // If a targetID is specified, make sure it either matches what the
- // container
- // is already connected to, or that we connect an unconnected container
- ID connectedID = container.getConnectedID();
- // If the container is not already connected to anything
- // then we connect it to the given target
- if (connectedID == null) {
- // connect to the target and we have a match
- try {
- connectHostContainer(serviceReference, container, target);
- } catch (Exception e) {
- logException("doConnectContainer containerID=" //$NON-NLS-1$
- + container.getID() + " target=" + target, e); //$NON-NLS-1$
- return false;
- }
- return true;
- } else {
- ID targetID = createTargetID(container, target);
- // We check here if the currently connectedID equals the target.
- // If it does we have a match
- if (connectedID.equals(targetID))
- return true;
- }
- return false;
- }
-
- protected boolean matchExistingHostContainer(
- ServiceReference serviceReference, IContainer container,
- IRemoteServiceContainerAdapter adapter,
- ContainerTypeDescription description, String[] requiredConfigTypes,
- String[] requiredServiceIntents) {
-
- return matchHostSupportedConfigTypes(requiredConfigTypes, description)
- && matchHostSupportedIntents(requiredServiceIntents,
- description)
- && matchHostContainerID(serviceReference, container)
- && matchHostContainerToConnectTarget(serviceReference,
- container);
- }
-
- protected boolean matchHostContainerID(ServiceReference serviceReference,
- IContainer container) {
-
- ID containerID = container.getID();
- // No match if the container has no ID
- if (containerID == null)
- return false;
-
- // Then get containerid if specified directly by user in properties
- ID requiredContainerID = (ID) serviceReference
- .getProperty(RemoteConstants.SERVICE_EXPORTED_CONTAINER_ID);
- // If the CONTAINER_I
- if (requiredContainerID != null) {
- return requiredContainerID.equals(containerID);
- }
- // Else get the container factory arguments, create an ID from the
- // arguments
- // and check if the ID matches that
- Namespace ns = containerID.getNamespace();
- Object cid = serviceReference
- .getProperty(RemoteConstants.SERVICE_EXPORTED_CONTAINER_FACTORY_ARGS);
- // If no arguments are present, then any container ID should match
- if (cid == null)
- return true;
- ID cID = null;
- if (cid instanceof ID) {
- cID = (ID) cid;
- } else if (cid instanceof String) {
- cID = IDUtil.createID(ns, (String) cid);
- } else if (cid instanceof Object[]) {
- Object cido = ((Object[]) cid)[0];
- cID = IDUtil.createID(ns, new Object[] { cido });
- }
- if (cID == null)
- return true;
- return containerID.equals(cID);
- }
-
- protected boolean matchHostSupportedConfigTypes(
- String[] requiredConfigTypes,
- ContainerTypeDescription containerTypeDescription) {
- // if no config type is set the spec requires to create a default
- // endpoint (see section 122.5.1)
- if (requiredConfigTypes == null)
- return true;
- // Get supported config types for this description
- String[] supportedConfigTypes = getSupportedConfigTypes(containerTypeDescription);
- // If it doesn't support anything, return false
- if (supportedConfigTypes == null || supportedConfigTypes.length == 0)
- return false;
- // Turn supported config types for this description into list
- List supportedConfigTypesList = Arrays.asList(supportedConfigTypes);
- List requiredConfigTypesList = Arrays.asList(requiredConfigTypes);
- // We check all of the required config types and make sure
- // that they are present in the supportedConfigTypes
- boolean result = true;
- for (Iterator i = requiredConfigTypesList.iterator(); i.hasNext();)
- result &= supportedConfigTypesList.contains(i.next());
- return result;
- }
-
- protected Collection createAndConfigureHostContainers(
- ServiceReference serviceReference,
- String[] serviceExportedInterfaces, String[] requiredConfigs,
- String[] requiredIntents) {
-
- List results = new ArrayList();
- ContainerTypeDescription[] descriptions = getContainerTypeDescriptions();
- if (descriptions == null)
- return results;
- // If there are no required configs specified, then create any defaults
- if (requiredConfigs == null || requiredConfigs.length == 0) {
- ContainerTypeDescription[] ctds = getContainerTypeDescriptionsForDefaultConfigTypes(descriptions);
- if (ctds != null) {
- for (int i = 0; i < ctds.length; i++) {
- IRemoteServiceContainer rsContainer = createRSContainer(
- serviceReference, ctds[i]);
- if (rsContainer != null)
- results.add(rsContainer);
- }
- }
- } else {
- // See if we have a match
- for (int i = 0; i < descriptions.length; i++) {
- IRemoteServiceContainer rsContainer = createMatchingContainer(
- descriptions[i], serviceReference,
- serviceExportedInterfaces, requiredConfigs,
- requiredIntents);
- if (rsContainer != null)
- results.add(rsContainer);
- }
- }
- // we still haven't created one then we check for no default and if
- // not present then we
- // create default ones
- if (results.size() == 0 && requiredConfigs != null
- && requiredConfigs.length > 0) {
- List requiredConfigsList = Arrays.asList(requiredConfigs);
- if (!requiredConfigsList.contains(NODEFAULT)) {
- ContainerTypeDescription[] ctds = getContainerTypeDescriptionsForDefaultConfigTypes(descriptions);
- if (ctds != null) {
- for (int i = 0; i < ctds.length; i++) {
- IRemoteServiceContainer rsContainer = createRSContainer(
- serviceReference, ctds[i]);
- if (rsContainer != null)
- results.add(rsContainer);
- }
- }
- }
- }
- return results;
- }
-
- protected ContainerTypeDescription[] getContainerTypeDescriptionsForDefaultConfigTypes(
- ContainerTypeDescription[] descriptions) {
- String[] defaultConfigTypes = getDefaultConfigTypes();
- if (defaultConfigTypes == null || defaultConfigTypes.length == 0)
- return null;
- List results = new ArrayList();
- for (int i = 0; i < descriptions.length; i++) {
- // For each description, get supported config types
- String[] supportedConfigTypes = descriptions[i]
- .getSupportedConfigs();
- if (supportedConfigTypes != null
- && matchDefaultConfigTypes(defaultConfigTypes,
- supportedConfigTypes))
- results.add(descriptions[i]);
- }
- return (ContainerTypeDescription[]) results
- .toArray(new ContainerTypeDescription[] {});
- }
-
- protected boolean matchDefaultConfigTypes(String[] defaultConfigTypes,
- String[] supportedConfigTypes) {
- List supportedConfigTypesList = Arrays.asList(supportedConfigTypes);
- for (int i = 0; i < defaultConfigTypes.length; i++) {
- if (supportedConfigTypesList.contains(defaultConfigTypes[i]))
- return true;
- }
- return false;
- }
-
- protected String[] getDefaultConfigTypes() {
- return defaultConfigTypes;
- }
-
- protected IRemoteServiceContainer createMatchingContainer(
- ContainerTypeDescription containerTypeDescription,
- ServiceReference serviceReference,
- String[] serviceExportedInterfaces, String[] requiredConfigs,
- String[] requiredIntents) {
-
- if (matchHostSupportedConfigTypes(requiredConfigs,
- containerTypeDescription)
- && matchHostSupportedIntents(requiredIntents,
- containerTypeDescription)) {
- return createRSContainer(serviceReference, containerTypeDescription);
- }
- return null;
- }
-
- protected IRemoteServiceContainer createRSContainer(
- ServiceReference serviceReference,
- ContainerTypeDescription containerTypeDescription) {
- try {
- IContainer container = createContainer(serviceReference,
- containerTypeDescription);
- IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container
- .getAdapter(IRemoteServiceContainerAdapter.class);
- if (adapter == null)
- throw new ContainerCreateException(
- "Container does not implement IRemoteServiceContainerAdapter"); //$NON-NLS-1$
- return new RemoteServiceContainer(container, adapter);
- } catch (Exception e) {
- logException(
- "Exception creating container from ContainerTypeDescription=" //$NON-NLS-1$
- + containerTypeDescription, e);
- return null;
- }
- }
-
- protected void connectHostContainer(ServiceReference serviceReference,
- IContainer container, Object target)
- throws ContainerConnectException, IDCreateException {
- ID targetID = (target instanceof String) ? IDUtil.createID(
- container.getConnectNamespace(), (String) target) : IDUtil
- .createID(container.getConnectNamespace(),
- new Object[] { target });
- Object context = serviceReference
- .getProperty(RemoteConstants.SERVICE_EXPORTED_CONTAINER_CONNECT_CONTEXT);
- IConnectContext connectContext = null;
- if (context != null) {
- connectContext = createConnectContext(serviceReference, container,
- context);
- }
- // connect the container
- container.connect(targetID, connectContext);
- }
-
- protected boolean matchHostSupportedIntents(
- String[] serviceRequiredIntents,
- ContainerTypeDescription containerTypeDescription) {
- // If there are no required intents then we have a match
- if (serviceRequiredIntents == null)
- return true;
-
- String[] supportedIntents = getSupportedIntents(containerTypeDescription);
-
- if (supportedIntents == null)
- return false;
-
- List supportedIntentsList = Arrays.asList(supportedIntents);
-
- boolean result = true;
- for (int i = 0; i < serviceRequiredIntents.length; i++)
- result = result
- && supportedIntentsList.contains(serviceRequiredIntents[i]);
-
- return result;
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
deleted file mode 100644
index 82bcb6749..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
+++ /dev/null
@@ -1,405 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.discovery.IServiceProperties;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.DebugOptions;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.LogUtility;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
-import org.osgi.framework.Version;
-
-public abstract class AbstractMetadataFactory {
-
- protected static final String LIST_SEPARATOR = " "; //$NON-NLS-1$
-
- protected void encodeString(IServiceProperties props, String name,
- String value) {
- props.setPropertyString(name, value);
- }
-
- protected String decodeString(IServiceProperties props, String name) {
- return props.getPropertyString(name);
- }
-
- protected void encodeLong(IServiceProperties result, String name, Long value) {
- result.setPropertyString(name, value.toString());
- }
-
- protected Long decodeLong(IServiceProperties props, String name) {
- String longAsString = props.getPropertyString(name);
- if (longAsString == null)
- return new Long(0);
- return new Long(longAsString);
- }
-
- protected void encodeList(IServiceProperties props, String name,
- List<String> list) {
- if (list == null)
- return;
- if (list.size() == 1) {
- props.setPropertyString(name, list.get(0));
- } else {
- final StringBuffer result = new StringBuffer();
- for (Iterator<String> i = list.iterator(); i.hasNext();) {
- result.append(i.next());
- if (i.hasNext())
- result.append(LIST_SEPARATOR);
- }
- // Now add to props
- props.setPropertyString(name, result.toString());
- }
- }
-
- protected List<String> decodeList(IServiceProperties props, String name) {
- String value = props.getPropertyString(name);
- if (value == null)
- return Collections.EMPTY_LIST;
- List<String> result = new ArrayList<String>();
- final StringTokenizer t = new StringTokenizer(value, LIST_SEPARATOR);
- while (t.hasMoreTokens())
- result.add(t.nextToken());
- return result;
- }
-
- protected void decodeOSGiProperties(IServiceProperties props,
- Map osgiProperties) {
- // org.osgi.framework.Constants.OBJECTCLASS
- List<String> interfaces = decodeList(props,
- org.osgi.framework.Constants.OBJECTCLASS);
- osgiProperties.put(org.osgi.framework.Constants.OBJECTCLASS,
- (String[]) interfaces.toArray(new String[interfaces.size()]));
- // org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_PACKAGE_VERSION_
- for (String intf : interfaces) {
- String packageKey = org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_PACKAGE_VERSION_
- + getPackageName(intf);
- String intfVersion = decodeString(props, packageKey);
- if (intfVersion != null)
- osgiProperties.put(packageKey, intfVersion);
- }
- // org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID
- String endpointId = decodeString(props,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID);
- osgiProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID,
- endpointId);
- // org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID
- Long endpointServiceId = decodeLong(
- props,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID);
- osgiProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID,
- endpointServiceId);
- // org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID
- String fwkuuid = decodeString(
- props,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID);
- osgiProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID,
- fwkuuid);
- // org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS
- List<String> configTypes = decodeList(
- props,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS);
- if (configTypes != null && configTypes.size() > 0)
- osgiProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,
- (String[]) configTypes
- .toArray(new String[configTypes.size()]));
- // org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS
- List<String> intents = decodeList(
- props,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS);
- if (intents != null && intents.size() > 0)
- osgiProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS,
- (String[]) intents.toArray(new String[intents
- .size()]));
- // org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED
- List<String> remoteConfigsSupported = decodeList(
- props,
- org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED);
- if (remoteConfigsSupported != null && remoteConfigsSupported.size() > 0)
- osgiProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED,
- (String[]) remoteConfigsSupported
- .toArray(new String[remoteConfigsSupported
- .size()]));
- // org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED
- List<String> remoteIntentsSupported = decodeList(
- props,
- org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED);
- if (remoteIntentsSupported != null && remoteIntentsSupported.size() > 0)
- osgiProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED,
- (String[]) remoteIntentsSupported
- .toArray(new String[remoteIntentsSupported
- .size()]));
-
- }
-
- protected EndpointDescription decodeEndpointDescription(
- IServiceProperties discoveredServiceProperties) {
-
- Map<String, Object> endpointDescriptionProperties = new TreeMap<String, Object>(
- String.CASE_INSENSITIVE_ORDER);
-
- decodeOSGiProperties(discoveredServiceProperties,
- endpointDescriptionProperties);
-
- // remote service id
- Long remoteServiceId = decodeLong(discoveredServiceProperties,
- org.eclipse.ecf.remoteservice.Constants.SERVICE_ID);
- endpointDescriptionProperties.put(
- org.eclipse.ecf.remoteservice.Constants.SERVICE_ID,
- remoteServiceId);
-
- // container id namespace
- String containerIDNamespace = decodeString(discoveredServiceProperties,
- RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE);
- if (containerIDNamespace != null)
- endpointDescriptionProperties.put(
- RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE,
- containerIDNamespace);
-
- // connect target ID
- String connectTargetIDName = decodeString(discoveredServiceProperties,
- RemoteConstants.ENDPOINT_CONNECTTARGET_ID);
- if (connectTargetIDName != null)
- endpointDescriptionProperties.put(
- RemoteConstants.ENDPOINT_CONNECTTARGET_ID,
- connectTargetIDName);
-
- // ID filter
- List<String> idFilterNames = decodeList(discoveredServiceProperties,
- RemoteConstants.ENDPOINT_IDFILTER_IDS);
- Object idFilterNamesval = PropertiesUtil
- .convertToStringPlusValue(idFilterNames);
- if (idFilterNamesval != null)
- endpointDescriptionProperties.put(
- RemoteConstants.ENDPOINT_IDFILTER_IDS, idFilterNamesval);
-
- // remote service filter
- String remoteServiceFilter = decodeString(discoveredServiceProperties,
- RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER);
- if (remoteServiceFilter != null)
- endpointDescriptionProperties.put(
- RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER,
- remoteServiceFilter);
-
- // Finally, fill out other properties
- decodeNonStandardServiceProperties(discoveredServiceProperties,
- endpointDescriptionProperties);
-
- return new EndpointDescription(endpointDescriptionProperties);
- }
-
- private String getPackageName(String className) {
- int lastDotIndex = className.lastIndexOf("."); //$NON-NLS-1$
- if (lastDotIndex == -1)
- return ""; //$NON-NLS-1$
- return className.substring(0, lastDotIndex);
- }
-
- protected void encodeOSGiServiceProperties(
- EndpointDescription endpointDescription, IServiceProperties result) {
- // org.osgi.framework.Constants.OBJECTCLASS =
- // endpointDescription.getInterfaces();
- List<String> interfaces = endpointDescription.getInterfaces();
- encodeList(result, org.osgi.framework.Constants.OBJECTCLASS, interfaces);
- // org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_PACKAGE_VERSION_
- // version every interface package, make sure to encode package version
- // (if specified)
- for (String intf : interfaces) {
- String intfPackageName = getPackageName(intf);
- Version intfVersion = endpointDescription
- .getPackageVersion(intfPackageName);
- if (intfVersion != null
- && !Version.emptyVersion.equals(intfVersion))
- encodeString(
- result,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_PACKAGE_VERSION_
- + intfPackageName, intfVersion.toString());
- }
- // org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID ==
- // endpointDescription.getId()
- String endpointId = endpointDescription.getId();
- encodeString(
- result,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID,
- endpointId);
- // org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID
- // = endpointDescription.getServiceId()
- long endpointServiceId = endpointDescription.getServiceId();
- encodeLong(
- result,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID,
- new Long(endpointServiceId));
- // org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID
- // = endpointDescription.getFrameworkUUID()
- String frameworkUUID = endpointDescription.getFrameworkUUID();
- if (frameworkUUID != null)
- encodeString(
- result,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID,
- frameworkUUID);
- // org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS
- // = endpointDescription.getConfigurationTypes();
- List<String> configurationTypes = endpointDescription
- .getConfigurationTypes();
- if (configurationTypes.size() > 0)
- encodeList(
- result,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,
- configurationTypes);
- // org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS =
- // endpointDescription.getIntents()
- List<String> serviceIntents = endpointDescription.getIntents();
- if (serviceIntents.size() > 0)
- encodeList(
- result,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS,
- serviceIntents);
- // org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED
- Map endpointDescriptionProperties = endpointDescription.getProperties();
- List<String> remoteConfigsSupported = PropertiesUtil
- .getStringPlusProperty(
- endpointDescriptionProperties,
- org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED);
- if (remoteConfigsSupported.size() > 0)
- encodeList(
- result,
- org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED,
- remoteConfigsSupported);
- // org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED
- List<String> remoteIntentsSupported = PropertiesUtil
- .getStringPlusProperty(
- endpointDescriptionProperties,
- org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED);
- if (remoteIntentsSupported.size() > 0)
- encodeList(
- result,
- org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED,
- remoteIntentsSupported);
-
- }
-
- protected void encodeServiceProperties(
- EndpointDescription endpointDescription, IServiceProperties result) {
-
- encodeOSGiServiceProperties(endpointDescription, result);
-
- // org.eclipse.ecf.remoteservice.Constants.SERVICE_ID =
- // endpointDescription.getRemoteServiceId()
- long remoteServiceId = endpointDescription.getRemoteServiceId();
- encodeLong(result, org.eclipse.ecf.remoteservice.Constants.SERVICE_ID,
- new Long(remoteServiceId));
-
- // org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE
- // = endpointDescription.getIdNamespace()
- String containerIDNamespace = endpointDescription.getIdNamespace();
- if (containerIDNamespace != null)
- encodeString(result,
- RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE,
- containerIDNamespace);
-
- // org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants.ENDPOINT_CONNECTTARGET_ID
- // = endpointDescription.getRemoteServiceId()
- ID connectTargetID = endpointDescription.getConnectTargetID();
- if (connectTargetID != null)
- encodeString(result, RemoteConstants.ENDPOINT_CONNECTTARGET_ID,
- connectTargetID.getName());
-
- // org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants.ENDPOINT_IDFILTER_IDS
- // = endpointDescription.getIDFilter();
- ID[] idFilter = endpointDescription.getIDFilter();
- if (idFilter != null && idFilter.length > 0) {
- List<String> idNames = new ArrayList<String>();
- for (int i = 0; i < idFilter.length; i++)
- idNames.add(idFilter[i].getName());
- encodeList(result, RemoteConstants.ENDPOINT_IDFILTER_IDS, idNames);
- }
-
- // org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER
- // = endpointDescription.getRemoteServiceFilter()
- String remoteFilter = endpointDescription.getRemoteServiceFilter();
- if (remoteFilter != null) {
- encodeString(result, RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER,
- remoteFilter);
- }
- // encode non standard properties
- encodeNonStandardServiceProperties(endpointDescription.getProperties(),
- result);
- }
-
- protected void encodeNonStandardServiceProperties(
- Map<String, Object> properties, IServiceProperties result) {
- for (String key : properties.keySet()) {
- if (!PropertiesUtil.isReservedProperty(key)) {
- Object val = properties.get(key);
- if (val instanceof byte[]) {
- result.setPropertyBytes(key, (byte[]) val);
- } else if (val instanceof String) {
- result.setPropertyString(key, (String) val);
- } else {
- result.setProperty(key, val);
- }
- }
- }
- }
-
- protected void decodeNonStandardServiceProperties(IServiceProperties props,
- Map<String, Object> result) {
- for (Enumeration keys = props.getPropertyNames(); keys
- .hasMoreElements();) {
- String key = (String) keys.nextElement();
- if (!PropertiesUtil.isReservedProperty(key)) {
- byte[] bytes = props.getPropertyBytes(key);
- if (bytes != null) {
- result.put(key, bytes);
- continue;
- }
- String str = props.getPropertyString(key);
- if (str != null) {
- result.put(key, str);
- continue;
- }
- Object obj = props.getProperty(key);
- if (obj != null) {
- result.put(key, obj);
- continue;
- }
- }
- }
- }
-
- protected void logWarning(String methodName, String message, Throwable t) {
- LogUtility.logWarning(methodName, DebugOptions.DISCOVERY,
- this.getClass(), message, t);
- }
-
- protected void logError(String methodName, String message, Throwable t) {
- LogUtility.logError(methodName, DebugOptions.DISCOVERY,
- this.getClass(), message, t);
- }
-
- public void close() {
- // nothing to do
- }
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java
deleted file mode 100644
index 9d7ce690a..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java
+++ /dev/null
@@ -1,442 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.DebugOptions;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.LogUtility;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.remoteserviceadmin.ExportRegistration;
-import org.osgi.service.remoteserviceadmin.ImportRegistration;
-import org.osgi.util.tracker.ServiceTracker;
-
-public abstract class AbstractTopologyManager {
-
- public static final String SERVICE_EXPORTED_INTERFACES_WILDCARD = "*"; //$NON-NLS-1$
-
- private BundleContext context;
-
- private ServiceTracker endpointDescriptionAdvertiserTracker;
- private Object endpointDescriptionAdvertiserTrackerLock = new Object();
-
- private ServiceTracker remoteServiceAdminTracker;
- private Object remoteServiceAdminTrackerLock = new Object();
-
- protected Collection<org.osgi.service.remoteserviceadmin.ExportRegistration> exportedRegistrations = new ArrayList<org.osgi.service.remoteserviceadmin.ExportRegistration>();
-
- protected Collection<org.osgi.service.remoteserviceadmin.ImportRegistration> importedRegistrations = new ArrayList<org.osgi.service.remoteserviceadmin.ImportRegistration>();
-
- public AbstractTopologyManager(BundleContext context) {
- this.context = context;
- }
-
- protected BundleContext getContext() {
- return context;
- }
-
- protected IEndpointDescriptionAdvertiser getEndpointDescriptionAdvertiser(
- EndpointDescription endpointDescription) {
- synchronized (endpointDescriptionAdvertiserTrackerLock) {
- if (endpointDescriptionAdvertiserTracker == null) {
- endpointDescriptionAdvertiserTracker = new ServiceTracker(
- getContext(),
- IEndpointDescriptionAdvertiser.class.getName(), null);
- endpointDescriptionAdvertiserTracker.open();
- }
- }
- return (IEndpointDescriptionAdvertiser) endpointDescriptionAdvertiserTracker
- .getService();
- }
-
- public void close() {
- synchronized (endpointDescriptionAdvertiserTrackerLock) {
- if (endpointDescriptionAdvertiserTracker != null) {
- endpointDescriptionAdvertiserTracker.close();
- endpointDescriptionAdvertiserTracker = null;
- }
- }
- synchronized (remoteServiceAdminTrackerLock) {
- if (remoteServiceAdminTracker != null) {
- remoteServiceAdminTracker.close();
- remoteServiceAdminTracker = null;
- }
- }
- synchronized (exportedRegistrations) {
- exportedRegistrations.clear();
- }
- synchronized (importedRegistrations) {
- importedRegistrations.clear();
- }
- context = null;
- }
-
- protected void logWarning(String methodName, String message) {
- LogUtility.logWarning(methodName, DebugOptions.TOPOLOGY_MANAGER,
- this.getClass(), message);
- }
-
- protected Filter createRSAFilter() {
- String filterString = "(&(" //$NON-NLS-1$
- + org.osgi.framework.Constants.OBJECTCLASS
- + "=" //$NON-NLS-1$
- + org.osgi.service.remoteserviceadmin.RemoteServiceAdmin.class
- .getName()
- + ")(" //$NON-NLS-1$
- + org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.SERVICE_PROP
- + "=*))"; //$NON-NLS-1$
- try {
- return getContext().createFilter(filterString);
- } catch (InvalidSyntaxException e) {
- // Should never happen
- return null;
- }
- }
-
- protected org.osgi.service.remoteserviceadmin.RemoteServiceAdmin getRemoteServiceAdmin() {
- synchronized (remoteServiceAdminTrackerLock) {
- if (remoteServiceAdminTracker == null) {
- remoteServiceAdminTracker = new ServiceTracker(getContext(),
- createRSAFilter(), null);
- remoteServiceAdminTracker.open();
- }
- }
- return (org.osgi.service.remoteserviceadmin.RemoteServiceAdmin) remoteServiceAdminTracker
- .getService();
- }
-
- protected void advertiseEndpointDescription(
- EndpointDescription endpointDescription) {
- IEndpointDescriptionAdvertiser advertiser = getEndpointDescriptionAdvertiser(endpointDescription);
- if (advertiser == null) {
- logWarning("advertiseExportedRegistration", //$NON-NLS-1$
- "No endpoint description advertiser available for endpointDescription=" //$NON-NLS-1$
- + endpointDescription);
- return;
- }
- // Now advertise endpoint description using endpoint description
- // advertiser
- IStatus result = advertiser.advertise(endpointDescription);
- if (!result.isOK())
- logError("advertiseExportedRegistration", //$NON-NLS-1$
- "Advertise of endpointDescription=" + endpointDescription //$NON-NLS-1$
- + " FAILED", result); //$NON-NLS-1$
- }
-
- protected void unadvertiseEndpointDescription(
- EndpointDescription endpointDescription) {
- IEndpointDescriptionAdvertiser advertiser = getEndpointDescriptionAdvertiser(endpointDescription);
- if (advertiser == null) {
- logError(
- "unadvertiseEndpointDescription", //$NON-NLS-1$
- "No endpoint description advertiser available to unadvertise endpointDescription=" //$NON-NLS-1$
- + endpointDescription);
- return;
- }
- // Now unadvertise endpoint description using endpoint description
- // advertiser
- IStatus result = advertiser.unadvertise(endpointDescription);
- if (!result.isOK())
- logError("unadvertiseEndpointDescription", //$NON-NLS-1$
- "Unadvertise of endpointDescription=" + endpointDescription //$NON-NLS-1$
- + " FAILED", result); //$NON-NLS-1$
- }
-
- protected void logError(String methodName, String message,
- Throwable exception) {
- LogUtility.logError(methodName, DebugOptions.TOPOLOGY_MANAGER,
- this.getClass(), message, exception);
- }
-
- protected void logError(String methodName, String message, IStatus result) {
- LogUtility.logError(methodName, DebugOptions.TOPOLOGY_MANAGER,
- this.getClass(), result);
- }
-
- protected void trace(String methodName, String message) {
- LogUtility.trace(methodName, DebugOptions.TOPOLOGY_MANAGER,
- this.getClass(), message);
- }
-
- protected void logError(String methodName, String message) {
- LogUtility.logError(methodName, DebugOptions.TOPOLOGY_MANAGER,
- this.getClass(), message);
- }
-
- protected void handleEndpointAdded(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpoint,
- String matchedFilter) {
- if (endpoint instanceof EndpointDescription)
- handleEndpointAdded((EndpointDescription) endpoint, matchedFilter);
- else
- logWarning("endpointAdded", //$NON-NLS-1$
- "ECF Topology Manager: Ignoring Non-ECF endpointAdded=" //$NON-NLS-1$
- + endpoint + ",matchedFilter=" + matchedFilter); //$NON-NLS-1$
- }
-
- protected void handleEndpointAdded(EndpointDescription endpointDescription,
- String matchedFilter) {
- // First, select importing remote service admin
- org.osgi.service.remoteserviceadmin.RemoteServiceAdmin rsa = getRemoteServiceAdmin();
-
- if (rsa == null) {
- logError("handleEndpointAdded", //$NON-NLS-1$
- "RemoteServiceAdmin not found for importing endpointDescription=" //$NON-NLS-1$
- + endpointDescription);
- return;
- }
-
- trace("handleEndpointAdded", "endpointDescription=" //$NON-NLS-1$ //$NON-NLS-2$
- + endpointDescription + " rsa=" + rsa); //$NON-NLS-1$
-
- // now call rsa.import
- org.osgi.service.remoteserviceadmin.ImportRegistration importRegistration = rsa
- .importService(endpointDescription);
-
- if (importRegistration == null) {
- logError("handleEndpointAdded", //$NON-NLS-1$
- "Import registration is null for endpointDescription=" //$NON-NLS-1$
- + endpointDescription + " and rsa=" + rsa); //$NON-NLS-1$
- } else {
- Throwable t = importRegistration.getException();
- if (t != null)
- handleInvalidImportRegistration(importRegistration, t);
- else {
- trace("handleEndpointAdded", //$NON-NLS-1$
- "service imported. importRegistration=" //$NON-NLS-1$
- + importRegistration);
- synchronized (importedRegistrations) {
- importedRegistrations.add(importRegistration);
- }
- }
- }
- }
-
- protected void handleInvalidImportRegistration(
- ImportRegistration importRegistration, Throwable t) {
- logError("handleInvalidImportRegistration", "importRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
- + importRegistration, t);
- }
-
- protected void handleEndpointRemoved(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpoint,
- String matchedFilter) {
- if (endpoint instanceof EndpointDescription)
- handleEndpointRemoved((EndpointDescription) endpoint, matchedFilter);
- else
- logWarning("endpointRemoved", //$NON-NLS-1$
- "ECF Topology Manager: Ignoring Non-ECF endpointRemoved=" //$NON-NLS-1$
- + endpoint + ",matchedFilter=" + matchedFilter); //$NON-NLS-1$
- }
-
- protected void handleEvent(ServiceEvent event, Collection contexts) {
- switch (event.getType()) {
- case ServiceEvent.MODIFIED:
- handleServiceModifying(event.getServiceReference());
- break;
- case ServiceEvent.MODIFIED_ENDMATCH:
- break;
- case ServiceEvent.REGISTERED:
- handleServiceRegistering(event.getServiceReference());
- break;
- case ServiceEvent.UNREGISTERING:
- handleServiceUnregistering(event.getServiceReference());
- break;
- default:
- break;
- }
- }
-
- protected void handleEndpointRemoved(
- EndpointDescription endpointDescription, String matchedFilter) {
- trace("handleEndpointRemoved", "endpointDescription=" //$NON-NLS-1$ //$NON-NLS-2$
- + endpointDescription);
- unimportService(endpointDescription);
- }
-
- protected void handleServiceRegistering(ServiceReference serviceReference) {
- // Using OSGI 4.2 Chap 13 Remote Services spec, get the specified remote
- // interfaces for the given service reference
- String[] exportedInterfaces = PropertiesUtil
- .getExportedInterfaces(serviceReference);
- // If no remote interfaces set, then we don't do anything with it
- if (exportedInterfaces == null)
- return;
-
- // Select remote service admin
- org.osgi.service.remoteserviceadmin.RemoteServiceAdmin rsa = getRemoteServiceAdmin();
-
- // if no remote service admin available, then log error and return
- if (rsa == null) {
- logError("handleServiceRegistered", //$NON-NLS-1$
- "No RemoteServiceAdmin found for serviceReference=" //$NON-NLS-1$
- + serviceReference
- + ". Remote service NOT EXPORTED"); //$NON-NLS-1$
- return;
- }
-
- // prepare export properties
- Map<String, Object> exportProperties = new TreeMap<String, Object>(
- String.CASE_INSENSITIVE_ORDER);
- exportProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTERFACES,
- exportedInterfaces);
- trace("handleServiceRegistering", "serviceReference=" //$NON-NLS-1$ //$NON-NLS-2$
- + serviceReference + " exportProperties=" + exportProperties); //$NON-NLS-1$
- Collection<org.osgi.service.remoteserviceadmin.ExportRegistration> registrations = rsa
- .exportService(serviceReference, exportProperties);
-
- if (registrations == null || registrations.size() == 0) {
- logError("handleServiceRegistered", //$NON-NLS-1$
- "No export registrations created by RemoteServiceAdmin=" //$NON-NLS-1$
- + rsa + ". ServiceReference=" + serviceReference //$NON-NLS-1$
- + " NOT EXPORTED"); //$NON-NLS-1$
- return;
- }
-
- List<EndpointDescription> endpointDescriptions = new ArrayList<EndpointDescription>();
-
- for (org.osgi.service.remoteserviceadmin.ExportRegistration exportRegistration : registrations) {
- // If they are invalid report as such
- Throwable t = exportRegistration.getException();
- if (t != null)
- handleInvalidExportRegistration(exportRegistration, t);
- else {
- trace("handleServiceRegistering", //$NON-NLS-1$
- "service exported. exportRegistration=" //$NON-NLS-1$
- + exportRegistration);
- endpointDescriptions
- .add((EndpointDescription) exportRegistration
- .getExportReference().getExportedEndpoint());
- synchronized (exportedRegistrations) {
- exportedRegistrations.add(exportRegistration);
- }
- }
- }
- // advertise valid exported registrations
- advertiseEndpointDescriptions(endpointDescriptions);
- }
-
- protected void advertiseEndpointDescriptions(
- List<EndpointDescription> endpointDescriptions) {
- for (EndpointDescription ed : endpointDescriptions)
- advertiseEndpointDescription(ed);
- }
-
- protected void handleInvalidExportRegistration(
- ExportRegistration exportRegistration, Throwable t) {
- logError("handleInvalidExportRegistration", "exportRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
- + exportRegistration, t);
- }
-
- protected void handleServiceModifying(ServiceReference serviceReference) {
- handleServiceUnregistering(serviceReference);
- handleServiceRegistering(serviceReference);
- }
-
- protected void handleServiceUnregistering(ServiceReference serviceReference) {
- Collection<EndpointDescription> endpointDescriptions = unexportService(serviceReference);
- if (endpointDescriptions != null)
- for (EndpointDescription ed : endpointDescriptions)
- unadvertiseEndpointDescription(ed);
- }
-
- protected Collection<EndpointDescription> unexportService(
- ServiceReference serviceReference) {
- Map<org.osgi.service.remoteserviceadmin.ExportRegistration, EndpointDescription> matchingExportRegistrations = null;
- synchronized (exportedRegistrations) {
- for (Iterator<org.osgi.service.remoteserviceadmin.ExportRegistration> i = exportedRegistrations
- .iterator(); i.hasNext();) {
- if (matchingExportRegistrations == null)
- matchingExportRegistrations = new HashMap<org.osgi.service.remoteserviceadmin.ExportRegistration, EndpointDescription>();
- org.osgi.service.remoteserviceadmin.ExportRegistration exportRegistration = i
- .next();
- // Only check valid registrations (no exceptions)
- if (exportRegistration.getException() == null) {
- org.osgi.service.remoteserviceadmin.ExportReference exportRef = exportRegistration
- .getExportReference();
- if (exportRef != null) {
- ServiceReference exportReference = exportRef
- .getExportedService();
- if (exportReference != null
- && serviceReference.equals(exportReference)) {
- matchingExportRegistrations.put(exportRegistration,
- (EndpointDescription) exportRef
- .getExportedEndpoint());
- }
- }
- // remove no matter what
- i.remove();
- }
- }
- }
- // If no matching export registrations then we return null and are done
- if (matchingExportRegistrations == null
- || matchingExportRegistrations.size() == 0)
- return null;
- // We close all matching export registrations
- for (Iterator<org.osgi.service.remoteserviceadmin.ExportRegistration> i = matchingExportRegistrations
- .keySet().iterator(); i.hasNext();) {
- org.osgi.service.remoteserviceadmin.ExportRegistration exportRegistration = i
- .next();
- trace("unexportService", "closing exportRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
- + exportRegistration);
- exportRegistration.close();
- }
- // And return endpointDescriptions for matching registrations
- return matchingExportRegistrations.values();
- }
-
- protected void unimportService(EndpointDescription endpointDescription) {
- List<org.osgi.service.remoteserviceadmin.ImportRegistration> removedRegistrations = null;
- synchronized (importedRegistrations) {
- for (Iterator<org.osgi.service.remoteserviceadmin.ImportRegistration> i = importedRegistrations
- .iterator(); i.hasNext();) {
- if (removedRegistrations == null)
- removedRegistrations = new ArrayList<org.osgi.service.remoteserviceadmin.ImportRegistration>();
- org.osgi.service.remoteserviceadmin.ImportRegistration importRegistration = i
- .next();
- if (importRegistration.getException() == null) {
- org.osgi.service.remoteserviceadmin.ImportReference importRef = importRegistration
- .getImportReference();
- if (importRef != null) {
- EndpointDescription ed = (EndpointDescription) importRef
- .getImportedEndpoint();
- if (ed != null && ed.isSameService(endpointDescription)) {
- removedRegistrations.add(importRegistration);
- }
- }
- // remove no matter what
- i.remove();
- }
- }
- }
- // Now close all of them
- if (removedRegistrations != null)
- for (org.osgi.service.remoteserviceadmin.ImportRegistration removedReg : removedRegistrations) {
- trace("unimportService", "closing importRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
- + removedReg);
- removedReg.close();
- }
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java
deleted file mode 100644
index 013aca7e5..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
-
-public class ConsumerContainerSelector extends
- AbstractConsumerContainerSelector implements IConsumerContainerSelector {
-
- private boolean autoCreateContainer = false;
-
- public ConsumerContainerSelector(boolean autoCreateContainer) {
- this.autoCreateContainer = autoCreateContainer;
- }
-
- public IRemoteServiceContainer selectConsumerContainer(
- EndpointDescription endpointDescription) {
- trace("selectConsumerContainers", "endpointDescription=" + endpointDescription); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Get the endpointID
- ID endpointContainerID = endpointDescription.getContainerID();
-
- String[] remoteSupportedConfigs = (String[]) endpointDescription
- .getProperties()
- .get(org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED);
-
- // Get connect targetID
- ID connectTargetID = endpointDescription.getConnectTargetID();
-
- IRemoteServiceContainer rsContainer = selectExistingConsumerContainer(
- endpointContainerID, remoteSupportedConfigs, connectTargetID);
-
- // If we haven't found any existing containers then we create one
- // from the remoteSupportedConfigs...*iff* autoCreateContainer is
- // set to true
- if (rsContainer == null && autoCreateContainer)
- rsContainer = createAndConfigureConsumerContainer(
- remoteSupportedConfigs, endpointDescription.getProperties());
-
- // Get the connect target ID from the endpointDescription
- // and connect the given containers to the connect targetID
- // This is only needed when when the endpointID is different from
- // the connect targetID, and the containers are not already connected
- connectContainerToTarget(rsContainer, connectTargetID);
-
- return rsContainer;
- }
-
- public void close() {
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescription.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescription.java
deleted file mode 100644
index 0f3dd47a8..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescription.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.discovery.identity.IServiceID;
-
-public class DiscoveredEndpointDescription {
-
- private Namespace discoveryLocatorNamespace;
- private IServiceID serviceID;
- private org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription;
- private int hashCode = 7;
-
- public DiscoveredEndpointDescription(
- Namespace discoveryLocatorNamespace,
- IServiceID serviceID,
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
- this.discoveryLocatorNamespace = discoveryLocatorNamespace;
- this.serviceID = serviceID;
- this.endpointDescription = endpointDescription;
- this.hashCode = 31 * this.hashCode
- + discoveryLocatorNamespace.getName().hashCode();
- this.hashCode = 31 * this.hashCode + endpointDescription.hashCode();
- }
-
- public int hashCode() {
- return hashCode;
- }
-
- public boolean equals(Object other) {
- if (other == null)
- return false;
- if (other == this)
- return true;
- if (!(other instanceof DiscoveredEndpointDescription))
- return false;
- DiscoveredEndpointDescription o = (DiscoveredEndpointDescription) other;
- return (this.discoveryLocatorNamespace
- .equals(o.discoveryLocatorNamespace) && this.endpointDescription
- .equals(o.endpointDescription));
- }
-
- public Namespace getDiscoveryLocatorNamespace() {
- return discoveryLocatorNamespace;
- }
-
- public IServiceID getServiceID() {
- return serviceID;
- }
-
- public org.osgi.service.remoteserviceadmin.EndpointDescription getEndpointDescription() {
- return endpointDescription;
- }
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescriptionFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescriptionFactory.java
deleted file mode 100644
index b5942fbb0..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescriptionFactory.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.discovery.IDiscoveryLocator;
-import org.eclipse.ecf.discovery.IServiceInfo;
-import org.eclipse.ecf.discovery.IServiceProperties;
-import org.eclipse.ecf.discovery.identity.IServiceID;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-
-public class DiscoveredEndpointDescriptionFactory extends
- AbstractMetadataFactory implements
- IDiscoveredEndpointDescriptionFactory {
-
- protected List<DiscoveredEndpointDescription> discoveredEndpointDescriptions = new ArrayList();
-
- private DiscoveredEndpointDescription findDiscoveredEndpointDescription(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
- synchronized (discoveredEndpointDescriptions) {
- for (DiscoveredEndpointDescription d : discoveredEndpointDescriptions) {
- org.osgi.service.remoteserviceadmin.EndpointDescription ed = d
- .getEndpointDescription();
- if (ed.equals(endpointDescription))
- return d;
- }
- }
- return null;
- }
-
- private DiscoveredEndpointDescription findUniscoveredEndpointDescription(
- IDiscoveryLocator locator, IServiceID serviceID) {
- synchronized (discoveredEndpointDescriptions) {
- for (DiscoveredEndpointDescription d : discoveredEndpointDescriptions) {
- Namespace dln = d.getDiscoveryLocatorNamespace();
- IServiceID svcId = d.getServiceID();
- if (dln.getName().equals(
- locator.getServicesNamespace().getName())
- && svcId.equals(serviceID)) {
- return d;
- }
- }
- }
- return null;
- }
-
- public DiscoveredEndpointDescription createDiscoveredEndpointDescription(
- IDiscoveryLocator locator, IServiceInfo discoveredServiceInfo) {
- try {
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription = createEndpointDescription(
- locator, discoveredServiceInfo);
- synchronized (discoveredEndpointDescriptions) {
- DiscoveredEndpointDescription ded = findDiscoveredEndpointDescription(endpointDescription);
- if (ded != null)
- return ded;
- else {
- ded = createDiscoveredEndpointDescription(locator,
- discoveredServiceInfo, endpointDescription);
- // put into discoveredEndpointDescriptions
- discoveredEndpointDescriptions.add(ded);
- return ded;
- }
- }
- } catch (Exception e) {
- logError("createDiscoveredEndpointDescription", //$NON-NLS-1$
- "Exception creating discovered endpoint description", e); //$NON-NLS-1$
- return null;
- }
- }
-
- public DiscoveredEndpointDescription getUndiscoveredEndpointDescription(
- IDiscoveryLocator locator, IServiceID serviceID) {
- synchronized (discoveredEndpointDescriptions) {
- DiscoveredEndpointDescription ded = findUniscoveredEndpointDescription(
- locator, serviceID);
- if (ded != null) {
- // remove
- discoveredEndpointDescriptions.remove(ded);
- return ded;
- }
- }
- return null;
- }
-
- protected org.osgi.service.remoteserviceadmin.EndpointDescription createEndpointDescription(
- IDiscoveryLocator locator, IServiceInfo discoveredServiceInfo) {
- IServiceProperties discoveredServiceProperties = discoveredServiceInfo
- .getServiceProperties();
- return decodeEndpointDescription(discoveredServiceProperties);
-
- }
-
- protected DiscoveredEndpointDescription createDiscoveredEndpointDescription(
- IDiscoveryLocator locator,
- IServiceInfo discoveredServiceInfo,
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
- return new DiscoveredEndpointDescription(
- locator.getServicesNamespace(),
- discoveredServiceInfo.getServiceID(), endpointDescription);
- }
-
- public void close() {
- removeAllEndpointDescriptions();
- super.close();
- }
-
- public boolean removeEndpointDescription(
- EndpointDescription endpointDescription) {
- synchronized (discoveredEndpointDescriptions) {
- DiscoveredEndpointDescription d = findDiscoveredEndpointDescription(endpointDescription);
- if (d != null) {
- discoveredEndpointDescriptions.remove(d);
- return true;
- }
- }
- return false;
- }
-
- public void removeAllEndpointDescriptions() {
- synchronized (discoveredEndpointDescriptions) {
- discoveredEndpointDescriptions.clear();
- }
- }
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
deleted file mode 100644
index 04ad7bea9..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.identity.IDCreateException;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.IDUtil;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Version;
-
-public class EndpointDescription extends
- org.osgi.service.remoteserviceadmin.EndpointDescription {
-
- private String idNamespace;
- private ID containerID;
- private long remoteServiceId;
- private ID connectTargetID;
- private ID[] idFilter;
- private String rsFilter;
-
- private int hashCode;
-
- public EndpointDescription(ServiceReference reference, Map osgiProperties) {
- super(reference, osgiProperties);
- verifyECFProperties();
- computeHashCode();
- }
-
- public EndpointDescription(Map osgiProperties) {
- super(osgiProperties);
- verifyECFProperties();
- computeHashCode();
- }
-
- private void verifyECFProperties() {
- this.idNamespace = verifyStringProperty(RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE);
- this.containerID = verifyIDProperty(idNamespace, getId());
- this.remoteServiceId = verifyLongProperty(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID);
- this.connectTargetID = verifyIDProperty(RemoteConstants.ENDPOINT_CONNECTTARGET_ID);
- this.idFilter = verifyIDFilter();
- this.rsFilter = verifyStringProperty(RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER);
- }
-
- private long verifyLongProperty(String propName) {
- Object r = getProperties().get(propName);
- if (r == null) {
- return 0l;
- }
- try {
- return ((Long) r).longValue();
- } catch (ClassCastException e) {
- IllegalArgumentException iae = new IllegalArgumentException(
- "property value is not a Long: " + propName); //$NON-NLS-1$
- iae.initCause(e);
- throw iae;
- }
- }
-
- private String verifyStringProperty(String propName) {
- Object r = getProperties().get(propName);
- try {
- return (String) r;
- } catch (ClassCastException e) {
- IllegalArgumentException iae = new IllegalArgumentException(
- "property value is not a String: " + propName); //$NON-NLS-1$
- iae.initCause(e);
- throw iae;
- }
- }
-
- private ID verifyIDProperty(String idNamespace, String idName) {
- if (idName == null)
- return null;
- try {
- return IDUtil.createID(idNamespace, idName);
- } catch (IDCreateException e) {
- IllegalArgumentException iae = new IllegalArgumentException(
- "cannot create a valid ID: idNamespace=" + idNamespace //$NON-NLS-1$
- + ", idName=" + idName); //$NON-NLS-1$
- iae.initCause(e);
- throw iae;
- }
- }
-
- private ID verifyIDProperty(String namePropName) {
- return verifyIDProperty(idNamespace, verifyStringProperty(namePropName));
- }
-
- private ID[] verifyIDFilter() {
- List<String> idNames = PropertiesUtil.getStringPlusProperty(
- getProperties(), RemoteConstants.ENDPOINT_IDFILTER_IDS);
- if (idNames.size() == 0)
- return null;
- List<ID> results = new ArrayList();
- String idNamespace = getIdNamespace();
- for (String idName : idNames) {
- try {
- results.add(IDUtil.createID(idNamespace, idName));
- } catch (IDCreateException e) {
- IllegalArgumentException iae = new IllegalArgumentException(
- "cannot create ID[]: idNamespace=" + idNamespace //$NON-NLS-1$
- + " idName=" + idName); //$NON-NLS-1$
- iae.initCause(e);
- throw iae;
- }
- }
- return (ID[]) results.toArray(new ID[results.size()]);
- }
-
- private void computeHashCode() {
- this.hashCode = super.hashCode();
- long remoteServiceId = getRemoteServiceId();
- this.hashCode = 31 * hashCode
- + (int) (remoteServiceId ^ (remoteServiceId >>> 32));
- }
-
- public Map<String, Version> getInterfaceVersions() {
- List<String> interfaces = getInterfaces();
- Map<String, Version> result = new HashMap<String, Version>();
- for (String intf : interfaces) {
- int index = intf.lastIndexOf('.');
- if (index == -1) {
- continue;
- }
- String packageName = intf.substring(0, index);
- result.put(intf, getPackageVersion(packageName));
- }
- return result;
- }
-
- public boolean equals(Object other) {
- if (other == null)
- return false;
- if (other == this)
- return true;
- if (!(other instanceof EndpointDescription))
- return false;
- EndpointDescription o = (EndpointDescription) other;
- return super.equals(other)
- && (o.getRemoteServiceId() == this.getRemoteServiceId());
- }
-
- public int hashCode() {
- return hashCode;
- }
-
- public boolean isSameService(
- org.osgi.service.remoteserviceadmin.EndpointDescription other) {
- if (!(other instanceof EndpointDescription))
- return false;
- EndpointDescription o = (EndpointDescription) other;
- return (super.isSameService(other) && o.getRemoteServiceId() == this
- .getRemoteServiceId());
- }
-
- public ID getContainerID() {
- return containerID;
- }
-
- public String getIdNamespace() {
- return idNamespace;
- }
-
- public ID getConnectTargetID() {
- return connectTargetID;
- }
-
- public long getRemoteServiceId() {
- return remoteServiceId;
- }
-
- public ID[] getIDFilter() {
- return idFilter;
- }
-
- public String getRemoteServiceFilter() {
- return rsFilter;
- }
-
- public String toString() {
- return "ECFEndpointDescription[containerID=" + containerID //$NON-NLS-1$
- + ", remoteServiceId=" + getRemoteServiceId() //$NON-NLS-1$
- + ", connectTargetID=" + connectTargetID + ", idFilter=" //$NON-NLS-1$ //$NON-NLS-2$
- + Arrays.toString(idFilter) + ", rsFilter=" + rsFilter //$NON-NLS-1$
- + ", hashCode=" + hashCode + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionAdvertiser.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionAdvertiser.java
deleted file mode 100644
index 30c788d68..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionAdvertiser.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ecf.discovery.IDiscoveryAdvertiser;
-import org.eclipse.ecf.discovery.IServiceInfo;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator;
-
-public class EndpointDescriptionAdvertiser implements
- IEndpointDescriptionAdvertiser {
-
- private EndpointDescriptionLocator endpointDescriptionLocator;
-
- public EndpointDescriptionAdvertiser(
- EndpointDescriptionLocator endpointDescriptionLocator) {
- this.endpointDescriptionLocator = endpointDescriptionLocator;
- }
-
- public IStatus advertise(EndpointDescription endpointDescription) {
- return doDiscovery(endpointDescription, true);
- }
-
- protected IStatus doDiscovery(IDiscoveryAdvertiser discoveryAdvertiser,
- IServiceInfo serviceInfo, boolean advertise) {
- try {
- if (advertise)
- discoveryAdvertiser.registerService(serviceInfo);
- else
- discoveryAdvertiser.unregisterService(serviceInfo);
- return Status.OK_STATUS;
- } catch (Exception e) {
- return createErrorStatus((advertise ? "registerService" //$NON-NLS-1$
- : "unregisterService") //$NON-NLS-1$
- + " with serviceInfo=" //$NON-NLS-1$
- + serviceInfo + " for discoveryAdvertiser=" //$NON-NLS-1$
- + discoveryAdvertiser + " failed", e); //$NON-NLS-1$
- }
- }
-
- protected IServiceInfoFactory getServiceInfoFactory() {
- return endpointDescriptionLocator.getServiceInfoFactory();
- }
-
- protected IDiscoveryAdvertiser[] getDiscoveryAdvertisers() {
- return endpointDescriptionLocator.getDiscoveryAdvertisers();
- }
-
- protected IStatus createErrorStatus(String message) {
- return createErrorStatus(message, null);
- }
-
- protected IStatus createErrorStatus(String message, Throwable e) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, e);
- }
-
- protected IStatus doDiscovery(EndpointDescription endpointDescription,
- boolean advertise) {
- Assert.isNotNull(endpointDescription);
- String messagePrefix = advertise ? "Advertise" : "Unadvertise"; //$NON-NLS-1$ //$NON-NLS-2$
- List<IStatus> statuses = new ArrayList<IStatus>();
- // First get serviceInfoFactory
- IServiceInfoFactory serviceInfoFactory = getServiceInfoFactory();
- if (serviceInfoFactory == null)
- return createErrorStatus(messagePrefix
- + " endpointDescription=" //$NON-NLS-1$
- + endpointDescription
- + ". No IServiceInfoFactory is available. Cannot unpublish endpointDescription=" //$NON-NLS-1$
- + endpointDescription);
- IDiscoveryAdvertiser[] discoveryAdvertisers = getDiscoveryAdvertisers();
- if (discoveryAdvertisers == null || discoveryAdvertisers.length == 0)
- return createErrorStatus(messagePrefix
- + " endpointDescription=" //$NON-NLS-1$
- + endpointDescription
- + ". No endpointDescriptionLocator advertisers available. Cannot unpublish endpointDescription=" //$NON-NLS-1$
- + endpointDescription);
- for (int i = 0; i < discoveryAdvertisers.length; i++) {
- IServiceInfo serviceInfo = (advertise ? serviceInfoFactory
- .createServiceInfoForDiscovery(discoveryAdvertisers[i],
- endpointDescription) : serviceInfoFactory
- .removeServiceInfoForUndiscovery(discoveryAdvertisers[i],
- endpointDescription));
- if (serviceInfo == null) {
- statuses.add(createErrorStatus(messagePrefix
- + " endpointDescription=" //$NON-NLS-1$
- + endpointDescription
- + ". Service Info is null. Cannot publish endpointDescription=" //$NON-NLS-1$
- + endpointDescription));
- continue;
- }
- // Now actually unregister with advertiser
- statuses.add(doDiscovery(discoveryAdvertisers[i], serviceInfo,
- advertise));
- }
- return createResultStatus(statuses, messagePrefix
- + " endpointDesription=" + endpointDescription //$NON-NLS-1$
- + ". Problem in unadvertise"); //$NON-NLS-1$
- }
-
- public IStatus unadvertise(EndpointDescription endpointDescription) {
- return doDiscovery(endpointDescription, false);
- }
-
- private IStatus createResultStatus(List<IStatus> statuses,
- String errorMessage) {
- List<IStatus> errorStatuses = new ArrayList<IStatus>();
- for (IStatus status : statuses)
- if (!status.isOK())
- errorStatuses.add(status);
- if (errorStatuses.size() > 0)
- return new MultiStatus(Activator.PLUGIN_ID, IStatus.ERROR,
- (IStatus[]) statuses.toArray(new IStatus[statuses.size()]),
- errorMessage, null);
- else
- return Status.OK_STATUS;
- }
-
- public void close() {
- this.endpointDescriptionLocator = null;
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java
deleted file mode 100644
index 95a1a2c66..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.DebugOptions;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.LogUtility;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.util.tracker.BundleTrackerCustomizer;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class EndpointDescriptionBundleTrackerCustomizer implements
- BundleTrackerCustomizer {
-
- private static final String REMOTESERVICE_MANIFESTHEADER = "Remote-Service"; //$NON-NLS-1$
- private static final String XML_FILE_PATTERN = "*.xml"; //$NON-NLS-1$
-
- private Map<Long, Collection<org.osgi.service.remoteserviceadmin.EndpointDescription>> bundleDescriptionMap = Collections
- .synchronizedMap(new HashMap<Long, Collection<org.osgi.service.remoteserviceadmin.EndpointDescription>>());
-
- private BundleContext bundleContext;
- private LocatorServiceListener endpointDescriptionHandler;
-
- private Object endpointDescriptionReaderTrackerLock = new Object();
- private ServiceTracker endpointDescriptionReaderTracker;
-
- public EndpointDescriptionBundleTrackerCustomizer(
- BundleContext bundleContext,
- LocatorServiceListener endpointDescriptionHandler) {
- this.bundleContext = bundleContext;
- this.endpointDescriptionHandler = endpointDescriptionHandler;
- }
-
- private IEndpointDescriptionReader getEndpointDescriptionReader() {
- synchronized (endpointDescriptionReaderTrackerLock) {
- if (endpointDescriptionReaderTracker == null) {
- endpointDescriptionReaderTracker = new ServiceTracker(
- bundleContext,
- IEndpointDescriptionReader.class.getName(), null);
- endpointDescriptionReaderTracker.open();
- }
- }
- return (IEndpointDescriptionReader) endpointDescriptionReaderTracker
- .getService();
- }
-
- public Object addingBundle(Bundle bundle, BundleEvent event) {
- handleAddingBundle(bundle);
- return bundle;
- }
-
- private void handleAddingBundle(Bundle bundle) {
- if (bundleContext == null)
- return;
- String remoteServicesHeaderValue = (String) bundle.getHeaders().get(
- REMOTESERVICE_MANIFESTHEADER);
- if (remoteServicesHeaderValue != null) {
- // First parse into comma-separated values
- String[] paths = remoteServicesHeaderValue.split(","); //$NON-NLS-1$
- if (paths != null)
- for (int i = 0; i < paths.length; i++)
- handleEndpointDescriptionPath(bundle, paths[i]);
- }
- }
-
- private void handleEndpointDescriptionPath(Bundle bundle,
- String remoteServicesHeaderValue) {
- // if it's empty, ignore
- if ("".equals(remoteServicesHeaderValue)) //$NON-NLS-1$
- return;
- Enumeration<URL> e = null;
- // if it endswith a '/', then scan for *.xml files
- if (remoteServicesHeaderValue.endsWith("/")) { //$NON-NLS-1$
- e = bundle.findEntries(remoteServicesHeaderValue, XML_FILE_PATTERN,
- false);
- } else {
- // Break into path and filename/pattern
- int lastSlashIndex = remoteServicesHeaderValue.lastIndexOf('/');
- if (lastSlashIndex == -1) {
- // no slash...might be a file name or pattern, assumed to be
- // at root of bundle
- e = bundle.findEntries("/", remoteServicesHeaderValue, false); //$NON-NLS-1$
- } else {
- String path = remoteServicesHeaderValue.substring(0,
- lastSlashIndex);
- if ("".equals(path)) { //$NON-NLS-1$
- // path is empty so assume it's root
- path = "/"; //$NON-NLS-1$
- }
- String filePattern = remoteServicesHeaderValue
- .substring(lastSlashIndex + 1);
- e = bundle.findEntries(path, filePattern, false);
- }
- }
- // Now process any found
- Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> endpointDescriptions = new ArrayList<org.osgi.service.remoteserviceadmin.EndpointDescription>();
- if (e != null) {
- while (e.hasMoreElements()) {
- org.osgi.service.remoteserviceadmin.EndpointDescription[] eps = handleEndpointDescriptionFile(
- bundle, e.nextElement());
- if (eps != null)
- for (int i = 0; i < eps.length; i++)
- endpointDescriptions.add(eps[i]);
- }
- }
- // finally, handle them
- if (endpointDescriptions.size() > 0) {
- bundleDescriptionMap.put(new Long(bundle.getBundleId()),
- endpointDescriptions);
- for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : endpointDescriptions)
- endpointDescriptionHandler.handleEndpointDescription(ed, true);
- }
- }
-
- private org.osgi.service.remoteserviceadmin.EndpointDescription[] handleEndpointDescriptionFile(
- Bundle bundle, URL fileURL) {
- InputStream ins = null;
- try {
- IEndpointDescriptionReader endpointDescriptionReader = getEndpointDescriptionReader();
- if (endpointDescriptionReader == null)
- throw new NullPointerException(
- "No endpointDescriptionReader available for handleEndpointDescriptionFile fileURL=" //$NON-NLS-1$
- + fileURL);
- ins = fileURL.openStream();
- return endpointDescriptionReader.readEndpointDescriptions(ins);
- } catch (Exception e) {
- logError("handleEndpointDescriptionFile", //$NON-NLS-1$
- "Exception creating endpoint descriptions from fileURL=" //$NON-NLS-1$
- + fileURL, e);
- return null;
- } finally {
- if (ins != null)
- try {
- ins.close();
- } catch (IOException e) {
- logError("handleEndpointDescriptionFile", //$NON-NLS-1$
- "Exception closing endpointDescription input fileURL=" //$NON-NLS-1$
- + fileURL, e);
- }
- }
- }
-
- private void logError(String method, String message, Throwable t) {
- LogUtility.logError(method, DebugOptions.DISCOVERY, this.getClass(),
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
- message, t));
- }
-
- public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
- }
-
- public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
- handleRemovedBundle(bundle);
- }
-
- private void handleRemovedBundle(Bundle bundle) {
- Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> endpointDescriptions = bundleDescriptionMap
- .remove(new Long(bundle.getBundleId()));
- if (endpointDescriptions != null)
- for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : endpointDescriptions)
- endpointDescriptionHandler.handleEndpointDescription(ed, false);
- }
-
- public void close() {
- synchronized (endpointDescriptionReaderTrackerLock) {
- if (endpointDescriptionReaderTracker != null) {
- endpointDescriptionReaderTracker.close();
- endpointDescriptionReaderTracker = null;
- }
- }
- bundleDescriptionMap.clear();
- bundleContext = null;
- }
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
deleted file mode 100644
index 532891dc2..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
+++ /dev/null
@@ -1,919 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TreeMap;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ecf.discovery.IDiscoveryAdvertiser;
-import org.eclipse.ecf.discovery.IDiscoveryLocator;
-import org.eclipse.ecf.discovery.IServiceEvent;
-import org.eclipse.ecf.discovery.IServiceInfo;
-import org.eclipse.ecf.discovery.IServiceListener;
-import org.eclipse.ecf.discovery.identity.IServiceID;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.DebugOptions;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.LogUtility;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
-import org.eclipse.equinox.concurrent.future.IExecutor;
-import org.eclipse.equinox.concurrent.future.IProgressRunnable;
-import org.eclipse.equinox.concurrent.future.ThreadsExecutor;
-import org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap;
-import org.eclipse.osgi.framework.eventmgr.EventDispatcher;
-import org.eclipse.osgi.framework.eventmgr.EventManager;
-import org.eclipse.osgi.framework.eventmgr.ListenerQueue;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
-import org.osgi.util.tracker.BundleTracker;
-import org.osgi.util.tracker.BundleTrackerCustomizer;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class EndpointDescriptionLocator {
-
- private BundleContext context;
- private IExecutor executor;
-
- // service info factory default
- private ServiceInfoFactory serviceInfoFactory;
- private ServiceRegistration defaultServiceInfoFactoryRegistration;
- // service info factory service tracker
- private Object serviceInfoFactoryTrackerLock = new Object();
- private ServiceTracker serviceInfoFactoryTracker;
-
- // endpoint description factory default
- private DiscoveredEndpointDescriptionFactory defaultEndpointDescriptionFactory;
- private ServiceRegistration defaultEndpointDescriptionFactoryRegistration;
- // endpoint description factory tracker
- private Object endpointDescriptionFactoryTrackerLock = new Object();
- private ServiceTracker endpointDescriptionFactoryTracker;
- // endpointDescriptionReader default
- private ServiceRegistration defaultEndpointDescriptionReaderRegistration;
-
- // For processing synchronous notifications asynchronously
- private EventManager eventManager;
- private ListenerQueue eventQueue;
- private LocatorServiceListener localLocatorServiceListener;
-
- // ECF IDiscoveryLocator tracker
- private ServiceTracker locatorServiceTracker;
- // Locator listeners
- private Map<IDiscoveryLocator, LocatorServiceListener> locatorListeners;
-
- private ServiceTracker endpointListenerTracker;
-
- private ServiceTracker advertiserTracker;
- private Object advertiserTrackerLock = new Object();
-
- private BundleTracker bundleTracker;
- private EndpointDescriptionBundleTrackerCustomizer bundleTrackerCustomizer;
-
- public EndpointDescriptionLocator(BundleContext context) {
- this.context = context;
- this.executor = new ThreadsExecutor();
- }
-
- public void start() {
- // For service info and endpoint description factories
- // set the service ranking to Integer.MIN_VALUE
- // so that any other registered factories will be preferred
- final Properties properties = new Properties();
- properties.put(Constants.SERVICE_RANKING,
- new Integer(Integer.MIN_VALUE));
- serviceInfoFactory = new ServiceInfoFactory();
- defaultServiceInfoFactoryRegistration = context.registerService(
- IServiceInfoFactory.class.getName(), serviceInfoFactory,
- (Dictionary) properties);
- defaultEndpointDescriptionFactory = new DiscoveredEndpointDescriptionFactory();
- defaultEndpointDescriptionFactoryRegistration = context
- .registerService(
- IDiscoveredEndpointDescriptionFactory.class.getName(),
- defaultEndpointDescriptionFactory,
- (Dictionary) properties);
- // setup/register default endpointDescriptionReader
- defaultEndpointDescriptionReaderRegistration = context.registerService(
- IEndpointDescriptionReader.class.getName(),
- new EndpointDescriptionReader(), (Dictionary) properties);
-
- // Create thread group, event manager, and eventQueue, and setup to
- // dispatch EndpointListenerEvents
- ThreadGroup eventGroup = new ThreadGroup(
- "RSA EndpointDescriptionLocator ThreadGroup"); //$NON-NLS-1$
- eventGroup.setDaemon(true);
- eventManager = new EventManager(
- "RSA EndpointDescriptionLocator Dispatcher", eventGroup); //$NON-NLS-1$
- eventQueue = new ListenerQueue(eventManager);
- CopyOnWriteIdentityMap listeners = new CopyOnWriteIdentityMap();
- listeners.put(this, this);
- eventQueue.queueListeners(listeners.entrySet(), new EventDispatcher() {
- public void dispatchEvent(Object eventListener,
- Object listenerObject, int eventAction, Object eventObject) {
- final String logMethodName = "dispatchEvent"; //$NON-NLS-1$
- final EndpointListenerEvent event = (EndpointListenerEvent) eventObject;
- final EndpointListener endpointListener = event
- .getEndpointListener();
- final EndpointDescription endpointDescription = event
- .getEndointDescription();
- final String matchingFilter = event.getMatchingFilter();
-
- try {
- if (event.isDiscovered())
- endpointListener.endpointAdded(endpointDescription,
- matchingFilter);
- else
- endpointListener.endpointRemoved(endpointDescription,
- matchingFilter);
- } catch (Exception e) {
- String message = "Exception in EndpointListener listener=" //$NON-NLS-1$
- + endpointListener + " description=" //$NON-NLS-1$
- + endpointDescription + " matchingFilter=" //$NON-NLS-1$
- + matchingFilter;
- logError(logMethodName, message, e);
- } catch (LinkageError e) {
- String message = "LinkageError in EndpointListener listener=" //$NON-NLS-1$
- + endpointListener + " description=" //$NON-NLS-1$
- + endpointDescription + " matchingFilter=" //$NON-NLS-1$
- + matchingFilter;
- logError(logMethodName, message, e);
- } catch (AssertionError e) {
- String message = "AssertionError in EndpointListener listener=" //$NON-NLS-1$
- + endpointListener + " description=" //$NON-NLS-1$
- + endpointDescription + " matchingFilter=" //$NON-NLS-1$
- + matchingFilter;
- logError(logMethodName, message, e);
- }
- }
- });
- // Register the endpoint listener tracker, so that endpoint listeners
- // that are subsequently added
- // will then be notified of discovered endpoints
- endpointListenerTracker = new ServiceTracker(context,
- EndpointListener.class.getName(),
- new ServiceTrackerCustomizer() {
- public Object addingService(ServiceReference reference) {
- if (context == null)
- return null;
- EndpointListener listener = (EndpointListener) context
- .getService(reference);
- if (listener == null)
- return null;
- Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> allDiscoveredEndpointDescriptions = getAllDiscoveredEndpointDescriptions();
- for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : allDiscoveredEndpointDescriptions) {
- EndpointDescriptionLocator.EndpointListenerHolder[] endpointListenerHolders = getMatchingEndpointListenerHolders(
- new ServiceReference[] { reference }, ed);
- if (endpointListenerHolders != null) {
- for (int i = 0; i < endpointListenerHolders.length; i++) {
- queueEndpointDescription(
- endpointListenerHolders[i]
- .getListener(),
- endpointListenerHolders[i]
- .getDescription(),
- endpointListenerHolders[i]
- .getMatchingFilter(), true);
- }
- }
- }
- return listener;
- }
-
- public void modifiedService(ServiceReference reference,
- Object service) {
- }
-
- public void removedService(ServiceReference reference,
- Object service) {
- }
- });
-
- endpointListenerTracker.open();
-
- locatorListeners = new HashMap();
- localLocatorServiceListener = new LocatorServiceListener(null);
- // Create locator service tracker, so new IDiscoveryLocators can
- // be used to discover endpoint descriptions
- locatorServiceTracker = new ServiceTracker(context,
- IDiscoveryLocator.class.getName(),
- new LocatorTrackerCustomizer());
- locatorServiceTracker.open();
- // Get any existing locators
- Object[] locators = locatorServiceTracker.getServices();
- if (locators != null) {
- // for all of them
- for (int i = 0; i < locators.length; i++) {
- // Add service listener to locator
- openLocator((IDiscoveryLocator) locators[i]);
- }
- }
- // Create bundle tracker for reading local/xml-file endpoint
- // descriptions
- bundleTrackerCustomizer = new EndpointDescriptionBundleTrackerCustomizer();
- bundleTracker = new BundleTracker(context, Bundle.ACTIVE
- | Bundle.STARTING, bundleTrackerCustomizer);
- // This may trigger local endpoint description discovery
- bundleTracker.open();
- }
-
- private void logError(String methodName, String message, Throwable e) {
- LogUtility.logError(methodName, DebugOptions.DISCOVERY,
- this.getClass(), message, e);
- }
-
- public void close() {
- if (bundleTracker != null) {
- bundleTracker.close();
- bundleTracker = null;
- }
- if (bundleTrackerCustomizer != null) {
- bundleTrackerCustomizer.close();
- bundleTrackerCustomizer = null;
- }
-
- // shutdown locatorListeners
- synchronized (locatorListeners) {
- for (IDiscoveryLocator l : locatorListeners.keySet()) {
- LocatorServiceListener locatorListener = locatorListeners
- .get(l);
- if (locatorListener != null) {
- l.removeServiceListener(locatorListener);
- locatorListener.close();
- }
- }
- locatorListeners.clear();
- }
-
- Object[] locators = locatorServiceTracker.getServices();
- if (locators != null) {
- for (int i = 0; i < locators.length; i++) {
- // Add service listener to locator
- shutdownLocator((IDiscoveryLocator) locators[i]);
- }
- }
-
- if (localLocatorServiceListener != null) {
- localLocatorServiceListener.close();
- localLocatorServiceListener = null;
- }
-
- if (endpointListenerTracker != null) {
- endpointListenerTracker.close();
- endpointListenerTracker = null;
- }
- // Shutdown asynchronous event manager
- if (eventManager != null) {
- eventManager.close();
- eventManager = null;
- }
-
- synchronized (endpointDescriptionFactoryTrackerLock) {
- if (endpointDescriptionFactoryTracker != null) {
- endpointDescriptionFactoryTracker.close();
- endpointDescriptionFactoryTracker = null;
- }
- }
- if (defaultEndpointDescriptionFactoryRegistration != null) {
- defaultEndpointDescriptionFactoryRegistration.unregister();
- defaultEndpointDescriptionFactoryRegistration = null;
- }
- if (defaultEndpointDescriptionFactory != null) {
- defaultEndpointDescriptionFactory.close();
- defaultEndpointDescriptionFactory = null;
- }
-
- synchronized (serviceInfoFactoryTrackerLock) {
- if (serviceInfoFactoryTracker != null) {
- serviceInfoFactoryTracker.close();
- serviceInfoFactoryTracker = null;
- }
- }
- if (defaultServiceInfoFactoryRegistration != null) {
- defaultServiceInfoFactoryRegistration.unregister();
- defaultServiceInfoFactoryRegistration = null;
- }
- if (serviceInfoFactory != null) {
- serviceInfoFactory.close();
- serviceInfoFactory = null;
- }
- if (defaultEndpointDescriptionReaderRegistration != null) {
- defaultEndpointDescriptionReaderRegistration.unregister();
- defaultEndpointDescriptionReaderRegistration = null;
- }
- if (locatorServiceTracker != null) {
- locatorServiceTracker.close();
- locatorServiceTracker = null;
- }
- synchronized (advertiserTrackerLock) {
- if (advertiserTracker != null) {
- advertiserTracker.close();
- advertiserTracker = null;
- }
- }
- this.executor = null;
- this.context = null;
- }
-
- public IDiscoveryAdvertiser[] getDiscoveryAdvertisers() {
- synchronized (advertiserTrackerLock) {
- if (advertiserTracker == null) {
- advertiserTracker = new ServiceTracker(context,
- IDiscoveryAdvertiser.class.getName(), null);
- advertiserTracker.open();
- }
- }
- ServiceReference[] advertiserRefs = advertiserTracker
- .getServiceReferences();
- if (advertiserRefs == null)
- return null;
- List<IDiscoveryAdvertiser> results = new ArrayList<IDiscoveryAdvertiser>();
- for (int i = 0; i < advertiserRefs.length; i++) {
- results.add((IDiscoveryAdvertiser) context
- .getService(advertiserRefs[i]));
- }
- return results.toArray(new IDiscoveryAdvertiser[results.size()]);
- }
-
- private void openLocator(IDiscoveryLocator locator) {
- if (context == null)
- return;
- synchronized (locatorListeners) {
- LocatorServiceListener locatorListener = new LocatorServiceListener(
- locator);
- locatorListeners.put(locator, locatorListener);
- processInitialLocatorServices(locator, locatorListener);
- }
- }
-
- private void shutdownLocator(IDiscoveryLocator locator) {
- if (locator == null || context == null)
- return;
- synchronized (locatorListeners) {
- LocatorServiceListener locatorListener = locatorListeners
- .remove(locator);
- if (locatorListener != null)
- locatorListener.close();
- }
- }
-
- void queueEndpointDescription(
- EndpointListener listener,
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
- String matchingFilters, boolean discovered) {
- if (eventQueue == null)
- return;
- synchronized (eventQueue) {
- eventQueue
- .dispatchEventAsynchronous(0, new EndpointListenerEvent(
- listener, endpointDescription, matchingFilters,
- discovered));
- }
- }
-
- Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> getAllDiscoveredEndpointDescriptions() {
- Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> result = new ArrayList();
- if (localLocatorServiceListener == null)
- return result;
- // Get local first
- result.addAll(localLocatorServiceListener.getEndpointDescriptions());
- synchronized (locatorListeners) {
- for (IDiscoveryLocator l : locatorListeners.keySet()) {
- LocatorServiceListener locatorListener = locatorListeners
- .get(l);
- result.addAll(locatorListener.getEndpointDescriptions());
- }
- }
- return result;
- }
-
- void queueEndpointDescription(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
- boolean discovered) {
- EndpointListenerHolder[] endpointListenerHolders = getMatchingEndpointListenerHolders(endpointDescription);
- if (endpointListenerHolders != null) {
- for (int i = 0; i < endpointListenerHolders.length; i++) {
- queueEndpointDescription(
- endpointListenerHolders[i].getListener(),
- endpointListenerHolders[i].getDescription(),
- endpointListenerHolders[i].getMatchingFilter(),
- discovered);
-
- }
- } else {
- LogUtility.logWarning(
- "queueEndpointDescription", //$NON-NLS-1$
- DebugOptions.DISCOVERY, this.getClass(),
- "No matching EndpointListeners found for " //$NON-NLS-1$
- + (discovered ? "discovered" : "undiscovered") //$NON-NLS-1$ //$NON-NLS-2$
- + " endpointDescription=" + endpointDescription); //$NON-NLS-1$
- }
-
- }
-
- private void processInitialLocatorServices(final IDiscoveryLocator locator,
- final LocatorServiceListener locatorListener) {
- IProgressRunnable runnable = new IProgressRunnable() {
- public Object run(IProgressMonitor arg0) throws Exception {
- IServiceInfo[] serviceInfos = locator.getServices();
- for (int i = 0; i < serviceInfos.length; i++) {
- locatorListener.handleService(serviceInfos[i], true);
- }
- return null;
- }
- };
- executor.execute(runnable, null);
- }
-
- void shutdownLocators() {
- Object[] locators = locatorServiceTracker.getServices();
- if (locators != null) {
- for (int i = 0; i < locators.length; i++) {
- // Add service listener to locator
- shutdownLocator((IDiscoveryLocator) locators[i]);
- }
- }
- }
-
- private class EndpointListenerEvent {
-
- private EndpointListener endpointListener;
- private org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription;
- private String matchingFilter;
- private boolean discovered;
-
- public EndpointListenerEvent(
- EndpointListener endpointListener,
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
- String matchingFilter, boolean discovered) {
- this.endpointListener = endpointListener;
- this.endpointDescription = endpointDescription;
- this.matchingFilter = matchingFilter;
- this.discovered = discovered;
- }
-
- public EndpointListener getEndpointListener() {
- return endpointListener;
- }
-
- public org.osgi.service.remoteserviceadmin.EndpointDescription getEndointDescription() {
- return endpointDescription;
- }
-
- public String getMatchingFilter() {
- return matchingFilter;
- }
-
- public boolean isDiscovered() {
- return discovered;
- }
- }
-
- private class LocatorTrackerCustomizer implements ServiceTrackerCustomizer {
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.osgi.util.tracker.ServiceTrackerCustomizer#addingService(org.
- * osgi.framework.ServiceReference)
- */
- public Object addingService(ServiceReference reference) {
- IDiscoveryLocator locator = (IDiscoveryLocator) context
- .getService(reference);
- if (locator != null)
- openLocator(locator);
- return locator;
- }
-
- public void modifiedService(ServiceReference reference, Object service) {
- }
-
- public void removedService(ServiceReference reference, Object service) {
- shutdownLocator((IDiscoveryLocator) service);
- }
- }
-
- public IServiceInfoFactory getServiceInfoFactory() {
- if (context == null)
- return null;
- synchronized (serviceInfoFactoryTrackerLock) {
- if (serviceInfoFactoryTracker == null) {
- serviceInfoFactoryTracker = new ServiceTracker(context,
- IServiceInfoFactory.class.getName(), null);
- serviceInfoFactoryTracker.open();
- }
- }
- return (IServiceInfoFactory) serviceInfoFactoryTracker.getService();
- }
-
- public IDiscoveredEndpointDescriptionFactory getDiscoveredEndpointDescriptionFactory() {
- synchronized (endpointDescriptionFactoryTrackerLock) {
- if (context == null)
- return null;
- if (endpointDescriptionFactoryTracker == null) {
- endpointDescriptionFactoryTracker = new ServiceTracker(context,
- IDiscoveredEndpointDescriptionFactory.class.getName(),
- null);
- endpointDescriptionFactoryTracker.open();
- }
- return (IDiscoveredEndpointDescriptionFactory) endpointDescriptionFactoryTracker
- .getService();
- }
- }
-
- private Object endpointListenerServiceTrackerLock = new Object();
-
- public EndpointListenerHolder[] getMatchingEndpointListenerHolders(
- EndpointDescription description) {
- synchronized (endpointListenerServiceTrackerLock) {
- if (context == null)
- return null;
- return getMatchingEndpointListenerHolders(
- endpointListenerTracker.getServiceReferences(), description);
- }
- }
-
- public class EndpointListenerHolder {
-
- private EndpointListener listener;
- private EndpointDescription description;
- private String matchingFilter;
-
- public EndpointListenerHolder(EndpointListener l,
- EndpointDescription d, String f) {
- this.listener = l;
- this.description = d;
- this.matchingFilter = f;
- }
-
- public EndpointListener getListener() {
- return listener;
- }
-
- public EndpointDescription getDescription() {
- return description;
- }
-
- public String getMatchingFilter() {
- return matchingFilter;
- }
- }
-
- public EndpointListenerHolder[] getMatchingEndpointListenerHolders(
- ServiceReference[] refs, EndpointDescription description) {
- if (refs == null)
- return null;
- List results = new ArrayList();
- for (int i = 0; i < refs.length; i++) {
- EndpointListener listener = (EndpointListener) context
- .getService(refs[i]);
- if (listener == null)
- continue;
- List<String> filters = PropertiesUtil.getStringPlusProperty(
- getMapFromProperties(refs[i]),
- EndpointListener.ENDPOINT_LISTENER_SCOPE);
- String matchingFilter = isMatch(description, filters);
- if (matchingFilter != null)
- results.add(new EndpointListenerHolder(listener, description,
- matchingFilter));
- }
- return (EndpointListenerHolder[]) results
- .toArray(new EndpointListenerHolder[results.size()]);
- }
-
- private String isMatch(EndpointDescription description, List<String> filters) {
- for (String filter : filters)
- if (description.matches(filter))
- return filter;
- return null;
- }
-
- private Map getMapFromProperties(ServiceReference ref) {
- Map<String, Object> results = new TreeMap<String, Object>(
- String.CASE_INSENSITIVE_ORDER);
- String[] keys = ref.getPropertyKeys();
- if (keys != null) {
- for (int i = 0; i < keys.length; i++) {
- results.put(keys[i], ref.getProperty(keys[i]));
- }
- }
- return results;
- }
-
- class EndpointDescriptionBundleTrackerCustomizer implements
- BundleTrackerCustomizer {
-
- private static final String REMOTESERVICE_MANIFESTHEADER = "Remote-Service"; //$NON-NLS-1$
- private static final String XML_FILE_PATTERN = "*.xml"; //$NON-NLS-1$
-
- private Map<Long, Collection<org.osgi.service.remoteserviceadmin.EndpointDescription>> bundleDescriptionMap = Collections
- .synchronizedMap(new HashMap<Long, Collection<org.osgi.service.remoteserviceadmin.EndpointDescription>>());
-
- private Object endpointDescriptionReaderTrackerLock = new Object();
- private ServiceTracker endpointDescriptionReaderTracker;
-
- private IEndpointDescriptionReader getEndpointDescriptionReader() {
- synchronized (endpointDescriptionReaderTrackerLock) {
- if (endpointDescriptionReaderTracker == null) {
- endpointDescriptionReaderTracker = new ServiceTracker(
- context,
- IEndpointDescriptionReader.class.getName(), null);
- endpointDescriptionReaderTracker.open();
- }
- }
- return (IEndpointDescriptionReader) endpointDescriptionReaderTracker
- .getService();
- }
-
- public Object addingBundle(Bundle bundle, BundleEvent event) {
- handleAddingBundle(bundle);
- return bundle;
- }
-
- private void handleAddingBundle(Bundle bundle) {
- if (context == null)
- return;
- String remoteServicesHeaderValue = (String) bundle.getHeaders()
- .get(REMOTESERVICE_MANIFESTHEADER);
- if (remoteServicesHeaderValue != null) {
- // First parse into comma-separated values
- String[] paths = remoteServicesHeaderValue.split(","); //$NON-NLS-1$
- if (paths != null)
- for (int i = 0; i < paths.length; i++)
- handleEndpointDescriptionPath(bundle, paths[i]);
- }
- }
-
- private void handleEndpointDescriptionPath(Bundle bundle,
- String remoteServicesHeaderValue) {
- // if it's empty, ignore
- if ("".equals(remoteServicesHeaderValue)) //$NON-NLS-1$
- return;
- Enumeration<URL> e = null;
- // if it endswith a '/', then scan for *.xml files
- if (remoteServicesHeaderValue.endsWith("/")) { //$NON-NLS-1$
- e = bundle.findEntries(remoteServicesHeaderValue,
- XML_FILE_PATTERN, false);
- } else {
- // Break into path and filename/pattern
- int lastSlashIndex = remoteServicesHeaderValue.lastIndexOf('/');
- if (lastSlashIndex == -1) {
- // no slash...might be a file name or pattern, assumed to be
- // at root of bundle
- e = bundle.findEntries(
- "/", remoteServicesHeaderValue, false); //$NON-NLS-1$
- } else {
- String path = remoteServicesHeaderValue.substring(0,
- lastSlashIndex);
- if ("".equals(path)) { //$NON-NLS-1$
- // path is empty so assume it's root
- path = "/"; //$NON-NLS-1$
- }
- String filePattern = remoteServicesHeaderValue
- .substring(lastSlashIndex + 1);
- e = bundle.findEntries(path, filePattern, false);
- }
- }
- // Now process any found
- Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> endpointDescriptions = new ArrayList<org.osgi.service.remoteserviceadmin.EndpointDescription>();
- if (e != null) {
- while (e.hasMoreElements()) {
- org.osgi.service.remoteserviceadmin.EndpointDescription[] eps = handleEndpointDescriptionFile(
- bundle, e.nextElement());
- if (eps != null)
- for (int i = 0; i < eps.length; i++)
- endpointDescriptions.add(eps[i]);
- }
- }
- // finally, handle them
- if (endpointDescriptions.size() > 0) {
- bundleDescriptionMap.put(new Long(bundle.getBundleId()),
- endpointDescriptions);
- for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : endpointDescriptions)
- localLocatorServiceListener.handleEndpointDescription(ed,
- true);
- }
- }
-
- private org.osgi.service.remoteserviceadmin.EndpointDescription[] handleEndpointDescriptionFile(
- Bundle bundle, URL fileURL) {
- InputStream ins = null;
- try {
- IEndpointDescriptionReader endpointDescriptionReader = getEndpointDescriptionReader();
- if (endpointDescriptionReader == null)
- throw new NullPointerException(
- "No endpointDescriptionReader available for handleEndpointDescriptionFile fileURL=" //$NON-NLS-1$
- + fileURL);
- ins = fileURL.openStream();
- return endpointDescriptionReader.readEndpointDescriptions(ins);
- } catch (Exception e) {
- logError("handleEndpointDescriptionFile", //$NON-NLS-1$
- "Exception creating endpoint descriptions from fileURL=" //$NON-NLS-1$
- + fileURL, e);
- return null;
- } finally {
- if (ins != null)
- try {
- ins.close();
- } catch (IOException e) {
- logError("handleEndpointDescriptionFile", //$NON-NLS-1$
- "Exception closing endpointDescription input fileURL=" //$NON-NLS-1$
- + fileURL, e);
- }
- }
- }
-
- private void logError(String method, String message, Throwable t) {
- LogUtility.logError(method, DebugOptions.DISCOVERY,
- this.getClass(), new Status(IStatus.ERROR,
- Activator.PLUGIN_ID, IStatus.ERROR, message, t));
- }
-
- public void modifiedBundle(Bundle bundle, BundleEvent event,
- Object object) {
- }
-
- public void removedBundle(Bundle bundle, BundleEvent event,
- Object object) {
- handleRemovedBundle(bundle);
- }
-
- private void handleRemovedBundle(Bundle bundle) {
- Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> endpointDescriptions = bundleDescriptionMap
- .remove(new Long(bundle.getBundleId()));
- if (endpointDescriptions != null)
- for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : endpointDescriptions)
- localLocatorServiceListener.handleEndpointDescription(ed,
- false);
- }
-
- public void close() {
- synchronized (endpointDescriptionReaderTrackerLock) {
- if (endpointDescriptionReaderTracker != null) {
- endpointDescriptionReaderTracker.close();
- endpointDescriptionReaderTracker = null;
- }
- }
- bundleDescriptionMap.clear();
- }
- }
-
- class LocatorServiceListener implements IServiceListener {
-
- private Object listenerLock = new Object();
- private IDiscoveryLocator locator;
-
- private List<org.osgi.service.remoteserviceadmin.EndpointDescription> discoveredEndpointDescriptions = new ArrayList();
-
- public LocatorServiceListener(IDiscoveryLocator locator) {
- this.locator = locator;
- if (locator != null)
- this.locator.addServiceListener(this);
- }
-
- public void serviceDiscovered(IServiceEvent anEvent) {
- handleService(anEvent.getServiceInfo(), true);
- }
-
- public void serviceUndiscovered(IServiceEvent anEvent) {
- handleService(anEvent.getServiceInfo(), false);
- }
-
- private boolean matchServiceID(IServiceID serviceId) {
- if (Arrays.asList(serviceId.getServiceTypeID().getServices())
- .contains(RemoteConstants.SERVICE_TYPE))
- return true;
- return false;
- }
-
- void handleService(IServiceInfo serviceInfo, boolean discovered) {
- IServiceID serviceID = serviceInfo.getServiceID();
- if (matchServiceID(serviceID))
- handleOSGiServiceEndpoint(serviceID, serviceInfo, discovered);
- }
-
- private void handleOSGiServiceEndpoint(IServiceID serviceId,
- IServiceInfo serviceInfo, boolean discovered) {
- if (locator == null)
- return;
- DiscoveredEndpointDescription discoveredEndpointDescription = getDiscoveredEndpointDescription(
- serviceId, serviceInfo, discovered);
- if (discoveredEndpointDescription != null) {
- handleEndpointDescription(
- discoveredEndpointDescription.getEndpointDescription(),
- discovered);
- } else {
- logWarning("handleOSGiServiceEvent", //$NON-NLS-1$
- "discoveredEndpointDescription is null for service info=" //$NON-NLS-1$
- + serviceInfo + ",discovered=" + discovered); //$NON-NLS-1$
- }
- }
-
- public void handleEndpointDescription(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
- boolean discovered) {
- synchronized (listenerLock) {
- if (discovered)
- discoveredEndpointDescriptions.add(endpointDescription);
- else
- discoveredEndpointDescriptions.remove(endpointDescription);
-
- queueEndpointDescription(endpointDescription, discovered);
- }
- }
-
- public Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> getEndpointDescriptions() {
- synchronized (listenerLock) {
- Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> result = new ArrayList<org.osgi.service.remoteserviceadmin.EndpointDescription>();
- result.addAll(discoveredEndpointDescriptions);
- return result;
- }
- }
-
- private void logWarning(String methodName, String message) {
- LogUtility.logWarning(methodName, DebugOptions.DISCOVERY,
- this.getClass(), message);
- }
-
- private void logError(String methodName, String message) {
- logError(methodName, message, null);
- }
-
- private void logError(String methodName, String message, Throwable t) {
- LogUtility.logError(methodName, DebugOptions.DISCOVERY,
- this.getClass(), message, t);
- }
-
- private DiscoveredEndpointDescription getDiscoveredEndpointDescription(
- IServiceID serviceId, IServiceInfo serviceInfo,
- boolean discovered) {
- // Get IEndpointDescriptionFactory
- final String methodName = "getDiscoveredEndpointDescription"; //$NON-NLS-1$
- IDiscoveredEndpointDescriptionFactory factory = getDiscoveredEndpointDescriptionFactory();
- if (factory == null) {
- logError(
- methodName,
- "No IEndpointDescriptionFactory found, could not create EndpointDescription for " //$NON-NLS-1$
- + (discovered ? "discovered" : "undiscovered") //$NON-NLS-1$ //$NON-NLS-2$
- + " serviceInfo=" + serviceInfo); //$NON-NLS-1$
- return null;
- }
- try {
- // Else get endpoint description factory to create
- // EndpointDescription
- // for given serviceID and serviceInfo
- return (discovered) ? factory
- .createDiscoveredEndpointDescription(locator,
- serviceInfo) : factory
- .getUndiscoveredEndpointDescription(locator, serviceId);
- } catch (Exception e) {
- logError(
- methodName,
- "Exception calling IEndpointDescriptionFactory." //$NON-NLS-1$
- + ((discovered) ? "createDiscoveredEndpointDescription" //$NON-NLS-1$
- : "getUndiscoveredEndpointDescription"), e); //$NON-NLS-1$
- return null;
- } catch (NoClassDefFoundError e) {
- logError(
- methodName,
- "NoClassDefFoundError calling IEndpointDescriptionFactory." //$NON-NLS-1$
- + ((discovered) ? "createDiscoveredEndpointDescription" //$NON-NLS-1$
- : "getUndiscoveredEndpointDescription"), e); //$NON-NLS-1$
- return null;
- }
- }
-
- public synchronized void close() {
- if (locator != null) {
- locator.removeServiceListener(this);
- locator = null;
- }
- discoveredEndpointDescriptions.clear();
- }
- }
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionParseException.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionParseException.java
deleted file mode 100644
index ed6de2b60..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionParseException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-public class EndpointDescriptionParseException extends Exception {
-
- private static final long serialVersionUID = -4481979787400184664L;
-
- public EndpointDescriptionParseException() {
- }
-
- public EndpointDescriptionParseException(String message) {
- super(message);
- }
-
- public EndpointDescriptionParseException(Throwable cause) {
- super(cause);
- }
-
- public EndpointDescriptionParseException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java
deleted file mode 100644
index e744d686e..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.DebugOptions;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.EndpointDescriptionParser;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.LogUtility;
-
-public class EndpointDescriptionReader implements IEndpointDescriptionReader {
-
- public org.osgi.service.remoteserviceadmin.EndpointDescription[] readEndpointDescriptions(
- InputStream input) throws IOException {
- // First create parser
- EndpointDescriptionParser parser = new EndpointDescriptionParser();
- // Parse input stream
- parser.parse(input);
- // Get possible endpoint descriptions
- List<EndpointDescriptionParser.EndpointDescription> parsedDescriptions = parser
- .getEndpointDescriptions();
- List<org.osgi.service.remoteserviceadmin.EndpointDescription> results = new ArrayList<org.osgi.service.remoteserviceadmin.EndpointDescription>();
- // For each one parsed, get properties and
- for (EndpointDescriptionParser.EndpointDescription ed : parsedDescriptions) {
- Map parsedProperties = ed.getProperties();
- try {
- results.add(new EndpointDescription(parsedProperties));
- } catch (Exception e) {
- LogUtility.logError(
- "readEndpointDescriptions", //$NON-NLS-1$
- DebugOptions.ENDPOINT_DESCRIPTION_READER,
- this.getClass(),
- "Exception parsing endpoint description properties", e); //$NON-NLS-1$
- }
- }
- return results.toArray(new EndpointDescription[results.size()]);
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionWriter.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionWriter.java
deleted file mode 100644
index 47a70f08c..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionWriter.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class EndpointDescriptionWriter {
-
- protected String indent = " "; //$NON-NLS-1$
-
- protected List<String> xmlNames;
-
- public EndpointDescriptionWriter() {
- this(null);
- }
-
- public EndpointDescriptionWriter(List<String> xmlNames) {
- this.xmlNames = xmlNames;
- }
-
- protected abstract class ComplexProperty {
- private String name;
- private Object value;
-
- public ComplexProperty(String name, Object value) {
- this.name = name;
- this.value = value;
- }
-
- public abstract void writeProperty(int indentLevel, Writer writer)
- throws IOException;
-
- protected String getName() {
- return name;
- }
-
- protected Object getValue() {
- return value;
- }
- }
-
- protected class XmlProperty extends ComplexProperty {
- public XmlProperty(String name, String xml) {
- super(name, xml);
- }
-
- void writeXml(int indentLevel, Writer writer) throws IOException {
- indent(indentLevel, writer);
- writer.append("<xml>"); //$NON-NLS-1$
- newLine(writer);
- indent(indentLevel + 1, writer);
- writer.append((String) getValue());
- newLine(writer);
- indent(indentLevel, writer);
- writer.append("</xml>"); //$NON-NLS-1$
- newLine(writer);
- }
-
- public void writeProperty(int indentLevel, Writer writer)
- throws IOException {
- indent(indentLevel, writer);
- writer.append("<property name=\"").append(getName()).append("\">"); //$NON-NLS-1$ //$NON-NLS-2$
- newLine(writer);
- writeXml(indentLevel + 1, writer);
- writer.append("</property>"); //$NON-NLS-1$
- newLine(writer);
- }
- }
-
- protected abstract class MultiValueProperty extends ComplexProperty {
- public MultiValueProperty(String name, Object value) {
- super(name, value);
- }
-
- abstract String getValueType();
-
- abstract void writePropertyValues(int indentLevel, Writer writer)
- throws IOException;
-
- public void writeProperty(int indentLevel, Writer writer)
- throws IOException {
- indent(indentLevel, writer);
- writer.append("<property name=\"").append(getName()) //$NON-NLS-1$
- .append("\" value-type=\"").append(getValueType()) //$NON-NLS-1$
- .append("\">"); //$NON-NLS-1$
- newLine(writer);
- writePropertyValues(indentLevel + 1, writer);
- indent(indentLevel, writer);
- writer.append("</property>"); //$NON-NLS-1$
- newLine(writer);
- }
-
- void writePropertyValue(int indentLevel, Object value, Writer writer)
- throws IOException {
- indent(indentLevel, writer);
- writer.append("<value>").append(value.toString()) //$NON-NLS-1$
- .append("</value>"); //$NON-NLS-1$
- newLine(writer);
- }
-
- }
-
- protected class SetProperty extends MultiValueProperty {
- public SetProperty(String key, Set value) {
- super(key, value);
- }
-
- public String getValueType() {
- return EndpointDescriptionWriter.this
- .getValueType(((Set) getValue()).iterator().next());
- }
-
- void writePropertyValues(int indentLevel, Writer writer)
- throws IOException {
- Set s = (Set) getValue();
- indent(indentLevel, writer);
- writer.append("<set>"); //$NON-NLS-1$
- newLine(writer);
- for (Iterator i = s.iterator(); i.hasNext();)
- writePropertyValue(indentLevel + 1, i.next(), writer);
- indent(indentLevel, writer);
- writer.append("</set>"); //$NON-NLS-1$
- }
-
- }
-
- protected class ListProperty extends MultiValueProperty {
- public ListProperty(String key, List value) {
- super(key, value);
- }
-
- public String getValueType() {
- return EndpointDescriptionWriter.this
- .getValueType(((List) getValue()).iterator().next());
- }
-
- void writePropertyValues(int indentLevel, Writer writer)
- throws IOException {
- List l = (List) getValue();
- indent(indentLevel, writer);
- writer.append("<list>"); //$NON-NLS-1$
- newLine(writer);
- for (Iterator i = l.iterator(); i.hasNext();)
- writePropertyValue(indentLevel + 1, i.next(), writer);
- indent(indentLevel, writer);
- writer.append("</list>"); //$NON-NLS-1$
- newLine(writer);
- }
- }
-
- protected class ArrayProperty extends MultiValueProperty {
- public ArrayProperty(String key, Object[] value) {
- super(key, value);
- }
-
- public String getValueType() {
- return EndpointDescriptionWriter.this
- .getValueType(((Object[]) getValue())[0]);
- }
-
- void writePropertyValues(int indentLevel, Writer writer)
- throws IOException {
- Object[] a = (Object[]) getValue();
- indent(indentLevel, writer);
- writer.append("<array>"); //$NON-NLS-1$
- newLine(writer);
- for (int i = 0; i < a.length; i++)
- writePropertyValue(indentLevel + 1, a[i], writer);
- indent(indentLevel, writer);
- writer.append("</array>"); //$NON-NLS-1$
- newLine(writer);
- }
- }
-
- public void writeEndpointDescriptions(
- Writer writer,
- org.osgi.service.remoteserviceadmin.EndpointDescription[] endpointDescriptions)
- throws IOException {
-
- indent(0, writer);
- writer.append("<endpoint-descriptions xmlns=\"http://www.osgi.org/xmlns/rsa/v1.0.0\">"); //$NON-NLS-1$
- newLine(writer);
- for (int i = 0; i < endpointDescriptions.length; i++)
- writeEndpointDescription(1, writer, endpointDescriptions[i]);
- indent(0, writer);
- writer.append("</endpoint-descriptions>"); //$NON-NLS-1$
- newLine(writer);
- }
-
- protected void writeEndpointDescription(
- int indentLevel,
- Writer writer,
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription)
- throws IOException {
- indent(indentLevel, writer);
- writer.append("<endpoint-description>"); //$NON-NLS-1$
- newLine(writer);
- writeProperties(indentLevel, writer, endpointDescription);
- indent(indentLevel, writer);
- writer.append("</endpoint-description>"); //$NON-NLS-1$
- newLine(writer);
- }
-
- protected void writeProperties(
- int indentLevel,
- Writer writer,
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription)
- throws IOException {
- Map<String, Object> properties = endpointDescription.getProperties();
- for (String name : properties.keySet())
- writeProperty(indentLevel + 1, writer, name, properties.get(name));
- }
-
- protected void writeProperty(int indentLevel, Writer writer, String name,
- Object value) throws IOException {
- if (value != null) {
- ComplexProperty complexProperty = getComplexProperty(name, value);
- if (complexProperty != null) {
- complexProperty.writeProperty(indentLevel, writer);
- return;
- }
- String valueType = getValueType(value);
- if (valueType != null) {
- writeValueProperty(indentLevel, name, valueType, value, writer);
- return;
- } else
- writeUnknownProperty(indentLevel, writer, name, value);
- }
- }
-
- protected void writeUnknownProperty(int indentLevel, Writer writer,
- String name, Object value) {
- // By default, do nothing
- }
-
- protected ComplexProperty getComplexProperty(String name, Object value) {
- XmlProperty xmlProperty = getXmlProperty(name, value);
- return (xmlProperty == null) ? getMultiValueProperty(name, value)
- : xmlProperty;
- }
-
- protected XmlProperty getXmlProperty(String name, Object value) {
- if (xmlNames != null && xmlNames.contains(name))
- return new XmlProperty(name, (String) value);
- return null;
- }
-
- protected void writeValueProperty(int indentLevel, String name,
- String valueType, Object value, Writer writer) throws IOException {
- indent(indentLevel, writer);
- writer.append("<property name=\"").append(name) //$NON-NLS-1$
- .append("\" value-type=\"").append(valueType) //$NON-NLS-1$
- .append("\" value=\"").append(value.toString()).append("\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
- newLine(writer);
- }
-
- protected MultiValueProperty getMultiValueProperty(String key, Object value) {
- if (value instanceof Set) {
- Set s = (Set) value;
- Object first = s.iterator().next();
- if (first == null)
- return null;
- return new SetProperty(key, s);
- } else if (value instanceof List) {
- List l = (List) value;
- Object first = l.get(0);
- if (first == null)
- return null;
- return new ListProperty(key, l);
- } else if (value.getClass().isArray()) {
- Object[] a = (Object[]) value;
- if (a.length == 0 || a[0] == null)
- return null;
- return new ArrayProperty(key, a);
- }
- return null;
- }
-
- protected String getValueType(Object value) {
- // first determine if is array
- if (value instanceof String)
- return "String"; //$NON-NLS-1$
- else if (value instanceof Long)
- return "Long"; //$NON-NLS-1$
- else if (value instanceof Double)
- return "Double"; //$NON-NLS-1$
- else if (value instanceof Float)
- return "Float"; //$NON-NLS-1$
- else if (value instanceof Integer)
- return "Integer"; //$NON-NLS-1$
- else if (value instanceof Byte)
- return "Byte"; //$NON-NLS-1$
- else if (value instanceof Character)
- return "Character"; //$NON-NLS-1$
- else if (value instanceof Boolean)
- return "Boolean"; //$NON-NLS-1$
- else if (value instanceof Short)
- return "Short"; //$NON-NLS-1$
- return null;
- }
-
- protected Writer newLine(Writer writer) throws IOException {
- return writer.append("\n"); //$NON-NLS-1$
- }
-
- protected Writer indent(int indentLevel, Writer writer) throws IOException {
- for (int i = 0; i < indentLevel; i++)
- writer.append(indent);
- return writer;
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/HostContainerSelector.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/HostContainerSelector.java
deleted file mode 100644
index 4fba49906..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/HostContainerSelector.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.ecf.core.IContainer;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
-import org.osgi.framework.ServiceReference;
-
-public class HostContainerSelector extends AbstractHostContainerSelector
- implements IHostContainerSelector {
-
- private boolean autoCreateContainer = false;
-
- public HostContainerSelector(String[] defaultConfigTypes,
- boolean autoCreateContainer) {
- super(defaultConfigTypes);
- this.autoCreateContainer = autoCreateContainer;
- }
-
- // Adding synchronized to make the host container finding
- // thread safe to deal with bug
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=331836
- public synchronized IRemoteServiceContainer[] selectHostContainers(
- ServiceReference serviceReference,
- String[] serviceExportedInterfaces,
- String[] serviceExportedConfigs, String[] serviceIntents) {
- // Find previously created containers that match the given
- // serviceExportedConfigs and serviceIntents
- Collection rsContainers = selectExistingHostContainers(
- serviceReference, serviceExportedInterfaces,
- serviceExportedConfigs, serviceIntents);
-
- if (rsContainers.size() == 0 && autoCreateContainer) {
- // If no existing containers are found we'll go through
- // finding/creating/configuring/connecting
- rsContainers = createAndConfigureHostContainers(serviceReference,
- serviceExportedInterfaces, serviceExportedConfigs,
- serviceIntents);
-
- // if SERVICE_EXPORTED_CONTAINER_CONNECT_TARGET service property is
- // specified, then
- // connect the host container(s)
- Object target = serviceReference
- .getProperty(RemoteConstants.ENDPOINT_CONNECTTARGET_ID);
- if (target != null) {
- for (Iterator i = rsContainers.iterator(); i.hasNext();) {
- IContainer container = ((IRemoteServiceContainer) i.next())
- .getContainer();
- try {
- connectHostContainer(serviceReference, container,
- target);
- } catch (Exception e) {
- logException("doConnectContainer failure containerID=" //$NON-NLS-1$
- + container.getID() + " target=" + target, e); //$NON-NLS-1$
- }
- }
-
- }
- }
-
- // return result
- return (IRemoteServiceContainer[]) rsContainers
- .toArray(new IRemoteServiceContainer[] {});
- }
-
- public void close() {
- }
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IConsumerContainerSelector.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IConsumerContainerSelector.java
deleted file mode 100644
index 3968a1da1..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IConsumerContainerSelector.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
-
-public interface IConsumerContainerSelector {
-
- public IRemoteServiceContainer selectConsumerContainer(
- EndpointDescription endpointDescription);
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IDiscoveredEndpointDescriptionFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IDiscoveredEndpointDescriptionFactory.java
deleted file mode 100644
index 04426c03e..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IDiscoveredEndpointDescriptionFactory.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import org.eclipse.ecf.discovery.IDiscoveryLocator;
-import org.eclipse.ecf.discovery.IServiceInfo;
-import org.eclipse.ecf.discovery.identity.IServiceID;
-
-public interface IDiscoveredEndpointDescriptionFactory {
-
- /**
- * Create an EndpointDescription for a discovered remote service.
- * Implementers of this factory service may return the type of
- * EndpointDescription appropriate for the associated distribution system
- * (e.g. ECFEndpointDescription). Implementers should return
- * <code>null</code> if no notification should occur.
- *
- * @param locator
- * the locator responsible for the discoveredServiceInfo. Must
- * not be <code>null</code>.
- * @param discoveredServiceInfo
- * the discovered service info. Must not be <code>null</code>.
- * @return DiscoveredEndpointDescription that will be used to notify
- * EndpointListeners about a new EndpointDescription. If
- * <code>null</code> is returned, no notification should be
- * performed by the calling code.
- */
- public DiscoveredEndpointDescription createDiscoveredEndpointDescription(
- IDiscoveryLocator locator, IServiceInfo discoveredServiceInfo);
-
- /**
- * Get an EndpointDescription for an undiscovered remote service.
- * Implementers of this factory service may return the type of
- * EndpointDescription appropriate for the associated distribution system
- * (e.g. ECFEndpointDescription). Implementers should return
- * <code>null</code> if no notification should occur.
- *
- * @param locator
- * the locator responsible for the discoveredServiceInfo. Must
- * not be <code>null</code>.
- * @param serviceId
- * the discovered service ID. Must not be <code>null</code>.
- * @return EndpointDescription that will be used to notify EndpointListeners
- * about an undiscovered EndpointDescription. If <code>null</code>
- * is returned, no notification should be performed by the calling
- * code.
- */
- public DiscoveredEndpointDescription getUndiscoveredEndpointDescription(
- IDiscoveryLocator locator, IServiceID serviceID);
-
- public boolean removeEndpointDescription(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription);
-
- public void removeAllEndpointDescriptions();
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionAdvertiser.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionAdvertiser.java
deleted file mode 100644
index 9e85780a4..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionAdvertiser.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import org.eclipse.core.runtime.IStatus;
-
-public interface IEndpointDescriptionAdvertiser {
-
- public IStatus advertise(EndpointDescription endpointDescription);
-
- public IStatus unadvertise(EndpointDescription endpointDescription);
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionReader.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionReader.java
deleted file mode 100644
index 62bc023d2..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IEndpointDescriptionReader.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-public interface IEndpointDescriptionReader {
-
- public org.osgi.service.remoteserviceadmin.EndpointDescription[] readEndpointDescriptions(
- InputStream ins) throws IOException,
- EndpointDescriptionParseException;
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IHostContainerSelector.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IHostContainerSelector.java
deleted file mode 100644
index a8ce3ff61..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IHostContainerSelector.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
-import org.osgi.framework.ServiceReference;
-
-public interface IHostContainerSelector {
- IRemoteServiceContainer[] selectHostContainers(
- ServiceReference serviceReference, String[] exportedInterfaces,
- String[] exportedConfigs, String[] serviceIntents);
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IPackageVersionComparator.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IPackageVersionComparator.java
deleted file mode 100644
index 56c5e4c90..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IPackageVersionComparator.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import org.osgi.framework.Version;
-
-public interface IPackageVersionComparator {
-
- public void comparePackageVersions(String packageName,
- Version remotePackageVersion, Version localPackageVersion)
- throws RuntimeException;
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java
deleted file mode 100644
index c8f2bea70..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IServiceInfoFactory.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import org.eclipse.ecf.discovery.IDiscoveryAdvertiser;
-import org.eclipse.ecf.discovery.IServiceInfo;
-
-public interface IServiceInfoFactory {
-
- public IServiceInfo createServiceInfoForDiscovery(
- IDiscoveryAdvertiser advertiser,
- EndpointDescription endpointDescription);
-
- public IServiceInfo removeServiceInfoForUndiscovery(
- IDiscoveryAdvertiser advertiser,
- EndpointDescription endpointDescription);
-
- public boolean removeServiceInfo(IDiscoveryAdvertiser advertiser,
- EndpointDescription endpointDescription);
-
- public void removeAllServiceInfos();
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/LocatorServiceListener.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/LocatorServiceListener.java
deleted file mode 100644
index 66a3bc170..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/LocatorServiceListener.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.ecf.discovery.IDiscoveryLocator;
-import org.eclipse.ecf.discovery.IServiceEvent;
-import org.eclipse.ecf.discovery.IServiceInfo;
-import org.eclipse.ecf.discovery.IServiceListener;
-import org.eclipse.ecf.discovery.identity.IServiceID;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.DebugOptions;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.LogUtility;
-
-class LocatorServiceListener implements IServiceListener {
-
- private Object listenerLock = new Object();
- private IDiscoveryLocator locator;
- private EndpointDescriptionLocator endpointDescriptionLocator;
-
- private List<org.osgi.service.remoteserviceadmin.EndpointDescription> discoveredEndpointDescriptions = new ArrayList();
-
- public LocatorServiceListener(
- EndpointDescriptionLocator endpointDescriptionLocator) {
- this(endpointDescriptionLocator, null);
- }
-
- public LocatorServiceListener(
- EndpointDescriptionLocator endpointDescriptionLocator,
- IDiscoveryLocator locator) {
- this.endpointDescriptionLocator = endpointDescriptionLocator;
- this.locator = locator;
- if (locator != null) {
- this.locator.addServiceListener(this);
- }
- }
-
- public void serviceDiscovered(IServiceEvent anEvent) {
- handleService(anEvent.getServiceInfo(), true);
- }
-
- public void serviceUndiscovered(IServiceEvent anEvent) {
- handleService(anEvent.getServiceInfo(), false);
- }
-
- private boolean matchServiceID(IServiceID serviceId) {
- if (Arrays.asList(serviceId.getServiceTypeID().getServices()).contains(
- RemoteConstants.SERVICE_TYPE))
- return true;
- return false;
- }
-
- void handleService(IServiceInfo serviceInfo, boolean discovered) {
- IServiceID serviceID = serviceInfo.getServiceID();
- if (matchServiceID(serviceID))
- handleOSGiServiceEndpoint(serviceID, serviceInfo, discovered);
- }
-
- private void handleOSGiServiceEndpoint(IServiceID serviceId,
- IServiceInfo serviceInfo, boolean discovered) {
- if (locator == null)
- return;
- DiscoveredEndpointDescription discoveredEndpointDescription = getDiscoveredEndpointDescription(
- serviceId, serviceInfo, discovered);
- if (discoveredEndpointDescription != null) {
- handleEndpointDescription(
- discoveredEndpointDescription.getEndpointDescription(),
- discovered);
- } else {
- logWarning("handleOSGiServiceEvent", //$NON-NLS-1$
- "discoveredEndpointDescription is null for service info=" //$NON-NLS-1$
- + serviceInfo + ",discovered=" + discovered); //$NON-NLS-1$
- }
- }
-
- public void handleEndpointDescription(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
- boolean discovered) {
- synchronized (listenerLock) {
- if (discovered)
- discoveredEndpointDescriptions.add(endpointDescription);
- else
- discoveredEndpointDescriptions.remove(endpointDescription);
-
- endpointDescriptionLocator.queueEndpointDescription(
- endpointDescription, discovered);
- }
- }
-
- public Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> getEndpointDescriptions() {
- synchronized (listenerLock) {
- Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> result = new ArrayList<org.osgi.service.remoteserviceadmin.EndpointDescription>();
- result.addAll(discoveredEndpointDescriptions);
- return result;
- }
- }
-
- private void logWarning(String methodName, String message) {
- LogUtility.logWarning(methodName, DebugOptions.DISCOVERY,
- this.getClass(), message);
- }
-
- private void logError(String methodName, String message) {
- logError(methodName, message, null);
- }
-
- private void logError(String methodName, String message, Throwable t) {
- LogUtility.logError(methodName, DebugOptions.DISCOVERY,
- this.getClass(), message, t);
- }
-
- private DiscoveredEndpointDescription getDiscoveredEndpointDescription(
- IServiceID serviceId, IServiceInfo serviceInfo, boolean discovered) {
- // Get IEndpointDescriptionFactory
- final String methodName = "getDiscoveredEndpointDescription"; //$NON-NLS-1$
- IDiscoveredEndpointDescriptionFactory factory = endpointDescriptionLocator
- .getDiscoveredEndpointDescriptionFactory();
- if (factory == null) {
- logError(
- methodName,
- "No IEndpointDescriptionFactory found, could not create EndpointDescription for " //$NON-NLS-1$
- + (discovered ? "discovered" : "undiscovered") //$NON-NLS-1$ //$NON-NLS-2$
- + " serviceInfo=" + serviceInfo); //$NON-NLS-1$
- return null;
- }
- try {
- // Else get endpoint description factory to create
- // EndpointDescription
- // for given serviceID and serviceInfo
- return (discovered) ? factory.createDiscoveredEndpointDescription(
- locator, serviceInfo) : factory
- .getUndiscoveredEndpointDescription(locator, serviceId);
- } catch (Exception e) {
- logError(
- methodName,
- "Exception calling IEndpointDescriptionFactory." //$NON-NLS-1$
- + ((discovered) ? "createDiscoveredEndpointDescription" //$NON-NLS-1$
- : "getUndiscoveredEndpointDescription"), e); //$NON-NLS-1$
- return null;
- } catch (NoClassDefFoundError e) {
- logError(
- methodName,
- "NoClassDefFoundError calling IEndpointDescriptionFactory." //$NON-NLS-1$
- + ((discovered) ? "createDiscoveredEndpointDescription" //$NON-NLS-1$
- : "getUndiscoveredEndpointDescription"), e); //$NON-NLS-1$
- return null;
- }
- }
-
- public synchronized void close() {
- if (locator != null) {
- locator.removeServiceListener(this);
- locator = null;
- }
- endpointDescriptionLocator = null;
- discoveredEndpointDescriptions.clear();
- }
-} \ No newline at end of file
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/PackageVersionComparator.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/PackageVersionComparator.java
deleted file mode 100644
index e0ee22a6a..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/PackageVersionComparator.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.DebugOptions;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.LogUtility;
-import org.osgi.framework.Version;
-
-public class PackageVersionComparator implements IPackageVersionComparator {
-
- public void comparePackageVersions(String packageName,
- Version remoteVersion, Version localVersion)
- throws RuntimeException {
- LogUtility.trace(
- "comparePackageVersions", //$NON-NLS-1$
- DebugOptions.PACKAGE_VERSION_COMPARATOR, this.getClass(),
- "packageName=" + packageName + ",remoteVersion=" //$NON-NLS-1$ //$NON-NLS-2$
- + remoteVersion + ",localVersion=" + localVersion); //$NON-NLS-1$
- // By default we do strict comparison of remote with local...they must
- // be exactly the same, or we thrown a runtime exception
- int compareResult = localVersion.compareTo(remoteVersion);
- // Now check compare result, and throw exception to fail compare
- if (compareResult != 0)
- throw new RuntimeException(
- "Package version compare failed with compareResult=" //$NON-NLS-1$
- + compareResult + " for package=" + packageName //$NON-NLS-1$
- + " localVersion=" + localVersion //$NON-NLS-1$
- + " remoteVersion=" + remoteVersion); //$NON-NLS-1$
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java
deleted file mode 100644
index b379fac35..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-public class RemoteConstants {
-
- private RemoteConstants() {
- // not instantiable
- }
-
- public static final String SERVICE_TYPE = "osgirsvc"; //$NON-NLS-1$
-
- public static final String DISCOVERY_SCOPE = "ecf.endpoint.discovery.scope"; //$NON-NLS-1$
- public static final String DISCOVERY_PROTOCOLS = "ecf.endpoint.discovery.protocols"; //$NON-NLS-1$
- public static final String DISCOVERY_NAMING_AUTHORITY = "ecf.endpoint.discovery.namingauthority"; //$NON-NLS-1$
- public static final String DISCOVERY_SERVICE_NAME = "ecf.endpoint.discovery.servicename"; //$NON-NLS-1$
- public static final String DISCOVERY_DEFAULT_SERVICE_NAME_PREFIX = "osgirsvc_"; //$NON-NLS-1$
-
- // container id namespace. Value of type String
- public static final String ENDPOINT_CONTAINER_ID_NAMESPACE = "ecf.endpoint.id.ns"; //$NON-NLS-1$
- // target id. Value of type String
- public static final String ENDPOINT_CONNECTTARGET_ID = "ecf.endpoint.connecttarget.id"; //$NON-NLS-1$
- // id filter. Value of type String+
- public static final String ENDPOINT_IDFILTER_IDS = "ecf.endpoint.idfilter.ids"; //$NON-NLS-1$
- // remote service filter. Value of type String
- public static final String ENDPOINT_REMOTESERVICE_FILTER = "ecf.endpoint.rsfilter"; //$NON-NLS-1$
-
- // Value of
- // org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS
- // For ECF providers this is a constant
- public static final String ENDPOINT_SERVICE_IMPORTED_CONFIGS_VALUE = "org.eclipse.ecf.config"; //$NON-NLS-1$
-
- // Value of type String,ID,or Object[]
- public static final String SERVICE_EXPORTED_CONTAINER_FACTORY_ARGS = "ecf.exported.containerfactoryargs"; //$NON-NLS-1$
- // Value of type IConnectContext
- public static final String SERVICE_EXPORTED_CONTAINER_CONNECT_CONTEXT = "ecf.exported.containerconnectcontext"; //$NON-NLS-1$
- // Value of type ID
- public static final String SERVICE_EXPORTED_CONTAINER_ID = "ecf.exported.containerid"; //$NON-NLS-1$
-
- public static final String SERVICE_IMPORTED_VALUETYPE = "ecf.imported.valuetype"; //$NON-NLS-1$
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteReferenceNotFoundException.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteReferenceNotFoundException.java
deleted file mode 100644
index 251b434ed..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteReferenceNotFoundException.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.eclipse.ecf.core.identity.ID;
-
-public class RemoteReferenceNotFoundException extends Exception {
-
- private static final long serialVersionUID = -4174685192086828376L;
-
- private ID targetID;
- private ID[] idFilter;
- private Collection<String> interfaces;
- private String rsFilter;
-
- public RemoteReferenceNotFoundException(ID targetID, ID[] idFilter,
- Collection<String> interfaces, String rsFilter) {
- this.targetID = targetID;
- this.idFilter = idFilter;
- this.interfaces = interfaces;
- this.rsFilter = rsFilter;
- }
-
- public ID getTargetID() {
- return targetID;
- }
-
- public ID[] getIdFilter() {
- return idFilter;
- }
-
- public Collection<String> getInterfaces() {
- return interfaces;
- }
-
- public String getRsFilter() {
- return rsFilter;
- }
-
- public String toString() {
- return "RemoteReferenceNotFoundException[targetID=" + targetID
- + ", idFilter=" + Arrays.toString(idFilter) + ", interfaces="
- + interfaces + ", rsFilter=" + rsFilter + "]";
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java
deleted file mode 100644
index 7095591df..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java
+++ /dev/null
@@ -1,1981 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeMap;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.ecf.core.ContainerTypeDescription;
-import org.eclipse.ecf.core.IContainer;
-import org.eclipse.ecf.core.IContainerManager;
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.util.ECFException;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.DebugOptions;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.LogUtility;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
-import org.eclipse.ecf.remoteservice.IOSGiRemoteServiceContainerAdapter;
-import org.eclipse.ecf.remoteservice.IRemoteService;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
-import org.eclipse.ecf.remoteservice.IRemoteServiceID;
-import org.eclipse.ecf.remoteservice.IRemoteServiceListener;
-import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
-import org.eclipse.ecf.remoteservice.IRemoteServiceRegistration;
-import org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent;
-import org.eclipse.ecf.remoteservice.events.IRemoteServiceUnregisteredEvent;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceException;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.Version;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.service.remoteserviceadmin.EndpointPermission;
-import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener;
-import org.osgi.util.tracker.ServiceTracker;
-
-@SuppressWarnings("deprecation")
-public class RemoteServiceAdmin implements
- org.osgi.service.remoteserviceadmin.RemoteServiceAdmin {
-
- public static final String SERVICE_PROP = "org.eclipse.ecf.rsa"; //$NON-NLS-1$
-
- private Bundle clientBundle;
-
- private boolean hostAutoCreateContainer = new Boolean(
- System.getProperty(
- "org.eclipse.ecf.osgi.services.remoteserviceadmin.hostAutoCreateContainer", //$NON-NLS-1$
- "true")).booleanValue(); //$NON-NLS-1$
- private String[] hostDefaultConfigTypes = new String[] { System
- .getProperty(
- "org.eclipse.ecf.osgi.services.remoteserviceadmin.hostDefaultConfigType", //$NON-NLS-1$
- "ecf.generic.server") }; //$NON-NLS-1$
-
- private boolean consumerAutoCreateContainer = new Boolean(
- System.getProperty(
- "org.eclipse.ecf.osgi.services.remoteserviceadmin.consumerAutoCreateContainer", //$NON-NLS-1$
- "true")).booleanValue(); //$NON-NLS-1$
-
- private PackageVersionComparator packageVersionComparator;
-
- private ServiceTracker packageAdminTracker;
- private Object packageAdminTrackerLock = new Object();
-
- private Object eventAdminTrackerLock = new Object();
- private ServiceTracker eventAdminTracker;
-
- private Object remoteServiceAdminListenerTrackerLock = new Object();
- private ServiceTracker remoteServiceAdminListenerTracker;
-
- private HostContainerSelector defaultHostContainerSelector;
- private ServiceRegistration defaultHostContainerSelectorRegistration;
-
- private ConsumerContainerSelector defaultConsumerContainerSelector;
- private ServiceRegistration defaultConsumerContainerSelectorRegistration;
-
- private Collection<ExportRegistration> exportedRegistrations = new ArrayList<ExportRegistration>();
- private Collection<ImportRegistration> importedRegistrations = new ArrayList<ImportRegistration>();
-
- public RemoteServiceAdmin(Bundle clientBundle) {
- this.clientBundle = clientBundle;
- Assert.isNotNull(this.clientBundle);
- trace("RemoteServiceAdmin<init>",
- "clientBundle=" + clientBundle.getSymbolicName());
- // Only setup defaults if it hasn't already been done by some other
- // Remote Service Admin instance
- Properties props = new Properties();
- props.put(org.osgi.framework.Constants.SERVICE_RANKING, new Integer(
- Integer.MIN_VALUE));
- // host container selector
- ServiceReference[] hostContainerSelectorRefs = null;
- try {
- hostContainerSelectorRefs = getClientBundleContext()
- .getServiceReferences(
- IHostContainerSelector.class.getName(), null);
- } catch (InvalidSyntaxException e) {
- // will not happen
- }
- // register a default only if no others already exist
- if (hostContainerSelectorRefs == null
- || hostContainerSelectorRefs.length == 0) {
- defaultHostContainerSelector = new HostContainerSelector(
- hostDefaultConfigTypes, hostAutoCreateContainer);
- defaultHostContainerSelectorRegistration = getClientBundleContext()
- .registerService(IHostContainerSelector.class.getName(),
- defaultHostContainerSelector, (Dictionary) props);
- }
- // consumer container selector
- ServiceReference[] consumerContainerSelectorRefs = null;
- try {
- consumerContainerSelectorRefs = getClientBundleContext()
- .getServiceReferences(
- IConsumerContainerSelector.class.getName(), null);
- } catch (InvalidSyntaxException e) {
- // will not happen
- }
- // register a default only if no others already exist
- if (consumerContainerSelectorRefs == null
- || consumerContainerSelectorRefs.length == 0) {
- defaultConsumerContainerSelector = new ConsumerContainerSelector(
- consumerAutoCreateContainer);
- defaultConsumerContainerSelectorRegistration = getClientBundleContext()
- .registerService(
- IConsumerContainerSelector.class.getName(),
- defaultConsumerContainerSelector,
- (Dictionary) props);
- }
- // create package version comparator
- packageVersionComparator = new PackageVersionComparator();
- }
-
- // RemoteServiceAdmin service interface impl methods
- public Collection<org.osgi.service.remoteserviceadmin.ExportRegistration> exportService(
- ServiceReference serviceReference,
- Map<String, Object> overridingProperties) {
-
- trace("exportService", "serviceReference=" + serviceReference //$NON-NLS-1$ //$NON-NLS-2$
- + ",properties=" + overridingProperties); //$NON-NLS-1$
-
- overridingProperties = (overridingProperties == null) ? Collections.EMPTY_MAP
- : overridingProperties;
-
- // First get exported interfaces
- String[] exportedInterfaces = (String[]) overridingProperties
- .get(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTERFACES);
- // As per 122.5.1 we only use the OBJECTCLASS value from the
- // serviceReference, not from the overridingProperties map
- if (exportedInterfaces == null)
- exportedInterfaces = PropertiesUtil
- .getExportedInterfaces(serviceReference);
- // If exportedInterfaces is still null, we throw
- if (exportedInterfaces == null)
- throw new IllegalArgumentException(
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTERFACES
- + " not set"); //$NON-NLS-1$
-
- // Get optional exported configs
- String[] exportedConfigs = PropertiesUtil
- .getStringArrayFromPropertyValue(overridingProperties
- .get(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_CONFIGS));
- if (exportedConfigs == null) {
- exportedConfigs = PropertiesUtil
- .getStringArrayFromPropertyValue(serviceReference
- .getProperty(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_CONFIGS));
- }
- // Get all intents (service.intents, service.exported.intents,
- // service.exported.intents.extra)
- String[] serviceIntents = PropertiesUtil.getServiceIntents(
- serviceReference, overridingProperties);
-
- // Get a host container selector, and use it to
- IHostContainerSelector hostContainerSelector = getHostContainerSelector();
- if (hostContainerSelector == null) {
- logError("handleServiceRegistering", //$NON-NLS-1$
- "No defaultHostContainerSelector available"); //$NON-NLS-1$
- return Collections.EMPTY_LIST;
- }
- // select ECF remote service containers that match given exported
- // interfaces, configs, and intents
- IRemoteServiceContainer[] rsContainers = hostContainerSelector
- .selectHostContainers(serviceReference, exportedInterfaces,
- exportedConfigs, serviceIntents);
- // If none found, log a warning and we're done
- if (rsContainers == null || rsContainers.length == 0) {
- logWarning(
- "handleServiceRegistered", "No remote service containers found for serviceReference=" //$NON-NLS-1$ //$NON-NLS-2$
- + serviceReference
- + ". Remote service NOT EXPORTED"); //$NON-NLS-1$
- return Collections.EMPTY_LIST;
- }
- Collection<ExportRegistration> exportRegistrations = new ArrayList<ExportRegistration>();
- synchronized (exportedRegistrations) {
- for (int i = 0; i < rsContainers.length; i++) {
- ExportRegistration exportRegistration = null;
- // If we've already got an export endpoint
- // for this service reference/containerID combination,
- // then create an ExportRegistration that uses the endpoint
- ExportEndpoint exportEndpoint = findExistingExportEndpoint(
- serviceReference, rsContainers[i].getContainer()
- .getID());
- // If we've already got one, then create a new
- // ExportRegistration for it and we're done
- if (exportEndpoint != null)
- exportRegistration = new ExportRegistration(exportEndpoint);
- else {
- // otherwise, actually export the service to create a new
- // ExportEndpoint
- // and use it to create a new ExportRegistration
- exportRegistration = new ExportRegistration(
- exportService(serviceReference,
- overridingProperties, exportedInterfaces,
- serviceIntents, rsContainers[i]));
- // If no exception, we add it to our known set of exported
- // registrations
- if (exportRegistration.getException() == null)
- exportedRegistrations.add(exportRegistration);
- }
- // We add it to the results in either case
- exportRegistrations.add(exportRegistration);
- }
- }
- // publish all exportRegistrations
- for (ExportRegistration exportReg : exportRegistrations)
- publishExportEvent(exportReg);
- // and return
- return new ArrayList<org.osgi.service.remoteserviceadmin.ExportRegistration>(
- exportRegistrations);
- }
-
- public org.osgi.service.remoteserviceadmin.ImportRegistration importService(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
-
- trace("importService", "endpointDescription=" + endpointDescription); //$NON-NLS-1$ //$NON-NLS-2$
-
- // First, make sure that the client bundle has the IMPORT endpoint
- // permission
- checkEndpointPermission(endpointDescription, EndpointPermission.IMPORT);
-
- if (endpointDescription.getServiceId() == 0)
- return handleNonOSGiService(endpointDescription);
-
- // First check to see whether it's one of ECF's endpoint descriptions
- if (endpointDescription instanceof EndpointDescription) {
- EndpointDescription ed = (EndpointDescription) endpointDescription;
- // Now get IConsumerContainerSelector, to select the ECF container
- // for the given endpointDescription
- IConsumerContainerSelector consumerContainerSelector = getConsumerContainerSelector();
- // If there is none, then we can go no further
- if (consumerContainerSelector == null) {
- logError("importService", //$NON-NLS-1$
- "No defaultConsumerContainerSelector available"); //$NON-NLS-1$
- return null;
- }
- // Select the rsContainer to handle the endpoint description
- IRemoteServiceContainer rsContainer = consumerContainerSelector
- .selectConsumerContainer(ed);
- // If none found, log a warning and we're done
- if (rsContainer == null) {
- logWarning(
- "importService", "No remote service container selected for endpoint=" //$NON-NLS-1$ //$NON-NLS-2$
- + endpointDescription
- + ". Remote service NOT IMPORTED"); //$NON-NLS-1$
- return null;
- }
- // If one selected then import the service to create an import
- // registration
- ImportRegistration importRegistration = null;
- synchronized (importedRegistrations) {
- ImportEndpoint importEndpoint = findImportEndpoint(ed);
- if (importEndpoint != null)
- importRegistration = new ImportRegistration(importEndpoint);
- else {
- importEndpoint = importService(ed, rsContainer);
- importRegistration = new ImportRegistration(importEndpoint);
- if (importRegistration.getException() == null)
- importedRegistrations.add(importRegistration);
- }
- }
- // publish import event
- publishImportEvent(importRegistration);
- // Finally, return the importRegistration. It may be null or not.
- return importRegistration;
- } else {
- logWarning("importService", "endpointDescription=" //$NON-NLS-1$ //$NON-NLS-2$
- + endpointDescription
- + " is not ECF EndpointDescription...ignoring"); //$NON-NLS-1$
- return null;
- }
- }
-
- public Collection<org.osgi.service.remoteserviceadmin.ExportReference> getExportedServices() {
- Collection<org.osgi.service.remoteserviceadmin.ExportReference> results = new ArrayList<org.osgi.service.remoteserviceadmin.ExportReference>();
- synchronized (exportedRegistrations) {
- for (ExportRegistration reg : exportedRegistrations) {
- org.osgi.service.remoteserviceadmin.ExportReference eRef = reg
- .getExportReference();
- if (eRef != null
- && checkEndpointPermissionRead("getExportedServices", //$NON-NLS-1$
- eRef.getExportedEndpoint()))
- results.add(eRef);
- }
- }
- return results;
- }
-
- public Collection<org.osgi.service.remoteserviceadmin.ImportReference> getImportedEndpoints() {
- Collection<org.osgi.service.remoteserviceadmin.ImportReference> results = new ArrayList<org.osgi.service.remoteserviceadmin.ImportReference>();
- synchronized (importedRegistrations) {
- for (ImportRegistration reg : importedRegistrations) {
- org.osgi.service.remoteserviceadmin.ImportReference iRef = reg
- .getImportReference();
- if (iRef != null
- && checkEndpointPermissionRead("getImportedEndpoints", //$NON-NLS-1$
- iRef.getImportedEndpoint()))
- results.add(iRef);
- }
- }
- return results;
- }
-
- // end RemoteServiceAdmin service interface impl methods
-
- private boolean checkEndpointPermissionRead(
- String methodName,
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
- try {
- checkEndpointPermission(endpointDescription,
- EndpointPermission.READ);
- return true;
- } catch (SecurityException e) {
- logError(methodName,
- "permission check failed for read access to endpointDescription=" //$NON-NLS-1$
- + endpointDescription, e);
- return false;
- }
- }
-
- private BundleContext getClientBundleContext() {
- return clientBundle.getBundleContext();
- }
-
- private Bundle getClientBundle() {
- return clientBundle;
- }
-
- private boolean removeExportRegistration(
- ExportRegistration exportRegistration) {
- synchronized (exportedRegistrations) {
- boolean removed = exportedRegistrations.remove(exportRegistration);
- trace("removeExportRegistration", "exportRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
- + exportRegistration + " exportedRegistrations=" //$NON-NLS-1$
- + exportedRegistrations + " removed=" + removed); //$NON-NLS-1$
- return removed;
- }
- }
-
- private boolean removeImportRegistration(
- ImportRegistration importRegistration) {
- synchronized (importedRegistrations) {
- boolean removed = importedRegistrations.remove(importRegistration);
- trace("removeImportRegistration", "importRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
- + importRegistration + " importedRegistrations=" //$NON-NLS-1$
- + importedRegistrations + " removed=" + removed); //$NON-NLS-1$
- return removed;
- }
- }
-
- private void closeDefaultContainerSelectors() {
- if (defaultHostContainerSelectorRegistration != null) {
- defaultHostContainerSelectorRegistration.unregister();
- defaultHostContainerSelectorRegistration = null;
- }
- if (defaultHostContainerSelector != null) {
- defaultHostContainerSelector.close();
- defaultHostContainerSelector = null;
- }
- if (defaultConsumerContainerSelectorRegistration != null) {
- defaultConsumerContainerSelectorRegistration.unregister();
- defaultConsumerContainerSelectorRegistration = null;
- }
- if (defaultConsumerContainerSelector != null) {
- defaultConsumerContainerSelector.close();
- defaultConsumerContainerSelector = null;
- }
- }
-
- private void checkEndpointPermission(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
- String permissionType) throws SecurityException {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null)
- return;
- sm.checkPermission(new EndpointPermission(endpointDescription,
- Activator.getDefault().getFrameworkUUID(), permissionType));
- }
-
- class ExportEndpoint {
-
- private ServiceReference serviceReference;
- private EndpointDescription endpointDescription;
-
- private IRemoteServiceRegistration rsRegistration;
- private ExportReference exportReference;
- private Set<ExportRegistration> exportRegistrations = new HashSet<ExportRegistration>();
-
- private Throwable exception;
-
- ExportEndpoint(ServiceReference serviceReference,
- EndpointDescription endpointDescription,
- IRemoteServiceRegistration reg) {
- Assert.isNotNull(serviceReference);
- this.serviceReference = serviceReference;
- Assert.isNotNull(endpointDescription);
- this.endpointDescription = endpointDescription;
-
- Assert.isNotNull(reg);
- this.rsRegistration = reg;
- this.exportReference = new ExportReference(serviceReference,
- endpointDescription);
- }
-
- ExportEndpoint(ServiceReference serviceReference,
- EndpointDescription endpointDescription, Throwable t) {
- Assert.isNotNull(serviceReference);
- this.serviceReference = serviceReference;
- Assert.isNotNull(endpointDescription);
- this.endpointDescription = endpointDescription;
- this.exception = t;
- }
-
- synchronized Throwable getException() {
- return exception;
- }
-
- synchronized ID getContainerID() {
- return endpointDescription.getContainerID();
- }
-
- synchronized ServiceReference getServiceReference() {
- return serviceReference;
- }
-
- synchronized EndpointDescription getEndpointDescription() {
- return endpointDescription;
- }
-
- synchronized ExportReference getExportReference() {
- return exportReference;
- }
-
- synchronized IRemoteServiceRegistration getRemoteServiceRegistration() {
- return rsRegistration;
- }
-
- synchronized boolean add(ExportRegistration exportRegistration) {
- return this.exportRegistrations.add(exportRegistration);
- }
-
- synchronized boolean close(ExportRegistration exportRegistration) {
- boolean removed = this.exportRegistrations
- .remove(exportRegistration);
- if (removed && exportRegistrations.size() == 0) {
- if (rsRegistration != null) {
- rsRegistration.unregister();
- rsRegistration = null;
- }
- if (exportReference != null) {
- exportReference.close();
- exportReference = null;
- }
- }
- return removed;
- }
-
- public synchronized String toString() {
- return "ExportEndpoint[rsRegistration=" + rsRegistration //$NON-NLS-1$
- + ", exportReference=" + exportReference + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- }
-
- class ExportRegistration implements
- org.osgi.service.remoteserviceadmin.ExportRegistration {
-
- private ExportEndpoint exportEndpoint;
-
- ExportRegistration(ExportEndpoint exportEndpoint) {
- Assert.isNotNull(exportEndpoint);
- this.exportEndpoint = exportEndpoint;
- // Add ourselves to this exported endpoint
- this.exportEndpoint.add(this);
- }
-
- synchronized ID getContainerID() {
- return (exportEndpoint == null) ? null : exportEndpoint
- .getContainerID();
- }
-
- synchronized ServiceReference getServiceReference() {
- return (exportEndpoint == null) ? null : exportEndpoint
- .getServiceReference();
- }
-
- public synchronized org.osgi.service.remoteserviceadmin.ExportReference getExportReference() {
- Throwable t = getException();
- if (t != null)
- throw new IllegalStateException(
- "Cannot get export reference as export registration is invalid", //$NON-NLS-1$
- t);
- return (exportEndpoint == null) ? null : exportEndpoint
- .getExportReference();
- }
-
- synchronized boolean match(ServiceReference serviceReference) {
- return match(serviceReference, null);
- }
-
- synchronized boolean match(ServiceReference serviceReference,
- ID containerID) {
- ServiceReference ourServiceReference = getServiceReference();
- if (ourServiceReference == null)
- return false;
- boolean serviceReferenceCompare = ourServiceReference
- .equals(serviceReference);
- // If the second parameter is null, then we compare only on service
- // references
- if (containerID == null)
- return serviceReferenceCompare;
- ID ourContainerID = getContainerID();
- if (ourContainerID == null)
- return false;
- return serviceReferenceCompare
- && ourContainerID.equals(containerID);
- }
-
- synchronized ExportEndpoint getExportEndpoint(
- ServiceReference serviceReference, ID containerID) {
- return match(serviceReference, containerID) ? exportEndpoint : null;
- }
-
- synchronized IRemoteServiceRegistration getRemoteServiceRegistration() {
- return (exportEndpoint == null) ? null : exportEndpoint
- .getRemoteServiceRegistration();
- }
-
- synchronized EndpointDescription getEndpointDescription() {
- return (exportEndpoint == null) ? null : exportEndpoint
- .getEndpointDescription();
- }
-
- public void close() {
- boolean closed = false;
- Throwable t = null;
- org.osgi.service.remoteserviceadmin.ExportReference exportReference = null;
- EndpointDescription endpointDescription = null;
- synchronized (this) {
- if (exportEndpoint != null) {
- t = getException();
- exportReference = (t == null) ? getExportReference() : null;
- endpointDescription = getEndpointDescription();
- closed = exportEndpoint.close(this);
- exportEndpoint = null;
- }
- }
- if (closed) {
- removeExportRegistration(this);
- publishEvent(
- new RemoteServiceAdminEvent(
- endpointDescription.getContainerID(),
- RemoteServiceAdminEvent.EXPORT_UNREGISTRATION,
- getClientBundle(), exportReference, t),
- endpointDescription);
- }
- }
-
- public synchronized Throwable getException() {
- return (exportEndpoint == null) ? null : exportEndpoint
- .getException();
- }
-
- public synchronized String toString() {
- return "ExportRegistration[exportEndpoint=" + exportEndpoint + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- }
-
- class ExportReference implements
- org.osgi.service.remoteserviceadmin.ExportReference {
-
- private ServiceReference serviceReference;
- private EndpointDescription endpointDescription;
-
- ExportReference(ServiceReference serviceReference,
- EndpointDescription endpointDescription) {
- this.serviceReference = serviceReference;
- this.endpointDescription = endpointDescription;
- }
-
- public synchronized ServiceReference getExportedService() {
- return serviceReference;
- }
-
- public synchronized org.osgi.service.remoteserviceadmin.EndpointDescription getExportedEndpoint() {
- return endpointDescription;
- }
-
- synchronized void close() {
- this.serviceReference = null;
- this.endpointDescription = null;
- }
-
- public synchronized String toString() {
- return "ExportReference[serviceReference=" + serviceReference //$NON-NLS-1$
- + ", endpointDescription=" + endpointDescription + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- }
-
- class ImportEndpoint {
-
- private IRemoteServiceContainerAdapter rsContainerAdapter;
- private EndpointDescription endpointDescription;
- private IRemoteServiceListener rsListener;
- private IRemoteServiceReference rsReference;
- private ServiceRegistration proxyRegistration;
- private ImportReference importReference;
- private Set<ImportRegistration> importRegistrations = new HashSet<ImportRegistration>();
-
- private Throwable exception;
-
- ImportEndpoint(IRemoteServiceContainerAdapter rsContainerAdapter,
- IRemoteServiceReference rsReference,
- IRemoteServiceListener rsListener,
- ServiceRegistration proxyRegistration,
- EndpointDescription endpointDescription) {
- this.rsContainerAdapter = rsContainerAdapter;
- this.endpointDescription = endpointDescription;
- this.rsReference = rsReference;
- this.rsListener = rsListener;
- this.proxyRegistration = proxyRegistration;
- this.importReference = new ImportReference(
- proxyRegistration.getReference(), endpointDescription);
- // Add the remoteservice listener to the container adapter, so that
- // the
- // rsListener
- // notified asynchronously if our underlying remote service
- // reference is
- // unregistered locally
- // due to disconnect or remote ejection
- this.rsContainerAdapter.addRemoteServiceListener(this.rsListener);
- }
-
- ImportEndpoint(IRemoteServiceContainerAdapter rsContainerAdapter,
- EndpointDescription endpointDescription, Throwable t) {
- this.rsContainerAdapter = rsContainerAdapter;
- this.endpointDescription = endpointDescription;
- this.exception = t;
- }
-
- synchronized EndpointDescription getEndpointDescription() {
- return endpointDescription;
- }
-
- synchronized Throwable getException() {
- return exception;
- }
-
- synchronized ID getContainerID() {
- return (rsReference == null) ? null : rsReference.getContainerID();
- }
-
- synchronized boolean add(ImportRegistration importRegistration) {
- return this.importRegistrations.add(importRegistration);
- }
-
- synchronized boolean close(ImportRegistration importRegistration) {
- boolean removed = this.importRegistrations
- .remove(importRegistration);
- if (removed && importRegistrations.size() == 0) {
- if (proxyRegistration != null) {
- proxyRegistration.unregister();
- proxyRegistration = null;
- }
- if (rsContainerAdapter != null) {
- if (rsReference != null) {
- rsContainerAdapter.ungetRemoteService(rsReference);
- rsReference = null;
- }
- // remove remote service listener
- if (rsListener != null) {
- rsContainerAdapter
- .removeRemoteServiceListener(rsListener);
- rsListener = null;
- }
- rsContainerAdapter = null;
- }
- if (importReference != null) {
- importReference.close();
- importReference = null;
- }
- }
- return removed;
- }
-
- synchronized ImportReference getImportReference() {
- return importReference;
- }
-
- synchronized boolean match(IRemoteServiceID remoteServiceID) {
- if (remoteServiceID == null || rsReference == null)
- return false;
- return rsReference.getID().equals(remoteServiceID);
- }
-
- public synchronized String toString() {
- return "ImportEndpoint[rsReference=" + rsReference //$NON-NLS-1$
- + ", proxyRegistration=" + proxyRegistration //$NON-NLS-1$
- + ", importReference=" + importReference + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- synchronized boolean match(EndpointDescription ed) {
- if (importReference == null)
- return false;
- EndpointDescription importedEndpoint = (EndpointDescription) importReference
- .getImportedEndpoint();
- if (importedEndpoint == null)
- return false;
- return importedEndpoint.isSameService(ed);
- }
-
- }
-
- class ImportRegistration implements
- org.osgi.service.remoteserviceadmin.ImportRegistration {
-
- private ImportEndpoint importEndpoint;
-
- ImportRegistration(ImportEndpoint importEndpoint) {
- Assert.isNotNull(importEndpoint);
- this.importEndpoint = importEndpoint;
- this.importEndpoint.add(this);
- }
-
- synchronized ID getContainerID() {
- return importEndpoint == null ? null : importEndpoint
- .getContainerID();
- }
-
- synchronized EndpointDescription getEndpointDescription() {
- return (importEndpoint == null) ? null : importEndpoint
- .getEndpointDescription();
- }
-
- synchronized boolean match(IRemoteServiceID remoteServiceID) {
- if (importEndpoint == null)
- return false;
- return importEndpoint.match(remoteServiceID);
- }
-
- synchronized ImportEndpoint getImportEndpoint(EndpointDescription ed) {
- if (importEndpoint == null)
- return null;
- if (importEndpoint.match(ed))
- return importEndpoint;
- return null;
- }
-
- public synchronized org.osgi.service.remoteserviceadmin.ImportReference getImportReference() {
- Throwable t = getException();
- if (t != null)
- throw new IllegalStateException(
- "Cannot get import reference as registration not properly initialized", //$NON-NLS-1$
- t);
- return importEndpoint == null ? null : importEndpoint
- .getImportReference();
- }
-
- public void close() {
- boolean closed = false;
- org.osgi.service.remoteserviceadmin.ImportReference importReference = null;
- EndpointDescription endpointDescription = null;
- Throwable t = null;
- synchronized (this) {
- if (importEndpoint != null) {
- t = getException();
- importReference = (t == null) ? getImportReference() : null;
- endpointDescription = getEndpointDescription();
- closed = importEndpoint.close(this);
- importEndpoint = null;
- }
- }
- if (closed) {
- removeImportRegistration(this);
- publishEvent(
- new RemoteServiceAdminEvent(
- endpointDescription.getContainerID(),
- RemoteServiceAdminEvent.IMPORT_UNREGISTRATION,
- getClientBundle(), importReference, t),
- endpointDescription);
- }
- }
-
- public synchronized Throwable getException() {
- return (importEndpoint == null) ? null : importEndpoint
- .getException();
- }
-
- public synchronized String toString() {
- return "ImportRegistration[importEndpoint=" + importEndpoint + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- }
-
- class ImportReference implements
- org.osgi.service.remoteserviceadmin.ImportReference {
-
- private ServiceReference importedServiceReference;
- private EndpointDescription endpointDescription;
-
- ImportReference(ServiceReference serviceReference,
- EndpointDescription endpointDescription) {
- this.importedServiceReference = serviceReference;
- this.endpointDescription = endpointDescription;
- }
-
- public synchronized ServiceReference getImportedService() {
- return importedServiceReference;
- }
-
- public synchronized org.osgi.service.remoteserviceadmin.EndpointDescription getImportedEndpoint() {
- return endpointDescription;
- }
-
- synchronized void close() {
- this.importedServiceReference = null;
- this.endpointDescription = null;
- }
-
- public synchronized String toString() {
- return "ImportReference[importedServiceReference=" //$NON-NLS-1$
- + importedServiceReference + ", endpointDescription=" //$NON-NLS-1$
- + endpointDescription + "]"; //$NON-NLS-1$
- }
-
- }
-
- private void publishEvent(RemoteServiceAdminEvent event,
- EndpointDescription endpointDescription) {
- // send event synchronously to RemoteServiceAdminListeners
- EndpointPermission perm = new EndpointPermission(endpointDescription,
- Activator.getDefault().getFrameworkUUID(),
- EndpointPermission.READ);
- // notify synchronously all appropriate listeners (those with READ
- // permission)
- RemoteServiceAdminListener[] listeners = getListeners(perm);
- if (listeners != null)
- for (int i = 0; i < listeners.length; i++)
- listeners[i].remoteAdminEvent(event);
- // Now also post the event asynchronously to EventAdmin
- postEvent(event, endpointDescription);
- }
-
- private void postEvent(RemoteServiceAdminEvent event,
- EndpointDescription endpointDescription) {
- EventAdmin eventAdmin = getEventAdmin();
- if (eventAdmin == null) {
- logWarning("postEvent", "No event admin available to post event=" //$NON-NLS-1$ //$NON-NLS-2$
- + event + " with endpointDescription=" //$NON-NLS-1$
- + endpointDescription);
- return;
- }
- int eventType = event.getType();
- String eventTypeName = null;
- switch (eventType) {
- case (RemoteServiceAdminEvent.EXPORT_REGISTRATION):
- eventTypeName = "EXPORT_REGISTRATION"; //$NON-NLS-1$
- break;
- case (RemoteServiceAdminEvent.EXPORT_ERROR):
- eventTypeName = "EXPORT_ERROR"; //$NON-NLS-1$
- break;
- case (RemoteServiceAdminEvent.EXPORT_UNREGISTRATION):
- eventTypeName = "EXPORT_UNREGISTRATION"; //$NON-NLS-1$
- break;
- case (RemoteServiceAdminEvent.EXPORT_WARNING):
- eventTypeName = "EXPORT_WARNING"; //$NON-NLS-1$
- break;
- case (RemoteServiceAdminEvent.IMPORT_REGISTRATION):
- eventTypeName = "IMPORT_REGISTRATION"; //$NON-NLS-1$
- break;
- case (RemoteServiceAdminEvent.IMPORT_ERROR):
- eventTypeName = "IMPORT_ERROR"; //$NON-NLS-1$
- break;
- case (RemoteServiceAdminEvent.IMPORT_UNREGISTRATION):
- eventTypeName = "IMPORT_UNREGISTRATION"; //$NON-NLS-1$
- break;
- case (RemoteServiceAdminEvent.IMPORT_WARNING):
- eventTypeName = "IMPORT_WARNING"; //$NON-NLS-1$
- break;
- }
- if (eventTypeName == null)
- logError("postEvent", "Event type=" + eventType //$NON-NLS-1$ //$NON-NLS-2$
- + " not understood for event=" + event + ". Not posting"); //$NON-NLS-1$ //$NON-NLS-2$
- String topic = "org/osgi/service/remoteserviceadmin/" + eventTypeName; //$NON-NLS-1$
- Bundle rsaBundle = getClientBundle();
- Dictionary eventProperties = new Properties();
- eventProperties.put("clientBundle", rsaBundle); //$NON-NLS-1$
- eventProperties.put("clientBundle.id", //$NON-NLS-1$
- new Long(rsaBundle.getBundleId()));
- eventProperties.put("clientBundle.symbolicname", //$NON-NLS-1$
- rsaBundle.getSymbolicName());
- eventProperties.put("clientBundle.version", rsaBundle.getVersion()); //$NON-NLS-1$
- String[] signers = getSignersForBundle(clientBundle);
- if (signers != null && signers.length > 0)
- eventProperties.put("clientBundle.signer", signers); //$NON-NLS-1$
- Throwable t = event.getException();
- if (t != null)
- eventProperties.put("cause", t); //$NON-NLS-1$
- long serviceId = endpointDescription.getServiceId();
- if (serviceId != 0)
- eventProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID,
- new Long(serviceId));
- String frameworkUUID = endpointDescription.getFrameworkUUID();
- if (frameworkUUID != null)
- eventProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID,
- frameworkUUID);
- String endpointId = endpointDescription.getId();
- if (endpointId != null)
- eventProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID,
- endpointId);
- List<String> interfaces = endpointDescription.getInterfaces();
- if (interfaces != null && interfaces.size() > 0)
- eventProperties.put(org.osgi.framework.Constants.OBJECTCLASS,
- interfaces.toArray(new String[interfaces.size()]));
- List<String> importedConfigs = endpointDescription
- .getConfigurationTypes();
- if (importedConfigs != null && importedConfigs.size() > 0)
- eventProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,
- importedConfigs.toArray(new String[importedConfigs
- .size()]));
- eventProperties.put("timestamp", new Long(new Date().getTime())); //$NON-NLS-1$
- eventProperties.put("event", event); //$NON-NLS-1$
- postRemoteServiceAdminEvent(topic, eventProperties);
-
- }
-
- private String[] getSignersForBundle(Bundle bundle) {
- List<String> result = new ArrayList<String>();
- Map signers = bundle.getSignerCertificates(Bundle.SIGNERS_ALL);
- for (Iterator i = signers.keySet().iterator(); i.hasNext();)
- result.add(i.next().toString());
- return (String[]) result.toArray(new String[result.size()]);
- }
-
- private void publishExportEvent(ExportRegistration exportRegistration) {
- Throwable exception = exportRegistration.getException();
- org.osgi.service.remoteserviceadmin.ExportReference exportReference = (exception == null) ? exportRegistration
- .getExportReference() : null;
- RemoteServiceAdminEvent rsaEvent = new RemoteServiceAdminEvent(
- exportRegistration.getContainerID(),
- (exception == null) ? RemoteServiceAdminEvent.EXPORT_REGISTRATION
- : RemoteServiceAdminEvent.EXPORT_ERROR,
- getClientBundle(), exportReference, exception);
- publishEvent(rsaEvent, exportRegistration.getEndpointDescription());
- }
-
- private void publishImportEvent(ImportRegistration importRegistration) {
- Throwable exception = importRegistration.getException();
- org.osgi.service.remoteserviceadmin.ImportReference importReference = (exception == null) ? importRegistration
- .getImportReference() : null;
- RemoteServiceAdminEvent rsaEvent = new RemoteServiceAdminEvent(
- importRegistration.getContainerID(),
- (exception == null) ? RemoteServiceAdminEvent.IMPORT_REGISTRATION
- : RemoteServiceAdminEvent.IMPORT_ERROR,
- getClientBundle(), importReference, exception);
- publishEvent(rsaEvent, importRegistration.getEndpointDescription());
- }
-
- private void closeRemoteServiceAdminListenerTracker() {
- synchronized (remoteServiceAdminListenerTrackerLock) {
- if (remoteServiceAdminListenerTracker != null) {
- remoteServiceAdminListenerTracker.close();
- remoteServiceAdminListenerTracker = null;
- }
- }
- }
-
- private RemoteServiceAdminListener[] getListeners(EndpointPermission perm) {
- synchronized (remoteServiceAdminListenerTrackerLock) {
- if (remoteServiceAdminListenerTracker == null) {
- remoteServiceAdminListenerTracker = new ServiceTracker(
- getClientBundleContext(),
- RemoteServiceAdminListener.class.getName(), null);
- remoteServiceAdminListenerTracker.open(true);
- }
- }
- ServiceReference[] unfilteredRefs = remoteServiceAdminListenerTracker
- .getServiceReferences();
- if (unfilteredRefs == null)
- return null;
- // Filter by Bundle.hasPermission
- List<ServiceReference> filteredRefs = new ArrayList<ServiceReference>();
- for (ServiceReference ref : unfilteredRefs)
- if (perm == null || ref.getBundle().hasPermission(perm))
- filteredRefs.add(ref);
- List<RemoteServiceAdminListener> results = new ArrayList<RemoteServiceAdminListener>();
- for (ServiceReference ref : filteredRefs) {
- RemoteServiceAdminListener l = (RemoteServiceAdminListener) remoteServiceAdminListenerTracker
- .getService(ref);
- if (l != null)
- results.add(l);
- }
- return results.toArray(new RemoteServiceAdminListener[results.size()]);
- }
-
- private ExportEndpoint findExistingExportEndpoint(
- ServiceReference serviceReference, ID containerID) {
- for (ExportRegistration eReg : exportedRegistrations) {
- ExportEndpoint exportEndpoint = eReg.getExportEndpoint(
- serviceReference, containerID);
- if (exportEndpoint != null)
- return exportEndpoint;
- }
- return null;
- }
-
- private EventAdmin getEventAdmin() {
- synchronized (eventAdminTrackerLock) {
- eventAdminTracker = new ServiceTracker(getClientBundleContext(),
- EventAdmin.class.getName(), null);
- eventAdminTracker.open(true);
- }
- return (EventAdmin) eventAdminTracker.getService();
- }
-
- private void postRemoteServiceAdminEvent(String topic,
- Dictionary eventProperties) {
- EventAdmin eventAdmin = getEventAdmin();
- if (eventAdmin == null) {
- logError("postRemoteServiceAdminEvent", //$NON-NLS-1$
- "No EventAdmin service available to send eventTopic=" //$NON-NLS-1$
- + topic + " eventProperties=" + eventProperties); //$NON-NLS-1$
- return;
- }
- eventAdmin.postEvent(new Event(topic, eventProperties));
- }
-
- private void closeEventAdminTracker() {
- synchronized (eventAdminTrackerLock) {
- if (eventAdminTracker != null) {
- eventAdminTracker.close();
- eventAdminTracker = null;
- }
- }
- }
-
- private void closePackageAdminTracker() {
- synchronized (packageAdminTrackerLock) {
- if (packageAdminTracker != null) {
- packageAdminTracker.close();
- packageAdminTracker = null;
- }
- }
- }
-
- private Object consumerContainerSelectorTrackerLock = new Object();
- private ServiceTracker consumerContainerSelectorTracker;
-
- private void closeConsumerContainerSelectorTracker() {
- synchronized (consumerContainerSelectorTrackerLock) {
- if (consumerContainerSelectorTracker != null) {
- consumerContainerSelectorTracker.close();
- consumerContainerSelectorTracker = null;
- }
- }
- if (defaultConsumerContainerSelector != null) {
- defaultConsumerContainerSelector.close();
- defaultConsumerContainerSelector = null;
- }
- }
-
- private Object hostContainerSelectorTrackerLock = new Object();
- private ServiceTracker hostContainerSelectorTracker;
-
- private void closeHostContainerSelectorTracker() {
- synchronized (hostContainerSelectorTrackerLock) {
- if (hostContainerSelectorTracker != null) {
- hostContainerSelectorTracker.close();
- hostContainerSelectorTracker = null;
- }
- }
- if (defaultHostContainerSelector != null) {
- defaultHostContainerSelector.close();
- defaultHostContainerSelector = null;
- }
- }
-
- protected IHostContainerSelector getHostContainerSelector() {
- synchronized (hostContainerSelectorTrackerLock) {
- if (hostContainerSelectorTracker == null) {
- hostContainerSelectorTracker = new ServiceTracker(
- getClientBundleContext(),
- IHostContainerSelector.class.getName(), null);
- hostContainerSelectorTracker.open();
- }
- }
- return (IHostContainerSelector) hostContainerSelectorTracker
- .getService();
- }
-
- protected IConsumerContainerSelector getConsumerContainerSelector() {
- synchronized (consumerContainerSelectorTrackerLock) {
- if (consumerContainerSelectorTracker == null) {
- consumerContainerSelectorTracker = new ServiceTracker(
- getClientBundleContext(),
- IConsumerContainerSelector.class.getName(), null);
- consumerContainerSelectorTracker.open();
- }
- }
- return (IConsumerContainerSelector) consumerContainerSelectorTracker
- .getService();
- }
-
- private Version getPackageVersion(ServiceReference serviceReference,
- String serviceInterface, String packageName) {
- Object service = getClientBundleContext().getService(serviceReference);
- if (service == null)
- return null;
- Class[] interfaceClasses = service.getClass().getInterfaces();
- if (interfaceClasses == null)
- return null;
- Class interfaceClass = null;
- for (int i = 0; i < interfaceClasses.length; i++) {
- if (interfaceClasses[i].getName().equals(serviceInterface))
- interfaceClass = interfaceClasses[i];
- }
- if (interfaceClass == null)
- return null;
- ExportedPackage exportedPackage = getExportedPackageForClass(
- getPackageAdmin(), interfaceClass);
- return (exportedPackage == null) ? null : exportedPackage.getVersion();
- }
-
- private Map<String, Object> createExportEndpointDescriptionProperties(
- ServiceReference serviceReference,
- Map<String, Object> overridingProperties,
- String[] exportedInterfaces, String[] serviceIntents,
- IRemoteServiceContainer rsContainer) {
- IContainer container = rsContainer.getContainer();
- ID containerID = container.getID();
-
- Map<String, Object> endpointDescriptionProperties = new TreeMap<String, Object>(
- String.CASE_INSENSITIVE_ORDER);
-
- // OSGi properties
- // OBJECTCLASS set to exportedInterfaces
- endpointDescriptionProperties.put(
- org.osgi.framework.Constants.OBJECTCLASS, exportedInterfaces);
-
- // Service interface versions
- for (int i = 0; i < exportedInterfaces.length; i++) {
- String packageName = getPackageName(exportedInterfaces[i]);
- String packageVersionKey = org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_PACKAGE_VERSION_
- + packageName;
- // If it's pre-set...by registration or by overridingProperties,
- // then use that value
- String packageVersion = (String) PropertiesUtil.getPropertyValue(
- serviceReference, overridingProperties, packageVersionKey);
- if (packageVersion == null) {
- Version version = getPackageVersion(serviceReference,
- exportedInterfaces[i], packageName);
- if (version != null && !version.equals(Version.emptyVersion))
- packageVersion = version.toString();
- else
- logWarning("createExportEndpointDescription", //$NON-NLS-1$
- "No or empty version specified for exported service interface=" //$NON-NLS-1$
- + exportedInterfaces[i]);
- }
- // Only set the package version if we have a non-null value
- if (packageVersion != null)
- endpointDescriptionProperties.put(packageVersionKey,
- packageVersion);
- }
-
- // ENDPOINT_ID
- String endpointId = (String) PropertiesUtil
- .getPropertyValue(
- serviceReference,
- overridingProperties,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID);
- if (endpointId == null)
- endpointId = containerID.getName();
- endpointDescriptionProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID,
- endpointId);
-
- // ENDPOINT_SERVICE_ID
- // This is always set to the value from serviceReference as per 122.5.1
- Long serviceId = (Long) serviceReference
- .getProperty(org.osgi.framework.Constants.SERVICE_ID);
- endpointDescriptionProperties.put(
- org.osgi.framework.Constants.SERVICE_ID, serviceId);
-
- // ENDPOINT_FRAMEWORK_ID
- String frameworkId = (String) PropertiesUtil
- .getPropertyValue(
- serviceReference,
- overridingProperties,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID);
- if (frameworkId == null)
- frameworkId = Activator.getDefault().getFrameworkUUID();
- endpointDescriptionProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID,
- frameworkId);
-
- // REMOTE_CONFIGS_SUPPORTED
- String[] remoteConfigsSupported = getSupportedConfigs(container);
- if (remoteConfigsSupported != null)
- endpointDescriptionProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED,
- remoteConfigsSupported);
- // SERVICE_IMPORTED_CONFIGS...set to same value as remote configs
- // supported (which is computed
- // for the exporting ECF container
- endpointDescriptionProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,
- remoteConfigsSupported);
-
- // SERVICE_INTENTS
- String[] intents = (String[]) PropertiesUtil
- .getPropertyValue(
- null,
- overridingProperties,
- org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS);
- if (intents == null)
- intents = serviceIntents;
- if (intents != null)
- endpointDescriptionProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS,
- intents);
-
- // REMOTE_INTENTS_SUPPORTED
- String[] remoteIntentsSupported = getSupportedIntents(container);
- if (remoteIntentsSupported != null)
- endpointDescriptionProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED,
- remoteIntentsSupported);
-
- // ECF properties
- // ID namespace
- String idNamespace = containerID.getNamespace().getName();
- endpointDescriptionProperties.put(
- RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE, idNamespace);
-
- // ENDPOINT_CONNECTTARGET_ID
- String connectTarget = (String) PropertiesUtil.getPropertyValue(
- serviceReference, overridingProperties,
- RemoteConstants.ENDPOINT_CONNECTTARGET_ID);
- if (connectTarget == null) {
- ID connectedID = rsContainer.getContainer().getConnectedID();
- if (connectedID != null && !connectedID.equals(containerID))
- connectTarget = connectedID.getName();
- }
- if (connectTarget != null)
- endpointDescriptionProperties.put(
- RemoteConstants.ENDPOINT_CONNECTTARGET_ID, connectTarget);
-
- // ENDPOINT_IDFILTER_IDS
- String[] idFilter = (String[]) PropertiesUtil.getPropertyValue(
- serviceReference, overridingProperties,
- RemoteConstants.ENDPOINT_IDFILTER_IDS);
- if (idFilter != null && idFilter.length > 0)
- endpointDescriptionProperties.put(
- RemoteConstants.ENDPOINT_IDFILTER_IDS, idFilter);
-
- // ENDPOINT_REMOTESERVICE_FILTER
- String rsFilter = (String) PropertiesUtil.getPropertyValue(
- serviceReference, overridingProperties,
- RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER);
- if (rsFilter != null)
- endpointDescriptionProperties.put(
- RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER, rsFilter);
-
- return endpointDescriptionProperties;
-
- }
-
- private Map<String, Object> copyNonReservedProperties(
- ServiceReference serviceReference,
- Map<String, Object> overridingProperties, Map<String, Object> target) {
- // copy all other properties...from service reference
- PropertiesUtil.copyNonReservedProperties(serviceReference, target);
- // And override with overridingProperties
- PropertiesUtil.copyNonReservedProperties(overridingProperties, target);
- return target;
- }
-
- private ContainerTypeDescription getContainerTypeDescription(
- IContainer container) {
- IContainerManager containerManager = Activator.getDefault()
- .getContainerManager();
- if (containerManager == null)
- return null;
- return containerManager.getContainerTypeDescription(container.getID());
- }
-
- private String[] getSupportedConfigs(IContainer container) {
- ContainerTypeDescription ctd = getContainerTypeDescription(container);
- return (ctd == null) ? null : ctd.getSupportedConfigs();
- }
-
- private String[] getImportedConfigs(IContainer container,
- String[] exporterSupportedConfigs) {
- ContainerTypeDescription ctd = getContainerTypeDescription(container);
- return (ctd == null) ? null : ctd
- .getImportedConfigs(exporterSupportedConfigs);
- }
-
- private String[] getSupportedIntents(IContainer container) {
- ContainerTypeDescription ctd = getContainerTypeDescription(container);
- return (ctd == null) ? null : ctd.getSupportedIntents();
- }
-
- private ID[] getIDFilter(EndpointDescription endpointDescription,
- ID endpointID) {
- ID[] idFilter = endpointDescription.getIDFilter();
- // If it is null,
- return (idFilter == null) ? new ID[] { endpointID } : idFilter;
- }
-
- private String getRemoteServiceFilter(
- EndpointDescription endpointDescription) {
- long rsId = endpointDescription.getRemoteServiceId();
- if (rsId == 0) {
- // It's not known...so we just return the 'raw' remote service
- // filter
- return endpointDescription.getRemoteServiceFilter();
- } else {
- String edRsFilter = endpointDescription.getRemoteServiceFilter();
- // It's a real remote service id...so we return
- StringBuffer result = new StringBuffer("(&(") //$NON-NLS-1$
- .append(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID)
- .append("=").append(rsId).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
- if (edRsFilter != null)
- result.append(edRsFilter);
- result.append(")"); //$NON-NLS-1$
- return result.toString();
- }
- }
-
- private org.osgi.service.remoteserviceadmin.ImportRegistration handleNonOSGiService(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
- // With non-OSGi service id (service id=0), we log a warning and return
- // null;
- logWarning("handleNonOSGiService", //$NON-NLS-1$
- "OSGi remote service id is 0 for endpointDescription=" //$NON-NLS-1$
- + endpointDescription);
- return null;
- }
-
- private ImportEndpoint createAndRegisterProxy(
- EndpointDescription endpointDescription,
- IRemoteServiceContainer rsContainer,
- IRemoteServiceReference selectedRsReference) throws Exception {
-
- IRemoteServiceContainerAdapter containerAdapter = rsContainer
- .getContainerAdapter();
- ID rsContainerID = rsContainer.getContainer().getID();
- // First get IRemoteService for selectedRsReference
- IRemoteService rs = containerAdapter
- .getRemoteService(selectedRsReference);
- if (rs == null)
- throw new NullPointerException(
- "getRemoteService returned null for selectedRsReference=" //$NON-NLS-1$
- + selectedRsReference + ",rsContainerID=" //$NON-NLS-1$
- + rsContainerID);
-
- Map proxyProperties = createProxyProperties(endpointDescription,
- rsContainer, selectedRsReference, rs);
-
- List<String> interfaces = endpointDescription.getInterfaces();
-
- ServiceRegistration proxyRegistration = getClientBundleContext()
- .registerService(
- (String[]) interfaces.toArray(new String[interfaces
- .size()]),
- createProxyServiceFactory(endpointDescription, rs),
- (Dictionary) PropertiesUtil
- .createDictionaryFromMap(proxyProperties));
-
- return new ImportEndpoint(containerAdapter, selectedRsReference,
- new RemoteServiceListener(), proxyRegistration,
- endpointDescription);
- }
-
- private ServiceFactory createProxyServiceFactory(
- EndpointDescription endpointDescription,
- IRemoteService remoteService) {
- return new ProxyServiceFactory(
- endpointDescription.getInterfaceVersions(), remoteService);
- }
-
- private Collection<Class> loadServiceInterfacesViaBundle(Bundle bundle,
- String[] interfaces) {
- List<Class> result = new ArrayList<Class>();
- for (int i = 0; i < interfaces.length; i++) {
- try {
- result.add(bundle.loadClass(interfaces[i]));
- } catch (ClassNotFoundException e) {
- logError("loadInterfacesViaBundle", "interface=" //$NON-NLS-1$ //$NON-NLS-2$
- + interfaces[i] + " cannot be loaded by clientBundle=" //$NON-NLS-1$
- + bundle.getSymbolicName(), e);
- continue;
- } catch (IllegalStateException e) {
- logError(
- "loadInterfacesViaBundle", //$NON-NLS-1$
- "interface=" //$NON-NLS-1$
- + interfaces[i]
- + " cannot be loaded since clientBundle is in illegal state", //$NON-NLS-1$
- e);
- continue;
- }
- }
- return result;
- }
-
- class ProxyServiceFactory implements ServiceFactory {
- private IRemoteService remoteService;
- private Map<String, Version> interfaceVersions;
-
- public ProxyServiceFactory(Map<String, Version> interfaceVersions,
- IRemoteService remoteService) {
- this.interfaceVersions = interfaceVersions;
- this.remoteService = remoteService;
- }
-
- public Object getService(Bundle bundle, ServiceRegistration registration) {
- return createProxy(bundle, registration.getReference(),
- remoteService, interfaceVersions);
- }
-
- public void ungetService(Bundle bundle,
- ServiceRegistration registration, Object service) {
- ungetProxyClassLoader(bundle);
- this.remoteService = null;
- this.interfaceVersions = null;
- }
- }
-
- private Object createProxy(Bundle requestingBundle,
- ServiceReference serviceReference, IRemoteService remoteService,
- Map<String, Version> interfaceVersions) {
- // Get symbolicName once for possible use below
- String bundleSymbolicName = requestingBundle.getSymbolicName();
- // Get String[] via OBJECTCLASS constant property
- String[] serviceClassnames = (String[]) serviceReference
- .getProperty(org.osgi.framework.Constants.OBJECTCLASS);
- // Load as many of the serviceInterface classes as possible
- Collection<Class> serviceInterfaceClasses = loadServiceInterfacesViaBundle(
- requestingBundle, serviceClassnames);
- // There has to be at least one serviceInterface that the clientBundle
- // can
- // load...otherwise the service can't be accessed
- if (serviceInterfaceClasses.size() < 1)
- throw new RuntimeException(
- "ProxyServiceFactory cannot load any serviceInterfaces=" //$NON-NLS-1$
- + serviceInterfaceClasses
- + " for serviceReference=" + serviceReference //$NON-NLS-1$
- + " via clientBundle=" + bundleSymbolicName); //$NON-NLS-1$
-
- // Now verify that the classes are of valid versions
- verifyServiceInterfaceVersionsForProxy(requestingBundle,
- serviceInterfaceClasses, interfaceVersions);
-
- // Now create/get class loader for proxy. This will typically
- // be an instance of ProxyClassLoader
- ClassLoader cl = getProxyClassLoader(requestingBundle);
- try {
- return remoteService.getProxy(cl, (Class[]) serviceInterfaceClasses
- .toArray(new Class[serviceInterfaceClasses.size()]));
- } catch (ECFException e) {
- throw new ServiceException(
- "ProxyServiceFactory cannot create proxy for clientBundle=" //$NON-NLS-1$
- + bundleSymbolicName + " from serviceReference=" //$NON-NLS-1$
- + serviceReference, e);
- }
-
- }
-
- private Map<Bundle, ProxyClassLoader> proxyClassLoaders = new HashMap<Bundle, ProxyClassLoader>();
-
- private void closeProxyClassLoaderCache() {
- synchronized (proxyClassLoaders) {
- proxyClassLoaders.clear();
- }
- }
-
- private ClassLoader getProxyClassLoader(Bundle bundle) {
- ProxyClassLoader proxyClassLoaderForBundle = null;
- synchronized (proxyClassLoaders) {
- proxyClassLoaderForBundle = proxyClassLoaders.get(bundle);
- if (proxyClassLoaderForBundle == null) {
- proxyClassLoaderForBundle = new ProxyClassLoader(bundle);
- proxyClassLoaders.put(bundle, proxyClassLoaderForBundle);
- } else
- proxyClassLoaderForBundle.addServiceUseCount();
- }
- return proxyClassLoaderForBundle;
- }
-
- private void ungetProxyClassLoader(Bundle bundle) {
- synchronized (proxyClassLoaders) {
- ProxyClassLoader proxyClassLoaderForBundle = proxyClassLoaders
- .get(bundle);
- if (proxyClassLoaderForBundle != null) {
- int useCount = proxyClassLoaderForBundle.getServiceUseCount();
- if (useCount == 0)
- proxyClassLoaders.remove(bundle);
- else
- proxyClassLoaderForBundle.removeServiceUseCount();
- }
- }
- }
-
- protected class ProxyClassLoader extends ClassLoader {
- private Bundle loadingBundle;
- private int serviceUseCount = 0;
-
- public ProxyClassLoader(Bundle loadingBundle) {
- this.loadingBundle = loadingBundle;
- }
-
- public Class loadClass(String name) throws ClassNotFoundException {
- return loadingBundle.loadClass(name);
- }
-
- public int getServiceUseCount() {
- return serviceUseCount;
- }
-
- public void addServiceUseCount() {
- serviceUseCount++;
- }
-
- public void removeServiceUseCount() {
- serviceUseCount--;
- }
- }
-
- private PackageAdmin getPackageAdmin() {
- synchronized (packageAdminTrackerLock) {
- if (packageAdminTracker == null) {
- packageAdminTracker = new ServiceTracker(
- getClientBundleContext(), PackageAdmin.class.getName(),
- null);
- packageAdminTracker.open();
- }
- }
- return (PackageAdmin) packageAdminTracker.getService();
- }
-
- private IPackageVersionComparator getPackageVersionComparator() {
- return packageVersionComparator;
- }
-
- private ExportedPackage getExportedPackageForClass(
- PackageAdmin packageAdmin, Class clazz) {
- String packageName = getPackageName(clazz.getName());
- // Get all exported packages with given package name
- ExportedPackage[] exportedPackagesWithName = packageAdmin
- .getExportedPackages(packageName);
- // If none then we return null
- if (exportedPackagesWithName == null)
- return null;
- // Get the clientBundle for the previously loaded interface class
- Bundle classBundle = packageAdmin.getBundle(clazz);
- if (classBundle == null)
- return null;
- for (int i = 0; i < exportedPackagesWithName.length; i++) {
- Bundle packageBundle = exportedPackagesWithName[i]
- .getExportingBundle();
- if (packageBundle == null)
- continue;
- if (packageBundle.equals(classBundle))
- return exportedPackagesWithName[i];
- }
- return null;
- }
-
- private String getPackageName(String className) {
- int lastDotIndex = className.lastIndexOf("."); //$NON-NLS-1$
- if (lastDotIndex == -1)
- return ""; //$NON-NLS-1$
- return className.substring(0, lastDotIndex);
- }
-
- private void verifyServiceInterfaceVersionsForProxy(Bundle bundle,
- Collection<Class> classes, Map<String, Version> interfaceVersions) {
- IPackageVersionComparator packageVersionComparator = getPackageVersionComparator();
- if (packageVersionComparator == null) {
- logError(
- "verifyServiceInterfaceVersionsForProxy", //$NON-NLS-1$
- "No package version comparator available, skipping package version comparison for service classes=" //$NON-NLS-1$
- + classes);
- return;
- }
- // For all service interface classes
- for (Class clazz : classes) {
- String className = clazz.getName();
- String packageName = getPackageName(className);
- ExportedPackage exportedPackage = getExportedPackageForClass(
- getPackageAdmin(), clazz);
- if (exportedPackage == null)
- throw new NullPointerException(
- "No exported package found for class=" + className); //$NON-NLS-1$
- // Now lookup version from specification
- Version remotePackageVersion = interfaceVersions.get(className);
- if (remotePackageVersion == null)
- throw new NullPointerException("Remote package=" + packageName //$NON-NLS-1$
- + " has no Version"); //$NON-NLS-1$
- Version localPackageVersion = exportedPackage.getVersion();
- if (localPackageVersion == null)
- throw new NullPointerException("Local package=" + packageName //$NON-NLS-1$
- + " has no Version"); //$NON-NLS-1$
-
- // Now do compare via package version comparator service
- packageVersionComparator.comparePackageVersions(packageName,
- remotePackageVersion, localPackageVersion);
- }
- }
-
- private IRemoteServiceReference selectRemoteServiceReference(
- Collection<IRemoteServiceReference> rsRefs, ID targetID,
- ID[] idFilter, Collection<String> interfaces, String rsFilter,
- IRemoteServiceContainer rsContainer) {
- if (rsRefs.size() == 0)
- return null;
- if (rsRefs.size() > 1) {
- logWarning("selectRemoteServiceReference", "rsRefs=" + rsRefs //$NON-NLS-1$ //$NON-NLS-2$
- + ",targetID=" + targetID + ",idFilter=" + idFilter //$NON-NLS-1$ //$NON-NLS-2$
- + ",interfaces=" + interfaces + ",rsFilter=" + rsFilter //$NON-NLS-1$ //$NON-NLS-2$
- + ",rsContainer=" + rsContainer.getContainer().getID() //$NON-NLS-1$
- + " has " + rsRefs.size() //$NON-NLS-1$
- + " values. Selecting the first element"); //$NON-NLS-1$
- }
- return rsRefs.iterator().next();
- }
-
- private Map createProxyProperties(EndpointDescription endpointDescription,
- IRemoteServiceContainer rsContainer,
- IRemoteServiceReference rsReference, IRemoteService remoteService) {
-
- Map resultProperties = new TreeMap<String, Object>(
- String.CASE_INSENSITIVE_ORDER);
- PropertiesUtil.copyNonReservedProperties(rsReference, resultProperties);
- // remove OBJECTCLASS
- resultProperties
- .remove(org.eclipse.ecf.remoteservice.Constants.OBJECTCLASS);
- // remove remote service id
- resultProperties
- .remove(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID);
- // Set intents if there are intents
- Object intentsValue = PropertiesUtil
- .convertToStringPlusValue(endpointDescription.getIntents());
- if (intentsValue != null)
- resultProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS,
- intentsValue);
-
- // Set service.imported to IRemoteService unless
- // SERVICE_IMPORTED_VALUETYPE is
- // set
- String serviceImportedType = (String) endpointDescription
- .getProperties()
- .get(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_VALUETYPE);
- if (serviceImportedType == null
- || serviceImportedType.equals(IRemoteService.class.getName()))
- resultProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED,
- remoteService);
- else
- resultProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED,
- new Boolean(true));
-
- String[] exporterSupportedConfigs = (String[]) endpointDescription
- .getProperties()
- .get(org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED);
- String[] importedConfigs = getImportedConfigs(
- rsContainer.getContainer(), exporterSupportedConfigs);
- // Set service.imported.configs
- resultProperties
- .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,
- importedConfigs);
- return resultProperties;
- }
-
- private ExportEndpoint exportService(ServiceReference serviceReference,
- Map<String, Object> overridingProperties,
- String[] exportedInterfaces, String[] serviceIntents,
- IRemoteServiceContainer rsContainer) {
-
- Map endpointDescriptionProperties = createExportEndpointDescriptionProperties(
- serviceReference, overridingProperties, exportedInterfaces,
- serviceIntents, rsContainer);
-
- // Create remote service properties
- Map remoteServiceProperties = copyNonReservedProperties(
- serviceReference, overridingProperties,
- new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER));
-
- IRemoteServiceContainerAdapter containerAdapter = rsContainer
- .getContainerAdapter();
-
- // Register remote service via ECF container adapter to create
- // remote service registration
- IRemoteServiceRegistration remoteRegistration = null;
- Throwable exception = null;
- try {
- // Check security access for export
- checkEndpointPermission(new EndpointDescription(serviceReference,
- endpointDescriptionProperties), EndpointPermission.EXPORT);
-
- if (containerAdapter instanceof IOSGiRemoteServiceContainerAdapter) {
- IOSGiRemoteServiceContainerAdapter osgiContainerAdapter = (IOSGiRemoteServiceContainerAdapter) containerAdapter;
- remoteRegistration = osgiContainerAdapter
- .registerRemoteService(
- exportedInterfaces,
- serviceReference,
- PropertiesUtil
- .createDictionaryFromMap(remoteServiceProperties));
- } else
- remoteRegistration = containerAdapter
- .registerRemoteService(
- exportedInterfaces,
- getClientBundleContext().getService(
- serviceReference),
- PropertiesUtil
- .createDictionaryFromMap(remoteServiceProperties));
- endpointDescriptionProperties
- .put(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID,
- remoteRegistration
- .getProperty(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID));
- } catch (Exception e) {
- exception = e;
- if (remoteRegistration != null)
- remoteRegistration.unregister();
- }
- EndpointDescription endpointDescription = new EndpointDescription(
- serviceReference, endpointDescriptionProperties);
- // Create ExportEndpoint/ExportRegistration
- return (exception == null) ? new ExportEndpoint(serviceReference,
- endpointDescription, remoteRegistration) : new ExportEndpoint(
- serviceReference, endpointDescription, exception);
- }
-
- private ImportEndpoint importService(
- EndpointDescription endpointDescription,
- IRemoteServiceContainer rsContainer) {
- trace("doImportService", "endpointDescription=" + endpointDescription //$NON-NLS-1$ //$NON-NLS-2$
- + ",rsContainerID=" + rsContainer.getContainer().getID()); //$NON-NLS-1$
- // Get interfaces from endpoint description
- Collection<String> interfaces = endpointDescription.getInterfaces();
- Assert.isNotNull(interfaces);
- Assert.isTrue(interfaces.size() > 0);
- // Get ECF endpoint ID...if this throws IDCreateException (because the
- // local system does not have
- // namespace for creating ID, or no namespace is present in
- // endpointDescription or endpoint id,
- // then it will be caught by the caller
- ID endpointContainerID = endpointDescription.getContainerID();
- Assert.isNotNull(endpointContainerID);
- // Get connect target ID. May be null
- ID targetID = endpointDescription.getConnectTargetID();
- if (targetID == null)
- targetID = endpointContainerID;
- // Get idFilter...also may be null
- ID[] idFilter = getIDFilter(endpointDescription, endpointContainerID);
- // Get remote service filter
- String rsFilter = getRemoteServiceFilter(endpointDescription);
- // IRemoteServiceReferences from query
- Collection<IRemoteServiceReference> rsRefs = new ArrayList<IRemoteServiceReference>();
- // Get IRemoteServiceContainerAdapter
- IRemoteServiceContainerAdapter containerAdapter = rsContainer
- .getContainerAdapter();
- // rsContainerID
- ID rsContainerID = rsContainer.getContainer().getID();
- try {
- // For all given interfaces
- for (String intf : interfaces) {
- // Get/lookup remote service references
- IRemoteServiceReference[] refs = containerAdapter
- .getRemoteServiceReferences(targetID, idFilter, intf,
- rsFilter);
- if (refs == null) {
- logWarning("doImportService", //$NON-NLS-1$
- "getRemoteServiceReferences return null for targetID=" //$NON-NLS-1$
- + targetID + ",idFilter=" + idFilter //$NON-NLS-1$
- + ",intf=" + intf + ",rsFilter=" + rsFilter //$NON-NLS-1$ //$NON-NLS-2$
- + " on rsContainerID=" + rsContainerID); //$NON-NLS-1$
- continue;
- }
- for (int i = 0; i < refs.length; i++)
- rsRefs.add(refs[i]);
- }
- IRemoteServiceReference selectedRsReference = selectRemoteServiceReference(
- rsRefs, targetID, idFilter, interfaces, rsFilter,
- rsContainer);
- // If none found, we obviously can't continue
- if (selectedRsReference == null)
- throw new RemoteReferenceNotFoundException(targetID, idFilter,
- interfaces, rsFilter);
-
- return createAndRegisterProxy(endpointDescription, rsContainer,
- selectedRsReference);
- } catch (Exception e) {
- logError(
- "importService", "selectRemoteServiceReference returned null for rsRefs=" //$NON-NLS-1$
- + rsRefs + ",targetID=" + targetID //$NON-NLS-1$
- + ",idFilter=" + idFilter + ",interfaces=" //$NON-NLS-1$ //$NON-NLS-2$
- + interfaces + ",rsFilter=" + rsFilter //$NON-NLS-1$
- + ",rsContainerID=" + rsContainerID, e);
- return new ImportEndpoint(containerAdapter, endpointDescription, e);
- }
- }
-
- private void closeExportRegistrations() {
- List<ExportRegistration> toClose = null;
- synchronized (exportedRegistrations) {
- toClose = new ArrayList<ExportRegistration>(exportedRegistrations);
- exportedRegistrations.clear();
- }
- for (ExportRegistration reg : toClose)
- reg.close();
- }
-
- private void closeImportRegistrations() {
- List<ImportRegistration> toClose = null;
- synchronized (importedRegistrations) {
- toClose = new ArrayList<ImportRegistration>(importedRegistrations);
- importedRegistrations.clear();
- }
- for (ImportRegistration reg : toClose)
- reg.close();
- }
-
- public void close() {
- trace("close", "closing importedRegistrations=" + importedRegistrations //$NON-NLS-1$ //$NON-NLS-2$
- + " exportedRegistrations=" + exportedRegistrations); //$NON-NLS-1$
- closeRemoteServiceAdminListenerTracker();
- closeEventAdminTracker();
- closePackageAdminTracker();
- closeProxyClassLoaderCache();
- closeConsumerContainerSelectorTracker();
- closeHostContainerSelectorTracker();
- closeDefaultContainerSelectors();
- closeImportRegistrations();
- closeExportRegistrations();
- this.clientBundle = null;
- }
-
- private ImportEndpoint findImportEndpoint(EndpointDescription ed) {
- for (ImportRegistration reg : importedRegistrations) {
- ImportEndpoint endpoint = reg.getImportEndpoint(ed);
- if (endpoint != null)
- return endpoint;
- }
- return null;
- }
-
- private void unimportService(IRemoteServiceID remoteServiceID) {
- List<ImportRegistration> removedRegistrations = new ArrayList<ImportRegistration>();
- synchronized (importedRegistrations) {
- for (Iterator<ImportRegistration> i = importedRegistrations
- .iterator(); i.hasNext();) {
- ImportRegistration importRegistration = i.next();
- if (importRegistration != null
- && importRegistration.match(remoteServiceID))
- removedRegistrations.add(importRegistration);
- }
- }
- // Now close all of them
- for (ImportRegistration removedReg : removedRegistrations) {
- trace("unimportService", "closing importRegistration=" + removedReg); //$NON-NLS-1$ //$NON-NLS-2$
- removedReg.close();
- }
- }
-
- class RemoteServiceListener implements IRemoteServiceListener {
- public void handleServiceEvent(IRemoteServiceEvent event) {
- if (event instanceof IRemoteServiceUnregisteredEvent)
- unimportService(event.getReference().getID());
- }
- }
-
- private void trace(String methodName, String message) {
- LogUtility.trace(methodName, DebugOptions.REMOTE_SERVICE_ADMIN,
- this.getClass(), message);
- }
-
- private void logWarning(String methodName, String message) {
- LogUtility.logWarning(methodName, DebugOptions.REMOTE_SERVICE_ADMIN,
- this.getClass(), message);
- }
-
- private void logError(String methodName, String message, Throwable t) {
- LogUtility.logError(methodName, DebugOptions.REMOTE_SERVICE_ADMIN,
- this.getClass(), message, t);
- }
-
- private void logError(String methodName, String message) {
- logError(methodName, message, (Throwable) null);
- }
-
- public class RemoteServiceAdminEvent extends
- org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent {
-
- private ID containerID;
-
- public RemoteServiceAdminEvent(
- ID containerID,
- int type,
- Bundle source,
- org.osgi.service.remoteserviceadmin.ExportReference exportReference,
- Throwable exception) {
- super(type, source, exportReference, exception);
- this.containerID = containerID;
- }
-
- public RemoteServiceAdminEvent(
- ID containerID,
- int type,
- Bundle source,
- org.osgi.service.remoteserviceadmin.ImportReference importReference,
- Throwable exception) {
- super(type, source, importReference, exception);
- this.containerID = containerID;
- }
-
- public ID getContainerID() {
- return containerID;
- }
-
- public String toString() {
- return "RemoteServiceAdminEvent[containerID=" + containerID //$NON-NLS-1$
- + ", getType()=" + getType() + ", getSource()=" + getSource() //$NON-NLS-1$ //$NON-NLS-2$
- + ", getException()=" + getException() //$NON-NLS-1$
- + ", getImportReference()=" + getImportReference() //$NON-NLS-1$
- + ", getExportReference()=" + getExportReference() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdminEvent.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdminEvent.java
deleted file mode 100644
index 5e3d63c6f..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdminEvent.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import org.eclipse.ecf.core.identity.ID;
-import org.osgi.framework.Bundle;
-import org.osgi.service.remoteserviceadmin.ExportReference;
-import org.osgi.service.remoteserviceadmin.ImportReference;
-
-public class RemoteServiceAdminEvent extends
- org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent {
-
- private ID containerID;
-
- public RemoteServiceAdminEvent(ID containerID, int type, Bundle source,
- ExportReference exportReference, Throwable exception) {
- super(type, source, exportReference, exception);
- this.containerID = containerID;
- }
-
- public RemoteServiceAdminEvent(ID containerID, int type, Bundle source,
- ImportReference importReference, Throwable exception) {
- super(type, source, importReference, exception);
- this.containerID = containerID;
- }
-
- public ID getContainerID() {
- return containerID;
- }
-
- public String toString() {
- return "RemoteServiceAdminEvent[containerID=" + containerID //$NON-NLS-1$
- + ", getType()=" + getType() + ", getSource()=" + getSource() //$NON-NLS-1$ //$NON-NLS-2$
- + ", getException()=" + getException() //$NON-NLS-1$
- + ", getImportReference()=" + getImportReference() //$NON-NLS-1$
- + ", getExportReference()=" + getExportReference() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ServiceInfoFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ServiceInfoFactory.java
deleted file mode 100644
index e3d25f552..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ServiceInfoFactory.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.osgi.services.remoteserviceadmin;
-
-import java.net.InetAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.ecf.core.identity.IDFactory;
-import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.discovery.IDiscoveryAdvertiser;
-import org.eclipse.ecf.discovery.IServiceInfo;
-import org.eclipse.ecf.discovery.IServiceProperties;
-import org.eclipse.ecf.discovery.ServiceInfo;
-import org.eclipse.ecf.discovery.ServiceProperties;
-import org.eclipse.ecf.discovery.identity.IServiceTypeID;
-import org.eclipse.ecf.discovery.identity.ServiceIDFactory;
-import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
-
-public class ServiceInfoFactory extends AbstractMetadataFactory implements
- IServiceInfoFactory {
-
- protected Map<ServiceInfoKey, IServiceInfo> serviceInfos = new HashMap();
-
- protected class ServiceInfoKey {
- private EndpointDescription endpointDescription;
- private Namespace discoveryNamespace;
- private int hashCode = 7;
-
- public ServiceInfoKey(EndpointDescription endpointDescription,
- Namespace discoveryNamespace) {
- this.endpointDescription = endpointDescription;
- this.discoveryNamespace = discoveryNamespace;
- this.hashCode = 31 * this.hashCode + endpointDescription.hashCode();
- this.hashCode = 31 * this.hashCode + discoveryNamespace.hashCode();
- }
-
- public boolean equals(Object other) {
- if (other == null)
- return false;
- if (!(other instanceof ServiceInfoKey))
- return false;
- ServiceInfoKey otherKey = (ServiceInfoKey) other;
- return (this.endpointDescription
- .equals(otherKey.endpointDescription) && this.discoveryNamespace
- .equals(otherKey.discoveryNamespace));
- }
-
- public int hashCode() {
- return hashCode;
- }
- }
-
- public IServiceInfo createServiceInfoForDiscovery(
- IDiscoveryAdvertiser advertiser,
- EndpointDescription endpointDescription) {
- try {
- Namespace advertiserNamespace = advertiser.getServicesNamespace();
- ServiceInfoKey key = new ServiceInfoKey(endpointDescription,
- advertiserNamespace);
- IServiceInfo existingServiceInfo = null;
- synchronized (serviceInfos) {
- existingServiceInfo = serviceInfos.get(key);
- // If it's already there, then we return null
- if (existingServiceInfo != null)
- return null;
- IServiceTypeID serviceTypeID = createServiceTypeID(
- endpointDescription, advertiser);
- String serviceName = createServiceName(endpointDescription,
- advertiser, serviceTypeID);
- URI uri = createURI(endpointDescription, advertiser,
- serviceTypeID, serviceName);
- IServiceProperties serviceProperties = createServiceProperties(
- endpointDescription, advertiser, serviceTypeID,
- serviceName, uri);
- IServiceInfo newServiceInfo = createServiceInfo(uri,
- serviceName, serviceTypeID, serviceProperties);
- // put into map using key
- serviceInfos.put(key, newServiceInfo);
- return newServiceInfo;
- }
- } catch (Exception e) {
- logError(
- "createServiceInfoForDiscovery", //$NON-NLS-1$
- "Exception creating service info for endpointDescription=" //$NON-NLS-1$
- + endpointDescription + ",advertiser=" + advertiser, //$NON-NLS-1$
- e);
- return null;
- }
- }
-
- protected IServiceInfo createServiceInfo(URI uri, String serviceName,
- IServiceTypeID serviceTypeID, IServiceProperties serviceProperties) {
- return new ServiceInfo(uri, serviceName, serviceTypeID,
- serviceProperties);
- }
-
- protected IServiceProperties createServiceProperties(
- EndpointDescription endpointDescription,
- IDiscoveryAdvertiser advertiser, IServiceTypeID serviceTypeID,
- String serviceName, URI uri) {
- ServiceProperties result = new ServiceProperties();
- encodeServiceProperties(endpointDescription, result);
- return result;
- }
-
- protected URI createURI(EndpointDescription endpointDescription,
- IDiscoveryAdvertiser advertiser, IServiceTypeID serviceTypeID,
- String serviceName) throws URISyntaxException {
- String path = "/" + serviceName; //$NON-NLS-1$
- String str = endpointDescription.getId();
- URI uri = null;
- while (true) {
- try {
- uri = new URI(str);
- if (uri.getHost() != null) {
- break;
- } else {
- final String rawSchemeSpecificPart = uri
- .getRawSchemeSpecificPart();
- // make sure we break eventually
- if (str.equals(rawSchemeSpecificPart)) {
- uri = null;
- break;
- } else {
- str = rawSchemeSpecificPart;
- }
- }
- } catch (URISyntaxException e) {
- uri = null;
- break;
- }
- }
- String scheme = RemoteConstants.SERVICE_TYPE;
- int port = 32565;
- if (uri != null) {
- port = uri.getPort();
- if (port == -1)
- port = 32565;
- }
- String host = null;
- if (uri != null) {
- host = uri.getHost();
- } else {
- try {
- host = InetAddress.getLocalHost().getHostAddress();
- } catch (Exception e) {
- logWarning(
- "createURI", //$NON-NLS-1$
- "failed to get local host adress, falling back to \'localhost\'.", e); //$NON-NLS-1$
- host = "localhost"; //$NON-NLS-1$
- }
- }
- return new URI(scheme, null, host, port, path, null, null);
- }
-
- protected String createServiceName(EndpointDescription endpointDescription,
- IDiscoveryAdvertiser advertiser, IServiceTypeID serviceTypeID) {
- // First create unique default name
- String defaultServiceName = createDefaultServiceName(
- endpointDescription, advertiser, serviceTypeID);
- // Look for service name that was explicitly set
- String serviceName = PropertiesUtil.getStringWithDefault(
- endpointDescription.getProperties(),
- RemoteConstants.DISCOVERY_SERVICE_NAME, defaultServiceName);
- return serviceName;
- }
-
- protected String createDefaultServiceName(
- EndpointDescription endpointDescription,
- IDiscoveryAdvertiser advertiser, IServiceTypeID serviceTypeID) {
- return RemoteConstants.DISCOVERY_DEFAULT_SERVICE_NAME_PREFIX
- + IDFactory.getDefault().createGUID().getName();
- }
-
- protected IServiceTypeID createServiceTypeID(
- EndpointDescription endpointDescription,
- IDiscoveryAdvertiser advertiser) {
- Map props = endpointDescription.getProperties();
- String[] scopes = PropertiesUtil.getStringArrayWithDefault(props,
- RemoteConstants.DISCOVERY_SCOPE, IServiceTypeID.DEFAULT_SCOPE);
- String[] protocols = PropertiesUtil.getStringArrayWithDefault(props,
- RemoteConstants.DISCOVERY_PROTOCOLS,
- IServiceTypeID.DEFAULT_SCOPE);
- String namingAuthority = PropertiesUtil.getStringWithDefault(props,
- RemoteConstants.DISCOVERY_NAMING_AUTHORITY,
- IServiceTypeID.DEFAULT_NA);
- return ServiceIDFactory.getDefault().createServiceTypeID(
- advertiser.getServicesNamespace(),
- new String[] { RemoteConstants.SERVICE_TYPE }, scopes,
- protocols, namingAuthority);
- }
-
- public IServiceInfo removeServiceInfoForUndiscovery(
- IDiscoveryAdvertiser advertiser,
- EndpointDescription endpointDescription) {
- Namespace advertiserNamespace = advertiser.getServicesNamespace();
- ServiceInfoKey key = new ServiceInfoKey(endpointDescription,
- advertiserNamespace);
- synchronized (serviceInfos) {
- return serviceInfos.remove(key);
- }
- }
-
- public void close() {
- removeAllServiceInfos();
- super.close();
- }
-
- public boolean removeServiceInfo(IDiscoveryAdvertiser advertiser,
- EndpointDescription endpointDescription) {
- return removeServiceInfoForUndiscovery(advertiser, endpointDescription) != null;
- }
-
- public void removeAllServiceInfos() {
- synchronized (serviceInfos) {
- serviceInfos.clear();
- }
- }
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.classpath b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.classpath
deleted file mode 100644
index 8a8f1668c..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.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/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.gitignore b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.gitignore
deleted file mode 100644
index e660fd93d..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin/
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.project b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.project
deleted file mode 100644
index 5fce69511..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.ecf.tests.osgi.services.remoteserviceadmin</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/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.jdt.core.prefs b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 75b5ac7b9..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,73 +0,0 @@
-#Fri Dec 03 17:02:32 PST 2010
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-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=error
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-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.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-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.suppressOptionalErrors=disabled
-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.unusedObjectAllocation=ignore
-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.6
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.core.prefs b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644
index 75b58abe5..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-#Tue Oct 26 17:03:06 PDT 2010
-eclipse.preferences.version=1
-pluginProject.extensions=false
-resolve.requirebundle=false
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.prefs b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.prefs
deleted file mode 100644
index 4455dc93e..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/.settings/org.eclipse.pde.prefs
+++ /dev/null
@@ -1,33 +0,0 @@
-#Fri Dec 03 17:02:03 PST 2010
-compilers.f.unresolved-features=1
-compilers.f.unresolved-plugins=1
-compilers.incompatible-environment=2
-compilers.p.build=1
-compilers.p.build.bin.includes=1
-compilers.p.build.encodings=2
-compilers.p.build.java.compiler=2
-compilers.p.build.java.compliance=1
-compilers.p.build.missing.output=2
-compilers.p.build.output.library=1
-compilers.p.build.source.library=1
-compilers.p.build.src.includes=1
-compilers.p.deprecated=1
-compilers.p.discouraged-class=2
-compilers.p.internal=1
-compilers.p.missing-packages=2
-compilers.p.missing-version-export-package=2
-compilers.p.missing-version-import-package=2
-compilers.p.missing-version-require-bundle=2
-compilers.p.no-required-att=0
-compilers.p.not-externalized-att=2
-compilers.p.unknown-attribute=1
-compilers.p.unknown-class=1
-compilers.p.unknown-element=1
-compilers.p.unknown-identifier=1
-compilers.p.unknown-resource=1
-compilers.p.unresolved-ex-points=0
-compilers.p.unresolved-import=0
-compilers.s.create-docs=false
-compilers.s.doc-folder=doc
-compilers.s.open-tags=1
-eclipse.preferences.version=1
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF
deleted file mode 100644
index 53aec2392..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,27 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %bundle.name
-Bundle-SymbolicName: org.eclipse.ecf.tests.osgi.services.remoteserviceadmin
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.eclipse.ecf.tests.osgi.services.remoteserviceadmin.Activator
-Bundle-Vendor: %bundle.provider
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ActivationPolicy: lazy
-Bundle-Localization: bundle
-Import-Package: org.eclipse.ecf.core,
- org.eclipse.ecf.core.identity;version="3.2.0",
- org.eclipse.ecf.core.util,
- org.eclipse.ecf.discovery;version="4.0.0",
- org.eclipse.ecf.discovery.identity;version="3.0.0",
- org.eclipse.ecf.osgi.services.remoteserviceadmin,
- org.eclipse.ecf.remoteservice,
- org.eclipse.ecf.remoteservice.events,
- org.eclipse.ecf.tests.remoteservice,
- org.eclipse.equinox.concurrent.future;version="1.0.0",
- org.osgi.framework;version="1.3.0",
- org.osgi.service.remoteserviceadmin;version="1.0.0",
- org.osgi.util.tracker
-Require-Bundle: org.eclipse.equinox.common;bundle-version="3.6.0",
- org.junit;bundle-version="4.8.1",
- org.eclipse.ecf.tests;bundle-version="2.1.0"
-Export-Package: org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;version="1.1.1"
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/about.html b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/about.html
deleted file mode 100644
index 4c79781a5..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/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 (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). 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, &quot;Program&quot; 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 (&quot;Redistributor&quot;) 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/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/build.properties b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/build.properties
deleted file mode 100644
index 0cf66274b..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/build.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- about.html,\
- bundle.properties
-src.includes = about.html,\
- bundle.properties
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/bundle.properties b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/bundle.properties
deleted file mode 100644
index 8675daf70..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/bundle.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-############################################################################
-# Copyright (c) 2010 Composent Inc. 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
-#
-############################################################################
-bundle.name=ECF Remote Service Admin Tests
-bundle.provider=Eclipse.org - ECF
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/ecf-remote-service-extra.xml b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/ecf-remote-service-extra.xml
deleted file mode 100644
index 4fcf05784..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/ecf-remote-service-extra.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0">
-<endpoint-description>
- <property name="objectClass" value="com.acme.Foo"/>
- <property name="endpoint.id" value="ecftcp://localhost:3282/server2"/>
- <property name="endpoint.service.id" value="2"/>
- <property name="endpoint.framework.uuid" value="abcd-1234-7654-fedc"/>
- <property name="service.imported.configs" value="ecf.generic.server"/>
- <property name="ecf.endpoint.remoteservice.id" value="200"/>
- <property name="endpoint.package.version.com.acme" value="4.2"/>
- <property name="com.acme.ws.xml">
- <xml>
- <config xmlns="http://acme.com/defs">
- <port>1029</port>
- <host>www.acme.com</host>
- </config>
- </xml>
- </property>
- <property name="service.intents">
- <list>
- <value>SOAP</value>
- <value>HTTP</value>
- </list>
- </property>
-</endpoint-description>
-</endpoint-descriptions>
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/ecf-remote-service-minimal.xml b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/ecf-remote-service-minimal.xml
deleted file mode 100644
index 11e2da17a..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/ecf-remote-service-minimal.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0">
-<endpoint-description>
- <property name="objectClass" value="com.acme.Foo"/>
- <property name="endpoint.id" value="ecftcp://localhost:3282/server"/>
- <property name="endpoint.service.id" value="1"/>
- <property name="endpoint.framework.uuid" value="abcd-1234-7654-fedc"/>
- <property name="service.imported.configs" value="ecf.generic.server"/>
- <property name="ecf.endpoint.remoteservice.id" value="100"/>
-</endpoint-description>
-</endpoint-descriptions>
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/osgi-remote-service-extra.xml b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/osgi-remote-service-extra.xml
deleted file mode 100644
index 906116807..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/osgi-remote-service-extra.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0">
-<endpoint-description>
- <property name="objectClass" value="com.acme.Foo"/>
- <property name="endpoint.id" value="http://ws.acme.com:9000/hello2"/>
- <property name="endpoint.service.id" value="2"/>
- <property name="endpoint.framework.uuid" value="abcd-1234-7654-fedc"/>
- <property name="service.imported.configs" value="com.acme"/>
- <property name="endpoint.package.version.com.acme" value="4.2"/>
- <property name="com.acme.ws.xml">
- <xml>
- <config xmlns="http://acme.com/defs">
- <port>1029</port>
- <host>www.acme.com</host>
- </config>
- </xml>
- </property>
- <property name="service.intents">
- <list>
- <value>SOAP</value>
- <value>HTTP</value>
- </list>
- </property>
-</endpoint-description>
-</endpoint-descriptions>
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/osgi-remote-service-minimal.xml b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/osgi-remote-service-minimal.xml
deleted file mode 100644
index 54741f46a..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/rsvcs/osgi-remote-service-minimal.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0">
-<endpoint-description>
- <property name="objectClass" value="com.acme.Foo"/>
- <property name="endpoint.id" value="http://ws.acme.com:9000/hello"/>
- <property name="endpoint.service.id" value="1"/>
- <property name="endpoint.framework.uuid" value="abcd-1234-7654-fedc"/>
- <property name="service.imported.configs" value="com.acme"/>
-</endpoint-description>
-</endpoint-descriptions>
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractDistributionTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractDistributionTest.java
deleted file mode 100644
index 64d5247cc..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractDistributionTest.java
+++ /dev/null
@@ -1,246 +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.tests.osgi.services.remoteserviceadmin;
-
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Properties;
-
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.util.Trace;
-import org.eclipse.ecf.remoteservice.IRemoteService;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
-import org.eclipse.ecf.remoteservice.IRemoteServiceListener;
-import org.eclipse.ecf.remoteservice.IRemoteServiceProxy;
-import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
-import org.eclipse.ecf.remoteservice.IRemoteServiceRegistration;
-import org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent;
-import org.eclipse.ecf.tests.ContainerAbstractTestCase;
-import org.eclipse.ecf.tests.remoteservice.IConcatService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public abstract class AbstractDistributionTest extends
- ContainerAbstractTestCase {
-
- protected IRemoteServiceContainerAdapter[] adapters = null;
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ecf.tests.ContainerAbstractTestCase#getClientContainerName()
- */
- protected abstract String getClientContainerName();
-
- protected void tearDown() throws Exception {
- super.tearDown();
- if (adapters != null) {
- for (int i = 0; i < adapters.length; i++) {
- adapters[i] = null;
- }
- adapters = null;
- }
- }
-
- protected void setClientCount(int count) {
- super.setClientCount(count);
- adapters = new IRemoteServiceContainerAdapter[count];
- }
-
- protected void setupRemoteServiceAdapters() throws Exception {
- final int clientCount = getClientCount();
- for (int i = 0; i < clientCount; i++) {
- adapters[i] = (IRemoteServiceContainerAdapter) getClients()[i]
- .getAdapter(IRemoteServiceContainerAdapter.class);
- }
- }
-
- protected BundleContext getContext() {
- return Activator.getDefault().getContext();
- }
-
- protected IRemoteServiceContainerAdapter[] getRemoteServiceAdapters() {
- return adapters;
- }
-
- protected IRemoteServiceListener createRemoteServiceListener(
- final boolean server) {
- return new IRemoteServiceListener() {
- public void handleServiceEvent(IRemoteServiceEvent event) {
- System.out.println((server ? "server" : "client")
- + "handleServiceEvent(" + event + ")");
- }
- };
- }
-
- protected void addRemoteServiceListeners() {
- for (int i = 0; i < adapters.length; i++) {
- adapters[i]
- .addRemoteServiceListener(createRemoteServiceListener(i == 0));
- }
- }
-
- protected IRemoteServiceRegistration registerRemoteService(
- IRemoteServiceContainerAdapter adapter, String serviceInterface,
- Object service, Dictionary serviceProperties, int sleepTime) {
- final IRemoteServiceRegistration result = adapter
- .registerRemoteService(new String[] { serviceInterface },
- service, serviceProperties);
- sleep(sleepTime);
- return result;
- }
-
- protected IRemoteServiceReference[] getRemoteServiceReferences(
- IRemoteServiceContainerAdapter adapter, String clazz, String filter) {
- try {
- return adapter.getRemoteServiceReferences((ID[]) null, clazz,
- filter);
- } catch (final InvalidSyntaxException e) {
- fail("should not happen");
- }
- return null;
- }
-
- protected IRemoteService getRemoteService(
- IRemoteServiceContainerAdapter adapter, String clazz, String filter) {
- final IRemoteServiceReference[] refs = getRemoteServiceReferences(
- adapter, clazz, filter);
- if (refs == null || refs.length == 0)
- return null;
- return adapter.getRemoteService(refs[0]);
- }
-
- protected String getFilterFromServiceProperties(Dictionary serviceProperties) {
- StringBuffer filter = null;
- if (serviceProperties != null && serviceProperties.size() > 0) {
- filter = new StringBuffer("(&");
- for (final Enumeration e = serviceProperties.keys(); e
- .hasMoreElements();) {
- final Object key = e.nextElement();
- final Object val = serviceProperties.get(key);
- if (key != null && val != null) {
- filter.append("(").append(key).append("=").append(val)
- .append(")");
- }
- }
- filter.append(")");
- }
- return (filter == null) ? null : filter.toString();
- }
-
- protected String[] getDefaultServiceClasses() {
- return new String[] { IConcatService.class.getName() };
- }
-
- protected Object getDefaultService() {
- return new IConcatService() {
- public String concat(String string1, String string2) {
- final String result = string1.concat(string2);
- System.out.println("SERVICE.concat(" + string1 + "," + string2
- + ") returning " + result);
- return string1.concat(string2);
- }
- };
- }
-
- protected ServiceRegistration registerService(String[] clazzes,
- Object service, Properties props) throws Exception {
- return getContext().registerService(clazzes, service, (Dictionary) props);
- }
-
- protected ServiceRegistration registerService(String clazz, Object service,
- Properties props) throws Exception {
- return registerService(new String[] { clazz }, service, props);
- }
-
- protected ServiceRegistration registerDefaultService(Properties props)
- throws Exception {
- return registerService(getDefaultServiceClasses(), getDefaultService(),
- props);
- }
-
- public ServiceReference getReference() {
- return null;
- }
-
- protected void assertReferenceHasCorrectType(ServiceReference sr,
- String classname) {
- String[] classes = (String[]) sr
- .getProperty(org.osgi.framework.Constants.OBJECTCLASS);
- assertTrue(classes != null);
- // Check object class
- assertTrue(Arrays.asList(classes).contains(classname));
- }
-
- protected void assertReferencesValidAndFirstHasCorrectType(
- ServiceReference[] references, String classname) {
- assertReferencesValid(references);
- assertReferenceHasCorrectType(references[0], classname);
- }
-
- protected void assertReferencesValid(ServiceReference[] references) {
- assertTrue(references != null);
- assertTrue(references.length > 0);
- }
-
- protected void assertStringResultValid(Object result, String compare) {
- assertNotNull(result);
- assertTrue(result instanceof String);
- assertTrue(compare.equals(result));
- }
-
- protected void assertProxyValid(Object proxy) {
- assertNotNull(proxy);
- assertTrue(proxy instanceof TestServiceInterface1);
- }
-
- protected ServiceTracker createProxyServiceTracker(String clazz)
- throws InvalidSyntaxException {
- ServiceTracker st = new ServiceTracker(getContext(), getContext()
- .createFilter(
- "(&(" + org.osgi.framework.Constants.OBJECTCLASS + "="
- + clazz + ")(" + org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED + "=*))"),
- new ServiceTrackerCustomizer() {
-
- public Object addingService(ServiceReference reference) {
- Trace.trace(Activator.PLUGIN_ID, "addingService="
- + reference);
- return getContext().getService(reference);
- }
-
- public void modifiedService(ServiceReference reference,
- Object service) {
- Trace.trace(Activator.PLUGIN_ID, "modifiedService="
- + reference);
- }
-
- public void removedService(ServiceReference reference,
- Object service) {
- Trace.trace(Activator.PLUGIN_ID, "removedService="
- + reference + ",svc=" + service);
- }
- });
- st.open(true);
- return st;
- }
-
- protected IRemoteService getRemoteServiceFromProxy(Object proxy) {
- assertTrue(proxy instanceof IRemoteServiceProxy);
- return ((IRemoteServiceProxy) proxy).getRemoteService();
- }
-
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionWriterTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionWriterTest.java
deleted file mode 100644
index 8c6c3ec2e..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractEndpointDescriptionWriterTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionWriter;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.IEndpointDescriptionAdvertiser;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public abstract class AbstractEndpointDescriptionWriterTest extends
- AbstractDistributionTest {
-
- protected static final int REGISTER_WAIT = 2000;
- private ServiceRegistration registration;
-
- private ServiceRegistration writerEndpointDescriptionAdvertiser;
- private EndpointDescriptionWriter writer;
-
- protected void setUp() throws Exception {
- super.setUp();
- writer = new EndpointDescriptionWriter();
- writerEndpointDescriptionAdvertiser = getContext().registerService(IEndpointDescriptionAdvertiser.class.getName(), createStandardOutputWriterServiceInfoFactory(), null);
- }
-
- private IEndpointDescriptionAdvertiser createStandardOutputWriterServiceInfoFactory() {
- return new IEndpointDescriptionAdvertiser() {
-
- @Override
- public IStatus advertise(EndpointDescription endpointDescription) {
- // TODO Auto-generated method stub
- try {
- StringWriter sr = new StringWriter();
- sr.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>").append("\n");
- writer.writeEndpointDescriptions(sr, new EndpointDescription[] { (EndpointDescription) endpointDescription });
- System.out.print(sr.toString());
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return Status.OK_STATUS;
- }
-
- @Override
- public IStatus unadvertise(EndpointDescription endpointDescription) {
- // TODO Auto-generated method stub
- return Status.OK_STATUS;
- }
- };
- }
-
- protected void tearDown() throws Exception {
- if (registration != null) {
- registration.unregister();
- registration = null;
- }
- if (writerEndpointDescriptionAdvertiser != null) {
- writerEndpointDescriptionAdvertiser.unregister();
- writerEndpointDescriptionAdvertiser = null;
- }
- super.tearDown();
- }
-
- public void testRegisterOnCreatedServer() throws Exception {
- Properties props = getServiceProperties();
- // Actually register with default service (IConcatService)
- registration = registerDefaultService(props);
- // Wait a while
- Thread.sleep(REGISTER_WAIT);
- }
-
- protected abstract String getServerContainerTypeName();
-
- private Properties getServiceProperties() {
- Properties props = new Properties();
- // Set config to the server container name/provider config name (e.g.
- // ecf.generic.server)
- props.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS,
- getServerContainerTypeName());
- // Set the service exported interfaces to all
- props.put(RemoteConstants.SERVICE_EXPORTED_INTERFACES, "*");
- return props;
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java
deleted file mode 100644
index 727ad91f4..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.discovery.IDiscoveryAdvertiser;
-import org.eclipse.ecf.discovery.IDiscoveryLocator;
-import org.eclipse.ecf.discovery.IServiceInfo;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.DiscoveredEndpointDescription;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.IDiscoveredEndpointDescriptionFactory;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.IServiceInfoFactory;
-import org.eclipse.ecf.tests.ECFAbstractTestCase;
-import org.osgi.framework.Constants;
-import org.osgi.util.tracker.ServiceTracker;
-
-public abstract class AbstractMetadataFactoryTest extends ECFAbstractTestCase {
-
- protected static final String DEFAULT_SERVICE_INTF_PACKAGE = "com.foo";
- protected static final String DEFAULT_SERVICE_INTF_VERSION = "3.0.0";
- protected static final String DEFAULT_SERVICE_INTF = DEFAULT_SERVICE_INTF_PACKAGE + "." + "Foo";
-
- protected static final String DEFAULT_ENDPOINT_ID = "ecftcp://localhost:3282/server";
- protected static final String DEFAULT_SERVICE_IMPORTED_CONFIG = "ecf.generic.server";
- protected static final String DEFAULT_SERVICE_INTENT1 = "test.intent.1";
- protected static final String DEFAULT_SERVICE_INTENT2 = "test.intent.2";
- protected static final String DEFAULT_ECF_TARGET_ID = "ecftcp://localhost:3333/server";
- protected static final String DEFAULT_RSFILTER = "(&(key1=foo)(key2=foo2))";
- protected static final String EXTRA_PROPERTY1 = "test.extra.prop.value.1";
- protected static final String EXTRA_PROPERTY2 = "test.extra.prop.value.2";
-
- protected IServiceInfoFactory serviceInfoFactory;
- protected IDiscoveredEndpointDescriptionFactory endpointDescriptionFactory;
-
- protected IDiscoveryAdvertiser discoveryAdvertiser;
- protected IDiscoveryLocator discoveryLocator;
-
- protected IDiscoveryLocator getDiscoveryLocator() {
- ServiceTracker serviceTracker = new ServiceTracker(Activator.getDefault().getContext(),IDiscoveryLocator.class.getName(), null);
- serviceTracker.open(true);
- IDiscoveryLocator result = (IDiscoveryLocator) serviceTracker.getService();
- serviceTracker.close();
- return result;
- }
-
- protected IDiscoveryAdvertiser getDiscoveryAdvertiser() {
- ServiceTracker serviceTracker = new ServiceTracker(Activator.getDefault().getContext(),IDiscoveryAdvertiser.class.getName(), null);
- serviceTracker.open(true);
- IDiscoveryAdvertiser result = (IDiscoveryAdvertiser) serviceTracker.getService();
- serviceTracker.close();
- return result;
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- serviceInfoFactory = null;
- endpointDescriptionFactory = null;
- discoveryAdvertiser = null;
- discoveryLocator = null;
- super.tearDown();
- }
-
- protected Object createOSGiObjectClass() {
- return new String[] { DEFAULT_SERVICE_INTF };
- }
-
- protected String createOSGiEndpointFrameworkUUID() {
- return UUID.randomUUID().toString();
- }
-
- protected String createOSGiEndpointId() {
- return DEFAULT_ENDPOINT_ID;
- }
-
- protected Long createOSGiEndpointServiceId() {
- return new Long(1);
- }
-
- protected EndpointDescription createRequiredEndpointDescription() {
- Map<String,Object> props = new HashMap<String,Object>();
- // Add required OSGi properties
- addRequiredOSGiProperties(props);
- createECFRemoteServiceId(props);
- // Add extra properties
- addExtraProperties(props);
- return new EndpointDescription(props);
- }
-
- protected EndpointDescription createFullEndpointDescription() {
- Map<String,Object> props = new HashMap<String,Object>();
- // Add required OSGi properties
- addRequiredOSGiProperties(props);
- // Add full OSGi properties
- addOptionalOSGiProperties(props);
- // required ECF properties
- // Add extra properties
- addExtraProperties(props);
- return new EndpointDescription(props);
- }
-
- protected void addExtraProperties(Map<String, Object> props) {
- props.put(EXTRA_PROPERTY1, "com.foo.bar.propertyvalue1");
- props.put(EXTRA_PROPERTY2, "com.foo.bar.propertyvalue2");
- }
-
- protected EndpointDescription createBadOSGiEndpointDescrption() throws Exception {
- Map<String,Object> props = new HashMap<String,Object>();
- // Add only ECF properties
- // no OSGi properties
- createECFRemoteServiceId(props);
- // This should throw a runtime exception
- return new EndpointDescription(props);
- }
-
- protected EndpointDescription createBadECFEndpointDescrption() throws Exception {
- Map<String,Object> props = new HashMap<String,Object>();
- // Add required OSGi properties
- addRequiredOSGiProperties(props);
- // Add full OSGi properties
- addOptionalOSGiProperties(props);
-
- // No ECF required properties
- // This should throw a runtime exception
- return new EndpointDescription(props);
- }
-
- protected String createOSGiServiceImportedConfig() {
- return DEFAULT_SERVICE_IMPORTED_CONFIG;
- }
-
- protected ID createECFContainerID(Map<String,Object> props) {
- return getIDFactory().createStringID(DEFAULT_ENDPOINT_ID);
- }
-
- protected ID createECFTargetID(Map<String,Object> props) {
- return getIDFactory().createStringID(DEFAULT_ECF_TARGET_ID);
- }
-
- protected void createECFRemoteServiceId(Map<String,Object> props) {
- props.put(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID, new Long(101));
- }
-
- protected void addRequiredOSGiProperties(Map<String,Object> props) {
- // OBJECTCLASS
- props.put(Constants.OBJECTCLASS,createOSGiObjectClass());
- // endpoint.service.id
- props.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID, createOSGiEndpointServiceId());
- // endpoint.framework.id
- props.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID, createOSGiEndpointFrameworkUUID());
- // endpoint.id
- props.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID, createOSGiEndpointId());
- // service imported configs
- props.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,createOSGiServiceImportedConfig());
- }
-
- protected void addOptionalOSGiProperties(Map<String,Object> props) {
- props.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS, createOSGiServiceIntents());
- props.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_PACKAGE_VERSION_+DEFAULT_SERVICE_INTF_PACKAGE,DEFAULT_SERVICE_INTF_VERSION);
- }
-
-
- protected Object createOSGiServiceIntents() {
- return new String[] { DEFAULT_SERVICE_INTENT1, DEFAULT_SERVICE_INTENT2 };
- }
-
- protected String createECFRSFilter(Map<String, Object> props) {
- return DEFAULT_RSFILTER;
- }
-
- protected ID[] createECFIDFilterIDs(Map<String, Object> props) {
- return new ID[] { getIDFactory().createGUID(), getIDFactory().createGUID() };
- }
-
- protected IServiceInfo createServiceInfoForDiscovery(EndpointDescription endpointDescription) {
- return serviceInfoFactory.createServiceInfoForDiscovery(discoveryAdvertiser, endpointDescription);
- }
-
- protected org.osgi.service.remoteserviceadmin.EndpointDescription createEndpointDescriptionFromDiscovery(
- IServiceInfo discoveredServiceInfo) {
- DiscoveredEndpointDescription ded = endpointDescriptionFactory.createDiscoveredEndpointDescription(discoveryLocator, discoveredServiceInfo);
- assertNotNull(ded);
- return ded.getEndpointDescription();
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceAccessTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceAccessTest.java
deleted file mode 100644
index b4815dd81..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceAccessTest.java
+++ /dev/null
@@ -1,249 +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.tests.osgi.services.remoteserviceadmin;
-
-import java.util.Properties;
-
-import org.eclipse.ecf.core.util.Trace;
-import org.eclipse.ecf.remoteservice.IRemoteCall;
-import org.eclipse.ecf.remoteservice.IRemoteCallListener;
-import org.eclipse.ecf.remoteservice.IRemoteService;
-import org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent;
-import org.eclipse.ecf.remoteservice.events.IRemoteCallEvent;
-import org.eclipse.equinox.concurrent.future.IFuture;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.osgi.util.tracker.ServiceTracker;
-
-public abstract class AbstractRemoteServiceAccessTest extends
- AbstractDistributionTest {
-
- protected static final int REGISTER_WAIT = Integer.parseInt(System.getProperty("waittime","15000"));
-
- private final String classname = TestServiceInterface1.class.getName();
- private ServiceTracker st;
- private ServiceRegistration registration;
-
- /* (non-Javadoc)
- * @see org.eclipse.ecf.tests.osgi.services.distribution.AbstractDistributionTest#tearDown()
- */
- protected void tearDown() throws Exception {
- // Unregister on server
- if (registration != null) {
- registration.unregister();
- registration = null;
- }
- if (st != null) {
- st.close();
- st = null;
- }
- Thread.sleep(REGISTER_WAIT);
- super.tearDown();
- }
-
- protected void createServiceTrackerAndRegister(final Properties props) throws Exception {
- // Setup service tracker for client
- st = createProxyServiceTracker(classname);
-
- // Actually register
- registration = registerService(classname,
- new TestService1(), props);
-
- // Wait
- Thread.sleep(REGISTER_WAIT);
- }
-
- protected void createServiceTrackerAndRegister() throws Exception {
- createServiceTrackerAndRegister(getServiceProperties());
- }
-
- protected Properties getServiceProperties() {
- final Properties props = new Properties();
- props.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, getServerContainerName());
- props.put(RemoteConstants.SERVICE_EXPORTED_INTERFACES, "*");
- return props;
- }
-
- protected IRemoteCall createRemoteCall() {
- return new IRemoteCall() {
-
- public String getMethod() {
- return "doStuff1";
- }
-
- public Object[] getParameters() {
- return new Object[] {};
- }
-
- public long getTimeout() {
- return 30000;
- }
-
- };
- }
-
-
- public void testGetRemoteServiceReference() throws Exception {
- createServiceTrackerAndRegister();
-
- // Service Consumer - Get (remote) ervice references
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
- // Spec requires that the 'service.imported' property be set
- assertTrue(remoteReferences[0].getProperty(RemoteConstants.SERVICE_IMPORTED) != null);
- }
-
- public void testGetRemoteServiceReferenceWithExtraProperties() throws Exception {
- final String TESTPROP1_VALUE = "baz";
- final String TESTPROP_VALUE = "foobar";
- final String TESTPROP1_NAME = "org.eclipse.ecf.testprop1";
- final String TESTPROP_NAME = "org.eclipse.ecf.testprop";
-
- final Properties props = getServiceProperties();
- // Add other properties
- props.put(TESTPROP_NAME, TESTPROP_VALUE);
- props.put(TESTPROP1_NAME,TESTPROP1_VALUE);
- createServiceTrackerAndRegister(props);
-
- // Service Consumer - Get (remote) ervice references
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
- // Spec requires that the 'service.imported' property be set
- assertTrue(remoteReferences[0].getProperty(RemoteConstants.SERVICE_IMPORTED) != null);
-
- final String testProp = (String) remoteReferences[0].getProperty(TESTPROP_NAME);
- final String testProp1 = (String) remoteReferences[0].getProperty(TESTPROP1_NAME);
- assertTrue(TESTPROP_VALUE.equals(testProp));
- assertTrue(TESTPROP1_VALUE.equals(testProp1));
- }
-
-
- public void testProxy() throws Exception {
- createServiceTrackerAndRegister();
-
- // Client - Get service references from service tracker
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
-
- // Get proxy/service
- final TestServiceInterface1 proxy = (TestServiceInterface1) getContext()
- .getService(remoteReferences[0]);
- assertNotNull(proxy);
- // Now use proxy
- final String result = proxy.doStuff1();
- Trace.trace(Activator.PLUGIN_ID, "proxy.doStuff1 result=" + result);
- assertTrue(TestServiceInterface1.TEST_SERVICE_STRING1.equals(result));
- }
-
- public void testCallSyncFromProxy() throws Exception {
- createServiceTrackerAndRegister();
-
- // Client - Get service references from service tracker
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
-
- // Get proxy
- final TestServiceInterface1 proxy = (TestServiceInterface1) getContext()
- .getService(remoteReferences[0]);
-
- assertProxyValid(proxy);
-
- // Get IRemoteService from proxy
- final IRemoteService remoteService = getRemoteServiceFromProxy(proxy);
-
- // Call remote service synchronously
- final Object result = remoteService.callSync(createRemoteCall());
- Trace.trace(Activator.PLUGIN_ID, "proxy.doStuff1 result=" + result);
- assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
- }
-
- public void testCallSync() throws Exception {
- createServiceTrackerAndRegister();
-
- // Client - Get service references from service tracker
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValidAndFirstHasCorrectType(remoteReferences, classname);
-
- final Object o = remoteReferences[0].getProperty(RemoteConstants.SERVICE_IMPORTED);
- assertNotNull(o);
- assertTrue(o instanceof IRemoteService);
- final IRemoteService rs = (IRemoteService) o;
-
- // Call synchronously
- final Object result = rs.callSync(createRemoteCall());
- Trace.trace(Activator.PLUGIN_ID, "callSync.doStuff1 result=" + result);
- assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
- }
-
- public void testCallAsync() throws Exception {
- createServiceTrackerAndRegister();
-
- // Client - Get service references from service tracker
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValid(remoteReferences);
-
- final Object o = remoteReferences[0].getProperty(RemoteConstants.SERVICE_IMPORTED);
- assertNotNull(o);
- assertTrue(o instanceof IRemoteService);
- final IRemoteService rs = (IRemoteService) o;
- // Call asynchronously
- rs.callAsync(createRemoteCall(), new IRemoteCallListener() {
- public void handleEvent(final IRemoteCallEvent event) {
- if (event instanceof IRemoteCallCompleteEvent) {
- final Object result = ((IRemoteCallCompleteEvent) event)
- .getResponse();
- Trace.trace(Activator.PLUGIN_ID,
- "callSync.doStuff1 result=" + result);
- assertStringResultValid(result,TestServiceInterface1.TEST_SERVICE_STRING1);
- syncNotify();
- }
- }
- });
-
- syncWaitForNotify(REGISTER_WAIT);
- }
-
- public void testCallFuture() throws Exception {
- createServiceTrackerAndRegister();
-
- // Client - Get service references from service tracker
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValid(remoteReferences);
-
- final Object o = remoteReferences[0].getProperty(RemoteConstants.SERVICE_IMPORTED);
- assertNotNull(o);
- assertTrue(o instanceof IRemoteService);
- final IRemoteService rs = (IRemoteService) o;
- // Call asynchronously
- final IFuture futureResult = rs.callAsync(createRemoteCall());
-
- // now get result from futureResult
- final Object result = futureResult.get();
- Trace.trace(Activator.PLUGIN_ID, "callSync.doStuff1 result=" + result);
- assertStringResultValid(result, TestServiceInterface1.TEST_SERVICE_STRING1);
- }
-
- public void testFireAsync() throws Exception {
- createServiceTrackerAndRegister();
-
- // Client - Get service references from service tracker
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValid(remoteReferences);
-
- final Object o = remoteReferences[0].getProperty(RemoteConstants.SERVICE_IMPORTED);
- assertNotNull(o);
- assertTrue(o instanceof IRemoteService);
- final IRemoteService rs = (IRemoteService) o;
- // Call asynchronously
- rs.fireAsync(createRemoteCall());
- Thread.sleep(REGISTER_WAIT);
- }
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceRegisterTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceRegisterTest.java
deleted file mode 100644
index 56e703c6d..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractRemoteServiceRegisterTest.java
+++ /dev/null
@@ -1,242 +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.tests.osgi.services.remoteserviceadmin;
-
-import java.util.Properties;
-import java.util.Vector;
-
-import org.eclipse.ecf.core.ContainerFactory;
-import org.eclipse.ecf.core.ContainerTypeDescription;
-import org.eclipse.ecf.core.IContainer;
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.remoteservice.Constants;
-import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
-import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
-import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener;
-
-public abstract class AbstractRemoteServiceRegisterTest extends
- AbstractDistributionTest {
-
- protected static final int REGISTER_WAIT = 2000;
- private ServiceRegistration registration;
- protected Vector<RemoteServiceAdminEvent> remoteServiceAdminEvents = new Vector<RemoteServiceAdminEvent>();
-
- protected abstract String getServerContainerTypeName();
-
- protected void tearDown() throws Exception {
- remoteServiceAdminEvents.clear();
- // Then unregister
- if(registration != null) {
- registration.unregister();
- registration = null;
- }
- Thread.sleep(REGISTER_WAIT);
-
- super.tearDown();
-
- IContainer [] containers = getContainerManager().getAllContainers();
- for(int i=0; i < containers.length; i++) {
- containers[i].dispose();
- }
- getContainerManager().removeAllContainers();
-
- }
-
- protected void registerWaitAndUnregister(Properties props, boolean verifyRegistration) throws Exception {
- // Actually register with default service (IConcatService)
- registration = registerDefaultService(props);
- // Wait a while
- Thread.sleep(REGISTER_WAIT);
- // Verify
- if (verifyRegistration) {
- verifyRemoteServiceRegisteredWithServer();
- }
- }
-
- private void verifyRemoteServiceRegisteredWithServer() throws Exception {
- verifyRemoteServiceRegistered(getServerContainerAdapter(), getDefaultServiceClasses()[0]);
- }
-
- protected void verifyRemoteServiceRegistered(IRemoteServiceContainerAdapter adapter, String className) throws Exception {
- IRemoteServiceReference [] refs = adapter.getRemoteServiceReferences((ID[]) null, className, null);
- assertNotNull(refs);
- assertTrue(refs.length > 0);
- String[] objectClasses = (String[]) refs[0].getProperty(Constants.OBJECTCLASS);
- assertTrue(objectClasses != null);
- assertTrue(objectClasses.length > 0);
- assertTrue(objectClasses[0].equals(className));
- }
-
- private IRemoteServiceContainerAdapter getServerContainerAdapter() {
- if (this.server != null) return (IRemoteServiceContainerAdapter) this.server.getAdapter(IRemoteServiceContainerAdapter.class);
- IContainer [] containers = getContainerManager().getAllContainers();
- String containerType = getServerContainerTypeName();
- for(int i=0; i < containers.length; i++) {
- ContainerTypeDescription ctd = getContainerManager().getContainerTypeDescription(containers[i].getID());
- if (ctd != null && ctd.getName().equals(containerType)) return (IRemoteServiceContainerAdapter) containers[i].getAdapter(IRemoteServiceContainerAdapter.class);
- }
- return null;
- }
-
- public void testRegisterOnCreatedServer() throws Exception {
- Properties props = getServiceProperties();
- registerWaitAndUnregister(props, true);
- }
-
- private Properties getServiceProperties() {
- Properties props = new Properties();
- // Set config to the server container name/provider config name (e.g. ecf.generic.server)
- props.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, getServerContainerTypeName());
- // Set the service exported interfaces to all
- props.put(RemoteConstants.SERVICE_EXPORTED_INTERFACES, "*");
- return props;
- }
-
- public void testRegisterOnCreatedServerWithIdentity() throws Exception {
- Properties props = getServiceProperties();
- // set the container factory arguments to the server identity (e.g. ecftcp://localhost:3282/server)
- props.put(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_CONTAINER_FACTORY_ARGS, new String[] { getServerIdentity() } );
-
- props.put("customsvcprop1","foo");
- props.put("customsvcprop2", "bar");
- registerWaitAndUnregister(props, true);
- }
-
- public void testRegisterOnExistingServer() throws Exception {
- // Create server container
- this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
-
- Properties props = getServiceProperties();
-
- registerWaitAndUnregister(props, true);
- }
-
- public void testRegisterOnExistingServerWithIntents() throws Exception {
- // Create server container
- this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
-
- Properties props = getServiceProperties();
- // Add intents
- props.put(RemoteConstants.SERVICE_INTENTS, "passByValue");
- registerWaitAndUnregister(props, true);
- }
-
- public void testRegisterOnExistingServerWithMissingIntents() throws Exception {
- // Create server container
- this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
-
- Properties props = getServiceProperties();
- // Add intent that no one actually exposes
- props.put(RemoteConstants.SERVICE_INTENTS, "foobar");
- registerWaitAndUnregister(props, false);
- }
-
- public void testRegisterOnExistingServerWithExportedIntents() throws Exception {
- // Create server container
- this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
-
- Properties props = getServiceProperties();
- // Add intents
- props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS, "passByValue");
- registerWaitAndUnregister(props, true);
- }
-
- public void testRegisterOnExistingServerWithMissingExportedIntents() throws Exception {
- // Create server container
- this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
-
- Properties props = getServiceProperties();
- // Add intent that no one actually exposes
- props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS, "foobar");
- registerWaitAndUnregister(props, false);
- }
-
- public void testRegisterOnExistingServerWithExportedExtraIntents() throws Exception {
- // Create server container
- this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
-
- Properties props = getServiceProperties();
- // Add intents
- props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA, "passByValue");
- registerWaitAndUnregister(props, true);
- }
-
- public void testRegisterOnExistingServerWithMissingExportedExtraIntents() throws Exception {
- // Create server container
- this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
-
- Properties props = getServiceProperties();
- // Add intent that no one actually exposes
- props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA, "foobar");
- registerWaitAndUnregister(props, false);
- }
-
- public void testRegisterOnExistingServerWithContainerID() throws Exception {
- // Create server container
- this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),new Object[] {createServerID()});
-
- final Properties props = getServiceProperties();
- props.put(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_CONTAINER_ID, this.server.getID());
- registerWaitAndUnregister(props, true);
- }
-
- public void testRegisterOnExistingServerWithIdentity() throws Exception {
- // Create server container
- this.server = ContainerFactory.getDefault().createContainer(getServerContainerTypeName(),getServerIdentity());
-
- Properties props = getServiceProperties();
-
- registerWaitAndUnregister(props, true);
- }
-
- protected boolean containsEventType(int eventType) {
- for(RemoteServiceAdminEvent event: remoteServiceAdminEvents) if (event.getType() == eventType) return true;
- return false;
- }
-
- protected RemoteServiceAdminListener createRemoteServiceAdminListener() {
- return new RemoteServiceAdminListener() {
- public void remoteAdminEvent(RemoteServiceAdminEvent event) {
- System.out.println("remoteAdminEvent event="+event);
- remoteServiceAdminEvents.add(event);
- }
- };
- }
-
- public void testRemoteServiceAdminListener() throws Exception {
- RemoteServiceAdminListener listener = createRemoteServiceAdminListener();
- ServiceRegistration listenerReg = getContext().registerService(RemoteServiceAdminListener.class.getName(), listener, null);
-
- Properties props = getServiceProperties();
- registration = registerDefaultService(props);
- // Wait a while
- Thread.sleep(REGISTER_WAIT);
-
- assertTrue(remoteServiceAdminEvents.size() > 0);
- assertTrue(containsEventType(RemoteServiceAdminEvent.EXPORT_REGISTRATION));
-
- // Now bring down
- registration.unregister();
- registration = null;
-
- // Wait a while
- Thread.sleep(REGISTER_WAIT);
-
- assertTrue(remoteServiceAdminEvents.size() > 2);
- assertTrue(containsEventType(RemoteServiceAdminEvent.EXPORT_UNREGISTRATION));
-
- // finally unregister the listenerReg
- listenerReg.unregister();
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractTwoRemoteServiceAccessTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractTwoRemoteServiceAccessTest.java
deleted file mode 100644
index 54add6c4b..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractTwoRemoteServiceAccessTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Composent 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:
- * Composent - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
-
-import java.util.Properties;
-
-import org.eclipse.ecf.core.util.Trace;
-import org.eclipse.ecf.remoteservice.IRemoteCall;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.osgi.util.tracker.ServiceTracker;
-
-public abstract class AbstractTwoRemoteServiceAccessTest extends
- AbstractDistributionTest {
-
- protected static final int REGISTER_WAIT = Integer.parseInt(System.getProperty("waittime","15000"));
-
- private final String[] classes = new String[] { TestServiceInterface1.class.getName(), TestServiceInterface2.class.getName() };
-
- private ServiceTracker st;
- private ServiceRegistration registration;
-
- /* (non-Javadoc)
- * @see org.eclipse.ecf.tests.osgi.services.distribution.AbstractDistributionTest#tearDown()
- */
- protected void tearDown() throws Exception {
- // Unregister on server
- if (registration != null) {
- registration.unregister();
- registration = null;
- }
- if (st != null) {
- st.close();
- st = null;
- }
- Thread.sleep(REGISTER_WAIT);
-
- super.tearDown();
- }
-
- protected void createServiceTrackerAndRegister(String lookupClass, final Properties props) throws Exception {
- // Setup service tracker for client
- st = createProxyServiceTracker(lookupClass);
-
- // Actually register
- registration = registerService(classes,
- new TestService1(), props);
-
- // Wait
- Thread.sleep(REGISTER_WAIT);
- }
-
- protected void createServiceTrackerAndRegister(String lookupClass) throws Exception {
- createServiceTrackerAndRegister(lookupClass, getServiceProperties());
- }
-
- protected Properties getServiceProperties() {
- final Properties props = new Properties();
- props.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, getServerContainerName());
- props.put(RemoteConstants.SERVICE_EXPORTED_INTERFACES, "*");
- return props;
- }
-
- protected IRemoteCall createRemoteCall() {
- return new IRemoteCall() {
-
- public String getMethod() {
- return "doStuff1";
- }
-
- public Object[] getParameters() {
- return new Object[] {};
- }
-
- public long getTimeout() {
- return 30000;
- }
-
- };
- }
-
-
- public void testGetRemoteService1Reference() throws Exception {
- String lookupClass = TestServiceInterface1.class.getName();
- createServiceTrackerAndRegister(lookupClass);
-
- // Service Consumer - Get (remote) ervice references
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValidAndFirstHasCorrectType(remoteReferences, lookupClass);
- // Spec requires that the 'service.imported' property be set
- assertTrue(remoteReferences[0].getProperty(RemoteConstants.SERVICE_IMPORTED) != null);
- }
-
- public void testGetRemoteService2Reference() throws Exception {
- String lookupClass = TestServiceInterface2.class.getName();
- createServiceTrackerAndRegister(lookupClass);
-
- // Service Consumer - Get (remote) ervice references
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValidAndFirstHasCorrectType(remoteReferences, lookupClass);
- // Spec requires that the 'service.imported' property be set
- assertTrue(remoteReferences[0].getProperty(RemoteConstants.SERVICE_IMPORTED) != null);
- }
-
-
- public void testProxyWithService1() throws Exception {
- String lookupClass = TestServiceInterface1.class.getName();
- createServiceTrackerAndRegister(lookupClass);
-
- // Client - Get service references from service tracker
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValidAndFirstHasCorrectType(remoteReferences, lookupClass);
-
- // Get proxy/service
- final TestServiceInterface1 proxy = (TestServiceInterface1) getContext()
- .getService(remoteReferences[0]);
- assertNotNull(proxy);
- // Now use proxy
- final String result = proxy.doStuff1();
- Trace.trace(Activator.PLUGIN_ID, "proxy.doStuff1 result=" + result);
- assertTrue(TestServiceInterface1.TEST_SERVICE_STRING1.equals(result));
- }
-
- public void testProxyWithService2() throws Exception {
-
- String lookupClass = TestServiceInterface2.class.getName();
-
- createServiceTrackerAndRegister(lookupClass);
-
- // Client - Get service references from service tracker
- final ServiceReference[] remoteReferences = st.getServiceReferences();
- assertReferencesValidAndFirstHasCorrectType(remoteReferences, lookupClass);
-
- // Get proxy/service
- final TestServiceInterface2 proxy = (TestServiceInterface2) getContext()
- .getService(remoteReferences[0]);
- assertNotNull(proxy);
- // Now use proxy
- String result = proxy.doStuff1();
- Trace.trace(Activator.PLUGIN_ID, "proxy.doStuff1 result=" + result);
- assertTrue(TestServiceInterface1.TEST_SERVICE_STRING1.equals(result));
-
- // Now use proxy
- result = proxy.doStuff2();
- Trace.trace(Activator.PLUGIN_ID, "proxy.doStuff2 result=" + result);
- assertTrue(TestServiceInterface2.TEST_SERVICE_STRING2.equals(result));
-
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/Activator.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/Activator.java
deleted file mode 100644
index 64651403a..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/Activator.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class Activator implements BundleActivator {
-
- public static final String PLUGIN_ID = "org.eclipse.ecf.tests.osgi.services.remoteserviceadmin";
-
- private static BundleContext context;
- private static Activator instance;
-
- public BundleContext getContext() {
- return context;
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext bundleContext) throws Exception {
- Activator.context = bundleContext;
- instance = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext bundleContext) throws Exception {
- Activator.context = null;
- instance = null;
- }
-
- public static Activator getDefault() {
- return instance;
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointDescriptionFactoryTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointDescriptionFactoryTest.java
deleted file mode 100644
index 66f31f2ff..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointDescriptionFactoryTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.ecf.discovery.IServiceInfo;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.DiscoveredEndpointDescriptionFactory;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.ServiceInfoFactory;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
-
-public class EndpointDescriptionFactoryTest extends AbstractMetadataFactoryTest {
-
- protected void setUp() throws Exception {
- super.setUp();
- discoveryAdvertiser = getDiscoveryAdvertiser();
- Assert.isNotNull(discoveryAdvertiser);
- serviceInfoFactory = new ServiceInfoFactory();
- Assert.isNotNull(serviceInfoFactory);
- discoveryLocator = getDiscoveryLocator();
- Assert.isNotNull(discoveryLocator);
- endpointDescriptionFactory = new DiscoveredEndpointDescriptionFactory();
- Assert.isNotNull(endpointDescriptionFactory);
- }
-
- public void testCreateRequiredEndpointDescriptionFromServiceInfo() throws Exception {
- EndpointDescription published = createRequiredEndpointDescription();
- assertNotNull(published);
- IServiceInfo serviceInfo = createServiceInfoForDiscovery(published);
- assertNotNull(serviceInfo);
- org.osgi.service.remoteserviceadmin.EndpointDescription received = createEndpointDescriptionFromDiscovery(serviceInfo);
- assertNotNull(received);
- assertTrue(published.equals(received));
- }
-
- public void testCreateFullEndpointDescriptionFromServiceInfo() throws Exception {
- EndpointDescription published = createFullEndpointDescription();
- assertNotNull(published);
- IServiceInfo serviceInfo = createServiceInfoForDiscovery(published);
- assertNotNull(serviceInfo);
- org.osgi.service.remoteserviceadmin.EndpointDescription received = createEndpointDescriptionFromDiscovery(serviceInfo);
- assertNotNull(received);
- assertTrue(published.equals(received));
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointListenerTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointListenerTest.java
deleted file mode 100644
index af75cbbfa..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/EndpointListenerTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-import junit.framework.TestCase;
-
-public class EndpointListenerTest extends TestCase {
-
- private EndpointListener createEndpointListener() {
- return new EndpointListener() {
-
- public void endpointAdded(EndpointDescription endpoint,
- String matchedFilter) {
- System.out.println("endpointAdded endpoint="+endpoint+",matchedFilter="+matchedFilter);
- }
-
- public void endpointRemoved(EndpointDescription endpoint,
- String matchedFilter) {
- System.out.println("endpointRemoved endpoint="+endpoint+",matchedFilter="+matchedFilter);
- }
-
- };
- }
-
- public void testEndpointListenerNotification() throws Exception {
- Properties props = new Properties();
- props.put(org.osgi.service.remoteserviceadmin.EndpointListener.ENDPOINT_LISTENER_SCOPE,"("+RemoteConstants.ENDPOINT_ID+"=*)");
- ServiceRegistration endpointListenerRegistration = Activator.getDefault().getContext().registerService(EndpointListener.class.getName(), createEndpointListener(), (Dictionary) props);
- Thread.sleep(5000);
- endpointListenerRegistration.unregister();
- }
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java
deleted file mode 100644
index f1bb631f4..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/ServiceInfoFactoryTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Composent, Inc. 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:
- * Composent, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.ecf.discovery.IServiceInfo;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.ServiceInfoFactory;
-
-public abstract class ServiceInfoFactoryTest extends AbstractMetadataFactoryTest {
-
- protected void setUp() throws Exception {
- super.setUp();
- discoveryAdvertiser = getDiscoveryAdvertiser();
- Assert.isNotNull(discoveryAdvertiser);
- serviceInfoFactory = new ServiceInfoFactory();
- }
-
- public void testCreateServiceInfoFromMinimalEndpointDescription() throws Exception {
- IServiceInfo serviceInfo = createServiceInfoForDiscovery(createRequiredEndpointDescription());
- assertNotNull(serviceInfo);
- }
-
- public void testCreateServiceInfoFromFullEndpointDescription() throws Exception {
- IServiceInfo serviceInfo = createServiceInfoForDiscovery(createFullEndpointDescription());
- assertNotNull(serviceInfo);
- }
-
- public void testCreateBadOSGiEndpointDescription() throws Exception {
- try{
- createBadOSGiEndpointDescrption();
- fail();
- } catch (Exception e) {
- // this is test success
- }
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestService1.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestService1.java
deleted file mode 100644
index 40644d7d1..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestService1.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/****************************************************************************
- * Copyright (c) 2009 Jan S. Rellermeyer 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:
- * Jan S. Rellermeyer - initial API and implementation
- *****************************************************************************/
-package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
-
-public final class TestService1 implements TestServiceInterface1, TestServiceInterface2 {
-
- public String doStuff1() {
- return TestServiceInterface1.TEST_SERVICE_STRING1;
- }
-
- public String doStuff2() {
- return TestServiceInterface2.TEST_SERVICE_STRING2;
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestServiceInterface1.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestServiceInterface1.java
deleted file mode 100644
index 1de0f5c88..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestServiceInterface1.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/****************************************************************************
- * Copyright (c) 2009 Jan S. Rellermeyer 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:
- * Jan S. Rellermeyer - initial API and implementation
- *****************************************************************************/
-package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
-
-public interface TestServiceInterface1 {
-
- final static String TEST_SERVICE_STRING1 = "TestService1";
-
- String doStuff1();
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestServiceInterface2.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestServiceInterface2.java
deleted file mode 100644
index 313d22410..000000000
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/TestServiceInterface2.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/****************************************************************************
- * Copyright (c) 2009 Jan S. Rellermeyer 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:
- * Jan S. Rellermeyer - initial API and implementation
- *****************************************************************************/
-package org.eclipse.ecf.tests.osgi.services.remoteserviceadmin;
-
-public interface TestServiceInterface2 extends TestServiceInterface1 {
-
- public static final String TEST_SERVICE_STRING2 = "TestService2";
-
-
- String doStuff2();
-
-}

Back to the top